Jump to content

MIDIO128 alternate program change && forward input to output


uclaros
 Share

Recommended Posts

Hi all, especially TK.

It's been quite some time since I last posted here, and I must say I am very happy to see that the community keeps growing!

To the point:

Is it supposed that the midio128 'alternate program change' and 'forward input to output' work together at the same time?

I mean, when the input is forwarded to the output, if the input is a program change, will it trigger alternate program change??

I tried it on a minimal setup of a 'midio8' with mios1.9 and midio128 2.1c and it didn't seem to work correctly. (forward works, alternate PC works only via midi)

It would be a cool feature!

PS. This issue was a reason for me to check out the "C wrapper" that I hadn't shown much interest for before. Thorsten, honestly, words can't say how amazing work you've done!! The C wrapper is excelent for creating midi applications, like the switching unit I needed midio128 for. I wrote simple C code for it in 5 mins!!!

Link to comment
Share on other sites

Hi uclaros,

you are right - the two functions are not correlating well together, this is a corner case which never has been considered

But as you've already noticed, the usage of the C wrapper is so easy, that such dedicated functions should better be programmed directly. It gives everybody more freedom to do even more individual stuff. I'm glad that you were able to use it in such a short time! :)

Best Regards, Thorsten.

Link to comment
Share on other sites

Heya Uclaros, great to hear it was so easy for you :) Maybe you could share the code with us? The Wiki is a great place for putting things like this, and it makes life easier for those who do not have such programminmg skills as yourself.

You can setup your own user projects page and paste the code in there. If you don't have the time, I will be happy to upload it for you, just PM me and I'll give you my email address, and you can send the files to me.

Thanks!

Link to comment
Share on other sites

Well, my project is pretty simple and straightforward.

It is not for a midibox, it just uses the hardware as a switch for my amplifier's channels.

I wanted to control :

* 4 relays that controll optocouplers (circuit

* 4 LEDs (channel indicator on frontpanel)

* (1 relay and one LED is on at a time - 4 total channels)

and to control them with:

* 4 buttons (amp frontpanel)

* midi Program Change messages 1-4 (floorboard)

midio128 firmware was not adequate because of the inconsistency between midi and the frontpanel buttons.

My main.c changes consist of:

void Init(void) __wparam
{
  //**On Powerup**//
  // set shift register update frequency
  MIOS_SRIO_UpdateFrqSet(1); // ms
  // only one DOUTX4 module is connected
  MIOS_SRIO_NumberSet(1);
  // debouncing value for DINs
  MIOS_SRIO_DebounceSet(20);
  // turn channel 1 on on powerup
  MIOS_DOUT_PinSet(0x07, 1);
  MIOS_DOUT_PinSet(0x00, 1);
  // and transmit program change 1 for consistency with pedalboard
  MIOS_MIDI_TxBufferPut(0xc0);
  MIOS_MIDI_TxBufferPut(0x00);
}
void MPROC_NotifyReceivedEvnt(unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{
  //**On MIDI Recieve**//
  //only work if Program Change is received on channel 1
  if( evnt0 == 0xc0) {
  //only work if Program Change 1,2,3 or 4 is recieved
      if(evnt1 == 0x00 || evnt1 == 0x01 || evnt1 == 0x02 || evnt1 == 0x03) {
  //reset all pins
            MIOS_DOUT_PinSet(0x00, 0);
            MIOS_DOUT_PinSet(0x01, 0);
            MIOS_DOUT_PinSet(0x02, 0);
            MIOS_DOUT_PinSet(0x03, 0);
            MIOS_DOUT_PinSet(0x04, 0);
            MIOS_DOUT_PinSet(0x05, 0);
            MIOS_DOUT_PinSet(0x06, 0);
            MIOS_DOUT_PinSet(0x07, 0);
  //activate the recieved program change's pin to control the relay
            MIOS_DOUT_PinSet(evnt1, 1);
  //the following code is a strange workaround for my peculiar wiring of the leds
               if(evnt1 == 0x00) {
                                evnt1 = 0x07;
                                }
               if(evnt1 == 0x01) {
                                evnt1 = 0x04;
                                }
               if(evnt1 == 0x02) {
                                evnt1 = 0x05;
                                }
               if(evnt1 == 0x03) {
                                evnt1 = 0x06;
                                }
  //set the correct LED on
            MIOS_DOUT_PinSet(evnt1, 1);

      }
  }
}
void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam
{
  //**On Button Press**//
  //Only parse if button is pressed, not released
if (!pin_value) {
  MIOS_MIDI_TxBufferPut(0xc0); // Program Change at channel #1
  MIOS_MIDI_TxBufferPut(pin);  // just forward the pin number (0-3)

 //Reset relays and LEDs
            MIOS_DOUT_PinSet(0x00, 0);
            MIOS_DOUT_PinSet(0x01, 0);
            MIOS_DOUT_PinSet(0x02, 0);
            MIOS_DOUT_PinSet(0x03, 0);
            MIOS_DOUT_PinSet(0x04, 0);
            MIOS_DOUT_PinSet(0x05, 0);
            MIOS_DOUT_PinSet(0x06, 0);
            MIOS_DOUT_PinSet(0x07, 0);
  // Turn Relay ON
            MIOS_DOUT_PinSet(pin, 1);

  // Same workaround for my peculiar led wiring
               if(pin == 0x00) {
                                pin = 0x07;
                                }
               if(pin == 0x01) {
                                pin = 0x04;
                                }
               if(pin == 0x02) {
                                pin = 0x05;
                                }
               if(pin == 0x03) {
                                pin = 0x06;
                                }
  //turn the correct LED on
            MIOS_DOUT_PinSet(pin, 1);

 }
}

I know my code could be simpler but this is a proof that one should not be afraid to use the C wrapper if his C skills are not that good!

My app works fine and I hope that my amp will switch fine soon too !!!

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...