Map midi number to note name

kmll's icon

I have not used gen before but I want to create a function for mapping midi number to note name. (Using these values: https://newt.phys.unsw.edu.au/jw/notes.html) I could implement this simply in javascript with an array but I believe gen is more efficient(?) and I think this would be a good occation for getting started with gen. However I am not sure where to start. I created a gen object with a codeBox and I tried to create an array but it seems like it is not regular C syntax(?) Any suggestions on where to begin will be appreciated.
(Or maybe this is the wrong use of gen(?)).

Dan Nigrin's icon

I can't help you on the Gen side of things, but you do know that a regular int object has two MIDI Display Format options that will show you MIDI note values?

kmll's icon

Thanks! I was not aware of this. Also I am not quite sure what you mean with "a regular int object", is this the [number] object?

(If there is an option using a prebuilt function for this I will obviously use this but I am still keen on starting to know gen so I am open for suggestions on how I could implement such a function in gen.)

Dan Nigrin's icon

Yes, number object, sorry. Just too accustomed to typing "i" and having it magically appear for me. :-)

kmll's icon

Thanks I was not aware of the "i" shortcut. Very useful:)

Looking on the [number] help file I could not find the reference to "MIDI Display Format options ". Can I please ask you to elaborate how I can use this display format?

Dan Nigrin's icon

In the number help file, click the "?" and choose "Open Reference" - in the Attributes section, you can read about all the various format options.

To actually select one of these format options, I use the Inspector - just highlight the number object in your patcher and open up the Inspector. There you'll see the ability to change the "Display Format" from a dropdown list.

kmll's icon

Brilliant:) Thanks again for pointing me in this direction!

(Since this is now solved I will open another thread regarding creating a generic gen function/gen usage).