Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: utf8 hash keys revisited: How can i use musical symbols as hash keys?

by karlgoethebier (Abbot)
on Oct 07, 2014 at 17:16 UTC ( [id://1103097]=note: print w/replies, xml ) Need Help??


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𝄫¹).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1103097]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-26 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found