Ticket #8626: kyra_fmt_music_NOTELENGTH.patch
File kyra_fmt_music_NOTELENGTH.patch, 2.4 KB (added by , 18 years ago) |
---|
-
sound_towns.cpp
144 144 MidiParser_EuD(); 145 145 146 146 bool loadMusic (byte *data, uint32 unused = 0); 147 void setTempo(int32 tempo); 147 int32 calculateTempo(int16 val); 148 148 149 protected: 149 150 void parseNextEvent (EventInfo &info); 150 151 void resetTracking(); … … 155 156 byte * _adjVelo; 156 157 int8 * _adjNote; 157 158 159 byte _tempo[3]; 160 158 161 uint8 _firstBaseTickStep; 159 162 uint8 _nextBaseTickStep; 160 uint 8_initialTempo;163 uint32 _initialTempo; 161 164 uint32 _baseTick; 162 165 }; 163 166 … … 744 747 } 745 748 746 749 MidiParser_EuD::MidiParser_EuD() : MidiParser(), 747 _firstBaseTickStep(0x33), _nextBaseTickStep(0x33), _initialTempo(0x5a) { 750 _firstBaseTickStep(0x33), _nextBaseTickStep(0x33) { 751 _initialTempo = calculateTempo(0x5a); 748 752 } 749 753 750 754 void MidiParser_EuD::parseNextEvent(EventInfo &info) { … … 764 768 info.delta = (tick < last) ? 0 : (tick - last); 765 769 766 770 info.event = 0x90 | _channel[chan]; 767 info.length = pos[7] | (pos[8] << 4) ;771 info.length = pos[7] | (pos[8] << 4) | (pos[9] << 8) | (pos[10] << 12); 768 772 769 773 int8 note = (int8) pos[4]; 770 774 if (_adjNote[chan]) { … … 811 815 _nextBaseTickStep = pos[1]; 812 816 pos += 6; 813 817 } else if (cmd == 0xF8) { 814 int16 tempo = pos[4] | (pos[5] << 7); 815 setTempo(tempo); 818 int32 tempo = calculateTempo(pos[4] | (pos[5] << 7)); 819 info.event = 0xff; 820 info.length = 3; 821 info.ext.type = 0x51; 822 _tempo[0] = (tempo >> 16) & 0xff; 823 _tempo[1] = (tempo >> 8) & 0xff; 824 _tempo[2] = tempo & 0xff; 825 info.ext.data = (byte*) _tempo; 816 826 pos += 6; 827 break; 817 828 } else if (cmd == 0xFD || cmd == 0xFE) { 818 829 // End of track. 819 830 if (_autoLoop) … … 848 859 _adjNote = (int8*) data + 0x3D4; 849 860 850 861 _firstBaseTickStep = data[0x804]; 851 _initialTempo = (data[0x805] > 0xfc) ? 0x5a : data[0x805];862 _initialTempo = calculateTempo((data[0x805] > 0xfc) ? 0x5a : data[0x805]); 852 863 853 864 _num_tracks = 1; 854 865 _ppqn = 120; … … 860 871 return true; 861 872 } 862 873 863 void MidiParser_EuD::setTempo(int32 tempo) { 864 if (!tempo) { 865 MidiParser::setTempo(0); 866 return; 867 } 874 int32 MidiParser_EuD::calculateTempo(int16 val) { 875 int32 tempo = val; 868 876 869 877 if (tempo < 0) 870 878 tempo = 0; … … 876 884 tempo <<= 1; 877 885 tempo <<= 8; 878 886 879 MidiParser::setTempo(tempo);887 return tempo; 880 888 } 881 889 882 890 void MidiParser_EuD::resetTracking() {