mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Midi: Adding matching note-offs for note-ons is now optional and be disabled via a parameter of MidiFile::readFrom
This commit is contained in:
parent
32a745d9f9
commit
b856e38d46
2 changed files with 12 additions and 6 deletions
|
|
@ -245,7 +245,7 @@ double MidiFile::getLastTimestamp() const
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
bool MidiFile::readFrom (InputStream& sourceStream)
|
||||
bool MidiFile::readFrom (InputStream& sourceStream, bool createMatchingNoteOffs)
|
||||
{
|
||||
clear();
|
||||
MemoryBlock data;
|
||||
|
|
@ -276,7 +276,7 @@ bool MidiFile::readFrom (InputStream& sourceStream)
|
|||
break;
|
||||
|
||||
if (chunkType == (int) ByteOrder::bigEndianInt ("MTrk"))
|
||||
readNextTrack (d, chunkSize);
|
||||
readNextTrack (d, chunkSize, createMatchingNoteOffs);
|
||||
|
||||
size -= (size_t) chunkSize + 8;
|
||||
d += chunkSize;
|
||||
|
|
@ -290,7 +290,7 @@ bool MidiFile::readFrom (InputStream& sourceStream)
|
|||
return false;
|
||||
}
|
||||
|
||||
void MidiFile::readNextTrack (const uint8* data, int size)
|
||||
void MidiFile::readNextTrack (const uint8* data, int size, bool createMatchingNoteOffs)
|
||||
{
|
||||
double time = 0;
|
||||
uint8 lastStatusByte = 0;
|
||||
|
|
@ -337,7 +337,9 @@ void MidiFile::readNextTrack (const uint8* data, int size)
|
|||
});
|
||||
|
||||
addTrack (result);
|
||||
tracks.getLast()->updateMatchedPairs();
|
||||
|
||||
if (createMatchingNoteOffs)
|
||||
tracks.getLast()->updateMatchedPairs();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -156,9 +156,13 @@ public:
|
|||
terms of midi ticks. To convert them to seconds, use the convertTimestampTicksToSeconds()
|
||||
method.
|
||||
|
||||
@param createMatchingNoteOffs if true, any missing note-offs for previous note-ons will
|
||||
be automatically added at the end of the file by calling
|
||||
MidiMessageSequence::updateMatchedPairs on each track.
|
||||
|
||||
@returns true if the stream was read successfully
|
||||
*/
|
||||
bool readFrom (InputStream& sourceStream);
|
||||
bool readFrom (InputStream& sourceStream, bool createMatchingNoteOffs = true);
|
||||
|
||||
/** Writes the midi tracks as a standard midi file.
|
||||
The midiFileType value is written as the file's format type, which can be 0, 1
|
||||
|
|
@ -180,7 +184,7 @@ private:
|
|||
OwnedArray<MidiMessageSequence> tracks;
|
||||
short timeFormat;
|
||||
|
||||
void readNextTrack (const uint8*, int size);
|
||||
void readNextTrack (const uint8*, int, bool);
|
||||
bool writeTrack (OutputStream&, const MidiMessageSequence&);
|
||||
|
||||
JUCE_LEAK_DETECTOR (MidiFile)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue