Day 4

Posted: September 4th, 2010 | Author: admin | Filed under: Creative Pact 2010 | No Comments »

This one has been in the works for awhile. I have been looking at the minim BETA for a few days and now I feel like I am getting my head around it. Today I made my first UGen. I think I am going to submit it to the distribution. It is a byte swapping algorithm inspired by swap~ in zexy for PD. This is one of my favourite distortions. Very loud and very nasty. You’ve been warned.

Today I also finally delved into Processing’s method for exporting applets. So, I am not going to dump a whole lot of code in this post. If you want to see the code follow the links below.

The audio display is rendered as points. This is inspired by something I saw at MUTEK this year and is also the flavour of the visual material for Frank Bretschneider’s EXP. http://www.frankbretschneider.de/Web-Site/exp.html


Today’s Code:

http://www.adamtindale.com/code/processing/creativepact2010/DAY4/


Day 3

Posted: September 3rd, 2010 | Author: admin | Filed under: Creative Pact 2010 | No Comments »

Today was a challenge. I downloaded the BETA of MINM so that I could try the new UGEN api. It is interesting but not fully featured yet. I saw a Granulator in there and I got excited. I wasn’t able to make any good sounds and I ran into some troubles with controlP5 and MINIM where they both had Controller classes and Events.

There is a crazy solution where the name of a controlP5 object can be declared as a global and the slider will update the global. I have to look further into why this works but it certainly minimizes the amount of code I have to write to make a basic GUI.

This example does a simple mapping of the BitCrush UGEN with a slider. It also has a display for the audio output. I would love to have access to the audio input too. More work to be done. I am learning a lot here.




import ddf.minim.*;
import ddf.minim.ugens.*;
import controlP5.*;

ControlP5 controlP5;
Slider bdslider;
public float bitdepth;

Minim minim;
LiveInput in;
AudioOutput out;
Constant controls = new Constant();
BitCrush fx1 = new BitCrush();

void setup(){
  size(500, 400);
  minim = new Minim(this);
  out = minim.getLineOut();
  in = new LiveInput( minim.getInputStream(out.getFormat().getChannels(), out.bufferSize(), out.sampleRate(), out.getFormat().getSampleSizeInBits()) ); 

  controlP5 = new ControlP5(this);
  bdslider = controlP5.addSlider("bitdepth",1,16,  15,height/3-80 , width-100,30);

  bdslider.setValue(8);

  controls.patch(fx1.bitRes);
  controls.setConstant (bitdepth); 

 in.patch(fx1).patch(out);
}

void draw(){
  background(50);
  stroke( 255 );

  controls.setConstant (bitdepth); 

  for( int i = 0; i < out.bufferSize() - 1; i++ )
  {
    float x1  =  map( i, 0, out.bufferSize(), 0, width );
    float x2  =  map( i+1, 0, out.bufferSize(), 0, width );
    line( x1, height*.75 + out.left.get(i)*50, x2, height*.75 + out.left.get(i+1)*50);
    line( x1, height*.75 + 50 + out.right.get(i)*50, x2, height*.75 + 50 + out.right.get(i+1)*50);
  }
  controlP5.draw();
}

void keyPressed(){
  if (key == ' ')
    saveFrame();
}

void stop()
{
  in.close();
  out.close();
  minim.stop();
  super.stop();
}

Day 2

Posted: September 2nd, 2010 | Author: admin | Filed under: Creative Pact 2010 | No Comments »

I have been messing with Minim. This is a simple synthesis sketch that uses a few triangle waves represented by coloured circles and modifies colour by monitoring the pan (which is randomized a bit).

The really fun features seem to be in the BETA so I will play with that a bit tomorrow. I am anxious to try out the granulator and the bitcrusher.




import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.effects.*;

Minim minim;
AudioOutput out;
TriangleWave s1;
TriangleWave s2;
TriangleWave s3;
BandPass bpf;

float circlesize = 50;

