Skip to content

Commit 40f1d58

Browse files
committed
SignalFlowOutputDevice: Intelligently handle different eexistence cases
1 parent 70b8cde commit 40f1d58

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

isobar/io/signalflow/output.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@ def __init__(self, graph=None):
2424
if graph:
2525
self.graph = graph
2626
else:
27-
try:
28-
self.graph = sf.AudioGraph()
29-
except NameError:
30-
raise Exception("Could not instantiate SignalFlowOutputDevice, signalflow not installed?")
31-
except sf.GraphAlreadyCreatedException:
32-
raise Exception("SignalFlow graph has already been instantiated."
33-
"Pass the AudioGraph object as an argument to SignalFlowOutputDevice.")
27+
self.graph = sf.AudioGraph.get_shared_graph()
28+
if self.graph is None:
29+
try:
30+
self.graph = sf.AudioGraph(start=True)
31+
except NameError:
32+
raise Exception("Could not instantiate SignalFlowOutputDevice, signalflow not installed?")
33+
except sf.GraphAlreadyCreatedException:
34+
raise Exception("SignalFlow graph has already been instantiated."
35+
"Pass the AudioGraph object as an argument to SignalFlowOutputDevice.")
3436

35-
self.graph.start()
3637
log.info("Opened SignalFlow output")
3738

3839
self.patches = []
@@ -52,6 +53,9 @@ def create(self, patch_spec, patch_params, output=None):
5253

5354
if output:
5455
if patch.add_to_graph():
56+
#--------------------------------------------------------------------------------
57+
# Can fail if the graph exceeds its configured patch count limit
58+
#--------------------------------------------------------------------------------
5559
output.add_input(patch)
5660
else:
5761
self.graph.play(patch)

0 commit comments

Comments
 (0)