Demo of sound events in Codesters. This version can be used with the Makey Makey because it uses the arrow keys to play the drums.

def play_c3(): stage.play_sound('PianoC') def play_d(): stage.play_sound('PianoD') def play_eb(): stage.play_sound('PianoEb') def play_f(): stage.play_sound('PianoF') def play_g(): stage.play_sound('PianoG') def play_ab(): stage.play_sound('PianoAb') def play_bb(): stage.play_sound('PianoBb') def play_c4(): stage.play_sound('PianoC4') def play_kick(): stage.play_sound('LDKick') def play_snare(): stage.play_sound('LDSnare') def play_hat_close(): stage.play_sound('LDHatClose') def play_hat_open(): stage.play_sound('LDHatOpen') def play_mystery_sound(): stage.play_sound('PianoAb') key_events = { 'a': play_c3, 's': play_d, 'd': play_eb, 'f': play_f, 'g': play_g, 'h': play_ab, 'j': play_bb, 'k': play_c4, 'z': play_kick, 'x': play_snare, 'c': play_hat_close, 'v': play_hat_open, 'up': play_snare, 'down': play_kick, 'right': play_hat_open, 'left': play_hat_close, 'space': play_mystery_sound } for k in key_events: stage.event_key(k, key_events[k]) t = codesters.Text('push a, s, d, f, g, h, j, k for piano', 0, 50) t = codesters.Text('push z, x, c, v for drums', 0, -0) white_key_letters = ['a', 's', None, 'f', 'g', None, None, 'k'] white_key_events = [play_c3, play_d, None, play_f, play_g, None, None, play_c4] # Create the sprites for the white keys starting_x = -175 w = 50 h = 150 y = 150 for i in range(8): x = starting_x + i * w white_key = codesters.Rectangle(x, y, w, h, 'white', 'black') if white_key_letters[i]: label = codesters.Text(white_key_letters[i], x, y) if white_key_events[i]: white_key.event_click(white_key_events[i]) # Create the sprites for the black keys black_key_letters = [None, 'd', None, 'h', 'j'] black_key_events = [None, play_eb, None, play_ab, play_bb] w = 30 h = 80 y = y + 35 x_pos_list = [starting_x + 25, starting_x + 80, starting_x + 175, starting_x + 225, starting_x + 275] for i in range(5): x = x_pos_list[i] black_key = codesters.Rectangle(x, y, w, h, 'black') if black_key_letters[i]: label = codesters.Text(black_key_letters[i], x, y, 'white') if black_key_events[i]: black_key.event_click(black_key_events[i]) sprite = codesters.Sprite("drumset_4af", 0, -150) sprite.set_size(0.25) mic = codesters.Sprite("microphone") mic.say("Use arrow keys for drums!") mic.set_size(0.5) mic.go_to(-140,-100)
Support