From 53210daa96f6b7e51299a2eb15532cb296fab25d Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Fri, 19 Dec 2008 15:37:01 +0000 Subject: update lab&mic files on the fly --- (limited to 'common') diff --git a/common/Util/CSoundClient.py b/common/Util/CSoundClient.py index 1fee0cb..44f61c5 100644 --- a/common/Util/CSoundClient.py +++ b/common/Util/CSoundClient.py @@ -319,6 +319,17 @@ class _CSoundClientPlugin: rval=storage instrument = self.instrumentDB.instId[instrumentId] + + if instrument.volatile != None: + sound = os.path.join(Config.DATA_DIR, instrument.name) + if os.path.isfile(sound): + st_mtime = os.stat(sound).st_mtime + if st_mtime != instrument.volatile: + instrument.volatile = st_mtime + loadedInstruments.remove(instrument.name) + self.load_instrument(instrument.name) + time.sleep(0.2) + if instrument.kit != None: instrument = self.instrumentDB.instNamed[instrument.kit[pitch]] pitch = 1 diff --git a/common/Util/InstrumentDB.py b/common/Util/InstrumentDB.py index 68928a5..0958989 100644 --- a/common/Util/InstrumentDB.py +++ b/common/Util/InstrumentDB.py @@ -9,6 +9,7 @@ class Instrument: def __init__(self, id): self.instrumentId = id self.kitStage = False + self.volatile = None # build an Instrument instance from argument list def loadFromArgs( self, name, csoundInstrumentId, register, loopStart, @@ -55,11 +56,13 @@ class InstrumentDB: # TEMP? add instrument from args def addInstrumentFromArgs( self, name, csoundInstrumentId, register, loopStart, - loopEnd, crossDur, ampScale, kit, wav, img, category, kitStage = False ): + loopEnd, crossDur, ampScale, kit, wav, img, category, + kitStage = False, volatile = False ): i = Instrument(len(self.inst)) self.inst += [ i ] i.loadFromArgs( name, csoundInstrumentId, register, loopStart, loopEnd, crossDur, ampScale, kit, wav, img, category ) i.kitStage = kitStage + if volatile: i.volatile = 0 self.instNamed[ i.name ] = i self.instId[i.instrumentId] = i diff --git a/common/Util/Instruments.py b/common/Util/Instruments.py index b4aa318..f616811 100644 --- a/common/Util/Instruments.py +++ b/common/Util/Instruments.py @@ -17,22 +17,22 @@ INST_PERC = Config.INST_PERC instrumentDB = InstrumentDB.getRef() -def _addInstrument( name, csoundInstrumentId, instrumentRegister, category, loopStart, loopEnd, crossDur, ampScale = 1, kit = None, kitStage = False ): - instrumentDB.addInstrumentFromArgs( name, csoundInstrumentId, instrumentRegister, loopStart, loopEnd, crossDur, ampScale, kit, name, Config.IMAGE_ROOT+"/"+name+".png", category, kitStage = kitStage ) +def _addInstrument( name, csoundInstrumentId, instrumentRegister, category, loopStart, loopEnd, crossDur, ampScale = 1, kit = None, kitStage = False, volatile = False ): + instrumentDB.addInstrumentFromArgs( name, csoundInstrumentId, instrumentRegister, loopStart, loopEnd, crossDur, ampScale, kit, name, Config.IMAGE_ROOT+"/"+name+".png", category, kitStage = kitStage, volatile = volatile ) if Config.MIC: - _addInstrument( "mic1", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 ) - _addInstrument( "mic2", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 ) - _addInstrument( "mic3", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 ) - _addInstrument( "mic4", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 ) + _addInstrument( "mic1", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1, volatile = True ) + _addInstrument( "mic2", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1, volatile = True ) + _addInstrument( "mic3", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1, volatile = True ) + _addInstrument( "mic4", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1, volatile = True ) if not Config.XO: - _addInstrument( "lab1", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 ) - _addInstrument( "lab2", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 ) - _addInstrument( "lab3", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 ) - _addInstrument( "lab4", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 ) - _addInstrument( "lab5", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 ) - _addInstrument( "lab6", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 ) + _addInstrument( "lab1", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1, volatile = True ) + _addInstrument( "lab2", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1, volatile = True ) + _addInstrument( "lab3", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1, volatile = True ) + _addInstrument( "lab4", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1, volatile = True ) + _addInstrument( "lab5", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1, volatile = True ) + _addInstrument( "lab6", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1, volatile = True ) _addInstrument( "ounk", INST_SIMP, MID, 'animals', 0, 0, 0, 1 ) _addInstrument( "gam", INST_TIED, HIGH, 'percussions', .69388, .7536, .02922, 1.4 ) -- cgit v0.9.1