Drum Hat Software Problem

/home/nick/Python/drums.py
pygame 2.0.1 (SDL 2.0.9, Python 3.7.3)
Hello from the pygame community. Contribute - pygame wiki
This example lets you play the drums with Drum HAT!
Pads are mapped like so:
7 = Rim hit, 1 = Whistle, 2 = Clash
6 = Hat, 8 = Clap, 3 = Cowbell
5 = Snare, 4 = Base
Press CTRL+C to exit!

XXX When I press any of the pads I get: XXX

Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 450, in _handle_alert
self._trigger_handler(x, inputs)
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 464, in _trigger_handler
self.handlers[event][channel](CapTouchEvent(channel, event, self.input_delta[channel]))
File “/usr/lib/python3/dist-packages/drumhat.py”, line 101, in _handle_press
_on_presschannel
File “/home/nick/Python/drums.py”, line 39, in handle_hit
samples[event.channel].play(loops=0)
IndexError: list index out of range

Did you run
curl https://get.pimoroni.com/drumhat | bash

What happens if you run the test.py file?

I don’t have a test.py to try.

Where should it be?

It is normally in the examples folder.
drum-hat/test.py at master · pimoroni/drum-hat (github.com)

https://learn.pimoroni.com/drum-hat 404 Not Found

OK, I re-installed it and now I get:

pygame 2.0.1 (SDL 2.0.9, Python 3.7.3)
Hello from the pygame community. https://www.pygame.org/contribute.html
This example lets you play the drums with Drum HAT!
Pads are mapped like so:
7 = Rim hit, 1 = Whistle, 2 = Clash
6 = Hat, 8 = Clap, 3 = Cowbell
5 = Snare, 4 = Base
Press CTRL+C to exit!

Traceback (most recent call last):
File “/home/nick/Python/drums.py”, line 28, in
pygame.mixer.init(44100, -16, 1, 512)
pygame.error: ALSA: Couldn’t open audio device: No such file or directory

nick@drum:~ $ find /home -name test.py

nick@drum:~ $

My link above will take to to that file on github, all the examples are here.
drum-hat/examples at master · pimoroni/drum-hat (github.com)

The learn section is down at the moment, its been unaccusable all day.

What are you using for sound?

OK, I downloaded and ran test.py and that works fine but there is no sound (RPi Zero W).

Ok, you must be using HDMI for sound?
Can you get sound on that Pi from another source like say a youtube video, or music?
Do you have the two drum folders, that’s where the sound file are?

@Caperjack1953 Hey Jack, I do believe you just recently setup a drum hat.
Was it Buster, and what sound device did you use? DAC, Analog, or HDMI?

I’m using USB sound:

4.048182] usb 1-1: Product: iMic USB audio system

Does it it actually produce sound?

This produces a loud tone!

speaker-test -c 1 -t sine -f 500

When I run drums.py it fails again with:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cap1xxx.py", line 450, in _handle_alert
    self._trigger_handler(x, inputs[x])
  File "/usr/lib/python3/dist-packages/cap1xxx.py", line 464, in _trigger_handler
    self.handlers[event][channel](CapTouchEvent(channel, event, self.input_delta[channel]))
  File "/usr/lib/python3/dist-packages/drumhat.py", line 101, in _handle_press
    _on_press[channel](event)
  File "./drums.py", line 39, in handle_hit
    samples[event.channel].play(loops=0)
IndexError: list index out of range
^CTraceback (most recent call last):
  File "./drums.py", line 49, in <module>
    time.sleep(1)

not sure ,haveing a really bad memory/confusion day today ,Ok checked it a bit ,I’m still using the orignal setup of PiZero ,The Speaker Phat and Piano and Drum Hat , I just copied /pasted that new bit of code you gave me when I got the other DrumHat from you and tested your hat …if that any makes sense

Ok, I have have almost the same setup, Pi Zero, Pirate Speaker, drum hat, piano hat. Pretty sure its Buster, just can’t remember if I set it up before or after the switch to Pulse Audio in Pi OS. I followed the itty bitty beat box tutorial. Learn section is down and out at the moment now though so i can’t link to it?

I thought you might have been tinkering with the other Drum Hat you have, the one you got in the trade of stuff with me.