From:
<pj...@ch...> - 2004-11-13 22:38:12
|
Hello! I've got a question about using the audio stream routines in Allegro. I know how to play a sample in 8 bit mono mode. With this format everything goes fine. However I faced a problem when trying to play the samples of 16 bit depth. So here's what I have: -------------------------------------cut here------------------------------------- stream = play_audio_stream(BUFFER_SIZE, 16, FALSE, 44100, 255, 128); plik = fopen(name,"rb+"); fseek(plik,44,SEEK_SET); while (!keypressed()) { short *p = (short *) get_audio_stream_buffer(stream); if (p) { for (i=0; i<BUFFER_SIZE; i++) { fread(&p[i],sizeof(short),1,plik); } free_audio_stream_buffer(stream); } } -------------------------------------cut here------------------------------------- Where name is name of a simple wave file (Windows PCM format), which is 16 bit, mono, with 44.1 kHz sampling rate. The problem is that the sound screeching in 16 bits. I even loaded a file, which consists only of silence, but the result is the same. The conclusion is that it must be something I'm doing wrong in playing 16 bits samples only, but the question what it can be remains. Does anybody have any ideas? My second question is how to play stereo samples. |