0

I am reading 1 channel audio data from buffer and writing to alsa for playback. I want to convert the PCM data from mono to stereo before writing out to the device. Is this handled automatically by some ALSA configuration? The asound.conf file:

type asym
playback.pcm {
  type plug
  slave.pcm {
  type dmix
  ipc_key 5978293 # must be unique for all dmix plugins!!!!
  ipc_key_add_uid yes
  slave {
       pcm "hw:0,0"
       channels 2
       format S16_LE
  }
  bindings {
       0 0
       1 1
  }
  }
}

Does specifying the channels as 2 in the configuration mean the dmix plugin will handle mono to stereo conversion?

0

No, you'll need other ALSA plugins for any type of conversion (sample rate, channels, ...).

Or you can go the easy route and use Pulseaudio (which comes as part of most distros today anyway): Its main usage is to allow many applications to share a soundcard, resample, convert between channels, etc. Which sounds like what you intended to do with the dmix.

If this is an XY-Problem, please edit the question with what you want to achieve, instead of what you think you need (dmix with channel bindings).

  • Thanks, I want to convert the PCM from mono->stereo before writing out to the device. alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html mentions the 'Automatic conversion plugin' (type plug). Will that work for my purpose? – Apoorva T. Aug 2 '18 at 14:12
  • I've never tried to use plug for increasing the number of channels. You may need an explicit ttable. There's also the route plugin. – dirkt Aug 2 '18 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.