Page 3 of 4

Re: snd-aloop, jack, etc

Posted: Tue May 04, 2010 5:56 am
by thorgal
hi guys, I tried the whole thing on my laptop, which has a prepackaged kernel installed (debian unstable) unlike my DAW PC where I compiled the kernel.

This is not very good from kernel packagers I believe. I had to do the following:

- install kernel source package from repository: yes, sucks! kernel headers are not enough!
- untar it
- cp /boot/config-`uname -r` .config
- make oldconfig && make prepare && make scripts
- edit Makefile and add extra version string : yes! even that is not included!!

cd to alsa-driver dir, followed my own WIKI but with an extra configure option to the driver compilation:

Code: Select all

./configure --with-cards=loopback --with-kernel=/usr/src/linux-source-2.6.32
since the linux source dir was called 'linux-source-2.6.32'. Otherwise, configure will pick the kernel version (2.6.32-4-686 on my laptop) and use the kernel-headers directory installed by the debian packaging, which failed in the 1st place.


But even then, I had a "vermagic mismatch" at modprobe time, so I used 'modprobe -f snd-aloop' (forcing, which "taints" the kernel) to make it work.


Pathetic ....

EDIT: I don't understand why this module is not included by default in kernel packages. It wouldn't harm to have it, would it ?

Re: snd-aloop, jack, etc

Posted: Sat May 08, 2010 4:10 pm
by thorgal
talking about loop, did you know that jackd can be launched with loopback ports ?

try

Code: Select all

jackd -L n  -etc <your usual options>
where n is the number of loopback ports you want. There will be an extra client called loopback.
Plug a system capture port to a loopback playback port, and plug the corresponding loopback capture port to your system playback ports :)

This has nothing to do with the ALSA virtual loopback card, all jack stuff here. This can be handy in situations when you want to loop back some playback signal to capture ports :)

Re: snd-aloop, jack, etc

Posted: Sat May 08, 2010 5:53 pm
by autostatic
thorgal wrote:EDIT: I don't understand why this module is not included by default in kernel packages. It wouldn't harm to have it, would it ?
In Ubuntu 9.10 Karmic Koala it is included in the generic kernel but not in the realtime kernel. I think it is just one single line in the ALSA-card-list file in the debian directory of the alsa-driver package that prevents the snd-aloop module from building. But I know jack about repackaging kernels/audio drivers.
Considering LMMS, I just compiled the most recent git commit patched with a JACK ring buffer patch and it seems to work a bit more stable.
The JACK loopback device is another rabbit out of the hat. Luckily there's Non-Mixer so at the moment I have no real need for such a loopback possibility.

Re: snd-aloop, jack, etc

Posted: Fri May 14, 2010 5:56 pm
by thorgal
hi guys,

I found the time today to look into the last remaining issue (initialization of the jack bridge while an ALSA app is playing). I added a few changes to asoundrc and the jack clients so the ugly hack is no longer needed :) For skype, you can set all ALSA devices to 'default' (capture, speakers, ringing).

http://alsa.opensrc.org/index.php/Jack_ ... ack_bridge

PS: Note that you can also use the ALSA OSS emulation. If you load the kernel module snd-pcm-oss, it will create by default a /dev/dsp1 which OSS app can use. I tried it with mplayer

mplayer -ao oss:/dev/dsp1 some_audio_file and it works :)
for OSS capture, that's not really possible, I don't know how to map /dev/adsp1 to subdevice hw:Loopback,0,1

Re: snd-aloop, jack, etc

Posted: Wed Jun 09, 2010 9:05 am
by thorgal
hi guys,

I had the time to look into this kernel module crap yesterday evening and I found an easy way to remedy the problem but it is a little drastic.

1- snd-aloop is not included in the kernel tree baseline, so you have to compile it from the alsa-driver source code.

2- the ALSA version mismatch is worked around by doing what I wanted to avoid in the first place, namely a complete install of the alsa-driver by issuing a 'make install'.

So, as a test bed, I installed kernel 2.6.33.5-rt22 from the sidux "horo" repository. I added this in my /etc/apt/sources.list

Code: Select all

