Skip to content

Commit

Permalink
SignalFlowOutputDevice: Intelligently handle different eexistence cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Oct 25, 2024
1 parent 70b8cde commit 40f1d58
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions isobar/io/signalflow/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ def __init__(self, graph=None):
if graph:
self.graph = graph
else:
try:
self.graph = sf.AudioGraph()
except NameError:
raise Exception("Could not instantiate SignalFlowOutputDevice, signalflow not installed?")
except sf.GraphAlreadyCreatedException:
raise Exception("SignalFlow graph has already been instantiated."
"Pass the AudioGraph object as an argument to SignalFlowOutputDevice.")
self.graph = sf.AudioGraph.get_shared_graph()
if self.graph is None:
try:
self.graph = sf.AudioGraph(start=True)
except NameError:
raise Exception("Could not instantiate SignalFlowOutputDevice, signalflow not installed?")
except sf.GraphAlreadyCreatedException:
raise Exception("SignalFlow graph has already been instantiated."
"Pass the AudioGraph object as an argument to SignalFlowOutputDevice.")

self.graph.start()
log.info("Opened SignalFlow output")

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

if output:
if patch.add_to_graph():
#--------------------------------------------------------------------------------
# Can fail if the graph exceeds its configured patch count limit
#--------------------------------------------------------------------------------
output.add_input(patch)
else:
self.graph.play(patch)
Expand Down

0 comments on commit 40f1d58

Please sign in to comment.