*edit : replaced my large piece of code by a minimal complete issue
Hello, I need some help to build a midi file, here is what I want to do :
- Read a music (monophonic) file - OK
- Detect pitches and offsets - rougthly OK
- Translate to midi note number - OK
- Put note events in a midi file - KO
The final purpose is to create a "whistle to midi" app.
Here is a test code for midi writing (sorry for duplication and length), it compile and run but the midifile is unreadable by sequencers or synthetisers (vlc) :
MidiMessageSequence midiMessageSequence; midiMessageSequence.addEvent(MidiMessage::noteOn(1,69,1.0f), 1000.0f); midiMessageSequence.addEvent(MidiMessage::noteOff(1,69,1.0f), 4000.0f); midiMessageSequence.sort(); MidiFile midiFile; midiFile.setSmpteTimeFormat (25, 40); midiFile.addTrack(midiMessageSequence); File outputFile(commandParser.getOutputFileName()); FileOutputStream outputStream(outputFile); midiFile.writeTo(outputStream); outputStream.flush();
After searching for a long time I seems to fail at knowing how to put the events in the file and what events are necessary.
I also struggle dealing with timestamps.
I also want to know how to assign instruments to channels.
Can you help me please?
ps : OSX yosemite | Xcode 5 | introjucer
pps: sorry if bad english I'm french.