diff options
author | jaberg <james@localhost.localdomain> | 2006-12-15 09:38:28 (GMT) |
---|---|---|
committer | jaberg <james@localhost.localdomain> | 2006-12-15 09:38:28 (GMT) |
commit | b0846402a71b135cec9b91756025a03f487634ef (patch) | |
tree | a0d373882064b2daa061006665c1e7aa7e778e31 /TamTam.py | |
parent | 968cd5474b658ac8a58564960f8a4908bc725073 (diff) |
opts
Diffstat (limited to 'TamTam.py')
-rwxr-xr-x | TamTam.py | 75 |
1 files changed, 39 insertions, 36 deletions
@@ -1,27 +1,38 @@ +import signal +import time +import sys import pygtk pygtk.require( '2.0' ) import gtk - +import Framework.CSound.CSoundClient as CSoundClient from Framework.Constants import Constants from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.CSound.CSoundClient import CSoundClient from Framework.CSound.CSoundServer import CsoundServerMult -import os -import sys -import signal -import time from GUI.StandalonePlayer import StandAlonePlayer from GUI.Core.MainWindow import MainWindow from Framework.Core.Profiler import TP + +if False: + csnd = CSoundClient.CSoundClientSocket( CSoundConstants.SERVER_ADDRESS, CSoundConstants.SERVER_PORT, os.getpid() ) +elif False: + csnd = CSoundClient.CSoundClientPerf( '/usr/share/olpc-csound-server/univorc.csd' ) +else: + csnd = CSoundClient.CSoundClientPerf( Constants.TAM_TAM_ROOT + '/Resources/univorc.csd' ) + + +csnd.initialize(True) +csnd.setMasterVolume(100.0) +CSoundClient.CSoundClient = csnd + + + if __name__ == "__main__": def run_sugar_mode(): - CSoundClient.initialize(True) - CSoundClient.setMasterVolume(100) - tamtam = StandAlonePlayer() + tamtam = StandAlonePlayer(csnd) #tamtam = gtk.Button("adsf") mainwin = gtk.Window(gtk.WINDOW_TOPLEVEL) mainwin.set_size_request(1200,600) @@ -34,20 +45,9 @@ if __name__ == "__main__": tamtam.show() mainwin.show() gtk.main() - CSoundClient.initialize(False) - sys.exit(0) def run_edit_mode(): - TP.Profile("TT::init") - TP.Profile("TT::init::csound") - CSoundClient.initialize(True) - CSoundClient.setMasterVolume(100) - TP.Profile("TT::init::csound") - TP.Profile("TT::init::mainwin") - TP.Profile("TT::init::mainwin::init") - tamtam = MainWindow() - TP.Profile("TT::init::mainwin::init") - TP.Profile("TT::init::mainwin::connect") + tamtam = MainWindow(csnd) mainwin = gtk.Window(gtk.WINDOW_TOPLEVEL) mainwin.set_title('TamTam Player') mainwin.set_resizable(False) @@ -58,24 +58,26 @@ if __name__ == "__main__": mainwin.connect( "delete_event", tamtam.delete_event ) mainwin.set_border_width(10) mainwin.set_geometry_hints( None, 855, Constants.NUMBER_OF_TRACKS * 50 + 200, 900, Constants.NUMBER_OF_TRACKS * 300 + 200 ) - TP.Profile("TT::init::mainwin::connect") - TP.Profile("TT::init::mainwin::add") mainwin.add(tamtam) - TP.Profile("TT::init::mainwin::add") - TP.Profile("TT::init::mainwin") - TP.Profile("TT::init::show") tamtam.show() mainwin.show() - TP.Profile("TT::init::show") - TP.Profile("TT::init") gtk.main() - CSoundClient.initialize(False) - sys.exit(0) if len(sys.argv) > 1 and sys.argv[1] == 'edit': - run_edit_mode() + if False: + import hotshot + prof = hotshot.Profile("some_stats") + prof.runcall(run_edit_mode) + prof.close() + else: + run_edit_mode() + csnd.initialize(False) + print 'GOT BACK FROM UNINIT' + sys.exit(0) else: run_sugar_mode() + sys.exit(0) + from sugar.activity.Activity import Activity class TamTam(Activity): @@ -83,7 +85,7 @@ class TamTam(Activity): Activity.__init__(self) - self.tamtam = StandAlonePlayer() + self.tamtam = StandAlonePlayer(csnd) self.connect('focus_in_event',self.handleFocusIn) self.connect('focus_out_event',self.handleFocusOut) self.connect('destroy', self.do_quit) @@ -95,12 +97,13 @@ class TamTam(Activity): self.connect( "key-release-event", self.tamtam.keyboardStandAlone.onKeyRelease ) def handleFocusIn(self, event, data=None): - CSoundClient.initialize(True) - CSoundClient.setMasterVolume(100) + csnd.initialize(True) + csnd.setMasterVolume(100) def handleFocusOut(self, event, data=None): - CSoundClient.initialize(False) + csnd.initialize(False) def do_quit(self, arg2): - CSoundClient.initialize(False) + csnd.initialize(False) del self.tamtam + |