shithub: aubio

Download patch

ref: 2a49114729ca45507924a8b8843e6120554d4530
parent: 060a3135918e8f1d7739ff5f1c82986c0fce7911
author: Paul Brossier <[email protected]>
date: Sun Feb 23 12:42:00 EST 2014

python/lib/aubio/slicing.py: respect source number of channels when slicing

--- a/python/lib/aubio/slicing.py
+++ b/python/lib/aubio/slicing.py
@@ -44,7 +44,7 @@
 
     while True:
         # get hopsize new samples from source
-        vec, read = s()
+        vec, read = s.do_multi()
         # if the total number of frames read will exceed the next region start
         if len(regions) and total_frames + read >= regions[0][0]:
             #print "getting", regions[0], "at", total_frames
@@ -53,7 +53,7 @@
             # create a name for the sink
             new_sink_path = new_sink_name(source_base_name, start_stamp, samplerate)
             # create its sink
-            g = sink(new_sink_path, samplerate)
+            g = sink(new_sink_path, samplerate, s.channels)
             # create a dictionary containing all this
             new_slice = {'start_stamp': start_stamp, 'end_stamp': end_stamp, 'sink': g}
             # append the dictionary to the current list of slices
@@ -72,12 +72,12 @@
             if remaining < read:
                 if remaining > start:
                     # write remaining samples from current region
-                    g(vec[start:remaining], remaining - start)
+                    g.do_multi(vec[:,start:remaining], remaining - start)
                     #print "closing region", "remaining", remaining
                     # close this file
                     g.close()
             elif read > start:
                 # write all the samples
-                g(vec[start:read], read - start)
+                g.do_multi(vec[:,start:read], read - start)
         total_frames += read
         if read < hopsize: break