All of lore.kernel.org
 help / color / mirror / Atom feed
* Rate Conversion
@ 2002-06-27  8:29 Kris Modrak
  2002-06-27 14:11 ` Jaroslav Kysela
  0 siblings, 1 reply; 7+ messages in thread
From: Kris Modrak @ 2002-06-27  8:29 UTC (permalink / raw)
  To: alsa-devel

I am writing a PCM application and wish to play a .wav file that has a
sampling rate of 8kHz on a hardware setup that only supports sampling
frequencies of 44.1 or 48kHz.

Does anyone know how to implement this?

I have tried setting up a rate plugin in my .asoundrc file

pcm.r8 {
        type rate               # Rate PCM
        slave slave_rate8000Hz  # Slave name
}

pcm_slave.slave_rate8000Hz {
        pcm "hw:0,0"
        rate 8000
}

But when using this device I am unable to set the rate to 8000 using
snd_pcm_hw_params_set_rate_near ();

I tried using the r8 device with aplay (version 0.9.0beta12) and get the
following error

> aplay -Dr8 s1.wav
Playing WAVE 's1.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
aplay: set_params:717: Broken configuration for this PCM: no
configurations available

I know it is possible to play the file because it works when I play it
from a netscape window.

Thanks in advance
Kris Modrak


-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Rate Conversion
  2002-06-27  8:29 Kris Modrak
@ 2002-06-27 14:11 ` Jaroslav Kysela
  2002-06-28  3:30   ` Kris Modrak
  0 siblings, 1 reply; 7+ messages in thread
From: Jaroslav Kysela @ 2002-06-27 14:11 UTC (permalink / raw)
  To: Kris Modrak; +Cc: alsa-devel@lists.sourceforge.net

On Thu, 27 Jun 2002, Kris Modrak wrote:

> I am writing a PCM application and wish to play a .wav file that has a
> sampling rate of 8kHz on a hardware setup that only supports sampling
> frequencies of 44.1 or 48kHz.
> 
> Does anyone know how to implement this?

You don't need to do this. Use the 'plughw' device which should do all 
conversions from you.

> 
> I have tried setting up a rate plugin in my .asoundrc file
> 
> pcm.r8 {
>         type rate               # Rate PCM
>         slave slave_rate8000Hz  # Slave name
> }
> 
> pcm_slave.slave_rate8000Hz {
>         pcm "hw:0,0"
>         rate 8000

Use 44100 or 48000. It's the rate for the hardware not the source rate.

						Jaroslav

-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project  http://www.alsa-project.org
SuSE Linux    http://www.suse.com



-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Rate Conversion
  2002-06-27 14:11 ` Jaroslav Kysela
@ 2002-06-28  3:30   ` Kris Modrak
  2002-06-28 11:28     ` Paul Davis
  0 siblings, 1 reply; 7+ messages in thread
From: Kris Modrak @ 2002-06-28  3:30 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: alsa-devel@lists.sourceforge.net

Jaroslav Kysela wrote:
> 
> On Thu, 27 Jun 2002, Kris Modrak wrote:
> 
> > I am writing a PCM application and wish to play a .wav file that has a
> > sampling rate of 8kHz on a hardware setup that only supports sampling
> > frequencies of 44.1 or 48kHz.
> >
> > Does anyone know how to implement this?
> 
> You don't need to do this. Use the 'plughw' device which should do all
> conversions from you.

I am a little confused about your advice. I am not sure how to access
the 'plughw' device from my application.

I have a full duplex application that can play a file at 44.1kHz and
record at the same rate but I want it to operate at lower sampling
frequencies.

I am not sure of how I should be setting up my PCM devices. How do I
tell them to convert, say, 8kHz audio data to 44.1kHz audio data so my
hardware can play it at the correct speed?

I tried using aplay with plughw to play an 8kHz file and got the
following results

>aplay -Dplughw s1.wav
Playing WAVE 's1.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
Segmentation fault

However it worked when using a 441.kHz file.

Regards
Kris Modrak


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Bringing you mounds of caffeinated joy.
http://thinkgeek.com/sf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Rate Conversion
  2002-06-28  3:30   ` Kris Modrak
@ 2002-06-28 11:28     ` Paul Davis
  2002-07-01  2:19       ` Kris Modrak
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Davis @ 2002-06-28 11:28 UTC (permalink / raw)
  To: u9514439; +Cc: Jaroslav Kysela, alsa-devel@lists.sourceforge.net

>> You don't need to do this. Use the 'plughw' device which should do all
>> conversions from you.
>
>I am a little confused about your advice. I am not sure how to access
>the 'plughw' device from my application.

     snd_pcm_open (&handle, "plughw:N,M", ...)

where N and M are the card number and subdevice number. Preferably,
this is a string supplied by the user, not hard coded into the application.

>I am not sure of how I should be setting up my PCM devices. How do I
>tell them to convert, say, 8kHz audio data to 44.1kHz audio data so my
>hardware can play it at the correct speed?

just as in the few token API examples. using
snd_pcm_hw_params_*(). there is no difference setting the parameters
no matter what "type" of PCM device you are using.

>I tried using aplay with plughw to play an 8kHz file and got the
>following results
>
>>aplay -Dplughw s1.wav
>Playing WAVE 's1.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
>Segmentation fault

almost certainly a bug in aplay. i suspect you might be one of the
first people to use it for a mono 8kHz file :(

--p





-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Caffeinated soap. No kidding.
http://thinkgeek.com/sf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Rate Conversion
  2002-06-28 11:28     ` Paul Davis
