1

Here is the code:

wave_obj = sa.WaveObject.from_wave_file("sounds/2c.wav")
wave_obj.play()

And this is the error I get:

ALSA lib pcm.c:7924:(snd_pcm_set_params) Channels count (1) not available for PLAYBACK: Invalid argument
Traceback (most recent call last):
  File "gpio.py", line 11, in <module>
wave_obj.play()
  File "/usr/local/lib/python3.4/dist-packages/simpleaudio/shiny.py", line 20, in play
self.bytes_per_sample, self.sample_rate)
  File "/usr/local/lib/python3.4/dist-packages/simpleaudio/shiny.py", line 61, in play_buffer
sample_rate)
_simpleaudio.SimpleaudioError: Error setting parameters. -- CODE: -22 -- MSG: Invalid argument

I'm trying to use a USB audio connector for audio out because I've heard it improves crackling. The library for sound playing I'm using is simpleaudio. Is this an issue with ALSA or simpleaudio, and how can I fix it?

Asked for in comments:

pi@raspberrypi:/etc $  ~/.asoundrc
-bash: /home/pi/.asoundrc: Permission denied
pi@raspberrypi:/etc $ sudo  ~/.asoundrc
sudo: /home/pi/.asoundrc: command not found


pi@raspberrypi:/etc $ ls
adduser.conf            environment        ldap            opt              security
alternatives            esound             ld.so.cache     os-release       selinux
apache2                 fake-hwclock.data  ld.so.conf      PackageKit       services
apm                     fb.modes           ld.so.conf.d    pam.conf         sgml
apparmor.d              fonts              ld.so.preload   pam.d            shadow
apt                     fstab              libaudit.conf   passwd           shadow-
avahi                   fuse.conf          libnl-3         passwd-          shells
bash.bashrc             gai.conf           libreoffice     perl             skel
bash_completion         gconf         


pi@raspberrypi:/ $ ls
bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
pi@raspberrypi:/ $ cat /etc/asound.conf
cat: /etc/asound.conf: No such file or directory

aplay

pi@raspberrypi:~/gpio $ aplay -v sounds/2c.wav
Playing WAVE 'sounds/2c.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
aplay: set_params:1239: Channels count non available
pi@raspberrypi:~/gpio $ aplay -v -D plughw sounds/2c.wav
Playing WAVE 'sounds/2c.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
Plug PCM: Hardware PCM card 0 'bcm2835 ALSA' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 1
  rate         : 44100
  exact rate   : 44100 (44100/1)
  msbits       : 16
  buffer_size  : 22050
  period_size  : 5512
  period_time  : 124988
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 5512
  period_event : 0
  start_threshold  : 22050
  stop_threshold   : 22050
  silence_threshold: 0
  silence_size : 0
  boundary     : 1445068800
  appl_ptr     : 0
  hw_ptr       : 0
  • Show the /etc/asound.conf and ~/.asoundrc files. – CL. May 16 '16 at 7:40
  • I couldn't find either of those, see edit to post – Seph Reed May 16 '16 at 7:46
  • Just show the contents: cat /etc/asound.conf. – CL. May 16 '16 at 7:48
  • I'm not finding anything. No file or directory, added an edit to post. – Seph Reed May 16 '16 at 7:51
  • What is the output of aplay -v sounds/2c.wav and aplay -v -D plughw sounds/2c.wav? – CL. May 16 '16 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.