def function_voices_create(context: Context, name: str, modifiers: Node = None, inherit: Voice = None): if inherit != None: pass voice = Voice(name, Instrument(name, 1)) forked = context.fork() forked.voice = voice if inherit != None: voice.instrument = inherit.instrument voice.time_signature = inherit.time_signature voice.velocity = inherit.velocity voice.octave = inherit.octave voice.value = inherit.value voice.tempo = inherit.tempo if modifiers != None: if isinstance(modifiers, MusicSequenceNode): for modifier in modifiers: if isinstance(modifier, ContextModifierNode): modifier.apply(voice) else: modifier.eval(forked) else: if isinstance(modifiers, ContextModifierNode): modifiers.apply(voice) else: modifiers.eval(forked) return voice
def apply(self, voice: Voice): voice.value = self.length