0
0

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:

[code:3fugh2h0]
FMOD_RESULT F_CALLBACK nsfopen(FMOD_CODEC_STATE *codec, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo)
{
nsf_init();
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 */
nsf_frame(nsf);

/* get some samples */
nsf->process(buffer, codec->waveformat->blockalign);
*read =16;

}
[/code:3fugh2h0]
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]

  • You must to post comments
0
0

i think you need to set all members of your waveformat structure. You may have some uninitialized variables in there.

Also i’m pretty sure your numsubsounds should be 0 not 1.

  • You must to post comments
0
0

Same here as the .sid-plugin. Now it suddenly "works". It plays a lot of noise instead of giving me a strange error. Something strange was going on with my computer yesterday.

But now let’s try to get some music instead of noise….

  • You must to post comments
0
0

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:

[code:zx6jxl05]
/* do a frame’s worth of the music play routine */
nsf_frame(nsf);

/* get some samples */
apu_process(buffer, size);

*read=size;
return FMOD_OK;
[/code:zx6jxl05]
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.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.