0
0

I opened a wav file and copied to buffer and created it like below

FMOD_CREATESOUNDEXINFO info;
memset( &info, 0, sizeof( FMOD_CREATESOUNDEXINFO ) );
info.cbsize = sizeof( FMOD_CREATESOUNDEXINFO );
info.length = wav file buffer size in byte;

system->createSound( pbuffer, FMOD_OPENMEMORY_POINT, &info, &sound );

and played it.

sounds like sputter when playing end of sound
so i changed createSound option to FMOD_OPENMEMORY_POINT | FMOD_CREATESTREAM then was no problem

should i use FMOD_OPENMEMORY_POINT and FMOD_CREATESTREAM together?

  • You must to post comments
0
0

If the sound file you’re loading is compressed, you might want to try using FMOD_CREATECOMPRESSEDSAMPLE instead of FMOD_CREATESTREAM. FMOD_CREATESTREAM tells FMOD to decompress at run-time which might explain why it’s working.

(FMOD_OPENMEMORY_POINT | FMOD_CREATECOMPRESSEDSAMPLE) is what you should be using

[quote:1p6soym7]should i use FMOD_OPENMEMORY_POINT and FMOD_CREATESTREAM together?[/quote:1p6soym7]
There is not technical reason not to, but it’s not particularly advantageous to do so. You can only play one stream at a time so you lose the benefit of samples, on the other hand it’s in memory so you lose the benefit of streams; therefore you’re getting the worst from both worlds.

  • You must to post comments
0
0

i added FMOD_CREATECOMPRESSEDSAMPLE but

still sounds sputtering when the playing end of sound.

only using FMOD_CREATSTREAM is worked clearly.

  • You must to post comments
0
0

Did you pad out both ends of your memory by 16 bytes?

From the FMOD_MODE section of the FMOD Docs:

[code:25wmsh0b]
With FMOD_OPENMEMORY_POINT and FMOD_OPENRAW or PCM, if using them together, note that you must pad the data on each side by 16 bytes. This is so fmod can modify the ends of the data for looping/interpolation/mixing purposes.
[/code:25wmsh0b]

  • You must to post comments
0
0

[quote:7tdxjkg0]Did you pad out both ends of your memory by 16 bytes?[/quote:7tdxjkg0]

no.. how to pad out both ends of memory.. any examples or tutorials?

[quote:7tdxjkg0]With FMOD_OPENMEMORY_POINT and FMOD_OPENRAW or PCM, if using them together, note that you must pad the data on each side by 16 bytes. This is so fmod can modify the ends of the data for looping/interpolation/mixing purposes.[/quote:7tdxjkg0]

i’m not using FMOD_OPENMEMORY_POINT, FMOD_OPENRAW together.

what i’m using flag is FMOD_OPENMEMORY_POINT | FMOD_CREATECOMPRESSEDSAMPLE | FMOD_SOFTWARE | FMOD_LOOP_OFF

  • You must to post comments
0
0

Yes, but you are using a .wav file, which is PCM data.

Just allocate 32 bytes of extra memory, then load your data 16 bytes forwards from your memory pointer. This will pad out both sides by 16 bytes.

  • You must to post comments
0
0

i added 16bytes data each side and it worked but still sputter end of sound

my code is

initialize sound system
[code:39pgpo0k]
FMOD_RESULT result;
FMOD_SPEAKERMODE speakermode;
FMOD_CAPS caps;

unsigned int uiVersion;

result = FMOD::System_Create( &m_pSystem );
if( result != FMOD_OK )
{
    return false;
}

result = m_pSystem->getVersion( &uiVersion );
if( result != FMOD_OK )
{
    return false;
}

if( uiVersion < FMOD_VERSION )
{
    return false;
}

result = m_pSystem->getDriverCaps(0, &caps, 0, 0, &speakermode);
if( result != FMOD_OK )
{
    return false;
}

result = m_pSystem->setSpeakerMode(speakermode);       /* Set the user selected speaker mode. */
if( result != FMOD_OK )
{
    return false;
}

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. */
    result = m_pSystem->setDSPBufferSize(1024, 10); /* At 48khz, the latency between issuing an fmod command and hearing it will now be about 213ms. */
    if( result != FMOD_OK )
    {
        return false;
    }
}

result = m_pSystem->setStreamBufferSize( 220 * 1024, FMOD_TIMEUNIT_RAWBYTES );
if( result != FMOD_OK )
{
    return false;
}


result = m_pSystem->init( MAX_SOUND_CHANNEL, FMOD_INIT_NORMAL, 0 );    /* Replace with whatever channel count and flags you use! */
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)           /* Ok, the speaker mode selected isn't supported by this soundcard.  Switch it back to stereo... */
{
    result = m_pSystem->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
    if( result != FMOD_OK )
    {
        return false;
    }

    result = m_pSystem->init(32, FMOD_INIT_NORMAL, 0); /* Replace with whatever channel count and flags you use! */
    if( result != FMOD_OK )
    {
        return false;
    }
}

result = m_pSystem->getMasterChannelGroup( &m_pMasterChannelGroup );
if( result != FMOD_OK )
{
    return false;
}

[/code:39pgpo0k]

create sound ( not deallocated pcData while the sound was using it in my project )
[code:39pgpo0k] //——————————————————————-
FILE* pFile;
if( _tfopen_s( &pFile, pcSoundFileName, _T( "rb" ) ) != 0 )
return false;

    fseek( pFile, 0, SEEK_END );
    unsigned long nFileSize = ftell( pFile );

    fseek( pFile, 0, SEEK_SET );
    char* pcData = new char[ nFileSize ];
    int nRead = (int)fread( pcData, sizeof( char ), nFileSize, pFile );
    fclose( pFile );
    //-------------------------------------------------------------------

    FMOD_CREATESOUNDEXINFO info;
    memset( &info, 0, sizeof( FMOD_CREATESOUNDEXINFO ) );
    info.cbsize = sizeof( FMOD_CREATESOUNDEXINFO );
    info.length = nFileSize;

    dwFlag = ( FMOD_OPENMEMORY_POINT | FMOD_CREATECOMPRESSEDSAMPLE |  FMOD_LOOP_OFF | FMOD_SOFTWARE );

    result = m_pSystem->createSound( pcData, dwFlag, &info, &pFMODSound->pSound );

[/code:39pgpo0k]

playsound
[code:39pgpo0k]
result = m_pSystem->playSound( FMOD_CHANNEL_FREE,
pFMODSound->pSound,
false,
&(pFMODSound->pChannel) );
[/code:39pgpo0k]

and i tested with this file
[url:39pgpo0k]http://hangenie.com/attachment/49006eb061c599Y.zip[/url:39pgpo0k]

thanks

  • You must to post comments
0
0

I can’t see where you are padding the data with 16 bytes on each side.

  • You must to post comments
0
0

i tested but it not worked.

the code was

[code:owl4pbeb] //——————————————————————-
FILE* pFile;
if( _tfopen_s( &pFile, pcSoundFileName, _T( "rb" ) ) != 0 )
return false;

  fseek( pFile, 0, SEEK_END ); 
  unsigned long nFileSize = ftell( pFile ); 

  fseek( pFile, 0, SEEK_SET ); 
  char* pcData = new char[ nFileSize ]; 
  int nRead = (int)fread( pcData, sizeof( char ), nFileSize, pFile ); 
  fclose( pFile ); 
  //------------------------------------------------------------------- 

  int nPadSize = nFileSize + 32;
  char* pBuffer = new char[ nPadSize ];
  memset( pBuffer, 0, nPadSize );
  memcpy( pBuffer+16, pcData, nFileSize );

  FMOD_CREATESOUNDEXINFO info; 
  memset( &info, 0, sizeof( FMOD_CREATESOUNDEXINFO ) ); 
  info.cbsize = sizeof( FMOD_CREATESOUNDEXINFO ); 
  info.length = nPadSize; 
  info.defaultfrequency = 44100;
  info.numchannels = 1;
  info.format = FMOD_SOUND_FORMAT_PCM32;

  dwFlag = ( FMOD_OPENRAW | FMOD_OPENMEMORY_POINT | FMOD_CREATECOMPRESSEDSAMPLE |  FMOD_LOOP_OFF | FMOD_SOFTWARE ); 

  result = m_pSystem->createSound( pBuffer, dwFlag, &info, &pFMODSound->pSound );[/code:owl4pbeb]
  • You must to post comments
0
0

Hi,

[code:9gxrrek9]
info.defaultfrequency = 44100;
info.numchannels = 1;
info.format = FMOD_SOUND_FORMAT_PCM32;
[/code:9gxrrek9]

That stuff in your code isn’t needed, and is incorrect, the file you posted was pcm16 and 6 channels. All you need to supply in the exinfo is length and cbsize.

Also, you do not need the FMOD_OPENRAW tag, you aren’t loading raw data so I don’t know why you put that in. The only tags you really need are:

[code:9gxrrek9]
FMOD_OPENMEMORY_POINT | FMOD_LOOP_OFF | FMOD_SOFTWARE
[/code:9gxrrek9]

I had a test of the file you uploaded, and it does click at the end when using FMOD_OPENMEMORY_POINT. This is because there is a bit of non-audio junk 144 bytes from the end of the file (looks like a "regn" tag?).

Anyway, you need to delete the last 144 bytes from the end of the file (starts with "regn\" and it will work okay without anymore clicks. Or build the wave without the tag.

  • You must to post comments
0
0

Thanks chenpo, resolved

  • You must to post comments
Showing 10 results
Your Answer

Please first to submit.