Last active
December 11, 2021 01:15
-
-
Save tado/a89dbf389b2d93a18ebb61905d2af0b1 to your computer and use it in GitHub Desktop.
課題kadai13)リズムボックスの途中まで (これを元に段を増やしていく!!)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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