Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Util
diff options
context:
space:
mode:
authorJames <olpc@xo-05-28-3A.localdomain>2007-08-25 23:21:23 (GMT)
committer James <olpc@xo-05-28-3A.localdomain>2007-08-25 23:21:23 (GMT)
commitbb8b6f9157c4a53c8ac024e66e71a30bc554427d (patch)
treea4cbbdc43d909475af6c1f3f327474a72538cab4 /Util
parent0b9902909b213aabb734b6020d9294aaab81e100 (diff)
replaced custom setChannel commands with single plugin call
Diffstat (limited to 'Util')
-rw-r--r--Util/CSoundClient.py35
-rw-r--r--Util/Clooper/aclient.cpp137
2 files changed, 25 insertions, 147 deletions
diff --git a/Util/CSoundClient.py b/Util/CSoundClient.py
index d5a3e37..60fdd9a 100644
--- a/Util/CSoundClient.py
+++ b/Util/CSoundClient.py
@@ -12,6 +12,11 @@ from Generation.GenerationConstants import GenerationConstants
from Util.Clooper.aclient import *
from Util import NoteDB
+
+_note_template = array.array('f', [0] * 19 )
+def _new_note_array():
+ return _note_template.__copy__()
+
class _CSoundClientPlugin:
#array index constants for csound
@@ -43,25 +48,30 @@ class _CSoundClientPlugin:
sc_destroy()
def setChannel(self, name, val):
- if self.on:
- sc_setChannel(name, val)
+ sc_setChannel(name, val)
+ #if self.on:
+ #sc_setChannel(name, val)
def setMasterVolume(self, volume):
+ sc_setChannel( 'masterVolume', volume)
#self.masterVolume = volume
- if self.on:
- sc_setMasterVolume(volume)
+ #if self.on:
+ #sc_setMasterVolume(volume)
def setTrackVolume( self, volume, trackId ):
- self.trackVolume = volume
- sc_setTrackVolume(volume, trackId+1)
+ sc_setChannel( 'trackVolume' + str(trackId + 1), volume )
+ #self.trackVolume = volume
+ #sc_setTrackVolume(volume, trackId+1)
def setTrackpadX( self, value ):
- trackpadX = value
- sc_setTrackpadX(trackpadX)
+ #trackpadX = value
+ #sc_setTrackpadX(trackpadX)
+ sc_setChannel( 'trackpadX', value)
def setTrackpadY( self, value ):
- trackpadY = value
- sc_setTrackpadY(trackpadY)
+ #trackpadY = value
+ #sc_setTrackpadY(trackpadY)
+ sc_setChannel( 'trackpadY', value)
def micRecording( self, table ):
sc_inputMessage( Config.CSOUND_MIC_RECORD % table )
@@ -210,12 +220,12 @@ class _CSoundClientPlugin:
else:
if (Config.DEBUG > 0): print 'ERROR: loopUpdate(): unsupported parameter change'
- def loopPlay(self, dbnote, active, storage=array.array('f',[0]*15) ):
+ def loopPlay(self, dbnote, active, storage=_new_note_array() ):
qid = (dbnote.page << 16) + dbnote.id
sc_loop_addScoreEvent( qid, 1, active, 'i',
self.csnote_to_array( dbnote.cs, storage))
- def play(self, csnote, secs_per_tick, storage=array.array('f', [0]*15)):
+ def play(self, csnote, secs_per_tick, storage=_new_note_array()):
a = self.csnote_to_array(csnote, storage)
a[self.DURATION] = a[self.DURATION] * secs_per_tick
a[self.ATTACK] = max(a[self.ATTACK]*a[self.DURATION], 0.002)
@@ -266,7 +276,6 @@ class _CSoundClientPlugin:
if duration < 0:
duration = -1
else:
-<<<<<<< HEAD:Util/CSoundClient.py
if mode == 'mini':
instrument_id_offset = 0
elif mode == 'edit':
diff --git a/Util/Clooper/aclient.cpp b/Util/Clooper/aclient.cpp
index 1755438..6ba2a72 100644
--- a/Util/Clooper/aclient.cpp
+++ b/Util/Clooper/aclient.cpp
@@ -166,8 +166,8 @@ struct EvLoop
std::multimap<int, ev_t *>::iterator ev_pos;
std::map<int, iter_t> idmap;
CSOUND * csound;
- void * mutex;
- int steps;
+ void * mutex; //this is locked when changing ev
+ int steps; //
TamTamSound * tt;
EvLoop(CSOUND * cs, TamTamSound * tt) : tick_prev(0), tickMax(1), rtick(0.0), ev(), ev_pos(ev.end()), csound(cs), mutex(NULL), steps(0), tt(tt)
@@ -199,7 +199,7 @@ struct EvLoop
}
void deactivateAll()
{
- csoundLockMutex(mutex);
+ csoundLockMutex(mutex); //not really necessary I think
for (iter_t i = ev.begin(); i != ev.end(); ++i)
{
i->second->activate_cmd(0);
@@ -645,88 +645,6 @@ struct TamTamSound
}
}
- void setMasterVolume(MYFLT vol)
- {
- if (!csound) {
- ll->printf(1, "skipping %s, csound==NULL\n", __FUNCTION__);
- return;
- }
- if (!ThreadID)
- {
- if (_debug && (VERBOSE > 1)) fprintf(_debug, "skipping %s, ThreadID==NULL\n", __FUNCTION__);
- return ;
- }
- MYFLT *p;
- if (!(csoundGetChannelPtr(csound, &p, "masterVolume", CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL)))
- *p = (MYFLT) vol;
- else
- {
- if (_debug && (VERBOSE >0)) fprintf(_debug, "ERROR: failed to set master volume\n");
- }
- }
-
- void setTrackVolume(MYFLT vol, int Id)
- {
- if (!csound) {
- ll->printf(1, "skipping %s, csound==NULL\n", __FUNCTION__);
- return;
- }
- if (!ThreadID)
- {
- if (_debug && (VERBOSE > 1)) fprintf(_debug, "skipping %s, ThreadID==NULL\n", __FUNCTION__);
- return ;
- }
- MYFLT *p;
- char buf[128];
- sprintf( buf, "trackVolume%i", Id);
- if (_debug && (VERBOSE > 10)) fprintf(_debug, "DEBUG: setTrackvolume string [%s]\n", buf);
- if (!(csoundGetChannelPtr(csound, &p, buf, CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL)))
- *p = (MYFLT) vol;
- else
- {
- if (_debug) fprintf(_debug, "ERROR: failed to set track volume\n");
- }
- }
-
- void setTrackpadX(MYFLT value)
- {
- if (!csound) {
- ll->printf(1, "skipping %s, csound==NULL\n", __FUNCTION__);
- return;
- }
- if (!ThreadID)
- {
- if (_debug && (VERBOSE > 1)) fprintf(_debug, "skipping %s, ThreadID==NULL\n", __FUNCTION__);
- return ;
- }
- MYFLT *p;
- if (!(csoundGetChannelPtr(csound, &p, "trackpadX", CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL)))
- *p = (MYFLT) value;
- else
- {
- if (_debug && (VERBOSE > 0)) fprintf(_debug, "ERROR: failed to set trackpad X value\n");
- }
- }
-
- void setTrackpadY(MYFLT value)
- {
- if (!csound) {
- ll->printf(1, "skipping %s, csound==NULL\n", __FUNCTION__);
- return;
- }
- if (!ThreadID)
- {
- if (_debug && (VERBOSE > 1)) fprintf(_debug, "skipping %s, ThreadID==NULL\n", __FUNCTION__);
- return ;
- }
- MYFLT *p;
- if (!(csoundGetChannelPtr(csound, &p, "trackpadY", CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL)))
- *p = (MYFLT) value;
- else
- {
- if (_debug && (VERBOSE >0)) fprintf(_debug, "ERROR: failed to set trackpad Y value\n");
- }
- }
void loopPlaying(int tf)
{
thread_playloop= tf;
@@ -868,51 +786,6 @@ DECL(sc_setChannel) //(float v)
Py_INCREF(Py_None);
return Py_None;
}
-DECL(sc_setMasterVolume) //(float v)
-{
- float v;
- if (!PyArg_ParseTuple(args, "f", &v))
- {
- return NULL;
- }
- sc_tt->setMasterVolume(v);
- Py_INCREF(Py_None);
- return Py_None;
-}
-DECL(sc_setTrackVolume) //(float v)
-{
- float v;
- int i;
- if (!PyArg_ParseTuple(args, "fi", &v, &i))
- {
- return NULL;
- }
- sc_tt->setTrackVolume(v,i);
- Py_INCREF(Py_None);
- return Py_None;
-}
-DECL(sc_setTrackpadX) //(float v)
-{
- float v;
- if (!PyArg_ParseTuple(args, "f", &v))
- {
- return NULL;
- }
- sc_tt->setTrackpadX(v);
- Py_INCREF(Py_None);
- return Py_None;
-}
-DECL(sc_setTrackpadY) //(float v)
-{
- float v;
- if (!PyArg_ParseTuple(args, "f", &v))
- {
- return NULL;
- }
- sc_tt->setTrackpadY(v);
- Py_INCREF(Py_None);
- return Py_None;
-}
DECL(sc_loop_getTick) // -> float
{
if (!PyArg_ParseTuple(args, "" ))
@@ -1064,10 +937,6 @@ static PyMethodDef SpamMethods[] = {
MDECL(sc_stop),
MDECL(sc_scoreEvent),
MDECL(sc_setChannel),
- MDECL(sc_setMasterVolume),
- MDECL(sc_setTrackVolume),
- MDECL(sc_setTrackpadX),
- MDECL(sc_setTrackpadY),
MDECL(sc_loop_getTick),
MDECL(sc_loop_setNumTicks),
MDECL(sc_loop_setTick),