Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
Hi Terry, > Yes it could be a leftover from the Python program. At the moment the > Python still runs on boot-up and then I kill it with Ctr-C. If it's a zombie it's because its parent isn't reaping its death. That means it has a parent that's living, and that will tell you whether it's the Python program or something you've manually started. `ps l 42' will give a long listing of PID 42, including PPID. > I have realised that I can play the music files no matter where they > are even though I'm using the same hw:2,0 port that has just failed > with bells. None of the bells files work with that or any other port, > but I can't see what is wrong with the format of the files and they > work if I send them to the bcm audio channel. `ffmpeg -i foo.mp4 |& grep Audio:' can show detail about a file and may highlight differences. Cheers, Ralph. -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
On Saturday, 10 March 2018 14:33:46 GMT Terry Coles wrote: > No all I have to do is work out why the bells won't play to the USB device, > but will play to the bcm device. I think I can use omxplayer for the bells, which works perfectly. It's only the mp3 files that I need to loop continuously. Thanks, Ralph for all your help again. Hopefully, I won't need to come back again, but who knows :-) -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
On Saturday, 10 March 2018 15:28:53 GMT Ralph Corderoy wrote: > Yes, but that means you've asked udev to assign an ID based on USB port, > not whether you have substituted the `1' above with that ID when trying > to play a tune. I've solved this now; as mentioned in my other post. The labels do work, but I have to use hw:label,device with mpg321. aplay seemed OK with just the label, which is what threw me. -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
Hi Terry, > > > > Have you tried using the ID you've assigned with udev based on > > > > the USB port as the card number; the `1' in `1,0' above? > > > > > > I've tried allsorts > > > > I can't tell if that includes my suggestion. :-) > > Well I did say that I'd been using udev rules. Yes, but that means you've asked udev to assign an ID based on USB port, not whether you have substituted the `1' above with that ID when trying to play a tune. > As mentioned previously, labels only work with aplay and omxplayer, > which don't support Python lists or looping through a list. This might help. Ignore aplay()'s definition; it's just because I don't have that command here. $ aplay() { s=$((RANDOM % 3 + 1)); echo playing $1 for $s s; sleep $s; } $ $ while :; do for f in zadok.mp3 black-dog.flac; do aplay $f; done; done playing zadok.mp3 for 1 s playing black-dog.flac for 3 s playing zadok.mp3 for 1 s playing black-dog.flac for 3 s playing zadok.mp3 for 2 s playing black-dog.flac for 1 s playing zadok.mp3 for 3 s ^C $ > It's easier to observe results and copy'n'paste from this machine than > from the Pi. But they don't have to behave the same, e.g. Raspbian probably thinks any audio device belongs to the one logged-in user whereas your normal distribution could be a lot more choosy because it knows there can be multiple users and perhaps multiple heads. Surely once you've ssh'd in from a terminal it all looks the same from the cut and paste point of view? :-) > ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0808", ATTR{id}="TOWER" > ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="013c", ATTR{id}="CHANCEL" Oh, you've different VID:PID now, I must have forgotten that. I thought you were going by USB port number, as explained on that page you linked to. > pcm.TOWER { > type hw > card 0 > device 0 > } Is that trying to tell it to map 0,0 to your udev TOWER ID, or that a thing called TOWER is to access 0,0 when used? Cheers, Ralph. -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
On Saturday, 10 March 2018 14:19:19 GMT Terry Coles wrote: > On Saturday, 10 March 2018 14:08:41 GMT Ralph Corderoy wrote: > > hw:label,device. Are you only using the Pi for these trials, or OK. Just spotted it. I wasn't using the device number with the label, so I was getting a 'Device not found' message. No all I have to do is work out why the bells won't play to the USB device, but will play to the bcm device. -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
On Saturday, 10 March 2018 14:08:41 GMT Ralph Corderoy wrote: > I can't tell if that includes my suggestion. :-) Well I did say that I'd been using udev rules. > Why would they? I thought the udev rules were mapping from a USB port > to a textual label. You then ditch the hw:card,device number and use As mentioned previously, labels only work with aplay and omxplayer, which don't support Python lists or looping through a list. > hw:label,device. Are you only using the Pi for these trials, or I'm using both. It's easier to observe results and copy'n'paste from this machine than from the Pi. > switching away from Raspbian? What's your udev look like after > following that guide? Raspbian is the goal. Here is the contents of /etc/udev/rules.d/70-alsa-permanent.rules: SUBSYSTEM!="sound", GOTO="my_usb_audio_end" ACTION!="add", GOTO="my_usb_audio_end" ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0808", ATTR{id}="TOWER" ATTRS{idVendor}=="0d8c", ATTRS{idProduct}=="013c", ATTR{id}="CHANCEL" LABEL="my_usb_audio_end" I've tried making the ATTR{id}=0 or 1 and that makes no difference. Here is the contents of /etc/asound.conf: pcm.!default { type hw card 0 device 0 } ctl.!default { type hw card 0 device 0 } pcm.TOWER { type hw card 0 device 0 } ctl.TOWER { type hw card 0 device 0 } pcm.CHANCEL { type hw card 1 device 0 } ctl.CHANCEL { type hw card 1 device 0 } I've also tried naming the Cards instead of using numbers. -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
On Saturday, 10 March 2018 14:04:13 GMT Ralph Corderoy wrote: > Kill how? Ctrl-C > In the same manner? Yes. > How are you identifying it as a zombie? What's the arguments for that > process? `ps ww 42' where 42 is its process ID shows them `weally > wide'. Does that tell you if it's the one that's also using hw:2,0? > Could it be you've been running your Python program and that's an mpg321 > from a leftover Subprocess.Popen? Top says it's a Zombie - it is marked z. Yes it could be a leftover from the Python program. At the moment the Python still runs on boot-up and then I kill it with Ctr-C. However, there is more evidence now: I have realised that I can play the music files no matter where they are even though I'm using the same hw:2,0 port that has just failed with bells. None of the bells files work with that or any other port, but I can't see what is wrong with the format of the files and they work if I send them to the bcm audio channel. I'm still investigating this. -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
Hi Terry, > > > subprocess.Popen(mpg321 -l -m -a hw:1,0 Playlist) > > > > Have you tried using the ID you've assigned with udev based on the > > USB port as the card number; the `1' in `1,0' above? > > I've tried allsorts I can't tell if that includes my suggestion. :-) > and whatever happens the hw: numbers never seem to bear any relation > to the ID's that i created in the udev rules. Why would they? I thought the udev rules were mapping from a USB port to a textual label. You then ditch the hw:card,device number and use hw:label,device. Are you only using the Pi for these trials, or switching away from Raspbian? What's your udev look like after following that guide? Cheers, Ralph. -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
Hi Terry, > Outside of my Python program Good, it's a lot easier to experiment and observe directly at the command line. > I can cd to a Playlist directory and issue: > > mpg321 -m -a hw:1,0 > > and it works, playing from the USB device designated CHANCEL. Staying > in the same directory I kill playback of the above file Kill how? > and issue: > > mpg321 -m -a hw:2,0 > > and it now plays from the USB device designated TOWER. If I then kill > that playback In the same manner? > and move to the directory which contains the bells and issue: > > mpg321 -m -a hw:2,0 > > The playback fails with the error: > > can't open libao driver with device hw:0,0 (is device in use?) > > as mentioned previously. If I run top, a Zombie mpg321 process shows > up. How are you identifying it as a zombie? What's the arguments for that process? `ps ww 42' where 42 is its process ID shows them `weally wide'. Does that tell you if it's the one that's also using hw:2,0? Could it be you've been running your Python program and that's an mpg321 from a leftover Subprocess.Popen? Cheers, Ralph. -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
On Saturday, 10 March 2018 13:55:04 GMT Ralph Corderoy wrote: > You *have* to use udev to map from USB port to an ID. > Assuming assignment to cards is random, but with a strong bias or > memory, i.e. can't be relied upon at all. This behaviour occurs even though I am using the instructions to set the port to an ID using udev! Things seem to have improved in this department since I moved my .asoundrc contents to /etc/asound.config, though I can't see why. (See my post at 11:41.) I've just spotted something trying to replicate the problem on this machine. I get the following error from syslog whn I plug an adaptor in: error opening ATTR{/sys/devices/pci:00/:00:1d.0/ usb2/2-1/2-1.7/2-1.7:1.0/sound/card1/pcmC1D0p/id} for writing: Permission denied So maybe udev has changed (again) and yet another technique is required. -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
Hi Terry, > Having worked consistently for many reboots, I just got a couple of > occasions when Card 0 came up as the bcm audio and the TOWER device > got moved to Card 2. You *have* to use udev to map from USB port to an ID. Assuming assignment to cards is random, but with a strong bias or memory, i.e. can't be relied upon at all. Cheers, Ralph. -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
Hi Terry, > I assume that this is because only one instance of the driver for the > USB Audio devices is loaded at boot-up and that is in use because it > is still playing the music. That sounds wrong. A driver is a piece of code that, given details about a device and somewhere to store its own state about that device, runs for multiple devices by being given a reference to the appropriate lump of data for the `current' device each time it's asked to do something. Cheers, Ralph. -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
On Saturday, 10 March 2018 13:47:25 GMT Ralph Corderoy wrote: > > subprocess.Popen(mpg321 -l -m -a hw:1,0 Playlist) > > Have you tried using the ID you've assigned with udev based on the USB > port as the card number; the `1' in `1,0' above? I've tried allsorts and whatever happens the hw: numbers never seem to bear any relation to the ID's that i created in the udev rules. See my other post. -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
Hi Terry, > https://github.com/dh1tw/remoteAudio/wiki/Persistent-USB-Mapping-of-Audio-devices-%28Linux%29 > > So I tried this, but hit another snag because although it worked, it > solved the wrong problem. I found that it works well to provide an > *identity* for the device, so I can tie a bus or Manufacturer's ID to > a label, but not to a channel ID (ie hw:x,y). ... > subprocess.Popen(mpg321 -l -m -a hw:1,0 Playlist) Have you tried using the ID you've assigned with udev based on the USB port as the card number; the `1' in `1,0' above? Cheers, Ralph. -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR
Re: [Dorset] Using Two USB Audio Adaptors and Selecting the Right One Programatically
On Friday, 9 March 2018 14:36:25 GMT Terry Coles wrote: > The light at the end of the tunnel is rapidly vanishing. Having worked > consistently for many reboots, I just got a couple of occasions when Card 0 > came up as the bcm audio and the TOWER device got moved to Card 2. I may have made some progress. I've moved the contents of my .asoundrc file to /etc/ asound.conf and I /think/ that I've now got the TOWER and CHANCEL USB devices coming up as hw:2,0 and hw:1,0 respectively. Time will tell if they stay there. I may have made a little progress on the driver thing too, but I don't know what it all means. What I am now seeing is somewhat weird. Outside of my Python program I can cd to a Playlist directory and issue: mpg321 -m -a hw:1,0 and it works, playing from the USB device designated CHANCEL. Staying in the same directory I kill playback of the above file and issue: mpg321 -m -a hw:2,0 and it now plays from the USB device designated TOWER. If I then kill that playback and move to the directory which contains the bells and issue: mpg321 -m -a hw:2,0 The playback fails with the error: can't open libao driver with device hw:0,0 (is device in use?) as mentioned previously. If I run top, a Zombie mpg321 process shows up. Any ideas as to what is going on? -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2018-04-03 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR