def note_playing_before_end_of_duration_play(): s = Note('A') s.play(duration=1.0) time.sleep(0.5) playing = s.is_playing() s.stop() return playing
def sound_flushing_sound_wont_stop_bugfix(): note = Note('A') start = time.time() note.play(2) time.sleep(1) note.stop() return verify_duration(start, 1)
def sound_play_test_sound_and_note_mixed(): n = Note('A') s = Sound(TEST_SOUND) n.play(duration=None) s.play() s.wait() n.stop() return True
def sound_manual_play_test_sound_and_note_mixed(): '''The sound match1.wav will play TWO TIMES on the speaker, mixed with an 'A' note. ''' n = Note('A') s = Sound(TEST_SOUND) n.play(duration=None) s.play() s.wait() s.play() s.wait() n.stop()
BEEP_DURATION = 0.05 ARENA_WIDTH = 10 GOLD_DEPTH = 2 gold_pos = mc.player.getTilePos() gold_pos.x += randint(-ARENA_WIDTH, ARENA_WIDTH) gold_pos.z += randint(-ARENA_WIDTH, ARENA_WIDTH) gold_pos.y = mc.getHeight(gold_pos.x, gold_pos.z) - GOLD_DEPTH mc.setBlock(gold_pos, block.GOLD_BLOCK) next_beep_time = time.time() while block.Block(mc.getBlock(gold_pos)) == block.GOLD_BLOCK: player_pos = mc.player.getTilePos() vector_to_gold = gold_pos - player_pos vector_to_gold.y = 0 distance_to_gold = vector_to_gold.length() if time.time() > next_beep_time: if distance_to_gold <= 1: if not beep.is_playing(): beep.play(duration=None) else: beep.play(duration=BEEP_DURATION).wait() next_beep_time = time.time() + log(distance_to_gold / 100 + 1) time.sleep(0.01) beep.stop() mc.postToChat("You found the gold!") time.sleep(3)
# Wait for user to repeat for i in play_order: button_pressed = Button.wait_many(buttons, timeout=3) if button_pressed != i: failed = True break # Light and play while button is pressed. lights[button_pressed].on() notes[button_pressed].play(duration=None) buttons[button_pressed].wait(press=False) time.sleep(0.2) lights[button_pressed].off() notes[button_pressed].stop() if not failed: time.sleep(1.0) # Play error tone with pressed light (or all lights) on. if button_pressed == None: for light in lights: light.on() else: lights[button_pressed].on() you_failed_note.play(1.5).wait() for light in lights: light.off() time.sleep(0.5)
ARENA_WIDTH = 10 GOLD_DEPTH = 2 gold_pos = mc.player.getTilePos() gold_pos.x += randint(-ARENA_WIDTH, ARENA_WIDTH) gold_pos.z += randint(-ARENA_WIDTH, ARENA_WIDTH) gold_pos.y = mc.getHeight(gold_pos.x, gold_pos.z) - GOLD_DEPTH mc.setBlock(gold_pos, block.GOLD_BLOCK) next_beep_time = time.time() while block.Block(mc.getBlock(gold_pos)) == block.GOLD_BLOCK: player_pos = mc.player.getTilePos() vector_to_gold = gold_pos - player_pos vector_to_gold.y = 0 distance_to_gold = vector_to_gold.length() if time.time() > next_beep_time: if distance_to_gold <= 1: if not beep.is_playing(): beep.play(duration=None) else: beep.play(duration=BEEP_DURATION).wait() next_beep_time = time.time() + log(distance_to_gold/100 + 1) time.sleep(0.01) beep.stop() mc.postToChat("You found the gold!") time.sleep(3)
def note_not_playing_after_end_of_duration_play(): s = Note('A') s.play(duration=1.0) time.sleep(1.5) return not s.is_playing()
def note_play(): n = Note('A') n.play() n.wait() return True
import time accel = Accel() # Calibrate z_rest = 0 SAMPLES = 100 for i in range(SAMPLES): x, y, z = accel.forces() z_rest += z time.sleep(0.01) z_rest /= SAMPLES # Beep to tell user we're starting recording beep = Note('A6') beep.play(0.2).wait() # Record taps TOTAL_TICKS = 2000 raw_tap_ticks = [] for i in range(TOTAL_TICKS): x, y, z = accel.forces() if abs(z_rest - z) > 0.1: raw_tap_ticks.append(i) time.sleep(0.001) # Beep to tell user we've stopped recording beep.play(0.2).wait() # Convert raw ticks to absolute ticks absolute_tap_ticks = []
import time accel = Accel() # Calibrate z_rest = 0 SAMPLES = 100 for i in range(SAMPLES): x, y, z = accel.forces() z_rest += z time.sleep(0.01) z_rest /= SAMPLES # Beep to tell user we're starting recording beep = Note('A6') beep.play(0.2).wait() # Record taps TOTAL_TICKS = 2000 raw_tap_ticks = [] for i in range(TOTAL_TICKS): x, y, z = accel.forces() if abs(z_rest-z) > 0.1: raw_tap_ticks.append(i) time.sleep(0.001) # Beep to tell user we've stopped recording beep.play(0.2).wait() # Convert raw ticks to absolute ticks absolute_tap_ticks = []