Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TamTamEdit.activity/Edit/MainWindow.py30
-rw-r--r--TamTamEdit.activity/TamTamEdit.py22
-rw-r--r--TamTamJam.activity/Jam/JamMain.py27
-rw-r--r--TamTamJam.activity/Jam/Toolbars.py13
-rw-r--r--TamTamJam.activity/TamTamJam.py21
-rw-r--r--TamTamMini.activity/Mini/miniTamTamMain.py9
-rw-r--r--TamTamMini.activity/Mini/miniToolbars.py8
-rw-r--r--TamTamMini.activity/TamTamMini.py17
-rw-r--r--TamTamMini.activity/activity/activity.info2
-rw-r--r--TamTamSynthLab.activity/SynthLab/SynthLabMain.py26
-rw-r--r--TamTamSynthLab.activity/TamTamSynthLab.py22
-rw-r--r--common/Config.py36
-rw-r--r--common/Resources/crop.csd16
-rw-r--r--common/Resources/cropSynthLab.csd17
-rw-r--r--common/Resources/tamtamorc.csd17
-rw-r--r--common/Util/CSoundClient.py10
-rw-r--r--common/Util/Instruments.py3
-rw-r--r--common/Util/LoopSettings.py2
18 files changed, 147 insertions, 151 deletions
diff --git a/TamTamEdit.activity/Edit/MainWindow.py b/TamTamEdit.activity/Edit/MainWindow.py
index 2420477..4842013 100644
--- a/TamTamEdit.activity/Edit/MainWindow.py
+++ b/TamTamEdit.activity/Edit/MainWindow.py
@@ -18,6 +18,7 @@ from EditToolbars import generateToolbar
from gettext import gettext as _
from subprocess import Popen
from sugar.graphics.palette import Palette, Invoker, _palette_observer
+from sugar.datastore import datastore
import time
import os
import commands
@@ -603,7 +604,7 @@ class MainWindow( gtk.EventBox ):
filter = gtk.FileFilter()
filter.add_pattern('*.ogg')
chooser.set_filter(filter)
- chooser.set_current_folder(Config.TUNE_DIR)
+ chooser.set_current_folder(Config.INSTANCE_DIR)
for f in chooser.list_shortcut_folder_uris():
chooser.remove_shortcut_folder_uri(f)
@@ -631,12 +632,12 @@ class MainWindow( gtk.EventBox ):
return False
def handlePlay( self, widget = None ):
-
if widget:
widget.event( gtk.gdk.Event( gtk.gdk.LEAVE_NOTIFY ) ) # fake the leave event
if self.audioRecordState:
- self.csnd.inputMessage( "i5400 0 -1" )
+ filename = Config.INSTANCE_DIR + "/perf.wav"
+ self.csnd.inputMessage( Config.CSOUND_RECORD_PERF % filename)
time.sleep( 0.01 )
if self.playScope == "All":
@@ -698,7 +699,8 @@ class MainWindow( gtk.EventBox ):
widget.event( gtk.gdk.Event( gtk.gdk.LEAVE_NOTIFY ) ) # fake the leave event
if self.audioRecordState:
- self.csnd.inputMessage( "i5401 4 1" )
+ filename = Config.INSTANCE_DIR + "/perf.wav"
+ self.csnd.inputMessage( Config.CSOUND_STOP_RECORD_PERF % filename)
time.sleep( 0.01 )
if self.playbackTimeout:
@@ -713,10 +715,20 @@ class MainWindow( gtk.EventBox ):
self.csnd.__del__()
time.sleep(0.5)
self.audioRecordState = False
- command = "gst-launch-0.10 filesrc location=" + Config.PREF_DIR + "/perf.wav ! wavparse ! audioconvert ! vorbisenc ! oggmux ! filesink location=" + self.audioFileName
- command2 = "rm /home/olpc/.sugar/default/tamtam/perf.wav"
+ command = "gst-launch-0.10 filesrc location=" + Config.INSTANCE_DIR + "/perf.wav ! wavparse ! audioconvert ! vorbisenc ! oggmux ! filesink location=" + self.audioFileName
+ command2 = "rm " + Config.INSTANCE_DIR + "/perf.wav"
(status, output) = commands.getstatusoutput(command)
(status2, output2) = commands.getstatusoutput(command2)
+
+ jobject = datastore.create()
+ jobject.metadata['title'] = os.path.split(self.audioFileName)[1]
+ jobject.metadata['keep'] = '1'
+ jobject.metadata['mime_type'] = 'audio/ogg'
+ jobject.file_path = self.audioFileName
+ datastore.write(jobject)
+
+ os.remove(self.audioFileName)
+
self.csnd.__init__()
time.sleep(0.1)
self.csnd.connect(True)
@@ -1393,7 +1405,7 @@ class MainWindow( gtk.EventBox ):
filter = gtk.FileFilter()
filter.add_pattern('*.tam')
chooser.set_filter(filter)
- chooser.set_current_folder(Config.TUNE_DIR)
+ chooser.set_current_folder(Config.DATA_DIR)
for f in chooser.list_shortcut_folder_uris():
chooser.remove_shortcut_folder_uri(f)
@@ -1416,7 +1428,7 @@ class MainWindow( gtk.EventBox ):
def handleLoopSave(self):
date = str(time.localtime()[3]) + '-' + str(time.localtime()[4]) + '-' + str(time.localtime()[5])
- ofilename = Config.PREF_DIR + '/' + date + '.ttl'
+ ofilename = Config.DATA_DIR + '/' + date + '.ttl'
ofile = open(ofilename, 'w')
ofilestream = ControlStream.TamTamOStream (ofile)
self.noteDB.dumpToStream(ofilestream)
@@ -1464,7 +1476,7 @@ class MainWindow( gtk.EventBox ):
filter = gtk.FileFilter()
filter.add_pattern('*.tam')
chooser.set_filter(filter)
- chooser.set_current_folder(Config.TUNE_DIR)
+ chooser.set_current_folder(Config.DATA_DIR)
for f in chooser.list_shortcut_folder_uris():
chooser.remove_shortcut_folder_uri(f)
diff --git a/TamTamEdit.activity/TamTamEdit.py b/TamTamEdit.activity/TamTamEdit.py
index 644d0b5..99a0fc3 100644
--- a/TamTamEdit.activity/TamTamEdit.py
+++ b/TamTamEdit.activity/TamTamEdit.py
@@ -22,7 +22,11 @@ from sugar.activity import activity
class TamTamEdit(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
- self.ensure_dirs()
+
+ for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']:
+ if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)):
+ shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.DATA_DIR + '/' + snd)
+ os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &')
color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
self.modify_bg(gtk.STATE_NORMAL, color)
@@ -87,7 +91,6 @@ class TamTamEdit(activity.Activity):
def onDestroy(self, arg2):
if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()'
- os.system('rm -f ' + Config.PREF_DIR + '/synthTemp*')
self.edit.onDestroy()
@@ -97,6 +100,7 @@ class TamTamEdit(activity.Activity):
gtk.main_quit()
+# No more dir created by TamTam
def ensure_dir(self, dir, perms=0777, rw=os.R_OK|os.W_OK):
if not os.path.isdir( dir ):
try:
@@ -106,20 +110,6 @@ class TamTamEdit(activity.Activity):
if not os.access(dir, rw):
print 'ERROR: directory %s is missing required r/w access\n' % dir
- def ensure_dirs(self):
- 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):
- os.mkdir(Config.PREF_DIR)
- os.system('chmod 0777 ' + Config.PREF_DIR + ' &')
- for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']:
- shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.SNDS_DIR + '/' + snd)
- os.system('chmod 0777 ' + Config.SNDS_DIR + '/' + snd + ' &')
-
def read_file(self,file_path):
self.edit.handleJournalLoad(file_path)
diff --git a/TamTamJam.activity/Jam/JamMain.py b/TamTamJam.activity/Jam/JamMain.py
index 9029265..53f2798 100644
--- a/TamTamJam.activity/Jam/JamMain.py
+++ b/TamTamJam.activity/Jam/JamMain.py
@@ -284,7 +284,7 @@ class JamMain(gtk.EventBox):
path = Config.TAM_TAM_ROOT+"/common/Resources/Desktops/"
filelist = os.listdir( path )
for file in filelist:
- shutil.copyfile( path+file, Config.SCRATCH_DIR+file )
+ shutil.copyfile( path+file, Config.TMP_DIR + '/' + file )
#-- Network -------------------------------------------
self.network = Net.Network()
@@ -327,7 +327,7 @@ class JamMain(gtk.EventBox):
self.activity._shared_activity.connect( "buddy-left", self.buddy_left )
self.activity.connect( "joined", self.joined )
self.network.setMode( Net.MD_WAIT )
-
+
#-- Final Set Up --------------------------------------
self.setVolume( self.volume )
self.setTempo( self.tempo )
@@ -346,10 +346,10 @@ class JamMain(gtk.EventBox):
self.network.shutdown()
#clear up scratch folder
- path = Config.SCRATCH_DIR
+ path = Config.TMP_DIR
filelist = os.listdir( path )
for file in filelist:
- os.remove( path+file )
+ os.remove( path + '/' + file )
#==========================================================
@@ -532,7 +532,7 @@ class JamMain(gtk.EventBox):
if inst.kit: # drum kit
if n.cs.pitch in GenerationConstants.DRUMPITCH:
n.cs.pitch = GenerationConstants.DRUMPITCH[n.cs.pitch]
- n.cs.onset += ticks
+ n.cs.onset += ticks
self.csnd.loopPlay( n, 1, loopId = loopId )
n.popState()
for n in self.noteDB.getNotesByTrack( page, 1 ): # metronome track
@@ -693,12 +693,13 @@ class JamMain(gtk.EventBox):
#==========================================================
# Mic recording
def micRec(self, widget, mic):
- os.system('rm ' + Config.SNDS_DIR + '/' + mic)
+ if os.path.isfile(os.path.join(Config.DATA_DIR, mic)):
+ os.system('rm ' + Config.DATA_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")
+ (s1,o1) = commands.getstatusoutput("arecord -f S16_LE -t wav -r 16000 -d 4 " + Config.DATA_DIR + "/tempMic.wav")
+ (s2, o2) = commands.getstatusoutput("csound " + "--strset999=" + Config.DATA_DIR + " " + Config.FILES_DIR + "/crop.csd")
+ (s3, o3) = commands.getstatusoutput("mv " + Config.DATA_DIR + "/micTemp.wav " + Config.DATA_DIR + "/" + mic)
+ (s4, o4) = commands.getstatusoutput("rm " + Config.DATA_DIR + "/tempMic.wav")
self.csnd.load_mic_instrument(mic)
@@ -960,7 +961,7 @@ class JamMain(gtk.EventBox):
if Config.DEBUG > 3: print "IOError:: _saveDesktop:", errno, strerror
def getDesktopScratchFile( self, i ):
- return Config.SCRATCH_DIR+"desktop%d" % i
+ return Config.TMP_DIR+"/desktop%d" % i
def handleJournalLoad( self, filepath ):
@@ -1134,7 +1135,7 @@ class JamMain(gtk.EventBox):
self.offsetTicks = (offset + self.offsetTicks) % (self.syncTicks*HEARTBEAT_BUFFER)
elapsedTicks += offset
- newTick = elapsedTicks % (self.syncTicks*HEARTBEAT_BUFFER)
+ newTick = elapsedTicks % (self.syncTicks*HEARTBEAT_BUFFER)
self.csnd.loopSetTick( newTick, self.heartbeatLoop )
self.csnd.loopSetNumTicks( self.syncTicks*HEARTBEAT_BUFFER, self.heartbeatLoop )
@@ -1144,7 +1145,7 @@ class JamMain(gtk.EventBox):
def _setBeat( self, beat ):
curTick = self.csnd.loopGetTick( self.heartbeatLoop ) % self.syncTicks
curBeat = int(curTick) // Config.TICKS_PER_BEAT
- offset = (beat - curBeat) * Config.TICKS_PER_BEAT
+ offset = (beat - curBeat) * Config.TICKS_PER_BEAT
if offset > self.syncTicks//2:
offset -= self.syncTicks
elif offset < -self.syncTicks//2:
diff --git a/TamTamJam.activity/Jam/Toolbars.py b/TamTamJam.activity/Jam/Toolbars.py
index 4b2533e..5e4ab6c 100644
--- a/TamTamJam.activity/Jam/Toolbars.py
+++ b/TamTamJam.activity/Jam/Toolbars.py
@@ -104,7 +104,7 @@ class JamToolbar( gtk.Toolbar ):
def setTempo( self, tempo, quiet = False ):
if self.tempoSliderActive:
- self.delayedTempo = tempo
+ self.delayedTempo = tempo
elif quiet:
self.tempoAdjustment.handler_block( self.tempoAdjustmentHandler )
self.tempoAdjustment.set_value( tempo )
@@ -218,7 +218,7 @@ class PlaybackToolbar( gtk.Toolbar ):
def setBeat( self, widget, beat ):
if not self.blockBeat and widget.get_active():
- self.owner._setBeat( beat )
+ self.owner._setBeat( beat )
def updateBeatWheel( self, beat ):
self.blockBeat = True
@@ -369,7 +369,7 @@ class LoopSettingsPalette( Palette ):
self.soundBox = gtk.HBox()
self.soundLabel = gtk.Label(_('Sound: '))
self.soundMenuBox = BigComboBox()
- self.sounds = os.listdir(Config.SNDS_DIR)
+ self.sounds = [snd for snd in os.listdir(Config.DATA_DIR) if snd != 'snds_info']
for sound in self.sounds:
self.soundMenuBox.append_item(self.sounds.index(sound), sound)
self.soundMenuBox.connect('changed', self.handleSound)
@@ -469,7 +469,7 @@ class LoopSettingsPalette( Palette ):
def handlePopup(self, widget, data=None):
self.setButtonState()
self.soundMenuBox.remove_all()
- self.sounds = os.listdir(Config.SNDS_DIR)
+ self.sounds = [snd for snd in os.listdir(Config.DATA_DIR) if snd != 'snds_info']
for sound in self.sounds:
self.soundMenuBox.append_item(self.sounds.index(sound), sound)
self.nameEntry.set_text("name_of_the_sound")
@@ -480,7 +480,7 @@ class LoopSettingsPalette( Palette ):
def handleSound(self, widget, data=None):
self.sndname = self.sounds[widget.props.value]
- fullname = Config.SNDS_DIR + '/' + self.sndname
+ fullname = Config.DATA_DIR + '/' + self.sndname
results = commands.getstatusoutput("du -b %s" % fullname)
if results[0] == 0:
list = results[1].split()
@@ -528,7 +528,7 @@ class LoopSettingsPalette( Palette ):
ofile.write(category)
ofile.close()
if copy:
- (s,o) = commands.getstatusoutput('cp ' + Config.SNDS_DIR + '/' + oldName + ' ' + Config.SNDS_DIR + '/' + self.sndname)
+ (s,o) = commands.getstatusoutput('cp ' + Config.DATA_DIR + '/' + oldName + ' ' + Config.DATA_DIR + '/' + self.sndname)
def set_values(self, soundLength):
self.soundLength = soundLength
@@ -580,4 +580,3 @@ class LoopSettingsPalette( Palette ):
self.playStopButton.set_active(False)
gobject.source_remove(self.timeoutStop)
self.ok = True
-
diff --git a/TamTamJam.activity/TamTamJam.py b/TamTamJam.activity/TamTamJam.py
index ef66ffd..b52cb10 100644
--- a/TamTamJam.activity/TamTamJam.py
+++ b/TamTamJam.activity/TamTamJam.py
@@ -26,7 +26,11 @@ class TamTamJam(activity.Activity):
gtk.gdk.threads_init()
activity.Activity.__init__(self, handle)
- self.ensure_dirs()
+
+ for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']:
+ if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)):
+ shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.DATA_DIR + '/' + snd)
+ os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &')
color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
self.modify_bg(gtk.STATE_NORMAL, color)
@@ -93,7 +97,6 @@ class TamTamJam(activity.Activity):
def onDestroy(self, arg2):
if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()'
- os.system('rm -f ' + Config.PREF_DIR + '/synthTemp*')
self.jam.onDestroy()
@@ -112,20 +115,6 @@ class TamTamJam(activity.Activity):
if not os.access(dir, rw):
print 'ERROR: directory %s is missing required r/w access\n' % dir
- def ensure_dirs(self):
- 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):
- os.mkdir(Config.PREF_DIR)
- os.system('chmod 0777 ' + Config.PREF_DIR + ' &')
- for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']:
- shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.SNDS_DIR + '/' + snd)
- os.system('chmod 0777 ' + Config.SNDS_DIR + '/' + snd + ' &')
-
def read_file(self,file_path):
self.jam.handleJournalLoad(file_path)
diff --git a/TamTamMini.activity/Mini/miniTamTamMain.py b/TamTamMini.activity/Mini/miniTamTamMain.py
index 0ac2bcb..395bd7d 100644
--- a/TamTamMini.activity/Mini/miniTamTamMain.py
+++ b/TamTamMini.activity/Mini/miniTamTamMain.py
@@ -315,12 +315,13 @@ class miniTamTamMain(gtk.EventBox):
self.instrumentPanelBox.remove( self.instrumentPanel )
def micRec(self, widget, mic):
- os.system('rm ' + Config.SNDS_DIR + '/' + mic)
+ if os.path.isfile(Config.DATA_DIR + '/' + mic):
+ os.system('rm ' + Config.DATA_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")
+ (s1,o1) = commands.getstatusoutput("arecord -f S16_LE -t wav -r 16000 -d 4 " + Config.DATA_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")
+ (s3, o3) = commands.getstatusoutput("mv " + Config.DATA_DIR + "/micTemp " + Config.DATA_DIR + "/" + mic)
+ (s4, o4) = commands.getstatusoutput("rm " + Config.DATA_DIR + "/tempMic.wav")
self.micTimeout = gobject.timeout_add(200, self.loadMicInstrument, mic)
self.instrumentPanel.set_activeInstrument(mic,True)
self.setInstrument(mic)
diff --git a/TamTamMini.activity/Mini/miniToolbars.py b/TamTamMini.activity/Mini/miniToolbars.py
index 9fac3d6..6401184 100644
--- a/TamTamMini.activity/Mini/miniToolbars.py
+++ b/TamTamMini.activity/Mini/miniToolbars.py
@@ -172,7 +172,7 @@ class LoopSettingsPalette( Palette ):
self.soundBox = gtk.HBox()
self.soundLabel = gtk.Label(_('Sound: '))
self.soundMenuBox = BigComboBox()
- self.sounds = os.listdir(Config.SNDS_DIR)
+ self.sounds = os.listdir(Config.DATA_DIR)
for sound in self.sounds:
self.soundMenuBox.append_item(self.sounds.index(sound), sound)
self.soundMenuBox.connect('changed', self.handleSound)
@@ -272,7 +272,7 @@ class LoopSettingsPalette( Palette ):
def handlePopup(self, widget, data=None):
self.setButtonState()
self.soundMenuBox.remove_all()
- self.sounds = os.listdir(Config.SNDS_DIR)
+ self.sounds = os.listdir(Config.DATA_DIR)
for sound in self.sounds:
self.soundMenuBox.append_item(self.sounds.index(sound), sound)
self.nameEntry.set_text("name_of_the_sound")
@@ -283,7 +283,7 @@ class LoopSettingsPalette( Palette ):
def handleSound(self, widget, data=None):
self.sndname = self.sounds[widget.props.value]
- fullname = Config.SNDS_DIR + '/' + self.sndname
+ fullname = Config.DATA_DIR + '/' + self.sndname
results = commands.getstatusoutput("du -b %s" % fullname)
if results[0] == 0:
list = results[1].split()
@@ -331,7 +331,7 @@ class LoopSettingsPalette( Palette ):
ofile.write(category)
ofile.close()
if copy:
- (s,o) = commands.getstatusoutput('cp ' + Config.SNDS_DIR + '/' + oldName + ' ' + Config.SNDS_DIR + '/' + self.sndname)
+ (s,o) = commands.getstatusoutput('cp ' + Config.DATA_DIR + '/' + oldName + ' ' + Config.DATA_DIR + '/' + self.sndname)
def set_values(self, soundLength):
self.soundLength = soundLength
diff --git a/TamTamMini.activity/TamTamMini.py b/TamTamMini.activity/TamTamMini.py
index 83bf59e..7347f6f 100644
--- a/TamTamMini.activity/TamTamMini.py
+++ b/TamTamMini.activity/TamTamMini.py
@@ -23,7 +23,6 @@ from sugar.activity import activity
class TamTamMini(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
- self.ensure_dirs()
color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
self.modify_bg(gtk.STATE_NORMAL, color)
@@ -96,7 +95,6 @@ class TamTamMini(activity.Activity):
def onDestroy(self, arg2):
if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()'
- os.system('rm -f ' + Config.PREF_DIR + '/synthTemp*')
self.mini.onDestroy()
@@ -106,6 +104,7 @@ class TamTamMini(activity.Activity):
gtk.main_quit()
+# no more dir created by TamTam
def ensure_dir(self, dir, perms=0777, rw=os.R_OK|os.W_OK):
if not os.path.isdir( dir ):
try:
@@ -115,20 +114,6 @@ class TamTamMini(activity.Activity):
if not os.access(dir, rw):
print 'ERROR: directory %s is missing required r/w access\n' % dir
- def ensure_dirs(self):
- 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):
- os.mkdir(Config.PREF_DIR)
- os.system('chmod 0777 ' + Config.PREF_DIR + ' &')
- for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']:
- shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.SNDS_DIR + '/' + snd)
- os.system('chmod 0777 ' + Config.SNDS_DIR + '/' + snd + ' &')
-
def read_file(self,file_path):
self.metadata['tamtam_subactivity'] = 'mini'
diff --git a/TamTamMini.activity/activity/activity.info b/TamTamMini.activity/activity/activity.info
index 5be06e2..0035a31 100644
--- a/TamTamMini.activity/activity/activity.info
+++ b/TamTamMini.activity/activity/activity.info
@@ -3,4 +3,4 @@ name = TamTamMini
service_name = org.laptop.TamTamMini
icon = activity-tamtammini
class = TamTamMini.TamTamMini
-activity_version = 47 \ No newline at end of file
+activity_version = 47
diff --git a/TamTamSynthLab.activity/SynthLab/SynthLabMain.py b/TamTamSynthLab.activity/SynthLab/SynthLabMain.py
index 69d8340..86ee199 100644
--- a/TamTamSynthLab.activity/SynthLab/SynthLabMain.py
+++ b/TamTamSynthLab.activity/SynthLab/SynthLabMain.py
@@ -299,7 +299,7 @@ class SynthLabMain(gtk.EventBox):
self.drawingBox.pack_start(self.drawingArea, False, False, 0)
tempFile = 'synthTemp'
- if tempFile in os.listdir(Config.PREF_DIR):
+ if tempFile in os.listdir(Config.TMP_DIR):
self.handleLoadTemp()
else:
self.presetCallback(None,1)
@@ -529,7 +529,7 @@ class SynthLabMain(gtk.EventBox):
def playNote( self, midiPitch, table ):
cpsPitch = 261.626*pow(1.0594633, midiPitch-36)
self.recCount += 1
- mess = "i5203." + str(self.recCount) + " 0 " + str(self.duration) + " " + str(cpsPitch) + " " + str(table) + " " + " " .join([str(n) for n in self.synthObjectsParameters.getOutputParameters()])
+ mess = "i5203." + str(self.recCount) + " 0 " + str(self.duration) + " " + str(cpsPitch) + " " + str(table) + " " + " ".join([str(n) for n in self.synthObjectsParameters.getOutputParameters()]) + ' "%s"' % Config.DATA_DIR
self.csnd.inputMessage( mess )
if self.recCount >= 9: self.recCount = 0
@@ -633,11 +633,12 @@ class SynthLabMain(gtk.EventBox):
if self.synthObjectsParameters.types[i] == 9:
snd = i - 3
dur = self.synthObjectsParameters.sourcesParameters[(i % 4) * 4]
- os.system('rm ' + Config.SNDS_DIR + '/labmic' + str(snd))
- (s1,o1) = commands.getstatusoutput("arecord -f S16_LE -t wav -r 16000 -d " + str(dur) + " " + Config.SNDS_DIR + '/tempMic.wav')
- (s2, o2) = commands.getstatusoutput("csound " + Config.FILES_DIR + "/cropSynthLab.csd")
- (s3, o3) = commands.getstatusoutput("mv " + Config.SNDS_DIR + "/micTemp " + Config.SNDS_DIR + "/" + 'labmic' + str(snd))
- (s4, o4) = commands.getstatusoutput("rm " + Config.SNDS_DIR + "/tempMic.wav")
+ if os.path.isfile(Config.DATA_DIR + '/labmic' + str(snd)):
+ os.system('rm ' + Config.DATA_DIR + '/labmic' + str(snd))
+ (s1,o1) = commands.getstatusoutput("arecord -f S16_LE -t wav -r 16000 -d " + str(dur) + " " + Config.DATA_DIR + '/tempMic.wav')
+ (s2, o2) = commands.getstatusoutput("csound " + "--strset999=" + Config.DATA_DIR + " " + Config.FILES_DIR + "/cropSynthLab.csd")
+ (s3, o3) = commands.getstatusoutput("mv " + Config.DATA_DIR + "/micTemp.wav " + Config.DATA_DIR + "/" + 'labmic' + str(snd))
+ (s4, o4) = commands.getstatusoutput("rm " + Config.DATA_DIR + "/tempMic.wav")
return
def handleMotion( self, widget, event ):
@@ -1174,7 +1175,8 @@ class SynthLabMain(gtk.EventBox):
if widget.get_active() == True:
self.recordButton = widget
self.recordWait = 1
- os.system('rm ' + Config.SNDS_DIR + '/lab' + str(data))
+ if os.path.isfile(Config.DATA_DIR + '/lab' + str(data)):
+ os.system('rm ' + Config.DATA_DIR + '/lab' + str(data))
self.table = 85 + data
else:
self.recordWait = 0
@@ -1304,7 +1306,7 @@ class SynthLabMain(gtk.EventBox):
filter = gtk.FileFilter()
filter.add_pattern('*.syn')
chooser.set_filter(filter)
- chooser.set_current_folder(Config.SYNTH_DIR)
+ chooser.set_current_folder(Config.DATA_DIR)
for f in chooser.list_shortcut_folder_uris():
chooser.remove_shortcut_folder_uri(f)
@@ -1334,7 +1336,7 @@ class SynthLabMain(gtk.EventBox):
filter = gtk.FileFilter()
filter.add_pattern('*.syn')
chooser.set_filter(filter)
- chooser.set_current_folder(Config.SYNTH_DIR)
+ chooser.set_current_folder(Config.DATA_DIR)
for f in chooser.list_shortcut_folder_uris():
chooser.remove_shortcut_folder_uri(f)
@@ -1356,13 +1358,13 @@ class SynthLabMain(gtk.EventBox):
f.close()
def handleSaveTemp( self ):
- file = Config.PREF_DIR + '/synthTemp'
+ file = Config.TMP_DIR + '/synthTemp'
f = shelve.open(file, 'n')
self.saveState(f)
f.close()
def handleLoadTemp( self ):
- file = Config.PREF_DIR + '/synthTemp'
+ file = Config.TMP_DIR + '/synthTemp'
f = shelve.open(file, 'r')
self.loadState(f)
f.close()
diff --git a/TamTamSynthLab.activity/TamTamSynthLab.py b/TamTamSynthLab.activity/TamTamSynthLab.py
index 496dd97..483d4f0 100644
--- a/TamTamSynthLab.activity/TamTamSynthLab.py
+++ b/TamTamSynthLab.activity/TamTamSynthLab.py
@@ -21,7 +21,11 @@ from sugar.activity import activity
class TamTamSynthLab(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
- self.ensure_dirs()
+
+ for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']:
+ if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)):
+ shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.DATA_DIR + '/' + snd)
+ os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &')
color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
self.modify_bg(gtk.STATE_NORMAL, color)
@@ -93,7 +97,6 @@ class TamTamSynthLab(activity.Activity):
def onDestroy(self, arg2):
if Config.DEBUG: print 'DEBUG: TamTam::onDestroy()'
- os.system('rm -f ' + Config.PREF_DIR + '/synthTemp*')
self.synthLab.onDestroy()
@@ -103,6 +106,7 @@ class TamTamSynthLab(activity.Activity):
gtk.main_quit()
+# No more dir created by TamTam
def ensure_dir(self, dir, perms=0777, rw=os.R_OK|os.W_OK):
if not os.path.isdir( dir ):
try:
@@ -112,20 +116,6 @@ class TamTamSynthLab(activity.Activity):
if not os.access(dir, rw):
print 'ERROR: directory %s is missing required r/w access\n' % dir
- def ensure_dirs(self):
- 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):
- os.mkdir(Config.PREF_DIR)
- os.system('chmod 0777 ' + Config.PREF_DIR + ' &')
- for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']:
- shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.SNDS_DIR + '/' + snd)
- os.system('chmod 0777 ' + Config.SNDS_DIR + '/' + snd + ' &')
-
def read_file(self,file_path):
self.synthLab.handleJournalLoad(file_path)
diff --git a/common/Config.py b/common/Config.py
index 8019334..0bf0210 100644
--- a/common/Config.py
+++ b/common/Config.py
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
import os, sys, time
-from sugar.activity.activity import get_bundle_path
+from sugar.activity.activity import get_bundle_path, get_activity_root
from sugar import env
#QUICKLOAD = os.path.isfile("QUICKLOAD") # skip loading inessential comenents to speed things up
SugarMode = True
-print "cwd:", os.getcwd()
if os.path.isfile("DEBUG"):
f = open("DEBUG")
l = f.read(10)
@@ -28,36 +27,35 @@ def logwrite(level, msg):
print >> logwrite.file, 'L%i:%f: %s'% (level, time.time(), msg)
logwrite.file.flush()
-
-
TAM_TAM_ROOT = get_bundle_path()
print 'INFO: loaded TAMTAM_ROOT=%s' % TAM_TAM_ROOT
+FILES_DIR = TAM_TAM_ROOT + "/common/Resources"
#PATHS
if os.path.isdir("/usr/share/tamtam/Sounds"):
SOUNDS_DIR = "/usr/share/tamtam/Sounds"
LIB_DIR = "/usr/share/tamtam"
else:
- SOUNDS_DIR = "/usr/share/activities/TamTamEdit.activity/common/Resources/Sounds"
- LIB_DIR = "/usr/share/activities/TamTamEdit.activity/common/Resources"
-FILES_DIR = TAM_TAM_ROOT + "/common/Resources"
-TUNE_DIR='/'
-SYNTH_DIR='/'
+ SOUNDS_DIR = "/home/olpc/Activities/TamTamEdit.activity/common/Resources/Sounds"
+ LIB_DIR = "/home/olpc/Activities/TamTamEdit.activity/common/Resources"
+
if SugarMode == True:
- PREF_DIR = env.get_profile_path() + '/tamtam'
- 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/"
+ if not os.path.isdir(os.path.join(get_activity_root(), 'data', 'snds_info')):
+ os.system("mkdir " + os.path.join(get_activity_root(), 'data', 'snds_info'))
+ INSTANCE_DIR = os.path.join(get_activity_root(), 'instance')
+ DATA_DIR = os.path.join(get_activity_root(), 'data')
+ TMP_DIR = os.path.join(get_activity_root(), 'tmp')
+ SNDS_DIR = DATA_DIR
+
+ SNDS_INFO_DIR = os.path.join(get_activity_root(), 'data', 'snds_info')
+
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/"
+ SCRATCH_DIR = os.getenv('HOME') + '/tamtam/.scratch'
#PLUGIN
PLUGIN_DEBUG = "STDERR"
@@ -92,6 +90,8 @@ CSOUND_NOTE_OFF = 'i %s.%s .2 0.01 1. 0. 0. 0.5 %d 0 0 0 0' %('%d','%d',INSTRUME
CSOUND_LOAD_LS_INSTRUMENT = 'f4999 0 0 -1 \"%s\" 0 0 0'
CSOUND_PLAY_LS_NOTE = 'i %i 0 -1'
CSOUND_STOP_LS_NOTE = 'i 5022 0 0.5'
+CSOUND_RECORD_PERF = 'i5400 0 -1 "%s"'
+CSOUND_STOP_RECORD_PERF = 'i5401 4 1 "%s"'
#################
@@ -102,7 +102,7 @@ LANGUAGE = 'En'
if os.path.isdir("/usr/share/tamtam/Images"):
IMAGE_ROOT = '/usr/share/tamtam/Images/'
else:
- IMAGE_ROOT = "/usr/share/activities/TamTamEdit.activity/common/Resources/Images/"
+ IMAGE_ROOT = "/home/olpc/Activities/TamTamEdit.activity/common/Resources/Images/"
MAIN_WINDOW_PADDING = 5
BG_COLOR = '#404040'
diff --git a/common/Resources/crop.csd b/common/Resources/crop.csd
index 03b10a5..483e578 100644
--- a/common/Resources/crop.csd
+++ b/common/Resources/crop.csd
@@ -14,8 +14,9 @@ nchnls=1
Playing temp file
****************************************************************/
instr 1
-
-asig diskin "/home/olpc/.sugar/default/tamtam/snds/tempMic.wav", 1
+Spath strget 999
+Stempfile strcat Spath, "/tempMic.wav"
+asig diskin Stempfile, 1
gasig dcblock asig
endin
@@ -45,9 +46,12 @@ kenv adsr 0.01, 0.05, .9, 0.01
adel delay gasig, .005
-ihandle fiopen "/home/olpc/.sugar/default/tamtam/snds/micTemp", 2
+Spath strget 999
+Sfile strcat Spath, "/micTemp.wav"
+
+ihandle fiopen Sfile, 2
-fout "/home/olpc/.sugar/default/tamtam/snds/micTemp", 2, adel*kenv
+fout Sfile, 2, adel*kenv
;out adel*kenv
adel = 0
@@ -57,7 +61,9 @@ endin
Audio input recording ( closing file )
****************************************************************/
instr 4
-ficlose "/home/olpc/.sugar/default/tamtam/snds/micTemp"
+Spath strget 999
+Sfile strcat Spath, "/micTemp.wav"
+ficlose Sfile
endin
diff --git a/common/Resources/cropSynthLab.csd b/common/Resources/cropSynthLab.csd
index cd1e25f..4abf203 100644
--- a/common/Resources/cropSynthLab.csd
+++ b/common/Resources/cropSynthLab.csd
@@ -15,9 +15,11 @@ Playing temp file
****************************************************************/
instr 1
-gilen filelen "/home/olpc/.sugar/default/tamtam/snds/tempMic.wav"
+Spath strget 999
+Stempfile strcat Spath, "/tempMic.wav"
+gilen filelen Stempfile
p3 = gilen
-asig diskin "/home/olpc/.sugar/default/tamtam/snds/tempMic.wav", 1
+asig diskin Stempfile, 1
gasig dcblock asig
endin
@@ -43,9 +45,12 @@ kenv adsr 0.01, 0.05, .9, 0.01
adel delay gasig, .005
-ihandle fiopen "/home/olpc/.sugar/default/tamtam/snds/micTemp", 2
+Spath strget 999
+Sfile strcat Spath, "/micTemp.wav"
-fout "/home/olpc/.sugar/default/tamtam/snds/micTemp", 2, adel*kenv
+ihandle fiopen Sfile, 2
+
+fout Sfile, 2, adel*kenv
;out adel*kenv
adel = 0
@@ -55,7 +60,9 @@ endin
Audio input recording ( closing file )
****************************************************************/
instr 4
-ficlose "/home/olpc/.sugar/default/tamtam/snds/micTemp"
+Spath strget 999
+Sfile strcat Spath, "/micTemp.wav"
+ficlose Sfile
endin
diff --git a/common/Resources/tamtamorc.csd b/common/Resources/tamtamorc.csd
index af430ef..1563a9f 100644
--- a/common/Resources/tamtamorc.csd
+++ b/common/Resources/tamtamorc.csd
@@ -15,6 +15,7 @@ gaoutR init 0
gasynth init 0
gkTrackpadX init 0
gkTrackpadY init 0
+gSpath strcpy " "
/*****************************
matrix for TamTam's SynthLab
@@ -394,9 +395,10 @@ elseif iSourceType == 9 then
aSource homeSine p4*kpara1, kpara2*0.1, iPar3+30
aSource = aSource*kpara4
elseif iSourceType == 10 then
- Sname sprintf "/home/olpc/.sugar/default/tamtam/snds/labmic%d", iPar2
+ Sname sprintf "/labmic%d", iPar2
+ Sfullname strcat gSpath, Sname
iSndpitch = p4/261.626
- aSource diskin Sname, iSndpitch*abs(kpara3), 0, 1
+ aSource diskin Sfullname, iSndpitch*abs(kpara3), 0, 1
aSource = aSource * kpara4
endif
@@ -533,7 +535,7 @@ endin
Performance recording start
*****************************************************************/
instr 5400
-Sname strcpy "/home/olpc/.sugar/default/tamtam/perf.wav"
+Sname strget p4
ihandle fiopen Sname, 2
fout Sname, 2, gaRecL, gaRecR
clear gaRecL, gaRecR
@@ -543,7 +545,7 @@ endin
Performance recording stop ( closing file )
*****************************************************************/
instr 5401
-Sname strcpy "/home/olpc/.sugar/default/tamtam/perf.wav"
+Sname strget p4
turnoff2 5400, 8, 0
ficlose Sname
endin
@@ -614,8 +616,9 @@ SynthLab input recording
****************************************************************/
instr 5204
-Sname2 sprintf "/home/olpc/.sugar/default/tamtam/snds/lab%d", int(p4)-85
-fout Sname2, 2, gasynth
+Sname sprintf "/lab%d", int(p4)-85
+Sfile strcat gSpath, Sname
+fout Sfile, 2, gasynth
clear gasynth
endin
@@ -624,6 +627,8 @@ TamTam's SynthLab instrument
************************/
instr 5203
+gSpath strget p10
+
if p5 != 0 then
event_i "i", 5204, 0, p3, p5
endif
diff --git a/common/Util/CSoundClient.py b/common/Util/CSoundClient.py
index 7e8ef78..69ed50f 100644
--- a/common/Util/CSoundClient.py
+++ b/common/Util/CSoundClient.py
@@ -95,7 +95,10 @@ class _CSoundClientPlugin:
def load_instruments( self ):
for instrumentSoundFile in self.instrumentDB.instNamed.keys():
if instrumentSoundFile[0:3] == 'mic' or instrumentSoundFile[0:3] == 'lab' or self.instrumentDB.instNamed[instrumentSoundFile].category == 'mysounds':
- fileName = Config.SNDS_DIR + '/' + instrumentSoundFile
+ try:
+ fileName = Config.JAM_DIR + '/' + instrumentSoundFile
+ except:
+ fileName = Config.SNDS_DIR + '/' + instrumentSoundFile
else:
fileName = Config.SOUNDS_DIR + "/" + instrumentSoundFile
instrumentId = Config.INSTRUMENT_TABLE_OFFSET + self.instrumentDB.instNamed[ instrumentSoundFile ].instrumentId
@@ -104,7 +107,10 @@ class _CSoundClientPlugin:
def load_instrument(self, inst):
if not inst in loadedInstruments:
if inst[0:3] == 'mic' or inst[0:3] == 'lab' or self.instrumentDB.instNamed[inst].category == 'mysounds':
- fileName = Config.SNDS_DIR + '/' + inst
+ try:
+ fileName = Config.JAM_DIR + '/' + inst
+ except:
+ fileName = Config.SNDS_DIR + '/' + inst
else:
fileName = Config.SOUNDS_DIR + "/" + inst
instrumentId = Config.INSTRUMENT_TABLE_OFFSET + self.instrumentDB.instNamed[ inst ].instrumentId
diff --git a/common/Util/Instruments.py b/common/Util/Instruments.py
index 12e755a..ef22bce 100644
--- a/common/Util/Instruments.py
+++ b/common/Util/Instruments.py
@@ -1,6 +1,7 @@
import os
import common.Config as Config
import common.Util.InstrumentDB as InstrumentDB
+from sugar.activity.activity import get_bundle_name
LOW = Config.LOW
MID = Config.MID
@@ -182,6 +183,8 @@ try:
except:
pass
+#jamId = os.path.split(os.path.realpath("/home/olpc/isolation/1/bundle_id_to_gid/org.laptop.TamTamJam"))[1]
+
DRUM1KIT = { 24 : "drum1kick",
26 : "drum1floortom",
diff --git a/common/Util/LoopSettings.py b/common/Util/LoopSettings.py
index a717089..f389275 100644
--- a/common/Util/LoopSettings.py
+++ b/common/Util/LoopSettings.py
@@ -136,7 +136,7 @@ class LoopSettings( gtk.VBox ):
self.show_all()
def handleCheck(self, widget):
- ofile = open(Config.PREF_DIR + "/sounds_settings", 'a')
+ ofile = open(Config.DATA_DIR + "/sounds_settings", 'a')
name = self.nameEntry.get_text()
if self.loopedSound:
tied = str(Config.INST_TIED)