« 21 / 30 »

redUniverse: L-System and Turtle

2009-05-11 13:22 supercollider

Now added RedLSystem and RedLTurtle to my redUniverse quark. RedLSystem is a fairly standard string rewrite class. One special feature is that it saves the structure/tree/recursion depth of the rewrite process. RedLTurtle either plot L-systems or standard strings. It comes with a set of default drawing functions, but you can easily add your own commands.

l= RedLSystem("F", ($F: "F[+F--F]+F"));
RedLTurtle(l, 40, 10, 0.9, 0.1).makeWindow;
l= RedLSystem("F", ($F: "|[-FFF--F]+F"));
RedLTurtle(l, 20, 20, 0.95, 0.2).makeWindow;
l= RedLSystem("F", ($F: "|[--F][+F]-F"));
RedLTurtle(l, 400, 20, 0.65, 0.1).makeWindow(initTranslate: Point(0.5, 0));
l= RedLSystem("F-F-F-F", ($F: "F[F]-F+F[--F]+F-F"));
RedLTurtle(l, 6, 90, 0.9).makeWindow(initTranslate: Point(1, 0));


2009-04-06 15:48 electronics, supercollider

A custom wireless system built for Craftwife. The LEDs are to be sewn into real ties. There are 6 red LEDs per receiver and each led can be dynamically controlled (PWM 0-255). All receivers run on battery (AA 3.6V lithium) and keep in contact with the transmitter using 2.4GHz wireless transceivers (Nordic nRF24L01+). The maximum working distance is about ~80m (line of sight).

The transmitter talks to SuperCollider via the RedTieMaster and RedTieSlave classes (USB-Serial 115200 baud).

Schematics, firmware, partlist and SuperCollider classes attached below (GNU GPL v2)

redTie transmitter and receivers...

Leds on ribbon cable...

Total cable length: 135cm, distance between LEDs: 4cm

redTie - wireless hardware demo


Pact - April

2009-04-01 23:24 livecoding, supercollider

April 2009, 30 days, 1hour/day. Do something and show the result to your contracting party. Similar to our previous live-coding practising sessions (Aug 2006 and Jun 2007). This time I battle Marcus Fjellström. Follow his daily work here.

My rules are: on the last day of March, code a single SynthDef in SuperCollider that I'll force myself to make music with all throughout the month. I'm not allowed to use any other SynthDefs! If I need to change the synth definition during the 30 days, all the music written up to that point will be affected. These constraints are both quite strict and quite silly I know, but I imagine it'll help me focus my 1hour work on controlling the synth instead of rewriting the synthesis part all the time (bad habit). Of course, it is not the optimal way to make music in SuperCollider. Normally one would opt for smaller SynthDefs that do less and are interconnect via busses. See that as a warning and don't copy my SynthDef below. It's a big ugly beast.

So here's first the SynthDef. Coded on March 31st...

