Re: [Osalp-dev] To play wav file
Status: Abandoned
Brought to you by:
daservis
From: Senthil K. <sen...@ho...> - 2003-05-20 11:30:33
|
Dear Sir, If possible and time permits please give me some feedback on the sample program which i have written to play the wav file. Attachment : WavPlayer.c prompt.wav ( properties of the wav file : 8 bit , mono, 11025 Hz) When i play through XMMS (player), i am able to hear good quality of sound. But with my program some noise comes along with the sound. In the programm i am setting the Master volume of Left speaker as 100 %. Will it have any impact on the sound quality( because of amplification). with thanks and regards Senthil >From: Darrick Servis <da...@dc...> >To: "Senthil Kumar" <sen...@ho...>, >osa...@li... >Subject: Re: [Osalp-dev] To play wav file >Date: Mon, 19 May 2003 10:47:31 -0700 > >To convert 8 bit unsigned mono to 16 bit signed stereo ... > >int data_length = 4096; >int channels = 2; >char* orig_ptr = malloc(data_length*sizeof(unsigned char)); >short* dest_ptr = malloc(data_length*channels*sizeof(signed int)); > >data_length = fread(orig_ptr,sizeof(unsigned char),data_length,FILE_IN); > >for (i = 0; i < data_length; i++){ > /* convert to signed 16 */ > *dest_ptr++ = (*orig_ptr++ << 8)^0x8000 ; > /* copy left channel to right */ > *dest_ptr++ = *dest_ptr; >} > >fwrite(dest_ptr,sizeof(signed int), data_length*channels,DSP_OUT); > >Stereo data is interleaved... > >You're getting dropouts because the timer is not synced to the soundcard. >That's not the way to do it anyway. Make a seperate thread from your >interface thread and do... > >while( play_file() ) >{ > play_chunk(); >} > >Writing to the soundcard blocks by default. > >Good luck, >Darrick > >On Monday 19 May 2003 03:44 am, Senthil Kumar wrote: > > Dear All, > > > > I am working in C with Linux as OS. > > I am having some problem in playing the raw pcm data extracted from wav > > file. > > My wav file is 8bit, Mono, 11025Hz. > > > > My audio driver supports 16bit, Stereo (2 channels), Sampling rate (can >be > > varied using ioctl system call). > > > > Since the Audio Driver properties cannot be changed for the Bits/sample >and > > channel, i made a convertion from 8 to 16 bits by multipying 8_bit_data > > *255 and assinged to 16_bit_array. > > But sound comes with some noise. > > > > Since the audio driver expects two 16 bit data at a time (because of 2 > > channel), i defined an int32 bit array of size 4096 . Read 4096 sample >from > > the wav file and filled in the array. > > > > I placed the 8 bit PCM data (extracted from wav file )in the first byte > > int32 bit array and wrote it to the dsp device. > > > > for(i=0;i<BUFFERSIZE;i++) > > { > > fread(&data,sizeof(unsigned char),1,ptr); > > // fread(&buffer1,sizeof(unsigned char),1,ptr1); > > audio_buffer1[i]=((((unsigned int) data)<<24)|0x00000000); > > } > > > > > > > > With the volume level as 100 % for the left speaker (since i am playing >the > > sound in the left speaker) i am able to get the sound, but not better > > quality. > > > > As i want to control play and stop immideately, i wrote the sound data >in > > sizes of 4096 samples. > > > > I kept one timer process, so that it will send message to my process at > > every 371ms. > > I calculated the time as > > > > 1 bit=( 1/11025*32) =2.834 micro seconds > > 4096*32 bits = 2micro seconds * 4096 *32 =371milli second. > > > > After every reading of 4096 samples from the wav file till the end of >the > > file, i wrote the data into the dsp device using the write function. > > > > But the sound played was not continuous and some jerk in the sound. > > Please help me to solve this problem. > > > > > > > > with thanks and regards > > Senthil > > > > _________________________________________________________________ > > Technical writer? Earn more now. > > http://server1.msn.co.in/msnleads/tis/index.asp Click here. > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: If flattening out C++ or Java > > code to make your application fit in a relational database is painful, > > don't do it! Check out ObjectStore. Now part of Progress Software. > > http://www.objectstore.net/sourceforge > > _______________________________________________ > > Osalp-dev mailing list > > Osa...@li... > > https://lists.sourceforge.net/lists/listinfo/osalp-dev > _________________________________________________________________ Narain Karthikeyan. The fastest Indian. http://server1.msn.co.in/msnspecials/narain/index.asp Know more about him. |