Skip to content

Instantly share code, notes, and snippets.

@mikkun
Created May 11, 2015 09:50
Show Gist options
  • Save mikkun/0fab99a3c4bcff0032b7 to your computer and use it in GitHub Desktop.
Save mikkun/0fab99a3c4bcff0032b7 to your computer and use it in GitHub Desktop.
「ドレミファインバータ」なメロディーが鳴るProcessingのサンプルコード
/**
* 「上田ブログ」(http://blog.ueda.asia/)のエントリー
* 『京急VVVF音(ドレミファインバータ)の周波数』
* (http://blog.ueda.asia/?p=6039)をProcessingで鳴らしてみる
*/
import ddf.minim.*;
import ddf.minim.ugens.*;
Minim minim;
AudioOutput out;
void setup() {
size(200, 100, P3D);
minim = new Minim(this);
out = minim.getLineOut();
out.playNote(0.0, 0.6, 349.0); // ファ
out.playNote(0.6, 0.3, 392.0); // ソ
out.playNote(0.9, 0.3, 440.0); // ラ
out.playNote(1.2, 0.2, 466.0); // ラ#
out.playNote(1.4, 0.2, 523.0); // ド
out.playNote(1.6, 0.2, 587.0); // レ
out.playNote(1.8, 0.2, 622.0); // レ#
out.playNote(2.0, 0.2, 698.0); // ファ
out.playNote(2.2, 3.0, 784.0); // ソ
}
void draw() {
background(0);
stroke(255);
for(int i = 0; i < out.bufferSize() - 1; i++) {
line(
i,
50 + out.mix.get(i) * 50,
i + 1,
50 + out.mix.get(i + 1) * 50
);
}
}
void stop() {
out.close();
minim.stop();
super.stop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment