![]() |
MIPI - Physical Interface for MIDI Files
|
#include <MidiFile.h>

Public Member Functions | |
| MidiFile (void) | |
| MidiFile (const std::string &filename) | |
| MidiFile (std::istream &input) | |
| MidiFile (const MidiFile &other) | |
| MidiFile (MidiFile &&other) | |
| ~MidiFile () | |
| MidiFile & | operator= (const MidiFile &other) |
| MidiFile & | operator= (MidiFile &&other) |
| bool | read (const std::string &filename) |
| bool | read (std::istream &instream) |
| bool | readBase64 (const std::string &base64data) |
| bool | readBase64 (std::istream &instream) |
| bool | readSmf (const std::string &filename) |
| bool | readSmf (std::istream &instream) |
| bool | write (const std::string &filename) |
| bool | write (std::ostream &out) |
| bool | writeBase64 (const std::string &out, int width=0) |
| bool | writeBase64 (std::ostream &out, int width=0) |
| std::string | getBase64 (int width=0) |
| bool | writeHex (const std::string &filename, int width=25) |
| bool | writeHex (std::ostream &out, int width=25) |
| bool | writeBinasc (const std::string &filename) |
| bool | writeBinasc (std::ostream &out) |
| bool | writeBinascWithComments (const std::string &filename) |
| bool | writeBinascWithComments (std::ostream &out) |
| bool | status (void) const |
| const MidiEventList & | operator[] (int aTrack) const |
| MidiEventList & | operator[] (int aTrack) |
| int | getTrackCount (void) const |
| int | getNumTracks (void) const |
| int | size (void) const |
| void | removeEmpties (void) |
| void | makeDeltaTicks (void) |
| void | setDeltaTicks (void) |
| void | deltaTicks (void) |
| void | makeAbsoluteTicks (void) |
| void | setAbsoluteTicks (void) |
| void | absoluteTicks (void) |
| int | getTickState (void) const |
| bool | isDeltaTicks (void) const |
| bool | isAbsoluteTicks (void) const |
| void | joinTracks (void) |
| void | splitTracks (void) |
| void | splitTracksByChannel (void) |
| int | getTrackState (void) const |
| int | hasJoinedTracks (void) const |
| int | hasSplitTracks (void) const |
| int | getSplitTrack (int track, int index) const |
| int | getSplitTrack (int index) const |
| void | sortTrack (int track) |
| void | sortTrackNoteOnsBeforeOffs (int track) |
| void | sortTrackNoteOffsBeforeOns (int track) |
| void | sortTracks (void) |
| void | sortTracksNoteOnsBeforeOffs (void) |
| void | sortTracksNoteOffsBeforeOns (void) |
| void | markSequence (void) |
| void | markSequence (int track, int sequence=1) |
| void | clearSequence (void) |
| void | clearSequence (int track) |
| int | addTrack (void) |
| int | addTrack (int count) |
| int | addTracks (int count) |
| void | deleteTrack (int aTrack) |
| void | mergeTracks (int aTrack1, int aTrack2) |
| int | getTrackCountAsType1 (void) |
| void | setMillisecondTicks (void) |
| int | getTicksPerQuarterNote (void) const |
| int | getTPQ (void) const |
| void | setTicksPerQuarterNote (int ticks) |
| void | setTPQ (int ticks) |
| void | doTimeAnalysis (void) |
| double | getTimeInSeconds (int aTrack, int anIndex) |
| double | getTimeInSeconds (int tickvalue) |
| double | getAbsoluteTickTime (double starttime) |
| int | getFileDurationInTicks (void) |
| double | getFileDurationInQuarters (void) |
| double | getFileDurationInSeconds (void) |
| int | linkNotePairsFIFO (void) |
| int | linkNotePairsLIFO (void) |
| int | linkNotePairs (void) |
| int | linkEventPairs (void) |
| void | clearLinks (void) |
| void | setFilename (const std::string &aname) |
| const char * | getFilename (void) const |
| MidiEvent * | addEvent (int aTrack, int aTick, std::vector< uchar > &midiData) |
| MidiEvent * | addEvent (MidiEvent &mfevent) |
| MidiEvent * | addEvent (int aTrack, MidiEvent &mfevent) |
| MidiEvent & | getEvent (int aTrack, int anIndex) |
| const MidiEvent & | getEvent (int aTrack, int anIndex) const |
| int | getEventCount (int aTrack) const |
| int | getNumEvents (int aTrack) const |
| void | allocateEvents (int track, int aSize) |
| void | erase (void) |
| void | clear (void) |
| void | clear_no_deallocate (void) |
| MidiEvent * | addNoteOn (int aTrack, int aTick, int aChannel, int key, int vel) |
| MidiEvent * | addNoteOff (int aTrack, int aTick, int aChannel, int key, int vel) |
| MidiEvent * | addNoteOff (int aTrack, int aTick, int aChannel, int key) |
| MidiEvent * | addController (int aTrack, int aTick, int aChannel, int num, int value) |
| MidiEvent * | addPatchChange (int aTrack, int aTick, int aChannel, int patchnum) |
| MidiEvent * | addTimbre (int aTrack, int aTick, int aChannel, int patchnum) |
| MidiEvent * | addPitchBend (int aTrack, int aTick, int aChannel, double amount) |
| void | setPitchBendRange (int aTrack, int aTick, int aChannel, double range) |
| MidiEvent * | addSustain (int aTrack, int aTick, int aChannel, int value) |
| MidiEvent * | addSustainPedal (int aTrack, int aTick, int aChannel, int value) |
| MidiEvent * | addSustainOn (int aTrack, int aTick, int aChannel) |
| MidiEvent * | addSustainPedalOn (int aTrack, int aTick, int aChannel) |
| MidiEvent * | addSustainOff (int aTrack, int aTick, int aChannel) |
| MidiEvent * | addSustainPedalOff (int aTrack, int aTick, int aChannel) |
| MidiEvent * | addMetaEvent (int aTrack, int aTick, int aType, std::vector< uchar > &metaData) |
| MidiEvent * | addMetaEvent (int aTrack, int aTick, int aType, const std::string &metaData) |
| MidiEvent * | addText (int aTrack, int aTick, const std::string &text) |
| MidiEvent * | addCopyright (int aTrack, int aTick, const std::string &text) |
| MidiEvent * | addTrackName (int aTrack, int aTick, const std::string &name) |
| MidiEvent * | addInstrumentName (int aTrack, int aTick, const std::string &name) |
| MidiEvent * | addLyric (int aTrack, int aTick, const std::string &text) |
| MidiEvent * | addMarker (int aTrack, int aTick, const std::string &text) |
| MidiEvent * | addCue (int aTrack, int aTick, const std::string &text) |
| MidiEvent * | addTempo (int aTrack, int aTick, double aTempo) |
| MidiEvent * | addKeySignature (int aTrack, int aTick, int fifths, bool mode=0) |
| MidiEvent * | addTimeSignature (int aTrack, int aTick, int top, int bottom, int clocksPerClick=24, int num32dsPerQuarter=8) |
| MidiEvent * | addCompoundTimeSignature (int aTrack, int aTick, int top, int bottom, int clocksPerClick=36, int num32dsPerQuarter=8) |
| uchar | readByte (std::istream &input) |
Static Public Member Functions | |
| static ushort | readLittleEndian2Bytes (std::istream &input) |
| static ulong | readLittleEndian4Bytes (std::istream &input) |
| static std::ostream & | writeLittleEndianUShort (std::ostream &out, ushort value) |
| static std::ostream & | writeBigEndianUShort (std::ostream &out, ushort value) |
| static std::ostream & | writeLittleEndianShort (std::ostream &out, short value) |
| static std::ostream & | writeBigEndianShort (std::ostream &out, short value) |
| static std::ostream & | writeLittleEndianULong (std::ostream &out, ulong value) |
| static std::ostream & | writeBigEndianULong (std::ostream &out, ulong value) |
| static std::ostream & | writeLittleEndianLong (std::ostream &out, long value) |
| static std::ostream & | writeBigEndianLong (std::ostream &out, long value) |
| static std::ostream & | writeLittleEndianFloat (std::ostream &out, float value) |
| static std::ostream & | writeBigEndianFloat (std::ostream &out, float value) |
| static std::ostream & | writeLittleEndianDouble (std::ostream &out, double value) |
| static std::ostream & | writeBigEndianDouble (std::ostream &out, double value) |
| static std::string | getGMInstrumentName (int patchIndex) |
Protected Attributes | |
| std::vector< MidiEventList * > | m_events |
| int | m_ticksPerQuarterNote = 120 |
| int | m_theTrackState = TRACK_STATE_SPLIT |
| int | m_theTimeState = TIME_STATE_ABSOLUTE |
| std::string | m_readFileName |
| bool | m_timemapvalid = false |
| std::vector< _TickTime > | m_timemap |
| bool | m_rwstatus = true |
| bool | m_linkedEventsQ = false |
Private Member Functions | |
| int | extractMidiData (std::istream &inputfile, std::vector< uchar > &array, uchar &runningCommand) |
| ulong | readVLValue (std::istream &inputfile) |
| ulong | unpackVLV (uchar a=0, uchar b=0, uchar c=0, uchar d=0, uchar e=0) |
| void | writeVLValue (long aValue, std::vector< uchar > &data) |
| int | makeVLV (uchar *buffer, int number) |
| void | buildTimeMap (void) |
| double | linearTickInterpolationAtSecond (double seconds) |
| double | linearSecondInterpolationAtTick (int ticktime) |
| std::string | base64Encode (const std::string &input) |
| std::string | base64Decode (const std::string &input) |
Static Private Member Functions | |
| static int | ticksearch (const void *A, const void *B) |
| static int | secondsearch (const void *A, const void *B) |
Static Private Attributes | |
| static const std::string | encodeLookup = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" |
| static const std::vector< int > | decodeLookup |
| static const char * | GMinstrument [128] |
| smf::MidiFile::MidiFile | ( | void | ) |
| smf::MidiFile::MidiFile | ( | const std::string & | filename | ) |

| smf::MidiFile::MidiFile | ( | std::istream & | input | ) |

| smf::MidiFile::MidiFile | ( | const MidiFile & | other | ) |
| smf::MidiFile::MidiFile | ( | MidiFile && | other | ) |
| smf::MidiFile::~MidiFile | ( | ) |

| void smf::MidiFile::absoluteTicks | ( | void | ) |

| MidiEvent * smf::MidiFile::addCompoundTimeSignature | ( | int | aTrack, |
| int | aTick, | ||
| int | top, | ||
| int | bottom, | ||
| int | clocksPerClick = 36, |
||
| int | num32dsPerQuarter = 8 |
||
| ) |

| MidiEvent * smf::MidiFile::addController | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel, | ||
| int | num, | ||
| int | value | ||
| ) |


| MidiEvent * smf::MidiFile::addCopyright | ( | int | aTrack, |
| int | aTick, | ||
| const std::string & | text | ||
| ) |

| MidiEvent * smf::MidiFile::addCue | ( | int | aTrack, |
| int | aTick, | ||
| const std::string & | text | ||
| ) |





| MidiEvent * smf::MidiFile::addInstrumentName | ( | int | aTrack, |
| int | aTick, | ||
| const std::string & | name | ||
| ) |

| MidiEvent * smf::MidiFile::addKeySignature | ( | int | aTrack, |
| int | aTick, | ||
| int | fifths, | ||
| bool | mode = 0 |
||
| ) |

