Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames <olpc@localhost.localdomain>2007-02-26 07:59:00 (GMT)
committer James <olpc@localhost.localdomain>2007-02-26 07:59:00 (GMT)
commitb91bd03107f5c8fd1eff166e18e888a1c6d3f1a9 (patch)
tree5c81997f09c73519674b25cdc6fd58478c05356b
parent7e9d820bfdcb9cc627efe22a3f984ebaea47cd41 (diff)
m
-rw-r--r--Edit/MainWindow.py11
-rw-r--r--SubActivity.py20
-rw-r--r--SynthLab/SynthLabWindow.py41
-rwxr-xr-xTamTam.py175
-rw-r--r--Util/CSoundClient.py19
-rw-r--r--Util/Clooper/aclient.cpp53
-rwxr-xr-xUtil/Clooper/aclient.sobin233858 -> 233913 bytes
-rw-r--r--Welcome.py58
-rw-r--r--miniTamTam/miniTamTamMain.py24
9 files changed, 252 insertions, 149 deletions
diff --git a/Edit/MainWindow.py b/Edit/MainWindow.py
index cf81ea7..5b961f0 100644
--- a/Edit/MainWindow.py
+++ b/Edit/MainWindow.py
@@ -18,6 +18,7 @@ class CONTEXT:
NOTE = 2
import Config
+from SubActivity import SubActivity
from Edit.MixerWindow import MixerWindow
from Generation.GenerationConstants import GenerationConstants
@@ -30,9 +31,9 @@ from Generation.Generator import generator1, variate
#-----------------------------------
# The main TamTam window
#-----------------------------------
-class MainWindow( gtk.EventBox ):
+class MainWindow( SubActivity ):
- def __init__( self ):
+ def __init__( self, set_mode ):
self.csnd = new_csound_client()
def init_data( ):
@@ -420,7 +421,7 @@ class MainWindow( gtk.EventBox ):
#===================================================
# begin initialization
- gtk.EventBox.__init__( self )
+ SubActivity.__init__( self, set_mode )
# keyboard variables
self.kb_active = False
@@ -1163,13 +1164,11 @@ class MainWindow( gtk.EventBox ):
def delete_event( self, widget, event, data = None ):
return False
- def destroy( self, widget ):
+ def onDestroy( self ):
if Config.DEBUG:
print TP.PrintAll()
- gtk.main_quit()
-
def updateContextNavButtons( self ):
if self.context == CONTEXT.PAGE:
self.GUI["2contextPrevButton"].hide()
diff --git a/SubActivity.py b/SubActivity.py
new file mode 100644
index 0000000..a3b1f7a
--- /dev/null
+++ b/SubActivity.py
@@ -0,0 +1,20 @@
+import pygtk
+pygtk.require( '2.0' )
+import gtk
+
+class SubActivity(gtk.EventBox):
+
+ def __init__(self, set_mode):
+ gtk.EventBox.__init__(self)
+ self.set_mode = set_mode
+
+ def onDestroy(self):
+ pass
+ def onKeyPress(self, widget, data):
+ pass
+ def onKeyRelease(self, widget, data):
+ pass
+ def onActivate(self):
+ pass
+ def onDeactivate(self):
+ pass
diff --git a/SynthLab/SynthLabWindow.py b/SynthLab/SynthLabWindow.py
index 398e135..d53116a 100644
--- a/SynthLab/SynthLabWindow.py
+++ b/SynthLab/SynthLabWindow.py
@@ -17,20 +17,23 @@ from SynthLab.SynthObjectsParameters import SynthObjectsParameters
from SynthLab.SynthLabConstants import SynthLabConstants
from SynthLab.Parameter import Parameter
from Util.Trackpad import Trackpad
+from SubActivity import SubActivity
Tooltips = Config.Tooltips
-class SynthLabWindow( gtk.Window ):
- def __init__( self, table, closeCallback ):
- gtk.Window.__init__( self, gtk.WINDOW_TOPLEVEL )
- color = gtk.gdk.color_parse(Config.PANEL_BCK_COLOR)
- self.modify_bg(gtk.STATE_NORMAL, color)
- self.set_border_width(Config.MAIN_WINDOW_PADDING)
- self.set_keep_above(False)
+as_window = False
+
+class SynthLabWindow(SubActivity):
+ def __init__( self, set_mode, table, dummy_to_change_signature ):
+ SubActivity.__init__(self, set_mode)
+ if as_window:
+ color = gtk.gdk.color_parse(Config.PANEL_BCK_COLOR)
+ self.modify_bg(gtk.STATE_NORMAL, color)
+ self.set_border_width(Config.MAIN_WINDOW_PADDING)
+ self.set_keep_above(False)
+ self.set_decorated(False)
self.csnd = new_csound_client()
self.trackpad = Trackpad( self, self.csnd )
self.table = table
- self.closeCallback = closeCallback
- self.set_decorated(False)
self.synthObjectsParameters = SynthObjectsParameters()
self.resetLocations()
self.objectCount = len(self.locations)
@@ -55,9 +58,8 @@ class SynthLabWindow( gtk.Window ):
self.clockStart = 0
self.sample_names = [name for i in range( len( Config.INSTRUMENTS ) ) for name in Config.INSTRUMENTS.keys() if Config.INSTRUMENTS[ name ].instrumentId == i ]
self.tooltips = gtk.Tooltips()
- self.add_events(gtk.gdk.KEY_PRESS_MASK|gtk.gdk.KEY_RELEASE_MASK)
- self.connect("key-press-event", self.onKeyPress)
- self.connect("key-release-event", self.onKeyRelease)
+ if as_window:
+ self.add_events(gtk.gdk.KEY_PRESS_MASK|gtk.gdk.KEY_RELEASE_MASK)
self.action = None
self.dragObject = None
@@ -79,8 +81,9 @@ class SynthLabWindow( gtk.Window ):
SynthLabConstants.GT_SOUND_OUTPUT ]
# set up window
- self.set_position( gtk.WIN_POS_CENTER_ON_PARENT )
- self.set_title("Synth Lab")
+ if as_window:
+ self.set_position( gtk.WIN_POS_CENTER_ON_PARENT )
+ self.set_title("Synth Lab")
self.mainBox = gtk.VBox()
self.subBox = gtk.HBox()
self.drawingBox = RoundVBox( 10, Config.INST_BCK_COLOR )
@@ -182,6 +185,9 @@ class SynthLabWindow( gtk.Window ):
self.presetCallback(self.presets,0)
self.tooltips.set_tip(self.durationSlider, Tooltips.SOUNDDUR + ': ' + self.durString)
+
+ def onDestroy(self):
+ pass
def onKeyPress(self,widget,event):
key = event.hardware_keycode
@@ -257,9 +263,10 @@ class SynthLabWindow( gtk.Window ):
def handleClose( self, widget, data ):
if self.instanceOpen:
self.synthLabParametersWindow.destroy()
- self.set_keep_above(False)
- self.closeCallback()
- self.hide()
+ self.set_mode('welcome')
+ if as_window:
+ self.set_keep_above(False)
+ self.hide()
def resetLocations( self ):
# deep copy the list
diff --git a/TamTam.py b/TamTam.py
index 3f6ee95..560fdc0 100755
--- a/TamTam.py
+++ b/TamTam.py
@@ -4,16 +4,21 @@ pygtk.require( '2.0' )
import gtk
import Config
-import Util.CSoundClient as CSoundClient
+from Util.CSoundClient import new_csound_client
from Util.Profiler import TP
+
+
from miniTamTam.miniTamTamMain import miniTamTamMain
from Edit.MainWindow import MainWindow
-from Util.Clooper.sclient import *
+from Welcome import Welcome
+from SynthLab.SynthLabWindow import SynthLabWindow
+
try :
from sugar.activity.Activity import Activity
except ImportError:
- print "No Sugar for you"
+ from gtk import Window as Activity
+
if not os.path.isdir(Config.PREF_DIR):
os.mkdir(Config.PREF_DIR)
@@ -22,23 +27,113 @@ if not os.path.isdir(Config.PREF_DIR):
shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.PREF_DIR + '/' + snd)
os.system('chmod 0777 ' + Config.PREF_DIR + '/' + snd + ' &')
+
+class TamTam(Activity):
+ # TamTam is the topmost container in the TamTam application
+ # At all times it has one child, which may be one of
+ # - the welcome screen
+ # - the mini-tamtam
+ # - the synth lab
+ # - edit mode
+
+ def __init__(self, mode='welcome'):
+ Activity.__init__(self)
+
+ color = gtk.gdk.color_parse(Config.PANEL_BCK_COLOR)
+ self.modify_bg(gtk.STATE_NORMAL, color)
+
+ self.set_title('TamTam')
+ self.set_resizable(False)
+
+ self.connect('focus_in_event',self.onFocusIn)
+ self.connect('focus_out_event',self.onFocusOut)
+ self.connect('destroy', self.onDestroy)
+ self.connect( "key-press-event", self.onKeyPress )
+ self.connect( "key-release-event", self.onKeyRelease )
+
+ self.modeList = {
+ 'welcome': Welcome(self.set_mode),
+ 'mini': miniTamTamMain(self.set_mode),
+ 'edit': MainWindow(self.set_mode),
+ 'synth': SynthLabWindow( self.set_mode, 86, None)
+ }
+ self.mode = mode
+
+ self.add(self.modeList[self.mode])
+ self.modeList[ self.mode ].onActivate()
+ self.show_all()
+
+ def doNothing(): #a callback function to appease SynthLab
+ pass
+ def set_mode(self, mode):
+ print 'DEBUG: TamTam::set_mode from', self.mode, 'to', mode
+ if mode in self.modeList:
+ self.remove( self.modeList[ self.mode ] )
+ self.modeList[ self.mode ].onDeactivate()
+ self.mode = mode
+ self.add( self.modeList[ self.mode ] )
+ self.modeList[ self.mode ].onActivate()
+ self.show_all()
+ else:
+ print 'DEBUG: TamTam::set_mode invalid mode:', mode
+
+ def onFocusIn(self, event, data=None):
+ print 'DEBUG: TamTam::onFocusOut in TamTam.py'
+ csnd = new_csound_client()
+ csnd.connect(True)
+ #csnd.load_instruments()
+
+ def onFocusOut(self, event, data=None):
+ print 'DEBUG: TamTam::onFocusOut in TamTam.py'
+ csnd = new_csound_client()
+ csnd.connect(False)
+
+ def onKeyPress(self, widget, event):
+ print 'DEBUG: TamTam::onKeyPress in TamTam.py'
+ if event.state == gtk.gdk.MOD1_MASK:
+ key = event.hardware_keycode
+ if key == 58: #M
+ self.set_mode('mini')
+ return
+ elif key == 39: #S
+ self.set_mode('synth')
+ return
+ elif key == 25: #W
+ self.set_mode('welcome')
+ return
+ self.modeList[ self.mode ].onKeyPress(widget, event)
+
+ def onKeyRelease(self, widget, event):
+ print 'DEBUG: TamTam::onKeyRelease in TamTam.py'
+ self.modeList[ self.mode ].onKeyRelease(widget, event)
+ pass
+
+ def onDestroy(self, arg2):
+ print 'DEBUG: TamTam::onDestroy()'
+ os.system('rm -f ' + Config.PREF_DIR + '/synthTemp*')
+
+ for m in self.modeList:
+ self.modeList[m].onDestroy()
+
+ csnd = new_csound_client()
+ csnd.connect(False)
+ csnd.destroy()
+
+ gtk.main_quit()
+
+
if __name__ == "__main__":
- def run_non_sugar_mode():
- tamtam = miniTamTamMain()
- mainwin = gtk.Window(gtk.WINDOW_TOPLEVEL)
- color = gtk.gdk.color_parse('#FFFFFF')
- mainwin.modify_bg(gtk.STATE_NORMAL, color)
- #mainwin.set_size_request(1200,700)
- mainwin.set_title('miniTamTam')
- mainwin.set_resizable(False)
- mainwin.connect('destroy' , gtk.main_quit )
- mainwin.connect( "key-press-event", tamtam.keyboardStandAlone.onKeyPress )
- mainwin.connect( "key-release-event", tamtam.keyboardStandAlone.onKeyRelease )
- mainwin.add(tamtam)
- tamtam.show()
- mainwin.show()
+ def run_non_sugar_mode(mode):
+ mainwin = TamTam(mode)
gtk.main()
+ if len(sys.argv) > 1 :
+ run_non_sugar_mode(sys.argv[1])
+ else:
+ run_non_sugar_mode('welcome')
+
+ sys.exit(0)
+
def run_edit_mode():
tamtam = MainWindow()
mainwin = gtk.Window(gtk.WINDOW_TOPLEVEL)
@@ -58,49 +153,3 @@ if __name__ == "__main__":
mainwin.show()
gtk.main()
- if len(sys.argv) > 1 and sys.argv[1] == 'edit':
- if False:
- import hotshot
- prof = hotshot.Profile("some_stats")
- prof.runcall(run_edit_mode)
- prof.close()
- else:
- run_edit_mode()
- else:
- run_non_sugar_mode()
-
- sys.exit(0)
-
-class TamTam(Activity):
- def __init__(self):
- Activity.__init__(self)
-
- color = gtk.gdk.color_parse(Config.PANEL_BCK_COLOR)
- self.modify_bg(gtk.STATE_NORMAL, color)
-
- self.tamtam = miniTamTamMain()
- self.connect('focus_in_event',self.handleFocusIn)
- self.connect('focus_out_event',self.handleFocusOut)
- self.connect('destroy', self.do_quit)
- self.add(self.tamtam)
- self.tamtam.show()
- self.set_title('TamTam')
- self.set_resizable(False)
- self.connect( "key-press-event", self.tamtam.keyboardStandAlone.onKeyPress )
- self.connect( "key-release-event", self.tamtam.keyboardStandAlone.onKeyRelease )
-
- def handleFocusIn(self, event, data=None):
- csnd = new_csound_client()
- csnd.connect(True)
- #csnd.load_instruments()
-
- def handleFocusOut(self, event, data=None):
- if self.tamtam.synthLabWindowOpen():
- return
- csnd = new_csound_client()
- csnd.connect(False)
-
- def do_quit(self, arg2):
- os.system('rm ' + Config.PREF_DIR + '/synthTemp*')
- del self.tamtam
-
diff --git a/Util/CSoundClient.py b/Util/CSoundClient.py
index 2543bca..399df60 100644
--- a/Util/CSoundClient.py
+++ b/Util/CSoundClient.py
@@ -18,13 +18,13 @@ class _CSoundClientPlugin:
sc_initialize(orc)
self.on = False
self.masterVolume = 80.0
+ self.periods_per_buffer = 2
def __del__(self):
self.connect(False)
sc_destroy()
-
def setMasterVolume(self, volume):
self.masterVolume = volume
if self.on:
@@ -57,22 +57,10 @@ class _CSoundClientPlugin:
def connect( self, init = True ):
def reconnect():
-# def load_instruments( ):
-# for instrumentSoundFile in Config.INSTRUMENTS.keys():
-# if instrumentSoundFile[0:3] == 'mic' or instrumentSoundFile[0:3] == 'lab':
-# fileName = Config.PREF_DIR + '/' + instrumentSoundFile
-# else:
-# fileName = Config.SOUNDS_DIR + "/" + instrumentSoundFile
-# instrumentId = Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[ instrumentSoundFile ].instrumentId
-# sc_inputMessage( Config.CSOUND_LOAD_INSTRUMENT % (instrumentId, fileName) )
-
- if sc_start() :
+ if sc_start(self.periods_per_buffer) :
print 'ERROR connecting'
else:
self.on = True
- sc_setMasterVolume(self.masterVolume)
- #load_instruments()
- time.sleep(0.2)
def disconnect():
if sc_stop() :
print 'ERROR connecting'
@@ -84,7 +72,7 @@ class _CSoundClientPlugin:
if not init and self.on :
disconnect()
- def destroy( self):
+ def destroy( self ):
self.connect(False)
sc_destroy()
@@ -265,4 +253,5 @@ def new_csound_client():
_Client.connect(True)
_Client.setMasterVolume(100.0)
_Client.load_instruments()
+ time.sleep(0.2)
return _Client
diff --git a/Util/Clooper/aclient.cpp b/Util/Clooper/aclient.cpp
index 10c7f9c..6b830c1 100644
--- a/Util/Clooper/aclient.cpp
+++ b/Util/Clooper/aclient.cpp
@@ -19,14 +19,12 @@
unsigned int SAMPLE_RATE = 16000;
-snd_pcm_uframes_t PERIODS_PER_BUFFER = 2;
-snd_pcm_uframes_t PERIOD_SIZE = (1<<8);
-static int setparams (snd_pcm_t * phandle )
+static int setparams (snd_pcm_t * phandle, int periods_per_buffer, snd_pcm_uframes_t period_size )
{
snd_pcm_hw_params_t *hw;
int srate_dir = 0;
- snd_pcm_uframes_t buffer_size = PERIOD_SIZE * PERIODS_PER_BUFFER, bsize, psize;
+ snd_pcm_uframes_t buffer_size = period_size * periods_per_buffer, bsize, psize;
ACFG(snd_pcm_hw_params_malloc(&hw));
ACFG(snd_pcm_hw_params_any(phandle, hw));
@@ -35,12 +33,12 @@ static int setparams (snd_pcm_t * phandle )
ACFG(snd_pcm_hw_params_set_rate_near(phandle, hw, &SAMPLE_RATE, &srate_dir));
ACFG(snd_pcm_hw_params_set_channels(phandle, hw, 2));
ACFG(snd_pcm_hw_params_set_buffer_size_near(phandle, hw, &buffer_size));
- ACFG(snd_pcm_hw_params_set_period_size_near(phandle, hw, &PERIOD_SIZE, 0));
+ ACFG(snd_pcm_hw_params_set_period_size_near(phandle, hw, &period_size, 0));
ACFG(snd_pcm_hw_params_get_buffer_size(hw, &bsize));
ACFG(snd_pcm_hw_params_get_period_size(hw, &psize, 0));
assert(bsize == buffer_size);
- assert(psize == PERIOD_SIZE);
+ assert(psize == period_size);
ACFG(snd_pcm_hw_params(phandle, hw));
@@ -164,9 +162,9 @@ struct EvLoop
CSOUND * csound;
void * mutex;
- EvLoop(CSOUND * cs) : _debug(NULL), tick_prev(0), tickMax(1), rtick(0.0), ev(), ev_pos(ev.end()), csound(cs), mutex(NULL)
+ EvLoop(CSOUND * cs, snd_pcm_uframes_t period_size) : _debug(NULL), tick_prev(0), tickMax(1), rtick(0.0), ev(), ev_pos(ev.end()), csound(cs), mutex(NULL)
{
- setTickDuration(0.05);
+ setTickDuration(0.05, period_size);
mutex = csoundCreateMutex(0);
}
~EvLoop()
@@ -213,14 +211,14 @@ struct EvLoop
ev_pos = ev.lower_bound( t );
csoundUnlockMutex(mutex);
}
- void setTickDuration(MYFLT d)
+ void setTickDuration(MYFLT d, int period_size)
{
if (!csound) {
fprintf(stderr, "skipping setTickDuration, csound==NULL\n");
return;
}
secs_per_tick = d;
- ticks_per_step = PERIOD_SIZE / ( d * 16000);
+ ticks_per_step = period_size / ( d * 16000);
if (0) fprintf(stderr, "INFO: duration %lf := ticks_per_step %lf\n", d, ticks_per_step);
}
void step(FILE * logf)
@@ -339,15 +337,20 @@ struct TamTamSound
enum {CONTINUE, STOP} PERF_STATUS;
int verbosity;
FILE * _debug;
+ bool _debug_close;
FILE * _light;
int thread_playloop;
int thread_measurelag;
EvLoop * loop;
+ const snd_pcm_uframes_t period_size;
+ int periods_per_buffer;
TamTamSound(char * orc)
- : ThreadID(NULL), csound(NULL), PERF_STATUS(STOP), verbosity(3), _debug(stderr),
+ : ThreadID(NULL), csound(NULL), PERF_STATUS(STOP), verbosity(3),
+ _debug(stderr), _debug_close(false),
_light(fopen("/sys/bus/platform/devices/leds-olpc/leds:olpc:keyboard/brightness", "w")),
- thread_playloop(0), thread_measurelag(0), loop(NULL)
+ thread_playloop(0), thread_measurelag(0), loop(NULL),
+ period_size(1<<8), periods_per_buffer(2)
{
if (1)
{
@@ -361,7 +364,7 @@ struct TamTamSound
//csoundInitialize(&argc, &argv, 0);
csoundPreCompile(csound);
- csoundSetHostImplementedAudioIO(csound, 1, PERIOD_SIZE);
+ csoundSetHostImplementedAudioIO(csound, 1, period_size);
int result = csoundCompile(csound, argc, &(argv[0]));
if (result)
{
@@ -375,7 +378,7 @@ struct TamTamSound
{
csound = NULL;
}
- loop = new EvLoop(csound);
+ loop = new EvLoop(csound, period_size);
}
~TamTamSound()
{
@@ -383,11 +386,15 @@ struct TamTamSound
{
stop();
delete loop;
+ if (_debug) fprintf(_debug, "Going for csoundReset\n");
csoundReset(csound);
+ if (_debug) fprintf(_debug, "Going for csoundDestroy\n");
csoundDestroy(csound);
}
- if (_debug) fclose(_debug);
+ if (_debug && _debug_close ) fclose(_debug);
if (_light) fclose(_light);
+
+ if (_debug) fprintf(_debug, "TamTam aclient destroyed\n");
}
uintptr_t thread_fn()
{
@@ -396,13 +403,13 @@ struct TamTamSound
int nloops = 0;
long int nsamples = csoundGetOutputBufferSize(csound);
long int nframes = nsamples/2; /* nchannels == 2 */ /* nframes per write */
- assert((unsigned)nframes == PERIOD_SIZE);
+ assert((unsigned)nframes == period_size);
float * buf = (float*)malloc(nsamples * sizeof(float));
if (_debug) fprintf(_debug, "INFO: nsamples = %li nframes = %li\n", nsamples, nframes);
snd_pcm_t * phandle;
ACFG(snd_pcm_open(&phandle, "default", SND_PCM_STREAM_PLAYBACK,0));
- if (setparams(phandle))
+ if (setparams(phandle, periods_per_buffer, period_size))
{
goto thread_fn_cleanup;
}
@@ -493,7 +500,7 @@ thread_fn_cleanup:
{
return ((TamTamSound*)clientData)->thread_fn();
}
- int start()
+ int start(int p_per_b)
{
if (!csound) {
fprintf(stderr, "skipping %s, csound==NULL\n", __FUNCTION__);
@@ -502,6 +509,7 @@ thread_fn_cleanup:
if (!ThreadID)
{
PERF_STATUS = CONTINUE;
+ periods_per_buffer = p_per_b;
ThreadID = csoundCreateThread(csThread, (void*)this);
return 0;
}
@@ -516,7 +524,7 @@ thread_fn_cleanup:
if (ThreadID)
{
PERF_STATUS = STOP;
- if (_debug) fprintf(_debug, "INFO: stop()");
+ if (_debug) fprintf(_debug, "INFO: aclient joining performance thread\n");
uintptr_t rval = csoundJoinThread(ThreadID);
if (rval) if (_debug) fprintf(_debug, "WARNING: thread returned %zu\n", rval);
ThreadID = NULL;
@@ -670,11 +678,12 @@ DECL(sc_initialize) //(char * csd)
//compile the score, connect to device, start a sound rendering thread
DECL(sc_start)
{
- if (!PyArg_ParseTuple(args, "" ))
+ int ppb;
+ if (!PyArg_ParseTuple(args, "i", &ppb ))
{
return NULL;
}
- return Py_BuildValue("i", sc_tt->start());
+ return Py_BuildValue("i", sc_tt->start(ppb));
}
//stop csound rendering thread, disconnect from sound device, clear tables.
DECL(sc_stop)
@@ -786,7 +795,7 @@ DECL(sc_loop_setTickDuration) // (MYFLT secs_per_tick)
{
return NULL;
}
- sc_tt->loop->setTickDuration(spt);
+ sc_tt->loop->setTickDuration(spt, sc_tt->period_size);
RetNone;
}
DECL(sc_loop_addScoreEvent) // (int id, int duration_in_ticks, char type, farray param)
diff --git a/Util/Clooper/aclient.so b/Util/Clooper/aclient.so
index c6033b7..17b7cd1 100755
--- a/Util/Clooper/aclient.so
+++ b/Util/Clooper/aclient.so
Binary files differ
diff --git a/Welcome.py b/Welcome.py
index 56910a3..428ab64 100644
--- a/Welcome.py
+++ b/Welcome.py
@@ -5,16 +5,16 @@ import gtk
import Config
from Util.ThemeWidgets import *
+
+from Util.CSoundClient import new_csound_client
+from Util.NoteDB import Note
+from miniTamTam.RythmGenerator import generator
+from SubActivity import SubActivity
-class Welcome(gtk.EventBox):
+class Welcome(SubActivity):
- def __init__(self):
- gtk.EventBox.__init__(self)
-
- self.draw()
- self.show_all()
-
- def draw(self):
+ def __init__(self, set_mode):
+ SubActivity.__init__(self, set_mode)
actVBox = RoundVBox(fillcolor = Config.WS_BCK_COLOR, bordercolor = Config.WS_BCK_COLOR, radius = Config.PANEL_RADIUS)
actHBox = gtk.HBox()
@@ -24,6 +24,7 @@ class Welcome(gtk.EventBox):
actBtnBox.set_size_request(200,200)
actBtnBox.set_border_width(Config.PANEL_SPACING)
actBtn = ImageButton(Config.IMAGE_ROOT + activity +'Tam.png')
+ actBtn.connect('clicked', self.onActivityBtnClicked, activity)
actBtnBox.pack_start(actBtn,True,False,0)
actHBox.pack_start(actBtnBox,True,False,0)
@@ -33,13 +34,36 @@ class Welcome(gtk.EventBox):
actVBox.pack_start(actHBox,False,False, 100)
actVBox.pack_start(title,False,False, 30)
self.add(actVBox)
+ self.show_all()
+ self.activate_count = 0
-if __name__ == "__main__":
- win = gtk.Window()
- wc = Welcome()
- win.add(wc)
- win.show()
- #start the gtk event loop
- gtk.main()
-
- \ No newline at end of file
+ def onActivityBtnClicked(self, widget, data):
+ self.set_mode(data)
+
+ def onActivate(self):
+ def flatten(ll):
+ rval = []
+ for l in ll:
+ rval += l
+ return rval
+ if self.activate_count == 0:
+ i = 0
+ csnd = new_csound_client()
+ csnd.loopClear()
+ beat = 8
+ regularity = 0.77
+ reverb = 0.2
+ for x in flatten( generator('drum3kit', beat, regularity, reverb) ):
+ n = Note(0, x.trackId, i, x)
+ i = i + 1
+ csnd.loopPlay(n)
+ csnd.loopSetNumTicks( beat * Config.TICKS_PER_BEAT)
+ csnd.loopSetTick(0)
+ csnd.loopStart()
+ self.activate_count = self.activate_count + 1
+
+ def onDeactivate(self):
+ if (self.activate_count == 1):
+ csnd = new_csound_client()
+ csnd.loopPause()
+ csnd.loopClear()
diff --git a/miniTamTam/miniTamTamMain.py b/miniTamTam/miniTamTamMain.py
index 0eca4da..dcb6fd1 100644
--- a/miniTamTam/miniTamTamMain.py
+++ b/miniTamTam/miniTamTamMain.py
@@ -23,10 +23,12 @@ from Util.InstrumentPanel import InstrumentPanel
Tooltips = Config.Tooltips
-class miniTamTamMain( gtk.EventBox ):
+from SubActivity import SubActivity
- def __init__(self):
- gtk.EventBox.__init__( self)
+class miniTamTamMain(SubActivity):
+
+ def __init__(self, set_mode):
+ SubActivity.__init__(self, set_mode)
self.set_border_width(Config.MAIN_WINDOW_PADDING)
self.csnd = new_csound_client()
@@ -71,14 +73,14 @@ class miniTamTamMain( gtk.EventBox ):
self.add(self.mainWindowBox)
self.enableKeyboard()
- self.connect('key-press-event',self.handleKeyboard)
self.setInstrument(self.instrument)
self.drawInstrumentButtons()
self.drawSliders()
self.drawGeneration()
self.show_all()
- self.playStartupSound()
+ if 'a good idea' == True:
+ self.playStartupSound()
self.synthLabWindow = None
@@ -360,12 +362,15 @@ class miniTamTamMain( gtk.EventBox ):
reverbSend = 0),
secs_per_tick)
- def handleKeyboard(self, widget, event):
- if event.hardware_keycode == 65:
+ def onKeyPress(self, widget, event):
+ if event.hardware_keycode == 65: #what key is this? what feature is this?
if self.playStopButton.get_active():
self.playStopButton.set_active(False)
else:
self.playStopButton.set_active(True)
+ self.keyboardStandAlone.onKeyPress(widget, event)
+ def onKeyRelease(self, widget, event):
+ self.keyboardStandAlone.onKeyRelease(widget, event)
def playStartupSound(self):
r = str(random.randrange(1,11))
@@ -376,8 +381,9 @@ class miniTamTamMain( gtk.EventBox ):
cleanInstrumentList.sort(lambda g,l: cmp(Config.INSTRUMENTS[g].category, Config.INSTRUMENTS[l].category) )
return cleanInstrumentList + ['drum1kit', 'drum2kit', 'drum3kit']
- def destroy( self, widget ):
- gtk.main_quit()
+ def onDestroy( self):
+ #this gets called when the whole app is being destroyed
+ pass
def scale(self, input,input_min,input_max,output_min,output_max):
range_input = input_max - input_min