Skip to content

Instantly share code, notes, and snippets.

@tado
Last active Dec 11, 2021
Embed
What would you like to do?
課題kadai13)リズムボックスの途中まで (これを元に段を増やしていく!!)
import ddf.minim.*;
int R = 0;
int f = 0;
Minim minim;
AudioSample[] player = new AudioSample[2];
PImage onImg;
PImage wakuImg;
PImage posImg;
int[] data1 = {1, -1, -1, -1, 1, -1, -1, -1};
int[] data2 = { - 1, -1, 1, -1, -1, -1, 1, 1};
void setup() {
size(510, 300);
frameRate(60);
onImg = loadImage("on.png");
wakuImg = loadImage("waku.png");
posImg = loadImage("pos.png");
minim = new Minim(this);//Minim の作成
player[0] = minim.loadSample("BD2.mp3");//音源の読み込み
player[1] = minim.loadSample("SN1.mp3");//音源の読み込み
}
void draw() {
background(255, 128, 0);
//音を制御する
f++;
if (f > 10) {
R++;
f = 0;
if (R >= 8) {
R = 0;
}
if (data1[R] == 1) {
player[0].trigger();
}
if (data2[R] == 1) {
player[1].trigger();
}
}
//リズムマシーンを表示
translate(50, 0);
image(posImg, R * 50, 0);
for (int i = 0; i < 8; i++) {
image(wakuImg, i * 50, 50);
if (data1[i] == 1) {
image(onImg, i * 50, 50);
}
image(wakuImg, i * 50, 100);
if (data2[i] == 1) {
image(onImg, i * 50, 100);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment