CodingTrain / Suggestion-Box

A repo to track ideas for topics
572 stars 86 forks source link

JavaScript Piano Keyboard #482

Open zstolfi opened 7 years ago

zstolfi commented 7 years ago

Not sure if anyone has suggested this topic before but here it is in case it hasn't. The piano should use equal temperament tuning (this) where each note is multiplied by the twelfth root of 2 to get a half step up. Also an A is at 440 hertz.

WillMacI commented 7 years ago

Creating A Piano Keyboard With P5.JS and loadSound()

You can draw the keyboard with P5.JS. Then you can import the key sounds with loadSound(). Here is some example code for loadSound():

function preload() {
 mySound = loadSound('assets/doorbell.mp3');
}

function setup() {
  mySound.setVolume(0.1);
  mySound.play();
}