summaryrefslogtreecommitdiff
path: root/examples/harmonicsynthesis.py
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2012-08-30 10:09:03 +0100
committerJohn Glover <j@johnglover.net>2012-08-30 10:09:03 +0100
commit781aa577be678e845d8c8ededa3b1aea5a6a4f6c (patch)
treeb2c670af2cab6137e0c1896d5fa2f28fdcbd2c6c /examples/harmonicsynthesis.py
parente11640ebce01e39b4a900c5c29acd401cda4f77f (diff)
downloadsimpl-781aa577be678e845d8c8ededa3b1aea5a6a4f6c.tar.gz
simpl-781aa577be678e845d8c8ededa3b1aea5a6a4f6c.tar.bz2
simpl-781aa577be678e845d8c8ededa3b1aea5a6a4f6c.zip
[examples] Rename synthesis examples.
Diffstat (limited to 'examples/harmonicsynthesis.py')
-rw-r--r--examples/harmonicsynthesis.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/harmonicsynthesis.py b/examples/harmonicsynthesis.py
new file mode 100644
index 0000000..99d6e39
--- /dev/null
+++ b/examples/harmonicsynthesis.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)