SuperCollider example

Welcome Forums Example output programs SuperCollider example

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Sam 1 year, 10 months ago.

  • Author
    Posts
  • #296

    gilFuser
    Participant

    Here it goes some examples of getting OSC messages from Wekinator in SuperCollider.

    But first I should mention that it really worth taking a look at the “OSC Communication” Guide in the Help System in SuperCollider.

    In Wekinator choose as Outputs Port the number 57120. Is the default port from which SC listens to OSC. Eventually this can change (e.g. if the communication is terminated abruptly). One can check it evaluating:

    NetAddr.langPort;

    // —- The simpler example possible: —- //

    OSCFunc({|msg, time, addr, recvPort|
    [msg, time, addr, recvPort].postln; // to check the values
    }, ‘/wek/outputs’);

    // —- Now a flexible example with a sound process: —- //

    /*
    Quarks.fetchDirectory;
    // wait a little, then:
    Quarks.install(“Modality-toolkit”);
    Quarks.install(“adclib”);
    // then Recompile Class Lybrary…
    */

    // make a named MFunc for all the things to do
    // when a value comes from ‘/wek/outputs’
    // and an OSCdef to listen for ‘/wek/outputs’ messages
    OSCdef(\fromWek, { |msg|
    MFdef(\wekOuts).value(msg)
    }, ‘/wek/outputs’).permanent_(true);

    // MFdefs are good to add functions under keys in it:
    MFdef(\wekOuts).add(\post, { |msg| msg.postln });
    MFdef(\wekOuts).remove(\post);

    //////////////// The Sound ///////////////////

    s.boot;

    Ndef(\friqMod).addSpec(\carrier, [22, 2222, \exp]);
    Ndef(\friqMod).addSpec(\modFreq, [0.04, 111, \exp]);
    Ndef(\friqMod).addSpec(\indexMulti, [0.008, 8, \exp]);

    (
    Ndef(\friqMod, {
    var carrier = \carrier.kr(440, 0.3);
    var modFreq = \modFreq.kr(1, 0.2);
    var index = \indexMulti.ar(0.01, 0.2); // this is not an ordinary index parameter

    var indexProp = (carrier * (index/modFreq));
    var freq = (carrier.lag(0.2) + index + (indexProp * modFreq * SinOsc.ar(modFreq))).clip(20, 20000);
    var synth = SinOsc.ar(([freq, freq*0.05+freq]).fold(44, 22000), 0, carrier.reciprocal);
    var comp = CompanderD.ar(synth, 0.04, 0.4, 0.75, 0.001, 0.002, mul:3);
    var leak = LeakDC.ar(comp, mul: \amp.kr(0.01, 0.1));
    leak
    }
    ).play;
    )

    Ndef(\friqMod).gui;

    /////////////////////////////////////////////

    (
    MFdef(\wekOuts).add(\snd, { |msg|
    Ndef(\friqMod).set(\carrier,
    msg[1].linexp(0, 1, 22, 2222)
    );
    Ndef(\friqMod).set(\modFreq,
    msg[2].linexp(0, 1, 0.04, 111)
    );
    Ndef(\friqMod).set(\indexMulti,
    msg[3].linexp(0, 1, 0.008, 8)
    );
    });
    )

    // turn listening on/off
    OSCdef(\fromWeki).enable;
    OSCdef(\fromWeki).disable;
    MFdef(\wekOuts).enable
    MFdef(\wekOuts).disable;

    /////////////////////////// that’s it ////////////////////////

    Some ideas and pieces of code from Alberto De Campo and Hannes Hoelzl here.

    I hope this can be useful.

    Rebecca, feel free to share

    bests,
    Gil

  • #408

    Sam
    Participant

    Yes its useful @gilfuser.

You must be logged in to reply to this topic.

  •  
  •  
  •  
  •  
  •