#include <MIDIFileWriter.h>
Collaboration diagram for MIDIFileWriter:

This includes file write code for generic simultaneous-track MIDI files, but the conversion stage only supports a single-track MIDI file with fixed tempo, time signature and timing division.
Definition at line 43 of file MIDIFileWriter.h.
Public Member Functions | |
| MIDIFileWriter (QString path, NoteModel *model, float tempo=120.f) | |
| virtual | ~MIDIFileWriter () |
| virtual bool | isOK () const |
| virtual QString | getError () const |
| virtual void | write () |
Protected Types | |
| enum | MIDIFileFormatType { MIDI_SINGLE_TRACK_FILE = 0x00, MIDI_SIMULTANEOUS_TRACK_FILE = 0x01, MIDI_SEQUENTIAL_TRACK_FILE = 0x02, MIDI_FILE_BAD_FORMAT = 0xFF } |
| typedef std::vector< MIDIEvent * > | MIDITrack |
| typedef std::map< unsigned int, MIDITrack > | MIDIComposition |
Protected Member Functions | |
| std::string | intToMIDIBytes (int number) const |
| std::string | longToMIDIBytes (unsigned long number) const |
| std::string | longToVarBuffer (unsigned long number) const |
| unsigned long | getMIDITimeForTime (RealTime t) const |
| bool | writeHeader () |
| bool | writeTrack (int track) |
| bool | writeComposition () |
| bool | convert () |
Protected Attributes | |
| QString | m_path |
| NoteModel * | m_model |
| bool | m_modelUsesHz |
| float | m_tempo |
| int | m_timingDivision |
| MIDIFileFormatType | m_format |
| unsigned int | m_numberOfTracks |
| MIDIComposition | m_midiComposition |
| std::ofstream * | m_midiFile |
| QString | m_error |
typedef std::vector<MIDIEvent *> MIDIFileWriter::MIDITrack [protected] |
Definition at line 55 of file MIDIFileWriter.h.
typedef std::map<unsigned int, MIDITrack> MIDIFileWriter::MIDIComposition [protected] |
Definition at line 56 of file MIDIFileWriter.h.
enum MIDIFileWriter::MIDIFileFormatType [protected] |
| MIDI_SINGLE_TRACK_FILE | |
| MIDI_SIMULTANEOUS_TRACK_FILE | |
| MIDI_SEQUENTIAL_TRACK_FILE | |
| MIDI_FILE_BAD_FORMAT |
Definition at line 58 of file MIDIFileWriter.h.
| MIDIFileWriter::MIDIFileWriter | ( | QString | path, | |
| NoteModel * | model, | |||
| float | tempo = 120.f | |||
| ) |
Definition at line 40 of file MIDIFileWriter.cpp.
References convert(), SparseValueModel< PointType >::getScaleUnits(), m_error, and m_modelUsesHz.
| MIDIFileWriter::~MIDIFileWriter | ( | ) | [virtual] |
| bool MIDIFileWriter::isOK | ( | ) | const [virtual] |
Definition at line 70 of file MIDIFileWriter.cpp.
References m_error.
Referenced by MainWindow::exportLayer().
| QString MIDIFileWriter::getError | ( | ) | const [virtual] |
Definition at line 76 of file MIDIFileWriter.cpp.
References m_error.
Referenced by MainWindow::exportLayer().
| void MIDIFileWriter::write | ( | ) | [virtual] |
Definition at line 82 of file MIDIFileWriter.cpp.
References writeComposition().
Referenced by MainWindow::exportLayer().
| string MIDIFileWriter::intToMIDIBytes | ( | int | number | ) | const [protected] |
| string MIDIFileWriter::longToMIDIBytes | ( | unsigned long | number | ) | const [protected] |
| string MIDIFileWriter::longToVarBuffer | ( | unsigned long | number | ) | const [protected] |
| unsigned long MIDIFileWriter::getMIDITimeForTime | ( | RealTime | t | ) | const [protected] |
| bool MIDIFileWriter::writeHeader | ( | ) | [protected] |
Definition at line 162 of file MIDIFileWriter.cpp.
References intToMIDIBytes(), m_format, m_midiFile, m_numberOfTracks, m_timingDivision, and MIDIConstants::MIDI_FILE_HEADER.
Referenced by writeComposition().
| bool MIDIFileWriter::writeTrack | ( | int | track | ) | [protected] |
Definition at line 184 of file MIDIFileWriter.cpp.
References longToMIDIBytes(), longToVarBuffer(), m_midiComposition, m_midiFile, MIDIConstants::MIDI_CHNL_AFTERTOUCH, MIDIConstants::MIDI_CTRL_CHANGE, MIDIConstants::MIDI_FILE_META_EVENT, MIDIConstants::MIDI_NOTE_OFF, MIDIConstants::MIDI_NOTE_ON, MIDIConstants::MIDI_PITCH_BEND, MIDIConstants::MIDI_POLY_AFTERTOUCH, MIDIConstants::MIDI_PROG_CHANGE, MIDIConstants::MIDI_SYSTEM_EXCLUSIVE, and MIDIConstants::MIDI_TRACK_HEADER.
Referenced by writeComposition().
| bool MIDIFileWriter::writeComposition | ( | ) | [protected] |
Definition at line 278 of file MIDIFileWriter.cpp.
References m_error, m_midiFile, m_numberOfTracks, m_path, writeHeader(), and writeTrack().
Referenced by write().
| bool MIDIFileWriter::convert | ( | ) | [protected] |
Definition at line 314 of file MIDIFileWriter.cpp.
References Pitch::getPitchForFrequency(), SparseModel< PointType >::getSampleRate(), m_format, m_midiComposition, m_model, m_modelUsesHz, m_numberOfTracks, m_tempo, m_timingDivision, MIDIConstants::MIDI_CUE_POINT, MIDIConstants::MIDI_END_OF_TRACK, MIDIConstants::MIDI_FILE_META_EVENT, MIDIConstants::MIDI_NOTE_OFF, MIDIConstants::MIDI_NOTE_ON, MIDIConstants::MIDI_SET_TEMPO, MIDI_SINGLE_TRACK_FILE, and notes.
Referenced by MIDIFileWriter().
QString MIDIFileWriter::m_path [protected] |
NoteModel* MIDIFileWriter::m_model [protected] |
bool MIDIFileWriter::m_modelUsesHz [protected] |
float MIDIFileWriter::m_tempo [protected] |
int MIDIFileWriter::m_timingDivision [protected] |
MIDIFileFormatType MIDIFileWriter::m_format [protected] |
unsigned int MIDIFileWriter::m_numberOfTracks [protected] |
Definition at line 83 of file MIDIFileWriter.h.
Referenced by convert(), writeComposition(), and writeHeader().
MIDIComposition MIDIFileWriter::m_midiComposition [protected] |
Definition at line 85 of file MIDIFileWriter.h.
Referenced by convert(), writeTrack(), and ~MIDIFileWriter().
std::ofstream* MIDIFileWriter::m_midiFile [protected] |
Definition at line 87 of file MIDIFileWriter.h.
Referenced by writeComposition(), writeHeader(), and writeTrack().
QString MIDIFileWriter::m_error [protected] |
Definition at line 88 of file MIDIFileWriter.h.
Referenced by getError(), isOK(), MIDIFileWriter(), and writeComposition().
1.5.1