def play_harley_sound(tempo=1): # play any wav file that you choose (just save it in the same directory) # you can download them from the internet (e.g. https://freewavesamples.com/) # or make your own: import sys import os dir_path = os.path.dirname(sys.argv[0]) sound_file = os.path.join(dir_path, 'sounds/harley_davidson.wav') file_path = os.path.abspath(sound_file) # start and finish anywhere between 0 and 1: command = 'sample "{0}", start: {1}, finish: {2}'.format( file_path, 0.4, 0.42) psonic.run(command)
def custom_sound(): # play any wav file that you choose (just save it in the same directory) # you can download them from the internet (e.g. https://freewavesamples.com/) # or make your own: import os dir_path = os.path.dirname(os.path.realpath(__file__)) sound_file = os.path.join(dir_path,'sounds/harley_davidson.wav') start = 0.2 # float between 0 and 1 finish = 0.3 # float between 0 and 1 file_path = os.path.abspath(sound_file) command = 'sample "{0}", start: {1}, finish: {2}'.format( file_path, start, finish) psonic.run(command)
def neverland_event(self, entity, action, entity_id): ''' entity_id ''' print(entity, action, entity_id) if entity == "cube": if action == "slide": run(cowbell) # run(test_run()) if action == "rotate_left": # play (60, attack=0.5, decay=1, sustain_level=0.4, sustain=2, release=0.5) # attack 淡入时间,中间持续时间,release淡出时间 # play是非阻塞的 play(70, sustain=0.25) # 响度 amp=2/0.5, 方向 pan=-1/1/0 sleep(self.beat) play(72, sustain=0.25)