semi-random music generator
in
Android Processing
•
1 year ago
Hi,
I'm attempting to write a semi-random auto-play music generator for Android based on the below code which is causing some unpredictable timing. I'm wondering if there's a more efficient/clever way to do this?
- void zTrigger() {
- float r = random(40);
- if (r >= 0 && r <= 4) {
- chord1();
- }
- if (r >= 5 && r <= 7) {
- chord2();
- }
- if (r >= 8 && r <= 10) {
- chord 3();
- }
- if (r >= 11 && r <= 14) {
- chord4();
- }
- if (r >= 15 && r <= 18) {
- chord5();
- }
- if (r >= 19 && r <= 22) {
- chord6();
- }
- if (r >= 23 && r <= 24) {
- chord7();
- }
- }
- if (zMode) {
- fill(200,0,0);
- ellipse(60,190,20,20);
- //8th Note Beat
- if (millis() - sTime3 >= (tempoTime/2)) {
- percussion3();
- sTime3 = millis();
- //1/4 note beat
- if (millis() - sTime >= (tempoTime)) {
- percussion1();
- zTrigger();
- sTime = millis();
- }
- }
- }
1