Skip to content

Instantly share code, notes, and snippets.

@mactkg
Created April 19, 2012 15:08
Show Gist options
  • Save mactkg/2421540 to your computer and use it in GitHub Desktop.
Save mactkg/2421540 to your computer and use it in GitHub Desktop.
まだ途中ですよ
import ddf.minim.analysis.*;
import ddf.minim.*;
Minim minim;
AudioPlayer in;
int time;
int waveH;
String stringName = "test";
String audioName = "bara.mp3";
void setup(){
size(1024,600);
minim = new Minim(this);
minim.debugOn();
in = minim.loadFile(audioName);
in.loop();
textFont(createFont("Cochin.ttc", 100));
time = 0;
waveH = 280;
}
void draw(){
background(240);
fill(128);
text(in.left.get(100), width/3, height/2+45);
fill(244, 179, 194);
stroke(244, 179, 194);
for(int i = 0; i < in.bufferSize() - 1; i++){
ellipse(i*2, 300 + in.left.get(i)*waveH, 3, 3);
}
fill(128);
text(width, 100, 100);
text(mouseX, 100, 200);
text(mouseX/1024.0 , 100, 300);
text(mouseX/1024.0*in.length(), 100, 400);
}
void keyReleased(){
if (key == 'p') {
in.play(int(mouseX/1024.0*in.length()));
}
}
void stop(){
in.close();
minim.stop();
super.stop();
}
import ddf.minim.analysis.*;
import ddf.minim.*;
Minim minim;
AudioInput in;
AudioRecorder recorder;
int time;
int waveH;
String stringName = "test";
void setup(){
size(1024,600);
minim = new Minim(this);
minim.debugOn();
in = minim.getLineIn(Minim.MONO, 512);
recorder = minim.createRecorder(in, stringName + ".wav", true);
textFont(createFont("Cochin.ttc", 100));
time = 0;
waveH = 280;
recorder.beginRecord();
}
void draw(){
background(240);
fill(128);
text(in.left.get(100), width/3, height/2+45);
fill(244, 179, 194);
stroke(244, 179, 194);
for(int i = 0; i < in.bufferSize() - 1; i++){
ellipse(i*2, 300 + in.left.get(i)*waveH, 3, 3);
//point(i, 200 + in.left.get(i)*waveH);
//line(i, 300 + in.left.get(i)*280, i+1, 300 + in.left.get(i+1)*280);
//line(i, 20 + in.left.get(i)*30, i+1, 20 + in.left.get(i+1)*30);
}
}
void keyReleased(){
if (key == 's') {
recorder.endRecord();
recorder.save();
}
}
void stop(){
in.close();
minim.stop();
super.stop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment