I think you do need to fill the waveform RAM to get sound?
At least in Mednafen...
Anyways, maybe it's time to share a little
Here is a basic function from my midi player that plays a single note:
void PlayNote(u8 chan, u16 freq, u8 vol) {
//Set up the frequency the channel will play
SND_REGS[chan].SxFQH = freq >> 8;
SND_REGS[chan].SxFQL = freq & 0xFF;
//Set the volume for the channel (0-15, same for left/right)
SND_REGS[chan].SxLRV = (vol << 4) | vol;
//Envelope for the channel (makes the tone fade out)
SND_REGS[chan].SxEV0 = 0xF7;
SND_REGS[chan].SxEV1 = 0x01;
//Start the channel without interval
SND_REGS[chan].SxINT = 0x9F;
}
Usage:
#include "audio.h"
#include "notes.h"
#include "voices.h"
//Copy the piano "instrument" to soundbank 1
copymem((void*)WAVEDATA1, (void*)PIANO, 128);
//Tell channel 0 to use soundbank 1
SND_REGS[0].SxRAM = 0;
//Play a "Middle-C" note on channel 0 with volume 8
PlayNote(0, C_4, 8);
The file "voices.h" includes a couple of different "instruments" that I made, to be loaded into the soundbanks.
The file "notes.h" defines all standard notes, fine-tuned manually to fit the VB's frequencies.
This should help you to get some tunes flowing
Just call PlayNote() with different note values (E_4, D_4, G_4 etc.) within your main loop (or better, on a timer interrupt)
Attach file:
audio.h Size: 2.72 KB; Hits: 77
notes.h Size: 3.50 KB; Hits: 79
voices.h Size: 1.25 KB; Hits: 63
Edited by DanB on 2011/1/3 21:25