diff options
author | Oli <olivier.belanger@umontreal.ca> | 2007-10-26 05:50:30 (GMT) |
---|---|---|
committer | Oli <olivier.belanger@umontreal.ca> | 2007-10-26 05:50:30 (GMT) |
commit | 9583b21dae8041c6544fb37de00ca42b034ebc98 (patch) | |
tree | 4c37d754cdaa5b332969f7fc30f0bba31025d006 | |
parent | 3aebf3dad1f5c137a5182cfe06b8edc778a5ddb9 (diff) |
miniT tabs cleanup, loop settings moved to Jam
23 files changed, 755 insertions, 127 deletions
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) diff --git a/TamTamJam.activity/Jam/JamMain.py b/TamTamJam.activity/Jam/JamMain.py index 9eb89fd..769674c 100644 --- a/TamTamJam.activity/Jam/JamMain.py +++ b/TamTamJam.activity/Jam/JamMain.py @@ -4,7 +4,7 @@ pygtk.require( '2.0' ) import gtk import pango -import os, sys, shutil +import os, sys, shutil, commands import common.Util.Instruments import common.Config as Config @@ -14,7 +14,7 @@ import sugar.graphics.style as style from Jam.Desktop import Desktop import Jam.Picker as Picker import common.Util.Block as Block -from Jam.Toolbars import JamToolbar, DesktopToolbar +from Jam.Toolbars import JamToolbar, DesktopToolbar, recordToolbar from common.Util.CSoundNote import CSoundNote @@ -199,7 +199,9 @@ class JamMain(gtk.EventBox): self.activity.toolbox.add_toolbar( _("Jam"), self.jamToolbar ) self.desktopToolbar = DesktopToolbar( self ) + self.recordToolbar = recordToolbar( self ) self.activity.toolbox.add_toolbar( _("Desktop"), self.desktopToolbar ) + self.activity.toolbox.add_toolbar( _("Record"), self.recordToolbar ) #-- GUI ----------------------------------------------- if True: # GUI @@ -709,6 +711,40 @@ class JamMain(gtk.EventBox): #========================================================== + # Mic recording + def micRec(self, widget, 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.SNDS_DIR + "/tempMic.wav") + (s2, o2) = commands.getstatusoutput("csound " + Config.FILES_DIR + "/crop.csd") + (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.csnd.load_instrument(mic) + + + #========================================================== + # Loop Settings + def loopSettingsChannel(self, channel, value): + self.csnd.setChannel(channel, value) + + def loopSettingsPlayStop(self, state, loop): + if not state: + if loop: + self.loopSettingsPlaying = True + self.csnd.inputMessage(Config.CSOUND_PLAY_LS_NOTE % 5022) + else: + self.csnd.inputMessage(Config.CSOUND_PLAY_LS_NOTE % 5023) + else: + if loop: + self.loopSettingsPlaying = False + self.csnd.inputMessage(Config.CSOUND_STOP_LS_NOTE) + + def load_ls_instrument(self, soundName): + self.csnd.load_ls_instrument(soundName) + + #========================================================== # Get/Set def getVolume( self ): diff --git a/TamTamJam.activity/Jam/Toolbars.py b/TamTamJam.activity/Jam/Toolbars.py index ac510db..139c2eb 100644 --- a/TamTamJam.activity/Jam/Toolbars.py +++ b/TamTamJam.activity/Jam/Toolbars.py @@ -2,6 +2,9 @@ import pygtk pygtk.require( '2.0' ) import gtk +import gobject + +import os, commands from gettext import gettext as _ @@ -12,11 +15,13 @@ from sugar.graphics.toggletoolbutton import ToggleToolButton from sugar.graphics.combobox import ComboBox from sugar.graphics.toolcombobox import ToolComboBox +from common.Util.ThemeWidgets import * + import common.Config as Config class JamToolbar( gtk.Toolbar ): - + def __init__( self, owner ): gtk.Toolbar.__init__( self ) @@ -31,13 +36,13 @@ class JamToolbar( gtk.Toolbar ): self.insert(self.stopButton, -1) self.stopButton.show() self.stopButton.set_tooltip(_('Stop')) - + self.pauseButton = ToggleToolButton('media-playback-pause') self.pauseButton.connect('clicked',self.handlePauseButton) self.insert(self.pauseButton, -1) self.pauseButton.show() self.pauseButton.set_tooltip(_('pause')) - + self.volumeAdjustment = gtk.Adjustment( 0.0, 0, 1.0, 0.1, 0.1, 0 ) self.volumeAdjustment.connect( 'value-changed', self.handleVolume ) self.volumeSlider = gtk.HScale( adjustment = self.volumeAdjustment ) @@ -92,7 +97,7 @@ class JamToolbar( gtk.Toolbar ): widget._palette = palette widget._palette.props.invoker = WidgetInvoker( widget ) #widget._palette.set_property( "position", position ) - + def _add_tooltip( self, widget, tooltip ): #self._add_palette( widget, Palette( tooltip ), Palette.DEFAULT ) self._add_palette( widget, Palette( tooltip ) ) @@ -115,19 +120,19 @@ class JamToolbar( gtk.Toolbar ): self.owner._setSyncBeats( widget.get_active() + 1 ) def mapRange( self, value, ilower, iupper, olower, oupper ): - if value == iupper: + if value == iupper: return oupper return olower + int( (oupper-olower+1)*(value-ilower)/float(iupper-ilower) ) - + def handleStopButton( self, widget ): self.owner.setStopped() - + def handlePauseButton (self, widget ): if widget.get_active(): self.owner.setPaused(True) else: - self.owner.setPaused(False) - + self.owner.setPaused(False) + def handleVolume( self, widget ): self.owner._setVolume( widget.get_value() ) @@ -141,6 +146,54 @@ class JamToolbar( gtk.Toolbar ): self.tempoImg.set_from_file(Config.TAM_TAM_ROOT + '/icons/tempo' + str(img) + '.svg') +class recordToolbar(gtk.Toolbar): + def __init__(self, jam): + gtk.Toolbar.__init__(self) + + 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.jam = jam + + self.micRec1Button = ToolButton('rec1') + self.micRec1Button.connect('clicked',self.jam.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.jam.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.jam.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.jam.micRec,'mic4') + self.insert(self.micRec4Button, -1) + self.micRec4Button.show() + self.micRec4Button.set_tooltip(('Record microphone into slot 4')) + + _insertSeparator() + + self._loopSettingsPalette = LoopSettingsPalette(_('Add new Sound'), self.jam) + self.loopSetButton = ToggleToolButton('loop') + self.loopSetButton.set_palette(self._loopSettingsPalette) + self.insert(self.loopSetButton, -1) + self.loopSetButton.show() + + self.show_all() + class DesktopToolbar( gtk.Toolbar ): def __init__( self, owner ): @@ -151,20 +204,20 @@ class DesktopToolbar( gtk.Toolbar ): self._insert_separator( True ) self.desktop = [] - + btn = RadioToolButton( 'preset1', group = None ) btn.connect( 'toggled', self.setDesktop, 0 ) btn.set_tooltip( _('Desktop 1') ) self.insert( btn, -1 ) self.desktop.append( btn ) - + for i in range(2,11): btn = RadioToolButton( 'preset%d'%i, group = self.desktop[0] ) btn.connect( 'toggled', self.setDesktop, i-1 ) btn.set_tooltip( _('Desktop %d'%i) ) self.insert( btn, -1 ) self.desktop.append( btn ) - + self._insert_separator( True ) self.show_all() @@ -181,3 +234,241 @@ class DesktopToolbar( gtk.Toolbar ): def setDesktop( self, widget, which ): if widget.get_active(): self.owner._setDesktop( which ) +class LoopSettingsPalette( Palette ): + def __init__( self, label, jam ): + Palette.__init__( self, label ) + self.connect('popup', self.handlePopup) + self.connect('popdown', self.handlePopdown) + + self.jam = jam + + 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.jam.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.jam.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.jam.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.jam.loopSettingsChannel('lend', self.end) + + def handleDur(self, widget, data=None): + self.dur = self.durAdjust.value + self.jam.loopSettingsChannel('ldur', self.dur) + + def handleVol(self, widget, data=None): + self.volume = self.volAdjust.value + self.jam.loopSettingsChannel('lvol', self.volume) + + def handlePlayButton(self, widget, data=None): + if self.ok: + self.jam.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 diff --git a/TamTamJam.activity/MANIFEST b/TamTamJam.activity/MANIFEST index ad970ba..1751725 100644 --- a/TamTamJam.activity/MANIFEST +++ b/TamTamJam.activity/MANIFEST @@ -11,6 +11,7 @@ icons/XYButDown.svg icons/XYButDownClick.svg icons/accept.svg icons/cancel.svg +icons/loop.svg icons/preset1.svg icons/preset10.svg icons/preset2.svg @@ -21,6 +22,10 @@ icons/preset6.svg icons/preset7.svg icons/preset8.svg icons/preset9.svg +icons/rec1.svg +icons/rec2.svg +icons/rec3.svg +icons/rec4.svg icons/tam-help.svg icons/tempo1.svg icons/tempo2.svg diff --git a/TamTamJam.activity/TamTamJam.py b/TamTamJam.activity/TamTamJam.py index a979b0b..5cdb45f 100644 --- a/TamTamJam.activity/TamTamJam.py +++ b/TamTamJam.activity/TamTamJam.py @@ -53,7 +53,7 @@ class TamTamJam(activity.Activity): #self.modeList[mode].regenerate() self.set_canvas( self.jam ) - + self.jam.onActivate(arg = None) self.show() @@ -71,7 +71,7 @@ class TamTamJam(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 TamTamJam(activity.Activity): else: csnd = new_csound_client() csnd.connect(True) - + def onKeyPress(self, widget, event): pass @@ -111,6 +111,7 @@ class TamTamJam(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 TamTamJam(activity.Activity): self.jam.handleJournalLoad(file_path) def write_file(self,file_path): - self.jam.handleJournalSave(file_path) + self.jam.handleJournalSave(file_path) diff --git a/TamTamJam.activity/icons/loop.svg b/TamTamJam.activity/icons/loop.svg new file mode 100644 index 0000000..c085ee6 --- /dev/null +++ b/TamTamJam.activity/icons/loop.svg @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14576) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="55px" height="55px" viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+<circle fill="#808284" cx="28.1" cy="27.84" r="22.5"/>
+<circle fill="none" stroke="#4C4D4F" stroke-width="2.25" cx="28.098" cy="27.932" r="21.572"/>
+<circle fill="none" stroke="#4C4D4F" stroke-width="0.75" cx="28.431" cy="27.692" r="18.793"/>
+<line fill="none" stroke="#FFFFFF" stroke-width="2" x1="25.001" y1="22.501" x2="30.501" y2="19.001"/>
+<path fill="none" stroke="#FFFFFF" stroke-width="2" d="M28.626,22.001c8.491,0,15.325-0.156,15.375,6.25
+ c0.043,5.498-6.884,6.25-15.375,6.25c-8.492,0-15.179-0.318-15.375-6.25C13.221,22.015,20.134,22.001,28.626,22.001z"/>
+<line fill="none" stroke="#FFFFFF" stroke-width="2" x1="25.751" y1="22.751" x2="30.501" y2="25.001"/>
+</svg>
diff --git a/TamTamJam.activity/icons/rec1.svg b/TamTamJam.activity/icons/rec1.svg new file mode 100644 index 0000000..4a88eec --- /dev/null +++ b/TamTamJam.activity/icons/rec1.svg @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14576) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="55px" height="55px" viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+<circle fill="#808284" cx="27.501" cy="27.408" r="22.5"/>
+<circle fill="none" stroke="#4C4D4F" stroke-width="2.25" cx="27.499" cy="27.5" r="21.572"/>
+<g enable-background="new ">
+ <path fill="#FFFFFF" d="M26.582,24.229h-0.034l-2.233,1.062l-0.45-2.052l3.099-1.438h2.269v11.703h-2.649V24.229z"/>
+</g>
+</svg>
diff --git a/TamTamJam.activity/icons/rec2.svg b/TamTamJam.activity/icons/rec2.svg new file mode 100644 index 0000000..108ea7e --- /dev/null +++ b/TamTamJam.activity/icons/rec2.svg @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14576) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="55px" height="55px" viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+<circle fill="#808284" cx="27.501" cy="27.408" r="22.5"/>
+<circle fill="none" stroke="#4C4D4F" stroke-width="2.25" cx="27.499" cy="27.5" r="21.572"/>
+<g enable-background="new ">
+ <path fill="#FFFFFF" d="M23.09,33.501v-1.656l1.512-1.369c2.557-2.286,3.8-3.603,3.835-4.969c0-0.954-0.576-1.711-1.926-1.711
+ c-1.008,0-1.893,0.504-2.503,0.973l-0.774-1.963c0.882-0.666,2.25-1.206,3.835-1.206c2.647,0,4.105,1.548,4.105,3.673
+ c0,1.963-1.423,3.529-3.115,5.042l-1.08,0.899v0.034h4.411v2.253H23.09z"/>
+</g>
+</svg>
diff --git a/TamTamJam.activity/icons/rec3.svg b/TamTamJam.activity/icons/rec3.svg new file mode 100644 index 0000000..2c64c70 --- /dev/null +++ b/TamTamJam.activity/icons/rec3.svg @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14576) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="55px" height="55px" viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+<circle fill="#808284" cx="27.501" cy="27.408" r="22.5"/>
+<circle fill="none" stroke="#4C4D4F" stroke-width="2.25" cx="27.499" cy="27.5" r="21.572"/>
+<g enable-background="new ">
+ <path fill="#FFFFFF" d="M23.575,30.818c0.486,0.252,1.604,0.72,2.721,0.72c1.423,0,2.143-0.684,2.143-1.564
+ c0-1.152-1.152-1.674-2.358-1.674h-1.117v-1.963h1.062c0.918-0.021,2.088-0.36,2.088-1.353c0-0.702-0.576-1.224-1.728-1.224
+ c-0.955,0-1.962,0.414-2.449,0.702l-0.558-1.981c0.7-0.45,2.104-0.882,3.617-0.882c2.502,0,3.891,1.312,3.891,2.917
+ c0,1.242-0.702,2.215-2.145,2.719v0.036c1.404,0.252,2.539,1.314,2.539,2.845c0,2.07-1.817,3.583-4.79,3.583
+ c-1.512,0-2.791-0.396-3.475-0.828L23.575,30.818z"/>
+</g>
+</svg>
diff --git a/TamTamJam.activity/icons/rec4.svg b/TamTamJam.activity/icons/rec4.svg new file mode 100644 index 0000000..14b2d0a --- /dev/null +++ b/TamTamJam.activity/icons/rec4.svg @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14576) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="55px" height="55px" viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+<circle fill="#808284" cx="27.501" cy="27.408" r="22.5"/>
+<circle fill="none" stroke="#4C4D4F" stroke-width="2.25" cx="27.499" cy="27.5" r="21.572"/>
+<g enable-background="new ">
+ <path fill="#FFFFFF" d="M27.934,33.501V30.71h-5.188v-1.782l4.431-7.13h3.349v6.858h1.404v2.055h-1.404v2.791L27.934,33.501
+ L27.934,33.501z M27.934,28.657v-2.593c0-0.702,0.036-1.422,0.09-2.178h-0.072c-0.378,0.756-0.684,1.438-1.081,2.178l-1.564,2.557
+ v0.036H27.934z"/>
+</g>
+</svg>
diff --git a/TamTamMini.activity/.DS_Store b/TamTamMini.activity/.DS_Store Binary files differnew file mode 100644 index 0000000..6926115 --- /dev/null +++ b/TamTamMini.activity/.DS_Store diff --git a/TamTamMini.activity/MANIFEST b/TamTamMini.activity/MANIFEST index b6de0fb..e402e8e 100644 --- a/TamTamMini.activity/MANIFEST +++ b/TamTamMini.activity/MANIFEST @@ -4,6 +4,7 @@ setup.py TamTamMini.py activity/activity-tamtammini.svg activity/activity.info +icons/accept.svg icons/keyrec.svg icons/loop.svg icons/micrec1.svg 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 diff --git a/TamTamMini.activity/TamTamMini.py b/TamTamMini.activity/TamTamMini.py index 404a7d1..83bf59e 100644 --- a/TamTamMini.activity/TamTamMini.py +++ b/TamTamMini.activity/TamTamMini.py @@ -119,6 +119,7 @@ class TamTamMini(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): diff --git a/TamTamMini.activity/icons/accept.svg b/TamTamMini.activity/icons/accept.svg new file mode 100755 index 0000000..a2f9e28 --- /dev/null +++ b/TamTamMini.activity/icons/accept.svg @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14576) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="45px" height="45px" viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+<g>
+
+ <path fill-rule="evenodd" clip-rule="evenodd" fill="none" stroke="#FFFFFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" d="
+ M5.78,28.079c0-12.43,10.071-22.499,22.499-22.499c12.431,0,22.501,10.069,22.501,22.499c0,12.431-10.07,22.501-22.501,22.501
+ C15.851,50.58,5.78,40.51,5.78,28.079z"/>
+</g>
+<g>
+
+ <line fill-rule="evenodd" clip-rule="evenodd" fill="none" stroke="#FFFFFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" x1="16.788" y1="26.691" x2="25.781" y2="38.706"/>
+
+ <line fill-rule="evenodd" clip-rule="evenodd" fill="none" stroke="#FFFFFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" x1="25.781" y1="38.706" x2="39.773" y2="18.704"/>
+</g>
+</svg>
diff --git a/TamTamSynthLab.activity/TamTamSynthLab.py b/TamTamSynthLab.activity/TamTamSynthLab.py index dd3b6d5..b115ec2 100644 --- a/TamTamSynthLab.activity/TamTamSynthLab.py +++ b/TamTamSynthLab.activity/TamTamSynthLab.py @@ -56,7 +56,7 @@ class TamTamSynthLab(activity.Activity): self.set_canvas( self.synthLab ) - + self.synthLab.onActivate(arg = None) self.show() @@ -74,7 +74,7 @@ class TamTamSynthLab(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() @@ -82,7 +82,7 @@ class TamTamSynthLab(activity.Activity): else: csnd = new_csound_client() csnd.connect(True) - + def onKeyPress(self, widget, event): pass @@ -114,6 +114,7 @@ class TamTamSynthLab(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): @@ -127,4 +128,4 @@ class TamTamSynthLab(activity.Activity): self.synthLab.handleJournalLoad(file_path) def write_file(self,file_path): - self.synthLab.handleJournalSave(file_path) + self.synthLab.handleJournalSave(file_path) diff --git a/common/Config.py b/common/Config.py index 2aae053..8efc36c 100644 --- a/common/Config.py +++ b/common/Config.py @@ -37,12 +37,14 @@ if SugarMode == True: TUNE_DIR=env.get_profile_path() + '/tamtam/tunes' SYNTH_DIR=env.get_profile_path() + '/tamtam/synthlab' SNDS_DIR=env.get_profile_path() + '/tamtam/snds' + SNDS_INFO_DIR=env.get_profile_path() + '/tamtam/snds_info' SCRATCH_DIR = PREF_DIR + "/.scratch/" else: PREF_DIR = os.getenv('HOME') + '/.tamtam' TUNE_DIR= os.getenv('HOME') + '/.tamtam/tunes' SYNTH_DIR= os.getenv('HOME') + '/.tamtam/synthlab' SNDS_DIR= os.getenv('HOME') + '/.tamtam/snds' + SNDS_INFO_DIR = os.getenv('HOME') + '/.tamtam/snds_info' SCRATCH_DIR = PREF_DIR + "/.scratch/" #PLUGIN diff --git a/common/Resources/tamtamorc.csd b/common/Resources/tamtamorc.csd index 37129fb..3eb3db4 100644 --- a/common/Resources/tamtamorc.csd +++ b/common/Resources/tamtamorc.csd @@ -509,8 +509,6 @@ aRight eqfil aRight, 4000, 1000, 0.125 aLeft butterhp aLeft, 150 aRight butterhp aRight, 150 -aLeft butterhp aLeft, 150 -aRight butterhp aRight, 150 aOutLeft dcblock (arev + aLeft) * koutGain * gkduck aOutRight dcblock (arev + aRight) * koutGain * gkduck @@ -749,6 +747,7 @@ instr 5022 kstart chnget "lstart" kend chnget "lend" kdur chnget "ldur" +kvol chnget "lvol" idurfadein init 0.005 idurfadeout init 0.095 @@ -790,12 +789,12 @@ kvibrato oscil .006, ivibRand, 1 a1 flooper2 0.5, 1+kvibrato, kstart, kend, kdur, 4999, 0, 0, 0, iskip -a1 = a1*kenv +a1 = a1*kenv*kvol gaoutL = a1*0.5+gaoutL gaoutR = a1*0.5+gaoutR -gainrev = a1*0.1+gainrev +gainrev = a1*0.05+gainrev tieskip: endin @@ -805,18 +804,20 @@ Loop points editor, simple player *************************/ instr 5023 +kvol chnget "lvol" + p3 = nsamp(4999) * giScale a1 loscil 0.5, 1, 4999, 1 kenv adsr 0.005, 0.05, .8, 0.1 -a1 = a1*kenv +a1 = a1*kenv*kvol gaoutL = a1*0.5+gaoutL gaoutR = a1*0.5+gaoutR -gainrev = a1*0.1+gainrev +gainrev = a1*0.05+gainrev endin diff --git a/common/Util/CSoundClient.py b/common/Util/CSoundClient.py index b3729d8..b8919eb 100644 --- a/common/Util/CSoundClient.py +++ b/common/Util/CSoundClient.py @@ -101,7 +101,10 @@ class _CSoundClientPlugin: def load_instrument(self, inst): if not inst in loadedInstruments: - fileName = Config.SOUNDS_DIR + "/" + inst + if inst[0:3] == 'mic' or inst[0:3] == 'lab' or self.instrumentDB.instNamed[inst].category == 'mysounds': + fileName = Config.SNDS_DIR + '/' + inst + else: + fileName = Config.SOUNDS_DIR + "/" + inst instrumentId = Config.INSTRUMENT_TABLE_OFFSET + self.instrumentDB.instNamed[ inst ].instrumentId sc_inputMessage( Config.CSOUND_LOAD_INSTRUMENT % (instrumentId, fileName) ) loadedInstruments.append(inst) diff --git a/common/Util/InstrumentDB.py b/common/Util/InstrumentDB.py index fd276ae..82c0e56 100644 --- a/common/Util/InstrumentDB.py +++ b/common/Util/InstrumentDB.py @@ -30,17 +30,17 @@ class Instrument: magic = f.readline()[:-1] if (magic != 'TamTam idf v1'): raise 'given file has wrong header' - self.name = f.readline() - self.csoundInstrumentId = f.readline() - self.register = f.readline() - self.loopStart = float( f.readline()) - self.loopEnd = float( f.readline()) - self.crossDur = float( f.readline()) - self.ampScale = float( f.readline()) + self.name = f.readline()[:-1] + self.csoundInstrumentId = float(f.readline()[:-1]) + self.register = f.readline()[:-1] + self.loopStart = float( f.readline()[:-1]) + self.loopEnd = float( f.readline()[:-1]) + self.crossDur = float( f.readline()[:-1]) + self.ampScale = float( f.readline()[:-1]) self.kit = None - self.wav = f.readline() - self.img = f.readline() - self.category = f.readline().split() + self.wav = f.readline()[:-1] + self.img = f.readline()[:-1] + self.category = f.readline() f.close() class InstrumentDB: @@ -68,16 +68,19 @@ class InstrumentDB: # add an instrument to the DB by reading from an instrument definition file def addInstrument( self, path ): + from common.Util.CSoundClient import new_csound_client + csnd = new_csound_client() i = Instrument(len(self.inst)) self.inst += [ i ] i.loadFromPath( path ) self.instNamed[ i.name ] = i - self.instId[self.instNamed[i].instrumentId] = i + self.instId[i.instrumentId] = i #print 'labelSet... ', self.labelSet self.labelSet['All'].add(i) if not self.labelSet.has_key(category): self.labelSet[category] = set([]) self.labelSet[category].add( i ) + csnd.load_instrument(i.name) # try to load each file in a given folder as an instrument def. file def scanInstrumentDir( self, path ): diff --git a/common/Util/Instruments.py b/common/Util/Instruments.py index 17a0594..004fcca 100644 --- a/common/Util/Instruments.py +++ b/common/Util/Instruments.py @@ -1,3 +1,4 @@ +import os import common.Config as Config import common.Util.InstrumentDB as InstrumentDB @@ -175,10 +176,9 @@ _addInstrument( "plane", INST_SIMP, MID, 'concret', 0, 0, 0, 0.7 ) _addInstrument( "slap", INST_SIMP, MID, 'concret', 0, 0, 0, 0.7 ) 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]), float(list[8])) + files = os.listdir(Config.SNDS_INFO_DIR) + for file in files: + instrumentDB.addInstrument(Config.SNDS_INFO_DIR + '/' + file) except: pass |