Elektruck

C3 with diff vel. 2 diff. notes

4 posts in this topic

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

You're welcome ;)

No it will not "struggle" but, this is just a way to handle the DOUT from MIDI Input, not to play something from a midi file. But this last thing is also possible.

Anyway this is very cool and fun :)

Best regards
Bruno


 

Edited by Antichambre

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now