From 8fb567c216b107a503a12de4fa9bf3f30fa59a5f Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Tue, 10 May 2016 21:53:01 +0200 Subject: [PATCH] python/demos: remove unused import and variables --- python/demos/demo_filterbank.py | 2 +- python/demos/demo_filterbank_slaney.py | 2 +- python/demos/demo_keyboard.py | 1 - python/demos/demo_mel-energy.py | 2 +- python/demos/demo_mfcc.py | 2 +- python/demos/demo_onset_plot.py | 2 +- python/demos/demo_pitch.py | 2 +- python/demos/demo_pitch_sinusoid.py | 3 +- python/demos/demo_pysoundcard_record.py | 3 +- python/demos/demo_reading_speed.py | 50 +++++++++++++++++++++++++++--- python/demos/demo_sink_create_woodblock.py | 2 +- python/demos/demo_tempo_plot.py | 2 +- python/demos/demo_tss.py | 1 + python/demos/demo_waveform_plot.py | 2 +- 14 files changed, 57 insertions(+), 19 deletions(-) mode change 100644 => 100755 python/demos/demo_reading_speed.py diff --git a/python/demos/demo_filterbank.py b/python/demos/demo_filterbank.py index 1620a031..69dc383d 100755 --- a/python/demos/demo_filterbank.py +++ b/python/demos/demo_filterbank.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from aubio import filterbank, fvec -from pylab import loglog, show, subplot, xlim, ylim, xlabel, ylabel, title +from pylab import loglog, show, xlim, ylim, xlabel, ylabel, title from numpy import vstack, arange win_s = 2048 diff --git a/python/demos/demo_filterbank_slaney.py b/python/demos/demo_filterbank_slaney.py index 636dc809..0a42505e 100755 --- a/python/demos/demo_filterbank_slaney.py +++ b/python/demos/demo_filterbank_slaney.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from aubio import filterbank -from numpy import array, arange, vstack +from numpy import arange, vstack win_s = 8192 samplerate = 16000 diff --git a/python/demos/demo_keyboard.py b/python/demos/demo_keyboard.py index 527d03bb..63786b9b 100755 --- a/python/demos/demo_keyboard.py +++ b/python/demos/demo_keyboard.py @@ -25,7 +25,6 @@ def get_keyboard_edges(firstnote = 21, lastnote = 108): return xb, xw, 2/3. *scaleb, 1/2. * scalew def create_keyboard_patches(firstnote, lastnote, ax = None): - import numpy as np import matplotlib.pyplot as plt from matplotlib.path import Path import matplotlib.patches as mpatches diff --git a/python/demos/demo_mel-energy.py b/python/demos/demo_mel-energy.py index ac098639..d433058c 100755 --- a/python/demos/demo_mel-energy.py +++ b/python/demos/demo_mel-energy.py @@ -1,7 +1,7 @@ #! /usr/bin/env python import sys -from aubio import fvec, source, pvoc, filterbank +from aubio import source, pvoc, filterbank from numpy import vstack, zeros win_s = 512 # fft size diff --git a/python/demos/demo_mfcc.py b/python/demos/demo_mfcc.py index 2242f0cd..d69ccef3 100755 --- a/python/demos/demo_mfcc.py +++ b/python/demos/demo_mfcc.py @@ -2,7 +2,7 @@ import sys from aubio import source, pvoc, mfcc -from numpy import array, vstack, zeros +from numpy import vstack, zeros win_s = 512 # fft size hop_s = win_s / 4 # hop size diff --git a/python/demos/demo_onset_plot.py b/python/demos/demo_onset_plot.py index a9286558..5d59cb67 100755 --- a/python/demos/demo_onset_plot.py +++ b/python/demos/demo_onset_plot.py @@ -2,7 +2,7 @@ import sys from aubio import onset, source -from numpy import array, hstack, zeros +from numpy import hstack, zeros win_s = 512 # fft size hop_s = win_s / 2 # hop size diff --git a/python/demos/demo_pitch.py b/python/demos/demo_pitch.py index 9126a55e..094eee7a 100755 --- a/python/demos/demo_pitch.py +++ b/python/demos/demo_pitch.py @@ -1,7 +1,7 @@ #! /usr/bin/env python import sys -from aubio import source, pitch, freqtomidi +from aubio import source, pitch if len(sys.argv) < 2: print "Usage: %s [samplerate]" % sys.argv[0] diff --git a/python/demos/demo_pitch_sinusoid.py b/python/demos/demo_pitch_sinusoid.py index 6407e586..1194df27 100755 --- a/python/demos/demo_pitch_sinusoid.py +++ b/python/demos/demo_pitch_sinusoid.py @@ -1,6 +1,6 @@ #! /usr/bin/env python -from numpy import random, sin, arange, ones, zeros +from numpy import random, sin, arange, zeros from math import pi from aubio import fvec, pitch @@ -10,7 +10,6 @@ def build_sinusoid(length, freqs, samplerate): def run_pitch(p, input_vec): f = fvec (p.hop_size) cands = [] - count = 0 for vec_slice in input_vec.reshape((-1, p.hop_size)): f[:] = vec_slice cands.append(p(f)) diff --git a/python/demos/demo_pysoundcard_record.py b/python/demos/demo_pysoundcard_record.py index e3816d2a..2b5c706e 100755 --- a/python/demos/demo_pysoundcard_record.py +++ b/python/demos/demo_pysoundcard_record.py @@ -21,9 +21,8 @@ def record_sink(sink_path): mono_vec = vec.sum(-1) / float(s.channels[0]) g(mono_vec, hop_size) total_frames += hop_size - except KeyboardInterrupt, e: + except KeyboardInterrupt: print "stopped after", "%.2f seconds" % (total_frames / s.samplerate) - pass s.stop() if __name__ == '__main__': diff --git a/python/demos/demo_reading_speed.py b/python/demos/demo_reading_speed.py old mode 100644 new mode 100755 index e6fdb78d..1158cec8 --- a/python/demos/demo_reading_speed.py +++ b/python/demos/demo_reading_speed.py @@ -5,16 +5,22 @@ Compare the speed of several methods for reading and loading a sound file. -This file depends on audioread and librosa: - https://github.com/beetbox/audioread - https://github.com/bmcfee/librosa +This file depends on the following packages: + + - audioread https://github.com/beetbox/audioread + - librosa https://github.com/bmcfee/librosa + - pydub https://github.com/jiaaro/pydub """ import numpy as np import aubio +""" import audioread import librosa +import scipy.io.wavfile +from pydub import AudioSegment +""" def read_file_audioread(filename): # taken from librosa.util.utils @@ -25,20 +31,43 @@ def read_file_audioread(filename): fmt = ' [samplerate]' % sys.argv[0] diff --git a/python/demos/demo_tempo_plot.py b/python/demos/demo_tempo_plot.py index de06d001..043e144f 100755 --- a/python/demos/demo_tempo_plot.py +++ b/python/demos/demo_tempo_plot.py @@ -39,7 +39,7 @@ while True: if len(beats) > 1: # do plotting - from numpy import array, arange, mean, median, diff + from numpy import mean, median, diff import matplotlib.pyplot as plt bpms = 60./ diff(beats) print 'mean period:', "%.2f" % mean(bpms), 'bpm', 'median', "%.2f" % median(bpms), 'bpm' diff --git a/python/demos/demo_tss.py b/python/demos/demo_tss.py index b38f474f..aa9107e0 100755 --- a/python/demos/demo_tss.py +++ b/python/demos/demo_tss.py @@ -44,3 +44,4 @@ if __name__ == '__main__': get_spectrogram(sys.argv[2]) subplot(313) get_spectrogram(sys.argv[3]) + show() diff --git a/python/demos/demo_waveform_plot.py b/python/demos/demo_waveform_plot.py index 91c6eda2..b4bd42a3 100755 --- a/python/demos/demo_waveform_plot.py +++ b/python/demos/demo_waveform_plot.py @@ -1,7 +1,7 @@ #! /usr/bin/env python import sys -from aubio import pvoc, source +from aubio import source from numpy import zeros, hstack def get_waveform_plot(filename, samplerate = 0, block_size = 4096, ax = None, downsample = 2**4): -- 2.11.0