in reply to Re^3: utf8 hash keys revisited: How can i use musical symbols as hash keys?
in thread utf8 hash keys revisited: How can i use musical symbols as hash keys?

"It's more extensible..."

Hi Jim,

sure, this is right - no doubt.

But don't you think that a "compound identifier" comes in more handy if you do the reverse mapping from Midi to Helmholtz like %midi_to_helmholtz = ( 70 => "a$sharp\/b$flat" );?

Best regards, Karl

P.S.: I skip the HoH approach for the moment, it is not the problem.

«The Crux of the Biscuit is the Apostrophe»

  • Comment on Re^4: utf8 hash keys revisited: How can i use musical symbols as hash keys?
  • Download Code

Replies are listed 'Best First'.
Re^5: utf8 hash keys revisited: How can i use musical symbols as hash keys?
by Jim (Curate) on Oct 07, 2014 at 22:47 UTC

    If maintaining a one-to-one relationship of %helmholtz_to_midi keys to %midi_to_helmholtz keys is an important requirement, then, yes, you have to do something kludgy like use a compound identifier. For example:

        $helmholtz_to_midi{'a♯¹/b♭¹'}{midi_note_number} = 70;
    

    and

        $midi_to_helmholtz{'70'}{helmholtz_note_name} = 'a♯¹/b♭¹';
    

    But the inescapable musical fact remains:  there isn't a one-to-one relationship of MIDI note numbers to Helmholtz note names. There's a one-to-many relationship, just as there's a one-to-many relationship of pitches (440 Hz) to enharmonic notes (g𝄪¹, a¹, b𝄫¹).