diff options
author | James <olpc@localhost.localdomain> | 2007-01-28 08:58:53 (GMT) |
---|---|---|
committer | James <olpc@localhost.localdomain> | 2007-01-28 08:58:53 (GMT) |
commit | e1aa8419a4d53e55411777e33a66f8fc173f1a2c (patch) | |
tree | 5a6793293281ac8e55eb2c37b9f5896400e5d150 /TamTam.py | |
parent | 9df98de3db07f52166d53290eccad6b55bb89454 (diff) |
CSoundClientPlugin v1
Diffstat (limited to 'TamTam.py')
-rwxr-xr-x | TamTam.py | 60 |
1 files changed, 12 insertions, 48 deletions
@@ -15,30 +15,12 @@ from Util.Clooper.SClient import * #csnd = CSoundClient.CSoundClientSocket( Config.SERVER_ADDRESS, Config.SERVER_PORT, os.getpid() ) #csnd = CSoundClient.CSoundClientPerf( '/usr/share/olpc-csound-server/univorc.csd' ) +#csnd = CSoundClient.CSoundClientPerf( Config.TAM_TAM_ROOT + '/Resources/univorc.csd' ) +csnd = CSoundClient.CSoundClientPlugin( Config.TAM_TAM_ROOT + '/Resources/univorc.csd' ) -def load_instruments( ): - home_path = env.get_profile_path() + Config.PREF_DIR - for instrumentSoundFile in Config.INSTRUMENTS.keys(): - if instrumentSoundFile[0:3] == 'mic' or instrumentSoundFile[0:3] == 'lab': - fileName = home_path + '/' + instrumentSoundFile - else: - fileName = Config.SOUNDS_DIR + "/" + instrumentSoundFile - instrumentId = Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[ instrumentSoundFile ].instrumentId - sc_instrumentLoad(instrumentId, fileName) - -USE_CSND = True - -if USE_CSND: - csnd = CSoundClient.CSoundClientPerf( Config.TAM_TAM_ROOT + '/Resources/univorc.csd' ) - csnd.initialize(True) - csnd.setMasterVolume(100.0) - CSoundClient.CSoundClient = csnd #Dodgy move: TODO: remove this global variable. -else: - sc_initialize( Config.TAM_TAM_ROOT + '/Resources/univorc.csd' ) - sc_setMasterVolume(50.0) - load_instruments() - time.sleep(0.2) - csnd = None +csnd.connect(True) +csnd.setMasterVolume(100.0) +CSoundClient.CSoundClient = csnd #Dodgy move: TODO: remove this global variable. if __name__ == "__main__": def run_sugar_mode(): @@ -82,18 +64,12 @@ if __name__ == "__main__": prof.close() else: run_edit_mode() - if USE_CSND: - csnd.initialize(False) - else: - sc_destroy() - sys.exit(0) else: run_sugar_mode() - if USE_CSND: - csnd.initialize(False) - else: - sc_destroy() - sys.exit(0) + + csnd.connect(False) + csnd.destroy() + sys.exit(0) from sugar.activity.Activity import Activity from sugar import env @@ -125,28 +101,16 @@ class TamTam(Activity): self.connect( "key-release-event", self.tamtam.keyboardStandAlone.onKeyRelease ) def handleFocusIn(self, event, data=None): - if USE_CSND: - csnd.initialize(True) - csnd.setMasterVolume(100) - self.tamtam.csnd.startTime() - self.tamtam.noteLooper.startTime() - else: - sc_something() + csnd.connect(True) def handleFocusOut(self, event, data=None): if self.tamtam.synthLabWindowOpen(): return - if USE_CSND: - csnd.initialize(False) - else: - sc_destroy() + csnd.connect(False) def do_quit(self, arg2): home_path = env.get_profile_path() + Config.PREF_DIR os.system('rm ' + home_path + '/synthTemp*') - if USE_CSND: - csnd.initialize(False) - else: - sc_destroy() + csnd.destroy(False) del self.tamtam |