Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Audio, Soundbylayout: how to use it at 24 bits/96 KHz

183 views
Skip to first unread message

Wolfgang Pfeiffer

unread,
Aug 16, 2009, 10:00:15 AM8/16/09
to
Hi All

PowerBook5,8 here.

I want to play a sound file that is coded to 24 bits/96000 Hz at
exactly these sample rates.

$ file 24-96-sound.wav
24-96-sound.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 24 bit, stereo 96000 Hz

Apple says the soundcard I have is able to do 16 or 24 bits, and
sample rates of up to 96KHz:

"The audio circuitry and audio device drivers handle audio data in
multiple formats. Both digital and analog audio circuitry handle audio
input and output data at sample rates of 32.0 kHz, 44.1 kHz, 48.0 kHz,
64.0 kHz, 88.2 kHz, and 96.0 kHz at sample depths of 16 bits and 24
bits."

Problem is, it looks as if I get maximum 48KHz when playing this 24/96
file:

-------------------------------
$ aplay -v -r 96000 24-96-sound.wav
Playing WAVE '24-96-sound.wav' : Signed 24 bit Little Endian in 3bytes, Rate 96000 Hz, Stereo
Plug PCM: Rate conversion PCM (48000, sformat=S16_BE)
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S24_3LE
subformat : STD
channels : 2
rate : 96000
exact rate : 96000 (96000/1)
msbits : 24
buffer_size : 32768
period_size : 2048
period_time : 21333
tstamp_mode : NONE
period_step : 1
avail_min : 2048
period_event : 0
start_threshold : 32768
stop_threshold : 32768
silence_threshold: 0
silence_size : 0
boundary : 1073741824
Slave: Soft volume PCM
Control: PCM Playback Volume
min_dB: -51
max_dB: 0
resolution: 256
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_BE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 16384
period_size : 1024
period_time : 21333
tstamp_mode : NONE
period_step : 1
avail_min : 1024
period_event : 0
start_threshold : 16384
stop_threshold : 16384
silence_threshold: 0
silence_size : 0
boundary : 1073741824
Slave: Direct Stream Mixing PCM
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_BE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 16384
period_size : 1024
period_time : 21333
tstamp_mode : NONE
period_step : 1
avail_min : 1024

[ .... ]
-----------------------------


mplayer:
-----------------------------

$ mplayer -identify 24-96-sound.wav
MPlayer SVN-r29409-4.3.3 (C) 2000-2009 MPlayer Team
Can't open joystick device /dev/input/js0: No such file or directory
Can't init input joystick
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing 24-96-sound.wav.
ID_AUDIO_ID=0
Audio only file format detected.
ID_FILENAME=24-96-sound.wav
ID_DEMUXER=audio
ID_AUDIO_FORMAT=1
ID_AUDIO_BITRATE=4608000
ID_AUDIO_RATE=0
ID_AUDIO_NCH=2
ID_LENGTH=394.00
ID_SEEKABLE=1
ID_CHAPTERS=0
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 96000 Hz, 2 ch, s24le, 4608.0 kbit/100.00% (ratio: 576000->576000)
ID_AUDIO_BITRATE=4608000
ID_AUDIO_RATE=96000
ID_AUDIO_NCH=2
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
[AO_ALSA] Format s24le is not supported by hardware, trying default.
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
ID_AUDIO_CODEC=pcm
Video: no video
Starting playback...

-----------------------------

do I have to recompile the 2.6.30 kernel I use, and if yes, what do I change?:

excerpt pcm.h:
------------------------

/* If you change this don't forget to change rates[] table in pcm_native.c */
#define SNDRV_PCM_RATE_5512 (1<<0) /* 5512Hz */
#define SNDRV_PCM_RATE_8000 (1<<1) /* 8000Hz */
#define SNDRV_PCM_RATE_11025 (1<<2) /* 11025Hz */
#define SNDRV_PCM_RATE_16000 (1<<3) /* 16000Hz */
#define SNDRV_PCM_RATE_22050 (1<<4) /* 22050Hz */
#define SNDRV_PCM_RATE_32000 (1<<5) /* 32000Hz */
#define SNDRV_PCM_RATE_44100 (1<<6) /* 44100Hz */
#define SNDRV_PCM_RATE_48000 (1<<7) /* 48000Hz */
#define SNDRV_PCM_RATE_64000 (1<<8) /* 64000Hz */
#define SNDRV_PCM_RATE_88200 (1<<9) /* 88200Hz */
#define SNDRV_PCM_RATE_96000 (1<<10) /* 96000Hz */
#define SNDRV_PCM_RATE_176400 (1<<11) /* 176400Hz */
#define SNDRV_PCM_RATE_192000 (1<<12) /* 192000Hz */

----------------------

Or some module parameter I could change for what I want?

What else?

Thanks in anticipation

Best regards
Wolfgang

--
http://heelsbroke.wordpress.com


--
To UNSUBSCRIBE, email to debian-powe...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Wolfgang Pfeiffer

unread,
Aug 16, 2009, 6:20:11 PM8/16/09
to
On Sun, Aug 16, 2009 at 03:53:20PM +0200, Wolfgang Pfeiffer wrote:
> Hi All
>
> PowerBook5,8 here.
>
> I want to play a sound file that is coded to 24 bits/96000 Hz at
> exactly these sample rates.
>
> $ file 24-96-sound.wav
> 24-96-sound.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 24 bit, stereo 96000 Hz
>
> Apple says the soundcard I have is able to do 16 or 24 bits, and
> sample rates of up to 96KHz:
>
> "The audio circuitry and audio device drivers handle audio data in
> multiple formats. Both digital and analog audio circuitry handle audio
> input and output data at sample rates of 32.0 kHz, 44.1 kHz, 48.0 kHz,
> 64.0 kHz, 88.2 kHz, and 96.0 kHz at sample depths of 16 bits and 24
> bits."

