diff options
24 files changed, 202 insertions, 167 deletions
@@ -47,6 +47,9 @@ PLUGIN_VERBOSE = 0 PLUGIN_UNIVORC = TAM_TAM_ROOT + "/Resources/univorc.csd" PLUGIN_KSMPS = 64 PLUGIN_RATE = 16000 +#PLUGIN_KSMPS = 64 +#PLUGIN_RATE = 22050 + ## PLUGIN ALSA PARAMETERS: ## for macbook pro @@ -92,7 +95,7 @@ INST_TIED = 5001 INST_SIMP = 5011 INST_PERC = 5021 -CATEGORIES = ['all','animals','concret','electronic','keyboard','people','percussions','strings','winds'] +CATEGORIES = ['all','animals','concret','keyboard','people','percussions','strings','winds', 'mysounds'] _nextInstrumentId = [0] INSTRUMENTS = {} @@ -101,6 +104,7 @@ def _addInstrument( name, csoundInstrumentId, instrumentRegister, soundClass, ca INSTRUMENTS[name] = Instrument( name, _nextInstrumentId[0], csoundInstrumentId, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur, kit ) _nextInstrumentId[0] += 1 + _addInstrument( "mic1", INST_TIED, MID, 'melo', 'mic', .01, 1.99, .01 ) _addInstrument( "mic2", INST_TIED, MID, 'melo', 'mic', .01, 1.99, .01 ) _addInstrument( "mic3", INST_TIED, MID, 'melo', 'mic', .01, 1.99, .01 ) @@ -167,14 +171,14 @@ _addInstrument( "clang", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ) _addInstrument( "ow", INST_SIMP, MID, 'melo', 'people', 0, 0, 0 ) _addInstrument( "sheep", INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 ) _addInstrument( "water", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ) -_addInstrument( "zap", INST_TIED, MID, 'melo', 'electronic', .299, .7323, .09895 ) +_addInstrument( "zap", INST_TIED, MID, 'melo', 'keyboard', .299, .7323, .09895 ) _addInstrument( "trumpet", INST_TIED, MID, 'melo', 'winds', .39934, .45537, .02729) _addInstrument( "bubbles", INST_TIED, MID, "melo", 'concret', 0.02, 1.177, 0.02) _addInstrument( "marimba", INST_TIED, MID, "melo", 'percussions', .26545, .33098, .03087) _addInstrument( "triangle", INST_TIED, MID, "melo", 'percussions', 1.21002, 1.31805, .01268) _addInstrument( "laugh", INST_SIMP, MID, 'melo', 'people', 0, 0, 0 ) _addInstrument( "voix", INST_TIED, MID, 'melo', 'people', .89608, .96092, .02343 ) -_addInstrument( "cling", INST_TIED, MID, 'melo', 'electronic', .09096, .7878, .18026 ) +_addInstrument( "cling", INST_TIED, MID, 'melo', 'keyboard', .09096, .7878, .18026 ) _addInstrument( "byke", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ) _addInstrument( "door", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ) _addInstrument( "basse", INST_TIED, MID, 'melo', 'strings', .58455, .67433, .03638 ) @@ -236,6 +240,15 @@ _addInstrument( "guit2", INST_TIED, MID, 'melo', 'strings', .33, 1.1583, .02 ) _addInstrument( "plane", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ) _addInstrument( "slap", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ) +try: + ifile = open(PREF_DIR + '/sounds_settings', 'r') + for line in ifile.readlines(): + list = line.split() + _addInstrument(list[0], int(list[1]), int(list[2]), list[3], list[4], float(list[5]), float(list[6]), float(list[7])) +except: + pass + + DRUM1KIT = { 24 : INSTRUMENTS["drum1kick"], 26 : INSTRUMENTS["drum1floortom"], 28 : INSTRUMENTS["drum1tom"], diff --git a/Resources/Images/generic.png b/Resources/Images/generic.png Binary files differnew file mode 100755 index 0000000..c42119b --- /dev/null +++ b/Resources/Images/generic.png diff --git a/Resources/Images/genericsel.png b/Resources/Images/genericsel.png Binary files differnew file mode 100755 index 0000000..2cbdb81 --- /dev/null +++ b/Resources/Images/genericsel.png diff --git a/Resources/Images/helpShow1.jpg b/Resources/Images/helpShow1.jpg Binary files differindex 620b5f7..f452054 100755 --- a/Resources/Images/helpShow1.jpg +++ b/Resources/Images/helpShow1.jpg diff --git a/Resources/Images/helpShow2.jpg b/Resources/Images/helpShow2.jpg Binary files differindex 5fed924..8f4cdd2 100755 --- a/Resources/Images/helpShow2.jpg +++ b/Resources/Images/helpShow2.jpg diff --git a/Resources/Images/helpShow3.jpg b/Resources/Images/helpShow3.jpg Binary files differindex 9a31d68..9fee5f8 100755 --- a/Resources/Images/helpShow3.jpg +++ b/Resources/Images/helpShow3.jpg diff --git a/Resources/Images/helpShow4.jpg b/Resources/Images/helpShow4.jpg Binary files differindex f73ea8a..8c0177f 100755 --- a/Resources/Images/helpShow4.jpg +++ b/Resources/Images/helpShow4.jpg diff --git a/Resources/Images/helpShow5.jpg b/Resources/Images/helpShow5.jpg Binary files differindex 05c788b..e18acd4 100755 --- a/Resources/Images/helpShow5.jpg +++ b/Resources/Images/helpShow5.jpg diff --git a/Resources/Images/helpShow6.jpg b/Resources/Images/helpShow6.jpg Binary files differindex ad824b7..9df826c 100755 --- a/Resources/Images/helpShow6.jpg +++ b/Resources/Images/helpShow6.jpg diff --git a/Resources/Images/helpShow7.jpg b/Resources/Images/helpShow7.jpg Binary files differindex 57d52b0..b27573e 100755 --- a/Resources/Images/helpShow7.jpg +++ b/Resources/Images/helpShow7.jpg diff --git a/Resources/Images/helpShow8.jpg b/Resources/Images/helpShow8.jpg Binary files differindex d2f9a0e..93b9671 100755 --- a/Resources/Images/helpShow8.jpg +++ b/Resources/Images/helpShow8.jpg diff --git a/Resources/Images/helpShow9.jpg b/Resources/Images/helpShow9.jpg Binary files differindex 4ee5467..9258cb8 100755 --- a/Resources/Images/helpShow9.jpg +++ b/Resources/Images/helpShow9.jpg diff --git a/Resources/Images/mysounds.png b/Resources/Images/mysounds.png Binary files differnew file mode 100644 index 0000000..37a7e6f --- /dev/null +++ b/Resources/Images/mysounds.png diff --git a/Resources/Images/mysoundssel.png b/Resources/Images/mysoundssel.png Binary files differnew file mode 100644 index 0000000..bd6fceb --- /dev/null +++ b/Resources/Images/mysoundssel.png 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/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/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/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) @@ -7,7 +7,7 @@ import os, signal,math import Config from Util.ThemeWidgets import * -from sugar.graphics.toolbutton import ToolButton +from sugar.graphics.toggletoolbutton import ToggleToolButton from Util.CSoundClient import new_csound_client from Util import ControlStream @@ -26,11 +26,11 @@ class Welcome(SubActivity): self.tooltips = gtk.Tooltips() self.activity = activity - self.activity.activity_toolbar.helpButton = ToolButton('tam-help') + self.helpButton = self.activity.activity_toolbar.helpButton = ToggleToolButton('tam-help') self.activity.activity_toolbar.insert(self.activity.activity_toolbar.helpButton,2) self.activity.activity_toolbar.helpButton.show() self.activity.activity_toolbar.helpButton.set_tooltip(_('Help')) - self.activity.activity_toolbar.helpButton.connect("clicked", self.handleHelp, None) + self.activity.activity_toolbar.helpButton.connect("toggled", self.handleHelp) actVBox = RoundVBox(fillcolor = Config.WS_BCK_COLOR, bordercolor = Config.WS_BCK_COLOR, radius = Config.PANEL_RADIUS) @@ -73,6 +73,15 @@ class Welcome(SubActivity): actVBox.pack_start(title,False,False) #actVBox.pack_start(buttonBox, False, False, 100) self.add(actVBox) + + self.helpWindow = gtk.Window(gtk.WINDOW_POPUP) + self.helpWindow.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#FFF")) + self.helpWindow.move( 0, 75 ) + self.helpWindow.resize( 1200, 825 ) + self.helpWindow.set_modal(True) + self.helpWindow.add_events( gtk.gdk.BUTTON_PRESS_MASK ) + self.helpWindow.connect("button-release-event", lambda w,e: self.helpButton.set_active(False)) + self.show_all() def handleLoad(self, widget, data=None): @@ -146,43 +155,35 @@ class Welcome(SubActivity): self.csnd.loopSetTick( 0 ) self.csnd.loopStart() - def handleHelp(self, widget, data ): - self.helpWindow = gtk.Window(gtk.WINDOW_POPUP) - self.helpWindow.move( 100, 75 ) - self.helpWindow.resize( 1000, 800 ) - self.helpWindow.set_modal(True) - self.helpWindow.add_events( gtk.gdk.BUTTON_PRESS_MASK ) - self.helpWindow.connect("button-release-event", lambda - w,e:self.helpWindow.hide() ) - - helpImg = gtk.Image() - - self.imglist = [ i for i in os.listdir(Config.IMAGE_ROOT) - if i[0:8] == 'helpShow'] - self.imglist.sort() - self.imgpos = 0 - def next(e,w,self): - imglist = self.imglist - imgpos = self.imgpos - self.imgpos = ( imgpos + 1 ) % len(imglist) - print 'loading file %s' % Config.IMAGE_ROOT + imglist[self.imgpos] - helpImg.set_from_file( Config.IMAGE_ROOT + imglist[self.imgpos]) - return True - def prev(e,w,self): - imglist = self.imglist - imgpos = self.imgpos - self.imgpos = ( imgpos - 1 + len(imglist)) % len(imglist) - helpImg.set_from_file( Config.IMAGE_ROOT + imglist[self.imgpos]) - return True - helpImg.set_from_file(Config.IMAGE_ROOT + self.imglist[self.imgpos]) - - hbox = gtk.HBox() - jj = gtk.EventBox() - jj.add(helpImg) - jj.connect("button-release-event", next, self) - hbox.pack_start( jj ) - self.helpWindow.add( hbox ) - self.helpWindow.show_all() + def handleHelp(self, widget): + if widget.get_active(): + helpImg = gtk.Image() + + self.imglist = [ i for i in os.listdir(Config.IMAGE_ROOT) + if i[0:8] == 'helpShow'] + self.imglist.sort() + self.imgpos = 0 + def release(w,e,self): + imglist = self.imglist + imgpos = self.imgpos + if e.button == 1: + self.imgpos = ( imgpos + 1 ) % len(imglist) + else: + self.imgpos = ( imgpos - 1 + len(imglist)) % len(imglist) + helpImg.set_from_file( Config.IMAGE_ROOT + imglist[self.imgpos]) + return True + helpImg.set_from_file(Config.IMAGE_ROOT + self.imglist[self.imgpos]) + + hbox = gtk.HBox() + jj = gtk.EventBox() + jj.add(helpImg) + jj.connect("button-release-event", release, self) + hbox.pack_start( jj, True, False ) + self.helpWindow.add( hbox ) + self.helpWindow.show_all() + else: + self.helpWindow.hide() + self.helpWindow.remove( self.helpWindow.get_children()[0] ) def onActivityBtnClicked(self, widget, data): widget.event( gtk.gdk.Event( gtk.gdk.LEAVE_NOTIFY ) ) # fake the leave event diff --git a/miniTamTam/GenRythm.py b/miniTamTam/GenRythm.py index a9d8f70..d0e23e3 100644 --- a/miniTamTam/GenRythm.py +++ b/miniTamTam/GenRythm.py @@ -4,8 +4,6 @@ import Config from Generation.GenerationConstants import GenerationConstants from Generation.Utils import * -from Util import Instrument - class GenRythm: def drumRythmSequence(self, instrumentName, nbeats, density, regularity ): rythmSequence = [] @@ -16,28 +14,28 @@ class GenRythm: countDown = 0 onsetTime = None - if Instrument.INST[instrumentName].register == 'punch': + if Config.INSTRUMENTS[instrumentName].instrumentRegister == Config.PUNCH: registerDensity = 0.5 downBeatRecurence = 4 downBeats = [x for x in GenerationConstants.DRUM_PUNCH_ACCENTS[ nbeats ]] for downBeat in downBeats: upBeats.append( downBeat + Config.TICKS_PER_BEAT / 2 ) - if Instrument.INST[instrumentName].register == 'low': + if Config.INSTRUMENTS[instrumentName].instrumentRegister == Config.LOW: registerDensity =1 downBeatRecurence = 4 downBeats = [x for x in GenerationConstants.DRUM_LOW_ACCENTS[ nbeats ]] for downBeat in downBeats: upBeats.append( downBeat + Config.TICKS_PER_BEAT / 2 ) - if Instrument.INST[instrumentName].register == 'mid': + if Config.INSTRUMENTS[instrumentName].instrumentRegister == Config.MID: registerDensity = .75 downBeatRecurence = 1 downBeats = [x for x in GenerationConstants.DRUM_MID_ACCENTS[ nbeats ]] for downBeat in downBeats: upBeats.append( downBeat + Config.TICKS_PER_BEAT / 4 ) - if Instrument.INST[instrumentName].register == 'high': + if Config.INSTRUMENTS[instrumentName].instrumentRegister == Config.HIGH: registerDensity = 1.5 downBeatRecurence = 1 downBeats = [x for x in GenerationConstants.DRUM_HIGH_ACCENTS[ nbeats ]] diff --git a/miniTamTam/KeyboardStandAlone.py b/miniTamTam/KeyboardStandAlone.py index eb4ea7f..1560023 100644 --- a/miniTamTam/KeyboardStandAlone.py +++ b/miniTamTam/KeyboardStandAlone.py @@ -7,7 +7,6 @@ from Generation.GenerationConstants import GenerationConstants from Util.NoteDB import Note from Util.CSoundNote import CSoundNote from Util.CSoundClient import new_csound_client -from Util import Instrument KEY_MAP_PIANO = Config.KEY_MAP_PIANO @@ -15,7 +14,7 @@ KEY_MAP_PIANO = Config.KEY_MAP_PIANO class KeyboardStandAlone: def __init__( self, recordingFunction, adjustDurationFunction, getCurrentTick, getPlayState, loop ): - self.csnd = new_csound_client() + self.csnd = new_csound_client() self.recording = recordingFunction self.adjustDuration = adjustDurationFunction self.getPlayState = getPlayState @@ -27,18 +26,18 @@ class KeyboardStandAlone: self.loop = loop self.loopSustain = False self.sustainedLoop = [] - + def setInstrument( self , instrument ): self.instrument = instrument - + def setReverb(self , reverb): self.reverb = reverb - + def onKeyPress(self,widget,event, volume): key = event.hardware_keycode - if key == 50: #Left Shift + if key == 50 or key == 62: #Left Shift self.loopSustain = True - + # If the key is already in the dictionnary, exit function (to avoir key repeats) if self.key_dict.has_key(key): return @@ -54,7 +53,7 @@ class KeyboardStandAlone: self.loop.start(key, self.instrument, self.reverb) return - # Assign on which track the note will be created according to the number of keys pressed + # Assign on which track the note will be created according to the number of keys pressed if self.trackCount >= 9: self.trackCount = 1 track = self.trackCount @@ -63,29 +62,29 @@ class KeyboardStandAlone: if KEY_MAP_PIANO.has_key(key): def playkey(pitch,duration,instrument): # Create and play the note - self.key_dict[key] = CSoundNote(onset = 0, - pitch = pitch, - amplitude = volume, - pan = 0.5, - duration = duration, - trackId = track, - instrumentId = instrument.instrumentId, + self.key_dict[key] = CSoundNote(onset = 0, + pitch = pitch, + amplitude = volume, + pan = 0.5, + duration = duration, + trackId = track, + instrumentId = instrument.instrumentId, reverbSend = self.reverb, tied = True, - mode = 'mini') + mode = 'mini') self.csnd.play(self.key_dict[key], 0.3) if self.getPlayState(): recOnset = int(self.csnd.loopGetTick()) self.onset_dict[key] = recOnset self.recording( CSoundNote( - onset = recOnset, - pitch = pitch, - amplitude = volume, - pan = 0.5, - duration = 100, + onset = recOnset, + pitch = pitch, + amplitude = volume, + pan = 0.5, + duration = 100, trackId = 0, - decay = .1, - instrumentId = instrument.instrumentId, + decay = .1, + instrumentId = instrument.instrumentId, reverbSend = self.reverb, tied = False, mode = 'mini')) @@ -94,36 +93,38 @@ class KeyboardStandAlone: #print >>log, 'instrumentName:', instrumentName pitch = KEY_MAP_PIANO[key] - if instrumentName in Instrument.KIT: + if None != Config.INSTRUMENTS[instrumentName].kit: + if pitch in GenerationConstants.DRUMPITCH: + pitch = GenerationConstants.DRUMPITCH[pitch] #print >>log, 'kit_element: ', Config.KIT_ELEMENT[pitch] - playkey(36,100, Instrument.KIT[instrumentName][ Config.KIT_ELEMENT[pitch] ] ) + playkey(36,100, Config.INSTRUMENTS[instrumentName].kit[pitch]) else: if event.state == gtk.gdk.MOD1_MASK: pitch += 5 - instrument = Instrument.INST[ instrumentName ] - if instrument.csoundInstrumentName == 'inst_perc': #Percussions resonance + instrument = Config.INSTRUMENTS[ instrumentName ] + if instrument.csoundInstrumentId == Config.INST_PERC: #Percussions resonance playkey( pitch, 60, instrument) else: playkey( pitch, -1, instrument) - + def onKeyRelease(self,widget,event): key = event.hardware_keycode if key == 50: self.loopSustain = False - + if key in Config.LOOP_KEYS: if key in self.sustainedLoop: return else: self.loop.stop(key) return - + if KEY_MAP_PIANO.has_key(key): csnote = self.key_dict[key] - if Instrument.INST_byId[ csnote.instrumentId ].csoundInstrumentName == 'inst_tied': + if Config.INSTRUMENTSID[ csnote.instrumentId ].csoundInstrumentId == Config.INST_TIED: csnote.duration = .5 csnote.decay = 0.7 #csnote.amplitude = 1 @@ -136,7 +137,6 @@ class KeyboardStandAlone: if self.getPlayState(): if self.onset_dict.has_key(key): del self.onset_dict[key] - + def onButtonPress( self, widget, event ): pass - diff --git a/miniTamTam/Loop.py b/miniTamTam/Loop.py index 3e9484a..2a66626 100755 --- a/miniTamTam/Loop.py +++ b/miniTamTam/Loop.py @@ -6,7 +6,6 @@ from Util.CSoundNote import CSoundNote from Util.CSoundClient import new_csound_client from Util.NoteDB import Note from Util.NoteDB import PARAMETER -from Util import Instrument from Generation.GenerationConstants import GenerationConstants class Loop: @@ -50,10 +49,10 @@ class Loop: pitch = i[1] gain = i[2]*self.volume duration = i[3] - if instrument in Instrument.KIT: + if Config.INSTRUMENTS[instrument].kit != None: if GenerationConstants.DRUMPITCH.has_key(pitch): pitch = GenerationConstants.DRUMPITCH[pitch] - instrument = Instrument.KIT[ Config.KIT_ELEMENT[pitch] ].name + instrument = Config.INSTRUMENTS[ instrument ].kit[pitch].name pitch = 36 return CSoundNote( onset = onset, pitch = pitch, @@ -61,7 +60,7 @@ class Loop: pan = 0.5, duration = duration, trackId = 0, - instrumentId = Instrument.INST[instrument].instrumentId, + instrumentId = Config.INSTRUMENTS[instrument].instrumentId, reverbSend = reverb, tied = False, mode = 'mini') diff --git a/miniTamTam/RythmGenerator.py b/miniTamTam/RythmGenerator.py index 70d9720..4740160 100644 --- a/miniTamTam/RythmGenerator.py +++ b/miniTamTam/RythmGenerator.py @@ -4,7 +4,6 @@ import Config from Util.CSoundNote import CSoundNote from Generation.GenerationConstants import GenerationConstants from GenRythm import GenRythm -from Util import Instrument def generator( instrument, nbeats, density, regularity, reverbSend ): @@ -46,7 +45,7 @@ def generator( instrument, nbeats, density, regularity, reverbSend ): barLength = Config.TICKS_PER_BEAT * nbeats #print 'pageGenerate drumPitch[0] ', drumPitch[0] - currentInstrument = Instrument.KIT[instrument][ Config.KIT_ELEMENT[ drumPitch[0] ]].name + currentInstrument = Config.INSTRUMENTS[ instrument ].kit[ drumPitch[0] ].name rythmSequence = makeRythm.drumRythmSequence(currentInstrument, nbeats, density, regularity) pitchSequence = makePitchSequence(len(rythmSequence), drumPitch ) diff --git a/miniTamTam/miniTamTamMain.py b/miniTamTam/miniTamTamMain.py index 7121fa4..331291a 100644 --- a/miniTamTam/miniTamTamMain.py +++ b/miniTamTam/miniTamTamMain.py @@ -36,7 +36,6 @@ from RythmGenerator import * from SynthLab.SynthLabWindow import SynthLabWindow from Util.Trackpad import Trackpad from Util.InstrumentPanel import InstrumentPanel -from Util import Instrument from gettext import gettext as _ @@ -641,14 +640,14 @@ class miniTamTamMain(SubActivity): def playInstrumentNote(self , instrument, secs_per_tick = 0.025): if not self.muteInst: - self.csnd.play( - CSoundNote( onset = 0, - pitch = 36, - amplitude = 1, - pan = 0.5, - duration = 20, - trackId = 1, - instrumentId = Instrument.INST[instrument].instrumentId, + self.csnd.play( + CSoundNote( onset = 0, + pitch = 36, + amplitude = 1, + pan = 0.5, + duration = 20, + trackId = 1, + instrumentId = Config.INSTRUMENTS[instrument].instrumentId, reverbSend = 0, tied = False, mode = 'mini'), |