Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/common/Util
diff options
context:
space:
mode:
authorOli <olivier.belanger@umontreal.ca>2007-10-26 05:50:30 (GMT)
committer Oli <olivier.belanger@umontreal.ca>2007-10-26 05:50:30 (GMT)
commit9583b21dae8041c6544fb37de00ca42b034ebc98 (patch)
tree4c37d754cdaa5b332969f7fc30f0bba31025d006 /common/Util
parent3aebf3dad1f5c137a5182cfe06b8edc778a5ddb9 (diff)
miniT tabs cleanup, loop settings moved to Jam
Diffstat (limited to 'common/Util')
-rw-r--r--common/Util/CSoundClient.py5
-rw-r--r--common/Util/InstrumentDB.py25
-rw-r--r--common/Util/Instruments.py8
3 files changed, 22 insertions, 16 deletions
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