def ev_func(fn, do_response=None, play_name=None): global chord, DURATION #todo not needed anymore, ev_func_init has it? if play_name is None: play_name = PLAY_NAME fname = get_fname(fn) if not is_lambda(fname): for e in ev_func_init(fn): yield e #{ #todo maybe find a simpler way for last_pitch - # maybe allow the ev_pitches to write into # some shared value, like a list or dict? # (maybe not tho, this seems maybe ok) last_pitch = None pause1 = pause_amt( ) #todo why use the same pause for 1st and 2nd part? if play_name: for e in ev_func_name(fname, pause1): last_pitch = midi.maybe_set_pitch(last_pitch, e) yield e #} # maybe run function and play response if do_response is None: do_response = True #coinflip() if do_response: #todo figure out last_pitch / prev_pitch stuff for e in ev_fn_response(fn, pause1=pause1, prev_pitch=last_pitch): yield e
def ev_func(fn, do_response=None, play_name=None): global chord, DURATION #todo not needed anymore, ev_func_init has it? if play_name is None: play_name = PLAY_NAME fname = get_fname(fn) if not is_lambda(fname): for e in ev_func_init(fn): yield e #{ #todo maybe find a simpler way for last_pitch - # maybe allow the ev_pitches to write into # some shared value, like a list or dict? # (maybe not tho, this seems maybe ok) last_pitch = None pause1 = pause_amt() #todo why use the same pause for 1st and 2nd part? if play_name: for e in ev_func_name(fname, pause1): last_pitch = midi.maybe_set_pitch(last_pitch, e) yield e #} # maybe run function and play response if do_response is None: do_response = True #coinflip() if do_response: #todo figure out last_pitch / prev_pitch stuff for e in ev_fn_response(fn, pause1=pause1, prev_pitch=last_pitch): yield e
def ev_fn_response(fn, pause1=None, prev_pitch=None): if is_function(fn): response = fn() if isinstance(response, types.GeneratorType): for section in response: #new_prev_pitch = ev_fn_response_1(section, pause1, prev_pitch) #prev_pitch = new_prev_pitch new_prev_pitch = None for e in ev_fn_response_1(section, pause1, prev_pitch=prev_pitch): new_prev_pitch = midi.maybe_set_pitch(new_prev_pitch, e) yield e prev_pitch = new_prev_pitch else: for e in ev_fn_response_1(response, pause1, prev_pitch=prev_pitch): yield e
def ev_fn_response(fn, pause1=None, prev_pitch=None): if is_function(fn): response = fn() if isinstance(response, types.GeneratorType): for section in response: #new_prev_pitch = ev_fn_response_1(section, pause1, prev_pitch) #prev_pitch = new_prev_pitch new_prev_pitch = None for e in ev_fn_response_1( section, pause1, prev_pitch=prev_pitch ): new_prev_pitch = midi.maybe_set_pitch(new_prev_pitch,e) yield e prev_pitch = new_prev_pitch else: for e in ev_fn_response_1( response, pause1, prev_pitch = prev_pitch ): yield e