class Waveform(Processor):
implements(IGrapher)
- BUFFER_SIZE = 1024
+ FFT_SIZE = 0x400
@interfacedoc
def __init__(self, width=None, height=None, output=None, bg_color=None, color_scheme=None):
super(Waveform, self).setup(channels, samplerate, nframes)
if self.graph:
self.graph = None
- self.adapter = FixedSizeInputAdapter(self.BUFFER_SIZE, channels, pad=True)
- self.graph = WaveformImage(self.width, self.height, self.nframes(), self.samplerate(), self.BUFFER_SIZE,
+ self.graph = WaveformImage(self.width, self.height, self.nframes(), self.samplerate(), self.FFT_SIZE,
bg_color=self.bg_color, color_scheme=self.color_scheme, filename=self.filename)
@interfacedoc
def process(self, frames, eod=False):
- for buffer, end in self.adapter.process(frames, eod):
- self.graph.process(buffer, end)
+ self.graph.process(frames, eod)
return frames, eod
@interfacedoc
class Spectrogram(Processor):
implements(IGrapher)
- BUFFER_SIZE = 512
+ FFT_SIZE = 0x1000
@interfacedoc
def __init__(self, width=None, height=None, output=None, bg_color=None, color_scheme=None):
super(Spectrogram, self).setup(channels, samplerate, nframes)
if self.graph:
self.graph = None
- self.adapter = FixedSizeInputAdapter(self.BUFFER_SIZE, channels, pad=True)
- self.graph = SpectrogramImage(self.width, self.height, self.nframes(), self.samplerate(), self.BUFFER_SIZE,
+ self.graph = SpectrogramImage(self.width, self.height, self.nframes(), self.samplerate(), self.FFT_SIZE,
bg_color=self.bg_color, color_scheme=self.color_scheme, filename=self.filename)
@interfacedoc
def process(self, frames, eod=False):
- for buffer, end in self.adapter.process(frames, eod):
- self.graph.process(buffer, end)
+ self.graph.process(frames, eod)
return frames, eod
@interfacedoc
from timeside.tests.api.examples import FileDecoder, WavEncoder
image_file = './spectrogram.png'
-source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.mp3")
+
+# mono
+#source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/guitar.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.mp3")
+
+# stereo
+source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/guitar_stereo.wav")
+#source = os.path.join(os.path.dirname(__file__), "/home/momo/music/flac/Isabelle Aboulker/Mon imagier des instruments/16 - Isabelle Aboulker - 16 instru.flac")
+#source = os.path.join(os.path.dirname(__file__), "/home/momo/music/ogg/Emilie_Jolie/01 - Henri Salvador - Prologue.ogg")
decoder = FileDecoder(source)
spectrogram = examples.Spectrogram(width=1024, height=256, output=image_file, bg_color=(0,0,0), color_scheme='default')
from timeside.tests.api.examples import FileDecoder, WavEncoder
image_file = './waveform.png'
-source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.mp3")
+
+# mono
+#source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/guitar.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/sweep_source.mp3")
+
+# stereo
+source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav")
+#source = os.path.join(os.path.dirname(__file__), "../samples/guitar_stereo.wav")
+#source = os.path.join(os.path.dirname(__file__), "/home/momo/music/flac/Isabelle Aboulker/Mon imagier des instruments/16 - Isabelle Aboulker - 16 instru.flac")
+#source = os.path.join(os.path.dirname(__file__), "/home/momo/music/ogg/Emilie_Jolie/01 - Henri Salvador - Prologue.ogg")
decoder = FileDecoder(source)
waveform = examples.Waveform(width=1024, height=256, output=image_file, bg_color=(0,0,0), color_scheme='default')