Go Down

Topic: PLEASE HELP!!!! (Read 1 time) previous topic - next topic

maxb6292

Hi guys,

I currently doing a project where I have force sensitive resistors (FSR) that I want to play a sound when pushed.  I need to get MIDI signals into garageband somehow and I don't know how to do that.  I am using the Serial - MIDI Converter that I got from http://www.spikenzielabs.com/SpikenzieLabs/Serial_MIDI.html and I'm not sure how to set it up because the directions are extremely vague.  I got it to a point where the serial RX box in the bottom right corner lights up red which means that the data is not MIDI formatted.  This might mean that I am also incorrectly setting up the inputs and outputs, I don't know.  I also need help figuring out how to then get that MIDI signal into Garageband so that when I push the FSR it plays a tone.

Any help would be greatly appreciated!!

Thanks

robtillaart

Welcome to the forum,

A more descriptive title would attract more people with possible solutions.
(99.9% is searching for help)

Your description is not clear enough for me to know what is wrong.
Maybe start explaining what part you find extremely vague?

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

maxb6292

I've gotten to the point where I need to set up the MIDI input and output.  Do I choose the things I set up in the IAC Driver? I did that however I am still not getting the signal to convert to MIDI (the RX box lights up red not green). 

maxb6292

This could also be due to the fact that I did not set up IAC Driver correctly.  Help on how to do that would also be appreciated. 

Grumpy_Mike

#4
Jan 03, 2015, 12:36 pm Last Edit: Jan 03, 2015, 12:45 pm by Grumpy_Mike
Quote
I got it to a point where the serial RX box in the bottom right corner lights up red which means that the data is not MIDI formatted. 
Sounds like you are not sending the correct numbers. If you need help with this then post the code you are running on the Arduino.

Here is some code just to fire some random MIDI notes off for testing:-
Code: [Select]


/* Midi note fire - Mike Cook March 2012
 *
 * -----------------
 * send MIDI serial data, automatically for a test
 *
###############################
*/
// Arduino pin assignments
#define midiChannel (byte)0

// Start of code
void setup() {
 //  Setup serial
   Serial.begin(57600);    // Serial MIDI speed
   programChange(0xc0, 14);  // Change MIDI voice

}

//********************* MAIN LOOP ***********************************

void loop() {
  int val;
  val = random(20,100);
    noteSend(0x90, val, 127);
    delay(200);
    noteSend(0x80, val, 127);
   delay(800);
    } // end loop function
   
//********************* Functions ***********************************


//  plays a MIDI note
 void noteSend(char cmd, char data1, char data2) {
  cmd = cmd | char(midiChannel);  // merge channel number
  Serial.write(cmd);
  Serial.write(data1);
  Serial.write(data2);
}
//  change the voice
 void programChange(char cmd, char data1) {
  cmd = cmd | char(midiChannel);  // merge channel number
  Serial.write(cmd);
  Serial.write(data1);
}

maxb6292

If you need help with this then post the code you are running on the Arduino.

Sorry, I am a beginner at arduinos in general.  This is the code that I have for the project.  I didn't write it so I don't know which part your'e looking for so I'll just post the whole thing.  
Code: [Select]

/***********HOBGOB ECLECTRONICS BeatSneaks code**************/

/*This code sends MIDI messages using electrical pulses from FSRs (Force Sensitive Resistors) placed in the heels and toes of a pair of sneakers.
It has been adapted from code by todbot, ladyada, spikenzielabs, and mschaff (ardrumo) - special thanks to X (wxs.ca)

You'll need to grab the Serial-MIDI Converter from spikenzielabs.com */
/************************************************************/

