• R/O
  • SSH
  • HTTPS

mdr: Commit


Commit MetaInfo

Revision103 (tree)
Time2023-10-14 07:09:47
Authormateuszviste

Log Message

fixed mdr_opl_noteoff() so it does not mess up the currently playing frequency

Change Summary

Incremental Difference

--- trunk/opl/oplnotes.c (revision 102)
+++ trunk/opl/oplnotes.c (revision 103)
@@ -27,9 +27,12 @@
2727
2828 #include <mdr/opl.h>
2929
30+/* cache for currently playing notes, required for computing KEY-OFF events */
31+static unsigned char keyon_cache[9];
32+
3033 /* releases a note on selected voice. */
3134 void mdr_opl_noteoff(unsigned char voice) {
32- mdr_opl_regwr(0xB0 + voice, 0);
35+ mdr_opl_regwr(0xB0 + voice, keyon_cache[voice]);
3336 }
3437
3538
@@ -41,8 +44,9 @@
4144 *
4245 * The note will be kept "pressed" until mdr_opl_noteoff() is called. */
4346 void mdr_opl_noteon(unsigned char voice, unsigned short freq, enum mdr_opl_fgroup_t fgroup) {
47+ keyon_cache[voice] = fgroup | (freq >> 8);
4448 mdr_opl_regwr(0xA0 + voice, freq & 0xff); /* set lowfreq */
45- mdr_opl_regwr(0xB0 + voice, (freq >> 8) | fgroup | 32); /* KEY ON + hifreq + octave */
49+ mdr_opl_regwr(0xB0 + voice, keyon_cache[voice] | 32); /* KEY ON + hifreq + octave */
4650 }
4751
4852
@@ -49,6 +53,7 @@
4953 /* changes the frequency of the note currently playing on voice channel, this
5054 * can be used for pitch bending. */
5155 void mdr_opl_notebend(unsigned char voice, unsigned short freq, enum mdr_opl_fgroup_t fgroup) {
56+ keyon_cache[voice] = fgroup | (freq >> 8);
5257 mdr_opl_regwr(0xA0 + voice, freq & 0xff); /* set lowfreq */
5358 mdr_opl_regwr(0xB0 + voice, (freq >> 8) | fgroup); /* hifreq + octave */
5459 }
Show on old repository browser