Skip to content

Commit

Permalink
Fix MIDI import encoding issue on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
PhysSong committed Jul 5, 2018
1 parent 1af0f08 commit 3e538d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions include/ImportFilter.h
Expand Up @@ -78,6 +78,11 @@ class EXPORT ImportFilter : public Plugin
return m_file.read( _data, _len );
}

inline QByteArray readAllData()
{
return m_file.readAll();
}

inline void ungetChar( char _ch )
{
m_file.ungetChar( _ch );
Expand Down
11 changes: 8 additions & 3 deletions plugins/MidiImport/MidiImport.cpp
Expand Up @@ -26,9 +26,12 @@
#include <QDomDocument>
#include <QDir>
#include <QApplication>
#include <QFile>
#include <QMessageBox>
#include <QProgressDialog>

#include <sstream>

#include "MidiImport.h"
#include "TrackContainer.h"
#include "InstrumentTrack.h"
Expand Down Expand Up @@ -279,8 +282,6 @@ class smfMidiChannel

bool MidiImport::readSMF( TrackContainer* tc )
{
QString filename = file().fileName();
closeFile();

const int preTrackSteps = 2;
QProgressDialog pd( TrackContainer::tr( "Importing MIDI-file..." ),
Expand All @@ -291,7 +292,11 @@ bool MidiImport::readSMF( TrackContainer* tc )

pd.setValue( 0 );

Alg_seq_ptr seq = new Alg_seq(filename.toLocal8Bit(), true);
std::stringstream stream;
QByteArray arr = readAllData();
stream.str(std::string(arr.constData(), arr.size()));

Alg_seq_ptr seq = new Alg_seq(stream, true);
seq->convert_to_beats();

pd.setMaximum( seq->tracks() + preTrackSteps );
Expand Down

0 comments on commit 3e538d5

Please sign in to comment.