deb http://cryptomys.de/experimental/ ./
deb-src http://cryptomys.de/experimental/ ./
then

Code: Select all

sudo apt-get update
sudo apt-get install horo-keyring
sudo apt-get install linux-image-2.6.33.5-rt22 linux-headers-2.6.33.5-rt22
I downloaded the ALSA driver source code 'alsa-driver-1.0.22.1' (1.0.21 did not work). Note I haven't tried 1.0.23 yet.

I then did a little kernel tweak:

Code: Select all

cd /lib/modules/2.6.33.5-rt22/build/include/linux
sudo ln -s ../generated/* .
this is because some kernel headers that are generated at compile time are no longer in "include/linux" but in "include/generated" and that confuses certain packages like alsa-driver during compile time.

I then configured and compiled alsa-driver. Since I wanted to do a complete make install, I had to include all the cards I was interested in:

Code: Select all

cd alsa-driver-1.0.22.1
./configure --with-cards=hdsp,loopback,hrtimer --with-oss=yes --with-sequencer=yes
make
sudo make install
I rebooted and everything worked :)

EDIT:
Just tried ALSA 1.0.23 (driver, lib, utils, etc). I installed packages from debian and compiled alsa-driver-1.0.23 as above. Everything works as expected :)

Re: snd-aloop, jack, etc

Posted: Fri Aug 27, 2010 9:42 pm
by Capoeira
Hi Thorgal,

trying to set up the device:

sidenote for ARCH-ERS: snd-aloop now in AUR: http://aur.archlinux.org/packages.php?ID=40180

when I try to set up the cloop-thing I get this (ploop-thing works):

Code: Select all

[studio@myhost ~]$ alsa_in -j cloop -dcloop
WARNING: chennel count does not match (requested 2 got 32)
WARNING: buffer size does not match: (requested 2048, got 11026)
WARNING: period size does not match: (requested 1024, got 5513)
selected sample format: float
Falha de segmentação
[studio@myhost ~]$ 

Re: snd-aloop, jack, etc

Posted: Sat Aug 28, 2010 12:37 am
by Capoeira
Capoeira wrote:Hi Thorgal,

trying to set up the device:

sidenote for ARCH-ERS: snd-aloop now in AUR: http://aur.archlinux.org/packages.php?ID=40180

when I try to set up the cloop-thing I get this (ploop-thing works):

Code: Select all

[studio@myhost ~]$ alsa_in -j cloop -dcloop
WARNING: chennel count does not match (requested 2 got 32)
WARNING: buffer size does not match: (requested 2048, got 11026)
WARNING: period size does not match: (requested 1024, got 5513)
selected sample format: float
Falha de segmentação
[studio@myhost ~]$ 

OK, snd-aloop went default sound-device in my system and in qjackctl device was default :?

It's working now, kind of
EDIT: Skype is working now like nover before, even with low-latency
Amarok > Xine > Alsa > snd-aloop > Jconvolver is too much. lol. get slow system and volume reacts 4-5 sec. after changing

Re: snd-aloop, jack, etc

Posted: Sat Aug 28, 2010 8:07 am
by thorgal
hey, glad you got it to work :)
don't except too much from this hack, as I mentioned before, low latency is not its strength!

for amarok, have you tried the gstreamer backend if you want to use ALSA ? I never attempted to use a convolver on the output of 'cloop'. Maybe you could tune the parameters of the convolver or increase the jack latency ? what is your system spec ?

Re: snd-aloop, jack, etc

Posted: Sun Aug 29, 2010 5:49 pm
by Capoeira
thorgal wrote:hey, glad you got it to work :)
don't except too much from this hack, as I mentioned before, low latency is not its strength!

for amarok, have you tried the gstreamer backend if you want to use ALSA ? I never attempted to use a convolver on the output of 'cloop'. Maybe you could tune the parameters of the convolver or increase the jack latency ? what is your system spec ?
yea, I HAD it run. I was testing it on my normal kernel.
Now that I'm trying to make it on my realtime-kernel I get a connection-problem all the time..trtied reinstalling snd-aloop already
can you see what the problem is? (this is with exactly your .asoundrc you posted in alsa-wiki)

Code: Select all

[studio@myhost ~]$ cat /proc/asound/modules
 0 snd_aloop
 1 snd_usb_audio
[studio@myhost ~]$ cat /proc/asound/cards
 0 [Loopback       ]: Loopback - Loopback
                      Loopback 1
 1 [Duo            ]: USB-Audio - USB AudioSport Duo
                      M Audio USB AudioSport Duo at usb-0000:00:1d.1-1, full speed
[studio@myhost ~]$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: 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 0: 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
card 1: Duo [USB AudioSport Duo], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
[studio@myhost ~]$ sudo modinfo snd-aloop
Senha:
filename:       /lib/modules/2.6.33-rt/kernel/sound/drivers/snd-aloop.ko
license:        GPL
description:    A loopback soundcard
author:         Jaroslav Kysela <perex@perex.cz>
depends:        snd-pcm,snd
vermagic:       2.6.33-rt SMP preempt mod_unload                                                                                     
parm:           index:Index value for loopback soundcard. (array of int)                                                             
parm:           id:ID string for loopback soundcard. (array of charp)                                                                
parm:           enable:Enable this loopback soundcard. (array of bool)                                                               
parm:           pcm_substreams:PCM substreams # (1-8) for loopback driver. (array of int)                                            
parm:           pcm_notify:Break capture when PCM format/rate/channels changes. (array of int)                                       
[studio@myhost ~]$ lsmod | grep aloop                                                                                                
snd_aloop              10061  0                                                                                                      
snd_pcm                69540  5 snd_usb_audio,snd_pcm_oss,snd_aloop                                                                  
snd                    53057  17 snd_usb_audio,snd_hwdep,snd_usb_lib,snd_rawmidi,snd_seq_oss,snd_seq,snd_seq_device,snd_pcm_oss,snd_mixer_oss,snd_aloop,snd_pcm,snd_timer                                                                                                 
[studio@myhost ~]$ # capture client
[studio@myhost ~]$ alsa_in -j cloop -dcloop
ALSA lib pcm_dsnoop.c:593:(snd_pcm_dsnoop_open) unable to open slave
Capture open error: Invalid argument
[studio@myhost ~]$ # playback client
[studio@myhost ~]$ alsa_out -j ploop -dploop 
Capture open error: Invalid argument
[studio@myhost ~]$ 

Re: snd-aloop, jack, etc

Posted: Mon Aug 30, 2010 9:30 am
by thorgal
... mmmm, there seems to be conflicting things but it is very hard to guess from this output.

Can you use the loopback device without jack ? say, if it is your ALSA default (defined in ~/.asoundrc), can you try something like:

Code: Select all

mplayer -ao alsa <some audio file>
??

does mplayer play the file alright ? (even though you cannot hear it of course)

Re: snd-aloop, jack, etc

Posted: Mon Aug 30, 2010 11:54 am
by Capoeira
thorgal wrote:

Code: Select all

mplayer -ao alsa <some audio file>
??

does mplayer play the file alright ? (even though you cannot hear it of course)

Code: Select all

[studio@myhost música clássica]$ mplayer -ao alsa Ravel\ -\ Bolero\ \&\ other\ Orchestral\ Works\ \ 02\ -\ La\ Valse.mp3 
MPlayer SVN-r32025-4.5.1 (C) 2000-2010 MPlayer Team
159 audio & 347 video codecs
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 Ravel - Bolero & other Orchestral Works  02 - La Valse.mp3.
Audio only file format detected.
Clip info:
 Title: La Valse                      
 Artist: Ravel                         
 Album: Bolero & other Orchestral Work
 Year:     
 Comment:                             
 Track: 2
 Genre: Unknown
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 44100 Hz, 2 ch, s16le, 192.0 kbit/13.61% (ratio: 24000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
[AO_ALSA] alsa-lib: pcm_hw.c:1293:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-22): Invalid argument
[AO_ALSA] alsa-lib: pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
[AO_ALSA] Playback open error: Invalid argument
Failed to initialize audio driver 'alsa'
Could not open/initialize audio device -> no sound.
Audio: no sound
Video: no video


Exiting... (End of file)
strange, because jack is working fine

Re: snd-aloop, jack, etc

Posted: Mon Aug 30, 2010 12:06 pm
by Capoeira
edit: its definitly the .asoundrc as without it alsa works. strange, because it worked woth the normal kernel.
I asked in Arch-forum now: https://bbs.archlinux.org/viewtopic.php ... 53#p818253

Re: snd-aloop, jack, etc

Posted: Mon Aug 30, 2010 7:16 pm
by thorgal
as far as I can tell, you have to compile your ALSA drivers for each kernel. Not sure that installation of precompiled stuff would work.

So if you have a 2 kernel install (normal and RT-patched), you have to go through the compilation procedure I have outlined in the howto for both. Yeah, I know, you'd rather not do it but I cannot think of a better alternative unless someone does the job for you (packager). It's a shame this loopback module is not part of the official kernel packages.

When you remove the .asoundrc, ALSA falls back to its system default, which is probably your hw:0. The resampling of the file you see is because your hardware is set up at 48k probably. If the file is not sampled at 48k, mplayer will resample on the fly I think.

Re: snd-aloop, jack, etc

Posted: Mon Aug 30, 2010 9:10 pm
by Capoeira
thorgal wrote:as far as I can tell, you have to compile your ALSA drivers for each kernel. Not sure that installation of precompiled stuff would work.

So if you have a 2 kernel install (normal and RT-patched), you have to go through the compilation procedure I have outlined in the howto for both. Yeah, I know, you'd rather not do it but I cannot think of a better alternative unless someone does the job for you (packager). It's a shame this loopback module is not part of the official kernel packages.
I had installed the package again for the kernel, logicly. Those packages are not precompiled (AUR-repro) AFAIK. The have only a script added of where to install stuff.


thorgal wrote:The resampling of the file you see is because your hardware is set up at 48k probably. If the file is not sampled at 48k, mplayer will resample on the fly I think.
no, it's set up to 41k, i've seen it today, forgot the comand.
What does the resample is DMIX: http://alsa.opensrc.org/index.php/Dmix# ... quality.3F


yea, i think i will have to do it with your method. I tried to avoid because I forget the folder, and someday will exclude it from HD. And pacagemanager gets confused

Re: snd-aloop, jack, etc

Posted: Sun Sep 05, 2010 5:36 pm
by Capoeira
Capoeira wrote: no, it's set up to 41k, i've seen it today, forgot the comand.
What does the resample is DMIX: http://alsa.opensrc.org/index.php/Dmix# ... quality.3F
how can I merge that in? I tried:

Code: Select all

# playback PCM device: using loopback subdevice 0,0
pcm.amix {
  type dmix
  ipc_key 219345
  slave {
  pcm "hw:Loopback,0,0"
  period_size 1024
        buffer_size 2048
        rate 44100
                     }
}
but still:

Code: Select all

[studio@myhost ~]$ alsa_in -j cloop -dcloop
WARNING: Rate doesn't match (requested 44100Hz, get 48000Hz)
WARNING: buffer size does not match: (requested 2048, got 12000)
WARNING: period size does not match: (requested 1024, got 6000)
selected sample format: 16bit
delay = 12416
and

Code: Select all

[studio@myhost música clássica]$ mplayer -ao alsa Ravel\ -\ Bolero\ \&\ other\ Orchestral\ Works\ \ 02\ -\ La\ Valse.mp3 
MPlayer SVN-r32025-4.5.1 (C) 2000-2010 MPlayer Team
159 audio & 347 video codecs
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 Ravel - Bolero & other Orchestral Works  02 - La Valse.mp3.
Audio only file format detected.
Clip info:
 Title: La Valse                      
 Artist: Ravel                         
 Album: Bolero & other Orchestral Work
 Year:     
 Comment:                             
 Track: 2
 Genre: Unknown
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 44100 Hz, 2 ch, s16le, 192.0 kbit/13.61% (ratio: 24000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A:   9.2 (09.2) of 745.0 (12:25.0)  0.9%