82 lines
No EOL
1.9 KiB
Python
82 lines
No EOL
1.9 KiB
Python
from ..action import TimedAction
|
|
|
|
class PlayAction(TimedAction):
|
|
|
|
def __init__(self, start_t, duration_t, nodes, program):
|
|
|
|
super().__init__(start_t, duration_t, nodes, program)
|
|
|
|
def start(self, node):
|
|
|
|
node.active = True
|
|
|
|
def end(self, node):
|
|
|
|
node.active = False
|
|
|
|
|
|
class NoteAction(TimedAction):
|
|
|
|
def __init__(self, note, start_t, duration_t, nodes, program):
|
|
|
|
super().__init__(start_t, duration_t, nodes, program)
|
|
self.note = note
|
|
|
|
def start(self, node):
|
|
|
|
node.freq = self.program.note_to_freq(self.note)
|
|
node.active = True
|
|
|
|
def end(self, node):
|
|
|
|
node.active = False
|
|
|
|
class LinearPitchTransition(TimedAction):
|
|
|
|
def __init__(self, start_note, end_node, start_t, duration_t, nodes, program):
|
|
|
|
super().__init__(start_t, duration_t, nodes, program)
|
|
self.start_note = start_note
|
|
self.end_node = end_node
|
|
|
|
self.start_freq = self.program.note_to_freq(start_note)
|
|
self.end_freq = self.program.note_to_freq(end_node)
|
|
|
|
self.freq_range = self.end_freq - self.start_freq
|
|
|
|
def start(self, node):
|
|
|
|
node.freq = self.start_freq
|
|
node.active = True
|
|
|
|
def progress(self, prc, node):
|
|
|
|
node.freq = self.start_freq + (self.freq_range * prc)
|
|
|
|
def end(self, node):
|
|
|
|
node.active = False
|
|
|
|
|
|
class LinearSpatialTransition(TimedAction):
|
|
|
|
def __init__(self, start_coords, end_coords, start_t, duration_t, nodes, program):
|
|
|
|
super().__init__(start_t, duration_t, nodes, program)
|
|
self.start_coords = start_coords
|
|
self.end_coords = end_coords
|
|
|
|
self.delta_coords = [end_coords[0] - start_coords[0], end_coords[1] - start_coords[1], end_coords[2] - start_coords[2]]
|
|
|
|
def start(self, node):
|
|
|
|
node.start_location = self.start_coords
|
|
|
|
def progress(self, prc, node):
|
|
|
|
l = []
|
|
l.append(self.start_coords[0] + (self.delta_coords[0] * prc))
|
|
l.append(self.start_coords[1] + (self.delta_coords[1] * prc))
|
|
l.append(self.start_coords[2] + (self.delta_coords[2] * prc))
|
|
node.start_location = tuple(l)
|
|
|