Initial commit
authorPi user <pi@njae.me.uk>
Sun, 20 Oct 2013 15:33:07 +0000 (16:33 +0100)
committerPi user <pi@njae.me.uk>
Sun, 20 Oct 2013 15:33:07 +0000 (16:33 +0100)
12 files changed:
.gitignore [new file with mode: 0644]
glove.py [new file with mode: 0644]
sounds/cymbal.wav [new file with mode: 0644]
sounds/guitar1.wav [new file with mode: 0644]
sounds/guitar2.wav [new file with mode: 0644]
sounds/guitar3.wav [new file with mode: 0644]
sounds/guitar4.wav [new file with mode: 0644]
sounds/guitar5.wav [new file with mode: 0644]
sounds/hihat.wav [new file with mode: 0644]
sounds/maracas.wav [new file with mode: 0644]
sounds/slowdrum.wav [new file with mode: 0644]
sounds/snare.wav [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..9039ffc
--- /dev/null
@@ -0,0 +1,6 @@
+*~
+*doc
+*log
+/tmp
+/__pycache__/*
+*pyc
diff --git a/glove.py b/glove.py
new file mode 100644 (file)
index 0000000..b63f648
--- /dev/null
+++ b/glove.py
@@ -0,0 +1,44 @@
+import pygame
+import RPi.GPIO as gpio
+import time
+import logging
+
+logger = logging.getLogger(__name__)
+loggerFileHandler = logging.FileHandler('glove.log')
+loggerFileHandlerFormatter = logging.Formatter('%(asctime)s %(levelname)-8s  %(message)s')
+loggerFileHandler.setFormatter(loggerFileHandlerFormatter)
+logger.addHandler(loggerFileHandler)
+logger.setLevel(logging.WARNING)
+logger.setLevel(logging.INFO)
+
+
+guitars = ['sounds/guitar1.wav',
+           'sounds/guitar2.wav',
+           'sounds/guitar3.wav',
+           'sounds/guitar4.wav',
+           'sounds/guitar5.wav']
+
+pygame.mixer.init()
+sounds = [pygame.mixer.Sound(g) for g in guitars]
+#for s in sounds:
+#    s.play()
+#    time.sleep(0.5)
+
+#time.sleep(2)
+
+gpio.setmode(gpio.BCM)
+gpio.setup(25, gpio.IN)
+
+last_switch = gpio.LOW
+
+while True:
+    this_switch = gpio.input(25)
+    logger.debug("This: {0}, Last: {1}".format(this_switch, last_switch))
+    if this_switch and not last_switch:
+        sounds[0].play()
+        last_switch = this_switch
+        logger.info("Started playing")
+    if not this_switch and last_switch:
+        sounds[0].stop()
+        last_switch = this_switch
+        logger.info("Stopped playing")
diff --git a/sounds/cymbal.wav b/sounds/cymbal.wav
new file mode 100644 (file)
index 0000000..7c2e528
Binary files /dev/null and b/sounds/cymbal.wav differ
diff --git a/sounds/guitar1.wav b/sounds/guitar1.wav
new file mode 100644 (file)
index 0000000..e396785
Binary files /dev/null and b/sounds/guitar1.wav differ
diff --git a/sounds/guitar2.wav b/sounds/guitar2.wav
new file mode 100644 (file)
index 0000000..8bfd1bc
Binary files /dev/null and b/sounds/guitar2.wav differ
diff --git a/sounds/guitar3.wav b/sounds/guitar3.wav
new file mode 100644 (file)
index 0000000..7e0e35c
Binary files /dev/null and b/sounds/guitar3.wav differ
diff --git a/sounds/guitar4.wav b/sounds/guitar4.wav
new file mode 100644 (file)
index 0000000..e53510b
Binary files /dev/null and b/sounds/guitar4.wav differ
diff --git a/sounds/guitar5.wav b/sounds/guitar5.wav
new file mode 100644 (file)
index 0000000..ad0ffc9
Binary files /dev/null and b/sounds/guitar5.wav differ
diff --git a/sounds/hihat.wav b/sounds/hihat.wav
new file mode 100644 (file)
index 0000000..e591363
Binary files /dev/null and b/sounds/hihat.wav differ
diff --git a/sounds/maracas.wav b/sounds/maracas.wav
new file mode 100644 (file)
index 0000000..a039e3a
Binary files /dev/null and b/sounds/maracas.wav differ
diff --git a/sounds/slowdrum.wav b/sounds/slowdrum.wav
new file mode 100644 (file)
index 0000000..c55965a
Binary files /dev/null and b/sounds/slowdrum.wav differ
diff --git a/sounds/snare.wav b/sounds/snare.wav
new file mode 100644 (file)
index 0000000..92d24c4
Binary files /dev/null and b/sounds/snare.wav differ