pxt-microbit
pxt-microbit copied to clipboard
micro:bit V1 tones and melody sound different after MakeCode V2
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:
- Connect speaker of headphone to P0
- Flash microbit-melody-mc2.hex
- Flash microbit-melody.hex
- 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]
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.
I am assuming this is as designed? If not reopen.