//this is the SynthDef that I must use for all 30 days
SynthDef(\redMond, {
  arg out= 0, pan= 0, det= 0,
  atk= 0.01, rel= 0.1, cur= -4, gate= 1,
  amp= 1, freq= 440, sel= 0, selFreq= 40,
  amp2= 0, freq2= 40, sel2= 0, selFreq2= 40,
  amp3= 0, freq3= 40, sel3= 0, selFreq3= 40,
  ringMix= -1, ringFreq= 440, ringGain= 0, ringRate= 1,
  distMix= -1, distFreq= 0.4, distDeep= 1,
  combMix= -1, combFreq= 40, combDecy= 1,
  moogMix= -1, moogFreq= 440, moogGain= 1,
  verbMix= -1, verbRoom= 0.4, verbDamp= 0.4;
  var iii, aaa, bbb, ccc, zzz,
  ii, aa, bb, cc, zz,
  i, a, b, c, z,
  det= det+1;  //detune.  1= no detune
  iii= SelectX.ar(sel3, [
    SinOsc.ar(selFreq3, 0, 1.5, 1.5),
    LFSaw.ar(selFreq3, 0, 1.5, 1.5),
    LFPulse.ar(selFreq3, 0, 0.3, 1.5, 1.5)
  aaa= SinOsc.ar(freq3, 0, amp3);
  bbb= LFSaw.ar(freq3*det, 0, amp3);
  ccc= LFPulse.ar(freq3*det*det, 0, 0.3, amp3);
  zzz= Select.ar(iii, [aaa, bbb, ccc]);
  ii= SelectX.ar(sel2, [
    SinOsc.ar(selFreq2, 0, 1.5, 1.5),
    LFSaw.ar(selFreq2, 0, 1.5, 1.5),
    LFPulse.ar(selFreq2, 0, 0.4, 1.5, 1.5)
  aa= SinOsc.ar(freq2+zzz, 0, amp2);
  bb= LFSaw.ar(freq2+zzz*det, 0, amp2);
  cc= LFPulse.ar(freq2+zzz*det*det, 0, 0.4, amp2);
  zz= Select.ar(ii, [aa, bb, cc]);
  i= SelectX.ar(sel, [
    SinOsc.ar(selFreq, 0, 1.5, 1.5),
    LFSaw.ar(selFreq, 0, 1.5, 1.5),
    LFPulse.ar(selFreq, 0, 0.5, 1.5, 1.5)
  a= SinOsc.ar(freq+zz);
  b= Saw.ar(freq+zz);
  c= Pulse.ar(freq+zz);
  z= Select.ar(i, [a, b, c]);
  z= XFade2.ar(z, SinOsc.ar(ringFreq+SinOsc.ar(ringRate, 0, ringGain), 0, z), ringMix);
  z= XFade2.ar(z, SinOsc.ar(distFreq, z*(1+(distDeep*(8pi-1))))*0.5, distMix);
  z= XFade2.ar(z, CombN.ar(z, 1, combFreq.reciprocal, combDecy), combMix);
  z= XFade2.ar(z, MoogFF.ar(z, moogFreq, moogGain), moogMix);
  z= FreeVerb.ar(z, verbMix*0.5+0.5, verbRoom, verbDamp);
  e= EnvGen.ar(Env.asr(atk, 1, rel, cur), gate, doneAction:2);
  Out.ar(out, Pan2.ar(z, pan, e*amp));

And here follows short MP3 excerpts. Note: all the 30 files + SynthDef can also be found the 'pact-apr09.zip' attached below.




2009-03-26 13:49 electronics

This is my all-round receiver for wireless controllers like redUniform and redThermoKontroll. It's a rebuild of my previous redUniform-master. I generalised it, added some buttons, switches and LEDs and put it into a proper box. I also removed the on-chip ceramic antenna on the Mirf transceiver and replaced it with a socket + a 4inch duck antenna. Now the range of the system is much greater.

The buttons I will use either as additional controllers or as backup controllers if a transmitter fails during the performance. The 4 LEDs are independently controlled and I imagine using them for visual feedback. Usually, I perform with the laptop hidden in the back and the laptop screen turned off. The LEDs will help to discretely show the status of the piece (form, section, sensor activity etc).

Version3 firmware attached below.




2009-03-17 22:16 electronics

I've finished another controller using the great V-USB from Obdev. This version has 16 pushbuttons, 1 switch, 1 light sensor, 4 pots and 1 slider. Just like the previous redKontroll it shows up as a standard HID devices and I have coded some simple MaxMSPJitter patches and SuperCollider classes to parse the data.

Of the 16 buttons, 12 are arranged as a full octave on a piano (black&grey instead of white&black), divided into 2 groups (cde/fgab). The remaining 4 as additional buttons on top of each group to form small pyramids. All this to later make it easier to remember what functions I assigned to which button.

Schematics, firmware, parts list and helper classes are available on the hardware page.

The total cost is about €45 and the major part of that is the buttons and the pots (see parts list).

RedInfo UGens

2009-03-06 13:46 supercollider

Last night I wrote three simple UGens for SuperCollider. They read the sudden motion sensor, ambient light sensors and the battery capacity on portable mac laptops. Download from the page: /code/sc/#plugins. (macOS 10.5 and later).

RedInfoSms - sudden motion sensor data sonified in SuperCollider


Below is the code for the example in the video. It is basically a remake of Cyrille Henry's classic bouncing balls (drpichon.free.fr/ch/data/msd_ch_20060603.mp4) using my redUniverse quark.

Note: new Apple laptops with SSD do not use sudden motion sensor (the hard drive no longer have any moving parts). So this example will only work with older laptops from ~2010. (battery and light sensor UGens still work though.)

//redFrik 090306, minor update 110804
  var width= 1000, height= 600, w, world, n= 30;
  var back= Window.new("", Window.screenBounds, false, false);
  back.view.background= Color.red(0.5, 1);

  SynthDef(\suddenmotionsynth, {|out= 0, freq= 400, maxDur= 0.3, amp= 1, pan= 0|
    var e, z, freqs, amps, rings;
    freqs= Array.geom(4, freq, Rand(1.5, 2.5));
    amps= Array.geom(4, 0.5, Rand(0, 1));
    rings= Array.geom(4, maxDur, Rand(0, 1))*maxDur;
    e= EnvGen.ar(Env.perc(0.0025, maxDur), 1, amp, doneAction:2);
    z= Klank.ar(`[freqs, amps, rings], WhiteNoise.ar(e));
    Out.ar(out, Pan2.ar(z*e, pan));
  SynthDef(\suddenmotionsensor, {|rate= 50|
    var trig= Impulse.kr(rate);
    SendReply.kr(trig, 'xyz', RedInfoSms.kr(trig));

  w= RedWindow("RedInfo", Rect.aboutPoint(Window.screenBounds.center, width/2, height/2)).front;
  world= RedWorld3(RedVector2D[width, height], RedVector2D[0, 0.98], 25, 0.25);

    var loc= RedVector2D[width, height].rand;
    var mass= 0.5.rrand(2);
    RedObject(world, loc, 0, 0, mass, mass*10);  //world,loc,vel,acc,mass,size

  OSCresponder(s.addr, 'xyz', {|t, r, m|
    //world.gravity= RedVector2D[m[3].neg*3, m[5]*5-4];  //some older macbooks have x inverted
    world.gravity= RedVector2D[m[3]*3, m[5]*5-4];

    Pen.fillColor= Color.red(1.2, 0.6);
      var osize, freq, amp, pan;
      if(world.contains(o).not, {
        osize= o.mass.linexp(0.5, 2, 0.15, 1);
        freq= osize.linexp(0.1, 1, 600, 400);
        amp= o.vel.mag.linexp(0, 25, 0.01, osize);
        pan= o.loc[0]/width*2-1;
        if(amp>0.02, {
          Synth(\suddenmotionsynth, [\freq, freq, \maxDur, osize, \amp, amp, \pan, pan]);

    if(w.isClosed.not, {w.close});
    if(back.isClosed.not, {back.close})

No, I'm not responsible if you accidentally drop your computer while using these.


2009-02-19 19:38 electronics

Soldering is such a nice relief from coding. For years I've had an old PC-joystick laying around (thank you, Abe). I knew I wanted to build something from it - something that would produce lovely noise - and yesterday I finally got around to hack it. The joystick now contains a slightly modified micro_noise synth circuit (based on a design by SGMK mechatronicart.ch). It also holds a 9V battery and the PC-connection cable now serves as sound output cable with standard 1/4 jack.

I used the switches and potentiometers that the joystick had and it was very quick to build and cost me virtually nothing. I just cut some cables and soldered them onto a tiny circuit board together with a few components. See the schematics below. The only visible change is the jack output and the LED I mounted in the case.

Based on micro_noise by SGMK. Slightly modified by /f0 090218

micro_noise_joy, 03:57, 15.8MB

Also see micro_noise2, Absolut micro_noise2 and micro_noise2 Batch.



2009-02-10 22:52 electronics

This is a tiny project from about 1 year ago. I wanted to add extra IR-light for my DV camera's night shot mode. Very useful when playing in dark and smoky clubs.

I bought 10 Osram high power IR LEDs (SFH4550) and found 5 small resistors (47 Ohm). I run it off two 1.5V batteries.

Below a picture and the schematics.

« 21 / 30 »