* Writing a Full-Duplex (capture/playback) application.
@ 2005-12-22 9:25 Juan Zapatero
2005-12-22 17:43 ` Steve deRosier
0 siblings, 1 reply; 6+ messages in thread
From: Juan Zapatero @ 2005-12-22 9:25 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 1565 bytes --]
Hello,
First of all, I'm going to explain what am I trying to do, so that best
help can be provided.
My final objective is to write a VoIP app to be used over a GPRS
network, but so far, I'm only taking care about audio. I need to capture
audio, compress it with Speex, and then, in the other end, decompress it
and play it. I have written an app based on ALSA api tutorials that
records audio into a raw file, but then, this raw file is not recognized
by Speex encoder, so that I need the file recorded into wav format.
Can anyone help me on how to capture audio into wav format?
Thanks a lot.
______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
puede contener informacion clasificada por su emisor como confidencial
en el marco de su Sistema de Gestion de Seguridad de la
Informacion siendo para uso exclusivo del destinatario, quedando
prohibida su divulgacion copia o distribucion a terceros sin la
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.
______________________
This message including any attachments may contain confidential
information, according to our Information Security Management System,
and intended solely for a specific individual to whom they are addressed.
Any unauthorised copy, disclosure or distribution of this message
is strictly forbidden. If you have received this transmission in error,
please notify the sender immediately and delete it.
______________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Writing a Full-Duplex (capture/playback) application.
2005-12-22 9:25 Writing a Full-Duplex (capture/playback) application Juan Zapatero
@ 2005-12-22 17:43 ` Steve deRosier
2005-12-23 9:39 ` Juan Zapatero
0 siblings, 1 reply; 6+ messages in thread
From: Steve deRosier @ 2005-12-22 17:43 UTC (permalink / raw)
To: Juan Zapatero; +Cc: alsa-devel
Errr... usually (depending on your settings) a raw file and a wav file are nearly the same, just the raw file is missing the wav header. I'd recommend you search on the net for the wav file format, it's really easy.
On the other hand, here's a link I've got in my bookmarks:
http://www.borg.com/~jglatt/tech/wave.htm
- Steve
Juan Zapatero wrote:
> Hello,
> First of all, I'm going to explain what am I trying to do, so that best
> help can be provided.
> My final objective is to write a VoIP app to be used over a GPRS
> network, but so far, I'm only taking care about audio. I need to capture
> audio, compress it with Speex, and then, in the other end, decompress it
> and play it. I have written an app based on ALSA api tutorials that
> records audio into a raw file, but then, this raw file is not recognized
> by Speex encoder, so that I need the file recorded into wav format.
> Can anyone help me on how to capture audio into wav format?
> Thanks a lot.
>
>
> ______________________
> Este mensaje, y en su caso, cualquier fichero anexo al mismo,
> puede contener informacion clasificada por su emisor como confidencial
> en el marco de su Sistema de Gestion de Seguridad de la
> Informacion siendo para uso exclusivo del destinatario, quedando
> prohibida su divulgacion copia o distribucion a terceros sin la
> autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
> erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
> Gracias por su colaboracion.
> ______________________
> This message including any attachments may contain confidential
> information, according to our Information Security Management System,
> and intended solely for a specific individual to whom they are addressed.
> Any unauthorised copy, disclosure or distribution of this message
> is strictly forbidden. If you have received this transmission in error,
> please notify the sender immediately and delete it.
> ______________________
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Writing a Full-Duplex (capture/playback) application.
2005-12-22 17:43 ` Steve deRosier
@ 2005-12-23 9:39 ` Juan Zapatero
2005-12-23 10:57 ` James Courtier-Dutton
0 siblings, 1 reply; 6+ messages in thread
From: Juan Zapatero @ 2005-12-23 9:39 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 1332 bytes --]
I've solved the problem concerning encapsulation into wave format,
thanks to Steve deRosier, but I still have another problem. How can I
configure hw:0,0 device to capture and play audio in Mono mode (only 1
channel).
I've tried to specify 1 channel with
snd_pcm_hw_params_set_channels(captura, cparams, 1), but I get an
'Unable to set channels' error.
Thanks.
______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
puede contener informacion clasificada por su emisor como confidencial
en el marco de su Sistema de Gestion de Seguridad de la
Informacion siendo para uso exclusivo del destinatario, quedando
prohibida su divulgacion copia o distribucion a terceros sin la
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.
______________________
This message including any attachments may contain confidential
information, according to our Information Security Management System,
and intended solely for a specific individual to whom they are addressed.
Any unauthorised copy, disclosure or distribution of this message
is strictly forbidden. If you have received this transmission in error,
please notify the sender immediately and delete it.
______________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Writing a Full-Duplex (capture/playback) application.
2005-12-23 9:39 ` Juan Zapatero
@ 2005-12-23 10:57 ` James Courtier-Dutton
2005-12-23 11:55 ` Juan Zapatero
0 siblings, 1 reply; 6+ messages in thread
From: James Courtier-Dutton @ 2005-12-23 10:57 UTC (permalink / raw)
To: Juan Zapatero; +Cc: alsa-devel
Juan Zapatero wrote:
> I've solved the problem concerning encapsulation into wave format,
> thanks to Steve deRosier, but I still have another problem. How can I
> configure hw:0,0 device to capture and play audio in Mono mode (only 1
> channel).
> I've tried to specify 1 channel with
> snd_pcm_hw_params_set_channels(captura, cparams, 1), but I get an
> 'Unable to set channels' error.
>
> Thanks.
>
When doing full duplex, do not open the device as full duplex, open the
device twice. Once for playback and once for capture. The reason for
this is that sound cards often have different buffer sizes for capture
and playback, and so separating them gives you more control over buffer
and period sizes.
For playback use device name "plug:front", for capture you can use the
same "plug:front". The important bit it the "plug", as it will do sample
rate and sample format conversion for you.
For low latency application like voice, it is actually better to sample
at high frequencies, e.g. 48000Hz. You then do the sample rate
conversion in your application. This way, not only is the sample rate
conversion much higher quality than alsa-lib can probably do, it can
also be optimised for your application. e.g. VoIP usually uses 20ms of
voice per packet. You can create a very efficient block sample rate
converter when taking all 20ms into account.
There is also an option in the api to force the "plug" layer to do
sample format conversion, but not sample rate conversion, thus ensuring
that alsa-lib does not do any sample rate conversion, leaving your
application to do it.
James
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Writing a Full-Duplex (capture/playback) application.
2005-12-23 10:57 ` James Courtier-Dutton
@ 2005-12-23 11:55 ` Juan Zapatero
2005-12-23 14:59 ` James Courtier-Dutton
0 siblings, 1 reply; 6+ messages in thread
From: Juan Zapatero @ 2005-12-23 11:55 UTC (permalink / raw)
To: James Courtier-Dutton; +Cc: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 2501 bytes --]
The problem about sample rate is that I need the captured audio to be as
much compressed as possible so that I can get it trough a GPRS link.
That's why I use 8000Hz, 16bit, and I would like to capture in Mono,
because there is no sense in capturing stereo channels with a mono
microphone.
> When doing full duplex, do not open the device as full duplex, open the
> device twice. Once for playback and once for capture. The reason for
> this is that sound cards often have different buffer sizes for capture
> and playback, and so separating them gives you more control over buffer
> and period sizes.
> For playback use device name "plug:front", for capture you can use the
> same "plug:front". The important bit it the "plug", as it will do sample
> rate and sample format conversion for you.
> For low latency application like voice, it is actually better to sample
> at high frequencies, e.g. 48000Hz. You then do the sample rate
> conversion in your application. This way, not only is the sample rate
> conversion much higher quality than alsa-lib can probably do, it can
> also be optimised for your application. e.g. VoIP usually uses 20ms of
> voice per packet. You can create a very efficient block sample rate
> converter when taking all 20ms into account.
> There is also an option in the api to force the "plug" layer to do
> sample format conversion, but not sample rate conversion, thus ensuring
> that alsa-lib does not do any sample rate conversion, leaving your
> application to do it.
>
> James
______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
puede contener informacion clasificada por su emisor como confidencial
en el marco de su Sistema de Gestion de Seguridad de la
Informacion siendo para uso exclusivo del destinatario, quedando
prohibida su divulgacion copia o distribucion a terceros sin la
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.
______________________
This message including any attachments may contain confidential
information, according to our Information Security Management System,
and intended solely for a specific individual to whom they are addressed.
Any unauthorised copy, disclosure or distribution of this message
is strictly forbidden. If you have received this transmission in error,
please notify the sender immediately and delete it.
______________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Writing a Full-Duplex (capture/playback) application.
2005-12-23 11:55 ` Juan Zapatero
@ 2005-12-23 14:59 ` James Courtier-Dutton
0 siblings, 0 replies; 6+ messages in thread
From: James Courtier-Dutton @ 2005-12-23 14:59 UTC (permalink / raw)
To: Juan Zapatero; +Cc: alsa-devel
Juan Zapatero wrote:
>>When doing full duplex, do not open the device as full duplex, open the
>>device twice. Once for playback and once for capture. The reason for
>>this is that sound cards often have different buffer sizes for capture
>>and playback, and so separating them gives you more control over buffer
>>and period sizes.
>>For playback use device name "plug:front", for capture you can use the
>>same "plug:front". The important bit it the "plug", as it will do sample
>>rate and sample format conversion for you.
>>For low latency application like voice, it is actually better to sample
>>at high frequencies, e.g. 48000Hz. You then do the sample rate
>>conversion in your application. This way, not only is the sample rate
>>conversion much higher quality than alsa-lib can probably do, it can
>>also be optimised for your application. e.g. VoIP usually uses 20ms of
>>voice per packet. You can create a very efficient block sample rate
>>converter when taking all 20ms into account.
>>There is also an option in the api to force the "plug" layer to do
>>sample format conversion, but not sample rate conversion, thus ensuring
>>that alsa-lib does not do any sample rate conversion, leaving your
>>application to do it.
>>
>>James
>
> The problem about sample rate is that I need the captured audio to be as
> much compressed as possible so that I can get it trough a GPRS link.
> That's why I use 8000Hz, 16bit, and I would like to capture in Mono,
> because there is no sense in capturing stereo channels with a mono
> microphone.
>
>
My point is that you capture at 48000Hz, you then resample down to
8000Hz in your software ready for the GPRS link.
You improve the latency that way.
James
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-12-23 14:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-22 9:25 Writing a Full-Duplex (capture/playback) application Juan Zapatero
2005-12-22 17:43 ` Steve deRosier
2005-12-23 9:39 ` Juan Zapatero
2005-12-23 10:57 ` James Courtier-Dutton
2005-12-23 11:55 ` Juan Zapatero
2005-12-23 14:59 ` James Courtier-Dutton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.