MidiSend{n}() functions confusion


#1

I'm confused about the MidiSend1, MidiSend2 and MidiSend3 functions.
In firmware/midi.h they are defined as
MidiSend3(midi_device_t dev, uint8_t port, uint8_t b0, uint8_t b1, uint8_t b2),
but in the AxoObjects the functions are used without the port parameter, e.g.
MidiSend3((midi_device_t) attr_device, MIDI_NOTE_ON + (attr_channel-1), lastnote, inlet_velo>>20)

I didn't find any macros or translation code, am I missing something?


#2

If you look attr_device you will see it's a pair of numbers. - this is because in the UI we combine device and port, partly as it only makes sense for USB host.


#3

Smart, makes definitely sense to combine them, little bit confusing though :slight_smile:


#4

yeah, its more a 'trick' than smart :slight_smile:

.... its a fun fact, that attributes can contain arbitrary code snippets, so are pretty flexible... and of course no performance overheads, since the code is inserted at compile time.


#5

True, quite versatile. I guess using a templating style like %device% instead of attr_device would have made that more clear, but the possibilities are the same.

Actually I just found a bug: in the object "sel/sel b 16 x2.axo" this templating style is used, I guess it missed the transition to inlet_, outlet_ and attr_ templates?


#6

as I said its a 'trick', we don't generally want users to think of attributes as templates, rather as 'fixed' compile time constants.... even that hopefully one day we can hide.

sel b 16... yup, that's old code indeed... I think, possibly, dating back to when the factory objects were generated in java, and then were transitioned - surprised its not been spotted before, obviously no one is using it :slight_smile: