diff options
author | Oli <olivier.belanger@umontreal.ca> | 2007-08-15 06:39:59 (GMT) |
---|---|---|
committer | Oli <olivier.belanger@umontreal.ca> | 2007-08-15 06:39:59 (GMT) |
commit | 1b9d2cd2bd9e3135b2aedd16e8cebc59d483c088 (patch) | |
tree | 8f4c22571c68325fb730efa5f45d07046a1e3e2f /Util | |
parent | f5e6fbe03050917940ea5673adb6625971e7eb6d (diff) |
dual instruments on melodic tracks
Diffstat (limited to 'Util')
-rw-r--r-- | Util/CSoundClient.py | 23 | ||||
-rw-r--r-- | Util/CSoundNote.py | 46 | ||||
-rw-r--r-- | Util/NoteDB.py | 17 |
3 files changed, 51 insertions, 35 deletions
diff --git a/Util/CSoundClient.py b/Util/CSoundClient.py index 0a10d21..8cc9ec2 100644 --- a/Util/CSoundClient.py +++ b/Util/CSoundClient.py @@ -26,7 +26,8 @@ class _CSoundClientPlugin: ATTACK, \ DECAY, \ FILTERTYPE, \ - FILTERCUTOFF ) = range(12) + FILTERCUTOFF, \ + INSTRUMENT2 ) = range(13) def __init__(self): sc_initialize( Config.PLUGIN_UNIVORC, Config.PLUGIN_DEBUG, @@ -204,9 +205,12 @@ class _CSoundClientPlugin: sc_loop_updateEvent( (page<<16)+id, self.FILTERTYPE, value, cmd) elif (parameter == NoteDB.PARAMETER.FILTERCUTOFF): sc_loop_updateEvent( (page<<16)+id, self.FILTERCUTOFF, value, cmd) + elif (parameter == NoteDB.PARAMETER.INSTRUMENT2): + sc_loop_updateEvent( (page<<16)+id, self.INSTRUMENT2, value, cmd) else: if (Config.DEBUG > 0): print 'ERROR: loopUpdate(): unsupported parameter change' + def loopPlay(self, dbnote, active): qid = (dbnote.page << 16) + dbnote.id sc_loop_addScoreEvent( qid, 1, active, 'i', self.csnote_to_array(dbnote.cs)) @@ -233,7 +237,8 @@ class _CSoundClientPlugin: csnote.filterCutoff, csnote.tied, csnote.instrumentId, - csnote.mode) + csnote.mode, + csnote.instrumentId2 ) def csnote_to_array1( self, onset, pitch, @@ -248,7 +253,8 @@ class _CSoundClientPlugin: filterCutoff = 1000, tied = False, instrumentId = Config.INSTRUMENTS["flute"].instrumentId, - mode = 'edit' ): + mode = 'edit', + instrumentId2 = -1 ): instrument = Config.INSTRUMENTSID[instrumentId] if instrument.kit != None: @@ -281,6 +287,14 @@ class _CSoundClientPlugin: instrument_id_offset = 0 else: instrument_id_offset = 100 + + if instrumentId2 != -1: + instrument2 = Config.INSTRUMENTSID[instrumentId2] + csInstrumentId2 = (instrument2.csoundInstrumentId + 100) * 0.0001 + secondInstrument = Config.INSTRUMENT_TABLE_OFFSET + instrumentId2 + csInstrumentId2 + else: + secondInstrument = -1 + a = array.array('f') a.extend( [ (instrument.csoundInstrumentId + (trackId+1) + instrument_id_offset) + trackId * 0.01, @@ -297,7 +311,8 @@ class _CSoundClientPlugin: filterCutoff, instrument.loopStart, instrument.loopEnd, - instrument.crossDur ]) + instrument.crossDur, + secondInstrument ]) return a diff --git a/Util/CSoundNote.py b/Util/CSoundNote.py index d41fc11..7b2019e 100644 --- a/Util/CSoundNote.py +++ b/Util/CSoundNote.py @@ -1,23 +1,23 @@ import Config -from Generation.GenerationConstants import GenerationConstants class CSoundNote : def __init__( self, - onset, - pitch, - amplitude, - pan, - duration, - trackId, - instrumentId = Config.INSTRUMENTS["flute"].instrumentId, - attack = 0.002, - decay = 0.098, - reverbSend = 0.1, - filterType = 0, + onset, + pitch, + amplitude, + pan, + duration, + trackId, + instrumentId = Config.INSTRUMENTS["flute"].instrumentId, + attack = 0.005, + decay = 0.098, + reverbSend = 0.1, + filterType = 0, filterCutoff = 1000, tied = False, - mode = 'edit' ): - + mode = 'edit', + instrumentId2 = -1 ): + self.onset = onset self.pitch = pitch self.amplitude = amplitude @@ -34,6 +34,14 @@ class CSoundNote : self.filterCutoff = filterCutoff self.tied = tied self.mode = mode + self.instrumentId2 = instrumentId2 + + def clone( self ): + return CSoundNote( self.onset, self.pitch, self.amplitude, self.pan, + self.duration, self.trackId, self.instrumentId, + self.attack, self.decay, self.reverbSend, + self.filterType, self.filterCutoff, self.tied, + self.mode, self.instrumentId2 ) def __getstate__unused(self): return {'onset': self.onset, @@ -67,13 +75,3 @@ class CSoundNote : self.tied = dict['tied'] self.mode = dict['mode'] self.nchanges = 0 - - def clone( self ): - return CSoundNote( self.onset, self.pitch, self.amplitude, self.pan, - self.duration, self.trackId, self.instrumentId, - self.attack, self.decay, self.reverbSend, - self.filterType, self.filterCutoff, self.tied, - self.mode ) - - - diff --git a/Util/NoteDB.py b/Util/NoteDB.py index f6ec5de..d334670 100644 --- a/Util/NoteDB.py +++ b/Util/NoteDB.py @@ -14,8 +14,9 @@ class PARAMETER: ATTACK, \ DECAY, \ FILTERTYPE, \ - FILTERCUTOFF \ - = range(13) #python-stye enum + FILTERCUTOFF, \ + INSTRUMENT2 \ + = range(14) #python-stye enum class Note: def __init__( self, page, track, id, cs ): @@ -30,7 +31,7 @@ class Page: self.ticks = beats*Config.TICKS_PER_BEAT self.color = color - + if not instruments: self.instruments = [ Config.INSTRUMENTS["kalimba"].instrumentId for i in range(Config.NUMBER_OF_TRACKS-1) ] + [ Config.INSTRUMENTS["drum1kit"].instrumentId ] else: @@ -213,7 +214,7 @@ class NoteDB: i += 1 self.tune = self.tune[:at] + sorted + self.tune[at:] - + #self._updateBeatsBefore( low ) for l in self.pageListeners: @@ -242,9 +243,9 @@ class NoteDB: self.deleteNotes( dstream + [-1] ) if len(ustream): self.updateNotes( ustream + [-1] ) - + self.pages[page].beats = value - self.pages[page].ticks = ticks + self.pages[page].ticks = ticks #self._updateBeatsBefore(self.tune.index(page)) elif parameter == PARAMETER.PAGE_COLOR: self.pages[page].color = value @@ -302,7 +303,7 @@ class NoteDB: # for i in range(ind, len(self.tune)): # self.beatsBefore[self.tune[ind]] = beats # beats += self.pages[self.tune[ind]].beats - + #======================================================= @@ -482,6 +483,8 @@ class NoteDB: self.noteD[page][track][id].cs.filterType = value elif parameter == PARAMETER.FILTERCUTOFF: self.noteD[page][track][id].cs.filterCutoff = value + elif parameter == PARAMETER.INSTRUMENT2: + self.noteD[page][track][id].cs.instrumentId2 = value for par in self.parasiteList.keys(): self.parasiteD[page][track][par][id].updateParameter( parameter, value ) |