Example #1
0
    def __init__(self, handle):
        # !!!!!! initialize threading in gtk !!!!!
        # ! this is important for the networking !
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        gtk.gdk.threads_init()

        activity.Activity.__init__(self, handle)

        for snd in ['mic1', 'mic2', 'mic3', 'mic4']:
            if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)):
                shutil.copyfile(Config.SOUNDS_DIR + '/' + snd,
                                Config.DATA_DIR + '/' + snd)
                os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &')

        color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
        self.modify_bg(gtk.STATE_NORMAL, color)

        self.set_title('TamTam Jam')
        self.set_resizable(False)

        self.trackpad = Trackpad(self)

        self.preloadTimeout = None

        self.connect('notify::active', self.onActive)
        self.connect('destroy', self.onDestroy)

        #load the sugar toolbar
        if Config.HAVE_TOOLBOX:
            self.toolbox = ToolbarBox()
            self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self),
                                        -1)
            self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1)
        else:
            self.toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(self.toolbox)

        self.toolbox.show()

        self.trackpad.setContext('jam')
        self.jam = JamMain(self)
        self.connect('key-press-event', self.jam.onKeyPress)
        self.connect('key-release-event', self.jam.onKeyRelease)
        #self.modeList[mode].regenerate()

        self.set_canvas(self.jam)

        self.jam.onActivate(arg=None)

        if Config.HAVE_TOOLBOX:
            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            self.toolbox.toolbar.insert(separator, -1)
            self.toolbox.toolbar.insert(widgets.StopButton(self), -1)
            self.toolbox.toolbar.show_all()

        self.show()
Example #2
0
    def __init__(self, handle):
        # !!!!!! initialize threading in gtk !!!!!
        # ! this is important for the networking !
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        Gdk.threads_init()

        activity.Activity.__init__(self, handle)

        for snd in ["mic1", "mic2", "mic3", "mic4"]:
            if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)):
                shutil.copyfile(Config.SOUNDS_DIR + "/" + snd, Config.DATA_DIR + "/" + snd)
                os.system("chmod 0777 " + Config.DATA_DIR + "/" + snd + " &")

        color = Gdk.color_parse(Config.WS_BCK_COLOR)
        self.modify_bg(Gtk.StateType.NORMAL, color)

        self.set_title("TamTam Jam")
        self.set_resizable(False)

        self.trackpad = Trackpad(self)

        self.preloadTimeout = None

        self.connect("notify::active", self.onActive)
        self.connect("destroy", self.onDestroy)

        toolbox = ToolbarBox()
        toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), -1)
        toolbox.toolbar.insert(Gtk.SeparatorToolItem(), -1)

        self.trackpad.setContext("jam")

        self.set_toolbar_box(toolbox)

        self.jam = JamMain(self)
        self.connect("key-press-event", self.jam.onKeyPress)
        self.connect("key-release-event", self.jam.onKeyRelease)
        # self.modeList[mode].regenerate()
        self.jam.onActivate(arg=None)

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbox.toolbar.insert(separator, -1)
        toolbox.toolbar.insert(widgets.StopButton(self), -1)

        toolbox.toolbar.show_all()
        self.set_canvas(self.jam)

        self.show_all()
