Re: [Alsa-user] Parallel/simultaneous recording (using threads) on multiple channels using M-Audio M-Track Eight

2017-04-28 Thread zcx
The .asoundrc I posted split the 4 inputs of the Delta 44 into 2 
recording pairs.

It worked with arecord but it would not work with the app that I wanted 
to use it with :(  I had the same errors that you have reported.

Using jack and the alsa jack plugin...

http://jackaudio.org/faq/routing_alsa.html

...splits the pairs reliably, so I used that instead.

Although I have the app source I do not know enough about alsa or the 
code to troubleshoot this further.

By the way, splitting the 4 outputs into 2 playback pairs with dshare 
was not a problem.

Although jack introduces some additional latency it was acceptable with 
in this case.

zcx

On 28/04/17 08:28, SREEKANTH SREEKUMAR wrote:
> I have M-Audio M-Track Eight, a USB based soundcard that I use to play and 
> record audio files using a python based tool I wrote.
.
.
.
> But, with the above, I figured out that it is not possible to play and record 
> on multiple channels simultaneously.
.
.
.
> "ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave
>
> arecord: main:722: audio open error: Device or resource busy"
>
.
.
.
>
> The user in the first post seems to have solved by adding the following to 
> his .asoundrc:
>
>
> pcm.D44_cslave {
> type dsnoop
> ipc_key 223456
> slave {
> pcm "hw:0,0"
> rate48000
> period_time 0   # in microseconds
> buffer_size 256 # in bytes
> period_size 64  # in bytes
> channels4
> format  S32_LE
> }
> bindings {
> 0 0
> 1 1
> 2 2
> 3 3
> }
> }
>
> pcm.D44_ch12_capture {
> typeplug
> ttable.0.0 1
> ttable.1.1 1
> slave.pcm   D44_cslave
> }
>
> pcm.D44_ch34_capture {
> typeplug
> ttable.0.2 1
> ttable.1.3 1
> slave.pcm   D44_cslave
> }
.
.
.
> Now, my questions are :
> 1. What could be the right configuration for me if I want to use the input 
> and output channels exclusively for capture/record and playing respectively? 
> Also, are my `arecord` and `aplay` commands fine?
> 2. If the error shows that dsnoop is indeed busy, then why was it not being 
> shown in the output of `lsof /dev/snd/pcm*`. The error clearly says there is 
> a definite problem with `dsnoop`, does that mean that it is not meant for 
> simultaneous/multi-channel recording? I mean is there a conflict between 
> `dsnoop` and `dshare` or if multiple instances of `dsnoop` is what is causing 
> the problem?


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


[Alsa-user] Parallel/simultaneous recording (using threads) on multiple channels using M-Audio M-Track Eight

2017-04-28 Thread SREEKANTH SREEKUMAR
I have M-Audio M-Track Eight, a USB based soundcard that I use to play and 
record audio files using a python based tool I wrote. My device definitions in 
.asoundrc looks like this:



pcm.!default {
type plug
slave {
   pcm "hw:1,0"
}
}

ctl.!default {
type hw
card 1
}

pcm_slave.m-audio_m-track_eight_1 {
pcm "hw:1,0"
channels 8
rate 44100
buffer_size 4096
period_size 1024
}

pcm.outch1 {
type dshare
ipc_key 
slave m-audio_m-track_eight_1
bindings [ 0 ]
hint.description "M-Audio M-Track Eight output/playback channel 1 (from 
output port 1)"
}

pcm.inch1 {
type dsnoop
ipc_key 2111
slave m-audio_m-track_eight_1
bindings [ 0 ]
hint.description "M-Audio M-Track Eight input/capture channel 1 (from input 
port 1)"
}

pcm.outch2 {
type dshare
ipc_key 1112
slave m-audio_m-track_eight_1
bindings [ 1 ]
hint.description "M-Audio M-Track Eight output/playback channel 2 (from 
output port 2)"
}

pcm.inch2 {
type dsnoop
ipc_key 2112
slave m-audio_m-track_eight_1
bindings [ 1 ]
hint.description "M-Audio M-Track Eight input/capture channel 2 (from input 
port 2)"
}

