Hey forum! Thanks for taking the time to read this!
So i’m trying my first piece of code, with very little experience…
My aim is to make a simple code that will show a letter/ note on screen (A to G) allong with an audio file (tts “A”, “B” etc…) to help me practice the piano .
I’d like to make this prompt a new note on the screen at random every 10 seconds.
So… this is what i’ve got…
var backgroundColor;
var randomNum = 0;
var musicNotes = ["A", "B", "C", "D", "E", "F", "G"];
var soundA;
var soundB;
var soundC;
var soundD;
var soundE;
var soundF;
var soundG;
var slider;
testABC = true
function setup() {
// set canvas size
createCanvas(400, 400);
// slider instellen
slider = createSlider(0, 1, 0.5, 0.01);
// load audio file klaar om af te spelen
soundA = loadSound("A.mp3", loaded);
soundB = loadSound("B.mp3", loaded);
soundC = loadSound("C.mp3", loaded);
soundD = loadSound("D.mp3", loaded);
soundE = loadSound("E.mp3", loaded);
soundF = loadSound("F.mp3", loaded);
soundG = loadSound("G.mp3", loaded);
}
// play audio file, callback
function loaded() {
soundA.play();
}
function draw() {
background(15);
//set volume van audio files
soundA.setVolume(slider.value());
soundB.setVolume(slider.value());
soundC.setVolume(slider.value());
soundD.setVolume(slider.value());
soundE.setVolume(slider.value());
soundF.setVolume(slider.value());
soundG.setVolume(slider.value());
var randomNote = musicNotes[randomNum];
fill(0);
noStroke();
print(randomNote);
text(randomNote, 10, 100);
}
function mousePressed() {
if (testABC == true) {
randomNum = int(random(7));
}
}
So, that’s not giving me what i want…
I find it kinda hard to know what direction to look for solving my code, so if you have any idea as where to look or what i’m doing wrong… that would help me alot!
HGP