Skip to content

Commit ce6f262

Browse files
committed
fluidsynth plugin stub, changed plugin exporting
1 parent fe5c8ab commit ce6f262

File tree

4 files changed

+47
-30
lines changed

4 files changed

+47
-30
lines changed

textbeat/instrument.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ def stop(self):
1313
pass
1414

1515
PLUGINS = []
16-
# plugins call this method
17-
def export(s):
18-
global PLUGINS
19-
if s not in PLUGINS:
20-
PLUGINS.append(s())
21-
def plugins():
22-
return PLUGINS
16+
# # plugins call this method
17+
# def export(s):
18+
# global PLUGINS
19+
# if s not in PLUGINS:
20+
# PLUGINS.append(s())
21+
# def plugins():
22+
# return PLUGINS
2323

textbeat/plugins/sonicpi.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ class SonicPi(Instrument):
1212
NAME = 'sonicpi'
1313
def __init__(self):
1414
Instrument.__init__(self, SonicPi.NAME)
15-
self.enabled = False
15+
self.initalized = False
1616
def init(self):
17-
self.enabled = True
17+
self.initalized = True
1818
def inited(self):
19-
return self.enabled
19+
return self.initalized
2020
def supported(self):
2121
return not ERROR
2222
def support(self):
2323
return ['sonicpi']
2424
def stop(self):
2525
pass
2626

27-
instrument.export(SonicPi)
27+
# instrument.export(SonicPi)
28+
export = SonicPi
2829

textbeat/plugins/supercollider.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ class SuperCollider(Instrument):
1616
NAME = 'supercollider'
1717
def __init__(self):
1818
Instrument.__init__(self, SuperCollider.NAME)
19-
self.enabled = False
19+
self.initalized = False
2020
def init(self):
21-
self.enabled = True
21+
self.initalized = True
2222
def inited(self):
23-
return self.enabled
23+
return self.initalized
2424
def supported(self):
2525
return not ERROR
2626
def support(self):
2727
return ['supercollider']
2828
def stop(self):
2929
pass
3030

31-
instrument.export(SuperCollider)
31+
export = SuperCollider
3232

textbeat/support.py

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@
1313

1414
SUPPORT_PLUGINS = {}
1515

16-
# load new-style plugins from plugins dir
16+
# load plugins from plugins dir
17+
18+
import textbeat.plugins as tbp
1719
from textbeat.plugins import *
18-
# get plugins from instrument modules's export list
19-
plugs = instrument.plugins()
20+
# search module exports for plugins
21+
plugs = []
22+
for p in tbp.__dict__:
23+
try:
24+
pattr = getattr(tbp, p)
25+
plugs += [pattr.export()]
26+
except:
27+
pass
28+
# plugs = instrument.plugins()
2029
for plug in plugs:
2130
# plug.init()
2231
ps = plug.support()
@@ -29,6 +38,11 @@
2938
if 'auto' in s:
3039
AUTO = True
3140
auto_inited = True
41+
if 'soundfonts' in s:
42+
SOUNDFONTS = True
43+
44+
# Note: the plugins below are old-style (contained within this file). New style
45+
# plugins are in the plugins folder and are loaded above
3246

3347
SUPPORT_ALL.add('carla')
3448
if which('carla'):
@@ -43,17 +57,17 @@
4357
# except ImportError:
4458
# pass
4559

46-
try:
47-
SUPPORT_ALL.add('fluidsynth')
48-
if which('fluidsynth'):
49-
import fluidsynth # https://github.com/flipcoder/pyfluidsynth
50-
SUPPORT.add('fluidsynth')
51-
SUPPORT.add('soundfonts')
52-
SOUNDFONTS = True
53-
# except AttributeError:
54-
# error("pyFluidSynth AttributeError detected. Use this pyFluidSynth version: https://github.com/flipcoder/pyfluidsynth")
55-
except ImportError:
56-
pass
60+
# try:
61+
# SUPPORT_ALL.add('fluidsynth')
62+
# if which('fluidsynth'):
63+
# import fluidsynth # https://github.com/flipcoder/pyfluidsynth
64+
# SUPPORT.add('fluidsynth')
65+
# SUPPORT.add('soundfonts')
66+
# SOUNDFONTS = True
67+
# # except AttributeError:
68+
# # error("pyFluidSynth AttributeError detected. Use this pyFluidSynth version: https://github.com/flipcoder/pyfluidsynth")
69+
# except ImportError:
70+
# pass
5771

5872
csound = None
5973
# if which('csound'):
@@ -209,6 +223,7 @@ def supports(tech):
209223
return tech in SUPPORT
210224

211225
def support_stop():
226+
# stop old-style plugins
212227
global carla_temp_proj
213228
if carla_temp_proj:
214229
os.unlink(carla_temp_proj)
@@ -219,7 +234,8 @@ def support_stop():
219234
if BGPROC:
220235
BGPIPE.send((BGCMD.QUIT,))
221236
BGPROC.join()
222-
global plugs
237+
238+
# stop plugins from plugins folder
223239
for plug in plugs:
224240
if plug.inited():
225241
plug.stop()

0 commit comments

Comments
 (0)