comparison data/fileio/MIDIFileReader.cpp @ 1038:cc27f35aa75c cxx11

Introducing the signed 64-bit frame index type, and fixing build failures from inclusion of -Wconversion with -Werror. Not finished yet.
author Chris Cannam
date Tue, 03 Mar 2015 15:18:24 +0000
parents 920699b6989d
children 26cf6d5251ec
comparison
equal deleted inserted replaced
1037:bf0e5944289b 1038:cc27f35aa75c
299 try { 299 try {
300 300
301 // Set file size so we can count it off 301 // Set file size so we can count it off
302 // 302 //
303 m_midiFile->seekg(0, ios::end); 303 m_midiFile->seekg(0, ios::end);
304 m_fileSize = m_midiFile->tellg(); 304 std::streamoff off = m_midiFile->tellg();
305 m_fileSize = 0;
306 if (off > 0) m_fileSize = off;
305 m_midiFile->seekg(0, ios::beg); 307 m_midiFile->seekg(0, ios::beg);
306 308
307 // Parse the MIDI header first. The first 14 bytes of the file. 309 // Parse the MIDI header first. The first 14 bytes of the file.
308 if (!parseHeader(getMIDIBytes(14))) { 310 if (!parseHeader(getMIDIBytes(14))) {
309 m_format = MIDI_FILE_BAD_FORMAT; 311 m_format = MIDI_FILE_BAD_FORMAT;
438 MIDIFileReader::parseTrack(unsigned int &lastTrackNum) 440 MIDIFileReader::parseTrack(unsigned int &lastTrackNum)
439 { 441 {
440 MIDIByte midiByte, metaEventCode, data1, data2; 442 MIDIByte midiByte, metaEventCode, data1, data2;
441 MIDIByte eventCode = 0x80; 443 MIDIByte eventCode = 0x80;
442 string metaMessage; 444 string metaMessage;
443 unsigned int messageLength; 445 long messageLength;
444 unsigned long deltaTime; 446 long deltaTime;
445 unsigned long accumulatedTime = 0; 447 long accumulatedTime = 0;
446 448
447 // The trackNum passed in to this method is the default track for 449 // The trackNum passed in to this method is the default track for
448 // all events provided they're all on the same channel. If we find 450 // all events provided they're all on the same channel. If we find
449 // events on more than one channel, we increment trackNum and record 451 // events on more than one channel, we increment trackNum and record
450 // the mapping from channel to trackNum in this channelTrackMap. 452 // the mapping from channel to trackNum in this channelTrackMap.
888 } 890 }
889 } 891 }
890 892
891 if (tracksToLoad.empty()) return 0; 893 if (tracksToLoad.empty()) return 0;
892 894
893 int n = tracksToLoad.size(), count = 0; 895 int n = int(tracksToLoad.size()), count = 0;
894 Model *model = 0; 896 Model *model = 0;
895 897
896 for (std::set<unsigned int>::iterator i = tracksToLoad.begin(); 898 for (std::set<unsigned int>::iterator i = tracksToLoad.begin();
897 i != tracksToLoad.end(); ++i) { 899 i != tracksToLoad.end(); ++i) {
898 900
936 model->setObjectName(QFileInfo(m_path).fileName()); 938 model->setObjectName(QFileInfo(m_path).fileName());
937 } 939 }
938 940
939 const MIDITrack &track = m_midiComposition.find(trackToLoad)->second; 941 const MIDITrack &track = m_midiComposition.find(trackToLoad)->second;
940 942
941 int totalEvents = track.size(); 943 int totalEvents = int(track.size());
942 int count = 0; 944 int count = 0;
943 945
944 bool sharpKey = true; 946 bool sharpKey = true;
945 947
946 for (MIDITrack::const_iterator i = track.begin(); i != track.end(); ++i) { 948 for (MIDITrack::const_iterator i = track.begin(); i != track.end(); ++i) {