Skip to content

midi: enharmonic equivalent notes no longer work #956

Open

Description

@sayomaki

Description

Since both letter_name_to_midi_note and letter_name_to_frequency has been moved out from the sound module into midi, it appears that a behavior change has happened, and enharmonic equivalent notes such as E#4 and Cb5 no longer work.

However, for double accidentals such as D##4, they fell through in the original sound implementation and produced the wrong note instead, and the decision of implementing it or not remains TBD.

I confirmed the behavior change in latest commit of modules, and reproducible in the sourceacademy.org deployment.

The midi module was introduced in f530275 (which is merged to master in ed1fe71)

Example

Unfortunately, using modules in the legacy js-slang runtime no longer works (and it also uses the newer midi module), and as such the original behavior can only be determined via older source code of sound here:

export function letter_name_to_midi_note(note: string): number {

Simple example to reproduce the error message in Source Academy:

from midi import letter_name_to_midi_note, letter_name_to_frequency

print(letter_name_to_midi_note("E#4"))
# letter_name_to_midi_note: Invalid Note with Octave: E#4
print(letter_name_to_frequency("Cb5"))
# letter_name_to_midi_note: Invalid Note with Octave: Cb5

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions