SuperCollider example

Welcome Forums Example inputs / feature extractors SuperCollider example

Tagged: 

This topic contains 5 replies, has 4 voices, and was last updated by  Scott 2 years, 9 months ago.

  • Author
    Posts
  • #276

    gilFuser
    Participant

    Hi there,
    I missed examples written in SuperCollider.
    So I just did one, based in the pD example because I thought it would be interesting to compare both.
    There is more to come.

    There it is (heavily commented to be also the “read-me”):

    // create a network address and assign it to a global variable
    ~toWekinator = NetAddr(“localhost”, 6448);

    // test sending a message
    ~toWekinator.sendMsg(‘/wek/inputs’, 0.0, 0.4, 0.8);

    //boot the server. It is needed for inner OSC msgs flow
    s.boot;

    // the arguments to be used in the Ndef GUI
    Spec.add(\val1, [0, 1, \lin]);
    Spec.add(\val2, [0, 1, \lin]);
    Spec.add(\val3, [0, 1, \lin]);

    // the SendReply inside the Ndef uses the arguments as values and send them (still inside SuperCollider) together as an array
    (
    Ndef(\oscValues, {|val1 = 0, val2 = 0, val3 = 0|
    SendReply.kr(Impulse.kr(60), ‘/innerOscFlow’, [val1,val2,val3]);
    });
    );

    // GUI for everybody!
    Ndef(\oscValues).gui;

    // get the array of values from SendReply, explode them as individual floats and send them trough the network address
    (
    OSCFunc({|msg|
    msg[3..].postln; //debug
    ~toWekinator.sendMsg(‘/wek/inputs’, *msg[3..]);
    }, ‘/innerOscFlow’);
    );

  • #277

    gilFuser
    Participant

    Replying to myself

    I got some really valuable advise from a SuperCollider Meister!
    He said “if your receiver program chokes on too much data or you just want to refine your code a bit, here are some techniques for limiting your network throughput…”

    So here it goes the improved version:

    // create a network address and assign it to a global variable
    ~toWekinator = NetAddr(“localhost”, 6448);

    // test sending a message
    ~toWekinator.sendMsg(‘/wek/inputs’, 0.0, 0.4, 0.8);

    //boot the server. It is needed for inner OSC msgs flow
    s.boot;

    // the arguments to be used in the Ndef GUI
    Spec.add(\val1, [0, 1, \lin]);
    Spec.add(\val2, [0, 1, \lin]);
    Spec.add(\val3, [0, 1, \lin]);

    // the SendReply inside the Ndef uses the arguments as values and send them (still inside SuperCollider) together as an array
    Ndef(\oscValues, {|val1 = 0, val2 = 0, val3 = 0|
    var data= [val1,val2,val3];
    var trig= Changed.kr(data).sum + Impulse.kr(1); // trigger when some value changed + “updater” at 1/second
    SendReply.kr(trig, ‘/innerOscFlow’, data);
    });

    OSCdef(\myRouter, {|msg| msg.postln}, ‘/innerOscFlow’); //just post for debugging

    // GUI for everybody!
    Ndef(\oscValues).gui;

    // get the array of values from SendReply, explode them as individual floats and send them trough the network address
    (
    OSCFunc({|msg|
    msg[3..].postln; //debug
    ~toWekinator.sendMsg(‘/wek/inputs’, *msg[3..]);
    }, ‘/innerOscFlow’);
    );

  • #278

    Rebecca
    Keymaster

    That’s fantastic! Thanks for sharing. Are you OK with me adding this to the github repository at github.com/fiebrink1/wekinator_examples and/or to the Examples page (with credit to you) ?

    • This reply was modified 3 years, 3 months ago by  Rebecca.
  • #293

    Tate
    Participant

    It looks like I’m sending fine to wekinator but how do I receive trained data back from wekinator?

    Also, for me to get it to work at all each ” had to be converted to a “”, think this might be a version thing not sure. The example files use “” though.

  • #295

    gilFuser
    Participant

    Hi Rebecca, hi Tate.

    Rebecca, sorry about the late reply. Feel free to share the code I did or any that I may make. I’m on the side of those who believe that sharing knowledge is important and necessary. Just like you, as I can notice.

    Tate, you will find the answer to your question in the section “Example output programs”. It makes more sense to post it there.

    Best regards,
    Gil

  • #360

    Scott
    Participant

    Hi Gil, this is great. I also made a SuperCollider feature extractor while taking Rebecca’s Machine Learning class on Kadenze. I took a slightly different approach and used a Routine to schedule the transmission of OSC messages. Also created some feature extractor SynthDefs using SC’s great audio analysis UGens:
    https://github.com/stooby/SCML

    Good to see other SC users working with Wekinator!

You must be logged in to reply to this topic.

  •  
  •  
  •  
  •  
  •