pcm.outch3 {
type dshare
ipc_key 1113
slave m-audio_m-track_eight_1
bindings [ 2 ]
hint.description "M-Audio M-Track Eight output/playback channel 3 (from 
output port 3)"
}

pcm.inch3 {
type dsnoop
ipc_key 2113
slave m-audio_m-track_eight_1
bindings [ 2 ]
hint.description "M-Audio M-Track Eight input/capture channel 3 (from input 
port 3)"
}

pcm.outch4 {
type dshare
ipc_key 1114
slave m-audio_m-track_eight_1
bindings [ 3 ]
hint.description "M-Audio M-Track Eight output/playback channel 4 (from 
output port 4)"
}

pcm.inch4 {
type dsnoop
ipc_key 2114
slave m-audio_m-track_eight_1
bindings [ 3 ]
hint.description "M-Audio M-Track Eight input/capture channel 4 (from input 
port 4)"
}

pcm.outch5 {
type dshare
ipc_key 1115
slave m-audio_m-track_eight_1
bindings [ 4 ]
hint.description "M-Audio M-Track Eight output/playback channel 5 (from 
output port 5)"
}

pcm.inch5 {
type dsnoop
ipc_key 2115
slave m-audio_m-track_eight_1
bindings [ 4 ]
hint.description "M-Audio M-Track Eight input/capture channel 5 (from input 
port 5)"
}

pcm.outch6 {
type dshare
ipc_key 1116
slave m-audio_m-track_eight_1
bindings [ 5 ]
hint.description "M-Audio M-Track Eight output/playback channel 6 (from 
output port 6)"
}

pcm.inch6 {
type dsnoop
ipc_key 2116
slave m-audio_m-track_eight_1
bindings [ 5 ]
hint.description "M-Audio M-Track Eight input/capture channel 6 (from input 
port 6)"
}

pcm.outch7 {
type dshare
ipc_key 1117
slave m-audio_m-track_eight_1
bindings [ 6 ]
hint.description "M-Audio M-Track Eight output/playback channel 7 (from 
output port 7)"
}

pcm.inch7 {
type dsnoop
ipc_key 2117
slave m-audio_m-track_eight_1
bindings [ 6 ]
hint.description "M-Audio M-Track Eight input/capture channel 7 (from input 
port 7)"
}

pcm.outch8 {
type dshare
ipc_key 1118
slave m-audio_m-track_eight_1
bindings [ 7 ]
hint.description "M-Audio M-Track Eight output/playback channel 8 (from 
output port 8)"
}

pcm.inch8 {
type dsnoop
ipc_key 2118
slave m-audio_m-track_eight_1
bindings [ 7 ]
hint.description "M-Audio M-Track Eight input/capture channel 8 (from input 
port 8)"
}



But, with the above, I figured out that it is not possible to play and record 
on multiple channels simultaneously. I do this by executing the following 
command in separate threads in a python script:


arecord -D plug:"+str(in_id)+" -c 1 -d "+str(duration)+" -f S16_LE -r 
"+str(rate)+" "+rec_filename


where `in_id` is the input channel variable that I pass to each of the threads.


More specifically, the `arecord` throws the error:


"ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave

arecord: main:722: audio open error: Device or resource busy"

I tried to debug this by running `lsof /dev/snd/pcm*` right before I start 
recording using `arecord` in my record function in the program, I see the 
following:


COMMAND   PIDUSER   FD   TYPE DEVICE SIZE/OFF NODE NAME
aplay   12236   user4  memCHR  116,3   493 /dev/snd/pcmC1D0p
aplay   12236   user44u   CHR  116,3  0t0  493 /dev/snd/pcmC1D0p


Then I came across the following two posts:
https://www.spinics.net/linux/fedora/alsa-user/msg14391.html
https://askubuntu.com/questions/27416/record-8-separate-line-in-channels-from-m-audio-delta-1010-card


The user in the first post seems to have solved by adding the following to his 
.asoundrc:


pcm.D44_cslave {
type dsnoop
ipc_key 223456
slave {
pcm "hw:0,0"
rate48000
period_time 0   # in