Exemplo n.º 1
0
def main():
    drumhat.all_off()

    for sample in samples:
        sample.start()

    drumhat.on_hit(drumhat.PADS, handle_hit)

    while True:
        for channel, sample in enumerate(samples):
            if not sample.sync and not sample.busy():
                drumhat.led_off(drumhat.NUMMAP[channel])

        time.sleep(1.0 / 30)
Exemplo n.º 2
0
def handle_hit(event):
    # event.channel is a zero based channel index for each pad
    # event.pad is the pad number from 1 to 8
    try:
        sample = samples[event.channel]
        if sample.toggle():
            drumhat.led_on(event.pad)
            print("Playing: {}".format(sample.filename))
        else:
            drumhat.led_off(event.pad)
            if sample.sync:
                print("Stopping: {}".format(sample.filename))

    except IndexError:
        print("Error: No sound mapped for {}".format(event.channel))
        pass
Exemplo n.º 3
0
def update_led(pad, status):
    print("Turn LED on Pad %d to %r") %(pad, status)
    if status == True:
        drumhat.led_on(pad)
    else:
        drumhat.led_off(pad)
Exemplo n.º 4
0
#!/usr/bin/env python

import time
from sys import exit

import drumhat


def hit_handler(event):
    print("Hit on pad: {}".format(event.pad))


def rel_handler(event):
    print("Release on pad: {}".format(event.pad))


drumhat.on_hit(drumhat.PADS, hit_handler)
drumhat.on_release(drumhat.PADS, rel_handler)

try:
    drumhat.auto_leds = False
    pads = drumhat.PADS
    while True:
        drumhat.led_on(pads[-1])
        drumhat.led_off(pads[0])
        pads.insert(0, pads.pop())
        time.sleep(0.1)

except KeyboardInterrupt:
    exit()
Exemplo n.º 5
0
import drumhat
import time

def hit_handler(event):
    print("Hit on pad: {}".format(event.pad))

def rel_handler(event):
    print("Release on pad: {}".format(event.pad))

drumhat.on_hit(drumhat.PADS, hit_handler)
drumhat.on_release(drumhat.PADS, rel_handler)

try:
    drumhat.auto_leds = False
    pads = drumhat.PADS
    while True:
        drumhat.led_on(pads[-1])
        drumhat.led_off(pads[0])
        pads.insert(0,pads.pop())
        time.sleep(0.1)

except KeyboardInterrupt:
    exit()
Exemplo n.º 6
0
 def start_record(self):
     for i in [0, 1, 2, 3, 4, 5, 6, 7]:
         drumhat.led_on(i + 1)
         pygame.time.wait(100)
         drumhat.led_off(i + 1)