If you the WAV file you want to play is less than 64Kb then you can use SndPlayResource which is very simple to use. I use this method in my ordering application and when the sound I want to play is greater than 64Kb I just chop it up into smaller chunks.

Here is the code I have written to do it (in Pascal but you should be able to see the similarities for C/C++ use):

procedure PlayWav;
var
  Error :err;
  WAVHandle :MemHandle;
  WAVPtr :MemPtr;
begin
  //1001 = resource to play
  WAVHandle :=DmGetResource(RSC('WAVE'),1001);
  WAVPtr :=MemHandleLock(WAVHandle);

  //play sound at full voume (32000)
  Error :=SndPlayResource(WAVPtr,32000,sndFlagSync);
  MemHandleUnlock(WAVHandle);
  DmReleaseResource(WAVHandle);
end;

//don't forget to declare the resource you want play:
resource
  DATA 1001 'WAVE' IN 'ordernotsent.wav';

Hope this helps!

Regards


Edward Jones


Kelly Leal wrote:
Hi!

I want to play a wav file (I'm using Tungsten E2), but I get "fatal exception" when I call SndStreamStart. Before, I make a call to SndStreamCreate and I get no errors, but I think that I'm doing something wrong when calling SndStreamCreate.

Here is my code:

err = SndStreamCreate(&mainStream, sndOutput, 44100, sndInt16Little, sndStereo, sndStreamBufferCallback,
     (void *)&byteArray, AUDIO_BUFF_SIZE, false);

I'm not really sure about sndStreamBufferCallback. Maybe the problem is here... I think that I got a little confused with its parameters! Does anybody have an example that works to show me?

Thanks in advance!!!!!

Kelly


--
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to