diff options
author | Chris Xiong <chirs241097@gmail.com> | 2017-01-15 22:08:35 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2017-01-15 22:08:35 +0800 |
commit | 8a0d671e1a77c58142d0cbe82f40ee64bcae2be5 (patch) | |
tree | cb7ce958d02f2bb9e00581a56c28120800521a93 /core | |
parent | b7842ae90b28618affdad6977c9c814aa573a3fe (diff) | |
download | QMidiPlayer-8a0d671e1a77c58142d0cbe82f40ee64bcae2be5.tar.xz |
A little code refactoring.
Diffstat (limited to 'core')
-rw-r--r-- | core/qmpmidimapperrtmidi.cpp | 2 | ||||
-rw-r--r-- | core/qmpmidiplay.cpp | 6 | ||||
-rw-r--r-- | core/qmpmidiread.cpp | 4 |
3 files changed, 4 insertions, 8 deletions
diff --git a/core/qmpmidimapperrtmidi.cpp b/core/qmpmidimapperrtmidi.cpp index 9515a0b..2d4fc26 100644 --- a/core/qmpmidimapperrtmidi.cpp +++ b/core/qmpmidimapperrtmidi.cpp @@ -30,7 +30,7 @@ int qmpMidiMapperRtMidi::deviceInit(int id) ports[i]=new RtMidiOut(); ports[i]->openPort(id); } - catch(RtMidiError e) + catch(RtMidiError &e) { printf("Device initialization failure: %s\n",e.what()); ports[i]=NULL; diff --git a/core/qmpmidiplay.cpp b/core/qmpmidiplay.cpp index 1d32501..9cd7782 100644 --- a/core/qmpmidiplay.cpp +++ b/core/qmpmidiplay.cpp @@ -211,11 +211,7 @@ void CMidiPlayer::playEvents() if(resumed)resumed=false; else if(sendtime.count()<(midiFile->getEvent(tceptr)->time-ct)*dpt) -#if _WIN32 - w32usleep((midiFile->getEvent(tceptr)->time-ct)*(dpt/1000)); -#else std::this_thread::sleep_for(std::chrono::nanoseconds((midiFile->getEvent(tceptr)->time-ct)*dpt-sendtime.count())); -#endif if(tcstop||!midiFile)break; ct=midiFile->getEvent(tceptr)->time; } @@ -463,7 +459,7 @@ void CMidiPlayer::setChannelPreset(int ch,int b,int p) } //16MSB..LSB1 void CMidiPlayer::setBit(uint16_t &n, uint16_t bn, uint16_t b) -{n^=(-b^n)&(1<<bn);} +{n^=(((~b)+1)^n)&(1<<bn);} void CMidiPlayer::setMute(int ch,bool m) {setBit(mute,ch,m?1:0);} void CMidiPlayer::setSolo(int ch,bool s) diff --git a/core/qmpmidiread.cpp b/core/qmpmidiread.cpp index 58a9786..a8bdabb 100644 --- a/core/qmpmidiread.cpp +++ b/core/qmpmidiread.cpp @@ -209,7 +209,7 @@ int CMidiFile::chunkReader(int hdrXp) char hdr[6]; if(!fgets(hdr,5,f))error(1,"E: Unexpected EOF."); if(hdrXp) - if(strncmp(hdr,"MThd",4)){error(1,"E: Wrong MIDI header.");throw;} + if(strncmp(hdr,"MThd",4)){error(1,"E: Wrong MIDI header.");throw 1;} else return headerChunkReader(),0; else if(strncmp(hdr,"MTrk",4)) @@ -243,7 +243,7 @@ CMidiFile::CMidiFile(const char* fn,CMidiPlayer* par) std::sort(eventList.begin(),eventList.end(),cmp); par->maxtk=eventList[eventList.size()-1]->time; } - catch(int){fprintf(stderr,"E: %s is not a supported file.\n",fn);valid=0;} + catch(int&){fprintf(stderr,"E: %s is not a supported file.\n",fn);valid=0;} } CMidiFile::~CMidiFile() { |