From 70a1cfc9d3c658bc0f018b450438db8039b469c7 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Tue, 7 Nov 2023 08:52:07 +0000 Subject: [PATCH] Update examples --- examples/buffer-play-example.py | 18 ++++++++++++------ examples/granulation-example.py | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/examples/buffer-play-example.py b/examples/buffer-play-example.py index b2b394e0..122eba9f 100755 --- a/examples/buffer-play-example.py +++ b/examples/buffer-play-example.py @@ -5,16 +5,22 @@ # Reads a stereo buffer from an audio file, and plays it through system output. #-------------------------------------------------------------------------------- -import signalflow as sf +from signalflow import * import os -graph = sf.AudioGraph() +graph = AudioGraph() -audio_path = os.path.join(os.path.dirname(__file__), "../audio/stereo-count.wav") -buf = sf.Buffer(audio_path) -player = sf.BufferPlayer(buf, loop=True) +#-------------------------------------------------------------------------------- +# Read samples into a Buffer by passing the filename +#-------------------------------------------------------------------------------- +audio_path = os.path.join(os.path.dirname(__file__), "audio", "stereo-count.wav") +buf = Buffer(audio_path) +print("Loaded buffer with %d channel(s), duration: %.1fs" % (buf.num_channels, buf.duration)) -print("Loaded buffer: %s" % buf) +#-------------------------------------------------------------------------------- +# Begin looping playback +#-------------------------------------------------------------------------------- +player = BufferPlayer(buf, loop=True) graph.play(player) graph.wait() diff --git a/examples/granulation-example.py b/examples/granulation-example.py index e667b1c8..3904ad36 100755 --- a/examples/granulation-example.py +++ b/examples/granulation-example.py @@ -15,7 +15,7 @@ #------------------------------------------------------------------------ # Load an audio buffer. #------------------------------------------------------------------------ -audio_path = os.path.join(os.path.dirname(__file__), "../audio/gliss.aif") +audio_path = os.path.join(os.path.dirname(__file__), "audio", "gliss.aif") buf = Buffer(audio_path) clock = RandomImpulse(50) pos = WhiteNoise(1, min=0, max=buf.duration, interpolate=False)