| MidiEvent * smf::MidiFile::addLyric | ( | int | aTrack, |
| int | aTick, | ||
| const std::string & | text | ||
| ) |

| MidiEvent * smf::MidiFile::addMarker | ( | int | aTrack, |
| int | aTick, | ||
| const std::string & | text | ||
| ) |

| MidiEvent * smf::MidiFile::addMetaEvent | ( | int | aTrack, |
| int | aTick, | ||
| int | aType, | ||
| const std::string & | metaData | ||
| ) |

| MidiEvent * smf::MidiFile::addMetaEvent | ( | int | aTrack, |
| int | aTick, | ||
| int | aType, | ||
| std::vector< uchar > & | metaData | ||
| ) |


| MidiEvent * smf::MidiFile::addNoteOff | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel, | ||
| int | key | ||
| ) |

| MidiEvent * smf::MidiFile::addNoteOff | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel, | ||
| int | key, | ||
| int | vel | ||
| ) |

| MidiEvent * smf::MidiFile::addNoteOn | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel, | ||
| int | key, | ||
| int | vel | ||
| ) |

| MidiEvent * smf::MidiFile::addPatchChange | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel, | ||
| int | patchnum | ||
| ) |


| MidiEvent * smf::MidiFile::addPitchBend | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel, | ||
| double | amount | ||
| ) |

