Create a sketch in Processing using the minim sound library.
You can either use an audio file or a live input.
Document your sketch in THREE (3) ways:
1) Upload your homework to the class wiki as usual. In order to include your sound file with the sketch, make sure to zip the file before your upload it. Do this by going into Sketch / Show Sketch Folder , and then File / Compress
2) copy and paste the code directly from Processing into the comment section of this blog post. Make sure to include your name.
3) use saveFrame() to make a selection of still frames, a gif, or an animation. Upload one or two still images from the "saveFrame" function into the comment section along with your code.
Email me for questions!
zoecberger@gmail.com
Teaching Processing
Friday, May 1, 2015
saveFrame()
Many times, the sketches created in Processing are not functional in JavaScript as we intend them. Luckily there are several other ways to share and display work.
You can screen capture your sketches from your desktop, but within Processing your can also capture frames.
The easiest way to do this is to simply add a line at the end of draw:
saveFrame();
This will save each frame (60fps) into your sketch folder. You can then use photoshop or aftereffects to restore the animation, for example.
saveFrame uses the extension .tif by default. Change this by adding an argument. The Hashtags will count the frames. You can use .tif, .tga, .jpg, or .png
saveFrame("filename_#####.jpg");
You can screen capture your sketches from your desktop, but within Processing your can also capture frames.
The easiest way to do this is to simply add a line at the end of draw:
saveFrame();
This will save each frame (60fps) into your sketch folder. You can then use photoshop or aftereffects to restore the animation, for example.
saveFrame uses the extension .tif by default. Change this by adding an argument. The Hashtags will count the frames. You can use .tif, .tga, .jpg, or .png
saveFrame("filename_#####.jpg");
Quick Start: Minim Sound Library: Simple Input
//Use processing to analyze audio input from your computer's mic
//import library
import ddf.minim.*;
//initialize variables
Minim minim;
AudioInput in;
void setup()
{
minim = new Minim(this);
in = minim.getLineIn();
size(300,300);
}
void draw()
{
background(0);
stroke(255);
for(int i = 0; i< in.bufferSize() - 1; i++)
{
line(i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50);
line(i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50);
}
}
//import library
import ddf.minim.*;
//initialize variables
Minim minim;
AudioInput in;
void setup()
{
minim = new Minim(this);
in = minim.getLineIn();
size(300,300);
}
void draw()
{
background(0);
stroke(255);
for(int i = 0; i< in.bufferSize() - 1; i++)
{
line(i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50);
line(i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50);
}
}
Quick Start: Minim Sound Library: Simple Waveform
//Use Processing to analyze a sound file. Don't forget to import your song!
//import library
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
//initialize variables
Minim minim;
AudioPlayer player;
void setup()
{
minim = new Minim(this);
player = minim.loadFile("Guide (Tom Gillieron Remix).aif");
player.play();
size(300,300);
}
void draw()
{
background(0);
stroke(255);
for(int i = 0; i< player.bufferSize() - 1; i++)
{
line(i, 50 + player.left.get(i)*50, i+1, 50 + player.left.get(i+1)*50);
line(i, 150 + player.right.get(i)*50, i+1, 150 + player.right.get(i+1)*50);
}
}
//import library
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
//initialize variables
Minim minim;
AudioPlayer player;
void setup()
{
minim = new Minim(this);
player = minim.loadFile("Guide (Tom Gillieron Remix).aif");
player.play();
size(300,300);
}
void draw()
{
background(0);
stroke(255);
for(int i = 0; i< player.bufferSize() - 1; i++)
{
line(i, 50 + player.left.get(i)*50, i+1, 50 + player.left.get(i+1)*50);
line(i, 150 + player.right.get(i)*50, i+1, 150 + player.right.get(i+1)*50);
}
}
Quick Start: Minim Sound Library: Simple Player
Simple Player:
//in Processing, go to Sketch / Add File / and select your song
//import library = full library imports even though we only need ddf.minim.*
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
//initialize variables use any name you like!
Minim minim;
AudioPlayer player;
void setup()
{
minim = new Minim(this);
player = minim.loadFile("Guide (Tom Gillieron Remix).aif");
player.play();
}
void draw()
{
}
//in Processing, go to Sketch / Add File / and select your song
//import library = full library imports even though we only need ddf.minim.*
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
//initialize variables use any name you like!
Minim minim;
AudioPlayer player;
void setup()
{
minim = new Minim(this);
player = minim.loadFile("Guide (Tom Gillieron Remix).aif");
player.play();
}
void draw()
{
}
//The player can also be executed in draw() to create interactive sketches.
Wednesday, February 11, 2015
Random Function: Rafael Lozano-Hemmer
From Rafael's website: “Method Random” is a series of chromogenic prints that have been generated by computational methods that attempt to create randomness. Random number generators (RNG) are essential algorithms for a large number of applications from encryption and security to simulation, jury selection, double-blind trials, statistical sampling, game theory and many others. While the sum of all colours picked by different RNG algorithms generates a neutral gray, patterns can be discerned when massive number of pixels can be seen simultaneously. These prints show how human perception of organization can often spot the fundamental difficulty for computers to appear unpredictable.
The nine algorithms chosen are as follows:
1. Image generated with a seed of 5970917 using an LCG algorithm with a=22695477, c=1, and m=2^32. The same algorithm used by Borland C/C++, except with using the least significant 24bits.
2. Image generated with a seed of 5972092 using an XORSHIFT with an l,r,l shifting pattern and a=1, b=3, and c=11 (instead of 10), using the least significant 24bits
3. Image was generated with RANDU with a seed of 9830209, using the least significant 24bits. (https://en.wikipedia.org/wiki/RANDU)
4. Image was generated with RANDU with a seed of 271828, using the most significant 24bits. (https://en.wikipedia.org/wiki/RANDU)
5. Image was generated with a seed of 1967 using an LCG algorithm with a=833, c=3927 and m=2^32. Using bits [6..30]
6. Image was generated with a seed of 1985 using a quadratic equation of the form y = ax^2 + bx +c with a=124,b=909, c=751 and m=2^32. Using bits [6..30]
7. Image was generated with a seed of 8333927 using x_{i+1} = roundleft(frac{x_i}{sqrt{x_i}} ight) +19671985. Using the least significant 24 bits
8. Image was generated with a seed of 7071067 using seed = (161803398*seed)+ seed. Using the least significant 24 bits
9. Image was generated with a seed of 14142135 using a quadratic equation of the form y = ax^2 - bx +c with a=132471, b=2584981, c=22958 and m=2^32. Using the most significant 24 bits.
http://www.lozano-hemmer.com/method_random.php
Subscribe to:
Posts (Atom)


