- Timestamp:
- Mar 5, 2013, 11:11:46 PM (12 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 7606d23
- Parents:
- 223e2fe
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/demos/demo_sink.py
r223e2fe re76eaf1 6 6 if __name__ == '__main__': 7 7 if len(sys.argv) < 3: 8 print 'usage: %s <inputfile> <outputfile> ' % sys.argv[0]8 print 'usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0] 9 9 sys.exit(1) 10 f = source(sys.argv[1], 8000, 256) 11 g = sink(sys.argv[2], 8000) 12 total_frames, read = 0, 256 10 11 if len(sys.argv) > 3: samplerate = int(sys.argv[3]) 12 else: samplerate = 0 13 if len(sys.argv) > 4: hop_size = int(sys.argv[4]) 14 else: hop_size = 256 15 16 f = source(sys.argv[1], samplerate, hop_size) 17 if samplerate == 0: samplerate = f.samplerate 18 g = sink(sys.argv[2], samplerate) 19 20 total_frames, read = 0, hop_size 13 21 while read: 14 22 vec, read = f() 15 23 g(vec, read) 16 24 total_frames += read 17 print "read", total_frames / float(f.samplerate), "seconds from", f.uri 25 print "wrote", "%.2fs" % (total_frames / float(samplerate) ), 26 print "(", total_frames, "frames", "in", total_frames % hop_size, "blocks", "at", "%dHz" % samplerate, ")", 27 print "from", f.uri, 28 print "to", g.uri
Note: See TracChangeset
for help on using the changeset viewer.