1:

Meantime I doubt this card can do 24 bits: after lots of testing it
looks it can do 16 and 32 bits only.

2:

I found and installed/edited an old ~/.aoundrc file. You find it
attached to this email. It works in that it uses a fixed sample rate
of 96000 Hz for anything you feed to your different sound players. I
hate this solution, as nowadays alsa simply should look at the file
that's fed to it, and then - per default - play it exactly as it was
coded, limited only by the capabilities of the sound card: e.g. a file
with 96000 Hz should be played at exactly that rate, and one with
44100 Hz with 44100 Hz.

But it's a - so far - working compromise. If in doubt don't use the
attached ~/.asoundrc: I cannot guarantee it won't break things on your
system.

3:

Thanks to Michel Dᅵnzer who - if my memory serves me well - published
an .asoundrc many years ago that helped me set up most parts of the one
attached to this email. Again, don't use it: things might have changed
greatly meantime ...

HTH

Best Regards

Wolfgang Pfeiffer

unread,
Aug 16, 2009, 6:20:14 PM8/16/09
to
On Mon, Aug 17, 2009 at 12:16:21AM +0200, Wolfgang Pfeiffer wrote:
>
> I found and installed/edited an old ~/.aoundrc file. You find it
> attached to this email.

Forgot it. It's attached now. Sorry.

Wolfgang

--
http://heelsbroke.wordpress.com

.asoundrc

Benjamin Cama

unread,
Aug 16, 2009, 6:50:08 PM8/16/09
to
Hi,

Just guessing : for mplayer, I know there is the -srate parameter that
can set a forced sampling rate for your sound card.
Maybe it will work, but the s24le to s16le conversion looks strange
too ...

Regards,
benjamin

Wolfgang Pfeiffer

unread,
Aug 18, 2009, 5:30:21 PM8/18/09
to
Hi Benjamin, hi All

Thanks, Benjamin, for your response ..

On Mon, Aug 17, 2009 at 12:26:58AM +0200, Benjamin Cama wrote:
> Hi,
>
> Just guessing : for mplayer, I know there is the -srate parameter that
> can set a forced sampling rate for your sound card.

You're right, but I get this switch - IIRC - only working if I install
the attached ~/.asoundrc. Without it this option does not change
mplayer's default here - which seems to be 48000 Hz, no matter what i
feed to mplayer - and this default is pulled - just guessing here -
from maybe /usr/share/alsa/alsa.conf

> Maybe it will work, but the s24le to s16le conversion looks strange
> too ...

Actually I haven't understood the {big,little} endian sound oddities
here - I recommend a look at 'aplay -v' and play some sound file: I
guess alsa just eats any sound, whether big or little endian, and
plays it back according to the endianness it finds on the hardware -
in that case big endian.

The solution:

If I install the attached ~/asoundrc both mplayer and aplay play the
files according to the values the sound files have - the depth at which
they're played back seems to depend on the rate they're played back -
that's nearly exactly what I was looking for. With mplayer I can even
change the rate with the -srate switch .. and yes, the rate is
commented out in the attached .asoundrc ...

Please note that I don't understand why this .asoundrc works as it
does: the documentation I found on the ALSA specifics was unusable
here - in the end I tested and edited config files I found on the
Interwebs. The one attached is the result of these tests.

If you want to explore your soundcard, and what it can do - sample
rate and depth: I use alsacap for this purpose, a little tool you find
at
http://www.volkerschatz.com/noise/alsa.html
- it compiled here in a second or 2 ...

------------------------------------

$ ./alsacap -h
Usage: alsacap [-R] [-C <card #> [-D <device #>]]
alsacap [-R] -d <device name> [-r <rate>|-c <# of channels>|-f <sample format>]...
ALSA capability lister.
First form: Scans one or all soundcards known to ALSA for devices,
subdevices and parameter ranges. -R causes a scan for recording
rather than playback devices. The other options specify the sound
card and possibly the device by number.
Second form: Displays ranges of configuration parameters for the given
ALSA device. Unlike with the first form, a non-hardware device may be
given. Up to three optional command-line arguments fix the rate,
number of channels and sample format in the order in which they are
given. The remaining parameter ranges are output. If unique, the
number of significant bits of the sample values is output. (Some
sound cards ignore some of the bits.)

--------------------------------------

$ ./alsacap
*** Scanning for playback devices ***
Card 0, ID `SoundByLayout', name `SoundByLayout'
Device 0, ID `Master', name `', 1 subdevices (1 available)
2 channels, sampling rate 8000..96000 Hz
Sample formats: S16_BE, S32_BE
Subdevice 0, name `subdevice #0

-----------------------------------------

$ ./alsacap -R
*** Scanning for recording devices ***
Card 0, ID `SoundByLayout', name `SoundByLayout'
Device 0, ID `Master', name `', 1 subdevices (1 available)
2 channels, sampling rate 8000..96000 Hz
Sample formats: S16_BE, S32_BE
Subdevice 0, name `subdevice #0'

------------------------------------------

.asoundrc
0 new messages