Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Reset the seek pointer after parsing magic bytes on MIDI import.
Fixes a silent bug that prevented any and all SMF midi import due to the Alg_midifile_reader's parse() function erroneously reading bytes 4 to 7 instead of 0 to 3.
  • Loading branch information
irrenhaus3 committed Jul 26, 2018
commit 4e8b435dd2dba4b6742524778191593573568eeb
5 changes: 5 additions & 0 deletions include/ImportFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ class LMMS_EXPORT ImportFilter : public Plugin
return -1;
}

inline void resetReadPosition()
{
m_file.seek(0);
}

inline int readBlock( char * _data, int _len )
{
return m_file.read( _data, _len );
Expand Down
6 changes: 5 additions & 1 deletion plugins/MidiImport/MidiImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ bool MidiImport::tryImport( TrackContainer* tc )
}
#endif

switch( readID() )
auto id = readID();
// Reset the seek pointer on the file so the subsequent routines
// don't choke when trying to read the first 4 bytes again.
resetReadPosition();
switch( id )
{
case makeID( 'M', 'T', 'h', 'd' ):
printf( "MidiImport::tryImport(): found MThd\n");
Expand Down