Go Down

Topic: play & sync a midi file to external clock (Read 2 times) previous topic - next topic

deseipel

right away, nothing works.  And other code I had working before also doesn't work now.  I wonder if there's some conflict when trying to use both MIDI and MIDIFile libraries.  I can tell that setup is working, because I see those MIDI msgs come through (MIDIOX).  But when I send a MIDI message, I get nothing.  Everything is based on noteOn callbacks.  So Im' wondering if the MIDIfile library is conflicting with the MIDI library. 

marco_c

Leave the midifile library out and see if the NoteOn callback works.

I don't see any reason why the two libs can't work together as I originally was using the midi library as a way to send messages from midi file before I realized I could just send my own message through the serial port.

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

deseipel

yeah, my older code before I added the midifile code works fine.

If I have a MIDI noteOn callback, would it interfere with the MIDIfile handler, or does the MIDIfile handler only 'do stuff' for MIDI coming from the file on the sd card?

deseipel

my theory of operation is that when a note comes into the MIDI IN, the code will send a start command to the sequencer, which will begin playing the sequence of MIDI.  But I think I need a way to begin playing the MIDI file on the SD card as well.  And be in sync with the sequencer....



Here's some of my code that I'm scrutinizing:



Code: [Select]
void HandleClock(){
Sync();
}

void Sync() {


  int err;
  if (err != -1)
  {
    DEBUG("\nSMF load Error ");
    DEBUG(err);
    delay(WAIT_DELAY);
  }
  else
  {
    if (!SMF.isEOF())
    {
      SMF.getNextEvent();
    }
    else
    {
      SMF.restart();
      midiSilence();
    }
  }
}


//this handles changing the program number,up or down and also start/stop toggle.

void HandleNoteOn (byte channel, byte note, byte velocity){
  //if note X is sent, send program change control to go up
  if (note == 58 and velocity>0){
    if (S == 0){
      S==1;
      MIDI.sendRealTime(Start);
      //Sync();
     
        //char songname = "";
  char buffer [13];
  sprintf(buffer, "%d.MID", P);
  //  songname = const char(P) + ".mid";
  SMF.setFilename(buffer);  //DON'T NEED TO GET THE SONGNAME AT EACH CLOCK MESSAGE.
  SMF.load();
  //String songname;   //name of the current midi file
     
    }
    else
    {
      S==0;
      MIDI.sendRealTime(Stop);
    }

  }

deseipel

While I'm not sure exactly what the issue is with the code that previously worked, I think there's a more fundamental issue:  with my current setup, there's no way my arduino can receive the clock from my sequencer AND also read the incoming notes to trigger program changes (to flow to the sequencer). 

the flow of data, currently is   

(electronic drum)----->(Alesis IO [trigger to MIDI interface]) ------->  (Arduino MIDI IN/OUT, SD card)  --------->(KORG ES1 Sequencer).


But the KORG has MIDI IN/OUT/THRU, so I'll have to think about if that opens up another setup possibility.

Go Up