#define HEELTHRESHOLD 450
#define TOETHRESHOLD 350
#define LOWERHEELTHRESHOLD 150
#define LOWERTOETHRESHOLD 101   // We're setting both a lower and an upper threshold for the FSRs, so that they will only trigger a MIDI message when we actually want them too.
#define HEEL1PIN 0
#define HEEL2PIN 1
#define TOE1PIN 2
#define TOE2PIN 3
#define EXTRAPIN1 4
#define EXTRAPIN2 5              // Define which analog in pins on the arduino we'll be using
int LEDpin = 13;                           // Connect LED to pin 13
int pinNote[6] = {78,65,88,59,41,42};      // This array stores the different MIDI notes that each pin is assigned
boolean heel1 = false;
boolean heel2 = false;
boolean toe1 = false;
boolean toe2 = false;                      //These variables will help us to make sure we don't send multiple MIDI messages per single hit        

void setup(void) {
  Serial.begin(57600);                     // We'll send debugging information to the Serial monitor
  pinMode(LEDpin, OUTPUT);
}

void loop(void) {                                                                                                                  // This is the main function that executes all the others.
 heel1 = sender(analogRead(HEEL1PIN), HEEL1PIN, pinNote[HEEL1PIN], "HEEL1", heel1, HEELTHRESHOLD, LOWERHEELTHRESHOLD);

        heel2 = sender(analogRead(HEEL2PIN), HEEL2PIN, pinNote[HEEL2PIN], "HEEL2", heel2, HEELTHRESHOLD, LOWERHEELTHRESHOLD);
      
        toe1 = sender((analogRead(TOE1PIN)+100), TOE1PIN, pinNote[TOE1PIN], "TOE1", toe1, TOETHRESHOLD, LOWERTOETHRESHOLD);
      
        toe2 = sender((analogRead(TOE2PIN)+100), TOE2PIN, pinNote[TOE2PIN], "TOE2", toe2, TOETHRESHOLD, LOWERTOETHRESHOLD);         // We add some extra punch to the toe readings so that they'll sound about as loud as the heel
}

void midimsg(unsigned char message, unsigned char pitch, unsigned char velocity) {    // This function sends a MIDI message with a message, pitch, and velocity
    Serial.print(message);
    Serial.print(pitch);
    Serial.print(velocity);
}

boolean sender(int reading, int pin, int note, char msg[], boolean press, int threshold, int lowerthreshold ) {   // This function is what does all the work
  if(reading >= threshold) {                                                                                      // If the user stomps harder than a certain threshold...
    if(!press) {                                                                                                  // and if the sensor is not already in 'pressed' mode...
        reading = reading/8 - 1;                                                                                  // convert the FSR reading to a MIDI-friendly value
 digitalWrite(LEDpin, HIGH);      
 midimsg(144, note, reading);                                                                              // Send a MIDI message
 Serial.println(msg);                                                                                      // Send a unique debug message to the Serial monitor
        delay(30);
        digitalWrite(LEDpin, LOW);
     }  press = true;                                                                                             // The sensor is now in 'pressed' mode,
   } else if(reading <= lowerthreshold) {                                                                         // once the applied force sinks below the lower threshold...
 press = false;                                                                                    // the sensor is no longer in 'pressed' mode
        }
   return press;
}

Grumpy_Mike

Quote
I don't know which part your'e looking for so I'll just post the whole thing. 
Good choice.
As it is not your code I can tell you it is crap, and old crap at that.
Basically as it stands it does not output MIDI data at all, so don't expect it to. It will just send debug messages to the serial port, some of which are ASCII equivalent of MIDI messages. Others of which are just debug messages.

Did that code of mine send notes out to your system. If it did then we can work on fixing that code but until it does there is no point.

maxb6292

#7
Jan 05, 2015, 08:22 pm Last Edit: Jan 05, 2015, 08:30 pm by maxb6292
Yes your code worked and the RX box in the bottom right corner is lighting up green.  It is also playing tones when I open garageband.

Grumpy_Mike

#8
Jan 05, 2015, 10:03 pm Last Edit: Jan 05, 2015, 10:50 pm by Grumpy_Mike
OK in the midimsg function change all the Serial.print calls to Serial.write
Then in the sender function remove the Serial.println line.

Try again and report back.

maxb6292

Yes it worked.  Thank you so much!

Go Up