From 770add82a8492d585b979de576241159503c017b Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 31 Oct 2013 22:51:58 +0100 Subject: [PATCH] tests/api to test/sandbox, add various tests in sandbox --- tests/{api => sandbox}/__init__.py | 0 tests/{api => sandbox}/examples.py | 0 tests/{api => sandbox}/exempleCMMR_vamp.py | 0 tests/{api => sandbox}/exemplesCMMR.py | 0 tests/{api => sandbox}/test_all.py | 0 tests/{api => sandbox}/test_all_graphers.py | 0 tests/{api => sandbox}/test_analyzer.py | 0 tests/{api => sandbox}/test_analyzer3.py | 0 tests/sandbox/test_analyzer4.py | 31 +++++++++++++++++++ tests/sandbox/test_aubio_bpm.py | 13 ++++++++ tests/sandbox/test_aubio_onsetrate.py | 10 ++++++ tests/{api => sandbox}/test_enc_flac.py | 0 tests/{api => sandbox}/test_enc_mp3.py | 0 .../{api => sandbox}/test_enc_mp3_by_block.py | 0 tests/{api => sandbox}/test_enc_ogg.py | 0 tests/{api => sandbox}/test_enc_webm.py | 0 tests/{api => sandbox}/test_flac.py | 0 tests/{api => sandbox}/test_lolevel.py | 0 .../test_lolevel_streaming.py | 0 .../test_lolevel_streaming_bad.py | 0 .../test_lolevel_streaming_vorbis.py | 0 tests/{api => sandbox}/test_mp3.py | 0 tests/sandbox/test_mp3_2.py | 27 ++++++++++++++++ tests/sandbox/test_mp3_3.py | 22 +++++++++++++ tests/sandbox/test_parent.py | 13 ++++++++ tests/{api => sandbox}/test_pipe.py | 0 tests/sandbox/test_results.py | 16 ++++++++++ tests/{api => sandbox}/test_spectrogram.py | 0 tests/sandbox/test_spectrogram2.py | 26 ++++++++++++++++ tests/sandbox/test_spectrogram3.py | 31 +++++++++++++++++++ tests/{api => sandbox}/test_vorbis.py | 0 tests/{api => sandbox}/test_wav.py | 0 tests/{api => sandbox}/test_waveform.py | 0 tests/sandbox/test_waveform3.py | 26 ++++++++++++++++ tests/sandbox/test_waveform4.py | 24 ++++++++++++++ tests/sandbox/test_waveform_centroid.py | 29 +++++++++++++++++ tests/sandbox/test_waveform_contour.py | 29 +++++++++++++++++ tests/sandbox/test_waveform_simple.py | 29 +++++++++++++++++ 38 files changed, 326 insertions(+) rename tests/{api => sandbox}/__init__.py (100%) rename tests/{api => sandbox}/examples.py (100%) rename tests/{api => sandbox}/exempleCMMR_vamp.py (100%) rename tests/{api => sandbox}/exemplesCMMR.py (100%) rename tests/{api => sandbox}/test_all.py (100%) rename tests/{api => sandbox}/test_all_graphers.py (100%) rename tests/{api => sandbox}/test_analyzer.py (100%) rename tests/{api => sandbox}/test_analyzer3.py (100%) create mode 100644 tests/sandbox/test_analyzer4.py create mode 100644 tests/sandbox/test_aubio_bpm.py create mode 100644 tests/sandbox/test_aubio_onsetrate.py rename tests/{api => sandbox}/test_enc_flac.py (100%) rename tests/{api => sandbox}/test_enc_mp3.py (100%) rename tests/{api => sandbox}/test_enc_mp3_by_block.py (100%) rename tests/{api => sandbox}/test_enc_ogg.py (100%) rename tests/{api => sandbox}/test_enc_webm.py (100%) rename tests/{api => sandbox}/test_flac.py (100%) rename tests/{api => sandbox}/test_lolevel.py (100%) rename tests/{api => sandbox}/test_lolevel_streaming.py (100%) rename tests/{api => sandbox}/test_lolevel_streaming_bad.py (100%) rename tests/{api => sandbox}/test_lolevel_streaming_vorbis.py (100%) rename tests/{api => sandbox}/test_mp3.py (100%) create mode 100644 tests/sandbox/test_mp3_2.py create mode 100644 tests/sandbox/test_mp3_3.py create mode 100644 tests/sandbox/test_parent.py rename tests/{api => sandbox}/test_pipe.py (100%) create mode 100644 tests/sandbox/test_results.py rename tests/{api => sandbox}/test_spectrogram.py (100%) create mode 100644 tests/sandbox/test_spectrogram2.py create mode 100644 tests/sandbox/test_spectrogram3.py rename tests/{api => sandbox}/test_vorbis.py (100%) rename tests/{api => sandbox}/test_wav.py (100%) rename tests/{api => sandbox}/test_waveform.py (100%) create mode 100644 tests/sandbox/test_waveform3.py create mode 100644 tests/sandbox/test_waveform4.py create mode 100644 tests/sandbox/test_waveform_centroid.py create mode 100644 tests/sandbox/test_waveform_contour.py create mode 100644 tests/sandbox/test_waveform_simple.py diff --git a/tests/api/__init__.py b/tests/sandbox/__init__.py similarity index 100% rename from tests/api/__init__.py rename to tests/sandbox/__init__.py diff --git a/tests/api/examples.py b/tests/sandbox/examples.py similarity index 100% rename from tests/api/examples.py rename to tests/sandbox/examples.py diff --git a/tests/api/exempleCMMR_vamp.py b/tests/sandbox/exempleCMMR_vamp.py similarity index 100% rename from tests/api/exempleCMMR_vamp.py rename to tests/sandbox/exempleCMMR_vamp.py diff --git a/tests/api/exemplesCMMR.py b/tests/sandbox/exemplesCMMR.py similarity index 100% rename from tests/api/exemplesCMMR.py rename to tests/sandbox/exemplesCMMR.py diff --git a/tests/api/test_all.py b/tests/sandbox/test_all.py similarity index 100% rename from tests/api/test_all.py rename to tests/sandbox/test_all.py diff --git a/tests/api/test_all_graphers.py b/tests/sandbox/test_all_graphers.py similarity index 100% rename from tests/api/test_all_graphers.py rename to tests/sandbox/test_all_graphers.py diff --git a/tests/api/test_analyzer.py b/tests/sandbox/test_analyzer.py similarity index 100% rename from tests/api/test_analyzer.py rename to tests/sandbox/test_analyzer.py diff --git a/tests/api/test_analyzer3.py b/tests/sandbox/test_analyzer3.py similarity index 100% rename from tests/api/test_analyzer3.py rename to tests/sandbox/test_analyzer3.py diff --git a/tests/sandbox/test_analyzer4.py b/tests/sandbox/test_analyzer4.py new file mode 100644 index 0000000..440fc00 --- /dev/null +++ b/tests/sandbox/test_analyzer4.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +import timeside +import sys +import os.path +import numpy +import time + + +class TestAnalyzer: + + analyzer = timeside.analyzer.Level() + + def __init__(self, path): + self.source = path + print "Processing %s" % self.source + self.decoder = timeside.decoder.FileDecoder(self.source) + print 'format: ', self.decoder.format() + self.pipe = self.decoder + self.sub_pipe = self.analyzer + + def process(self): + self.pipe = self.pipe | self.sub_pipe + self.pipe.run() + + def results(self): + print self.sub_pipe.results() + +test = TestAnalyzer(sys.argv[-1]) +test.process() +test.results() diff --git a/tests/sandbox/test_aubio_bpm.py b/tests/sandbox/test_aubio_bpm.py new file mode 100644 index 0000000..9c0e84a --- /dev/null +++ b/tests/sandbox/test_aubio_bpm.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +import sys +sys.path.append('/home/momo/dev/aubio/interfaces/python/build/lib.linux-x86_64-2.6/') + +import timeside + +decoder = timeside.decoder.FileDecoder('/home/momo/music_local/Kavinsky - Nightcall EP/01 Nightcall (Feat. Lovefoxxx).mp3') +analyzer = timeside.analyzer.AubioBPM() +(decoder | analyzer).run() +print analyzer.result() + + diff --git a/tests/sandbox/test_aubio_onsetrate.py b/tests/sandbox/test_aubio_onsetrate.py new file mode 100644 index 0000000..1a812eb --- /dev/null +++ b/tests/sandbox/test_aubio_onsetrate.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- + +import timeside + +decoder = timeside.decoder.FileDecoder('/home/momo/music_local/Kavinsky - Nightcall EP/01 Nightcall (Feat. Lovefoxxx).mp3') +analyzer = timeside.analyzer.AubioOnsetRate() +(decoder | analyzer).run() +print analyzer.result() + + diff --git a/tests/api/test_enc_flac.py b/tests/sandbox/test_enc_flac.py similarity index 100% rename from tests/api/test_enc_flac.py rename to tests/sandbox/test_enc_flac.py diff --git a/tests/api/test_enc_mp3.py b/tests/sandbox/test_enc_mp3.py similarity index 100% rename from tests/api/test_enc_mp3.py rename to tests/sandbox/test_enc_mp3.py diff --git a/tests/api/test_enc_mp3_by_block.py b/tests/sandbox/test_enc_mp3_by_block.py similarity index 100% rename from tests/api/test_enc_mp3_by_block.py rename to tests/sandbox/test_enc_mp3_by_block.py diff --git a/tests/api/test_enc_ogg.py b/tests/sandbox/test_enc_ogg.py similarity index 100% rename from tests/api/test_enc_ogg.py rename to tests/sandbox/test_enc_ogg.py diff --git a/tests/api/test_enc_webm.py b/tests/sandbox/test_enc_webm.py similarity index 100% rename from tests/api/test_enc_webm.py rename to tests/sandbox/test_enc_webm.py diff --git a/tests/api/test_flac.py b/tests/sandbox/test_flac.py similarity index 100% rename from tests/api/test_flac.py rename to tests/sandbox/test_flac.py diff --git a/tests/api/test_lolevel.py b/tests/sandbox/test_lolevel.py similarity index 100% rename from tests/api/test_lolevel.py rename to tests/sandbox/test_lolevel.py diff --git a/tests/api/test_lolevel_streaming.py b/tests/sandbox/test_lolevel_streaming.py similarity index 100% rename from tests/api/test_lolevel_streaming.py rename to tests/sandbox/test_lolevel_streaming.py diff --git a/tests/api/test_lolevel_streaming_bad.py b/tests/sandbox/test_lolevel_streaming_bad.py similarity index 100% rename from tests/api/test_lolevel_streaming_bad.py rename to tests/sandbox/test_lolevel_streaming_bad.py diff --git a/tests/api/test_lolevel_streaming_vorbis.py b/tests/sandbox/test_lolevel_streaming_vorbis.py similarity index 100% rename from tests/api/test_lolevel_streaming_vorbis.py rename to tests/sandbox/test_lolevel_streaming_vorbis.py diff --git a/tests/api/test_mp3.py b/tests/sandbox/test_mp3.py similarity index 100% rename from tests/api/test_mp3.py rename to tests/sandbox/test_mp3.py diff --git a/tests/sandbox/test_mp3_2.py b/tests/sandbox/test_mp3_2.py new file mode 100644 index 0000000..5d5fe22 --- /dev/null +++ b/tests/sandbox/test_mp3_2.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +from timeside.decoder import * +from timeside.encoder import * +import os.path + +source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav") +dest = os.path.join(os.path.dirname(__file__), "/tmp/sweep_wav.mp3") + +decoder = FileDecoder(source) +encoder = Mp3Encoder(dest) + +(decoder | encoder).run() + +metadata = {'TIT2': 'title', #title2 + 'TCOM': 'composer', #composer + 'TPE1': 'lead creator', #lead + 'UFID': 'identifier', #Unique ID... + 'TALB': 'album', #album + 'TCON': 'genre', #genre + 'TDRC': '2011', #year +# 'COMM': 'blabla', #comment + } + +encoder.set_metadata(metadata) +encoder.write_metadata() + diff --git a/tests/sandbox/test_mp3_3.py b/tests/sandbox/test_mp3_3.py new file mode 100644 index 0000000..2d74b37 --- /dev/null +++ b/tests/sandbox/test_mp3_3.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +import time +import timeside + +metadata = {'TIT2': 'title', #title2 + 'TCOM': 'composer', #composer + 'TPE1': 'lead creator', #lead + 'UFID': 'identifier', #Unique ID... + 'TALB': 'album', #album + 'TCON': 'genre', #genre + 'TDRC': '2011', #year +# 'COMM': 'blabla', #comment + } + +decoder = timeside.decoder.FileDecoder('/home/momo/dev/telemeta/sandboxes/sandbox_lam/media/items/2012/09/26/LAM_ETUD_01_01_004.wav') + +encoder = timeside.encoder.Mp3Encoder('/tmp/output.mp3') +encoder.set_metadata(metadata) + +(decoder | encoder).run() + diff --git a/tests/sandbox/test_parent.py b/tests/sandbox/test_parent.py new file mode 100644 index 0000000..4852464 --- /dev/null +++ b/tests/sandbox/test_parent.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +import timeside +import os.path + +source = os.path.join(os.path.dirname(__file__), "../samples/sweep.wav") + +d = timeside.decoder.FileDecoder(source) +a = timeside.analyzer.OnsetDetectionFunction() + +(d | a).run() + +print a.results \ No newline at end of file diff --git a/tests/api/test_pipe.py b/tests/sandbox/test_pipe.py similarity index 100% rename from tests/api/test_pipe.py rename to tests/sandbox/test_pipe.py diff --git a/tests/sandbox/test_results.py b/tests/sandbox/test_results.py new file mode 100644 index 0000000..f489b38 --- /dev/null +++ b/tests/sandbox/test_results.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +import timeside.decoder +import timeside.analyzer + + +decoder = timeside.decoder.FileDecoder('/home/momo/dev/timeside/timeside/tests/samples/sweep.wav') +analyzer = timeside.analyzer.AubioMelEnergy() +(decoder | analyzer).run() + +print len(analyzer.results()) +print len(analyzer.results()) +print len(analyzer.results()) + + + diff --git a/tests/api/test_spectrogram.py b/tests/sandbox/test_spectrogram.py similarity index 100% rename from tests/api/test_spectrogram.py rename to tests/sandbox/test_spectrogram.py diff --git a/tests/sandbox/test_spectrogram2.py b/tests/sandbox/test_spectrogram2.py new file mode 100644 index 0000000..762f5ac --- /dev/null +++ b/tests/sandbox/test_spectrogram2.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import os +from timeside.decoder import * +from timeside.grapher import * + +sample_dir = '../samples' +img_dir = '../results/img' +if not os.path.exists(img_dir): + os.mkdir(img_dir) + +test_dict = {'sweep.wav': 'spec_wav.png',} + +for source, image in test_dict.iteritems(): + audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source) + image = img_dir + os.sep + image + print 'Test : decoder(%s) | waveform (%s)' % (source, image) + decoder = FileDecoder(audio) + spectrogram = SpectrogramLinear() + (decoder | spectrogram).run() + print 'frames per pixel = ', spectrogram.samples_per_pixel + print "render spectrogram to: %s" % image + spectrogram.render(image) + + + diff --git a/tests/sandbox/test_spectrogram3.py b/tests/sandbox/test_spectrogram3.py new file mode 100644 index 0000000..19fcf9b --- /dev/null +++ b/tests/sandbox/test_spectrogram3.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +import os +import timeside + +audio_dir = '/home/momo/music_local/test/aboul/wav/' +audio_file = 'aboul.wav' +audio_path = audio_dir + audio_file +img_dir = '../results/img' + +if not os.path.exists(img_dir): + os.makedirs(img_dir) + +decoder = timeside.decoder.FileDecoder(audio_path) +analyzers = timeside.core.processors(timeside.api.IAnalyzer) +pipe = decoder + +for analyzer in analyzers: + subpipe = analyzer() + analyzers_sub.append(subpipe) + pipe = pipe | subpipe + +image = img_dir + os.sep + source + '.png' +print 'Test : decoder(%s) | waveform (%s)' % (source, image) + +spectrogram = SpectrogramLinear(width=10240, height=512, bg_color=(0,0,0), color_scheme='default') +(decoder | spectrogram).run() +print 'frames per pixel = ', spectrogram.samples_per_pixel +print "render spectrogram to: %s" % image +spectrogram.render(image) + diff --git a/tests/api/test_vorbis.py b/tests/sandbox/test_vorbis.py similarity index 100% rename from tests/api/test_vorbis.py rename to tests/sandbox/test_vorbis.py diff --git a/tests/api/test_wav.py b/tests/sandbox/test_wav.py similarity index 100% rename from tests/api/test_wav.py rename to tests/sandbox/test_wav.py diff --git a/tests/api/test_waveform.py b/tests/sandbox/test_waveform.py similarity index 100% rename from tests/api/test_waveform.py rename to tests/sandbox/test_waveform.py diff --git a/tests/sandbox/test_waveform3.py b/tests/sandbox/test_waveform3.py new file mode 100644 index 0000000..74603cb --- /dev/null +++ b/tests/sandbox/test_waveform3.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import os +from timeside.core import * +from timeside.api import * +from timeside.decoder import * +from timeside.grapher import * + +sample_dir = '/home/momo/music_local/Isabelle Aboulker/Mon imagier des instruments/wav/' +img_dir = '../results/img' +if not os.path.exists(img_dir): + os.mkdir(img_dir) + +for source in os.listdir(sample_dir): + audio = sample_dir + os.sep + source + image = img_dir + os.sep + source + '.png' + print 'Test : decoder(%s) | waveform (%s)' % (source, image) + decoder = FileDecoder(audio) + waveform = Waveform(width=1024, height=256, bg_color=(0,0,0), color_scheme='default') + (decoder | waveform).run() + print 'frames per pixel = ', waveform.graph.samples_per_pixel + print "render waveform to: %s" % image + waveform.render(image) + + + diff --git a/tests/sandbox/test_waveform4.py b/tests/sandbox/test_waveform4.py new file mode 100644 index 0000000..41e7a82 --- /dev/null +++ b/tests/sandbox/test_waveform4.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +import os +from timeside.core import * +from timeside.api import * +from timeside.decoder import * +from timeside.grapher import * + +sample = '/home/momo/music_local/Isabelle Aboulker/Mon imagier des instruments/16 - Isabelle Aboulker - 16 instru.flac' +img_dir = '../results/img' +if not os.path.exists(img_dir): + os.mkdir(img_dir) + +audio = sample +image = img_dir + os.sep + 'toto.png' +decoder = FileDecoder(audio) +waveform = Waveform(width=1211, height=170, bg_color=(0,0,0), color_scheme='default') +(decoder | waveform).run() +print 'frames per pixel = ', waveform.graph.samples_per_pixel +print "render waveform to: %s" % image +waveform.render(image) + + + diff --git a/tests/sandbox/test_waveform_centroid.py b/tests/sandbox/test_waveform_centroid.py new file mode 100644 index 0000000..6b343d1 --- /dev/null +++ b/tests/sandbox/test_waveform_centroid.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import os +from timeside.core import * +from timeside.api import * +from timeside.decoder import * +from timeside.grapher import * + +sample_dir = '../samples' +img_dir = '../results/img' +if not os.path.exists(img_dir): + os.makedirs(img_dir) + +test_dict = {'sweep.wav': 'waveform_wav.png', + 'sweep.flac': 'waveform_flac.png', + 'sweep.ogg': 'waveform_ogg.png', + 'sweep.mp3': 'waveform_mp3.png', + } + +for source, image in test_dict.iteritems(): + audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source) + image = img_dir + os.sep + image + print 'Test : decoder(%s) | waveform (%s)' % (source, image) + decoder = FileDecoder(audio) + waveform = WaveformCentroid(width=1024, height=256, bg_color=(0,0,0), color_scheme='default') + (decoder | waveform).run() + print 'frames per pixel = ', waveform.samples_per_pixel + print "render waveform to: %s" % image + waveform.render(image) diff --git a/tests/sandbox/test_waveform_contour.py b/tests/sandbox/test_waveform_contour.py new file mode 100644 index 0000000..7fde73c --- /dev/null +++ b/tests/sandbox/test_waveform_contour.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import os +from timeside.core import * +from timeside.api import * +from timeside.decoder import * +from timeside.grapher import * + +sample_dir = '../samples' +img_dir = '../results/img' +if not os.path.exists(img_dir): + os.makedirs(img_dir) + +test_dict = {'sweep.wav': 'waveform_wav.png', + 'sweep.flac': 'waveform_flac.png', + 'sweep.ogg': 'waveform_ogg.png', + 'sweep.mp3': 'waveform_mp3.png', + } + +for source, image in test_dict.iteritems(): + audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source) + image = img_dir + os.sep + image + print 'Test : decoder(%s) | waveform (%s)' % (source, image) + decoder = FileDecoder(audio) + waveform = WaveformContourBlack() + (decoder | waveform).run() + print 'frames per pixel = ', waveform.samples_per_pixel + print "render waveform to: %s" % image + waveform.render(image) diff --git a/tests/sandbox/test_waveform_simple.py b/tests/sandbox/test_waveform_simple.py new file mode 100644 index 0000000..ea95a4a --- /dev/null +++ b/tests/sandbox/test_waveform_simple.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import os +from timeside.core import * +from timeside.api import * +from timeside.decoder import * +from timeside.grapher import * + +sample_dir = '../samples' +img_dir = '../results/img' +if not os.path.exists(img_dir): + os.makedirs(img_dir) + +test_dict = {'sweep.wav': 'waveform_wav.png', + 'sweep.flac': 'waveform_flac.png', + 'sweep.ogg': 'waveform_ogg.png', + 'sweep.mp3': 'waveform_mp3.png', + } + +for source, image in test_dict.iteritems(): + audio = os.path.join(os.path.dirname(__file__), sample_dir + os.sep + source) + image = img_dir + os.sep + image + print 'Test : decoder(%s) | waveform (%s)' % (source, image) + decoder = FileDecoder(audio) + waveform = Waveform() + (decoder | waveform).run() + print 'frames per pixel = ', waveform.samples_per_pixel + print "render waveform to: %s" % image + waveform.render(image) -- 2.39.5