write a wav file to audio device using alsa -


i want write .wav file audio device. used alsa purpose. took sample file.here copying file sample data buffer.

    file.read(reinterpret_cast<char*>(&buff),wave.dataheader.chunksize);     int nframes = wave.dataheader.chunksize/2;     while( nframes > 0 ){             int r = snd_pcm_writei (playback_handle,                                  reinterpret_cast<const char*>(buff), nframes);             nframes = nframes - r;             if(r < 0){                     fprintf (stderr, "write audio interface failed (%s)\n",                              snd_strerror (err));                     exit (1);             }             buff += r * 2;     } 

my files data is

file size: 2084
fmtchunk size: 16
format type: 1
channels: 2
sample rate: 48000
bytes per sec: 192000
bits per sample: 16

here giving error
a.out: pcm.c:1250: snd_pcm_writei: assertion `pcm' failed.
aborted
.
here should nframes value , how should write audio device in advance.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -