-
Notifications
You must be signed in to change notification settings - Fork 16
/
buffer-play-example.py
executable file
·32 lines (23 loc) · 1.11 KB
/
buffer-play-example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3
#--------------------------------------------------------------------------------
# Example: Buffer playback
# Reads a stereo buffer from an audio file, and plays it through system output.
#--------------------------------------------------------------------------------
from signalflow import *
import os
def main():
graph = AudioGraph()
#--------------------------------------------------------------------------------
# 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))
#--------------------------------------------------------------------------------
# Begin looping playback
#--------------------------------------------------------------------------------
player = BufferPlayer(buf, loop=True)
graph.play(player)
graph.wait()
if __name__ == "__main__":
main()