[Csnd] Flexx Csound interface

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Csnd] Flexx Csound interface


Last time I mentioned Flexx, a pure Python solution to create GUI's in the browser.
It took me some time to get used to the event system used by Flexx, but it is very powerful..

Here is a complete example with 4 sliders controlling ADSR of a csd.

Flexx Csound interface
    zappfinger, 23SEP2018

import sys
sys.path.insert(0, '/Users/richard/py35env/lib/python3.5/site-packages')
from csoundSession import CsoundSession
from flexx import flx, ui, event

class ThemedForm(flx.Widget):   # lives in JS

    def init(self):
        self.slider1 = flx.Slider(min=0.01, max=2, value=.5, flex=0)
        self.slider2 = flx.Slider(min=0, max=6, value=0, flex=0)
        self.slider3 = flx.Slider(min=1, max=10, value=5, flex=0)
        self.slider4 = flx.Slider(min=0, max=6, value=0, flex=1)

    def _update(self, *events):
        att, dec, sus, rel = self.slider1.value, self.slider2.value, self.slider3.value, self.slider4.value
        self.root.cses.update(att, dec, sus, rel)

class CsSession(flx.PyComponent):  # Lives in Python
    cs = CsoundSession("/Users/richard/PycharmProjects/OSCall/csds/Mono_Synth.csd")

    def update(self, *events):
        self.cs.setControlChannel('att', events[0])
        self.cs.setControlChannel('dec', events[1])
        self.cs.setControlChannel('sus', events[2])
        self.cs.setControlChannel('rel', events[3])
        self.cs.setControlChannel('pitchglide', 1.5)

class MyApp(flx.PyComponent):
    cses = flx.ComponentProp()

    def init(self):
        self.ui = ThemedForm()

if __name__ == '__main__':
    app = flx.App(MyApp)
    #m = flx.launch(MyApp, 'chrome-app')
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here