Talk:.asoundrc

From the ALSA wiki

Revision as of 22:09, 3 December 2009 by Rapidfire (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Copy input and output streams into a file

This works, but it's extremely rude. I would like to have a result file with both streams mixed together, which would not overwrite itself every time, but the docs are extremely terse on this topic. I wasn't able to figure out how exactly copy is supposed to work, or how to split and join streams... I hope some brave soul takes this up and modifies it to be pretty and useful.

The conversion into wavs for me is:

sox -V -r48000 -c2 -w -s $1 $1.wav

but your stream may be at different rate etc. Would be nice to run it through a rate thingie but I didn't have the time to try to figure it out as well.

pcm.duplex {
       type asym
       playback.pcm "dmix"
       capture.pcm "dsnoop"
  }


pcm.rec_out {
       type file
       file    "/home/grin/tmp/rec_out.raw"
       slave {
               pcm duplex
       }
}

pcm.rec_mic {
       type file
       file    "/home/grin/tmp/rec_mic.raw"
       slave {
               pcm duplex
       }
}

--Grin 10:30, 22 June 2007 (EST)

Converting stereo to mono sound

There must be several ways to get this accomplished, but I wrote up a sample ~/.asoundrc file that can downmix to mono by default. Not sure if this is the best way to do it. Is it worth merging into the article?

Of course, it is often possible to tweak the applications or sound servers rather than the alsa layer itself. In "Alsa Force Mono (Ubuntu Forum)", the issue comes up and is resolved in this way. In my case, the application is a bit hard to manipulate, etc., ...


  pcm.card0 {
      type hw
      card 0
  }
  pcm.mono {
      type route
      slave.pcm card0
      slave.channels 2
      ttable.0.0 0.5
      ttable.0.1 0.5
      ttable.1.0 0.5
      ttable.1.1 0.5 
  }
  pcm.!default {
      type route
      slave.pcm card0
      slave.channels 2
      ttable.0.0 0.5
      ttable.0.1 0.5
      ttable.1.0 0.5
      ttable.1.1 0.5 
  }

-- Eolvwa 12:55, 13 April 2008 (EST)

Splitting output into front, rear, center, side outputs...

Using the recipe on that page, I manage to send output to front OR rear

I tried to expand the recipe like that :

pcm.out12 {
   type plug
   slave {
       pcm "dshare"
       channels 4
   }
   ttable.0.0 1
   ttable.1.1 1
}
pcm.out34 {
   type plug
   slave {
       pcm "dshare"
       channels 4
   }
   ttable.0.2 1
   ttable.1.3 1
}
pcm.out56 {
   type plug
   slave {
       pcm "dshare"
       channels 4
   }
   ttable.0.4 1
   ttable.1.5 1
}
pcm.out78 {
   type plug
   slave {
       pcm "dshare"
       channels 4
   }
   ttable.0.6 1
   ttable.1.7 1
}

but it does not work, I have no sound when using out56 or out78 and aplay just shows 4 lines in the transformation table :

# cat /root/temp.wav | aplay -vD out78
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Plug PCM: Route conversion PCM (sformat=S32_LE)
 Transformation table:
   0 <- none
   1 <- none
   2 <- none
   3 <- none
Its setup is:
 stream       : PLAYBACK
 access       : RW_INTERLEAVED
[...]

I will post the solution if I find one and if anyone wants to help, well... :-)

Court-jus 20:11, 28 January 2009 (EST)

separate outputs

OK, i reply to myself for future reference

here is the asound.conf that I use and now I can play on any of the outputs :

# cat /etc/asound.conf
pcm.dshare {
   type dmix
   ipc_key 2048
   slave {
       pcm "hw:0"
       rate 44100
       period_time 0
       period_size 1024
       buffer_size 8192
       channels 8
   }
   bindings {
       0 0
       1 1
       2 2
       3 3
       4 4
       5 5
       6 6
       7 7
   }
}
pcm.out12 {
   type plug
   slave {
       pcm "dshare"
       channels 8
   }
   # ttable syntax (as I understand it) :
   #   ttable.INPUTCHANNEL.OUTPUTCHANNEL VOLUME
   #   so in the example below, I redirect the first channel of the input to the first channel of the output
   #   i do the same for the second channel and I mute the others
   ttable.0.0 1
   ttable.1.1 1
   ttable.0.2 0
   ttable.1.3 0
   ttable.0.4 0
   ttable.1.5 0
   ttable.0.6 0
   ttable.1.7 0
}
pcm.out34 {
   type plug
   slave {
       pcm "dshare"
       channels 8
   }
   ttable.0.0 0
   ttable.1.1 0
   ttable.0.2 1
   ttable.1.3 1
   ttable.0.4 0
   ttable.1.5 0
   ttable.0.6 0
   ttable.1.7 0
}
pcm.out56 {
   type plug
   slave {
       pcm "dshare"
       channels 8
   }
   ttable.0.0 0
   ttable.1.1 0
   ttable.0.2 0
   ttable.1.3 0
   ttable.0.4 1
   ttable.1.5 1
   ttable.0.6 0
   ttable.1.7 0
}
pcm.out78 {
   type plug
   slave {
       pcm "dshare"
       channels 8
   }
   ttable.0.0 0
   ttable.1.1 0
   ttable.0.2 0
   ttable.1.3 0
   ttable.0.4 0
   ttable.1.5 0
   ttable.0.6 1
   ttable.1.7 1
}

and here is how I can use it :

# cat temp.wav | aplay -D out78
# mplayer -ao alsa:device=out78 temp.wav

Court-jus 00:05, 29 January 2009 (EST)

Converting mono to stereo

Stereo to mono is nice, but how do you convert two mono channels into one stereo channel? --Rapidfire 08:09, 4 December 2009 (EST)

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox