from unit_timeside import unittest, TestRunner
import timeside
-from scipy.signal import chirp
-import numpy as np
+from timeside.tools.test_samples import samples
from tempfile import NamedTemporaryFile
import os
""" test Graphers from analyzers"""
def setUp(self):
- samplerate = 16000 # LimsiSad require Fs = 16000 Hz
- duration = 10
- t = np.arange(0, duration, 1/samplerate)
- samples = chirp(t=t, f0=20, t1=t[-1], f1=samplerate/2,
- method='logarithmic')
- decoder_cls = timeside.core.get_processor('array_decoder')
- self.decoder = decoder_cls(samples, samplerate=samplerate)
+ source = samples["C4_scale.wav"]
+ decoder_cls = timeside.core.get_processor('file_decoder')
+ self.decoder = decoder_cls(uri=source)
def _perform_test(self, grapher_cls):
"""Internal function that test grapher for a given analyzer"""
# see http://stackoverflow.com/a/8881973
# TODO: mean may not be appropriate for waveform ... (mean~=0)
nb_frames = self.data.shape[0]
- chunksize = size[0]
- numchunks = nb_frames // chunksize
+ numchunks = size[0]
+
+ if nb_frames > 10*numchunks:
+ ax.plot(self.time, self.data)
+ return
+ else:
+ chunksize = 1
+ numchunks = nb_frames
+
+ print "nb_frames %d" % nb_frames
+ print "chunksize %d" % chunksize
+ print "numchunks %d" % numchunks
if self.data.ndim <= 1:
ychunks = self.data[:chunksize*numchunks].reshape((-1,
xcenters = xchunks.mean(axis=1)
# Now plot the bounds and the mean...
- ax.fill_between(xcenters, min_env, max_env, color='gray',
- edgecolor='none', alpha=0.5)
- ax.plot(xcenters, ycenters)
+ ax.fill_between(xcenters, min_env, max_env, color='blue',
+ edgecolor='black', alpha=1)
+ #ax.plot(xcenters, ycenters, color='gray', alpha=0.5)
#ax.plot(self.time, self.data)
else:
@interfacedoc
def post_process(self):
pipe_result = self.process_pipe.results
- parent_uuid = self.parents['analyzer'].uuid()
- parent_result = pipe_result[parent_uuid][self._result_id]
+ analyzer_uuid = self.parents['analyzer'].uuid()
+ analyzer_result = pipe_result[analyzer_uuid][self._result_id]
- fg_image = parent_result._render_PIL((self.image_width,
+ fg_image = analyzer_result._render_PIL((self.image_width,
self.image_height), self.dpi)
if self._background:
bg_uuid = self.parents['bg_analyzer'].uuid()
# Merge background and foreground images
from PIL.Image import blend
- fg_image = blend(fg_image, bg_image, 0.25)
+ fg_image = blend(fg_image, bg_image, 0.15)
self.image = fg_image
parent_analyzer = analyzer(**analyzer_parameters)
self.parents['analyzer'] = parent_analyzer
- # TODO : make it generic when analyzer will be "atomize"
- self._parent_uuid = parent_analyzer.uuid()
self._result_id = result_id
@staticmethod