Ticket #8637: softsynth.patch
File softsynth.patch, 3.9 KB (added by , 17 years ago) |
---|
-
ym2612.cpp
90 90 _specifiedSustainRate = instrument[24] & 31; 91 91 _specifiedSustainLevel = (instrument[28] >> 4) & 15; 92 92 _specifiedReleaseRate = instrument[28] & 15; 93 _state = _s_ready; // ËÜʪ¤Ç¤Ï¤É¤¦¤Ê¤Î¤«¤Ê?93 _state = _s_ready; 94 94 velocity(_velocity); 95 95 } 96 96 97 97 void Operator2612::keyOn() { 98 98 _state = _s_attacking; 99 99 _tickCount = 0; 100 _phase = 0; // ¤É¤¦¤â¡¢¼ÂºÝ¤³¤¦¤é¤·¤¤101 _currentLevel = ((int32)0x7f << 15); // ¤³¤ì¤â¡¢¼ÂºÝ¤³¤¦¤é¤·¤¤100 _phase = 0; 101 _currentLevel = ((int32)0x7f << 15); 102 102 } 103 103 104 104 void Operator2612::keyOff() { … … 116 116 if (r != 0) { 117 117 r = r * 2 + (keyscaleTable[freq/262205] >> (3-_keyScale)); 118 118 if (r >= 64) 119 r = 63; // ¤¹¤ë¤Ù¤¤Ê¤ó¤À¤í¤¦¤È¤Ï»×¤¦¤ó¤À¤±¤É (ÀÖp.207)119 r = 63; 120 120 } 121 121 122 122 r = 63 - r; … … 125 125 else { 126 126 value = powtbl[(r&3) << 7]; 127 127 value *= 1 << (r >> 2); 128 value *= 41; // r == 20 ¤Î¤È¤¡¢0-96[db] ¤¬ 10.01[ms] == 41.00096128 value *= 41; 129 129 value /= 1 << (15 + 5); 130 130 value *= 127 - _specifiedTotalLevel; 131 131 value /= 127; … … 156 156 if (r != 0) { 157 157 r = r * 2 + 1; // (Translated) I cannot know whether the timing is a good choice or not 158 158 r = r * 2 + (keyscaleTable[freq/262205] >> (3-_keyScale)); 159 // KS ¤Ë¤è¤ëÊäÀµ¤Ï¤¢¤ë¤é¤·¤¤¡£ÀÖp.206 ¤Ç¤Ïµ½Ò¤µ¤ì¤Æ¤Ê¤¤¤±¤É¡£159 // KS 160 160 if (r >= 64) 161 161 r = 63; 162 162 } … … 229 229 } 230 230 231 231 if (level < zero_level) { 232 int phaseShift = *phasebuf >> 2; // Àµ¤·¤¤ÊÑÄ´Î̤Ï? 3 ¤¸¤ã¾®¤µ¤¹¤®¤Ç 2 ¤¸¤ãÂ礤¤¤è¤¦¤Ê¡£232 int phaseShift = *phasebuf >> 2; 233 233 if (_feedbackLevel) 234 234 phaseShift += (output << (_feedbackLevel - 1)) / 1024; 235 235 output = sintbl[((_phase >> 7) + phaseShift) & 0x7ff]; 236 output >>= (level >> 18); // Àµ¤·¤¤¸º¿êÎ̤Ï?236 output >>= (level >> 18); 237 237 // Here is the original code, which requires 64-bit ints 238 238 // output *= powtbl[511 - ((level>>25)&511)]; 239 239 // output >>= 16; … … 438 438 } 439 439 440 440 void Voice2612::recalculateFrequency() { 441 // MIDI ¤È¤â°ã¤¦¤·....442 // ¤É¤¦¤¤¤¦»ÅÍͤʤó¤À¤í¤¦¤«?443 // ¤È»×¤Ã¤¿¤é¡¢¤Ê¤ó¤È¡¢¤³¤ì (¢) ¤¬Àµ²ò¤é¤·¤¤¡£441 // 442 // 443 // 444 444 int32 basefreq = frequencyTable[_note]; 445 445 int cfreq = frequencyTable[_note - (_note % 12)]; 446 446 int oct = _note / 12; 447 int fnum = (int) (((double)basefreq * (1 << 13)) / cfreq); // OPL ¤Î fnum ¤ÈƱ¤¸¤è¤¦¤Ê¤â¤Î¡£447 int fnum = (int) (((double)basefreq * (1 << 13)) / cfreq); 448 448 fnum += _frequencyOffs - 0x2000; 449 449 if (fnum < 0x2000) { 450 450 fnum += 0x2000; … … 455 455 oct++; 456 456 } 457 457 458 // _frequency ¤ÏºÇ½ªÅª¤Ë¥Ð¥¤¥¢¥¹ 256*1024 ÇÜ458 // 459 459 _frequency = (int) ((frequencyTable[oct*12] * (double)fnum) / 8); 460 460 461 461 int i; … … 515 515 } 516 516 517 517 void MidiChannel_YM2612::controlChange(byte control, byte value) { 518 // ¤¤¤¤¤Î¤«¤³¤ì¤Ç?518 // 519 519 if (control == 121) { 520 520 // Reset controller 521 521 removeAllVoices(); … … 537 537 } 538 538 539 539 void MidiChannel_YM2612::pitchBend(int16 value) { 540 // ¤¤¤¤¤Î¤«¤³¤ì¤Ç?540 // 541 541 Voice2612 *voice = _voices; 542 542 for (; voice; voice = voice->next) 543 543 voice->pitchBend(value); … … 696 696 0x03d5, 0x0410, 0x044e, 0x048f, 697 697 }; 698 698 699 // (int)(880.0 * 256.0 * pow(2.0, (note-0x51)/12.0)) ; // ¥Ð¥¤¥¢¥¹ 256 ÇÜ700 // 0x45 ¤¬ 440Hz (a4)¡¢0x51 ¤¬ 880Hz (a5) ¤é¤·¤¤699 // (int)(880.0 * 256.0 * pow(2.0, (note-0x51)/12.0)) 700 // 701 701 frequencyTable = new int [120]; 702 702 for (block = -1; block < 9; block++) { 703 703 for (i = 0; i < 12; i++) { … … 707 707 } 708 708 709 709 keycodeTable = new int [120]; 710 // detune Î̤η׻»¤ä KS ¤Ë¤è¤ë rate ÊÑ´¹¤Ë»È¤¦¤ó¤¸¤ã¤Ê¤¤¤«¤Ê710 // detune 711 711 for (block = -1; block < 9; block++) { 712 712 for (i = 0; i < 12; i++) { 713 713 // see p.204 … … 730 730 keyscaleTable[0] = 0; 731 731 for (freq = 1; freq < 8192; freq++) { 732 732 keyscaleTable[freq] = (int)(log((double)freq) / 9.03 * 32.0) - 1; 733 // 8368[Hz] (o9c) ¤Ç 32¤¯¤é¤¤¡£9.03 =:= ln 8368733 // 8368[Hz] (o9c) 734 734 } 735 735 } 736 736