From 4013382cb68db2492fd19cfbc94c17dc06344bf6 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 14 Feb 2014 18:31:21 -0300 Subject: [PATCH] python/demos/demo_pysoundcard_play.py: added simple example using pysoundcard --- python/demos/demo_pysoundcard_play.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 python/demos/demo_pysoundcard_play.py diff --git a/python/demos/demo_pysoundcard_play.py b/python/demos/demo_pysoundcard_play.py new file mode 100755 index 00000000..b0bf70c1 --- /dev/null +++ b/python/demos/demo_pysoundcard_play.py @@ -0,0 +1,24 @@ +#! /usr/bin/env python + +def play_source(source_path): + """Play an audio file using pysoundcard.""" + + from aubio import source + from pysoundcard import Stream + + hop_size = 256 + f = source(source_path, hop_size = hop_size) + samplerate = f.samplerate + + s = Stream(sample_rate = samplerate, block_length = hop_size) + s.start() + read = 0 + while 1: + vec, read = f() + s.write(vec) + if read < hop_size: break + s.stop() + +if __name__ == '__main__': + import sys + play_source(sys.argv[1]) -- 2.11.0