svcore
1.9
|
#include <MIDIFileReader.h>
Public Member Functions | |
MIDIFileReader (QString path, MIDIFileImportPreferenceAcquirer *pref, sv_samplerate_t mainModelSampleRate, ProgressReporter *reporter=0) | |
virtual | ~MIDIFileReader () |
bool | isOK () const override |
Return true if the file appears to be of the correct type. More... | |
QString | getError () const override |
Model * | load () const override |
Read the file and return the corresponding data model. More... | |
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 |
typedef std::pair< RealTime, double > | TempoChange |
typedef std::map< unsigned long, TempoChange > | TempoMap |
Protected Member Functions | |
bool | parseFile () |
bool | parseHeader (const std::string &midiHeader) |
bool | parseTrack (unsigned int &trackNum) |
Model * | loadTrack (unsigned int trackNum, Model *existingModel=0, int minProgress=0, int progressAmount=100) const |
bool | consolidateNoteOffEvents (unsigned int track) |
void | updateTempoMap (unsigned int track) |
void | calculateTempoTimestamps () |
RealTime | getTimeForMIDITime (unsigned long midiTime) const |
int | midiBytesToInt (const std::string &bytes) |
long | midiBytesToLong (const std::string &bytes) |
long | getNumberFromMIDIBytes (int firstByte=-1) |
MIDIByte | getMIDIByte () |
std::string | getMIDIBytes (unsigned long bytes) |
bool | skipToNextTrack () |
Protected Attributes | |
bool | m_smpte |
int | m_timingDivision |
int | m_fps |
int | m_subframes |
MIDIFileFormatType | m_format |
unsigned int | m_numberOfTracks |
long | m_trackByteCount |
bool | m_decrementCount |
std::map< int, QString > | m_trackNames |
std::set< unsigned int > | m_loadableTracks |
std::set< unsigned int > | m_percussionTracks |
MIDIComposition | m_midiComposition |
TempoMap | m_tempoMap |
QString | m_path |
std::ifstream * | m_midiFile |
size_t | m_fileSize |
QString | m_error |
sv_samplerate_t | m_mainModelSampleRate |
MIDIFileImportPreferenceAcquirer * | m_acquirer |
Detailed Description
Definition at line 58 of file MIDIFileReader.h.
Member Typedef Documentation
|
protected |
Definition at line 74 of file MIDIFileReader.h.
|
protected |
Definition at line 75 of file MIDIFileReader.h.
|
protected |
Definition at line 76 of file MIDIFileReader.h.
|
protected |
Definition at line 77 of file MIDIFileReader.h.
Member Enumeration Documentation
|
protected |
Enumerator | |
---|---|
MIDI_SINGLE_TRACK_FILE | |
MIDI_SIMULTANEOUS_TRACK_FILE | |
MIDI_SEQUENTIAL_TRACK_FILE | |
MIDI_FILE_BAD_FORMAT |
Definition at line 79 of file MIDIFileReader.h.
Constructor & Destructor Documentation
MIDIFileReader::MIDIFileReader | ( | QString | path, |
MIDIFileImportPreferenceAcquirer * | pref, | ||
sv_samplerate_t | mainModelSampleRate, | ||
ProgressReporter * | reporter = 0 |
||
) |
Definition at line 59 of file MIDIFileReader.cpp.
References m_error, and parseFile().
|
virtual |
Definition at line 82 of file MIDIFileReader.cpp.
References m_midiComposition.
Member Function Documentation
|
overridevirtual |
Return true if the file appears to be of the correct type.
The DataFileReader will be constructed by passing a file path to its constructor. If the file can at that time be determined to be not of a type that this reader can read, it should return false in response to any subsequent call to isOK().
If the file is apparently of the correct type, isOK() should return true; if it turns out that the file cannot after all be read (because it's corrupted or the detection misfired), then the read() function may return NULL.
Implements DataFileReader.
Definition at line 99 of file MIDIFileReader.cpp.
References m_error.
Referenced by load().
|
overridevirtual |
Reimplemented from DataFileReader.
Definition at line 105 of file MIDIFileReader.cpp.
References m_error.
|
overridevirtual |
Read the file and return the corresponding data model.
This function is not expected to be thread-safe or reentrant. This function may be interactive (i.e. it's permitted to pop up dialogs and windows and ask the user to specify any details that can't be automatically extracted from the file).
Return NULL if the file cannot be parsed at all (although it's preferable to return a partial model and warn the user).
Caller owns the returned model and must delete it after use.
Implements DataFileReader.
Definition at line 802 of file MIDIFileReader.cpp.
References MIDIFileImportPreferenceAcquirer::getTrackImportPreference(), MIDIFileImportPreferenceAcquirer::ImportNothing, isOK(), loadTrack(), m_acquirer, m_loadableTracks, m_path, m_percussionTracks, m_trackNames, MIDIFileImportPreferenceAcquirer::MergeAllNonPercussionTracks, MIDIFileImportPreferenceAcquirer::MergeAllTracks, and MIDIFileImportPreferenceAcquirer::showError().
|
protected |
Definition at line 278 of file MIDIFileReader.cpp.
References calculateTempoTimestamps(), consolidateNoteOffEvents(), getMIDIBytes(), m_error, m_fileSize, m_format, m_loadableTracks, m_midiComposition, m_midiFile, m_numberOfTracks, m_path, m_trackByteCount, MIDI_FILE_BAD_FORMAT, parseHeader(), parseTrack(), skipToNextTrack(), SVDEBUG, updateTempoMap(), and MIDIException::what().
Referenced by MIDIFileReader().
|
protected |
Definition at line 395 of file MIDIFileReader.cpp.
References m_format, m_fps, m_numberOfTracks, m_smpte, m_subframes, m_timingDivision, MIDIConstants::MIDI_FILE_HEADER, midiBytesToInt(), midiBytesToLong(), and SVDEBUG.
Referenced by parseFile().
|
protected |
Definition at line 441 of file MIDIFileReader.cpp.
References MIDIEvent::getChannelNumber(), getMIDIByte(), getMIDIBytes(), getNumberFromMIDIBytes(), m_midiComposition, m_midiFile, m_percussionTracks, m_trackByteCount, m_trackNames, MIDIConstants::MIDI_CHANNEL_NUM_MASK, MIDIConstants::MIDI_CHNL_AFTERTOUCH, MIDIConstants::MIDI_CTRL_CHANGE, MIDIConstants::MIDI_END_OF_EXCLUSIVE, MIDIConstants::MIDI_FILE_META_EVENT, MIDIConstants::MIDI_MESSAGE_TYPE_MASK, MIDIConstants::MIDI_NOTE_OFF, MIDIConstants::MIDI_NOTE_ON, MIDIConstants::MIDI_PERCUSSION_CHANNEL, MIDIConstants::MIDI_PITCH_BEND, MIDIConstants::MIDI_POLY_AFTERTOUCH, MIDIConstants::MIDI_PROG_CHANGE, MIDIConstants::MIDI_STATUS_BYTE_MASK, MIDIConstants::MIDI_SYSTEM_EXCLUSIVE, MIDIConstants::MIDI_TRACK_NAME, and SVDEBUG.
Referenced by parseFile().
|
protected |
Definition at line 918 of file MIDIFileReader.cpp.
References NoteModel::add(), RealTime::frame2RealTime(), Pitch::getPitchLabel(), NoteModel::getSampleRate(), getTimeForMIDITime(), m_fps, m_mainModelSampleRate, m_midiComposition, m_path, m_smpte, m_subframes, MIDIConstants::MIDI_CHANNEL_PREFIX, MIDIConstants::MIDI_CHANNEL_PREFIX_OR_PORT, MIDIConstants::MIDI_CHNL_AFTERTOUCH, MIDIConstants::MIDI_COPYRIGHT_NOTICE, MIDIConstants::MIDI_CTRL_CHANGE, MIDIConstants::MIDI_CUE_POINT, MIDIConstants::MIDI_INSTRUMENT_NAME, MIDIConstants::MIDI_KEY_SIGNATURE, MIDIConstants::MIDI_LYRIC, MIDIConstants::MIDI_NOTE_OFF, MIDIConstants::MIDI_NOTE_ON, MIDIConstants::MIDI_PITCH_BEND, MIDIConstants::MIDI_POLY_AFTERTOUCH, MIDIConstants::MIDI_PROG_CHANGE, MIDIConstants::MIDI_SEQUENCE_NUMBER, MIDIConstants::MIDI_SEQUENCER_SPECIFIC, MIDIConstants::MIDI_SET_TEMPO, MIDIConstants::MIDI_SMPTE_OFFSET, MIDIConstants::MIDI_SYSTEM_EXCLUSIVE, MIDIConstants::MIDI_TEXT_EVENT, MIDIConstants::MIDI_TEXT_MARKER, MIDIConstants::MIDI_TIME_SIGNATURE, MIDIConstants::MIDI_TRACK_NAME, RealTime::realTime2Frame(), NoteModel::setCompletion(), NoteModel::setValueQuantization(), and SVDEBUG.
Referenced by load().
|
protected |
Definition at line 662 of file MIDIFileReader.cpp.
References m_midiComposition, MIDIConstants::MIDI_NOTE_OFF, and MIDIConstants::MIDI_NOTE_ON.
Referenced by parseFile().
|
protected |
Definition at line 711 of file MIDIFileReader.cpp.
References m_midiComposition, m_tempoMap, MIDIConstants::MIDI_SET_TEMPO, SVDEBUG, and RealTime::zeroTime.
Referenced by parseFile().
|
protected |
Definition at line 739 of file MIDIFileReader.cpp.
References RealTime::fromSeconds(), m_tempoMap, m_timingDivision, and RealTime::zeroTime.
Referenced by parseFile().
|
protected |
Definition at line 765 of file MIDIFileReader.cpp.
References RealTime::fromSeconds(), m_tempoMap, m_timingDivision, and RealTime::zeroTime.
Referenced by loadTrack().
|
protected |
Definition at line 126 of file MIDIFileReader.cpp.
Referenced by parseHeader().
|
protected |
Definition at line 111 of file MIDIFileReader.cpp.
Referenced by parseHeader(), and skipToNextTrack().
|
protected |
Definition at line 213 of file MIDIFileReader.cpp.
References getMIDIByte(), and m_midiFile.
Referenced by parseTrack().
|
protected |
Definition at line 143 of file MIDIFileReader.cpp.
References m_decrementCount, m_midiFile, and m_trackByteCount.
Referenced by getNumberFromMIDIBytes(), and parseTrack().
|
protected |
Definition at line 172 of file MIDIFileReader.cpp.
References m_decrementCount, m_midiFile, and m_trackByteCount.
Referenced by parseFile(), parseTrack(), and skipToNextTrack().
|
protected |
Definition at line 247 of file MIDIFileReader.cpp.
References getMIDIBytes(), m_decrementCount, m_midiFile, m_trackByteCount, MIDIConstants::MIDI_TRACK_HEADER, and midiBytesToLong().
Referenced by parseFile().
Member Data Documentation
|
protected |
Definition at line 112 of file MIDIFileReader.h.
Referenced by loadTrack(), and parseHeader().
|
protected |
Definition at line 113 of file MIDIFileReader.h.
Referenced by calculateTempoTimestamps(), getTimeForMIDITime(), and parseHeader().
|
protected |
Definition at line 114 of file MIDIFileReader.h.
Referenced by loadTrack(), and parseHeader().
|
protected |
Definition at line 115 of file MIDIFileReader.h.
Referenced by loadTrack(), and parseHeader().
|
protected |
Definition at line 116 of file MIDIFileReader.h.
Referenced by parseFile(), and parseHeader().
|
protected |
Definition at line 117 of file MIDIFileReader.h.
Referenced by parseFile(), and parseHeader().
|
protected |
Definition at line 119 of file MIDIFileReader.h.
Referenced by getMIDIByte(), getMIDIBytes(), parseFile(), parseTrack(), and skipToNextTrack().
|
protected |
Definition at line 120 of file MIDIFileReader.h.
Referenced by getMIDIByte(), getMIDIBytes(), and skipToNextTrack().
|
protected |
Definition at line 122 of file MIDIFileReader.h.
Referenced by load(), and parseTrack().
|
protected |
Definition at line 123 of file MIDIFileReader.h.
Referenced by load(), and parseFile().
|
protected |
Definition at line 124 of file MIDIFileReader.h.
Referenced by load(), and parseTrack().
|
protected |
Definition at line 125 of file MIDIFileReader.h.
Referenced by consolidateNoteOffEvents(), loadTrack(), parseFile(), parseTrack(), updateTempoMap(), and ~MIDIFileReader().
|
protected |
Definition at line 126 of file MIDIFileReader.h.
Referenced by calculateTempoTimestamps(), getTimeForMIDITime(), and updateTempoMap().
|
protected |
Definition at line 128 of file MIDIFileReader.h.
Referenced by load(), loadTrack(), and parseFile().
|
protected |
Definition at line 129 of file MIDIFileReader.h.
Referenced by getMIDIByte(), getMIDIBytes(), getNumberFromMIDIBytes(), parseFile(), parseTrack(), and skipToNextTrack().
|
protected |
Definition at line 130 of file MIDIFileReader.h.
Referenced by parseFile().
|
protected |
Definition at line 131 of file MIDIFileReader.h.
Referenced by getError(), isOK(), MIDIFileReader(), and parseFile().
|
protected |
Definition at line 132 of file MIDIFileReader.h.
Referenced by loadTrack().
|
protected |
Definition at line 134 of file MIDIFileReader.h.
Referenced by load().
The documentation for this class was generated from the following files:
Generated by 1.8.11