ref: f6ce7dfea99cf32beb2afc8e7b02fb5f19f7544f
parent: f2f36117c889c19b643058a0af33070baf4b48be
author: Simon Howard <[email protected]>
date: Sat Aug 29 21:56:33 EDT 2009
Make some noise. Subversion-branch: /branches/opl-branch Subversion-revision: 1640
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -42,6 +42,8 @@
#include "opl.h"
#include "midifile.h"
+#define TEST
+
#define MAXMIDLENGTH (96 * 1024)
#define GENMIDI_NUM_INSTRS 128
@@ -405,6 +407,30 @@
}
}
+#ifdef TEST
+static void TestCallback(void *arg)
+{
+ opl_voice_t *voice = arg;
+ int note;
+ int wait_time;
+
+ // Set level:
+ WriteRegister(OPL_REGS_LEVEL + voice->op2, 0);
+
+ // Note off:
+
+ WriteRegister(OPL_REGS_FREQ_2 + voice->index, 0x00);
+ // Note on:
+
+ note = (rand() % (0x2ae - 0x16b)) + 0x16b;
+ WriteRegister(OPL_REGS_FREQ_1 + voice->index, note & 0xff);
+ WriteRegister(OPL_REGS_FREQ_2 + voice->index, 0x30 + (note >> 8));
+
+ wait_time = (rand() % 700) + 50;
+ OPL_SetCallback(wait_time, TestCallback, arg);
+}
+#endif
+
// Initialise music subsystem
static boolean I_OPL_InitMusic(void)
@@ -443,17 +469,19 @@
#ifdef TEST
{
+ int i;
opl_voice_t *voice;
+ int instr_num;
- voice = GetFreeVoice();
- SetVoiceInstrument(voice, &main_instrs[34].opl2_voice);
+ for (i=0; i<3; ++i)
+ {
+ voice = GetFreeVoice();
+ instr_num = rand() % 100;
- // Set level:
- WriteRegister(OPL_REGS_LEVEL + voice->op2, 0x94);
+ SetVoiceInstrument(voice, &main_instrs[instr_num].opl2_voice);
- // Note on:
- WriteRegister(OPL_REGS_FREQ_1 + voice->index, 0x65);
- WriteRegister(OPL_REGS_FREQ_2 + voice->index, 0x2b);
+ OPL_SetCallback(0, TestCallback, voice);
+ }
}
#endif