1. #creativePact 2011 Day 4

    This is now in Stereo but the Delay is half as loud as the original sound. Maybe tomorrow I’ll look at having multiple repeats or something - I would have done it today but was Dancing with Gerry til 5am :/


    ~gate = Bus.audio(s, 2);

    ~delay = Bus.audio(s, 2);

    {Out.ar([0, 1], DelayN.ar(In.ar(~delay, 2), 5, 2, 0.5))}.play

    {Out.ar([0, 1, ~delay], In.ar(~gate, 2))}.play;

    {Out.ar(~gate, SoundIn.ar)}.play;

  2. #creativePact 2011

    This now has a Delay effect added, providing a two second delay coming out of the Right Hand channel. Lovely.


    ~gate = Bus.audio(s, 2);

    ~delay = Bus.audio(s, 2);

    {Out.ar(1, DelayN.ar(In.ar(~delay, 2), 5, 2))}.play

    {Out.ar([0, ~delay], In.ar(~gate, 2))}.play;

    {Out.ar(~gate, SoundIn.ar)}.play;

  3. #creativePact 2011 - An Expensive Patchcord.

    Here is my first bit of code, you’ll need headphones if you want to avoid feedback. It just takes the first input from your Soundcard (in this case I’m just using the Internal Microphone) and plays it out of the headphones. I’m sending it through a Bus called gate~ which will let me later add more effects and control the wet/dry mix. 

    Run each line of code separately or SuperCollider will cry, which will make you cry.

    ~gate = Bus.audio(s, 2);

    {Out.ar(0, In.ar(~gate, 2))}.play;

    {Out.ar(~gate, SoundIn.ar)}.play;

  4. #creativePact 2011 - what am I doing?

    Last year I tinkered with SuperCollider and Processing, somewhat aimlessly before completely tailing off and failing to reach the end of September.

    This year, I’ve decided to create a live audio FX processor in SuperCollider. I figure if I have some sort of goal I might be tempted to stick with it for longer (this might not work out though, as I intend to be drunk for most of September… oh well!)

    The idea is partly inspired by a MaxMSP project I did in 2nd year which was broadly the same thing…but in Max…

  5. #creativePact Day ?? - an improvement!

    Here ya go!

    void setup(){

      size(360, 360);

    stroke(255);

    strokeWeight(5);

    smooth();

    noFill();

    }

    void draw(){

      background(0);

      int sides = mouseY/20;

       float x = 0, y = 0;

    float angle = mouseX;

      beginShape();

    for (int i=0; i<sides; i++){

      x = width/2+cos(radians(angle))*width/2.5;

      y = height/2+sin(radians(angle))*width/2.5;

      vertex(x, y);

      angle+=360/sides;

    }

    endShape(CLOSE);

    }

  6. #creativePact Day ??

    #creativePact - so I’ve made it back to Processing, here’s some code, fire it up and click in the window - the number of sides to the shape increases! (thanks to Ira Greenberg’s Processing book for getting me started on this one):

    void setup() {

      size (400, 400);

      background(0);

      smooth();

      noFill();

    }

    int points;

    void draw() {

      background(0);

      makePoly(width/2, height/2, points, 150, 255, 8, MITER);

    if(points> 18) {

          points = 3;}

    }

    void mouseClicked() {

      points = points+1;

    }

    void makePoly(int x, int y, int points, float radius, int strokeCol, float strokeWt, int strokeJn){

      float px=0, py=0;

      float angle = 0;

      stroke(strokeCol);

      strokeJoin(strokeJn);

      strokeWeight(strokeWt);

      beginShape();

      for (int i=0; i<points; i++){

        px = x+cos(radians(angle))*radius;

        py = y+sin(radians(angle))*radius;

        vertex(px, py);

        angle+=360/points;

      }

      endShape(CLOSE);

    }

    Lovely!

  7. #creativePact Day 24

    #creativePact, I’ve just been having a play with Dashcode which is part of the Xcode Developer package from Apple, with simple templates, it’s pretty easy to get something working without lots of hassle. I’ve initially tried using it with Twitter, but I won’t post anything until tomorrow (or Sunday, for tomorrow is the day of beer).

  8. #creativePact Day 21

    #creativePact Here is yesterday’s code but now the second analog stick is also in use. I’d like to change this to make the swarm attracted to whichever analog stick position is nearest. Maybe tomorrow.

    import procontroll.*;

    import net.java.games.input.*;

    Mover[] mover = new Mover[400];

    ControllIO controllIO;

    ControllDevice joypad;

    ControllStick stick1;

    ControllStick stick2;

    ControllButton buttonX;

    ControllButton buttonC;

    ControllButton buttonT; 

    ControllButton buttonS;

    ControllButton buttonL1;

    ControllButton buttonL2;

    ControllButton buttonL3;

    ControllButton buttonR1;

    ControllButton buttonR2;

    ControllButton buttonR3;

    ControllButton buttonSelect;

    ControllButton buttonStart;

    ControllButton buttonUp;

    ControllButton buttonDown;

    ControllButton buttonLeft;

    ControllButton buttonRight;

    void setup() {

      size(640, 480);

      smooth();

      background(0);

      controllIO = ControllIO.getInstance(this);

      joypad = controllIO.getDevice("Twin USB Joystick");

      stick1 = joypad.getStick(0);

      stick2 = joypad.getStick(1);

      buttonT = joypad.getButton(0);

      buttonC = joypad.getButton(1);

      buttonX = joypad.getButton(2);

      buttonS = joypad.getButton(3);

      for (int i = 0; i < mover.length; i++) {

        mover[i] = new Mover();

      }

    }

    void draw() {

      background(180, 100, 180);

      for (int i = 0; i < mover.length; i++) {

        mover[i].update();

        mover[i].display();

        mover[i].checkEdges();

      }

    }

    class Mover {

      PVector location;

      PVector velocity;

      PVector acceleration;

      float topspeed;

      PVector location1;

      PVector velocity1;

      PVector acceleration1;

      float topspeed1;

      float xsticka1;

      float ysticka1;

      float xsitcka2;

      float ysticka2;

      float xstickb1;

      float ystickb1;

      float xsitckb2;

      float ystickb2;

      Mover() {

        location = new PVector(random(width), random(height));

        velocity = new PVector(0, 0);

        topspeed = 5;

        location1 = new PVector(random(width), random(height));

        velocity1 = new PVector(0, 0);

        topspeed1 = 5;

      }

      void update() {

        float xsticka1 = stick2.getTotalY() + height/2;

        float ysticka1 = stick2.getTotalX() + width/2;

        float xsticka2 = constrain(xsticka1, 0, width);

        float ysticka2 = constrain(ysticka1, 0, height);

        float xstickb1 = stick1.getTotalX() + height/2;

        float ystickb1 = stick1.getTotalY() + width/2;

        float xstickb2 = constrain(xstickb1, 0, width);

        float ystickb2 = constrain(ystickb1, 0, height);

        PVector mouse = new PVector(xsticka2, ysticka2);

        PVector mouse1 = new PVector(xstickb2, ystickb2);

        PVector dir = PVector.sub(mouse, location);

        PVector dir1 = PVector.sub(mouse1, location1);

        dir.normalize();

        dir1.normalize();

        if (buttonT.pressed() == true) {

          dir.mult(0.000001);

        } 

        else if (buttonC.pressed() == true) {

          dir.mult(1);

        } 

        else if (buttonX.pressed() == true) {

          dir.mult(5);

        } 

        else if (buttonS.pressed() == true) {

          dir.mult(0.8);

        } 

        else {

          dir.mult(0.2);

        };

        if (buttonT.pressed() == true) {

          dir1.mult(0.000001);

        } 

        else if (buttonC.pressed() == true) {

          dir1.mult(1);

        } 

        else if (buttonX.pressed() == true) {

          dir1.mult(5);

        } 

        else if (buttonS.pressed() == true) {

          dir1.mult(0.8);

        } 

        else {

          dir1.mult(0.2);

        }

        acceleration = dir;

        acceleration1 = dir1;

        velocity.add(acceleration);

        velocity.limit(topspeed);

        location.add(velocity);

        velocity1.add(acceleration1);

        velocity1.limit(topspeed1);

        location1.add(velocity1);

      }

      void display() {

        stroke(location.x, location.y, location.y);

        fill(location.x, location.y, location.y);

        ellipse(location.x, location.y, 2, 2);

        stroke(location1.x, location1.y, location1.y);

        fill(location1.x, location1.y, location1.y);

        ellipse(location1.x, location1.y, 2, 2);

      }

      void checkEdges() {

        if ((location.x > width) || (location.x < 0)) {

          velocity.x = velocity.x * -1;

        } 

        if ((location.y > height) || (location.y < 0)) {

          velocity.y = velocity.y * -1;

        }

        if ((location1.x > width) || (location1.x < 0)) {

          velocity1.x = velocity1.x * -1;

        } 

        if ((location1.y > height) || (location1.y < 0)) {

          velocity1.y = velocity1.y * -1;

        }

      }

    }

  9. #creativePact Days 18-20

    #creativePact haven’t updated for a few days, but i did spend ages working on this on Saturday but only got it working today. It’s now controllable with a PS2 controller (I got a PS2 controller to USB cable off Amazon for it). The Left Analog stick replaces the functionality of the mouse position. The Triangle, Circle etc. replace the Button presses. I’ll add some more functionality soon.

    I sort of solved a problem with Scott McLaughlin’s worms http://creativepact-2010-scottmclaughlin.blogspot.com/ leaving the screen, by using the constrain() function to stop the swarms being able to leave the screen. Haven’t quite figured how to stop the PS2 controls position leaving the screen yet though…I’ll have a think.

    import procontroll.*;

    import net.java.games.input.*;

    Mover[] mover = new Mover[400];

    ControllIO controllIO;

    ControllDevice joypad;

    ControllStick stick1;

    ControllStick stick2;

    ControllButton buttonX;

    ControllButton buttonC;

    ControllButton buttonT; 

    ControllButton buttonS;

    ControllButton buttonL1;

    ControllButton buttonL2;

    ControllButton buttonL3;

    ControllButton buttonR1;

    ControllButton buttonR2;

    ControllButton buttonR3;

    ControllButton buttonSelect;

    ControllButton buttonStart;

    ControllButton buttonUp;

    ControllButton buttonDown;

    ControllButton buttonLeft;

    ControllButton buttonRight;

    void setup() {

      size(640, 480);

      smooth();

      background(0);

      controllIO = ControllIO.getInstance(this);

      joypad = controllIO.getDevice("Twin USB Joystick");

      stick1 = joypad.getStick(0);

      stick2 = joypad.getStick(1);

      buttonT = joypad.getButton(0);

      buttonC = joypad.getButton(1);

      buttonX = joypad.getButton(2);

      buttonS = joypad.getButton(3);

      for (int i = 0; i < mover.length; i++) {

        mover[i] = new Mover();

      }

    }

    void draw() {

      background(180, 100, 180);

      for (int i = 0; i < mover.length; i++) {

        mover[i].update();

        mover[i].display();

        mover[i].checkEdges();

      }

    }

    class Mover {

      PVector location;

      PVector velocity;

      PVector acceleration;

      float topspeed;

      float xstick2;

      float ystick2;

      float xsitck3;

      float ystick3;

      Mover() {

        location = new PVector(random(width), random(height));

        velocity = new PVector(0, 0);

        topspeed = 5;

      }

      void update() {

        float xstick2 = stick2.getTotalY() + height/2;

        float ystick2 = stick2.getTotalX() + width/2;

        float xstick3 = constrain(xstick2, 0, width);

        float ystick3 = constrain(ystick2, 0, height);

        PVector mouse = new PVector(xstick3, ystick3);

        PVector dir = PVector.sub(mouse, location);

        dir.normalize();

        if (buttonT.pressed() == true) {

          dir.mult(0.000001);

        } 

        else if (buttonC.pressed() == true) {

          dir.mult(1);

        } 

        else if (buttonX.pressed() == true) {

          dir.mult(5);

        } 

        else if (buttonS.pressed() == true) {

          dir.mult(0.8);

        } 

        else {

          dir.mult(0.2);

        }

        acceleration = dir;

        velocity.add(acceleration);

        velocity.limit(topspeed);

        location.add(velocity);

      }

      void display() {

        stroke(location.x, location.y, location.y);

        fill(location.x, location.y, location.y);

        ellipse(location.x, location.y, 2, 2);

      }

      void checkEdges() {

        if ((location.x > width) || (location.x < 0)) {

          velocity.x = velocity.x * -1;

        } 

        if ((location.y > height) || (location.y < 0)) {

          velocity.y = velocity.y * -1;

        }

      }

    }

  10. #creativePact Day 17

    #creativePact, no code today, should get the chance to play with a ps2 controller this weekend. Check.