pxt-microbit icon indicating copy to clipboard operation
pxt-microbit copied to clipboard

micro:bit V1 tones and melody sound different after MakeCode V2

Open martinwork opened this issue 2 years ago • 1 comments

Describe the bug Arising from support ticket https://support.microbit.org/helpdesk/tickets/55444 (private)

Tones and melody on micro:bit V1 sound different compared to MakeCode V2. This zip has hex files built in MakeCode V2 and live melody.zip

I think the difference is that the volume variable and mapping introduced in MakeCode V3 limits the analogue value to 128, whereas MakeCode V2 used to set it to 512. v2: https://github.com/microsoft/pxt-microbit/blob/d18a5640c3e8676a71291980c07bbf67bc64c2a9/libs/core/pins.cpp#L309 Now: https://github.com/microsoft/pxt-microbit/blob/master/libs/core/pins.cpp#L353

The scenario in the ticket uses music.ringTone(40000) to drive an amplifier and ultrasound transmitters to levitate styrofoam particles, which stopped working when the hex was recompiled recently. The solution was to bypass music and set P0 directly.

To Reproduce Steps to reproduce the behavior:

  1. Connect speaker of headphone to P0
  2. Flash microbit-melody-mc2.hex
  3. Flash microbit-melody.hex
  4. Notice difference

Expected behavior Sound on micro:bit V1 unchanged.

micro:bit version (please complete the following information):

You can find this information in the lower right hand corner of the back of micro:bit (the side that says BBC micro:bit).

  • Which version of the micro:bit is this relevant to [ EG V1.3, V1.5, V2.0, or specify it's not hardware related ]

Tested with 1.3 and 1.5

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22]

martinwork avatar Jul 27 '22 12:07 martinwork

I think the reasoning iirc was that the default volume of 512 was dangerously loud when played over headphones. @pelikhan correct my if I'm wrong.

For this very specific program, I think this workaround is justified.

riknoll avatar Aug 03 '22 18:08 riknoll

I am assuming this is as designed? If not reopen.

abchatra avatar Sep 02 '22 17:09 abchatra