void setup()
{
  size(400, 200);
  frameRate(24);
  minim = new Minim(this);
  out = minim.getLineOut(Minim.STEREO);

  bpf = new BandPass (500, 100, out.sampleRate() ) ;

  s1 = new TriangleWave(440, 0, out.sampleRate());
  s1.portamento(2000);
  out.addSignal(s1);

  s2 = new TriangleWave(450, 0, out.sampleRate());
  s2.portamento(2000);
  out.addSignal(s2);

  s3 = new TriangleWave(490, 0, out.sampleRate());
  s3.portamento(2000);
  out.addSignal(s3);

  out.addEffect(bpf);

  ellipseMode(CENTER);
  smooth();
  noStroke();

  s1.setPan(0);
  s2.setPan(1.0);
  s3.setPan(-1.0);

  //println(s1.pan() + " " + s2.pan() +" " + s3.pan() );
}

void draw()
{
  background(0);

  fill ( lerpColor (color(255,190,10), color(130,190,180), (s1.pan() + 1)*0.5 ));
  ellipse((s1.pan() * width/2) + width/2, height/2, s1.amplitude() * circlesize , s1.amplitude() * circlesize);

  fill ( lerpColor (color(255,190,10), color(130,190,180), (s2.pan() + 1)*0.5 ));
  ellipse((s2.pan() * width/2) + width/2, height/2, s2.amplitude() * circlesize , s2.amplitude() * circlesize);

  fill ( lerpColor (color(255,190,10), color(130,190,180), (s3.pan() + 1)*0.5 ));
  ellipse((s3.pan() * width/2) + width/2, height/2, s3.amplitude() * circlesize , s3.amplitude() * circlesize);

  if (s1.amplitude() < 0.3)
    s1.setAmp( s1.amplitude() + 0.01);

  if (s2.amplitude() < 0.3)
    s2.setAmp( s2.amplitude() + 0.01);

  if (s3.amplitude() < 0.3)
    s3.setAmp( s3.amplitude() + 0.01);

  s1.setPan( constrain(s1.pan() + random(-0.01,0.01) ,-1.0,1.0));
  s2.setPan( constrain(s2.pan() + random(-0.01,0.01) ,-1.0,1.0));
  s3.setPan( constrain(s3.pan() + random(-0.01,0.01) ,-1.0,1.0));

}

void mouseClicked(){
  s1.setFreq(s1.frequency() + random(-10,10) );
  s2.setFreq(s2.frequency() + random(-10,10) );
  s3.setFreq(s3.frequency() + random(-10,10) );
  saveFrame();
}

void stop()
{
  out.close();
  minim.stop();
  super.stop();
}

Day 1

Posted: September 2nd, 2010 | Author: admin | Filed under: Creative Pact 2010 | No Comments »

My first sketch is a simple Lissajous curve out of a live audio input. I borrowed some code from a Minim example and a sketch from OpenProcessing.org.

I used the RMS values from the audio buffer to determine the sound and location of each plot. These changes aren’t radical but they add some flavour. Enjoy!



import ddf.minim.*;
import processing.video.*;

Minim minim;
AudioInput input;
WaveformRenderer waveform;

MovieMaker mm;

void setup()
{
  size(640, 480, P2D);
  frameRate(24);

  minim = new Minim(this);
  input = minim.getLineIn(Minim.STEREO, 512);
  waveform = new WaveformRenderer();
  input.addListener(waveform);

  mm = new MovieMaker(this, width, height, "mysketchoutput.mov", 24, MovieMaker.H263, MovieMaker.HIGH);
}

void draw()
{
  //background(0);
  fill(0,20);
  noStroke();
  rect(0,0,width,height);
  // see waveform.pde for an explanation of how this works
  waveform.draw();
  mm.addFrame();
}

void stop()
{
  // always close Minim audio classes when you are done with them
  input.close();
  // always stop Minim before exiting.
  minim.stop();
  super.stop();
   mm.finish();
}

void captureEvent(Capture myCapture) {
  myCapture.read();
}

class WaveformRenderer implements AudioListener
{
  private float[] left;
  private float[] right;

  color a = color (38,148,200);
  color b = color(200,148,38);

  WaveformRenderer()
  {
    left = null;
    right = null;
  }

  synchronized void samples(float[] samp)
  {
    left = samp;
  }

  synchronized void samples(float[] sampL, float[] sampR)
  {
    left = sampL;
    right = sampR;
  }

