diff options
author | Oli <olpc@localhost.localdomain> | 2007-03-04 23:44:20 (GMT) |
---|---|---|
committer | Oli <olpc@localhost.localdomain> | 2007-03-04 23:44:20 (GMT) |
commit | 90fd4e1f17ea44f5886c8714cc085f69ea068695 (patch) | |
tree | c6d344260b369befe8c7bfb47ef55fa7d8743b4f /Util | |
parent | f30b36406907dc1956a18c550fe2fdfa151323f4 (diff) |
new instrument for edit's notes
Diffstat (limited to 'Util')
-rw-r--r-- | Util/CSoundClient.py | 29 | ||||
-rw-r--r-- | Util/CSoundNote.py | 99 |
2 files changed, 63 insertions, 65 deletions
diff --git a/Util/CSoundClient.py b/Util/CSoundClient.py index 4d30dbb..79ad8f3 100644 --- a/Util/CSoundClient.py +++ b/Util/CSoundClient.py @@ -153,6 +153,7 @@ class _CSoundClientPlugin: def loopPlay(self, dbnote, active): qid = (dbnote.page << 16) + dbnote.id sc_loop_addScoreEvent( qid, 1, active, 'i', self.csnote_to_array(dbnote.cs)) + def play(self, csnote, secs_per_tick): a = self.csnote_to_array(csnote) a[self.DURATION] = a[self.DURATION] * secs_per_tick @@ -175,8 +176,8 @@ class _CSoundClientPlugin: csnote.filterType, csnote.filterCutoff, csnote.tied, - csnote.overlap, - csnote.instrumentId) + csnote.instrumentId, + csnote.mode) INSTR_TRACK=0 ONSET=1 @@ -198,8 +199,8 @@ class _CSoundClientPlugin: filterType = 0, filterCutoff = 1000, tied = False, - overlap = False, - instrumentId = Config.INSTRUMENTS["flute"].instrumentId ): + instrumentId = Config.INSTRUMENTS["flute"].instrumentId, + mode = 'edit' ): instrument = Config.INSTRUMENTSID[instrumentId] if instrument.kit != None: @@ -208,25 +209,21 @@ class _CSoundClientPlugin: time_in_ticks = 0 else: pitch = GenerationConstants.TRANSPOSE[ pitch - 24 ] - - # condition for tied notes - if instrument.csoundInstrumentId == 101 and tied and fullDuration: - duration= -1.0 - # condition for overlaped notes - if instrument.csoundInstrumentId == 102 and overlap: - duration += 1.0 time_in_ticks = 1 + instrument_offset = 0 # condition for tied notes - if instrument.csoundInstrumentId == Config.INST_TIED and tied and fullDuration: + if instrument.csoundInstrumentId == Config.INST_TIED and tied and mode == 'mini': duration = -1 - # condition for overlaped notes - if instrument.csoundInstrumentId == Config.INST_PERC and overlap: - duration = duration + 1.0 + instrument_offset = 0 + elif instrument.csoundInstrumentId == Config.INST_TIED and not tied and mode == 'mini': + instrument_offset = 0 + elif instrument.csoundInstrumentId == Config.INST_TIED and mode == 'edit': + instrument_offset = 100 a = array.array('f') a.extend( [ - (instrument.csoundInstrumentId + trackId) + trackId * 0.01, + (instrument.csoundInstrumentId + trackId + instrument_offset) + trackId * 0.01, onset, duration, pitch, diff --git a/Util/CSoundNote.py b/Util/CSoundNote.py index 226ed51..f1c9d85 100644 --- a/Util/CSoundNote.py +++ b/Util/CSoundNote.py @@ -21,7 +21,7 @@ class CSoundNote : filterType = 0, filterCutoff = 1000, tied = False, - overlap = False ): + mode = 'edit' ): self.onset = onset self.pitch = pitch @@ -39,7 +39,7 @@ class CSoundNote : self.filterType = filterType self.filterCutoff = filterCutoff self.tied = tied - self.overlap = overlap + self.mode = mode self.nchanges = 0 self.noteId = self.NOTE_ID_COUNTER self.NOTE_ID_COUNTER += 1 @@ -59,7 +59,7 @@ class CSoundNote : 'filterType': self.filterType, 'filterCutoff': self.filterCutoff, 'tied': self.tied, - 'overlap': self.overlap } + 'mode': self.mode } def __setstate__(self,dict): self.onset = dict['onset'] @@ -76,58 +76,59 @@ class CSoundNote : self.filterType = dict['filterType'] self.filterCutoff = dict['filterCutoff'] self.tied = dict['tied'] - self.overlap = dict['overlap'] + 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.fullDuration, self.instrumentId, - self.attack, self.decay, self.reverbSend, self.filterType, self.filterCutoff, self.tied, self.overlap ) + self.attack, self.decay, self.reverbSend, self.filterType, self.filterCutoff, self.tied, self.mode ) - def getText( self, secs_per_tick, delay ): - if secs_per_tick > 1 : raise 'invalid secs_per_tick' - if Config.INSTRUMENTSID[self.instrumentId].kit != None: - instr = Config.INSTRUMENTSID[self.instrumentId].key[self.pitch] - newPitch = 1 - else: - instr = self.INSTRUMENTSID[self.instrumentId] - newPitch = pow( GenerationConstants.TWO_ROOT_TWELVE, self.pitch - 36 ) - newDuration = secs_per_tick * self.duration +# def getText( self, secs_per_tick, delay ): +# if secs_per_tick > 1 : raise 'invalid secs_per_tick' +# if Config.INSTRUMENTSID[self.instrumentId].kit != None: +# instr = Config.INSTRUMENTSID[self.instrumentId].key[self.pitch] +# newPitch = 1 +# else: +# instr = self.INSTRUMENTSID[self.instrumentId] +# newPitch = pow( GenerationConstants.TWO_ROOT_TWELVE, self.pitch - 36 ) +# +# newDuration = secs_per_tick * self.duration +# +# # condition for tied notes +# if instr.csoundInstrumentId == 101 and self.tied and self.fullDuration: +# newDuration = -1 +# # condition for overlaped notes +# if instr.csoundInstrumentId == 102 and self.overlap: +# newDuration = oneTickDuration * self.duration + 1. +# +# if True: newAmplitude = self.amplitude * 0.8 +# else : newAmplitude = self.amplitude * music_volume_get( self.trackId ) +# +# newAttack = newDuration * self.attack +# if newAttack <= 0.002: +# newAttack = 0.002 +# +# newDecay = newDuration * self.decay +# if newDecay <= 0.002: +# newDecay = 0.002 - # condition for tied notes - if instr.csoundInstrumentId == 101 and self.tied and self.fullDuration: - newDuration = -1 - # condition for overlaped notes - if instr.csoundInstrumentId == 102 and self.overlap: - newDuration = oneTickDuration * self.duration + 1. - - if True: newAmplitude = self.amplitude * 0.8 - else : newAmplitude = self.amplitude * music_volume_get( self.trackId ) - - newAttack = newDuration * self.attack - if newAttack <= 0.002: - newAttack = 0.002 - - newDecay = newDuration * self.decay - if newDecay <= 0.002: - newDecay = 0.002 - - return Config.PLAY_NOTE_COMMAND % ( \ - instr.csoundInstrumentId, - self.trackId, - delay, - newDuration, - newPitch, - self.reverbSend, - newAmplitude, - self.pan, - Config.INSTRUMENT_TABLE_OFFSET+instr.instrumentId, - newAttack, - newDecay, - self.filterType, - self.filterCutoff, - instr.loopStart, - instr.loopEnd, - instr.crossDur ) +# return Config.PLAY_NOTE_COMMAND % ( \ +# instr.csoundInstrumentId, +# self.trackId, +# delay, +# newDuration, +# newPitch, +# self.reverbSend, +# newAmplitude, + # self.pan, +# Config.INSTRUMENT_TABLE_OFFSET+instr.instrumentId, +# newAttack, +# newDecay, +# self.filterType, +# self.filterCutoff, +# instr.loopStart, +# instr.loopEnd, +# instr.crossDur ) |