0
0

One of my users is a little unhappy with the default linear resampler and asked to add the ability to change it for his game. So I added it in and even though I get no error, there is no audible difference. Like either it does not work internally or my settings are incompatible with it. Here is the code.

[code:2aq47frf]
FMOD_DSP_RESAMPLER samplemethod = (FMOD_DSP_RESAMPLER)1;
double FMODInternalSetResampler(FMOD_DSP_RESAMPLER resamplemethod)
{
//no need if(!inited) {{FMODASSERT(FMOD_ERR_INITIALIZATION);}}

if(resamplemethod>= FMOD_DSP_RESAMPLER_MAX) {{FMODASSERT(FMOD_ERR_INVALID_PARAM);}}
if(resamplemethod<0) {{FMODASSERT(FMOD_ERR_INVALID_PARAM);}}
int samplerate;
FMOD_SOUND_FORMAT format;
int numoutputchannels;
int maxinputchannels;
FMOD_DSP_RESAMPLER rm;
int bits;

FMODASSERT(FMOD_System_GetSoftwareFormat(mainsystem,
    &samplerate,
    &format,
    &numoutputchannels,
    &maxinputchannels,
    &rm,
    &bits));

FMODASSERT(FMOD_System_SetSoftwareFormat(mainsystem,
    samplerate,
    format,
    numoutputchannels,
    maxinputchannels,
    (FMOD_DSP_RESAMPLER) (DWORD)resamplemethod));
return (double)1;

}
[/code:2aq47frf]

[code:2aq47frf]
export double FMODinit(double maxsounds, double supportwebfiles)
{
if(inited) {FMODASSERT(FMOD_ERR_INITIALIZED);}

pds_list_add = (GMPROC*) GetProcAddress("ds_list_add");
//init_ds_list_add();

memset(curpassword,0,256);
memset(samplebuffer,0,16384*sizeof(float));
memset(tagname,0,2048);
memset(tagdata,0,2048);

FMOD_RESULT result;
 unsigned int     version;
FMOD_SPEAKERMODE speakermode;
FMOD_CAPS        caps;
int              numdrivers;


/*
    Create a System object and initialize.
*/

FMODASSERT(FMOD_System_Create(&mainsystem));        // Create the main system object.

FMODASSERT(FMOD_System_GetVersion(mainsystem,&version));

if (version < FMOD_VERSION)
{
    MessageBeep(MB_ICONWARNING);
    MessageBoxA(GetActiveWindow(),"initFMOD-Incompatible fmodex.dll found. It's possible another game or product is running using and older version of this dll or the supplied fmod dll is incompatible.", "FMOD Error", MB_ICONSTOP);
    FMODASSERT(FMOD_ERR_VERSION);
}
FMODASSERT(FMOD_System_GetNumDrivers(mainsystem,&numdrivers));

if (numdrivers == 0)
{
    FMODASSERT(FMOD_System_SetOutput(mainsystem,FMOD_OUTPUTTYPE_NOSOUND));
}
else
{
    FMODASSERT(FMOD_System_GetDriverCaps(mainsystem, 0, &caps, 0, 0, &speakermode));
    FMODASSERT(FMOD_System_SetSpeakerMode(mainsystem,speakermode));       /* Set the user selected speaker mode. */

    if (caps & FMOD_CAPS_HARDWARE_EMULATED)             /* The user has the 'Acceleration' slider set to off!  This is really bad for latency!. */
    {                                                   /* You might want to warn the user about this. */
        MessageBeep(MB_ICONWARNING);
        MessageBoxA(GetActiveWindow(),"You've turned windows 'Acceleration' too low and will experience major slow downs. You can fix this in the control panel's hardware acceleration options. Location varies depending your Windows version.", "FMOD Warning", MB_ICONWARNING);
        //Dont care if this fails
        FMOD_System_SetDSPBufferSize(mainsystem,1024, 10);    /* At 48khz, the latency between issuing an fmod command and hearing it will now be about 213ms. */
    }
    //Dont care if this fails
    FMOD_System_SetHardwareChannels(mainsystem, 32, 64, 32, 64);
    FMOD_System_SetSoftwareChannels(mainsystem,100);
}

/**********************************************/
//Over here!!!!
if(FMODInternalSetResampler(samplemethod) == 0) return 0;
/**********************************************/ result =

FMOD_System_Init(mainsystem,(int)maxsounds, FMOD_INIT_NORMAL /|FMOD_INIT_VOL0_BECOMES_VIRTUAL/ , 0); // Initialize FMOD.
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)
{
FMOD_System_SetSpeakerMode(mainsystem,FMOD_SPEAKERMODE_STEREO);
result = FMOD_System_Init(mainsystem,(int)maxsounds, FMOD_INIT_NORMAL /| FMOD_INIT_VOL0_BECOMES_VIRTUAL/ , 0);
}
FMODASSERT(result);

if(supportwebfiles)
    FMODASSERT(FMOD_System_SetStreamBufferSize(mainsystem,64*1024, FMOD_TIMEUNIT_RAWBYTES));

FMODASSERT(FMOD_System_CreateChannelGroup(mainsystem, "priority", &priority));
FMODASSERT(FMOD_System_CreateChannelGroup(mainsystem, "effects", &effects));
FMODASSERT(FMOD_System_CreateChannelGroup(mainsystem, "ambientmusic", &ambientmusic));
FMODASSERT(FMOD_System_CreateChannelGroup(mainsystem, "ambienteffects", &ambienteffects));
FMOD_CHANNELGROUP *maingrp;
FMODASSERT(FMOD_System_GetMasterChannelGroup(mainsystem, &maingrp));
FMODASSERT(FMOD_ChannelGroup_AddGroup(maingrp,priority));
FMODASSERT(FMOD_ChannelGroup_AddGroup(maingrp,effects));
FMODASSERT(FMOD_ChannelGroup_AddGroup(maingrp,ambientmusic));
FMODASSERT(FMOD_ChannelGroup_AddGroup(maingrp,ambienteffects));

if(!supportwebfiles)
    FMODASSERT(FMOD_System_SetFileSystem(mainsystem,myopen, myclose, myread, myseek,2048));

inited = true;
return (double) 1;

}
[/code:2aq47frf]
[code:2aq47frf]
export double FMODSetResampler(double resamplemethod)
{
//if(inited) {{FMODASSERT(FMOD_ERR_INITIALIZATION);}}

if(resamplemethod>= FMOD_DSP_RESAMPLER_MAX) {{FMODASSERT(FMOD_ERR_INVALID_PARAM);}}
if(resamplemethod<0) {{FMODASSERT(FMOD_ERR_INVALID_PARAM);}}
samplemethod = (FMOD_DSP_RESAMPLER) (DWORD) resamplemethod;
return (double)1;

}
[/code:2aq47frf]

  • You must to post comments
0
0

2 things,
either your sound is not loaded as FMOD_SOFTWARE
or you’re playing the sound at the same rate as the output and it doesn’t need to be resampled (therefore it sounds exactly as it would as it was recorded)

  • You must to post comments
0
0

this is how the sound is loaded
[code:3e9hp5jk]
export double FMODSoundAdd(LPCSTR soundfile, double threed, double streamed)
{
if(!inited) {{FMODASSERT(FMOD_ERR_INITIALIZATION);}}
FMOD_SOUND *sound = NULL;

DWORD flags = FMOD_LOOP_NORMAL | FMOD_2D | FMOD_SOFTWARE|FMOD_ACCURATETIME;
if(threed)
{
    //MessageBoxA(GetActiveWindow(),soundfile,(LPCSTR)"3d",MB_ICONINFORMATION);
    flags = FMOD_LOOP_NORMAL | FMOD_3D | FMOD_SOFTWARE | FMOD_3D_LINEARROLLOFF|FMOD_ACCURATETIME;
}
else
{
    //      MessageBoxA(GetActiveWindow(),soundfile,(LPCSTR)"2D",MB_ICONINFORMATION);
}
if(streamed)
{
    FMODASSERT(FMOD_System_CreateStream(mainsystem, soundfile, flags, 0, &sound));
    //FMODASSERT(FMOD_System_CreateSound(mainsystem, soundfile, flags| FMOD_CREATESTREAM | FMOD_NONBLOCKING, 0, &sound));
//char t[] = "123456789";
//wsprintf( t, "%ld", (int)sound);

// MessageBoxA(GetActiveWindow(),t,"",0);

}
else
{
    FMODASSERT(FMOD_System_CreateSound(mainsystem, soundfile, flags, 0, &sound));
}

if(sound == NULL) {{FMODASSERT(FMOD_ERR_INVALID_HANDLE);}}
//MessageBoxA(GetActiveWindow(),"2","",0);

myinfo *mi = (myinfo *)GlobalAllocPtr(GMEM_FIXED|GMEM_ZEROINIT,(sizeof(myinfo)));
//MessageBoxA(GetActiveWindow(),"3","",0);
if(mi == NULL) {FMODASSERT(FMOD_ERR_MEMORY);}
mi->maxvolume = 1;
strcpy(mi->file,soundfile);
mi->threed =(threed);
mi->streamed =(streamed);
//all other members set by GMEM_ZEROINIT
//MessageBoxA(GetActiveWindow(),"4","",0);

FMODASSERT(FMOD_Sound_SetUserData(sound, (void *)mi));
//MessageBoxA(GetActiveWindow(),"5","",0);

return (double) (DWORD) sound;

}
[/code:3e9hp5jk]

And these are the sample sounds I was given
[url=http://host-a.net/icuurd12b42/samples.zip:3e9hp5jk]Download samples.zip[/url:3e9hp5jk]

My user provided a few samples on how it should sound like. The rs_none.wav is the file I used to test it out. Assuming it should sound like the other 2 when the right resampling is used.

Looking at my code, I assume you may be right about the sample rate of the file itself as the code looks like it’s initialized properly.

Does this mean the function would likely work if I was to reduce the sampling rate of the rs_none file? Like the sampling is capped to the max already so the function has no effect?

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.