  synchronized void draw()
  {
    if ( left != null && right != null )
    {
      noFill();

      float rms = 0;
      for (int i = 0 ; i < left.length; i++)
        rms += left[i];
      rms *= rms;
      //rms /= left.length;

      fill(lerpColor(a,b,rms*255));

      beginShape();
      for (int step=0; step< right.length; step++) {
             float l = 5-step;
             int x=(int) (right[step]*l*Math.sin(l*Math.PI/right.length));
             int y=(int) (right[step]*l*Math.cos(l*Math.PI/right.length));
             vertex ( 0.75*width + x - rms, height/2 + y);
      }
      endShape();
    }
  }
}

O’Reilly Class

Posted: August 31st, 2010 | Author: admin | Filed under: Creative Pact 2010 | No Comments »

I enrolled for the O’Reilly class on Processing and Arduino and it starts in 30 minutes. I am hoping that it becomes useful. I do like controlP5 as a library for guis.

In the meantime I did a few utils. I have an easy save mechanism thanks to saveFrame() in Processing. I also have some sketch code for recording video. Surely this will change over the month but these are things that I thought would be important to start.

I think I may also start a template sketch so I can get straight to my idea. I’ll be sure to put it up if I get to it.


import processing.video.*;
MovieMaker mm;  // Declare MovieMaker object

/*
// copy to setup() to activate
 mm = new MovieMaker(this, width, height, "mysketchoutput.mov",
                       frameRate, MovieMaker.H263, MovieMaker.HIGH);
// copy to the end of draw()
mm.addFrame();
*/
void captureEvent(Capture myCapture) {
  myCapture.read();
}

void mouseReleased(){
   println(frameRate);
}

void keyPressed(){
 if(key == ' ')
  saveFrame();

 if (key == 'f')
  println(frameRate); 

 if(key == 's' & mm != null)
    mm.finish();
}

Sorry

Posted: August 28th, 2010 | Author: admin | Filed under: Uncategorized | No Comments »

I just changed the way the url mechanism works and it looks like if you subscribe via RSS then all of the blog looks new to your reader. Sorry!


Gearing Up for Creative Pact 2010

Posted: August 28th, 2010 | Author: admin | Filed under: Creative Pact 2010 | No Comments »

Finally I am going to be staying at home for some length of time. I have a few goals for the next few months to forward my practice. I need to improve my Processing.org skills and learn some new tricks to get my next project done. To that end I am committing to the Creative Pact 2010 in order to keep myself motivated.

Every day in September I will put up a new post about something creative I have done in Processing. I was thinking that every post would be audio + visuals but I think I am going to keep it manageable. I don’t know if I will have more than an hour a day to be creative since school starts soon. Weekends will likely have bigger projects, as I will have more time on those days.

I am hoping to learn some more about Minim, controlP5, GLGraphics and OpenGL in general as I create this stuff.

For all you Processing experts watching please comment and show me how to improve my code, coding, and inspiration for visuals. Even links to things would be super helpful.

I am going to build a few tools for the next few days so I can take some screenshots and videos easily to post for y’all. I will put them here in case they are useful for you too.


Motion Study

Posted: August 3rd, 2010 | Author: admin | Filed under: Uncategorized | No Comments »

I took a bunch of pictures and then pasted them together with

convert $(ls *JPG | sort -n -r) $(ls *JPG | sort -n) -layers OptimizePlus paper.gif

convert is a tool from the free ImageMagick package. The sort command organizes the files into numerical order (great for those file names that cameras tend to import). The -r flag reverses the set in the first sequences and then I remove it for the second sequence so it loops nicely. Again, you may have to click on the picture and let it load a second before you get a nicely looping image.


Rolling

Posted: August 3rd, 2010 | Author: admin | Filed under: Uncategorized | No Comments »


// TITLE: Rolling
// Adam Tindale 2010

int count = 0;
import gifAnimation.*;

GifMaker gifExport;
void setup(){

  gifExport = new GifMaker(this, "blackorwhite.gif");
  gifExport.setRepeat(0);

 frameRate(5);
 noStroke();
}

void draw(){
  background(0);

  rect(((count-10)/10.0) * width,0, width, height);

 gifExport.setDelay(5);
 gifExport.addFrame();

 if (count == 19){
  gifExport.finish();
  exit();
 }

  count = ++count % 20;
}

SELFPORTRAIT (_loading)

Posted: August 3rd, 2010 | Author: admin | Filed under: Uncategorized | No Comments »

This is an animated GIF. Click on it to watch the animation.