From 7400fb60ca6b454330996cc5b2c425b8c1e366c9 Mon Sep 17 00:00:00 2001 From: Oli Date: Tue, 09 Oct 2007 05:42:59 +0000 Subject: work on meta algo, amplitude scaled on transposition --- (limited to 'common/Util') diff --git a/common/Util/.CSoundClient.py.swp b/common/Util/.CSoundClient.py.swp new file mode 100644 index 0000000..b062a0b --- /dev/null +++ b/common/Util/.CSoundClient.py.swp Binary files differ diff --git a/common/Util/CSoundClient.py b/common/Util/CSoundClient.py index 7a9e6e3..969ee55 100644 --- a/common/Util/CSoundClient.py +++ b/common/Util/CSoundClient.py @@ -5,6 +5,7 @@ import sys import threading import time import array +from math import sqrt import common.Config as Config @@ -301,19 +302,19 @@ class _CSoundClientPlugin: instrument_id_offset = 0 elif mode == 'edit': instrument_id_offset = 100 - + if instrument.csoundInstrumentId == Config.INST_SIMP: if mode == 'mini': instrument_id_offset = 0 elif mode == 'edit': - if instrument.soundClass == 'drum': + if instrument.name[0:4] == 'drum': instrument_id_offset = 0 else: instrument_id_offset = 100 - amplitude = amplitude * instrument.ampScale - print "%f * %f = %f" % (amplitude, instrument.ampScale, amplitude * instrument.ampScale) - print "instrument %s final amplitude: %f" % (instrument.name, amplitude) + amplitude = amplitude / sqrt(pitch) #instrument.ampScale + #print "%f * %f = %f" % (amplitude, instrument.ampScale, amplitude * instrument.ampScale) + #print "instrument %s final amplitude: %f" % (instrument.name, amplitude) rval[0] = (instrument.csoundInstrumentId + \ (trackId+1) + instrument_id_offset) + trackId * 0.01 rval[1] = onset diff --git a/common/Util/InstrumentDB.py b/common/Util/InstrumentDB.py index ca1e0ef..900dd86 100644 --- a/common/Util/InstrumentDB.py +++ b/common/Util/InstrumentDB.py @@ -10,14 +10,15 @@ class Instrument: self.id = id # build an Instrument instance from argument list - def loadFromArgs( self, name, csoundInstrumentName, register, loopStart, - loopEnd, crossDur, wav, img, labels ): + def loadFromArgs( self, name, csoundInstrumentId, register, loopStart, + loopEnd, crossDur, ampScale, wav, img, labels ): self.name = name - self.csoundInstrumentName = csoundInstrumentName + self.csoundInstrumentId = csoundInstrumentId self.register = register self.loopStart = loopStart self.loopEnd = loopEnd self.crossDur = crossDur + self.ampScale = ampScale self.wav = wav self.img = img self.labels = labels @@ -29,11 +30,12 @@ class Instrument: if (magic != 'TamTam idf v1'): raise 'given file has wrong header' self.name = f.readline() - self.csoundInstrumentName = 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.wav = f.readline() self.img = f.readline() self.labels = f.readline().split() @@ -50,12 +52,12 @@ class InstrumentDB: self.kitNamed = {} # -> kit with that name # TEMP? add instrument from args - def addInstrumentFromArgs( self, name, csoundInstrumentName, register, loopStart, - loopEnd, crossDur, wav, img, labels ): - i = Instrument(len(self.inst)) + def addInstrumentFromArgs( self, name, csoundInstrumentId, register, loopStart, + loopEnd, crossDur, ampScale, wav, img, labels ): + i = Instrument(len(self.inst)) self.inst += [ i ] - i.loadFromArgs( name, csoundInstrumentName, register, loopStart, loopEnd, crossDur, wav, img, labels ) - #print 'labelSet... ', self.labelSet + i.loadFromArgs( name, csoundInstrumentId, register, loopStart, loopEnd, crossDur, ampScale, wav, img, labels ) + #print 'labelSet... ', self.labelSet self.labelSet['All'].add(i) for l in i.labels: if l not in self.labelSet: @@ -65,7 +67,7 @@ class InstrumentDB: # add an instrument to the DB by reading from an instrument definition file def addInstrument( self, path ): - i = Instrument(len(self.inst)) + i = Instrument(len(self.inst)) self.inst += [ i ] i.loadFromPath( path ) self.instNamed[ i.name ] = i @@ -140,4 +142,3 @@ if __name__ == "__main__": i1.scanInstrumentDir( sys.argv[1] ) i1.debug_summarize() - -- cgit v0.9.1