Skip to contentSkip to conversation

alsa formats explained?

DISCUSSION James Courtier-Dutton 2 participants 2 messages Jul 1, 2004

lore
Share & tools
lore
#1 lore raw
In reply to James Courtier-Dutton
Quoted 7 lines · James Courtier-Dutton

I need to send 32bits for each sample to a sound card. The contents of the value is LE.
The card only takes notice of the high 24bits. 0xffffff00

Which alsa format string should I use in the alsa driver to tell alsa-lib to send samples in this format.

Quoted 8 lines

I want alsa-lib to be able to do the correct conversions:
E.g. 8bit samples -> 0xff000000

     16bit samples -> 0xffff0000
     24bit samples -> 0xffffff00
     32bit samples -> 0xffffffff  (but the lower 8 bits 0x000000ff will 

be dropped by the hardware.)

I think I should use S32_LE, but I wanted to verify that here first.

Correct.

Quoted 5 lines

I can find a bit of the alsa docs explaining this, but it seems a bit unclear to me. Maybe a diagram should be added or something like this:
S32_LE, alsa-lib sends to the hardware 24bit samples -> 0xffffff00 S24_LE, alsa-lib sends to the hardware 24bit samples -> 0x00ffffff (^ I think it works like that ^)

Correct.

Quoted 8 lines

Here is what I found:
"24-bit linear samples are using three low bytes from the 32-bit word. When hardware uses 24-bit format in 32-bit linear samples (the low byte is ignored), then the sample format is 32-bit, and the msbits_per_sample member from the snd_pcm_channel_setup_t structure shows count of most significant bits being used (24 in this case). The other formats (for example 20-bit linear sample stored in the 32-bit linear sample) may follow this example as well."

What's unclear?

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com

#0 lore raw

I need to send 32bits for each sample to a sound card. The contents of the value is LE.
The card only takes notice of the high 24bits. 0xffffff00

Which alsa format string should I use in the alsa driver to tell alsa-lib to send samples in this format.

I want alsa-lib to be able to do the correct conversions:
E.g. 8bit samples -> 0xff000000

    16bit samples -> 0xffff0000
    24bit samples -> 0xffffff00
    32bit samples -> 0xffffffff  (but the lower 8 bits 0x000000ff will 

be dropped by the hardware.)

I think I should use S32_LE, but I wanted to verify that here first.

I can find a bit of the alsa docs explaining this, but it seems a bit unclear to me. Maybe a diagram should be added or something like this:
S32_LE, alsa-lib sends to the hardware 24bit samples -> 0xffffff00
S24_LE, alsa-lib sends to the hardware 24bit samples -> 0x00ffffff
(^ I think it works like that ^)

Here is what I found:
"24-bit linear samples are using three low bytes from the 32-bit word. When hardware uses 24-bit format in 32-bit linear samples (the low byte is ignored), then the sample format is 32-bit, and the msbits_per_sample member from the snd_pcm_channel_setup_t structure shows count of most significant bits being used (24 in this case). The other formats (for example 20-bit linear sample stored in the 32-bit linear sample) may follow this example as well."

Cheers
James

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com