source: python/demos/demo_tss.py @ 082c88b

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 082c88b was 3184468, checked in by Paul Brossier <piem@piem.org>, 12 years ago

python/demos/demo_tss.py: improve default parameters

  • Property mode set to 100755
File size: 1.4 KB
RevLine 
[7175ed4]1#! /usr/bin/env python
[d3b1eb1]2
3import sys
4from aubio import source, sink, pvoc, tss
5
6if __name__ == '__main__':
7  if len(sys.argv) < 2:
8    print 'usage: %s <inputfile> <outputfile_transient> <outputfile_steady>' % sys.argv[0]
9    sys.exit(1)
10
11  samplerate = 44100
[3184468]12  win_s = 1024      # fft size
13  hop_s = win_s / 4 # block size
14  threshold = 0.5
[d3b1eb1]15
16  f = source(sys.argv[1], samplerate, hop_s)
17  g = sink(sys.argv[2], samplerate)
18  h = sink(sys.argv[3], samplerate)
19
[3184468]20  pva = pvoc(win_s, hop_s)    # a phase vocoder
21  pvb = pvoc(win_s, hop_s)    # another phase vocoder
[d3b1eb1]22  t = tss(win_s, hop_s)       # transient steady state separation
23
24  t.set_threshold(threshold)
25
26  read = hop_s
27
28  while read:
29    samples, read = f()               # read file
[3184468]30    spec = pva(samples)                # compute spectrum
[d3b1eb1]31    trans_spec, stead_spec = t(spec)  # transient steady-state separation
[3184468]32    transients = pva.rdo(trans_spec)   # overlap-add synthesis of transients
33    steadstate = pvb.rdo(stead_spec)   # overlap-add synthesis of steady states
[d3b1eb1]34    g(transients, read)               # write transients to output
35    h(steadstate, read)               # write steady states to output
[0c83de6]36
37  del f, g, h                         # finish writing the files now
38
39  from demo_spectrogram import get_spectrogram
40  from pylab import subplot, show
41  subplot(311)
42  get_spectrogram(sys.argv[1])
43  subplot(312)
44  get_spectrogram(sys.argv[2])
45  subplot(313)
46  get_spectrogram(sys.argv[3])
47  show()
Note: See TracBrowser for help on using the repository browser.