diff options
author | amartin <olpc@localhost.localdomain> | 2007-03-01 23:23:38 (GMT) |
---|---|---|
committer | amartin <olpc@localhost.localdomain> | 2007-03-01 23:23:38 (GMT) |
commit | 4a2707833481847966876009c21b4842671df4b4 (patch) | |
tree | e1031144155c1383936d68a7a0f7b21cfae390cb /Util/CSoundClient.py | |
parent | b048a6c2cf509e5f78bda23c0888abd4d230b626 (diff) |
CSoundNote now uses .instrumentId, and .instrument and .instrumentFlag are no longer valid
BE WARNED!?
Diffstat (limited to 'Util/CSoundClient.py')
-rw-r--r-- | Util/CSoundClient.py | 68 |
1 files changed, 23 insertions, 45 deletions
diff --git a/Util/CSoundClient.py b/Util/CSoundClient.py index c2b5a9f..66f5949 100644 --- a/Util/CSoundClient.py +++ b/Util/CSoundClient.py @@ -124,21 +124,11 @@ class _CSoundClientPlugin: elif (parameter == NoteDB.PARAMETER.PITCH): print 'INFO: updating pitch', (page<<16)+id, value pitch = value - instr = note.cs.instrumentFlag - if instr[0:4] == 'drum': - if pitch in GenerationConstants.DRUMPITCH: - key = GenerationConstants.DRUMPITCH[ pitch ] - else: - key = pitch - - if instr == 'drum1kit': - instr = Config.DRUM1INSTRUMENTS[ key ] - if instr == 'drum2kit': - instr = Config.DRUM2INSTRUMENTS[ key ] - if instr == 'drum3kit': - instr = Config.DRUM3INSTRUMENTS[ key ] + if Config.INSTRUMENTSID[note.cs.instrumentId].kit != None: + instr = Config.INSTRUMENTSID[note.cs.instrumentId].kit[pitch].name pitch = 1 else: + instr = Config.INSTRUMENTSID[note.cs.instrumentId].name pitch = GenerationConstants.TRANSPOSE[ pitch - 24 ] sc_loop_updateEvent( (page<<16)+id, 3, pitch, cmd) elif (parameter == NoteDB.PARAMETER.AMPLITUDE): @@ -148,19 +138,13 @@ class _CSoundClientPlugin: print 'INFO: updating duration', (page<<16)+id, value sc_loop_updateEvent( (page<<16)+id, 2, value, cmd) elif (parameter == NoteDB.PARAMETER.INSTRUMENT): - instr = value pitch = note.cs.pitch - if instr[0:4] == 'drum': - if pitch in GenerationConstants.DRUMPITCH: - key = GenerationConstants.DRUMPITCH[ pitch ] - else: - key = pitch - - if instr in Config.DRUMKITS: - instr = Config.DRUMSINSTRUMENTSDICT[Config.DRUMKITS.index(instr)][ key ] - csoundInstId = Config.INSTRUMENTS[ instr ].csoundInstrumentId - csoundTable = Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[instr].instrumentId - print 'INFO: updating instrument', (page<<16)+id, instr, csoundInstId + instrument = Config.INSTRUMENTSID[value] + if instrument.kit != None: + instrument = instrument.kit[pitch] + csoundInstId = instrument.csoundInstrumentId + csoundTable = Config.INSTRUMENT_TABLE_OFFSET + instrument.instrumentId + print 'INFO: updating instrument', (page<<16)+id, instrument.name, csoundInstId sc_loop_updateEvent( (page<<16)+id, 0, csoundInstId + note.track * 0.01, cmd ) sc_loop_updateEvent( (page<<16)+id, 7, csoundTable , -1 ) else: @@ -192,7 +176,7 @@ class _CSoundClientPlugin: csnote.filterCutoff, csnote.tied, csnote.overlap, - csnote.instrumentFlag) + csnote.instrumentId) INSTR_TRACK=0 ONSET=1 @@ -215,54 +199,48 @@ class _CSoundClientPlugin: filterCutoff = 1000, tied = False, overlap = False, - instr = Config.FLUTE ): - - if instr[0:4] == 'drum': - if pitch in GenerationConstants.DRUMPITCH: - key = GenerationConstants.DRUMPITCH[ pitch ] - else: - key = pitch - - if instr in Config.DRUMKITS: - instr = Config.DRUMSINSTRUMENTSDICT[Config.DRUMKITS.index(instr)][ key ] + instrumentId = Config.INSTRUMENTS["flute"].instrumentId ): + instrument = Config.INSTRUMENTSID[instrumentId] + if instrument.kit != None: + instrument = instrument.kit[pitch] pitch = 1 time_in_ticks = 0 else: pitch = GenerationConstants.TRANSPOSE[ pitch - 24 ] # condition for tied notes - if Config.INSTRUMENTS[ instr ].csoundInstrumentId == 101 and tied and fullDuration: + if instrument.csoundInstrumentId == 101 and tied and fullDuration: duration= -1.0 # condition for overlaped notes - if Config.INSTRUMENTS[ instr ].csoundInstrumentId == 102 and overlap: + if instrument.csoundInstrumentId == 102 and overlap: duration += 1.0 time_in_ticks = 1 # condition for tied notes - if Config.INSTRUMENTS[ instr].csoundInstrumentId == Config.INST_TIED and tied and fullDuration: + if instrument.csoundInstrumentId == Config.INST_TIED and tied and fullDuration: duration = -1 # condition for overlaped notes - if Config.INSTRUMENTS[ instr ].csoundInstrumentId == Config.INST_PERC and overlap: + if instrument.csoundInstrumentId == Config.INST_PERC and overlap: duration = duration + 1.0 a = array.array('f') a.extend( [ - (Config.INSTRUMENTS[ instr ].csoundInstrumentId + trackId) + trackId * 0.01, + (instrument.csoundInstrumentId + trackId) + trackId * 0.01, onset, duration, pitch, reverbSend, amplitude, pan, - Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[instr].instrumentId, + Config.INSTRUMENT_TABLE_OFFSET + instrument.instrumentId, attack, decay, filterType, filterCutoff, - Config.INSTRUMENTS[ instr ].loopStart, - Config.INSTRUMENTS[ instr ].loopEnd, - Config.INSTRUMENTS[ instr ].crossDur ]) + instrument.loopStart, + instrument.loopEnd, + instrument.crossDur ]) return a |