diff options
-rw-r--r-- | examples/plotpartials.py | 19 | ||||
-rw-r--r-- | examples/plotpeaks.py (renamed from simpl/examples/plotpeaks.py) | 9 | ||||
-rw-r--r-- | examples/residual.py | 17 | ||||
-rw-r--r-- | examples/resynth.py | 21 | ||||
-rw-r--r-- | simpl/examples/plotpartials.py | 15 | ||||
-rw-r--r-- | simpl/examples/residual.py | 17 | ||||
-rw-r--r-- | simpl/examples/resynth.py | 20 |
7 files changed, 64 insertions, 54 deletions
diff --git a/examples/plotpartials.py b/examples/plotpartials.py new file mode 100644 index 0000000..65017b0 --- /dev/null +++ b/examples/plotpartials.py @@ -0,0 +1,19 @@ +import sys +import matplotlib.pyplot as plt +import simpl + +usage = 'Usage: python {0} <wav file>'.format(__file__) +if len(sys.argv) != 2: + print usage + sys.exit(1) + +audio = simpl.read_wav(sys.argv[1])[0] + +pd = simpl.LorisPeakDetection() +pd.max_peaks = 30 +peaks = pd.find_peaks(audio) +pt = simpl.MQPartialTracking() +pt.max_partials = 30 +partials = pt.find_partials(peaks) +simpl.plot_partials(partials, show_peaks=False) +plt.show() diff --git a/simpl/examples/plotpeaks.py b/examples/plotpeaks.py index 01d44ed..ef2a1a4 100644 --- a/simpl/examples/plotpeaks.py +++ b/examples/plotpeaks.py @@ -1,8 +1,13 @@ +import sys import simpl import matplotlib.pyplot as plt -input_file = '../../tests/audio/flute.wav' -audio = simpl.read_wav(input_file)[0] +usage = 'Usage: python {0} <wav file>'.format(__file__) +if len(sys.argv) != 2: + print usage + sys.exit(1) + +audio = simpl.read_wav(sys.argv[1])[0] # take just a few frames audio = audio[len(audio) / 2:(len(audio) / 2) + 4096] diff --git a/examples/residual.py b/examples/residual.py new file mode 100644 index 0000000..cd41dd4 --- /dev/null +++ b/examples/residual.py @@ -0,0 +1,17 @@ +import sys +import numpy as np +import scipy.io.wavfile as wav +import simpl + +usage = 'Usage: python {0} <input wav file> <output wav file>'.format(__file__) +if len(sys.argv) != 3: + print usage + sys.exit(1) + +audio = simpl.read_wav(sys.argv[1])[0] +output_file = sys.argv[2] + +r = simpl.SMSResidual() +audio_out = r.synth(audio) +audio_out = np.asarray(audio_out * 32768, np.int16) +wav.write(output_file, 44100, audio_out) diff --git a/examples/resynth.py b/examples/resynth.py new file mode 100644 index 0000000..99d6e39 --- /dev/null +++ b/examples/resynth.py @@ -0,0 +1,21 @@ +import sys +import numpy as np +import scipy.io.wavfile as wav +import simpl + +usage = 'Usage: python {0} <input wav file> <output wav file>'.format(__file__) +if len(sys.argv) != 3: + print usage + sys.exit(1) + +audio = simpl.read_wav(sys.argv[1])[0] +output_file = sys.argv[2] + +pd = simpl.LorisPeakDetection() +peaks = pd.find_peaks(audio) +pt = simpl.SMSPartialTracking() +partials = pt.find_partials(peaks) +synth = simpl.LorisSynthesis() +audio_out = synth.synth(partials) +audio_out = np.asarray(audio_out * 32768, np.int16) +wav.write(output_file, 44100, audio_out) diff --git a/simpl/examples/plotpartials.py b/simpl/examples/plotpartials.py deleted file mode 100644 index 8bce791..0000000 --- a/simpl/examples/plotpartials.py +++ /dev/null @@ -1,15 +0,0 @@ -import matplotlib.pyplot as plt -import simpl - -input_file = '../../tests/audio/flute.wav' -audio = simpl.read_wav(input_file)[0] -audio = audio[len(audio) / 2:(len(audio) / 2) + 4096] - -pd = simpl.SndObjPeakDetection() -pd.max_peaks = 60 -peaks = pd.find_peaks(audio) -pt = simpl.MQPartialTracking() -pt.max_partials = 60 -partials = pt.find_partials(peaks) -simpl.plot_partials(partials, show_peaks=False) -plt.show() diff --git a/simpl/examples/residual.py b/simpl/examples/residual.py deleted file mode 100644 index bfaa412..0000000 --- a/simpl/examples/residual.py +++ /dev/null @@ -1,17 +0,0 @@ -import simpl -import numpy as np -from scipy.io.wavfile import read, write - -input_file = '../../tests/audio/flute.wav' -output_file = 'residual.wav' - -audio_data = read(input_file) -audio = np.asarray(audio_data[1]) / 32768.0 -sampling_rate = audio_data[0] -hop_size = 512 - -r = simpl.SMSResidual() -r.hop_size = hop_size -audio_out = r.synth(audio) -audio_out = np.asarray(audio_out * 32768, np.int16) -write(output_file, 44100, audio_out) diff --git a/simpl/examples/resynth.py b/simpl/examples/resynth.py deleted file mode 100644 index 78f3f2d..0000000 --- a/simpl/examples/resynth.py +++ /dev/null @@ -1,20 +0,0 @@ -import simpl -import numpy as np -from scipy.io.wavfile import write - -input_file = '../../tests/audio/flute.wav' -output_file = 'resynth.wav' - -audio = simpl.read_wav(input_file)[0] - -pd = simpl.SMSPeakDetection() -pd.max_peaks = 40 -pd.hop_size = 512 -peaks = pd.find_peaks(audio) -pt = simpl.MQPartialTracking() -pt.max_partials = 20 -partials = pt.find_partials(peaks) -synth = simpl.SndObjSynthesis() -audio_out = synth.synth(partials) -audio_out = np.asarray(audio_out * 32768, np.int16) -write(output_file, 44100, audio_out) |