pygame

pygame

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)
pygame.init()

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

# Use GPIO Interrupt Pin

clap.play()

GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.IN)

# Use mpr121 class for everything else

mpr121.TOU_THRESH = 0x30
mpr121.REL_THRESH = 0x33
mpr121.setup(0x5a)


# Track touches

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

while True:

        if (GPIO.input(7)): # Interupt pin is high
                pass
        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):
                                                kick.play()
                                        elif (i == 1):
                                                snare.play()
                                        elif (i == 2):
                                                openhh.play()
                                        elif (i == 3):
                                                closedhh.play()
                                        elif (i == 4):
                                                clap.play()
                                        elif (i == 5):
                                                cymbal.play()

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




root@raspberrypi:/home/pi# python /home/pi/Desktop/mpr121/beetbox.py
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/beetbox.py", 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
Cal
 
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 2 guests