Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorOli <olivier.belanger@umontreal.ca>2008-04-10 03:30:59 (GMT)
committer Oli <olivier.belanger@umontreal.ca>2008-04-10 03:30:59 (GMT)
commit2fa8060b7fd790b3260e65d225a4eca5080683a7 (patch)
treebecc0461cffa308ecf5f77acb9ee130ada0a728c /common
parent957af9bf585d58518bb275ec4926ed11bbd3285e (diff)
On the way to respect security policy
Diffstat (limited to 'common')
-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
7 files changed, 64 insertions, 37 deletions
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)