Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong notes in start/play melody #6012

Open
martinwork opened this issue Nov 16, 2024 · 2 comments
Open

Wrong notes in start/play melody #6012

martinwork opened this issue Nov 16, 2024 · 2 comments
Assignees

Comments

@martinwork
Copy link
Contributor

Describe the bug

Arising from https://www.reddit.com/r/microbit/comments/1gsly00/does_anyone_else_have_this_bug_where_it_plays/

Wrong notes can be heard in start/play melody in both simulator and hardware.

It seems to have changed between v4 and v5. Both old "start" and new "play" blocks are affected.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://makecode.microbit.org/v4
  2. Import https://makecode.microbit.org/_XmJJ4ab224b1
  3. Press A to hear melody - seems OK
  4. Try the same in v5, v6 or v7
  5. Hear incorrect beep towards the end
  6. Try v6 project in v6 or v7 https://makecode.microbit.org/_MKzbqwKCgAEg
  7. Hear error

Expected behavior
No wrong notes.

micro:bit version (please complete the following information):
V1 and V2

Desktop (please complete the following information):

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

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6] iPad
  • OS: [e.g. iOS8.1] iPadOS 18
  • Browser [e.g. stock browser, safari] Chrome
  • Version [e.g. 22]
@abchatra
Copy link
Collaborator

@riknoll fyi

@martinwork
Copy link
Contributor Author

Changing 23 to 24 in this calculation fixes the built in melodies

octave = Math.idiv((melody[i] - 23), 12)

The octave for each B (e.g. MIDI 0x53) is currently calculated to be the same as the C above it (e.g. MIDI 0x54)

So Melodies.Entertainer:
4a014b014c0154024c0154024c0154035401560157015801540156015802530156025404
has a b5 near the end
['d4:1','d#','e','c5:2','e4:1','c5:2','e4:1','c5:3','c:1','d','d#','e','c','d','e:2','b:1','d:2','c:4']
that should be a b4
['d4:1','d#','e','c5:2','e4:1','c5:2','e4:1','c5:3','c:1','d','d#','e','c','d','e:2','b4:1','d5:2','c:4']
as in MakeCode v4

return ['d4:1', 'd#', 'e', 'c5:2', 'e4:1', 'c5:2', 'e4:1', 'c5:3', 'c:1', 'd', 'd#', 'e', 'c', 'd', 'e:2', 'b4:1', 'd5:2', 'c:4'];

In the frequency calculation, octaves 1-8 are supported with note numbers C=1 to B=12

* @param octave The octave of the note (1 - 8)

The lowest supported note is c1 = MIDI 0x24=36. In fact I think b0 works, because it's note 12. . . 12 + (12 * (0 - 1))) = 0

Test: https://makecode.microbit.org/_8WmDKaLyqAax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants