Hey guys

Having some problems with FSOUND_Sample_Load…

I have a function that loads a simple wave file for me. It works as expected if I specify a file name directly in the FSOUND_Sample_Load call, but can’t seem to find it (at least it won’t play anything) if I call it with a char *.

See code.

[code:18uqbe6u]void LoadTone()
CString tempStr
("\Program Files\PocketPC\800_15_8000.wav");

char tmp[256];
char *p = (char *)tempStr.GetBuffer(1); 

dahstream = FSOUND_Sample_Load(FSOUND_FREE, 

tempStr.ReleaseBuffer( );

// This works as expected
         // dahstream = FSOUND_Sample_Load(FSOUND_FREE, 
//  "\\Program Files\\PocketPC\\800_15_8000.wav",
//  FSOUND_8BITS,0);

sampleLength = FSOUND_Sample_GetLength(dahstream);


I know I’m missing something obvious and that someone else has run into this. Any hints?

Additionally, I’d really like to turn this function into a version that loads the wave into memory. I’m thinking that I’ll need to use:
dahstream = FSOUND_Sample_Load(FSOUND_FREE,

but I don’t have a good example to look at to calculate numBytes.

Any ideas? Thanks in advance.

  • You must to post comments

Oh, and FSOUND_LOADMEMORY loads the file FROM memory, not into memory. When FSOUND_LOADMEMORY is used, the filename parameter is used as a pointer to the file in memory. numbytes is the length of the file in memory so FMOD knows when it has reached the end of the file.

  • You must to post comments

I think it is something to do with CString. Try this…

char *p = “\Program Files\PocketPC\800_15_8000.wav”;
dahstream = FSOUND_Sample_Load(FSOUND_FREE, p, FSOUND_8BITS, 0);

I think you will find that will work. If you insist on using CString, then try this…

dahstream = FSOUND_Sample_Load(FSOUND_FREE, (char *)tempStr.GetBuffer(1), FSOUND_8BITS, 0);

I’m not sure what the parameter to GetBuffer means (I have never used CString) or what it actually returns.

This seems to prove the KISS principle. Using CString just adds a level of complexity that is not really required and is just another place for something to go wrong.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.