| MidiEvent * smf::MidiFile::addSustain | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel, | ||
| int | value | ||
| ) |


| MidiEvent * smf::MidiFile::addSustainOff | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel | ||
| ) |


| MidiEvent * smf::MidiFile::addSustainOn | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel | ||
| ) |


| MidiEvent * smf::MidiFile::addSustainPedal | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel, | ||
| int | value | ||
| ) |

| MidiEvent * smf::MidiFile::addSustainPedalOff | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel | ||
| ) |

| MidiEvent * smf::MidiFile::addSustainPedalOn | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel | ||
| ) |

| MidiEvent * smf::MidiFile::addTempo | ( | int | aTrack, |
| int | aTick, | ||
| double | aTempo | ||
| ) |

| MidiEvent * smf::MidiFile::addText | ( | int | aTrack, |
| int | aTick, | ||
| const std::string & | text | ||
| ) |

| MidiEvent * smf::MidiFile::addTimbre | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel, | ||
| int | patchnum | ||
| ) |

| MidiEvent * smf::MidiFile::addTimeSignature | ( | int | aTrack, |
| int | aTick, | ||
| int | top, | ||
| int | bottom, | ||
| int | clocksPerClick = 24, |
||
| int | num32dsPerQuarter = 8 |
||
| ) |


| int smf::MidiFile::addTrack | ( | int | count | ) |

| int smf::MidiFile::addTrack | ( | void | ) |


| MidiEvent * smf::MidiFile::addTrackName | ( | int | aTrack, |
| int | aTick, | ||
| const std::string & | name | ||
| ) |

| int smf::MidiFile::addTracks | ( | int | count | ) |

| void smf::MidiFile::allocateEvents | ( | int | track, |
| int | aSize | ||
| ) |
|
private |

|
private |

|
private |


| void smf::MidiFile::clear | ( | void | ) |


| void smf::MidiFile::clear_no_deallocate | ( | void | ) |


| void smf::MidiFile::clearLinks | ( | void | ) |

| void smf::MidiFile::clearSequence | ( | int | track | ) |

| void smf::MidiFile::clearSequence | ( | void | ) |

| void smf::MidiFile::deleteTrack | ( | int | aTrack | ) |

| void smf::MidiFile::deltaTicks | ( | void | ) |


| void smf::MidiFile::doTimeAnalysis | ( | void | ) |


| void smf::MidiFile::erase | ( | void | ) |

|
private |


| double smf::MidiFile::getAbsoluteTickTime | ( | double | starttime | ) |

| std::string smf::MidiFile::getBase64 | ( | int | width = 0 | ) |

| MidiEvent & smf::MidiFile::getEvent | ( | int | aTrack, |
| int | anIndex | ||
| ) |

| const MidiEvent & smf::MidiFile::getEvent | ( | int | aTrack, |
| int | anIndex | ||
| ) | const |
| int smf::MidiFile::getEventCount | ( | int | aTrack | ) | const |

| double smf::MidiFile::getFileDurationInQuarters | ( | void | ) |

| double smf::MidiFile::getFileDurationInSeconds | ( | void | ) |


| int smf::MidiFile::getFileDurationInTicks | ( | void | ) |


| const char * smf::MidiFile::getFilename | ( | void | ) | const |

|
static |

| int smf::MidiFile::getNumEvents | ( | int | aTrack | ) | const |

| int smf::MidiFile::getNumTracks | ( | void | ) | const |


| int smf::MidiFile::getSplitTrack | ( | int | index | ) | const |

| int smf::MidiFile::getSplitTrack | ( | int | track, |
| int | index | ||
| ) | const |

| int smf::MidiFile::getTicksPerQuarterNote | ( | void | ) | const |

| int smf::MidiFile::getTickState | ( | void | ) | const |

| double smf::MidiFile::getTimeInSeconds | ( | int | aTrack, |
| int | anIndex | ||
| ) |


| double smf::MidiFile::getTimeInSeconds | ( | int | tickvalue | ) |

| int smf::MidiFile::getTPQ | ( | void | ) | const |

| int smf::MidiFile::getTrackCount | ( | void | ) | const |


| int smf::MidiFile::getTrackCountAsType1 | ( | void | ) |

| int smf::MidiFile::getTrackState | ( | void | ) | const |

| int smf::MidiFile::hasJoinedTracks | ( | void | ) | const |
| int smf::MidiFile::hasSplitTracks | ( | void | ) | const |

