Postby Cal » Mon Dec 09, 2013 9:32 pm

upon running this file, i receive the following error

Code: Select all
import pygame

import RPi.GPIO as GPIO
import mpr121

# User pygame for sounds

pygame.mixer.pre_init(44100, -16, 12, 512)

kick = pygame.mixer.Sound('/kick.wav')
snare = pygame.mixer.Sound('/snare.wav')
openhh = pygame.mixer.Sound('/open.wav')
closedhh = pygame.mixer.Sound('/closed.wav')
clap = pygame.mixer.Sound('/clap.wav')
cymbal = pygame.mixer.Sound('/cymbal.wav')

# Use GPIO Interrupt Pin

GPIO.setup(7, GPIO.IN)

# Use mpr121 class for everything else

mpr121.TOU_THRESH = 0x30
mpr121.REL_THRESH = 0x33

# Track touches

touches = [0,0,0,0,0,0];

while True:

        if (GPIO.input(7)): # Interupt pin is high
        else: # Interupt pin is low

                touchData = mpr121.readData(0x5a)

                for i in range(6):
                        if (touchData & (1<<i)):

                                if (touches[i] == 0):

                                        print( 'Pin ' + str(i) + ' was just touched')

                                        if (i == 0):
                                        elif (i == 1):
                                        elif (i == 2):
                                        elif (i == 3):
                                        elif (i == 4):
                                        elif (i == 5):

                                touches[i] = 1;
                                if (touches[i] == 1):
                                        print( 'Pin ' + str(i) + ' was just released')
                                touches[i] = 0;

root@raspberrypi:/home/pi# python /home/pi/Desktop/mpr121/
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4720:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM default
Traceback (most recent call last):
File "/home/pi/Desktop/mpr121/", line 16, in <module>
kick = pygame.mixer.Sound('/kick.wav')
pygame.error: mixer system not initialized

i had this working earlier but with no sound coming out. i tried to fix the sound and seem to have made things worse. i dont know why im getting alsa errors when i just want to use pygame.

any ideas?
Last edited by metulburr on Mon Dec 09, 2013 9:49 pm, edited 3 times in total.
Reason: added codetags and moved to appropriate forums
Posts: 6
Joined: Mon Dec 02, 2013 8:35 pm

Return to Game Development

Who is online

Users browsing this forum: No registered users and 3 guests