@ 2002-07-01  2:19       ` Kris Modrak
  2002-07-01 11:51         ` Paul Davis
  0 siblings, 1 reply; 7+ messages in thread
From: Kris Modrak @ 2002-07-01  2:19 UTC (permalink / raw)
  To: Paul Davis; +Cc: Jaroslav Kysela, alsa-devel@lists.sourceforge.net

Paul Davis wrote:
> 
> >I am a little confused about your advice. I am not sure how to access
> >the 'plughw' device from my application.
> 
>      snd_pcm_open (&handle, "plughw:N,M", ...)
> 
> where N and M are the card number and subdevice number. Preferably,
> this is a string supplied by the user, not hard coded into the application.
> 
> >I am not sure of how I should be setting up my PCM devices. How do I
> >tell them to convert, say, 8kHz audio data to 44.1kHz audio data so my
> >hardware can play it at the correct speed?
> 
> just as in the few token API examples. using
> snd_pcm_hw_params_*(). there is no difference setting the parameters
> no matter what "type" of PCM device you are using.

Apart from rates or 44.1 or 48kHz I was unable to find a rate/period
size combination that I was able to use with plughw:0,0.

snd_pcm_hw_params_set_period_size () failed for every period size I
tried (64, 128, 256, 512, 1024, 2048 and 4096) when I had the rate set
to 8, 16 or 32 kHz.

I managed to set the following combinations of hardware parameters:
-22050Hz with period sizes of 2048, 1024, 512, 256, 128 and 64
-11025Hz with period sizes of 1024, 512, 256, 128 and 64

but when I ran my application I encountered the following error

ALSA lib pcm_hw.c:380:(snd_pcm_hw_start) SNDRV_PCM_IOCTL_START failed:
Broken pipe

Does anyone have any further suggestions of things that I could try or
why this rate conversion isn't working for me? I am using ALSA
0.9.0beta12 with a Hammerfall Light (RME Digi9636) soundcard.

Kris Modrak


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Rate Conversion
  2002-07-01  2:19       ` Kris Modrak
@ 2002-07-01 11:51         ` Paul Davis
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Davis @ 2002-07-01 11:51 UTC (permalink / raw)
  To: u9514439; +Cc: Jaroslav Kysela, alsa-devel@lists.sourceforge.net

>Apart from rates or 44.1 or 48kHz I was unable to find a rate/period
>size combination that I was able to use with plughw:0,0.

This is an error in alsa-lib as far as I can tell. its possible to set
the rate to 32kHz using the hardware device (for the Hammerfall) and
use it without a problem. I wish I could help you with the issue in
alsa-lib, but i don't understand it well enough nor do i have the time.

--p


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Rate Conversion
       [not found] <200206281126.g5SBQLTk004595@anu.edu.au>
@ 2002-07-02  0:43 ` Kris Modrak
  0 siblings, 0 replies; 7+ messages in thread
From: Kris Modrak @ 2002-07-02  0:43 UTC (permalink / raw)
  To: Paul Davis; +Cc: Jaroslav Kysela, alsa-devel@lists.sourceforge.net

Paul Davis wrote:
> 
> >> You don't need to do this. Use the 'plughw' device which should do all
> >> conversions from you.
> >
> >I am a little confused about your advice. I am not sure how to access
> >the 'plughw' device from my application.
> 
>      snd_pcm_open (&handle, "plughw:N,M", ...)
> 
> where N and M are the card number and subdevice number. Preferably,
> this is a string supplied by the user, not hard coded into the application.
> 
> >I am not sure of how I should be setting up my PCM devices. How do I
> >tell them to convert, say, 8kHz audio data to 44.1kHz audio data so my
> >hardware can play it at the correct speed?
> 
> just as in the few token API examples. using
> snd_pcm_hw_params_*(). there is no difference setting the parameters
> no matter what "type" of PCM device you are using.

If use the virtual plughw:0,0 device and set the rate to 8kHz, at what
rate is my actual hardware device set to? Where are these settings made
and how are they decided?

Do I need to, or is it possible to, tell my soundcard to operate at
44.1kHz?

Kris Modrak


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-07-02  0:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200206281126.g5SBQLTk004595@anu.edu.au>
2002-07-02  0:43 ` Rate Conversion Kris Modrak
2002-06-27  8:29 Kris Modrak
2002-06-27 14:11 ` Jaroslav Kysela
2002-06-28  3:30   ` Kris Modrak
2002-06-28 11:28     ` Paul Davis
2002-07-01  2:19       ` Kris Modrak
2002-07-01 11:51         ` Paul Davis

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.