Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/miniTamTam
diff options
context:
space:
mode:
authorJames <olpc@xo-05-28-3A.localdomain>2007-07-20 23:23:53 (GMT)
committer James <olpc@xo-05-28-3A.localdomain>2007-07-20 23:23:53 (GMT)
commit6784621507a8c7786e731b984ab57a7b8c3da400 (patch)
tree45a1132c192d23dbc77dd7b0022349621f4332f8 /miniTamTam
parentbbff3cb7d8d95976a55b9ad8d7a6d37fca69f731 (diff)
parentc312ded2c29fdcc3435d93834f5044175cbe6884 (diff)
merged
Diffstat (limited to 'miniTamTam')
-rw-r--r--miniTamTam/KeyboardStandAlone.py2
-rw-r--r--miniTamTam/MiniSequencer.py46
-rw-r--r--miniTamTam/miniTamTamMain.py188
-rw-r--r--miniTamTam/miniToolbars.py84
4 files changed, 165 insertions, 155 deletions
diff --git a/miniTamTam/KeyboardStandAlone.py b/miniTamTam/KeyboardStandAlone.py
index b8ae1eb..019f0c9 100644
--- a/miniTamTam/KeyboardStandAlone.py
+++ b/miniTamTam/KeyboardStandAlone.py
@@ -74,7 +74,7 @@ class KeyboardStandAlone:
mode = 'mini')
self.csnd.play(self.key_dict[key], 0.3)
if self.getPlayState():
- recOnset = self.csnd.loopGetTick()
+ recOnset = int(self.csnd.loopGetTick())
self.onset_dict[key] = recOnset
self.recording( CSoundNote(
onset = recOnset,
diff --git a/miniTamTam/MiniSequencer.py b/miniTamTam/MiniSequencer.py
index 4182af9..797a04c 100644
--- a/miniTamTam/MiniSequencer.py
+++ b/miniTamTam/MiniSequencer.py
@@ -1,6 +1,6 @@
import pygtk
pygtk.require( '2.0' )
-import gtk
+import gtk
import gobject
import time
import Config
@@ -10,13 +10,13 @@ from Util.NoteDB import Note
from Util.NoteDB import PARAMETER
class MiniSequencer:
- def __init__( self, recordButtonState ):
+ def __init__( self, recordButtonState, recordOverSensitivity ):
self.notesList = []
self.sequencer = []
self.pitchs = []
self.beat = 4
self.volume = 0.5
- self.tempo = Config.PLAYER_TEMPO
+ self.tempo = Config.PLAYER_TEMPO
self.checkOk = 0
self.tick = 0
self.id = 1000
@@ -25,22 +25,31 @@ class MiniSequencer:
self.recordState = 0
self.startPoint = 0
self.recordButtonState = recordButtonState
+ self.recordOverSensitivity = recordOverSensitivity
self.playbackTimeout = None
self.playState = 0
-
+
def setTempo( self, tempo ):
self.tempo = tempo
gobject.source_remove( self.playBackTimeout )
self.playState = 0
- def handleRecordButton( self, widget, data ):
+ def handleRecordButton( self, widget, data=None ):
if not self.startLooking:
- if 1: #widget.get_active() == True:
+ if widget.get_active() == True and not self.recordState:
+ self.button = 1
+ self.recordOverSensitivity( True )
self.beats = [i*4 for i in range(self.beat)]
self.upBeats = [i+2 for i in self.beats]
self.realTick = [i for i in range(self.beat*4)]
- if data:
- self.clearSequencer()
+ self.clearSequencer()
+ self.startLooking = 1
+ self.startPlayback()
+
+ def handleOverButton( self, widget, data=None ):
+ if not self.startLooking:
+ if widget.get_active() == True and not self.recordState:
+ self.button = 2
self.startLooking = 1
self.startPlayback()
@@ -70,8 +79,8 @@ class MiniSequencer:
self.pitchs = []
self.recordState = 1
self.startLooking = 0
- self.recordButtonState(True)
- self.startPoint = self.csnd.loopGetTick()
+ self.recordButtonState(self.button, True)
+ self.startPoint = int(self.csnd.loopGetTick())
if self.startPoint == 0:
self.startPoint = self.beat * Config.TICKS_PER_BEAT - 1
if self.recordState:
@@ -85,10 +94,10 @@ class MiniSequencer:
return ( onset // 3 ) * 3
elif ( onset % 3 ) == 2:
return ( ( onset // 3 ) + 1 ) * 3
-
+
def adjustDuration( self, pitch, onset ):
if pitch in self.pitchs:
- offset = self.csnd.loopGetTick()
+ offset = int(self.csnd.loopGetTick())
for note in self.sequencer:
if note.pitch == pitch and note.onset == onset:
if offset > note.onset:
@@ -102,22 +111,22 @@ class MiniSequencer:
self.csnd.loopPlay(n,1) #add as active
self.pitchs.remove( pitch )
-
+
def adjustSequencerVolume(self, volume):
self.volume = volume
for n in self.notesList:
- self.csnd.loopUpdate(n, PARAMETER.AMPLITUDE, n.cs.amplitude*self.volume, 1)
+ self.csnd.loopUpdate(n, PARAMETER.AMPLITUDE, n.cs.amplitude*self.volume, 1)
def handleClock( self ):
- currentTick = self.csnd.loopGetTick()
+ currentTick = int(self.csnd.loopGetTick())
t = currentTick / 3
if self.tick != t:
self.tick = t
if self.startLooking:
if self.tick in self.beats:
- self.recordButtonState(True)
+ self.recordButtonState(self.button, True)
if self.tick in self.upBeats:
- self.recordButtonState(False)
+ self.recordButtonState(self.button, False)
if self.recordState:
if currentTick < self.startPoint:
@@ -125,7 +134,6 @@ class MiniSequencer:
if currentTick >= self.startPoint and self.checkOk:
self.checkOk = 0
self.recordState = 0
- self.recordButtonState(False)
+ self.recordButtonState(self.button, False)
return True
-
diff --git a/miniTamTam/miniTamTamMain.py b/miniTamTam/miniTamTamMain.py
index 67cc446..331291a 100644
--- a/miniTamTam/miniTamTamMain.py
+++ b/miniTamTam/miniTamTamMain.py
@@ -42,12 +42,12 @@ from gettext import gettext as _
Tooltips = Config.Tooltips
from SubActivity import SubActivity
-
+
class miniTamTamMain(SubActivity):
-
+
def __init__(self, activity, set_mode):
SubActivity.__init__(self, set_mode)
-
+
self.activity = activity
@@ -68,7 +68,7 @@ class miniTamTamMain(SubActivity):
self.rythmInstrument = 'drum1kit'
self.muteInst = False
self.drumFillin = Fillin( self.beat, self.tempo, self.rythmInstrument, self.reverb, self.drumVolume )
- self.sequencer= MiniSequencer(self.recordStateButton)
+ self.sequencer= MiniSequencer(self.recordStateButton, self.recordOverSensitivity)
self.loop = Loop(self.beat, sqrt( self.instVolume*0.01 ))
self.csnd.loopSetTempo(self.tempo)
self.noteList = []
@@ -80,9 +80,9 @@ class miniTamTamMain(SubActivity):
self.volume = 150
self.csnd.setMasterVolume(self.volume)
self.sequencer.beat = self.beat
- self.loop.beat = self.beat
+ self.loop.beat = self.beat
self.tooltips = gtk.Tooltips()
-
+
self.masterVBox = gtk.VBox()
self.mainWindowBox = gtk.HBox()
self.leftBox = gtk.VBox()
@@ -92,18 +92,18 @@ class miniTamTamMain(SubActivity):
self.mainWindowBox.pack_start(self.leftBox,False,False)
self.masterVBox.pack_start(self.mainWindowBox)
self.add(self.masterVBox)
-
+
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.loopSettingsPopup.add( self.loopSettings )
-
-
+ self.loopSettingsPopup.add( self.loopSettings )
+
+
self.drawInstrumentButtons()
#self.drawSliders()
self.drawGeneration()
@@ -112,8 +112,8 @@ class miniTamTamMain(SubActivity):
self.playStartupSound()
self.synthLabWindow = None
-
-
+
+
self.beatPickup = True
#self.regenerate()
@@ -132,7 +132,7 @@ class miniTamTamMain(SubActivity):
# data packing classes
self.packer = xdrlib.Packer()
self.unpacker = xdrlib.Unpacker("")
-
+
#-- handle forced networking ---------------------------------------
if self.network.isHost():
self.updateSync()
@@ -155,7 +155,7 @@ class miniTamTamMain(SubActivity):
self._recordToolbar.show()
self.activity.connect( "shared", self.shared )
-
+
if os.path.isfile("FORCE_SHARE"): # HOST
r = random.random()
#print "::::: Sharing as TTDBG%f :::::" % r
@@ -169,12 +169,12 @@ class miniTamTamMain(SubActivity):
self.activity.connect( "joined", self.joined )
self.network.setMode( Net.MD_WAIT )
#self.activity.activity_toolbar.share.hide()
-
- def drawSliders( self ):
+
+ def drawSliders( self ):
mainLowBox = gtk.HBox()
mainSliderBox = RoundHBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
mainSliderBox.set_border_width(Config.PANEL_SPACING)
-
+
reverbSliderBox = gtk.HBox()
self.reverbSliderBoxImgTop = gtk.Image()
self.reverbSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'reverb0.png')
@@ -201,7 +201,7 @@ class miniTamTamMain(SubActivity):
balSliderBox.pack_start(balSlider, True, 20)
balSliderBox.pack_start(self.balSliderBoxImgTop, False, padding=0)
self.tooltips.set_tip(balSlider,Tooltips.BAL)
-
+
micRecordBox = gtk.HBox()
for i in [1,2,3,4]:
recordButton = ImageButton(Config.IMAGE_ROOT + 'synthRecord' + str(i) + '.png', Config.IMAGE_ROOT + 'synthRecord' + str(i) + 'Down.png', Config.IMAGE_ROOT + 'synthRecord' + str(i) + 'Over.png')
@@ -209,7 +209,7 @@ class miniTamTamMain(SubActivity):
recordButton.connect("clicked", self.micRec, target)
micRecordBox.pack_start(recordButton, False, False, 2)
self.tooltips.set_tip(recordButton, Tooltips.MT_RECORDBUTTONS[i-1])
-
+
#Transport Button Box
transportBox = RoundHBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
transportBox.set_border_width(Config.PANEL_SPACING)
@@ -225,23 +225,23 @@ class miniTamTamMain(SubActivity):
transportBox.pack_start(closeButton)
self.tooltips.set_tip(self.seqRecordButton,Tooltips.SEQ)
self.tooltips.set_tip(self.playStopButton,Tooltips.PLAY)
-
+
mainSliderBox.pack_start(balSliderBox, padding = 5)
mainSliderBox.pack_start(reverbSliderBox, padding = 5)
mainSliderBox.pack_start(micRecordBox, padding = 5)
-
+
mainLowBox.pack_start(mainSliderBox)
mainLowBox.pack_start(transportBox)
-
- self.masterVBox.pack_start(mainLowBox)
-
+
+ self.masterVBox.pack_start(mainLowBox)
+
def drawGeneration( self ):
slidersBox = RoundVBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
slidersBox.set_border_width(Config.PANEL_SPACING)
geneButtonBox = RoundHBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS)
geneButtonBox.set_border_width(Config.PANEL_SPACING)
-
+
geneSliderBox = gtk.VBox()
self.geneSliderBoxImgTop = gtk.Image()
self.geneSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'complex6.png')
@@ -254,7 +254,7 @@ class miniTamTamMain(SubActivity):
geneSliderBox.pack_start(self.geneSliderBoxImgTop, False, padding=10)
geneSliderBox.pack_start(geneSlider, True, 20)
self.tooltips.set_tip(geneSlider,Tooltips.COMPL)
-
+
beatSliderBox = gtk.VBox()
self.beatSliderBoxImgTop = gtk.Image()
self.beatSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'beat3.png')
@@ -270,7 +270,7 @@ class miniTamTamMain(SubActivity):
self.delayedTempo = 0 # used to store tempo updates while the slider is active
self.tempoSliderActive = False
-
+
tempoSliderBox = gtk.VBox()
self.tempoSliderBoxImgTop = gtk.Image()
self.tempoSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'tempo5.png')
@@ -297,31 +297,28 @@ class miniTamTamMain(SubActivity):
volumeSliderBox.pack_start(self.volumeSliderBoxImgTop, False, padding=10)
volumeSliderBox.pack_start(volumeSlider, True)
self.tooltips.set_tip(volumeSlider,Tooltips.VOL)
-
-
- slidersBoxSub = gtk.HBox()
+
+
+ slidersBoxSub = gtk.HBox()
slidersBoxSub.pack_start(beatSliderBox)
slidersBoxSub.pack_start(geneSliderBox)
slidersBoxSub.pack_start(tempoSliderBox)
slidersBoxSub.pack_start(volumeSliderBox)
slidersBox.pack_start(slidersBoxSub)
-
+
generateBtnSub = gtk.HBox()
generateBtn = ImageButton(Config.IMAGE_ROOT + 'dice.png', clickImg_path = Config.IMAGE_ROOT + 'diceblur.png')
generateBtn.connect('button-press-event', self.handleGenerateBtn)
- self.loopSettingsBtn = ImageToggleButton(Config.IMAGE_ROOT + 'dice.png', Config.IMAGE_ROOT + 'diceblur.png')
- self.loopSettingsBtn.connect('toggled', self.handleLoopSettingsBtn)
- generateBtnSub.pack_start(self.loopSettingsBtn)
generateBtnSub.pack_start(generateBtn)
slidersBox.pack_start(generateBtnSub)
self.tooltips.set_tip(generateBtn,Tooltips.GEN)
-
- #Generation Button Box
+
+ #Generation Button Box
geneVBox = gtk.VBox()
geneTopBox = gtk.HBox()
geneMidBox = gtk.HBox()
geneLowBox = gtk.HBox()
-
+
generationDrumBtn1 = ImageRadioButton(group = None , mainImg_path = Config.IMAGE_ROOT + 'drum1kit.png' , altImg_path = Config.IMAGE_ROOT + 'drum1kitselgen.png')
generationDrumBtn1.connect('clicked' , self.handleGenerationDrumBtn , 'drum1kit')
geneTopBox.pack_start(generationDrumBtn1)
@@ -346,27 +343,27 @@ class miniTamTamMain(SubActivity):
self.tooltips.set_tip(generationDrumBtn3,Tooltips.AFRI)
self.tooltips.set_tip(generationDrumBtn4,Tooltips.ELEC)
self.tooltips.set_tip(generationDrumBtn5,Tooltips.BRES)
-
+
self.rightBox.pack_start(slidersBox, True)
self.rightBox.pack_start(geneButtonBox, True)
def loopSettingsChannel(self, channel, value):
self.csnd.setChannel(channel, value)
-
+
def loopSettingsPlayStop(self, state, loop):
if not state:
if loop:
self.csnd.inputMessage(Config.CSOUND_PLAY_LS_NOTE % 5022)
else:
- self.csnd.inputMessage(Config.CSOUND_PLAY_LS_NOTE % 5023)
+ self.csnd.inputMessage(Config.CSOUND_PLAY_LS_NOTE % 5023)
else:
if loop:
self.csnd.inputMessage(Config.CSOUND_STOP_LS_NOTE)
-
+
def doneLoopSettingsPopup(self):
- if self.loopSettingsBtn.get_active():
- self.loopSettingsBtn.set_active(False)
-
+ if self._recordToolbar.loopSetButton.get_active():
+ self._recordToolbar.loopSetButton.set_active(False)
+
def handleLoopSettingsBtn(self, widget, data=None):
if widget.get_active():
@@ -375,16 +372,16 @@ class miniTamTamMain(SubActivity):
#filter = gtk.FileFilter()
#filter.add_pattern('*.wav')
#chooser.set_filter(filter)
- chooser.set_current_folder(Config.PREF_DIR)
+ 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:
+ try:
tempName = chooser.get_filename()
soundName = os.path.split(tempName)[1]
- except IOError:
+ except IOError:
print 'ERROR: failed to load Sound from file %s' % chooser.get_filename()
chooser.destroy()
results = commands.getstatusoutput("csound -U sndinfo %s" % tempName)
@@ -397,17 +394,17 @@ class miniTamTamMain(SubActivity):
self.loopSettingsPopup.move( 600, 200 )
self.timeoutLoad = gobject.timeout_add(1000, self.load_ls_instrument, soundName)
else:
- self.loopSettingsPopup.hide()
+ self.loopSettingsPopup.hide()
def load_ls_instrument(self, name):
self.csnd.load_ls_instrument(name)
gobject.source_remove( self.timeoutLoad )
-
+
def drawInstrumentButtons(self):
self.instrumentPanelBox = gtk.HBox()
# InstrumentPanel(elf.setInstrument,self.playInstrumentNote, False, self.micRec, self.synthRec)
self.leftBox.pack_start(self.instrumentPanelBox,True,True)
-
+
def setInstrumentPanel( self, instrumentPanel ):
instrumentPanel.configure( self.setInstrument,self.playInstrumentNote, False, self.micRec, self.synthRec )
self.instrumentPanel = instrumentPanel
@@ -417,29 +414,35 @@ class miniTamTamMain(SubActivity):
self.instrumentPanelBox.remove( self.instrumentPanel )
def micRec(self, widget, mic):
- os.system('rm ' + Config.PREF_DIR + '/' + mic)
+ os.system('rm ' + Config.SNDS_DIR + '/' + mic)
self.csnd.inputMessage("i5600 0 4")
- (s1,o1) = commands.getstatusoutput("arecord -f S16_LE -t wav -r 16000 -d 4 " + Config.PREF_DIR + "/tempMic.wav")
+ (s1,o1) = commands.getstatusoutput("arecord -f S16_LE -t wav -r 16000 -d 4 " + Config.SNDS_DIR + "/tempMic.wav")
(s2, o2) = commands.getstatusoutput("csound " + Config.FILES_DIR + "/crop.csd")
- (s3, o3) = commands.getstatusoutput("mv " + Config.PREF_DIR + "/micTemp " + Config.PREF_DIR + "/" + mic)
- (s4, o4) = commands.getstatusoutput("rm " + Config.PREF_DIR + "/tempMic.wav")
+ (s3, o3) = commands.getstatusoutput("mv " + Config.SNDS_DIR + "/micTemp " + Config.SNDS_DIR + "/" + mic)
+ (s4, o4) = commands.getstatusoutput("rm " + Config.SNDS_DIR + "/tempMic.wav")
self.micTimeout = gobject.timeout_add(200, self.loadMicInstrument, mic)
self.instrumentPanel.set_activeInstrument(mic,True)
self.setInstrument(mic)
-
+
def synthRec(self,lab):
if self.synthLabWindow != None:
self.synthLabWindow.destroy()
self.synthLabWindow =None
- self.synthLabWindow = SynthLabWindow(
+ self.synthLabWindow = SynthLabWindow(
{'lab1':86, 'lab2':87, 'lab3':88, 'lab4':89}[lab],
self.closeSynthLab)
self.synthLabWindow.show_all()
- def recordStateButton( self, state ):
- self._recordToolbar.keyboardRecButton.set_active( state )
-
+ def recordStateButton( self, button, state ):
+ if button == 1:
+ self._recordToolbar.keyboardRecButton.set_active( state )
+ else:
+ 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')
@@ -474,18 +477,19 @@ class miniTamTamMain(SubActivity):
self.csnd.loopPlay(n,1) #add as active
self.csnd.loopSetNumTicks( self.beat * Config.TICKS_PER_BEAT)
self.drumFillin.unavailable( noteOnsets, notePitchs )
+ self.recordOverSensitivity( False )
def adjustDrumVolume(self):
for n in self.noteList:
self.csnd.loopUpdate(n[1], PARAMETER.AMPLITUDE, n[1].cs.amplitude*self.drumVolume, 1)
-
+
def handleClose(self,widget):
if self.playStopButton.get_active() == True:
- self.playStopButton.set_active(False)
+ self.playStopButton.set_active(False)
self.sequencer.clearSequencer()
self.csnd.loopClear()
self.set_mode('quit')
-
+
def handleGenerationSlider(self, adj):
img = int(adj.value * 7)+1
self.geneSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'complex' + str(img) + '.png')
@@ -504,14 +508,14 @@ class miniTamTamMain(SubActivity):
self.sequencer.beat = self.beat
self.loop.beat = self.beat
self.drumFillin.setBeats( self.beat )
-
+
def handleBeatSlider(self, adj):
img = self.scale(int(adj.value),2,12,1,11)
self.beatSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'beat' + str(img) + '.png')
self.sequencer.beat = self.beat
self.loop.beat = self.beat
self.drumFillin.setBeats( self.beat )
-
+
def handleBeatSliderRelease(self, widget, event):
self.beat = int(widget.get_adjustment().value)
self.sequencer.beat = self.beat
@@ -538,7 +542,7 @@ class miniTamTamMain(SubActivity):
def handleTempoSliderChange(self,adj):
if self.network.isPeer():
self.requestTempoChange(int(adj.value))
- else:
+ else:
self._updateTempo( int(adj.value) )
def _updateTempo( self, val ):
@@ -547,18 +551,18 @@ class miniTamTamMain(SubActivity):
t = time.time()
percent = self.heartbeatElapsed() / self.beatDuration
- self.tempo = val
+ self.tempo = val
self.beatDuration = 60.0/self.tempo
self.ticksPerSecond = Config.TICKS_PER_BEAT*self.tempo/60.0
self.csnd.loopSetTempo(self.tempo)
- self.sequencer.tempo = self.tempo
+ self.sequencer.tempo = self.tempo
self.drumFillin.setTempo(self.tempo)
if self.network.isHost():
self.heatbeatStart = t - percent*self.beatDuration
self.updateSync()
self.sendTempoUpdate()
-
+
img = int(self.scale( self.tempo,
Config.PLAYER_TEMPO_LOWER,Config.PLAYER_TEMPO_UPPER,
1,8))
@@ -576,7 +580,7 @@ class miniTamTamMain(SubActivity):
self._playToolbar.balanceSliderImgLeft.set_from_file(Config.IMAGE_ROOT + 'dru' + str(img) + '.png')
img2 = int(self.scale(self.instVolume,0,100,0,4.9))
self._playToolbar.balanceSliderImgRight.set_from_file(Config.IMAGE_ROOT + 'instr' + str(img2) + '.png')
-
+
def handleReverbSlider(self, adj):
self.reverb = adj.value
self.drumFillin.setReverb( self.reverb )
@@ -589,7 +593,7 @@ class miniTamTamMain(SubActivity):
self.csnd.setMasterVolume(self.volume)
img = int(self.scale(self.volume,0,200,0,3.9))
self.volumeSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'volume' + str(img) + '.png')
-
+
def handlePlayButton(self, widget, data = None):
# use widget.get_active() == False when calling this on 'clicked'
# use widget.get_active() == True when calling this on button-press-event
@@ -616,24 +620,24 @@ class miniTamTamMain(SubActivity):
for (o,n) in self.noteList :
self.csnd.loopUpdate(n, NoteDB.PARAMETER.INSTRUMENT, instrumentId, -1)
self.drumFillin.setInstrument( self.rythmInstrument )
-
+
def handleGenerateBtn(self , widget , data=None):
self.regenerate()
if not self._playToolbar.playButton.get_active():
- self._playToolbar.playButton.set_active(True)
+ self._playToolbar.playButton.set_active(True)
- #this calls sends a 'clicked' event,
+ #this calls sends a 'clicked' event,
#which might be connected to handlePlayButton
self.playStartupSound()
def enableKeyboard( self ):
- self.keyboardStandAlone = KeyboardStandAlone( self.sequencer.recording, self.sequencer.adjustDuration, self.csnd.loopGetTick, self.sequencer.getPlayState, self.loop )
+ self.keyboardStandAlone = KeyboardStandAlone( self.sequencer.recording, self.sequencer.adjustDuration, self.csnd.loopGetTick, self.sequencer.getPlayState, self.loop )
self.add_events(gtk.gdk.BUTTON_PRESS_MASK)
-
+
def setInstrument( self , instrument ):
self.instrument = instrument
self.keyboardStandAlone.setInstrument(instrument)
-
+
def playInstrumentNote(self , instrument, secs_per_tick = 0.025):
if not self.muteInst:
self.csnd.play(
@@ -648,7 +652,7 @@ class miniTamTamMain(SubActivity):
tied = False,
mode = 'mini'),
secs_per_tick)
-
+
def onKeyPress(self, widget, event):
if event.hardware_keycode == 219: #'/*' button to reset drum loop
if self.playStopButton.get_active() == True:
@@ -662,19 +666,19 @@ class miniTamTamMain(SubActivity):
self.muteInst = False
else:
self.muteInst = True
-
+
if event.hardware_keycode == 65: #what key is this? what feature is this?
pass
#if self.playStopButton.get_active():
#self.playStopButton.set_active(False)
#else:
#self.playStopButton.set_active(True)
-
+
self.keyboardStandAlone.onKeyPress(widget, event, sqrt( self.instVolume*0.01 ))
def onKeyRelease(self, widget, event):
self.keyboardStandAlone.onKeyRelease(widget, event)
-
+
def playStartupSound(self):
r = str(random.randrange(1,11))
self.playInstrumentNote('guidice' + r)
@@ -691,12 +695,12 @@ class miniTamTamMain(SubActivity):
def onDestroy( self ):
self.network.shutdown()
-
+
def scale(self, input,input_min,input_max,output_min,output_max):
range_input = input_max - input_min
range_output = output_max - output_min
result = (input - input_min) * range_output / range_input + output_min
-
+
if (input_min > input_max and output_min > output_max) or (output_min > output_max and input_min < input_max):
if result > output_min:
return output_min
@@ -704,7 +708,7 @@ class miniTamTamMain(SubActivity):
return output_max
else:
return result
-
+
if (input_min < input_max and output_min < output_max) or (output_min < output_max and input_min > input_max):
if result > output_max:
return output_max
@@ -712,8 +716,8 @@ class miniTamTamMain(SubActivity):
return output_min
else:
return result
-
-
+
+
#-----------------------------------------------------------------------
# Network
@@ -786,7 +790,7 @@ class miniTamTamMain(SubActivity):
if not self.syncTimeout:
self.syncTimeout = gobject.timeout_add( 1000, self.updateSync )
self.sendTempoQuery()
-
+
def processHT_SYNC_REPLY( self, sock, message, data ):
t = time.time()
hash = data[0:4]
@@ -809,7 +813,7 @@ class miniTamTamMain(SubActivity):
self._updateTempo( val )
self.tempoAdjustment.handler_unblock( self.tempoAdjustmentHandler )
self.sendSyncQuery()
-
+
def processPR_SYNC_QUERY( self, sock, message, data ):
self.packer.pack_float(self.nextHeartbeat())
self.network.send( Net.HT_SYNC_REPLY, data + self.packer.get_buffer(), sock )
@@ -846,7 +850,7 @@ class miniTamTamMain(SubActivity):
def heartbeatElapsedTicks( self ):
delta = time.time() - self.heartbeatStart
return self.ticksPerSecond*(delta % self.beatDuration)
-
+
def updateSync( self ):
if self.network.isOffline():
return False
@@ -863,7 +867,7 @@ class miniTamTamMain(SubActivity):
curTicksIn = curTick % Config.TICKS_PER_BEAT
ticksIn = self.heartbeatElapsedTicks()
err = curTicksIn - ticksIn
- if err > Config.TICKS_PER_BEAT_DIV2:
+ if err > Config.TICKS_PER_BEAT_DIV2:
err -= Config.TICKS_PER_BEAT
elif err < -Config.TICKS_PER_BEAT_DIV2:
err += Config.TICKS_PER_BEAT
@@ -876,9 +880,9 @@ class miniTamTamMain(SubActivity):
#print "correct:: %f ticks, %f ticks in, %f expected, %f err, correct %f" % (curTick, curTicksIn, ticksIn, err, correct)
if abs(err) > 0.25:
self.csnd.loopAdjustTick(-err)
-
-if __name__ == "__main__":
+
+if __name__ == "__main__":
MiniTamTam = miniTamTam()
#start the gtk event loop
gtk.main()
diff --git a/miniTamTam/miniToolbars.py b/miniTamTam/miniToolbars.py
index d066f07..90088a8 100644
--- a/miniTamTam/miniToolbars.py
+++ b/miniTamTam/miniToolbars.py
@@ -10,16 +10,17 @@ from gettext import gettext as _
class playToolbar(gtk.Toolbar):
def __init__(self,toolbox, miniTamTam):
gtk.Toolbar.__init__(self)
-
- def _insertSeparator():
- self.separator = gtk.SeparatorToolItem()
- self.separator.set_draw(True)
- self.insert(self.separator,-1)
- self.separator.show()
-
+
+ def _insertSeparator(x = 1):
+ for i in range(x):
+ self.separator = gtk.SeparatorToolItem()
+ self.separator.set_draw(True)
+ self.insert(self.separator,-1)
+ self.separator.show()
+
self.toolbox = toolbox
self.miniTamTam = miniTamTam
-
+
self.tooltips = gtk.Tooltips()
self.playButton = ToggleToolButton('play')
@@ -27,11 +28,9 @@ class playToolbar(gtk.Toolbar):
self.insert(self.playButton, -1)
self.playButton.show()
self.playButton.set_tooltip(_('Play / Stop'))
-
- _insertSeparator()
- _insertSeparator()
- _insertSeparator()
-
+
+ _insertSeparator(3)
+
self.balanceSliderImgLeft = gtk.Image()
self.balanceSliderImgRight = gtk.Image()
self.balanceSliderImgLeft.set_from_file(Config.IMAGE_ROOT + 'dru2.png')
@@ -39,7 +38,7 @@ class playToolbar(gtk.Toolbar):
self.balanceSliderImgLeftTool = gtk.ToolItem()
self.balanceSliderImgLeftTool.add(self.balanceSliderImgLeft)
self.balanceSliderImgRightTool = gtk.ToolItem()
- self.balanceSliderImgRightTool.add(self.balanceSliderImgRight)
+ self.balanceSliderImgRightTool.add(self.balanceSliderImgRight)
self.balanceSliderAdj = gtk.Adjustment(value=50, lower=0, upper=100, step_incr=1, page_incr=0, page_size=0)
self.balanceSliderAdj.connect("value_changed" , self.miniTamTam.handleBalanceSlider)
self.balanceSlider = gtk.HScale(adjustment = self.balanceSliderAdj)
@@ -58,10 +57,9 @@ class playToolbar(gtk.Toolbar):
self.balanceSlider.show()
self.balanceSliderTool.show()
self.balanceSliderTool.set_tooltip(self.tooltips, _('Balance'))
-
- _insertSeparator()
- _insertSeparator()
-
+
+ _insertSeparator(2)
+
self.reverbSliderImgRight = gtk.Image()
self.reverbSliderImgRight.set_from_file(Config.IMAGE_ROOT + 'reverb0.png')
self.reverbSliderImgRightTool = gtk.ToolItem()
@@ -82,65 +80,65 @@ class playToolbar(gtk.Toolbar):
self.reverbSlider.show()
self.reverbSliderTool.show()
self.reverbSliderTool.set_tooltip(self.tooltips, _('Reverb'))
-
-
+
+
class recordToolbar(gtk.Toolbar):
def __init__(self,toolbox, miniTamTam):
gtk.Toolbar.__init__(self)
-
- def _insertSeparator():
- self.separator = gtk.SeparatorToolItem()
- self.separator.set_draw(True)
- self.insert(self.separator,-1)
- self.separator.show()
-
+
+ def _insertSeparator(x = 1):
+ for i in range(x):
+ self.separator = gtk.SeparatorToolItem()
+ self.separator.set_draw(True)
+ self.insert(self.separator,-1)
+ self.separator.show()
+
self.toolbox = toolbox
self.miniTamTam = miniTamTam
-
+
self.micRec1Button = ToolButton('rec1')
self.micRec1Button.connect('clicked',self.miniTamTam.micRec,'mic1')
self.insert(self.micRec1Button, -1)
self.micRec1Button.show()
self.micRec1Button.set_tooltip(_('Record microphone into slot 1'))
-
+
self.micRec2Button = ToolButton('rec2')
self.micRec2Button.connect('clicked',self.miniTamTam.micRec,'mic2')
self.insert(self.micRec2Button, -1)
self.micRec2Button.show()
self.micRec2Button.set_tooltip(_('Record microphone into slot 2'))
-
+
self.micRec3Button = ToolButton('rec3')
self.micRec3Button.connect('clicked',self.miniTamTam.micRec,'mic3')
self.insert(self.micRec3Button, -1)
self.micRec3Button.show()
self.micRec3Button.set_tooltip(_('Record microphone into slot 3'))
-
+
self.micRec4Button = ToolButton('rec4')
self.micRec4Button.connect('clicked',self.miniTamTam.micRec,'mic4')
self.insert(self.micRec4Button, -1)
self.micRec4Button.show()
self.micRec4Button.set_tooltip(('Record microphone into slot 4'))
-
- _insertSeparator()
- _insertSeparator()
-
+
+ _insertSeparator(12)
+
self.keyboardRecButton = ToggleToolButton('keyrec')
- self.keyboardRecButton.connect('clicked', self.miniTamTam.sequencer.handleRecordButton, True)
+ self.keyboardRecButton.connect('clicked', self.miniTamTam.sequencer.handleRecordButton )
self.insert(self.keyboardRecButton, -1)
self.keyboardRecButton.show()
self.keyboardRecButton.set_tooltip(_('Click to record a loop'))
-
+
self.keyboardRecOverButton = ToggleToolButton('overrec')
- self.keyboardRecOverButton.connect('clicked', self.miniTamTam.sequencer.handleRecordButton, False)
+ self.keyboardRecOverButton.connect('clicked', self.miniTamTam.sequencer.handleOverButton )
self.insert(self.keyboardRecOverButton, -1)
self.keyboardRecOverButton.show()
self.keyboardRecOverButton.set_tooltip(_('Click to add a loop'))
-
- _insertSeparator()
- _insertSeparator()
-
+ self.keyboardRecOverButton.set_sensitive(False)
+
+ _insertSeparator(2)
+
self.loopSetButton = ToggleToolButton('loop')
- #self.loopSetButton.connect('clicked', self.miniTamTam.changeme)
+ self.loopSetButton.connect('clicked', self.miniTamTam.handleLoopSettingsBtn)
self.insert(self.loopSetButton, -1)
self.loopSetButton.show()
self.loopSetButton.set_tooltip(_('Add new sound')) \ No newline at end of file