MTC + SMPTE Problems


#1

Hi Juce forum! Does anyone know why Midi file generated by my program don’t open in Logic or other DAWs? I believe I must be setting the wrong SMPTE format settings as the juce documentation says 4,25 should be MTC not SMPTE right? Or do I just not understand what is going on at all.

[code]void SequenceToMidiManager::writePatternToMidiFile(MidiFile& newFile, Pattern pattern, int BPM){

MidiMessageSequence *seq = new MidiMessageSequence;

newFile.addTrack(*seq);
newFile.setSmpteTimeFormat (4, 25);
    

double ticks = 60.0/(double)BPM * 0.5 * i *1000;
double noteLength = (60.0/(double)BPM * 0.5 *1000);

int noteNumber = 36;
float velocity = 1.0;
  
addNoteToSequence(*seq, noteNumber, velocity, ticks, ticks+noteLength);
}

[/code]

[code] else if (button == &savePattern) {
FileChooser chooser(“Select Generated Sequence Destination”, File::nonexistent,
“mid”,
true);
chooser.browseForFileToSave(true);

       File midiFile = chooser.getResult();
       
       FileOutputStream outStream (midiFile);
       MidiFile output;
       writePatternToMidiFile(output, *pattern.getLast(), 120);
       output.writeTo(outStream);
   }[/code]

That’s all the code I have regarding writing midi files. Have I missed something critical?


#2

Got it, if anyone else ever has this problem this is the correct method, you need to set ticks per quarter note too.

[code]void SequenceToMidiManager::writePatternToMidiFile(MidiFile& newFile, Pattern pattern, int BPM){

MidiMessageSequence *seq = new MidiMessageSequence;

newFile.addTrack(*seq);
int tpq = 1000;
newFile.setSmpteTimeFormat (4, 25);
newFile.setTicksPerQuarterNote (tpq);
    

double ticks = 60.0/(double)BPM * 0.5 * i *1000;
double noteLength = (60.0/(double)BPM * 0.5 *1000);

int noteNumber = 36;
float velocity = 1.0;
  
addNoteToSequence(*seq, noteNumber, velocity, ticks, ticks+noteLength);
}

[/code]