Permalink
Browse files

Fix MIDI import encoding issue on Windows

  • Loading branch information...
PhysSong committed Jun 4, 2018
1 parent 1af0f08 commit 3e538d510c135d6b6504298aa57135506397c708
Showing with 13 additions and 3 deletions.
  1. +5 −0 include/ImportFilter.h
  2. +8 −3 plugins/MidiImport/MidiImport.cpp
View
@@ -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 );
@@ -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"
@@ -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..." ),
@@ -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 );

0 comments on commit 3e538d5

Please sign in to comment.