| bool smf::MidiFile::isAbsoluteTicks | ( | void | ) | const |
| bool smf::MidiFile::isDeltaTicks | ( | void | ) | const |

| void smf::MidiFile::joinTracks | ( | void | ) |


|
private |


|
private |


| int smf::MidiFile::linkEventPairs | ( | void | ) |


|
inline |


| int smf::MidiFile::linkNotePairsFIFO | ( | void | ) |


| int smf::MidiFile::linkNotePairsLIFO | ( | void | ) |

| void smf::MidiFile::makeAbsoluteTicks | ( | void | ) |


| void smf::MidiFile::makeDeltaTicks | ( | void | ) |


|
private |

| void smf::MidiFile::markSequence | ( | int | track, |
| int | sequence = 1 |
||
| ) |

| void smf::MidiFile::markSequence | ( | void | ) |


| void smf::MidiFile::mergeTracks | ( | int | aTrack1, |
| int | aTrack2 | ||
| ) |


| MidiEventList & smf::MidiFile::operator[] | ( | int | aTrack | ) |
| const MidiEventList & smf::MidiFile::operator[] | ( | int | aTrack | ) | const |

| bool smf::MidiFile::read | ( | const std::string & | filename | ) |


| bool smf::MidiFile::read | ( | std::istream & | instream | ) |

| bool smf::MidiFile::readBase64 | ( | const std::string & | base64data | ) |

| bool smf::MidiFile::readBase64 | ( | std::istream & | instream | ) |

| uchar smf::MidiFile::readByte | ( | std::istream & | input | ) |

|
static |

|
static |

| bool smf::MidiFile::readSmf | ( | const std::string & | filename | ) |


| bool smf::MidiFile::readSmf | ( | std::istream & | instream | ) |

|
private |


| void smf::MidiFile::removeEmpties | ( | void | ) |
|
staticprivate |

|
inline |

|
inline |

| void smf::MidiFile::setFilename | ( | const std::string & | aname | ) |

| void smf::MidiFile::setMillisecondTicks | ( | void | ) |
| void smf::MidiFile::setPitchBendRange | ( | int | aTrack, |
| int | aTick, | ||
| int | aChannel, | ||
| double | range | ||
| ) |

| void smf::MidiFile::setTicksPerQuarterNote | ( | int | ticks | ) |

| void smf::MidiFile::setTPQ | ( | int | ticks | ) |

| int smf::MidiFile::size | ( | void | ) | const |


|
inline |

| void smf::MidiFile::sortTrackNoteOffsBeforeOns | ( | int | track | ) |

| void smf::MidiFile::sortTrackNoteOnsBeforeOffs | ( | int | track | ) |


|
inline |


| void smf::MidiFile::sortTracksNoteOffsBeforeOns | ( | void | ) |

| void smf::MidiFile::sortTracksNoteOnsBeforeOffs | ( | void | ) |


| void smf::MidiFile::splitTracks | ( | void | ) |


| void smf::MidiFile::splitTracksByChannel | ( | void | ) |

| bool smf::MidiFile::status | ( | void | ) | const |

|
staticprivate |

|
private |

| bool smf::MidiFile::write | ( | const std::string & | filename | ) |


| bool smf::MidiFile::write | ( | std::ostream & | out | ) |

| bool smf::MidiFile::writeBase64 | ( | const std::string & | out, |
| int | width = 0 |
||
| ) |


| bool smf::MidiFile::writeBase64 | ( | std::ostream & | out, |
| int | width = 0 |
||
| ) |

|
static |
|
static |
|
static |
|
static |
|
static |

|
static |

| bool smf::MidiFile::writeBinasc | ( | const std::string & | filename | ) |


| bool smf::MidiFile::writeBinasc | ( | std::ostream & | out | ) |

| bool smf::MidiFile::writeBinascWithComments | ( | const std::string & | filename | ) |


| bool smf::MidiFile::writeBinascWithComments | ( | std::ostream & | out | ) |

| bool smf::MidiFile::writeHex | ( | const std::string & | filename, |
| int | width = 25 |
||
| ) |


| bool smf::MidiFile::writeHex | ( | std::ostream & | out, |
| int | width = 25 |
||
| ) |

|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
private |

|
staticprivate |
|
staticprivate |
|
staticprivate |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |