Piccole correzioni e migliorie varie
Leonardo Robol [2010-03-13 09:48]
Piccole correzioni e migliorie varie
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]