diff options
author | Nat <natcl@hotmail.com> | 2007-10-26 20:46:18 (GMT) |
---|---|---|
committer | Nat <natcl@hotmail.com> | 2007-10-26 20:46:18 (GMT) |
commit | 1a4a49865ea6543177a9734b80fb3a9227808b45 (patch) | |
tree | 384aff89f07f06960977f5a283f1625a72523ff9 /TamTamEdit.activity | |
parent | 7c0c78e17dccfdd34c78c7a10ceb8b315986d8de (diff) | |
parent | 2e1f26239411a0448c31f4911263ada60dbf3514 (diff) |
Merge branch 'master' of git+ssh://natcl@dev.laptop.org/git/projects/tamtam
Diffstat (limited to 'TamTamEdit.activity')
-rw-r--r-- | TamTamEdit.activity/Edit/MainWindow.py | 135 | ||||
-rw-r--r-- | TamTamEdit.activity/MANIFEST | 26 | ||||
-rw-r--r-- | TamTamEdit.activity/TamTamEdit.py | 9 |
3 files changed, 105 insertions, 65 deletions
diff --git a/TamTamEdit.activity/Edit/MainWindow.py b/TamTamEdit.activity/Edit/MainWindow.py index 64892aa..73f52a4 100644 --- a/TamTamEdit.activity/Edit/MainWindow.py +++ b/TamTamEdit.activity/Edit/MainWindow.py @@ -4,6 +4,8 @@ import gtk import gobject +import common.Util.Instruments +import common.Util.InstrumentDB as InstrumentDB from common.Util.ThemeWidgets import * from common.Util.Profiler import TP from common.Util import NoteDB @@ -45,6 +47,7 @@ class MainWindow( gtk.EventBox ): def __init__( self, activity ): gtk.EventBox.__init__(self) + self.instrumentDB = InstrumentDB.getRef() self.csnd = new_csound_client() self.tooltips = gtk.Tooltips() self.activity = activity @@ -55,8 +58,7 @@ class MainWindow( gtk.EventBox ): self.scale = GenerationConstants.DEFAULT_SCALE # META ALGO: [section, variation or not, nPages] A B A C - # TODO: Different parameters sets for each tracks - self.tuneForm = [[0, False, 4], [1, False, 4], [0, True, 4], [2, False, 4]] + self.tuneForm = [[0, False, 2], [1, False, 4], [0, True, 2], [2, False, 2]] def init_data( ): TP.ProfileBegin("init_data") @@ -68,12 +70,19 @@ class MainWindow( gtk.EventBox ): #[ instrument index, ... ] self.trackInstrumentDefault = [ - Config.INSTRUMENTS["kalimba"], - Config.INSTRUMENTS["kalimba"], - Config.INSTRUMENTS["kalimba"], - Config.INSTRUMENTS["kalimba"], - Config.INSTRUMENTS["drum2kit"] ] + self.instrumentDB.instNamed["kalimba"], + self.instrumentDB.instNamed["kalimba"], + self.instrumentDB.instNamed["kalimba"], + self.instrumentDB.instNamed["kalimba"], + self.instrumentDB.instNamed["drum2kit"] ] self.trackInstrument = self.trackInstrumentDefault[:] + + for i in self.trackInstrument: + if i.kit == None: + self.csnd.load_instrument(i.name) + else: + self.csnd.load_drumkit(i.name) + if len(self.trackInstrument) != Config.NUMBER_OF_TRACKS: raise 'error' self.drumIndex = Config.NUMBER_OF_TRACKS - 1 @@ -112,7 +121,7 @@ class MainWindow( gtk.EventBox ): self.GUI["2instrumentPalette"] = instrumentPalette(_('Track 1 Volume'), self) def draw_inst_icons(): - instrumentNames = [ k for k in Config.INSTRUMENTS.keys() if (k[0:4] != 'drum' and k[0:4] != 'guid') or Config.INSTRUMENTS[k].kit ] + instrumentNames = [ k for k in self.instrumentDB.instNamed.keys() if (k[0:4] != 'drum' and k[0:4] != 'guid') or self.instrumentDB.instNamed[k].kit ] self.GUI["2instrumentIcons"] = {} for instrument in instrumentNames: try: @@ -410,6 +419,12 @@ class MainWindow( gtk.EventBox ): orch = self.newOrchestra() + for i in orch: + if i.kit == None: + self.csnd.load_instrument(i.name) + else: + self.csnd.load_drumkit(i.name) + instrumentsIds = [] for inst in orch: instrumentsIds.append(inst.instrumentId) @@ -461,20 +476,20 @@ class MainWindow( gtk.EventBox ): keyboardPickup = [] fxPickup = [] drumsPickup = ["drum1kit", "drum2kit", "drum3kit", "drum4kit", "drum5kit"] - for name in Config.INSTRUMENTS.keys(): - if Config.INSTRUMENTS[name].category == 'strings' and Config.INSTRUMENTS[name].name != 'violin': + for name in self.instrumentDB.instNamed.keys(): + if self.instrumentDB.instNamed[name].category == 'strings' and self.instrumentDB.instNamed[name].name != 'violin': stringsPickup.append(name) - elif Config.INSTRUMENTS[name].category == 'winds' and Config.INSTRUMENTS[name].name != 'didjeridu': + elif self.instrumentDB.instNamed[name].category == 'winds' and self.instrumentDB.instNamed[name].name != 'didjeridu': windsPickup.append(name) - elif Config.INSTRUMENTS[name].category == 'keyboard' or Config.INSTRUMENTS[name].category == 'percussions' and not name.startswith('drum'): - if Config.INSTRUMENTS[name].name != 'zap' and Config.INSTRUMENTS[name].name != 'cling': + elif self.instrumentDB.instNamed[name].category == 'keyboard' or self.instrumentDB.instNamed[name].category == 'percussions' and not name.startswith('drum'): + if self.instrumentDB.instNamed[name].name != 'zap' and self.instrumentDB.instNamed[name].name != 'cling': keyboardPickup.append(name) return [ - Config.INSTRUMENTS[random.choice(stringsPickup)], - Config.INSTRUMENTS[random.choice(stringsPickup)], - Config.INSTRUMENTS[random.choice(windsPickup)], - Config.INSTRUMENTS[random.choice(keyboardPickup)], - Config.INSTRUMENTS[random.choice(drumsPickup)] ] + self.instrumentDB.instNamed[random.choice(stringsPickup)], + self.instrumentDB.instNamed[random.choice(stringsPickup)], + self.instrumentDB.instNamed[random.choice(windsPickup)], + self.instrumentDB.instNamed[random.choice(keyboardPickup)], + self.instrumentDB.instNamed[random.choice(drumsPickup)] ] def chooseGenParams(self): choose = [random.randint(0,16) for x in range(4)] @@ -794,6 +809,10 @@ class MainWindow( gtk.EventBox ): else: self.trackInstrument2[id] = instrument + if instrument.kit == None: + self.csnd.load_instrument(instrument.name) + else: + self.csnd.load_drumkit(instrument.name) if primary: # TODO handle secondary instruments properly if (Config.DEBUG > 3): print "handleInstrumentChanged", id, instrument.name, primary @@ -856,7 +875,7 @@ class MainWindow( gtk.EventBox ): self.GUI["9instrumentPopup"].hide() def donePickInstrument( self, instrumentName ): - self.handleInstrumentChanged( (self.last_clicked_instTrackID, Config.INSTRUMENTS[instrumentName]), self.last_clicked_instPrimary ) + self.handleInstrumentChanged( (self.last_clicked_instTrackID, self.instrumentDB.instNamed[instrumentName]), self.last_clicked_instPrimary ) btn = self.GUI["2instrument%dButton" % (self.last_clicked_instTrackID+1)] if self.last_clicked_instPrimary: btn.setPrimary( self.GUI["2instrumentIcons"][instrumentName] ) @@ -873,7 +892,7 @@ class MainWindow( gtk.EventBox ): self.GUI["2drumButton"].set_active( False ) def donePickDrum( self, drumName ): - self.handleInstrumentChanged( ( self.drumIndex, Config.INSTRUMENTS[drumName] ) ) + self.handleInstrumentChanged( ( self.drumIndex, self.instrumentDB.instNamed[drumName] ) ) self.GUI["2drumButton"].setImage( "main", self.GUI["2instrumentIcons"][drumName] ) self.GUI["2drumButton"].setImage( "alt", self.GUI["2instrumentIcons"][drumName] ) self.GUI["2drumButton"].set_active( False ) @@ -886,7 +905,7 @@ class MainWindow( gtk.EventBox ): pan = 0.5, duration = 20, trackId = 1, - instrumentId = Config.INSTRUMENTS[instrumentName].instrumentId, + instrumentId = self.instrumentDB.instNamed[instrumentName].instrumentId, reverbSend = 0), secs_per_tick) @@ -1220,7 +1239,7 @@ class MainWindow( gtk.EventBox ): page = self.noteDB.getPage(pageId) for i in range(Config.NUMBER_OF_TRACKS): if self.trackInstrument[i].instrumentId != page.instruments[i]: - self.trackInstrument[i] = Config.INSTRUMENTSID[page.instruments[i]] + self.trackInstrument[i] = self.instrumentDB.instId[page.instruments[i]] if i == Config.NUMBER_OF_TRACKS-1: btn = self.GUI["2drumButton"] btn.setImage( "main", self.GUI["2instrumentIcons"][self.trackInstrument[i].name] ) @@ -1481,7 +1500,7 @@ class MainWindow( gtk.EventBox ): if self.activity.activity_toolbar.title.is_focus(): return - + # backspace and del keys if keyval == gtk.keysyms.Delete or keyval == gtk.keysyms.BackSpace: if self.context == CONTEXT.PAGE: self.pageDelete() @@ -1516,7 +1535,7 @@ class MainWindow( gtk.EventBox ): def onKeyPress(self,widget,event): - + self.handleKeyboardShortcuts(event) Config.ModKeys.keyPress( event.hardware_keycode ) key = event.hardware_keycode @@ -1549,8 +1568,8 @@ class MainWindow( gtk.EventBox ): if tid == Config.NUMBER_OF_TRACKS-1: if GenerationConstants.DRUMPITCH.has_key( pitch ): pitch = GenerationConstants.DRUMPITCH[pitch] - if Config.INSTRUMENTS[instrument].kit != None: - instrument = Config.INSTRUMENTS[instrument].kit[pitch].name + if self.instrumentDB.instNamed[instrument].kit != None: + instrument = self.instrumentDB.instNamed[instrument].kit[pitch].name duration = 100 # Create and play the note @@ -1560,7 +1579,7 @@ class MainWindow( gtk.EventBox ): pan = 0.5, duration = duration, trackId = fakeTrack, - instrumentId = Config.INSTRUMENTS[instrument].instrumentId, + instrumentId = self.instrumentDB.instNamed[instrument].instrumentId, tied = False, mode = 'edit') self.csnd.play(self.kb_keydict[key], 0.3) @@ -1633,7 +1652,7 @@ class MainWindow( gtk.EventBox ): pan = 0.5, duration = duration, trackId = index, - instrumentId = Config.INSTRUMENTS[instrument].instrumentId, + instrumentId = self.instrumentDB.instNamed[instrument].instrumentId, tied = False, mode = 'edit') @@ -1647,7 +1666,7 @@ class MainWindow( gtk.EventBox ): self.durUpdate = gobject.timeout_add( 25, self.durationUpdate ) def onKeyRelease(self,widget,event): - + Config.ModKeys.keyRelease( event.hardware_keycode ) key = event.hardware_keycode @@ -1663,7 +1682,7 @@ class MainWindow( gtk.EventBox ): gobject.source_remove( self.durUpdate ) self.durUpdate = False - if Config.INSTRUMENTSID[ self.kb_keydict[key].instrumentId ].csoundInstrumentId == Config.INST_TIED: + if self.instrumentDB.instId[ self.kb_keydict[key].instrumentId ].csoundInstrumentId == Config.INST_TIED: self.kb_keydict[key].duration = 0.5 self.kb_keydict[key].amplitude = 0 self.kb_keydict[key].decay = 0.5 @@ -1743,7 +1762,7 @@ class MainWindow( gtk.EventBox ): if stop: key = self.csId[4] - if Config.INSTRUMENTSID[ self.kb_keydict[key].instrumentId ].csoundInstrumentId == Config.INST_TIED: + if self.instrumentDB.instId[ self.kb_keydict[key].instrumentId ].csoundInstrumentId == Config.INST_TIED: self.kb_keydict[key].duration = 0.5 self.kb_keydict[key].amplitude = 0 self.kb_keydict[key].decay = 0.5 @@ -2080,6 +2099,7 @@ class instrumentPalette( Popup ): def __init__(self, label, edit): Popup.__init__(self, label, edit) + self.instrumentDB = InstrumentDB.getRef() self.edit = edit self.skip = False @@ -2098,7 +2118,7 @@ class instrumentPalette( Popup ): self.muteButton.connect("toggled",self.handlemuteButton) self.muteButton.set_active(True) self.tooltips.set_tip(self.muteButton, _('Mute track')) - + self.soloButtonLabel = gtk.Label(_('S')) self.soloButton = gtk.CheckButton() self.soloButton.connect("toggled",self.handlesoloButton) @@ -2111,10 +2131,10 @@ class instrumentPalette( Popup ): self.volumeSlider.set_size_request(250, -1) self.volumeSlider.set_inverted(False) self.volumeSlider.set_draw_value(False) - + self.categories = [cat.capitalize() for cat in Config.CATEGORIES] self.instruments = self.getInstruments() - + self.categoryBox = BigComboBox() for category in self.categories: image = Config.IMAGE_ROOT + category.lower() + '.png' @@ -2126,7 +2146,7 @@ class instrumentPalette( Popup ): self.instrumentBox1 = BigComboBox() self.loadInstrumentMenu(self.getInstruments()) self.instrumentBox1.connect('changed', self.handleInstrumentChange) - + self.volumeBox.pack_start(self.muteButtonLabel, padding = 5) self.volumeBox.pack_start(self.muteButton, padding = 5) #self.volumeBox.pack_start(self.soloButtonLabel, padding = 5) @@ -2139,25 +2159,26 @@ class instrumentPalette( Popup ): self.mainBox.show_all() self.set_content(self.mainBox) - + def handleTrackVolume(self, widget): if not self.skipVolAdj: if self.lastClickedTrack != None: self.edit.handleTrackVolume(widget = widget, track = self.lastClickedTrack) - + def handlemuteButton(self, widget): if not self.skipVolAdj: if self.lastClickedTrack != None: self.edit.handlemuteButton(widget, self.lastClickedTrack) - + def handlesoloButton(self, widget, event = None): pass def handleInstrumentChange(self, widget): if not self.skip: instrument = widget.props.value - self.edit.playInstrumentNote(instrument) self.edit.donePickInstrument(instrument) + time.sleep(0.05) + self.edit.playInstrumentNote(instrument) self.popdown(True) def handleCategoryChange(self, widget): @@ -2169,15 +2190,15 @@ class instrumentPalette( Popup ): if not self.skip: self.instrumentBox1.popup() #self.skip = False - + def setCategory(self, category): self.categoryBox.set_active(self.categories.index(category.capitalize())) - + def setInstrument(self, instrument): self.skip = True self.instrumentBox1.set_active(self.instruments.index(instrument)) self.skip = False - + def loadInstrumentMenu(self, instruments): self.instrumentBox1.remove_all() for instrument in instruments: @@ -2188,10 +2209,10 @@ class instrumentPalette( Popup ): def getInstruments(self, category = 'all'): if category == 'all': - return sorted([instrument for instrument in Config.INSTRUMENTS.keys() if not instrument.startswith('drum') and not instrument.startswith('guid')]) + return sorted([instrument for instrument in self.instrumentDB.instNamed.keys() if not instrument.startswith('drum') and not instrument.startswith('guid')]) else: - return sorted([instrument for instrument in Config.INSTRUMENTS.keys() if not instrument.startswith('drum') and not instrument.startswith('guid') and Config.INSTRUMENTS[instrument].category == category]) - + return sorted([instrument for instrument in self.instrumentDB.instNamed.keys() if not instrument.startswith('drum') and not instrument.startswith('guid') and self.instrumentDB.instNamed[instrument].category == category]) + def setBlock( self, widget = None, event = None, block = None ): if self.is_up(): self.popdown(True) @@ -2203,15 +2224,16 @@ class instrumentPalette( Popup ): self.muteButton.set_active(True) else: self.muteButton.set_active(False) - self.skipVolAdj = False + self.skipVolAdj = False self.lastClickedTrack = block self.popup( True ) - + class drumPalette( Popup ): ICON_SIZE = (70,70) def __init__(self, label, edit, trackID): Popup.__init__(self, label, edit) + self.instrumentDB = InstrumentDB.getRef() self.trackID = trackID self.edit = edit @@ -2239,13 +2261,13 @@ class drumPalette( Popup ): self.volumeSlider.set_size_request(250, -1) self.volumeSlider.set_inverted(False) self.volumeSlider.set_draw_value(False) - + self.drums = self.getDrums() self.drumBox = BigComboBox() self.loadDrumMenu(self.getDrums()) self.drumBox.connect('changed', self.handleInstrumentChange) - + self.volumeBox.pack_start(self.muteButton, padding = 5) self.volumeBox.pack_start(self.volumeSlider, padding = 5) self.mainBox.pack_start(self.volumeBox, padding = 5) @@ -2258,16 +2280,17 @@ class drumPalette( Popup ): def handleInstrumentChange(self, widget): if not self.skip: drum = widget.props.value - self.edit.playInstrumentNote(drum) self.edit.donePickDrum(drum) + time.sleep(0.05) + self.edit.playInstrumentNote(drum) self.popdown(True) - - + + def setDrum(self, Drum): self.skip = True self.drumBox.set_active(self.drums.index(Drum)) self.skip = False - + def loadDrumMenu(self, instruments): self.drumBox.remove_all() for instrument in instruments: @@ -2277,12 +2300,10 @@ class drumPalette( Popup ): self.drumBox.append_item(instrument, text = None, icon_name = image, size = instrumentPalette.ICON_SIZE) def getDrums(self): - return sorted([instrument for instrument in Config.INSTRUMENTS.keys() if Config.INSTRUMENTS[instrument].kit]) - + return sorted([instrument for instrument in self.instrumentDB.instNamed.keys() if self.instrumentDB.instNamed[instrument].kit]) + def setBlock( self, widget = None, event = None, block = None ): if self.is_up(): self.popdown(True) else: self.popup( True ) - - diff --git a/TamTamEdit.activity/MANIFEST b/TamTamEdit.activity/MANIFEST index 93eb17c..9bd16ff 100644 --- a/TamTamEdit.activity/MANIFEST +++ b/TamTamEdit.activity/MANIFEST @@ -60,14 +60,12 @@ common/Util/ControlStream.py common/Util/Credits.py common/Util/InstrumentDB.py common/Util/InstrumentPanel.py -common/Util/Instrument_.py +common/Util/Instruments.py common/Util/KeyboardWindow.py common/Util/LoopSettings.py common/Util/Network.py common/Util/NoteDB.py -common/Util/NoteLooper.py common/Util/Profiler.py -common/Util/Sound.py common/Util/ThemeWidgets.py common/Util/Trackpad.py common/Util/__init__.py @@ -102,21 +100,31 @@ common/Resources/tooltips_en.py common/Resources/tooltips_fr.py common/Resources/Sounds/acguit common/Resources/Sounds/alarm +common/Resources/Sounds/armbone +common/Resources/Sounds/babylaugh +common/Resources/Sounds/babyuhoh common/Resources/Sounds/banjo common/Resources/Sounds/basse +common/Resources/Sounds/basse2 common/Resources/Sounds/bird common/Resources/Sounds/bottle common/Resources/Sounds/bubbles common/Resources/Sounds/byke common/Resources/Sounds/camera common/Resources/Sounds/car +common/Resources/Sounds/carhorn common/Resources/Sounds/cat common/Resources/Sounds/cello +common/Resources/Sounds/chicken common/Resources/Sounds/chimes common/Resources/Sounds/clang +common/Resources/Sounds/clang2 common/Resources/Sounds/clarinette +common/Resources/Sounds/clavinet common/Resources/Sounds/cling +common/Resources/Sounds/cow common/Resources/Sounds/crash +common/Resources/Sounds/cricket common/Resources/Sounds/diceinst common/Resources/Sounds/didjeridu common/Resources/Sounds/dog @@ -185,7 +193,11 @@ common/Resources/Sounds/drum5timablesslap common/Resources/Sounds/drum5vibraslap common/Resources/Sounds/duck common/Resources/Sounds/duck2 +common/Resources/Sounds/fingercymbals +common/Resources/Sounds/flugel common/Resources/Sounds/flute +common/Resources/Sounds/foghorn +common/Resources/Sounds/frogs common/Resources/Sounds/gam common/Resources/Sounds/guidice1 common/Resources/Sounds/guidice10 @@ -199,10 +211,14 @@ common/Resources/Sounds/guidice8 common/Resources/Sounds/guidice9 common/Resources/Sounds/guit common/Resources/Sounds/guit2 +common/Resources/Sounds/guitmute +common/Resources/Sounds/guitshort common/Resources/Sounds/harmonica common/Resources/Sounds/harmonium -common/Resources/Sounds/horse +common/Resources/Sounds/harpsichord common/Resources/Sounds/kalimba +common/Resources/Sounds/hey +common/Resources/Sounds/horse common/Resources/Sounds/koto common/Resources/Sounds/lab1 common/Resources/Sounds/lab2 @@ -224,6 +240,7 @@ common/Resources/Sounds/piano common/Resources/Sounds/plane common/Resources/Sounds/rhodes common/Resources/Sounds/saxo +common/Resources/Sounds/saxsoprano common/Resources/Sounds/sheep common/Resources/Sounds/shenai common/Resources/Sounds/sitar @@ -231,6 +248,7 @@ common/Resources/Sounds/slap common/Resources/Sounds/triangle common/Resources/Sounds/trumpet common/Resources/Sounds/tuba +common/Resources/Sounds/ukulele common/Resources/Sounds/violin common/Resources/Sounds/voix common/Resources/Sounds/water diff --git a/TamTamEdit.activity/TamTamEdit.py b/TamTamEdit.activity/TamTamEdit.py index e5c830f..00fc13d 100644 --- a/TamTamEdit.activity/TamTamEdit.py +++ b/TamTamEdit.activity/TamTamEdit.py @@ -53,7 +53,7 @@ class TamTamEdit(activity.Activity): #self.modeList[mode].regenerate() self.set_canvas( self.edit ) - + self.edit.onActivate(arg = None) self.show() @@ -71,7 +71,7 @@ class TamTamEdit(activity.Activity): if Config.DEBUG > 4: print "TamTam::preload returned after", time.time() - t return True - + def onActive(self, widget = None, event = None): if widget.props.active == False: csnd = new_csound_client() @@ -79,7 +79,7 @@ class TamTamEdit(activity.Activity): else: csnd = new_csound_client() csnd.connect(True) - + def onKeyPress(self, widget, event): pass @@ -111,6 +111,7 @@ class TamTamEdit(activity.Activity): self.ensure_dir(Config.TUNE_DIR) self.ensure_dir(Config.SYNTH_DIR) self.ensure_dir(Config.SNDS_DIR) + self.ensure_dir(Config.SNDS_INFO_DIR) self.ensure_dir(Config.SCRATCH_DIR) if not os.path.isdir(Config.PREF_DIR): @@ -124,4 +125,4 @@ class TamTamEdit(activity.Activity): self.edit.handleJournalLoad(file_path) def write_file(self,file_path): - self.edit.handleJournalSave(file_path) + self.edit.handleJournalSave(file_path) |