Advertisement
Guest User

Untitled

a guest
Aug 25th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. import pygame.mixer
  2. import RPi.GPIO as GPIO
  3. from sys import exit
  4. import random
  5. import time
  6. import glob
  7. import pygame.event
  8.  
  9. attack = glob.glob("attack/*.wav") #folder with attack quotes
  10. move = glob.glob("movement/*.wav") #folder with move/idle quotes
  11. taunt = glob.glob("taunt/*.wav") #folder with taunt quotes
  12. joke = glob.glob("joke/*.wav") #folder with the jokes
  13. laugh = glob.glob("laugh/*.wav") #folder with the laughing tracks
  14. pick = glob.glob("pick/*.wav") #folder with pick/ban quotes
  15. misc = glob.glob("misc/*.wav")
  16.  
  17. GPIO.setmode(GPIO.BCM)
  18. GPIO.setup(4, GPIO.IN)
  19. GPIO.setup(17, GPIO.IN)
  20. GPIO.setup(18, GPIO.IN)
  21. GPIO.setup(21, GPIO.IN)
  22. GPIO.setup(23, GPIO.IN)
  23. GPIO.setup(24, GPIO.IN)
  24. GPIO.setup(25, GPIO.IN)
  25. pygame.mixer.init(48000, -16, 1, 1024)
  26. sndA = pygame.mixer.Sound(random.choice(attack))
  27. sndB = pygame.mixer.Sound(random.choice(move))
  28. sndC = pygame.mixer.Sound(random.choice(taunt))
  29. sndD = pygame.mixer.Sound(random.choice(joke))
  30. sndE = pygame.mixer.Sound(random.choice(laugh))
  31. sndF = pygame.mixer.Sound(random.choice(pick))
  32. sndG = pygame.mixer.Sound(random.choice(misc))
  33. SoundA = pygame.mixer.Channel(1)
  34. SoundB = pygame.mixer.Channel(2)
  35. SoundC = pygame.mixer.Channel(3)
  36. SoundD = pygame.mixer.Channel(4)
  37. SoundE = pygame.mixer.Channel(5)
  38. SoundF = pygame.mixer.Channel(6)
  39. SoundG = pygame.mixer.Channel(7)
  40.  
  41. print ("Soundboard aktiv.");
  42.  
  43. while True:
  44.  
  45. try:
  46. if (GPIO.input(4) == True):
  47. SoundA.play(sndA)
  48.  
  49. if (GPIO.input(17) == True):
  50. SoundB.play(sndB)
  51.  
  52. if (GPIO.input(18) == True):
  53. SoundC.play(sndC)
  54.  
  55. if (GPIO.input(21) == True):
  56. SoundD.play(sndD)
  57.  
  58. if (GPIO.input(23) == True):
  59. SoundE.play(sndE)
  60.  
  61. if (GPIO.input(24) == True):
  62. SoundF.play(sndF)
  63.  
  64. if (GPIO.input(25) == True):
  65. SoundG.play(sndG);
  66.  
  67.  
  68. except KeyboardInterrupt:
  69. exit()
  70. time.sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement