Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Edit/MainWindow.py140
-rwxr-xr-xTamTam.py1
-rw-r--r--Util/CSoundClient.py8
-rw-r--r--Util/Trackpad.py43
4 files changed, 99 insertions, 93 deletions
diff --git a/Edit/MainWindow.py b/Edit/MainWindow.py
index aa99de3..1626fc8 100644
--- a/Edit/MainWindow.py
+++ b/Edit/MainWindow.py
@@ -32,7 +32,9 @@ from Edit.TrackInterface import TrackInterface, TrackInterfaceParasite
from Edit.TuneInterface import TuneInterface, TuneInterfaceParasite
from Generation.Generator import generator1, variate, GenerationParameters
+
Tooltips = Config.Tooltips()
+KEY_MAP_PIANO = Config.KEY_MAP_PIANO
#-----------------------------------
# The main TamTam window
@@ -296,8 +298,11 @@ class MainWindow( SubActivity ):
self.GUI["2toolPanel"].pack_start( self.GUI["2contextBox"], False )
# + + transport box
self.GUI["2transportBox"] = formatRoundBox( RoundHBox(), Config.BG_COLOR )
- self.GUI["2recordButton"] = ImageButton( Config.IMAGE_ROOT+"record.png", Config.IMAGE_ROOT+"recordsel.png", Config.IMAGE_ROOT+"recordsel.png", backgroundFill = Config.BG_COLOR )
+ self.GUI["2keyRecordButton"] = ImageToggleButton( Config.IMAGE_ROOT+"record2.png", Config.IMAGE_ROOT+"record2sel.png", Config.IMAGE_ROOT+"record2sel.png", backgroundFill = Config.BG_COLOR )
+ self.GUI["2keyRecordButton"].connect("clicked", self.handleKeyboardRecordButton )
+ self.GUI["2recordButton"] = ImageToggleButton( Config.IMAGE_ROOT+"record.png", Config.IMAGE_ROOT+"recordsel.png", Config.IMAGE_ROOT+"recordsel.png", backgroundFill = Config.BG_COLOR )
self.GUI["2recordButton"].connect("clicked", self.handleAudioRecord )
+ self.GUI["2transportBox"].pack_start( self.GUI["2keyRecordButton"] )
self.GUI["2transportBox"].pack_start( self.GUI["2recordButton"] )
self.GUI["2playpauseBox"] = gtk.HBox()
self.GUI["2playpauseBox"].set_size_request( 90, -1 )
@@ -429,9 +434,7 @@ class MainWindow( SubActivity ):
SubActivity.__init__( self, set_mode )
# keyboard variables
- self.kb_active = False
self.kb_record = False
- self.kb_mono = False
self.kb_keydict = {}
# playback params
@@ -574,25 +577,27 @@ class MainWindow( SubActivity ):
self.csnd.loopUpdate(n, NoteDB.PARAMETER.DURATION, n.cs.duration , 1)
def handleAudioRecord( self, widget, data=None ):
- chooser = gtk.FileChooserDialog(
+ if widget.get_active() == True:
+ chooser = gtk.FileChooserDialog(
title='Save tune as Audio file',
action=gtk.FILE_CHOOSER_ACTION_SAVE,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK))
- filter = gtk.FileFilter()
- filter.add_pattern('*.ogg')
- chooser.set_filter(filter)
- chooser.set_current_folder(Config.TUNE_DIR)
-
- for f in chooser.list_shortcut_folder_uris():
- chooser.remove_shortcut_folder_uri(f)
-
- if chooser.run() == gtk.RESPONSE_OK:
- self.audioRecordState = True
- self.audioFileName = chooser.get_filename()
- if self.audioFileName[-4:] != '.ogg':
- self.audioFileName += '.ogg'
-
- chooser.destroy()
+ filter = gtk.FileFilter()
+ filter.add_pattern('*.ogg')
+ chooser.set_filter(filter)
+ chooser.set_current_folder(Config.TUNE_DIR)
+
+ for f in chooser.list_shortcut_folder_uris():
+ chooser.remove_shortcut_folder_uri(f)
+
+ if chooser.run() == gtk.RESPONSE_OK:
+ self.audioRecordState = True
+ self.audioFileName = chooser.get_filename()
+ if self.audioFileName[-4:] != '.ogg':
+ self.audioFileName += '.ogg'
+ chooser.destroy()
+ else:
+ self.audioRecordState = False
def handlePlay( self, widget ):
@@ -656,8 +661,6 @@ class MainWindow( SubActivity ):
self.predrawTimeout = False
self.playbackTimeout = gobject.timeout_add( 50, self.onTimeout )
- #self.kb_record = self.GUI["2playButton"].get_active() and self.GUI["2recordButton"].get_active()
-
def handleStop( self, widget, rewind = True ):
widget.event( gtk.gdk.Event( gtk.gdk.LEAVE_NOTIFY ) ) # fake the leave event
@@ -690,6 +693,7 @@ class MainWindow( SubActivity ):
time.sleep(0.1)
self.waitToSet()
self.csnd.load_instruments()
+ self.GUI["2recordButton"].set_active(False)
self.playing = False
if rewind: self.handleRewind()
@@ -799,12 +803,8 @@ class MainWindow( SubActivity ):
if self.GUI["2toolPointerButton"].get_active(): return "default"
else: return "draw"
- def onKeyboardButton( self, widget, data ):
- self.kb_active = widget.get_active()
-
- def onKeyboardRecordButton( self, widget, data ):
-
- self.kb_record = self.GUI["playButton"].get_active() and self.GUI["2recordButton"].get_active()
+ def handleKeyboardRecordButton( self, widget, data ):
+ self.kb_record = self.GUI["2keyRecordButton"].get_active()
def pickInstrument( self, widget, num ):
if widget.get_active(): # show the panel
@@ -1428,71 +1428,67 @@ class MainWindow( SubActivity ):
key = event.hardware_keycode
- if not self.kb_active:
- return
- if self.kb_record:
- self.kb_mono = False
-
# If the key is already in the dictionnary, exit function (to avoir key repeats)
if self.kb_keydict.has_key(key):
return
# Assign on which track the note will be created according to the number of keys pressed
- track = len(self.kb_keydict)+10
- if self.kb_mono:
- track = 10
+ track = len(self.kb_keydict)
# If the pressed key is in the keymap
- if KEY_MAP.has_key(key):
+ if KEY_MAP_PIANO.has_key(key):
# CsoundNote parameters
- onset = self.getCurrentTick()
- pitch = KEY_MAP[key]
+ onset = self.csnd.loopGetTick()
+ pitch = KEY_MAP_PIANO[key]
duration = -1
- instrument = self.trackInstrument[0].name
+
# get instrument from top selected track if a track is selected
- if self.getSelectedtrackIds():
- instrument = self.trackInstrument[min(self.getSelectedtrackIds())].name
- if instrument == 'drum1kit':
- if GenerationConfig.DRUMPITCH.has_key( pitch ):
- instrument = Config.DRUM1INSTRUMENTS[ GenerationConfig.DRUMPITCH[ pitch ] ]
- else:
- instrument = Config.DRUM1INSTRUMENTS[ pitch ]
- pitch = 36
- duration = 100
+ if True in self.trackSelected:
+ index = self.trackSelected.index(True)
+ instrument = self.getTrackInstrument(index).name
+ else:
+ return
- if Config.INSTRUMENTS[instrument].csoundInstrumentID == 102:
+ if instrument[0:4] == 'drum':
+ track = index
+ if GenerationConstants.DRUMPITCH.has_key( pitch ):
+ pitch = GenerationConstants.DRUMPITCH[pitch]
+ if Config.INSTRUMENTS[instrument].kit != None:
+ instrument = Config.INSTRUMENTS[instrument].kit[pitch].name
+ pitch = 36
duration = 100
# Create and play the note
- self.kb_keydict[key] = CSoundNote(onset = 0,
- pitch = pitch,
- amplitude = 1,
- pan = 0.5,
- duration = duration,
- trackId = track,
- instrument = instrument,
- instrumentFlag = instrument)
- self.kb_keydict[key].playNow()
+ self.kb_keydict[key] = CSoundNote(onset = 0,
+ pitch = pitch,
+ amplitude = 1,
+ pan = 0.5,
+ duration = duration,
+ trackId = track,
+ instrumentId = Config.INSTRUMENTS[instrument].instrumentId,
+ tied = True,
+ mode = 'mini')
+ self.csnd.play(self.kb_keydict[key], 0.3)
def onKeyRelease(self,widget,event):
Config.ModKeys.keyRelease( event.hardware_keycode )
- if not self.kb_active:
- return
key = event.hardware_keycode
- if KEY_MAP.has_key(key):
- self.kb_keydict[key].duration = 0
- self.kb_keydict[key].amplitude = 0
- self.kb_keydict[key].nchanges += 1
- self.kb_keydict[key].playNow()
- if self.kb_record and len( self.getSelectedtrackIds() ) != 0:
- if (Config.DEBUG > 1) : print "ERROR: discarding recorded note "
- if False:
- curtick = something
- self.kb_keydict[key].duration = curtick - self.kb_keydict[key].onset
- self.kb_keydict[key].amplitude = 1.0
- self.kb_keydict[key].nchanges += 1
+ if True in self.trackSelected:
+ index = self.trackSelected.index(True)
+ else:
+ return
+
+
+ if KEY_MAP_PIANO.has_key(key):
+ csnote = self.kb_keydict[key]
+ if Config.INSTRUMENTSID[ csnote.instrumentId ].csoundInstrumentId == Config.INST_TIED:
+ csnote.duration = 0.5
+ csnote.amplitude = 0
+ csnote.decay = 0.7
+ csnote.tied = True
+ self.csnd.play(self.kb_keydict[key], 0.3)
del self.kb_keydict[key]
def delete_event( self, widget, event, data = None ):
diff --git a/TamTam.py b/TamTam.py
index 8a56f4b..0e718e1 100755
--- a/TamTam.py
+++ b/TamTam.py
@@ -90,6 +90,7 @@ class TamTam(Activity):
self.remove( self.modeList[ self.mode ] )
self.mode = None
+ self.trackpad.setContext(mode)
if mode == 'welcome':
if not (mode in self.modeList):
diff --git a/Util/CSoundClient.py b/Util/CSoundClient.py
index f4c8d84..64e4521 100644
--- a/Util/CSoundClient.py
+++ b/Util/CSoundClient.py
@@ -256,7 +256,12 @@ class _CSoundClientPlugin:
instrument_id_offset = 0
elif instrument.csoundInstrumentId == Config.INST_TIED and not tied and mode == 'mini':
instrument_id_offset = 0
- elif instrument.csoundInstrumentId == Config.INST_TIED and mode == 'edit':
+ elif instrument.csoundInstrumentId == Config.INST_TIED and tied and mode == 'edit' and duration < 0:
+ duration = -1
+ instrument_id_offset = 0
+ elif instrument.csoundInstrumentId == Config.INST_TIED and tied and mode == 'edit' and duration > 0:
+ instrument_id_offset = 0
+ elif instrument.csoundInstrumentId == Config.INST_TIED and not tied and mode == 'edit':
instrument_id_offset = 100
if instrument.csoundInstrumentId == Config.INST_SIMP and mode == 'mini':
@@ -283,6 +288,7 @@ class _CSoundClientPlugin:
instrument.loopStart,
instrument.loopEnd,
instrument.crossDur ])
+ print a
return a
diff --git a/Util/Trackpad.py b/Util/Trackpad.py
index 8d92b4a..85fc169 100644
--- a/Util/Trackpad.py
+++ b/Util/Trackpad.py
@@ -34,7 +34,9 @@ class Trackpad:
self.display = self.win.get_display()
self.screen = gtk.gdk.Display.get_default_screen(self.display)
-
+ def setContext(self, context):
+ self.context = context
+
def create_invisible_cursor(self):
pix_data = """/* XPM */
static char * invisible_xpm[] = {
@@ -46,27 +48,28 @@ class Trackpad:
self.invisible_cursor = gtk.gdk.Cursor(pix,pix,color,color,0,0)
def handle_motion(self,widget,event):
- if event.x < 0:
- X = 0
- elif event.x > self.screen.get_width():
- X = self.screen.get_width()
- else:
- X = event.x
+ if self.context != 'edit':
+ if event.x < 0:
+ X = 0
+ elif event.x > self.screen.get_width():
+ X = self.screen.get_width()
+ else:
+ X = event.x
- if event.y < 0:
- Y = 0
- elif event.y > self.screen.get_height():
- Y = self.screen.get_height()
- else:
- Y = event.y
+ if event.y < 0:
+ Y = 0
+ elif event.y > self.screen.get_height():
+ Y = self.screen.get_height()
+ else:
+ Y = event.y
- self.current_x = X
- self.current_y = Y
- if self.buttonPressed:
- self.final_x = X - self.first_x
- self.final_y = Y - self.first_y
- self.csnd.setTrackpadX(self.final_x)
- self.csnd.setTrackpadY(self.final_y)
+ self.current_x = X
+ self.current_y = Y
+ if self.buttonPressed:
+ self.final_x = X - self.first_x
+ self.final_y = Y - self.first_y
+ self.csnd.setTrackpadX(self.final_x)
+ self.csnd.setTrackpadY(self.final_y)
def handle_keyPress(self,widget,event):
if KEY_MAP_PIANO.has_key(event.hardware_keycode) and self.buttonPressed == False: