Going from Midi Out Pin to PA2 via Hugo's script


#1

I try to send Midi from 1 board to another via the Midi Out Pin to PA3 with @Hugo's script...It doesn't work...does anyone know why? Sending from PA2 to PA3 with the script works...


#2

i just used hugos scripts a couple days ago and iirc they are by default configured to send from TX/RX to RX/TX of the other board, so PA2 to other board PA3 and PA3 to other board PA2. the JP2 connectors usually are not involved i think?


#3

I want to use the regular midi out because I want to use all the convenient midi objects, like midi thru, clock out etc.

So
Axo 1 regular midi out ---> Axo 2 PA3 script midi in

But maybe this doesnt work pin to pin...
For now I go PA2-PA3 but it's pain in the ass to forward like 20+cc values with this script objects and I haven't figured out how to send midi clock with the script...


#4

i worked on some hugo serial stuff, you can easily just have a small object on Axo1 that just fowards ALL midi data to PA2? for clock, you might have to add some code, eg from @a773 midithru_incl_clock object:

if ((status_type == MIDI_CONTROL_CHANGE) ||
                (status_type == MIDI_NOTE_OFF) ||
                (status_type == MIDI_NOTE_ON) ||
                (status_type == MIDI_POLY_PRESSURE) ||
                (status_type == MIDI_PITCH_BEND)) {
                    MidiSend3((midi_device_t) attr_output,status,data1,data2);
                    flash_cnt = FLASH_LEN;
            } else if ( (status_type == MIDI_PROGRAM_CHANGE) ||
                        (status_type == MIDI_CHANNEL_PRESSURE)) {
                MidiSend2((midi_device_t) attr_output,status,data1);
                flash_cnt = FLASH_LEN;
            } else if ((status == MIDI_TIMING_CLOCK) ||
      			(status == MIDI_START) ||
    				(status == MIDI_CONTINUE) ||
      			(status == MIDI_STOP)) {
    				MidiSend1((midi_device_t) attr_output,status);
  				}

#5

Ok thanks but where would I put this code? into the script part or the k-rate part? I didn't really understand how these objects in hugos examples work, or rather I don't get the connection between the script part and the object part.

I'm sorry, I'm quite diletantic with code I didn't get much further as copy pasting code from different objects together.

P.S. What I want more precisely is to forward all midi data from usb host port of axo 1 to axo 2, and have the midi clock out patchable like with the clock_tx object od drj.


#6

something like that would go in the sending object, top right in hugos midi script, on Axo1, to forward all USB or other incoming midi data to serial TX. then on Axo2 you have the top left script which just forwards all RX data to internal midi so on Axo2 you can then use all regular midi objects.
you need to kind of merge hugos script with a midi thru script. edit both the scrip and the embedded object midi code. if you have a day or two i can send the objects i made last week.

if you wanna alter/add midi clock on Axo1 to send to Axo2, you need some more ptaching. maybe there are clock-to-internal-midi objects? look into interal midi. cause anything you send to that egts caught by hugos sender object.

edit:
so heres the code to go into the "script", you need to add SendMidi1 according "midithru_incl_clock" object... or just copy the whole filtering from there, i left some stuff out iirc.

    void setup(){

    }

    void SendMidi3(uint8_t b0,uint8_t b1,uint8_t b2){
      sdPut(&SD2,b0);
      sdPut(&SD2,b1);
      sdPut(&SD2,b2);
    }
    void SendMidi2(uint8_t b0,uint8_t b1){
      sdPut(&SD2,b0);
      sdPut(&SD2,b1);
    }

    void loop(){
    //chThdSleepMilliseconds(10);
      if (this->trig){
      	uint8_t status_type = status & 0xF0;
      	if ( (status_type == MIDI_PROGRAM_CHANGE) ||
              (status_type == MIDI_CHANNEL_PRESSURE)){
              	SendMidi2(this->status,this->data1);
              }
         else SendMidi3(this->status,this->data1,this->data2);
      	LogTextMessage("Sending: %d - %d - %d",this->status,this->data1,this->data2);
      	this->trig2 = 1;
      }
     
      
    }

local data of the embedded object:

uint8_t bstatus, bdata1, bdata2;
uint8_t status, data1, data2;
bool trig, trig2, btrig;

attr_script
msg_t ThreadX2(){
  setup();
  while(!chThdShouldTerminate()){
     loop();
     chThdSleepMilliseconds(1);
  }
  chThdExit((msg_t)0);
}
static msg_t ThreadX(void *arg) {
((attr_parent *)arg)->ThreadX2();
}
WORKING_AREA(waThreadX, 1024);
Thread *Thd;

and k-rate of embedded script object:

    this->data1 = bdata1;
    this->data2 = bdata2;
    this->trig = btrig;
    if (this->trig2) { btrig = 0;this->trig2 = 0;}

this all might have some weird hacks and shit in there, it was working but i cahnged my mind, resorted to an usb chain and then crashed my whole system for 5 days. so good luck haha.


#7

Yes I already thoght something like this. It's just that these two layers, the object and the script part confuse me and I cannot use the copy and pasting that I usually do.

the thing is depending on the situation axo 1 generates a clock, or when there is one coming externally it uses the external clock and sends it to axo 2.
What I did now as work around is just send 24ppq and 4ppq as one bar counter


But I would really prefer to send normal midi clock.


I would be very happy to see what you have done. Maybe it would make me understand this script part a bit more

Edit: Oh very nice I apreciate that :pray:


#8

Hey there,

I don't really get midi through to work. Copy pasted the code you send me but there is no midi being forwarded.

midi thru.axp (9.9 KB)

As for the midi clock I just need something like something like this in the form of the script.