From 5ab3c4ece2ba1500c268606df583828d85f6a0ec Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Thu, 23 Mar 2017 15:09:28 +0100 Subject: [PATCH] python/lib/aubio/cmd.py: add a flush function --- python/lib/aubio/cmd.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/python/lib/aubio/cmd.py b/python/lib/aubio/cmd.py index ee8ace74..de6e9db1 100644 --- a/python/lib/aubio/cmd.py +++ b/python/lib/aubio/cmd.py @@ -194,6 +194,8 @@ class default_process(object): name = type(self).__name__.split('_')[1] optstr = ' '.join(['running', name, 'with options', repr(self.options), '\n']) sys.stderr.write(optstr) + def flush(self, n_frames, samplerate): + pass class process_onset(default_process): valid_opts = ['method', 'hop_size', 'buf_size', 'samplerate'] @@ -265,6 +267,9 @@ class process_notes(default_process): fmt_out = "%f\t" % lastmidi fmt_out += self.time2string(frames_read, samplerate) sys.stdout.write(fmt_out) # + '\t') + def flush(self, frames_read, samplerate): + eof = self.time2string(frames_read, samplerate) + sys.stdout.write(eof + '\n') class process_mfcc(default_process): def __init__(self, args): @@ -350,11 +355,8 @@ def main(): frames_read += read # exit loop at end of file if read < a_source.hop_size: break - # special case for notes - if args.command == 'notes': - eof = processor.time2string(frames_read, a_source.samplerate) - sys.stdout.write(eof + '\n') - sys.stdout.flush() + # flush the processor if needed + processor.flush(frames_read, a_source.samplerate) if args.verbose > 1: fmt_string = "read {:.2f}s" fmt_string += " ({:d} samples in {:d} blocks of {:d})" -- 2.11.0