diff options
author | Oli <olivier.belanger@umontreal.ca> | 2007-07-20 23:29:53 (GMT) |
---|---|---|
committer | Oli <olivier.belanger@umontreal.ca> | 2007-07-20 23:29:53 (GMT) |
commit | 88cd0106879984d484bdb711dfe2e1f9616beebf (patch) | |
tree | 27edef4ed7e363ddf427e6d9e1727d12ad7fadc7 /Util | |
parent | 6feac855a14b2843580296b6fa6c0d0a5f1975a0 (diff) |
loop settings
Diffstat (limited to 'Util')
-rw-r--r-- | Util/CSoundClient.py | 2 | ||||
-rw-r--r-- | Util/Instrument.py | 7 | ||||
-rw-r--r-- | Util/InstrumentPanel.py | 73 | ||||
-rw-r--r-- | Util/LoopSettings.py | 84 |
4 files changed, 96 insertions, 70 deletions
diff --git a/Util/CSoundClient.py b/Util/CSoundClient.py index c52cad1..0a10d21 100644 --- a/Util/CSoundClient.py +++ b/Util/CSoundClient.py @@ -81,7 +81,7 @@ class _CSoundClientPlugin: def load_instruments( self ): for instrumentSoundFile in Config.INSTRUMENTS.keys(): - if instrumentSoundFile[0:3] == 'mic' or instrumentSoundFile[0:3] == 'lab': + if instrumentSoundFile[0:3] == 'mic' or instrumentSoundFile[0:3] == 'lab' or Config.INSTRUMENTS[instrumentSoundFile].category == 'mysounds': fileName = Config.SNDS_DIR + '/' + instrumentSoundFile else: fileName = Config.SOUNDS_DIR + "/" + instrumentSoundFile diff --git a/Util/Instrument.py b/Util/Instrument.py index f3d835d..5bc74b3 100644 --- a/Util/Instrument.py +++ b/Util/Instrument.py @@ -187,9 +187,9 @@ if drum_load_dynamic: else: KIT = { 'drum1kit' : [ 'drum1kick', 'drum1floortom', 'drum1tom', - 'drum1chine', 'drum1splash', 'drum1crash', + 'drum1chine', 'drum1splash', 'drum1crash', 'drum1snaresidestick', 'drum1snaresidestick', 'drum1snare', - 'drum1ridebell', 'drum1hardride', 'drum1hatshoulder', + 'drum1ridebell', 'drum1hardride', 'drum1hatshoulder', 'drum1hatpedal'], 'drum2kit' : [ "drum2darbukadoom", "drum2darbukapied", "drum2darbukapiedsoft", "drum2hatflanger", "drum2darbukatak", "drum2darbukatak", @@ -343,7 +343,7 @@ if 0: for kitpath in kitpaths: kitidx = int( kitpath[4] ) print kitpath, kitidx - exec "DRUM%iKIT = {} ; curkit = DRUM%iKIT" % (kitidx,kitidx) + exec "DRUM%iKIT = {} ; curkit = DRUM%iKIT" % (kitidx,kitidx) name = kitpath[0:-4] kitfile = file('snd/'+ kitpath, 'r') line = kitfile.readline() @@ -390,4 +390,3 @@ if 0: "mic2" : 8, "mic3" : 9, "mic4" : 10 } - diff --git a/Util/InstrumentPanel.py b/Util/InstrumentPanel.py index 5a14a0c..a3a95fe 100644 --- a/Util/InstrumentPanel.py +++ b/Util/InstrumentPanel.py @@ -13,7 +13,7 @@ Tooltips = Config.Tooltips class InstrumentPanel( gtk.EventBox ): def __init__(self,setInstrument = None, playInstrument = None, enterMode = False, micRec = None, synthRec = None, rowLen = 8, _instDic = None, force_load = True ): gtk.EventBox.__init__(self) - + self.setInstrument = setInstrument self.playInstrument = playInstrument self.micRec = micRec @@ -29,12 +29,12 @@ class InstrumentPanel( gtk.EventBox ): if force_load: self.load() def configure( self, setInstrument = None, playInstrument = None, enterMode = False, micRec = None, synthRec = None, rowLen = 8 ): - + self.setInstrument = setInstrument self.playInstrument = playInstrument self.enterMode = enterMode self.micRec = micRec - + if self.rowLen != rowLen: self.rowLen = rowLen self.prepareInstrumentTable( self.category ) @@ -83,23 +83,23 @@ class InstrumentPanel( gtk.EventBox ): self.loadStage[0] = 5.1 else: self.loadStage[0] = 6 - + if self.loadStage[0] == 5.1: if not self.loadInstDic( self.instDic, timeout, self.loadStage ): return False self.loadStage[0] = 6 if timeout >= 0 and time.time() > timeout: return False - + if self.loadStage[0] == 6: self.loadInstrumentViewport() self.loadStage[0] = 7 if timeout >= 0 and time.time() > timeout: return False - + if self.loadStage[0] == 7: self.prepareInstrumentTable() self.loadStage[0] = 8 if timeout >= 0 and time.time() > timeout: return False - + self.add(self.mainVBox) self.show_all() @@ -107,7 +107,7 @@ class InstrumentPanel( gtk.EventBox ): return True def loadInstrumentList( self, timeout = -1, loadStage = [0,0,0] ): - + if loadStage[1] == 0: self.instrumentList = { "all": [], "all.enterMode": [], "percussions.enterMode": [], "lab": [], "mic": [], "kit": [] } for category in Config.CATEGORIES: @@ -143,11 +143,11 @@ class InstrumentPanel( gtk.EventBox ): self.instrumentList["all.enterMode"] += self.instrumentList["mic"] + self.instrumentList["lab"] self.instrumentList["percussions"] += self.instrumentList["kit"] self.instrumentList["people"] += self.instrumentList["mic"] - self.instrumentList["electronic"] += self.instrumentList["lab"] + self.instrumentList["keyboard"] += self.instrumentList["lab"] loadStage[1] = 0 return True - + def loadToolbar( self, timeout = -1, loadStage = [0,0,0] ): if loadStage[1] == 0: self.loadData["toolbarBox"] = gtk.HBox() @@ -177,7 +177,7 @@ class InstrumentPanel( gtk.EventBox ): loadStage[2] = 0 loadStage[1] += 1 if timeout >= 0 and time.time() > timeout: return False - + self.mainVBox.pack_start(self.loadData["toolbarBox"],False,False) self.loadData.pop("btn") @@ -194,7 +194,7 @@ class InstrumentPanel( gtk.EventBox ): loadStage[1] = 1 if timeout >= 0 and time.time() > timeout: return False - + for i in range( loadStage[1]-1, self.loadData["len"] ): instrument = self.instrumentList["all"][i] if loadStage[2] == 0: @@ -204,7 +204,10 @@ class InstrumentPanel( gtk.EventBox ): if timeout >= 0 and time.time() > timeout: return False if loadStage[2] == 1: - self.loadData["instButton"] = ImageRadioButton(self.firstInstButton, Config.IMAGE_ROOT + instrument + '.png' , Config.IMAGE_ROOT + instrument + 'sel.png', Config.IMAGE_ROOT + instrument + 'sel.png') + try: + self.loadData["instButton"] = ImageRadioButton(self.firstInstButton, Config.IMAGE_ROOT + instrument + '.png' , Config.IMAGE_ROOT + instrument + 'sel.png', Config.IMAGE_ROOT + instrument + 'sel.png') + except: + self.loadData["instButton"] = ImageRadioButton(self.firstInstButton, Config.IMAGE_ROOT + 'generic.png' , Config.IMAGE_ROOT + 'genericsel.png', Config.IMAGE_ROOT + 'genericsel.png') loadStage[2] = 2 if timeout >= 0 and time.time() > timeout: return False @@ -228,7 +231,7 @@ class InstrumentPanel( gtk.EventBox ): self.loadData.pop("len") loadStage[1] = 0 return True - + def loadInstrumentViewport( self ): self.instrumentBox = RoundHBox(fillcolor = Config.INSTRUMENT_GRID_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS) @@ -244,10 +247,10 @@ class InstrumentPanel( gtk.EventBox ): self.instrumentBox.pack_start(self.scrollWin,True,True,0) self.mainVBox.pack_start(self.instrumentBox) self.show_all() - + def prepareInstrumentTable(self,category = 'all'): - - self.category = category + + self.category = category if self.enterMode: if category == "all": category = "all.enterMode" @@ -261,14 +264,14 @@ class InstrumentPanel( gtk.EventBox ): instrumentNum = len(self.instrumentList[category]) instruments = self.instrumentList[category] - + cols = self.rowLen if instrumentNum < cols: cols = instrumentNum rows = (instrumentNum // cols) if instrumentNum % cols is not 0: #S'il y a un reste rows = rows + 1 - + self.instTable = gtk.Table(rows,cols,True) self.instTable.set_row_spacings(0) self.instTable.set_col_spacings(0) @@ -279,35 +282,35 @@ class InstrumentPanel( gtk.EventBox ): break instBox = self.instDic[instruments[row*cols+col]] self.instTable.attach(instBox, col, col+1, row, row+1, gtk.SHRINK, gtk.SHRINK, 0, 0) - + self.tableEventBox.add(self.instTable) self.instTable.show_all() - + def selectFirstCat(self): self.firstTbBtn.set_active(True) - + def handleToolbarBtnPress(self, widget, category): - if widget.get_active(): + if widget.get_active(): self.prepareInstrumentTable(category) def handleInstrumentButtonClick(self,widget,instrument): if widget.get_active() is True and self.recstate == False: - if self.setInstrument: + if self.setInstrument: widget.event( gtk.gdk.Event( gtk.gdk.LEAVE_NOTIFY ) ) # fake the leave event self.setInstrument(instrument) if self.playInstrument: self.playInstrument(instrument) if self.enterMode: pass #Close the window - + def handleInstrumentButtonEnter(self,widget,instrument): - if self.enterMode and self.playInstrument: + if self.enterMode and self.playInstrument: self.playInstrument(instrument) - + def handleMicRecButtonClick(self,widget,mic): self.recstate = False self.setInstrument(mic) if self.micRec: self.micRec(mic) - + def handleRecButtonPress(self,widget,btn): self.recstate = True btn.set_active(True) @@ -320,14 +323,14 @@ class InstrumentPanel( gtk.EventBox ): btn.handler_block(btn.clickedHandler) btn.set_active(state) btn.handler_unblock(btn.clickedHandler) - - + + class DrumPanel( gtk.EventBox ): def __init__(self, setDrum = None): gtk.EventBox.__init__(self) color = gtk.gdk.color_parse(Config.PANEL_BCK_COLOR) self.modify_bg(gtk.STATE_NORMAL, color) - + self.setDrum = setDrum self.instrumentList = [] keys = Config.INSTRUMENTS.keys() @@ -336,7 +339,7 @@ class DrumPanel( gtk.EventBox ): self.instrumentList.append( key ) self.instrumentList.sort() self.drawDrums() - + def drawDrums(self): firstBtn = None btnBox = RoundHBox(fillcolor = '#6F947B', bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS) @@ -353,10 +356,10 @@ class DrumPanel( gtk.EventBox ): btnBox.pack_start(instBox, False, False, 0) self.add(btnBox) self.show_all() - + def setDrums(self,widget,data): if widget.get_active(): - if self.setDrum: + if self.setDrum: widget.event( gtk.gdk.Event( gtk.gdk.LEAVE_NOTIFY ) ) # fake the leave event self.setDrum(data) @@ -367,7 +370,7 @@ class DrumPanel( gtk.EventBox ): btn.set_active(state) btn.handler_unblock(btn.clickedHandler) -if __name__ == "__main__": +if __name__ == "__main__": win = gtk.Window() wc = DrumPanel(None) win.add(wc) diff --git a/Util/LoopSettings.py b/Util/LoopSettings.py index ce92708..f90966e 100644 --- a/Util/LoopSettings.py +++ b/Util/LoopSettings.py @@ -21,22 +21,22 @@ class LoopSettings( gtk.VBox ): self.settingsBox = gtk.HBox() self.pack_start(self.settingsBox) - + self.fixed = gtk.Fixed() self.settingsBox.pack_start(self.fixed) - + self.mainBox = gtk.VBox() - + self.controlsBox = gtk.HBox() self.GUI = {} - + nameBox = gtk.VBox() self.nameEntry = gtk.Entry() self.nameEntry.set_text("name_of_the_sound") nameBox.pack_start(self.nameEntry) self.mainBox.pack_start(nameBox, False, False, 5) - + loopedBox = gtk.HBox() loopedLabel = gtk.Label("Looped sound: ") loopedBox.pack_start(loopedLabel) @@ -44,8 +44,8 @@ class LoopSettings( gtk.VBox ): loopedToggle.connect('button-press-event', self.handleLooped ) loopedBox.pack_start(loopedToggle) self.mainBox.pack_start(loopedBox, False, False, 5) - - categoryBox = gtk.HBox() + + categoryBox = gtk.HBox() categoryMenu = gtk.MenuBar() cmenu = gtk.Menu() for cat in Config.CATEGORIES: @@ -58,8 +58,8 @@ class LoopSettings( gtk.VBox ): self.categoryButton.connect_object("event", self.categoryBtnPress, cmenu) categoryBox.pack_end(self.categoryButton) self.mainBox.pack_start(categoryBox, False, False, 5) - - registerBox = gtk.HBox() + + registerBox = gtk.HBox() registerMenu = gtk.MenuBar() rmenu = gtk.Menu() self.registerList = ['LOW', 'MID', 'HIGH', 'PUNCH'] @@ -71,8 +71,8 @@ class LoopSettings( gtk.VBox ): self.registerButton = gtk.Button("Register") self.registerButton.connect_object("event", self.registerBtnPress, rmenu) registerBox.pack_end(self.registerButton) - self.mainBox.pack_start(registerBox, False, False, 5) - + self.mainBox.pack_start(registerBox, False, False, 5) + startBox = gtk.VBox() self.startAdjust = gtk.Adjustment( 0.01, 0, 1., .001, .001, 0) self.GUI['startSlider'] = ImageVScale( Config.TAM_TAM_ROOT + "/Resources/Images/sliderEditVolume.png", self.startAdjust, 7 ) @@ -81,11 +81,11 @@ class LoopSettings( gtk.VBox ): self.GUI['startSlider'].set_size_request(50, 200) self.startEntry = gtk.Entry() self.startEntry.set_width_chars(5) - self.handleStart( self.startAdjust ) + self.handleStart( self.startAdjust ) startBox.pack_start(self.GUI['startSlider'], True, True, 5) startBox.pack_start(self.startEntry, True, True, 5) self.controlsBox.pack_start(startBox) - + endBox = gtk.VBox() self.endAdjust = gtk.Adjustment( 0.9, 0, 1, .001, .001, 0) self.GUI['endSlider'] = ImageVScale( Config.TAM_TAM_ROOT + "/Resources/Images/sliderEditVolume.png", self.endAdjust, 7 ) @@ -97,7 +97,7 @@ class LoopSettings( gtk.VBox ): self.handleEnd( self.endAdjust ) endBox.pack_start(self.GUI['endSlider'], True, True, 5) endBox.pack_start(self.endEntry, True, True, 5) - self.controlsBox.pack_start(endBox) + self.controlsBox.pack_start(endBox) durBox = gtk.VBox() self.durAdjust = gtk.Adjustment( 0.01, 0, 0.2, .001, .001, 0) @@ -111,59 +111,83 @@ class LoopSettings( gtk.VBox ): durBox.pack_start(self.GUI['durSlider'], True, True, 5) durBox.pack_start(self.durEntry, True, True, 5) self.controlsBox.pack_start(durBox) - + self.mainBox.pack_start(self.controlsBox, False, False, 5) - + previewBox = gtk.VBox() self.playStopButton = ImageToggleButton(Config.IMAGE_ROOT + 'miniplay.png', Config.IMAGE_ROOT + 'stop.png') self.playStopButton.connect('button-press-event' , self.handlePlayButton) previewBox.pack_start(self.playStopButton) self.mainBox.pack_start(previewBox, False, False, 5) - + + checkBox = gtk.VBox() + checkButton = ImageButton(Config.IMAGE_ROOT + 'check.png') + checkButton.connect('clicked' , self.handleCheck) + checkBox.pack_start(checkButton) + self.mainBox.pack_start(checkBox, False, False, 5) + self.fixed.put( self.mainBox, 0, 0 ) - + self.show_all() - + + def handleCheck(self, widget): + ofile = open(Config.PREF_DIR + "/sounds_settings", 'a') + name = self.nameEntry.get_text() + if self.loopedSound: + tied = str(Config.INST_TIED) + else: + tied = str(Config.INST_SIMP) + register = str(self.register) + melo = 'melo' + category = 'mysounds' + start = str(self.start) + end = str(self.end) + dur = str(self.dur) + + ofile.write(name + ' ' + tied + ' ' + register + ' ' + melo + ' ' + category + ' ' + start + ' ' + end + ' ' + dur + '\n') + + ofile.close() + def set_values(self, name, soundLength): self.nameEntry.set_text(name) self.soundLength = soundLength self.handleStart(self.GUI['startSlider']) self.handleEnd(self.GUI['endSlider']) - + def handleLooped(self, widget, data=None): if widget.get_active() == True: self.loopedSound = False else: self.loopedSound = True - + def categoryBtnPress(self, widget, event): if event.type == gtk.gdk.BUTTON_PRESS: widget.popup(None, None, None, event.button, event.time) return True return False - + def handleCategory(self, widget, category): self.category = category self.categoryButton.set_label(self.category) - + def registerBtnPress(self, widget, event): if event.type == gtk.gdk.BUTTON_PRESS: widget.popup(None, None, None, event.button, event.time) return True - return False + return False def handleRegister(self, widget, register): self.register = register self.registerButton.set_label(self.registerList[self.register]) - + def handleStart(self, widget, data=None): self.startSlider = self.startAdjust.value self.start = self.startSlider * self.soundLength if self.start > self.end: - self.start = self.end + self.start = self.end self.startEntry.set_text(str(self.start)) self.setChannel('lstart', self.start) - + def handleEnd(self, widget, data=None): self.endSlider = self.endAdjust.value self.end = self.endSlider * self.soundLength @@ -171,17 +195,17 @@ class LoopSettings( gtk.VBox ): self.end = self.start self.endEntry.set_text(str(self.end)) self.setChannel('lend', self.end) - + def handleDur(self, widget, data=None): self.dur = self.durAdjust.value self.durEntry.set_text(str(self.dur)) self.setChannel('ldur', self.dur) - + def handlePlayButton(self, widget, data=None): self.playFunction(widget.get_active(), self.loopedSound) if self.loopedSound == False and widget.get_active() == False: self.timeoutStop = gobject.timeout_add(int(self.soundLength * 1000), self.playButtonState) - + def playButtonState(self): # something's weird here self.playStopButton.set_active(True) |