Exemplo n.º 1
0
 def __init__(self, seconds: float, freq: float, points: List[List[float]],
              **kwargs):
     Source.__init__(self)
     self.seconds = seconds
     self.freq = float(freq)
     self.points = np.array(points)
     self.curve = Curve.from_nodes(points)
Exemplo n.º 2
0
 def __init__(self,
              name: str,
              output: str,
              seconds: float,
              octave: int = 0,
              **kwargs):
     Source.__init__(self)
     freq = notes[name] * (2**octave)
     clazz = NoteSource.sources[output]
     self.source = clazz(freq=freq, seconds=seconds)
Exemplo n.º 3
0
def play_from_source(root: Source,
                     fs: int,
                     start: Optional[Frames] = None,
                     end: Optional[Frames] = None):
    start = start if start is not None else 0
    end = end if end is not None else root.get_duration(fs)
    buffer = root.get_buffer(fs, start, end)

    # Ensure that highest value is in 16-bit range
    audio = buffer / np.max(np.abs(buffer)) * (2**15 - 1)

    # Convert to 16-bit data
    audio = audio.astype(np.int16)

    # Start playback
    play_obj = sa.play_buffer(audio, 1, 2, fs)

    # Wait for playback to finish before exiting
    play_obj.wait_done()
Exemplo n.º 4
0
 def __init__(self, file, **kwargs):
     Source.__init__(self)
     self.file = file
     self.buffer = None
     self.source_fs = None
Exemplo n.º 5
0
 def __init__(self, scale: Parametrizable, child: Source):
     Source.__init__(self)
     self.child = child
     self.scale = parametrize(scale)
Exemplo n.º 6
0
 def __init__(self, factor: float, child: Source):
     Source.__init__(self)
     self.factor = float(factor)
     self.child = child
Exemplo n.º 7
0
 def __init__(self, source: Source):
     Source.__init__(self)
     self.source = source
Exemplo n.º 8
0
 def __init__(self, child: Source, transforms: List[Transform], **kwargs):
     Source.__init__(self)
     self.child = child
     self.transforms = transforms
Exemplo n.º 9
0
 def __init__(self, buf, source_fs: Frames, **kwargs):
     Source.__init__(self)
     self.buf = buf
     self.source_fs = source_fs
Exemplo n.º 10
0
 def __init__(self, freq, seconds, **kwargs):
     Source.__init__(self)
     self.freq = freq
     self.seconds = seconds
Exemplo n.º 11
0
 def __init__(self, children: List[Source] = None):
     Source.__init__(self)
     self.children = children if children is not None else []
Exemplo n.º 12
0
 def __init__(self, children: List[Tuple[float, Source]] = None):
     Source.__init__(self)
     self.children = children if children is not None else []
Exemplo n.º 13
0
 def __init__(self, freq, seconds, **kwargs):
     Source.__init__(self)
     self.freq = freq
     self.per = 1.0 / float(self.freq)
     self.seconds = seconds