Hi. I’m trying to create a plugin that plays .nsf-files (from Nintendo 8-bit). It’s using Nofrendo as emulator, and I looked at the winamp-plugin. I succeeded in creating an input plugin to play .sid-files with great help from Karl Kox. However my audio skills isn’t that great and I can’t get any sound from this plugin. This is the important part of the code I have right now:
FMOD_RESULT F_CALLBACK nsfopen(FMOD_CODEC_STATE *codec, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo)
nsf = nsf_load("C:\sid\super mario bros.nsf", 0, 0);
nsf_playtrack(nsf, nsf->current_song, 44100, 8, FALSE);
nsfwaveformat.channels = 2; nsfwaveformat.format = FMOD_SOUND_FORMAT_PCM16; nsfwaveformat.frequency = 44100; nsfwaveformat.blockalign = (16 >> 3) * nsfwaveformat.channels; nsfwaveformat.lengthpcm = 0xffffffff; //inifite length codec->numsubsounds = 1; /* number of 'subsounds'*/ codec->waveformat = &nsfwaveformat; codec->plugindata = 0; /* user data value */ return FMOD_OK;
FMOD_RESULT F_CALLBACK nsfread(FMOD_CODEC_STATE codec, void *buffer, unsigned int size, unsigned int *read)
/ do a frame’s worth of the music play routine */
/* get some samples */ nsf->process(buffer, codec->waveformat->blockalign); *read =16;
So with this code I only get an error from FMOD ("An invalid speaker was passed to this function based on the current speaker mode"). That *read=16 is just something I put there for now. Anyone has any ideas? Any obvious things?[/code]
- bLAZER asked 10 years ago
ok, I got the music sounding fine now BUT (and it’s a very big but) the music plays about 3 times too fast. It’s probably because I run the NES too fast. This is how the read callback looks like:
/* do a frame’s worth of the music play routine */
/* get some samples */
So how do I know when I should do a nes-frame? At the moment I’m obviously doing it to often.
I looked at a winamp plugin but there the user creates his own buffer and keep count of a lot of buffer things that fmod handles for me, so I really don’t know how to tackle this.
Please login first to submit.