From a1b300304c77276fc73e58bfefafbf94ab7939a9 Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Sat, 13 Mar 2010 10:48:34 +0100 Subject: [PATCH] Piccole correzioni e migliorie varie --- Filtering/Filtering.py | 3 +++ Filtering/dwt | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Filtering/Filtering.py b/Filtering/Filtering.py index 126885a..2247897 100644 --- a/Filtering/Filtering.py +++ b/Filtering/Filtering.py @@ -124,6 +124,9 @@ class WaveletStack(): """Get the length of the lowsample array, i.e. how many low samples track do we have pushed.""" return len(self.high_samples) + + def GetAllSamplesNumber(self): + return sum(map(len, self.low_samples)) + sum(map(len,self.high_samples)) + len(self.end_effect) + len(self.end) def GetNumSamples(self): """Get the total number of samples in the WaveletStack.""" diff --git a/Filtering/dwt b/Filtering/dwt index c3d2ab3..b6d0fd8 100755 --- a/Filtering/dwt +++ b/Filtering/dwt @@ -78,6 +78,7 @@ class DWT(): StartProgram () startingTime = time.time () + self.depth = depth # Scelgo la filterbank da utilizzare if filterbank == 'haar': @@ -96,6 +97,7 @@ class DWT(): wavelets = filterBank.Split (samples) Output ("Decomposed in %f seconds" % (time.time() - startingTime)) + Output ("Wavelet size: %d bytes" % (2*wavelets.GetAllSamplesNumber())) # Mostro la decomposizione se l'utente l'ha chiesto if action == 'show': @@ -149,7 +151,7 @@ class DWT(): # We set the frequency to have seconds (and not samples) # in the x-axis of the plot. - frequency = 44100.0 + frequency = float (44100) # We choose a decreasing scale to sync all the samples # because they are recursively downsamples by a factor @@ -157,13 +159,14 @@ class DWT(): scale = pow(2, wavelets.GetNumSamples ()) singleOffset = 2 * wavelets.GetSamplesMaxValue() - offset = -3 * singleOffset + offset = -(self.depth / 2) * singleOffset - # We plot only the first 1000000 samples, to avoid memory + # We plot only the first 60 seconds of audio, to avoid memory # being flooded with our data :) - toPlot = 1000000 + toPlot = int(frequency) * 60 # Stampo i low + print scale scale = int(0.5 * scale) low = wavelets.PopLowSamples() data = low[:toPlot / scale] -- 2.1.4