Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Util/CSoundClient.py
diff options
context:
space:
mode:
authorJames <olpc@localhost.localdomain>2007-02-28 02:15:04 (GMT)
committer James <olpc@localhost.localdomain>2007-02-28 02:15:04 (GMT)
commit23b868606bb363d10499be3a09128c088f950421 (patch)
tree55385466eaa61187605f7e40200f7f22b639b2a5 /Util/CSoundClient.py
parentb2b3c26ff63f7231bfbe1bdfea14b84f5aa90b65 (diff)
drum switching works in mini
Diffstat (limited to 'Util/CSoundClient.py')
-rw-r--r--Util/CSoundClient.py42
1 files changed, 30 insertions, 12 deletions
diff --git a/Util/CSoundClient.py b/Util/CSoundClient.py
index 399df60..ad68a0b 100644
--- a/Util/CSoundClient.py
+++ b/Util/CSoundClient.py
@@ -83,11 +83,6 @@ class _CSoundClientPlugin:
print 'WARNING: replacing sendText() with inputMessage(%s)' % txt[19:-3]
sc_inputMessage( txt[19:-3] )
- def loopSet_onset_note(self, onset_note):
- sc_loop_clear()
- for (o,n) in onset_note:
- n.playLoop() # a special non-documented CSoundNote function!
-
def loopClear(self):
sc_loop_clear()
def loopDelete(self, dbnote):
@@ -110,12 +105,18 @@ class _CSoundClientPlugin:
print 'INFO: loop tempo: %f -> %f' % (t, 60.0 / (Config.TICKS_PER_BEAT * t))
sc_loop_setTickDuration( 60.0 / (Config.TICKS_PER_BEAT * t))
- def loopUpdate(self, note, parameter, value):
+ def loopDeactivate(self, note = None):
+ if note == None:
+ sc_loop_deactivate_all()
+ else:
+ print 'ERROR: deactivating a single note is not implemented'
+
+ def loopUpdate(self, note, parameter, value,cmd):
page = note.page
id = note.id
if (parameter == NoteDB.PARAMETER.ONSET):
print 'INFO: updating onset', (page<<16)+id, value
- sc_loop_updateEvent( (page<<16)+id, 1, value)
+ sc_loop_updateEvent( (page<<16)+id, 1, value, cmd)
elif (parameter == NoteDB.PARAMETER.PITCH):
print 'INFO: updating pitch', (page<<16)+id, value
pitch = value
@@ -135,18 +136,35 @@ class _CSoundClientPlugin:
pitch = 1
else:
pitch = GenerationConstants.TRANSPOSE[ pitch - 24 ]
- sc_loop_updateEvent( (page<<16)+id, 3, pitch)
+ sc_loop_updateEvent( (page<<16)+id, 3, pitch, cmd)
elif (parameter == NoteDB.PARAMETER.AMPLITUDE):
print 'INFO: updating amp', (page<<16)+id, value
- sc_loop_updateEvent( (page<<16)+id, 5, value)
+ sc_loop_updateEvent( (page<<16)+id, 5, value, cmd)
elif (parameter == NoteDB.PARAMETER.DURATION):
print 'INFO: updating duration', (page<<16)+id, value
- sc_loop_updateEvent( (page<<16)+id, 2, 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
+ sc_loop_updateEvent( (page<<16)+id, 0, csoundInstId + note.track * 0.01, cmd )
+ sc_loop_updateEvent( (page<<16)+id, 7, csoundTable , -1 )
else:
print 'ERROR: loopUpdate(): unsupported parameter change'
- def loopPlay(self, dbnote):
+ def loopPlay(self, dbnote, active):
+ print 'INFO: adding note ', (dbnote.page<<16)+dbnote.id
qid = (dbnote.page << 16) + dbnote.id
- sc_loop_addScoreEvent( qid, 1, 'i', self.csnote_to_array(dbnote.cs))
+ 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