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
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.
Subscribe to:
Posts (Atom)