Skip to content

Commit

Permalink
Expose open and close commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
rec committed Dec 28, 2014
1 parent f04dbb4 commit b1b9fdd
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
8 changes: 6 additions & 2 deletions code/cpp/echomesh/component/LightingWindow.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cdef extern from "echomesh/component/LightingWindow.h" namespace "echomesh":
InstrumentGrid* grid()
void saveSnapshotToFile(string)
void setLights(FColorList)
void setVisible(bool)

LightingWindow* makeLightingWindow() nogil
void deleteLightingWindow(LightingWindow*) nogil
Expand All @@ -20,9 +21,12 @@ cdef class PyLightingWindow:
self.thisptr = makeLightingWindow()

def __dealloc__(self):
self.close()
self.dealloc()

def close(self):
def set_visible(self, bool visible):
self.thisptr.setVisible(visible)

def dealloc(self):
deleteLightingWindow(self.thisptr)
self.thisptr = NULL

Expand Down
2 changes: 1 addition & 1 deletion code/cpp/echomesh/util/EchomeshApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ApplicationBase : public juce::JUCEApplicationBase {
virtual bool moreThanOneInstanceAllowed() { return false; }
virtual void initialise(const String&) {
if (CALLBACK and USER_DATA)
CALLBACK(USER_DATA, "start");
CALLBACK(USER_DATA, "{\"event\":\"start\"}");
}
virtual void shutdown() {}
virtual void anotherInstanceStarted(const String&) {}
Expand Down
8 changes: 5 additions & 3 deletions code/python/echomesh/Instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from echomesh.Cechomesh import cechomesh
from echomesh.base import Settings
from echomesh.base import Quit
from echomesh.base import Yaml
from echomesh.element import ScoreMaster
from echomesh.expression import Expression
from echomesh.graphics import Display
Expand Down Expand Up @@ -44,7 +45,6 @@ def do_quit():
self.score_master = ScoreMaster.ScoreMaster()
self.peers = Peers.Peers(self)
self.socket = PeerSocket.PeerSocket(self, self.peers)
# self.callback = self.after_server_starts

self.display = Display.display(self.callback)
self.keyboard_runnable = self.osc = None
Expand Down Expand Up @@ -98,10 +98,12 @@ def main(self):
# Prevents crashes if you start and stop echomesh very fast.

def callback(self, data):
if data == 'start':
data = Yaml.decode_one(data)
event = data['event']
if event == 'start':
self.after_server_starts()
else:
#print(data)
print(data)
pass

def after_server_starts(self):
Expand Down
7 changes: 1 addition & 6 deletions code/python/echomesh/element/Snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,9 @@ def __init__(self, parent, description):

def _on_run(self):
super(Snapshot, self)._on_run()

if not Visualizer.INSTANCE:
LOGGER.error('No Visualizer.INSTANCE')
return

self.pause()
self.index += 1
Visualizer.INSTANCE.snapshot(self.get_file(self.index))
Visualizer.instance().snapshot(self.get_file(self.index))

def get_file(self, index):
if self.use_index:
Expand Down
4 changes: 2 additions & 2 deletions code/python/echomesh/output/OutputCache.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
LOGGER = Log.logger(__name__)

def default_output():
from echomesh.output.Visualizer import Visualizer
return Visualizer()
from echomesh.output import Visualizer
return Visualizer.instance()

class _SingleOutput(object):
def __init__(self, name, data, output_cache):
Expand Down
14 changes: 11 additions & 3 deletions code/python/echomesh/output/Visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def __init__(self, **values):
self.values.add_client()

def _close_window(self):
if self.lighting_window:
self.lighting_window.close()
self.lighting_window = None
self.lighting_window = None

def pause(self):
super(Visualizer, self).pause()
Expand Down Expand Up @@ -99,3 +97,13 @@ def emit_output(self, data):

lights.scale(self.brightness)
self.lighting_window.set_lights(lights)

def instance():
if not Visualizer.INSTANCE:
Visualizer()
return Visualizer.INSTANCE

def close():
if Visualizer.INSTANCE:
Visualizer.INSTANCE.close();
Visualizer.INSTANCE = None

0 comments on commit b1b9fdd

Please sign in to comment.