Page 1 of 1

sox default device

Posted: Wed Aug 01, 2012 1:10 am
by justinwood
Anyone else having issues with "sox"?

I installed it and I get the following errors when running "play test.wav":

play WARN alsa: can't encode 0-bit Unknown or not applicable
play FAIL sox: Sorry, there is no default audio device configured

I did some reading and I should be able to pass sox a default device parameter, however I am not sure where to get that info. None of the options in alsa make sense, I did try passing --default alsa and didnt get anywhere.

Can someone point me at some documentation or give me a hand?

thanks!

Re: sox default device

Posted: Sun Aug 05, 2012 1:47 pm
by Rob Sykes
Try
AUDIODEV=hw:0 play test.wav

Re: sox default device

Posted: Tue Apr 16, 2013 2:04 pm
by ericvrp
Hi,

I've tried recording with rec/sox and can't find the correct AUDIODEV for my microphone. I think the one I am using now as actually my audio output device. Could anyone help me out finding the right setting for 'rec' on a Raspberry Pi?
rec samples/temp.flac
rec WARN alsa: can't encode 0-bit Unknown or not applicable
rec FAIL formats: can't open input `default': snd_pcm_open error: No such file or directory
AUDIODEV=hw:1 rec samples/temp.flac
rec FAIL sox: Sorry, there is no default audio device configured
AUDIODEV=hw:0 rec -r 16000 samples/temp.flac silence 1 0.2 2% 1 0:00:2 2%
rec WARN alsa: can't encode 0-bit Unknown or not applicable
rec FAIL formats: can't open input `hw:0': snd_pcm_open error: No such file or directory
The following command works however:
arecord -D "plughw:1,0" -q -f cd -t wav -d 5

Re: sox default device

Posted: Tue Apr 16, 2013 6:27 pm
by drgeoff
ericvrp wrote:I've tried recording with rec/sox and can't find the correct AUDIODEV for my microphone. I think the one I am using now as actually my audio output device. Could anyone help me out finding the right setting for 'rec' on a Raspberry Pi?
What USB microphone or USB interface are you using? What responses do you get to the 'lsusb' and 'lsmod' commands?

Re: sox default device

Posted: Fri May 03, 2013 4:33 pm
by kupad
I had the same problem, and solved it like so:

In addition to setting the audio device with the environment variable AUDIODEV with:
> export AUDIODEV=hw:1,0

(hw:1,0 being a typical value for a USB microphone on raspi)

I also had to set the AUDIODRIVER environment variable:
> export AUDIODRIVER=alsa

Then I was able to use rec. I wanted it, over arecord, since it can start recording when it detects sound, and can stop recording when it detects silence.

--kupad

Re: sox default device

Posted: Mon Jul 08, 2013 8:03 pm
by vonzepp
Hi

I have also this problem. I tried the listed solution however it doesn't solve my problem. Leaving an error of .

rec FAIL formats: can't open input `hw:1,0': snd_pcm_open error: No such file or directory
.

Those anyone have ideas about this?

Edit: I managed to fix this. First you need to to arecord -l

Then export AUDIODEV=hw:[insert card number],[insert device number]

Re: sox default device

Posted: Thu Apr 21, 2016 7:55 pm
by ThisNameNotUsed
I did all this and went through all the same errors and corrections but I am still left with this error:

Code: Select all

export AUDIODEV=hw:1,0
rec rectest.wav
rec FAIL formats: can't open output file `rectest.wav': Permission denied

sudo rec rectest.wav
rec FAIL formats: can't open input  `default': snd_pcm_open error: No such file or directory

I don't know because I am new to Linux but this might explain something: I had to follow these directions to install a hifi berry amp that I am using: https://www.hifiberry.com/guides/config ... ux-3-18-x/

Re: sox default device

Posted: Mon Jan 22, 2018 8:07 pm
by nixoid
Try create file .asoundrc in your home dir with content:

Code: Select all

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

Re: sox default device

Posted: Tue Jun 26, 2018 12:52 pm
by SyncMaster
possibly it is a authorisation problem. The user needs to be in group audio.
Check with
arecord -l
correct output is
# arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: r4 [UltraMic 200K 16 bit r4], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

Type: groups
to see if you belong to audio, otherwise add the user to the group audio:
sudo usermod -a -G audio myuser