Example #3
0
class TamTamJam(activity.Activity):
    def __init__(self, handle):
        # !!!!!! initialize threading in gtk !!!!!
        # ! this is important for the networking !
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        gtk.gdk.threads_init()

        activity.Activity.__init__(self, handle)

        for snd in ['mic1', 'mic2', 'mic3', 'mic4']:
            if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)):
                shutil.copyfile(Config.SOUNDS_DIR + '/' + snd,
                                Config.DATA_DIR + '/' + snd)
                os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &')

        color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
        self.modify_bg(gtk.STATE_NORMAL, color)

        self.set_title('TamTam Jam')
        self.set_resizable(False)

        self.trackpad = Trackpad(self)

        self.preloadTimeout = None

        self.connect('notify::active', self.onActive)
        self.connect('destroy', self.onDestroy)

        #load the sugar toolbar
        if Config.HAVE_TOOLBOX:
            self.toolbox = ToolbarBox()
            self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self),
                                        -1)
            self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1)
        else:
            self.toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(self.toolbox)

        self.toolbox.show()

        self.trackpad.setContext('jam')
        self.jam = JamMain(self)
        self.connect('key-press-event', self.jam.onKeyPress)
        self.connect('key-release-event', self.jam.onKeyRelease)
        #self.modeList[mode].regenerate()

        self.set_canvas(self.jam)

        self.jam.onActivate(arg=None)

        if Config.HAVE_TOOLBOX:
            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            self.toolbox.toolbar.insert(separator, -1)
            self.toolbox.toolbar.insert(widgets.StopButton(self), -1)
            self.toolbox.toolbar.show_all()

        self.show()

    def onPreloadTimeout(self):
        if Config.DEBUG > 4:
            print "TamTam::onPreloadTimeout", self.preloadList

        t = time.time()
        if self.preloadList[0].load(t +
                                    0.100):  # finished preloading this object
            self.preloadList.pop(0)
            if not len(self.preloadList):
                if Config.DEBUG > 1:
                    print "TamTam::finished preloading", time.time() - t
                self.preloadTimeout = False
                return False  # finished preloading everything

        if Config.DEBUG > 4:
            print "TamTam::preload returned after", time.time() - t

        return True

    def onActive(self, widget=None, event=None):
        if widget.props.active == False:
            logging.debug('Jam.onActivate disconnecting csound')
            csnd = new_csound_client()
            csnd.connect(False)
        else:
            logging.debug('Jam.onActivate connecting csound')
            csnd = new_csound_client()
            csnd.connect(True)

    def onKeyPress(self, widget, event):
        pass

    def onKeyRelease(self, widget, event):
        pass

    def onDestroy(self, arg2):
        if Config.DEBUG:
            print 'DEBUG: TamTam::onDestroy()'

        self.jam.onDestroy()

        csnd = new_csound_client()
        csnd.connect(False)
        csnd.destroy()

        gtk.main_quit()

    def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):
Example #4
0
class TamTamJam(activity.Activity):
    def __init__(self, handle):
        # !!!!!! initialize threading in gtk !!!!!
        # ! this is important for the networking !
        # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        Gdk.threads_init()

        activity.Activity.__init__(self, handle)

        for snd in ["mic1", "mic2", "mic3", "mic4"]:
            if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)):
                shutil.copyfile(Config.SOUNDS_DIR + "/" + snd, Config.DATA_DIR + "/" + snd)
                os.system("chmod 0777 " + Config.DATA_DIR + "/" + snd + " &")

        color = Gdk.color_parse(Config.WS_BCK_COLOR)
        self.modify_bg(Gtk.StateType.NORMAL, color)

        self.set_title("TamTam Jam")
        self.set_resizable(False)

        self.trackpad = Trackpad(self)

        self.preloadTimeout = None

        self.connect("notify::active", self.onActive)
        self.connect("destroy", self.onDestroy)

        toolbox = ToolbarBox()
        toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), -1)
        toolbox.toolbar.insert(Gtk.SeparatorToolItem(), -1)

        self.trackpad.setContext("jam")

        self.set_toolbar_box(toolbox)

        self.jam = JamMain(self)
        self.connect("key-press-event", self.jam.onKeyPress)
        self.connect("key-release-event", self.jam.onKeyRelease)
        # self.modeList[mode].regenerate()
        self.jam.onActivate(arg=None)

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbox.toolbar.insert(separator, -1)
        toolbox.toolbar.insert(widgets.StopButton(self), -1)

        toolbox.toolbar.show_all()
        self.set_canvas(self.jam)

        self.show_all()

    def onPreloadTimeout(self):
        if Config.DEBUG > 4:
            print "TamTam::onPreloadTimeout", self.preloadList

        t = time.time()
        if self.preloadList[0].load(t + 0.100):  # finished preloading this object
            self.preloadList.pop(0)
            if not len(self.preloadList):
                if Config.DEBUG > 1:
                    print "TamTam::finished preloading", time.time() - t
                self.preloadTimeout = False
                return False  # finished preloading everything

        if Config.DEBUG > 4:
            print "TamTam::preload returned after", time.time() - t

        return True

    def onActive(self, widget=None, event=None):
        if widget.props.active == False:
            logging.debug("Jam.onActivate disconnecting csound")
            csnd = new_csound_client()
            csnd.connect(False)
        else:
            logging.debug("Jam.onActivate connecting csound")
            csnd = new_csound_client()
            csnd.connect(True)

    def onKeyPress(self, widget, event):
        pass

    def onKeyRelease(self, widget, event):
        pass

    def onDestroy(self, arg2):
        if Config.DEBUG:
            print "DEBUG: TamTam::onDestroy()"

        self.jam.onDestroy()

        csnd = new_csound_client()
        csnd.connect(False)
        csnd.destroy()

        Gtk.main_quit()

    def ensure_dir(self, dir, perms=0777, rw=os.R_OK | os.W_OK):