Here is the code:

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

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>
  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
_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


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.
    Commented May 16, 2016 at 7:40
  • I couldn't find either of those, see edit to post
    – Seph Reed
    Commented May 16, 2016 at 7:46
  • Just show the contents: cat /etc/asound.conf.
    – CL.
    Commented May 16, 2016 at 7:48
  • I'm not finding anything. No file or directory, added an edit to post.
    – Seph Reed
    Commented May 16, 2016 at 7:51
  • 1
    so, I found a "fix." apparently mono .wav files don't play nice, so I got some stereo ones instead. I hate python.
    – Seph Reed
    Commented May 16, 2016 at 8:31


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.