Midi Thru with filters...I have it working as script but want to make an object

midi

#1

Beginner questions.

My new midi keyboard doesn't have zones, so I looked into getting the Ax to do that for me.
I've done a lot of coding, but nothing on the Ax before.

Here's the script, modded from a simple thru found on the forum ( I've looked for a MidiThru object, seen mention of it but can't find the actual file)

if (dev == MIDI_DEVICE_USB_HOST) {
uint8_t status_type = status & 0xF0;
uint8_t midi_ch = status & 0x0F;
uint8_t split_note = 0x3F;
uint8_t left_zone_ch= 0x01;
uint8_t right_zone_ch= 0x00;

if ((status_type == MIDI_CONTROL_CHANGE) ||
(status_type == MIDI_POLY_PRESSURE) ||
(status_type == MIDI_PITCH_BEND)) {
MidiSend3(MIDI_DEVICE_DIN,0,status,data1,data2);
} else if ((status_type == MIDI_PROGRAM_CHANGE) ||
(status_type == MIDI_CHANNEL_PRESSURE)) {
MidiSend2(MIDI_DEVICE_DIN,0,status,data1);
} else if ((status_type == MIDI_NOTE_OFF) ||
(status_type == MIDI_NOTE_ON)){
uint8_t status_ch = status;
if ( data1<split_note ) {
status_ch = status_type | left_zone_ch;
} else {
status_ch = status_type | right_zone_ch;
}
MidiSend3(MIDI_DEVICE_DIN,0,status_ch,data1,data2);
}
}

So it just sends the top half of the keyboard to Ch1, bottom half to Ch2. Any commands other than Notes keep their channel.

To some extent I can just work on the script do whatever want as regards octave shifts or whatever, but I'd like to make it configurable by midi Prog Ch for performance.

I read that the script obj is deprecated, and I want to be able to write to persistent variables.

So any pointers as to how to take the next step, which is presumably to move that code over to an object?

Where can I look at the functions and variables that will be in scope for the code in the objects?


Need a bit of help with MIDI forwarding
#2

just create a new object in the patcher and paste your code into the midi tab after opening the edit portion of the object. i think that should just work...


#3

thanks, I still need help with that though ;-(

Edit>New Object only seems to let me load existing objects


#4

try typing object in the search field, it should give you an empty object.


#5

Check this out for making new objects, etc.


#6

:slight_smile:
OK. Thanks for advice, I'm not quite there though.

"typing object in search field" always seems to find an object, not a blank canvas.
(otoh I now found a midi-thru object by a773...it's all learning)

The "Coding axoloti Objects" text has "create a patch/object object"....doesn't say how.

Doesn't seem to be a "Save As" option available if starting from an existing object.


#7

You create the the patch/object by typing object into the search bar... The object that loads IS the blank canvas. It's basically an empty object. Click the edit button to edit it with your code.

Good luck!


#8

hi Mattilyn,
thanks for helping.
I already followed lokki's instruction.
When I type into the search bar the editor loads an existing object.
e.g.
as soon as i type 'a' it loads a "logic AND' object.

So is that a bug? does it work for you?

....and there's no "save as" option, which would allow to create a new (copy) object without overwriting the original


#9

Something doesn't sound right, so try this:

Open a new patch and double click the background, type object into the search bar and you should see this:

Double click the highlighted patch/object and it should load the empty object and look like this:

Click the edit button on the object and that's where you put the code. Should look like this:

Use the tabs on the left to see where you can put the code, you'll prob want the midi tab.

Put your code in, close the object editor and test...
At this point your object is saved in the patch, not the library.
When it's working open the object editor and then from the top menu file/copy to library. Choose 'home' as the library, give it a name and save it. Now it should show in the object library for use in other patches.

Hope that works!


#10

Ahhh!
type "object", not object.
I was typing in the name of the object.

thankyou

Now how do I save it?
"Save as" doesn't exist.
"Save" is greyed out, although I don't in any case want to


#11

It automatically saves with the patch when you close the editor and save the patch. To save the object in the library for other patches, use 'copy to library' from the file menu in the object editor...


#12

Excellent.
Thankyou.

so if I save in 'contrib' will that be shared?

If so I won't put stuff 'under construction' in there.


#13

It won't be shared unless you set up stuff on github I think.