asoundrc snd-aloop

Non release banter
User avatar
Slaxmax
Contributor
Contributor
Posts: 408
Joined: 03 Jan 2013, 09:51
Distribution: KDE4
Location: Campinas Brazil https://goo.gl/yrxwKi

asoundrc snd-aloop

Post#1 by Slaxmax » 29 Jul 2014, 00:11

How to work with module snd-aloop?
I have a compiled kernel with this module and activated with modprobe.
I do not know how to work ~.asoundrc, I need this for stream alsa.

sound devices

Code: Select all

guest@porteus:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: ALC888 Analog [ALC888 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 1: ALC888 Digital [ALC888 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
thanks
“DNA is like a computer program but far, far more advanced than any software ever created.”
― Bill Gates, The Road Ahead

cttan
Shogun
Shogun
Posts: 333
Joined: 26 Jan 2011, 16:15
Distribution: Porteus 3.2 and 4.0 64bit KDE
Location: Malaysia

Re: asoundrc snd-aloop

Post#2 by cttan » 29 Jul 2014, 02:48

Hi Slaxmax,

Maybe you can try fifo and cat without touching the kernel.

http://www.debian-administration.org/ar ... audio_data

I have below code and able to stream a radio channel to my Asterisk phone. But alas the mplayer is almost constantly at 50% CPU usage.

Code: Select all

#!/bin/bash
PIPE="/tmp/onefmmohpipe"
mknod $PIPE p
mplayer http://208.80.54.79:443/ONEFMAAC -really-quiet -quiet -af resample=8000,channels=1,format=alaw -ao pcm:fast:file=$PIPE | cat $PIPE
rm $PIPE
exit

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: asoundrc snd-aloop

Post#3 by brokenman » 29 Jul 2014, 04:20

asound.rc is just a configuration file for alsa. Run the following script to create you config.Run it as: myasound-script.sh > ~.asoundrc

Code: Select all

#!/bin/bash
# asoundrc v0.1.0 20090101 markc@renta.net GPLv3
# asoundrc v0.2.0 20090320 quatro_por_quatro@yahoo.es GPLv3
#
# A simple script to create a particular default audio device regardless
# of what cards are loaded or in what order. It could be used anytime or
# placed in a ~/.bashrc script for a persistent setup every login.
#
# Usage: asoundrc [DEFAULT_CARD] > ~/.asoundrc

# use the first parameter as the card name, or else
# look for the sound card, discarding those that are only microphones
# when there are multiple cards, use the first one
if default_card="${1:-$(cat "$(for f in $(ls -1 /proc/asound/card[0-9]*/{midi,codec}* 2>/dev/null); do echo "${f%/*}"; done \
| sed -e '\|^[\[:blank:]\]$|d' -e 'q')/id" 2>/dev/null)}"; then
   echo "Using sound card: ${default_card}" >&2 
   cat /proc/asound/card[0-9]*/id | \
   gawk --assign default_card="${default_card}" \
'{print "pcm."$1" { type hw; card "$1"; }\nctl."$1" { type hw; card "$1"; }" }
END {print "pcm.!default pcm."default_card"\nctl.!default ctl."default_card}'
else
   echo "Warning: No sound cards found." >&2
fi
You can read more about asoundrc here: http://www.alsa-project.org/main/index.php/Asoundrc

Here is hwo to stream audio over your network: http://ywwg.com/wordpress/?p=1201

Boa sorte!
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
Slaxmax
Contributor
Contributor
Posts: 408
Joined: 03 Jan 2013, 09:51
Distribution: KDE4
Location: Campinas Brazil https://goo.gl/yrxwKi

Re: asoundrc snd-aloop

Post#4 by Slaxmax » 29 Jul 2014, 19:42

Thanks guys

I can do stream alsa to http (mp3) using pulseaudio, vlc and sox, but I do not want to use it.
I would use the snd-aloop module, but I have to mix alsa for this module.
The problem is that I do not know, I've tried many methods and it still fails.
I am also doing tests with low-latency stream.
“DNA is like a computer program but far, far more advanced than any software ever created.”
― Bill Gates, The Road Ahead

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: asoundrc snd-aloop

Post#5 by brokenman » 29 Jul 2014, 20:47

Can you describe your goal in detail? Do you want to stream audio from your Porteus machine to another machine on the network, or do you want to stream audio from somewhere else TO your porteus machine?
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
Slaxmax
Contributor
Contributor
Posts: 408
Joined: 03 Jan 2013, 09:51
Distribution: KDE4
Location: Campinas Brazil https://goo.gl/yrxwKi

Re: asoundrc snd-aloop

Post#6 by Slaxmax » 29 Jul 2014, 21:02

Porteus to porteus in LAN.
I can stream alsa over http (pulse,sox and vlc) but I want stream using snd-aloop only (without pulseaudio).
“DNA is like a computer program but far, far more advanced than any software ever created.”
― Bill Gates, The Road Ahead

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: asoundrc snd-aloop

Post#7 by brokenman » 29 Jul 2014, 22:03

Very basic instructions for doing this over ssh.

http://plasmasturm.org/log/soundserverhack/
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
Slaxmax
Contributor
Contributor
Posts: 408
Joined: 03 Jan 2013, 09:51
Distribution: KDE4
Location: Campinas Brazil https://goo.gl/yrxwKi

Re: asoundrc snd-aloop

Post#8 by Slaxmax » 31 Jul 2014, 19:44

Best way for me.
OBS: You need compile snd-aloop for your kernel (not compiled in porteus default)
see: http://www.alsa-project.org/main/index. ... dule-aloop

To stream alsa (pc soundcard) to http (mp2) using snd-aloop and vlc. I found the following configuration that worked.
I don't know how asoundrc operates, but it worked. :D

/home/guest/.asoundrc

Code: Select all

pcm.!default {
  type asym
  playback.pcm "LoopAndReal"
  #capture.pcm "looprec"
  capture.pcm "hw:0,0"
}

pcm.looprec {
    type hw
    card "Loopback"
    device 1
    subdevice 0
}


pcm.LoopAndReal {
  type plug
  slave.pcm mdev
  route_policy "duplicate"
}


pcm.mdev {
  type multi
  slaves.a.pcm pcm.MixReale
  slaves.a.channels 2
  slaves.b.pcm pcm.MixLoopback
  slaves.b.channels 2
  bindings.0.slave a
  bindings.0.channel 0
  bindings.1.slave a
  bindings.1.channel 1
  bindings.2.slave b
  bindings.2.channel 0
  bindings.3.slave b
  bindings.3.channel 1
}


pcm.MixReale {
  type dmix
  ipc_key 1024
  slave {
    pcm "hw:0,0"
    rate 48000
    #rate 44100
    periods 128
    period_time 0
    period_size 1024 # must be power of 2
    buffer_size 8192
  }
}

pcm.MixLoopback {
  type dmix
  ipc_key 1025
  slave {
    pcm "hw:Loopback,0,0"
    rate 48000
    #rate 44100
    periods 128
    period_time 0
    period_size 1024 # must be power of 2
    buffer_size 8192
  }
}
load module snd-aloop

Code: Select all

root@porteus:/home/guest# modprobe snd-aloop
stream using vlc (terminal)

Code: Select all

cvlc -v -q alsa://hw:1,1  --sout '#transcode{acodec=mpga,ab=192}:standard{access=http,mux=raw,dst=:8080} '
to play stream in your device (mobile, tablet, etc...)
open vlc or similar application and type
http://IP-YOUR-PC:8080
example (in my case)
http://192.168.2.101:8080

to play in other pc porteus
type in terminal (example)

Code: Select all

mplayer http://192.168.2.101:8080
enjoy :good:
“DNA is like a computer program but far, far more advanced than any software ever created.”
― Bill Gates, The Road Ahead

Post Reply