Jump to content

C3 with diff vel. 2 diff. notes


Elektruck
 Share

Recommended Posts

Hi,

I'm building a midi triggered snaredrum with solenoids controlled by a relay board wich is controlled by a stmf4 running MIDIO128 V3. To get some sort of velocity control I want to use different solenoids, micro's, 5N  and 20N strength. So when for example, C3, velocity 64 is played it will activate DOUT pin D01, and when C3, velocity 96 is played it will trigger DOUT pin D02 and when C3, velocity 127 is played it will trigger DOUT pin D03.

I hope someone can point me in the right direction how to achieve this. If someone knows how to do it in Ableton, change C3, velo 65 to C#3 for example then that would be cool too. I make midifiles in ableton and let them play by MIDIO128

Thanx

Link to comment
Share on other sites

I don't know running MIDIO128 but with a basic app (traditional) this is not complicated
 

/////////////////////////////////////////////////////////////////////////////
// This hook is called when a MIDI package has been received
/////////////////////////////////////////////////////////////////////////////
void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package)
{
  // check the note
  if( ((midi_package.event == NoteOn)||(midi_package.event == NoteOff)) && (midi_package.note == 0x3c)){ //only note C3
    // clear velocity if note Off
    if(midi_package.event == NoteOff)midi_package.velocity = 0;
    // check velocity
    switch(midi_package.velocity){
      case 0:
        MIOS32_DOUT_PinSet(0, 0);
        MIOS32_DOUT_PinSet(1, 0);
        MIOS32_DOUT_PinSet(2, 0);
      break;
      case 1 ... 64:
        MIOS32_DOUT_PinSet(0, 1);
      break;
      case 65 ... 96:
        MIOS32_DOUT_PinSet(1, 1);
      break;
      case 127:
        MIOS32_DOUT_PinSet(2, 1);
      break;
      default:
      break;
    }
  }
}


Best regards
Bruno

Link to comment
Share on other sites

Hi Bruno,

Thank you very much! Altough this is quite "abracadabra" to me, I managed to copy your example in the app.c file of the MIDIO128_v3 folder and after some troubleshooting it recompiled, and it works!

I can play C3's with different velocities and they're played by DOUTpin 0,1 and 2. I'll manage to expand this further to my needs. Only thing I'm a bit worried about, is that I just add a bit of code to the MIDIO128 app, and that this piece of code will "struggle" with the original app. Or shouln't this be a problem?!

Thanks anyway, I'm ways further to my goal now. HERE is an early vid of my experiments

Link to comment
Share on other sites

  • 4 months later...

Hi, it's been a while, but I'm still busy with this project. Till now I just used ableton to trigger the solenoinds through the midio128V3 box. But now I want to play them directly from the midifile on the midio128box. I don't know where to put the piece of code bruno gave me. I copied it in the app.c file and that works for the midi input of the midio128box. But, as Bruno said, it doen't work for the midifiles on the SD Card. I tried different things with routing, but I can't seem to route the midi events from the midifile to the midi input of the midio128box. So I looked further  in the "src" folder of the Midio128V3 app, that's where the app.c file is, and there are lots of other files. I copied it to seq.c, It complise but with no result. And I copied it to the mid_file.c, but that I can't compile cause "midi_package" is undeclared in this function.

I hope someone can give me some extra hints cause now I'm stuck again. Thanx!

Link to comment
Share on other sites

Events are read from midi file and scheduled by the seq_bpm(sequencer module) thru the seq.c file, sent to seq_midi_out(still sequencer module) and played from it.
You can modify the private hook which is installed by SEQ_MIDI_OUT_Callback_MIDI_SendPackage_Set and called by the scheduler.

This hook:

/////////////////////////////////////////////////////////////////////////////
// this hook is called when the MIDI scheduler sends a package
/////////////////////////////////////////////////////////////////////////////
static s32 Hook_MIDI_SendPackage(mios32_midi_port_t port, mios32_midi_package_t package)
{
  // realtime events are already scheduled by MIDI_ROUTER_SendMIDIClockEvent()
  if( package.evnt0 >= 0xf8 ) {
    MIOS32_MIDI_SendPackage(port, package);
  } else {
    // forward to MIDIO
    if( seq_play_enable_dout )
      MIDIO_DOUT_MIDI_NotifyPackage(port, package);

    // forward to enabled MIDI ports
    int i;
    u16 mask = 1;
    for(i=0; i<16; ++i, mask <<= 1) {
      if( seq_play_enabled_ports & mask ) {
	// USB0/1/2/3, UART0/1/2/3, IIC0/1/2/3, OSC0/1/2/3
	mios32_midi_port_t port = USB0 + ((i&0xc) << 2) + (i&3);
	MIOS32_MIDI_SendPackage(port, package);
      }
    }
  }

  return 0; // no error
}

But it seems this app was prepared for that purpose, have a look to the lines especially:

    // forward to MIDIO
    if( seq_play_enable_dout )
      MIDIO_DOUT_MIDI_NotifyPackage(port, package);


 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...