MIDI help

edited May 2009 in WTPA1 Mods
anyone have any experience with arduino midi out. I would like to add a control to the case for jitter as well as more easily accessing the other effects (single button presses). So here is what I came up with, it does not seem to be working, but I am also unsure about the wiring.


/******************************************************************************

* Read an analog input from a pot and generate MIDI cc commands.
******************************************************************************/


void setup() {
Serial.begin(31250);

}

void loop() {
midi_jitter(1, analogRead(0) / 8); //channel 1
delay(1);
}

void midi_jitter(byte channel, byte lev) {
Serial.print(0xB0 | (channel & 0xf), BYTE); // control change command
Serial.print(0x09, BYTE); // jitter CC
Serial.print(lev & 0x7f, BYTE); // 0-127
}



If anyone has any experience using the arduino for MIDI let me know if this looks ok.

Comments

  • My first impression is that you are using the variable powerPin but I don't see a definition, but you do define ringPin and never seem to use it.
  • A few of those pins were left over from my psuedo ring mod code, i have edited the code above so it contains just the jitter code. Basically the arduino reads a pot set up as a voltage divider hooked up to adc 0. it divides the result by 8 to get a number between 1 and 127 and then sends this to the midi in of the wtpa as a midi command with cc 9 (jitter). I am not sure how the jitter should sound so I do not know if it is working as it should. Does anyone have a sample or a description of what the jitter effect should sound like?

    I had a quesiton for todd - what exactly is happening when the jitter effect is called? I am thinking that there might be a way to implement this effect using the arduino alone (without midi).
  • Are you powering the Arduino with a USB cable or with an external power supply?
  • A change I would make -- I'd store the previous value of pin0 in a variable, & send the midi value only if it hasn't changed since the previous iteration -- i'm guessing that constantly sending a stream of MIDI might not be in your best interest...
  • That's true, too. I was headed down the path of trying to figure out if mateo is actually sending the serial bytes to his computer without realizing it.
  • ha... i think I have been. I was planning on hooking the arduino up to the bipolar supply that I have installed in the stpa case, however I have not done so yet. i will try it out and see how it goes.


    On the issue of constantly sending midi data, I guess you are probably right, that is another reason why I was asking how the jitter was implemented.

    thanks for the input guys.
  • serial transmission to the computer shouldn't be an issue. it will go to the FT232RL USB / TTL chip as well as pin1. You should be able to see the MIDI in both places. WRT where your arduino is getting its power from, this shouldn't matter as well due to the optoisolator at the MIDI input.

    Also, I assume you could just bypass the optoisolator if you're embedding them in the same case & powering them from the same supply, but if it's already built, I'm not sure why you'd bother...
  • @smrl: I use Arduino's for MIDI projects a lot and have noticed that if I have them attached by USB, the MIDI serial data coming out the TX pin doesn't always work. I think the scenario is this:
    -Attach the Arduino to computer with USB cable
    -Computer sees FTDI chip and communicates with it
    -FTDI chip sets it's baud rate based on what the Arduino IDE has been set to (or what Windows is set to in the case of a Windows PC)
    -The Arduino runs your code and tries to set the MIDI baud rate of 31250, which *sometimes* seems to be successful
    -When it is not successful, the data comes out at the wrong baud rate or not at all

    I've spent many hours scratching my head before thinking it through and powering externally, bypassing the FTDI chip, always seems to do the trick.
  • Hi all,
    The jitter message, like all MIDI commands to WTPA, should only be sent when you want the parameter to change. WTPA internally keeps track of state. Looks like you already know the following from reading your code, but for instance, if you want the jitter value to be 32, you would send a control change to the channel you're interested in, the control change number of the jitter effect, and then the jitter value (32 in this case). In the case of jitter, this serves to reshuffle the jitter array and move the sample pointer to the first chunk of RAM in the list.
    In the case of jitter, sending a constant stream of MIDI with the same CC value will just constantly reshuffle the array. This will sound like noise, or nothing, and will likely bog down the processor since the jitter calculations take some time.
    Finally, FWIW, WTPA implements running status. If you're just sending jitter MIDI, then you only need to send the status byte (CC and channel number) once.

    Hope this helps and good luck!
    Todd
Sign In or Register to comment.