Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TamTamMini.activity/Mini
diff options
context:
space:
mode:
authorOli <olivier.belanger@umontreal.ca>2007-10-26 05:50:30 (GMT)
committer Oli <olivier.belanger@umontreal.ca>2007-10-26 05:50:30 (GMT)
commit9583b21dae8041c6544fb37de00ca42b034ebc98 (patch)
tree4c37d754cdaa5b332969f7fc30f0bba31025d006 /TamTamMini.activity/Mini
parent3aebf3dad1f5c137a5182cfe06b8edc778a5ddb9 (diff)
miniT tabs cleanup, loop settings moved to Jam
Diffstat (limited to 'TamTamMini.activity/Mini')
-rw-r--r--TamTamMini.activity/Mini/InstrumentPanel.py6
-rw-r--r--TamTamMini.activity/Mini/miniTamTamMain.py103
-rw-r--r--TamTamMini.activity/Mini/miniToolbars.py248
3 files changed, 278 insertions, 79 deletions
diff --git a/TamTamMini.activity/Mini/InstrumentPanel.py b/TamTamMini.activity/Mini/InstrumentPanel.py
index a35b774..103c6f4 100644
--- a/TamTamMini.activity/Mini/InstrumentPanel.py
+++ b/TamTamMini.activity/Mini/InstrumentPanel.py
@@ -75,8 +75,9 @@ class InstrumentPanel( gtk.EventBox ):
if timeout >= 0 and time.time() > timeout: return False
if self.loadStage[0] == 4:
- if not self.loadToolbar( timeout, self.loadStage ):
- return False
+ # hide category row
+ #if not self.loadToolbar( timeout, self.loadStage ):
+ # return False
self.loadStage[0] = 5
if timeout >= 0 and time.time() > timeout: return False
@@ -181,6 +182,7 @@ class InstrumentPanel( gtk.EventBox ):
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")
diff --git a/TamTamMini.activity/Mini/miniTamTamMain.py b/TamTamMini.activity/Mini/miniTamTamMain.py
index ed92955..f9568b2 100644
--- a/TamTamMini.activity/Mini/miniTamTamMain.py
+++ b/TamTamMini.activity/Mini/miniTamTamMain.py
@@ -74,6 +74,10 @@ class miniTamTamMain(gtk.EventBox):
for i in range(21):
self.csnd.setTrackVolume( 100, i )
+ for i in range(10):
+ r = str(i+1)
+ self.csnd.load_instrument('guidice' + r)
+
self.volume = 100
self.csnd.setMasterVolume(self.volume)
self.sequencer.beat = self.beat
@@ -93,24 +97,12 @@ class miniTamTamMain(gtk.EventBox):
self.enableKeyboard()
self.setInstrument(self.instrument)
- self.loopSettingsPopup = gtk.Window(gtk.WINDOW_POPUP)
- self.loopSettingsPopup.set_modal(True)
- self.loopSettingsPopup.add_events( gtk.gdk.BUTTON_PRESS_MASK )
- self.loopSettingsPopup.connect("button-release-event", lambda w,e:self.doneLoopSettingsPopup() )
- self.loopSettings = LoopSettings( self.loopSettingsPopup, self.loopSettingsPlayStop, self.loopSettingsChannel, self.doneLoopSettingsPopup )
- self.loopSettingsPopup.add( self.loopSettings )
- self.loopSettingsPlaying = False
-
-
self.drawInstrumentButtons()
self.drawGeneration()
self.show_all()
if 'a good idea' == True:
self.playStartupSound()
- #self.synthLabWindow = None
-
-
self.beatPickup = True
#self.regenerate()
@@ -151,12 +143,12 @@ class miniTamTamMain(gtk.EventBox):
# Toolbar
self.activity.activity_toolbar.share.show()
self._playToolbar = playToolbar(self.activity.toolbox, self)
- self._recordToolbar = recordToolbar(self.activity.toolbox, self)
- self.activity.toolbox.add_toolbar(_('Play'), self._playToolbar)
- self.activity.toolbox.add_toolbar(_('Record'), self._recordToolbar)
+ #self._recordToolbar = recordToolbar(self.activity.toolbox, self)
+ #self.activity.toolbox.add_toolbar(_('Play'), self._playToolbar)
+ #self.activity.toolbox.add_toolbar(_('Record'), self._recordToolbar)
self.activity.toolbox.set_current_toolbar(1)
- self._playToolbar.show()
- self._recordToolbar.show()
+ #self._playToolbar.show()
+ #self._recordToolbar.show()
self.activity.connect( "shared", self.shared )
@@ -246,6 +238,16 @@ class miniTamTamMain(gtk.EventBox):
slidersBox.pack_start(slidersBoxSub)
generateBtnSub = gtk.HBox()
+
+ #playImg = gtk.Image()
+ #playImg.set_from_icon_name('media-playback-start', gtk.ICON_SIZE_LARGE_TOOLBAR)
+ self.playButton = ImageToggleButton(Config.IMAGE_ROOT + 'miniplay.png', Config.IMAGE_ROOT + 'stop.png')
+ #self.playButton.set_relief(gtk.RELIEF_NONE)
+ #self.playButton.set_image(playImg)
+ self.playButton.connect('clicked',self.handlePlayButton)
+ generateBtnSub.pack_start(self.playButton)
+ #self.playButton.set_tooltip(_('Play / Stop'))
+
generateBtn = ImageButton(Config.IMAGE_ROOT + 'dice.png', clickImg_path = Config.IMAGE_ROOT + 'diceblur.png')
generateBtn.connect('button-press-event', self.handleGenerateBtn)
generateBtnSub.pack_start(generateBtn)
@@ -301,52 +303,8 @@ class miniTamTamMain(gtk.EventBox):
self.loopSettingsPlaying = False
self.csnd.inputMessage(Config.CSOUND_STOP_LS_NOTE)
- def doneLoopSettingsPopup(self):
- if self._recordToolbar.loopSetButton.get_active():
- if self.loopSettingsPlaying:
- self.csnd.inputMessage(Config.CSOUND_STOP_LS_NOTE)
- self.loopSettingsPlaying = False
- self._recordToolbar.loopSetButton.set_active(False)
-
- def handleLoopSettingsBtn(self, widget, data=None):
- if widget.get_active():
-
- chooser = gtk.FileChooserDialog(title='Edit SoundFile Preference',action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
-
- #filter = gtk.FileFilter()
- #filter.add_pattern('*.wav')
- #chooser.set_filter(filter)
- chooser.set_current_folder(Config.SNDS_DIR)
-
- for f in chooser.list_shortcut_folder_uris():
- chooser.remove_shortcut_folder_uri(f)
-
- if chooser.run() == gtk.RESPONSE_OK:
- try:
- tempName = chooser.get_filename()
- soundName = os.path.split(tempName)[1]
- except IOError:
- print 'ERROR: failed to load Sound from file %s' % chooser.get_filename()
- chooser.destroy()
- #results = commands.getstatusoutput("csound -U sndinfo %s" % tempName)
- results = commands.getstatusoutput("du -b %s" % tempName)
- if results[0] == 0:
- list = results[1].split()
- #pos = list.index('seconds')
- #soundLength = float(list[pos-1])
- soundLength = float(list[0]) / 2 / 16000.
- self.loopSettings.set_name(soundName)
- self.loopSettings.setButtonState()
- self.loopSettingsPopup.show()
- self.loopSettingsPopup.move( 600, 200 )
- self.timeoutLoad = gobject.timeout_add(2000, self.load_ls_instrument, soundName, soundLength)
- else:
- self.loopSettingsPopup.hide()
-
- def load_ls_instrument(self, soundName, soundLength):
+ def load_ls_instrument(self, soundName):
self.csnd.load_ls_instrument(soundName)
- self.loopSettings.set_values(soundLength)
- gobject.source_remove( self.timeoutLoad )
def drawInstrumentButtons(self):
self.instrumentPanelBox = gtk.HBox()
@@ -379,19 +337,12 @@ class miniTamTamMain(gtk.EventBox):
self._recordToolbar.keyboardRecOverButton.set_active( state )
def recordOverSensitivity( self, state ):
- self._recordToolbar.keyboardRecOverButton.set_sensitive( state )
-
- #def synthLabWindowOpen(self):
- #return self.synthLabWindow != None and self.synthLabWindow.get_property('visible')
+ pass
+ #self._recordToolbar.keyboardRecOverButton.set_sensitive( state )
def loadMicInstrument( self, data ):
self.csnd.load_mic_instrument( data )
- #def closeSynthLab(self):
- #if self.synthLabWindow != None:
- #self.synthLabWindow.destroy()
- #self.synthLabWindow = None
-
def regenerate(self):
def flatten(ll):
rval = []
@@ -547,7 +498,8 @@ class miniTamTamMain(gtk.EventBox):
self.drumFillin.stop()
self.sequencer.stopPlayback()
self.csnd.loopPause()
- widget.set_icon_widget(self.playButtonImg)
+ #widget.set_image(self.playButtonImg)
+ #widget.set_relief(gtk.RELIEF_NONE)
self.playing = False
else:
if not self.firstTime:
@@ -559,7 +511,8 @@ class miniTamTamMain(gtk.EventBox):
#print "play:: next beat in %f ticks. bpb == %d. setting ticks to %d" % (nextInTicks, self.beat, Config.TICKS_PER_BEAT*self.beat - int(round(nextInTicks)))
self.csnd.loopSetTick( Config.TICKS_PER_BEAT*self.beat - int(round(nextInTicks)) )
self.csnd.loopStart()
- widget.set_icon_widget(self.stopButtonImg)
+ #widget.set_image(self.stopButtonImg)
+ #widget.set_relief(gtk.RELIEF_NONE)
self.playing = True
@@ -575,8 +528,8 @@ class miniTamTamMain(gtk.EventBox):
def handleGenerateBtn(self , widget , data=None):
self.regenerate()
- if not self._playToolbar.playButton.get_active():
- self._playToolbar.playButton.set_active(True)
+ if not self.playButton.get_active():
+ self.playButton.set_active(True)
#this calls sends a 'clicked' event,
#which might be connected to handlePlayButton
diff --git a/TamTamMini.activity/Mini/miniToolbars.py b/TamTamMini.activity/Mini/miniToolbars.py
index 8608673..2c8c90a 100644
--- a/TamTamMini.activity/Mini/miniToolbars.py
+++ b/TamTamMini.activity/Mini/miniToolbars.py
@@ -1,7 +1,10 @@
#!/usr/bin/env python
import gtk
+import gobject
+import os, commands
import common.Config as Config
+from common.Util.ThemeWidgets import *
from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.toggletoolbutton import ToggleToolButton
@@ -144,8 +147,249 @@ class recordToolbar(gtk.Toolbar):
_insertSeparator()
+ self._loopSettingsPalette = LoopSettingsPalette(_('Add new Sound'), self.miniTamTam)
self.loopSetButton = ToggleToolButton('loop')
- self.loopSetButton.connect('clicked', self.miniTamTam.handleLoopSettingsBtn)
+ #self.loopSetButton.connect('clicked', self.miniTamTam.handleLoopSettingsBtn)
+ self.loopSetButton.set_palette(self._loopSettingsPalette)
self.insert(self.loopSetButton, -1)
self.loopSetButton.show()
- self.loopSetButton.set_tooltip(_('Add new sound'))
+ #self.loopSetButton.set_tooltip(_('Add new sound'))
+
+class LoopSettingsPalette( Palette ):
+ def __init__( self, label, mini ):
+ Palette.__init__( self, label )
+ self.connect('popup', self.handlePopup)
+ self.connect('popdown', self.handlePopdown)
+
+ self.mini = mini
+
+ self.tooltips = gtk.Tooltips()
+ self.loopedSound = False
+ self.soundLength = 1.00
+ self.start = 0
+ self.end = 1.00
+ self.dur = 0.01
+ self.volume = 1
+ self.register = 0
+ self.ok = True
+
+ self.mainBox = gtk.VBox()
+
+ self.controlsBox = gtk.HBox()
+
+ self.GUI = {}
+
+ self.soundBox = gtk.HBox()
+ self.soundLabel = gtk.Label(_('Sound: '))
+ self.soundMenuBox = BigComboBox()
+ self.sounds = os.listdir(Config.SNDS_DIR)
+ for sound in self.sounds:
+ self.soundMenuBox.append_item(self.sounds.index(sound), sound)
+ self.soundMenuBox.connect('changed', self.handleSound)
+ self.soundBox.pack_start(self.soundLabel, False, False, padding=10)
+ self.soundBox.pack_start(self.soundMenuBox, False, False, padding=10)
+
+ self.mainBox.pack_start(self.soundBox, False, False, 10)
+
+ nameBox = gtk.VBox()
+ self.nameEntry = gtk.Entry()
+ entrycolor = gtk.gdk.Color()
+ self.nameEntry.modify_text(gtk.STATE_NORMAL, entrycolor)
+ self.nameEntry.set_text("name_of_the_sound")
+ nameBox.pack_start(self.nameEntry)
+ self.mainBox.pack_start(nameBox, False, False, 10)
+
+ registerBox = gtk.HBox()
+ self.registerBoxLabel = gtk.Label(_('Register: '))
+ self.registerMenuBox = BigComboBox()
+ self.registers = ['LOW', 'MID', 'HIGH', 'PUNCH']
+ for reg in self.registers:
+ self.registerMenuBox.append_item(self.registers.index(reg), reg)
+ self.registerMenuBox.connect('changed', self.handleRegister)
+ registerBox.pack_start(self.registerBoxLabel, False, False, padding=10)
+ registerBox.pack_end(self.registerMenuBox, False, False, padding=10)
+ self.mainBox.pack_start(registerBox, False, False, 10)
+
+ loopedBox = gtk.HBox()
+ loopedLabel = gtk.Label("Looped sound: ")
+ loopedToggle = ImageToggleButton(Config.IMAGE_ROOT+"checkOff.svg",Config.IMAGE_ROOT+"checkOn.svg")
+ loopedToggle.connect('button-press-event', self.handleLooped )
+ loopedBox.pack_start(loopedLabel, False, False, padding=10)
+ loopedBox.pack_end(loopedToggle, False, False, padding=10)
+ self.mainBox.pack_start(loopedBox, False, False, 10)
+
+ startBox = gtk.VBox()
+ self.startAdjust = gtk.Adjustment( 0.01, 0, 1., .001, .001, 0)
+ self.GUI['startSlider'] = gtk.VScale( adjustment = self.startAdjust )
+ self.startAdjust.connect("value-changed", self.handleStart)
+ self.GUI['startSlider'].set_inverted(True)
+ self.GUI['startSlider'].set_size_request(50, 200)
+ self.GUI['startSlider'].set_digits(3)
+ self.handleStart( self.startAdjust )
+ startBox.pack_start(self.GUI['startSlider'], 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'] = gtk.VScale( adjustment = self.endAdjust )
+ self.endAdjust.connect("value-changed", self.handleEnd)
+ self.GUI['endSlider'].set_inverted(True)
+ self.GUI['endSlider'].set_size_request(50, 200)
+ self.GUI['endSlider'].set_digits(3)
+ self.handleEnd( self.endAdjust )
+ endBox.pack_start(self.GUI['endSlider'], True, True, 5)
+ self.controlsBox.pack_start(endBox)
+
+ durBox = gtk.VBox()
+ self.durAdjust = gtk.Adjustment( 0.01, 0, 0.2, .001, .001, 0)
+ self.GUI['durSlider'] = gtk.VScale( adjustment = self.durAdjust )
+ self.durAdjust.connect("value-changed", self.handleDur)
+ self.GUI['durSlider'].set_inverted(True)
+ self.GUI['durSlider'].set_size_request(50, 200)
+ self.GUI['durSlider'].set_digits(3)
+ self.handleDur( self.durAdjust )
+ durBox.pack_start(self.GUI['durSlider'], True, True, 5)
+ self.controlsBox.pack_start(durBox)
+
+ volBox = gtk.VBox()
+ self.volAdjust = gtk.Adjustment( 1, 0, 2, .01, .01, 0)
+ self.GUI['volSlider'] = gtk.VScale( adjustment = self.volAdjust )
+ self.volAdjust.connect("value-changed", self.handleVol)
+ self.GUI['volSlider'].set_inverted(True)
+ self.GUI['volSlider'].set_size_request(50, 200)
+ self.GUI['volSlider'].set_digits(3)
+ self.handleVol( self.volAdjust )
+ volBox.pack_start(self.GUI['volSlider'], True, True, 5)
+ self.controlsBox.pack_start(volBox)
+
+ self.mainBox.pack_start(self.controlsBox, False, False, 10)
+
+ 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, 10)
+
+ checkBox = gtk.VBox()
+ checkButton = ImageButton(Config.TAM_TAM_ROOT + '/icons/accept.svg')
+ checkButton.connect('clicked' , self.handleCheck)
+ checkBox.pack_start(checkButton)
+ self.mainBox.pack_start(checkBox, False, False, 10)
+
+ self.mainBox.show_all()
+ self.set_content(self.mainBox)
+
+ def handlePopup(self, widget, data=None):
+ self.setButtonState()
+ self.soundMenuBox.remove_all()
+ self.sounds = os.listdir(Config.SNDS_DIR)
+ for sound in self.sounds:
+ self.soundMenuBox.append_item(self.sounds.index(sound), sound)
+ self.nameEntry.set_text("name_of_the_sound")
+
+ def handlePopdown(self, widget, data=None):
+ if self.playStopButton.get_active() == True:
+ self.mini.loopSettingsPlayStop(True, self.loopedSound)
+
+ def handleSound(self, widget, data=None):
+ self.sndname = self.sounds[widget.props.value]
+ fullname = Config.SNDS_DIR + '/' + self.sndname
+ results = commands.getstatusoutput("du -b %s" % fullname)
+ if results[0] == 0:
+ list = results[1].split()
+ soundLength = float(list[0]) / 2 / 16000.
+ self.nameEntry.set_text(self.sndname)
+ self.set_values(soundLength)
+ self.startAdjust.set_all( 0.01, 0, soundLength, .001, .001, 0)
+ self.endAdjust.set_all( soundLength-0.01, 0, soundLength, .001, .001, 0)
+ self.timeoutLoad = gobject.timeout_add(2000, self.loopSettingsDelay)
+
+ def loopSettingsDelay(self):
+ self.mini.load_ls_instrument(self.sndname)
+ gobject.source_remove( self.timeoutLoad )
+
+ def handleCheck(self, widget):
+ if self.nameEntry.get_text() != self.sndname:
+ oldName = self.sndname
+ self.sndname = self.nameEntry.get_text()
+ copy = True
+ else:
+ copy = False
+
+ ofile = open(Config.SNDS_INFO_DIR + '/' + self.sndname, 'w')
+ if self.loopedSound:
+ tied = str(Config.INST_TIED)
+ else:
+ tied = str(Config.INST_SIMP)
+ register = str(self.register)
+ category = 'mysounds'
+ start = str(self.start)
+ end = str(self.end)
+ dur = str(self.dur)
+ vol = str(self.volume)
+
+ ofile.write('TamTam idf v1\n')
+ ofile.write(self.sndname + '\n')
+ ofile.write(tied + '\n')
+ ofile.write(register + '\n')
+ ofile.write(start + '\n')
+ ofile.write(end + '\n')
+ ofile.write(dur + '\n')
+ ofile.write(vol + '\n')
+ ofile.write(self.sndname + '\n')
+ ofile.write(Config.LIB_DIR+"/Images/"+self.sndname+".png\n")
+ ofile.write(category)
+ ofile.close()
+ if copy:
+ (s,o) = commands.getstatusoutput('cp ' + Config.SNDS_DIR + '/' + oldName + ' ' + Config.SNDS_DIR + '/' + self.sndname)
+
+ def set_values(self, soundLength):
+ 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 handleRegister(self, widget, data=None):
+ self.register = self.registers[widget.props.value]
+
+ def handleStart(self, widget, data=None):
+ self.start = self.startAdjust.value
+ if self.start > self.end:
+ self.start = self.end
+ self.mini.loopSettingsChannel('lstart', self.start)
+
+ def handleEnd(self, widget, data=None):
+ self.end = self.endAdjust.value
+ if self.end < self.start:
+ self.end = self.start
+ self.mini.loopSettingsChannel('lend', self.end)
+
+ def handleDur(self, widget, data=None):
+ self.dur = self.durAdjust.value
+ self.mini.loopSettingsChannel('ldur', self.dur)
+
+ def handleVol(self, widget, data=None):
+ self.volume = self.volAdjust.value
+ self.mini.loopSettingsChannel('lvol', self.volume)
+
+ def handlePlayButton(self, widget, data=None):
+ if self.ok:
+ self.mini.loopSettingsPlayStop(widget.get_active(), self.loopedSound)
+ if self.loopedSound == False and widget.get_active() == False:
+ self.timeoutStop = gobject.timeout_add(int(self.soundLength * 1000)+500, self.playButtonState)
+
+ def setButtonState(self):
+ self.ok = False
+ self.playStopButton.set_active(False)
+ self.ok = True
+
+ def playButtonState(self):
+ self.ok = False
+ self.playStopButton.set_active(False)
+ gobject.source_remove(self.timeoutStop)
+ self.ok = True