mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
MidiFile: Allow reporting the type of parsed files
This commit is contained in:
parent
71bc141770
commit
1fb2203517
2 changed files with 17 additions and 4 deletions
|
|
@ -356,7 +356,9 @@ double MidiFile::getLastTimestamp() const
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
bool MidiFile::readFrom (InputStream& sourceStream, bool createMatchingNoteOffs)
|
||||
bool MidiFile::readFrom (InputStream& sourceStream,
|
||||
bool createMatchingNoteOffs,
|
||||
int* fileType)
|
||||
{
|
||||
clear();
|
||||
MemoryBlock data;
|
||||
|
|
@ -405,7 +407,12 @@ bool MidiFile::readFrom (InputStream& sourceStream, bool createMatchingNoteOffs)
|
|||
d += chunkSize;
|
||||
}
|
||||
|
||||
return size == 0;
|
||||
const auto successful = (size == 0);
|
||||
|
||||
if (successful && fileType != nullptr)
|
||||
*fileType = header.fileType;
|
||||
|
||||
return successful;
|
||||
}
|
||||
|
||||
void MidiFile::readNextTrack (const uint8* data, int size, bool createMatchingNoteOffs)
|
||||
|
|
@ -778,7 +785,9 @@ struct MidiFileTest : public UnitTest
|
|||
MemoryInputStream is (os.getData(), os.getDataSize(), false);
|
||||
MidiFile mf;
|
||||
|
||||
if (mf.readFrom (is))
|
||||
int fileType = 0;
|
||||
|
||||
if (mf.readFrom (is, true, &fileType))
|
||||
return mf;
|
||||
|
||||
return {};
|
||||
|
|
|
|||
|
|
@ -160,10 +160,14 @@ public:
|
|||
@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.
|
||||
@param midiFileType if not nullptr, the integer at this address will be set
|
||||
to 0, 1, or 2 depending on the type of the midi file
|
||||
|
||||
@returns true if the stream was read successfully
|
||||
*/
|
||||
bool readFrom (InputStream& sourceStream, bool createMatchingNoteOffs = true);
|
||||
bool readFrom (InputStream& sourceStream,
|
||||
bool createMatchingNoteOffs = true,
|
||||
int* midiFileType = nullptr);
|
||||
|
||||
/** 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue