Skip to content

Commit

Permalink
sounds, mic input output as ellipse, not great as it relies on mic vo…
Browse files Browse the repository at this point in the history
…lume levels
  • Loading branch information
left23 committed Mar 11, 2018
1 parent a72b0aa commit 7ab6e0c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# midi-drums
p5 midi drum machine using novation launch control for input, and Wes Bos' JS drum kit
p5 midi drum machine using novation launch control for input, and Wes Bos' JS drum kit GUI

You need a midi controller to see this working

https://p5js.org

https://github.com/wesbos/JavaScript30/tree/master/01%20-%20JavaScript%20Drum%20Kit

https://github.com/therewasaguy/p5-music-viz
28 changes: 20 additions & 8 deletions js/drums.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ var mySketch = function(myDrums) {
var boom;
var volumeBoom;



myDrums.preload = function () {
boom = myDrums.loadSound('sounds/Broke_For_Free_-_01_-_As_Colorful_As_Ever.mp3');
//boom = myDrums.loadSound('sounds/ride.mp3');
}

p5.midi.onInput = function (event) {
myDrums.clear();
console.dir(event);
myDrums.playSound();
//Drums.volumeControl();
//myDrums.volumeControl();
}

myDrums.setup = function (event) {
Expand All @@ -41,18 +39,24 @@ var mySketch = function(myDrums) {
this.classList.remove('playing');
}

console.log(boom);
//console.log(boom);

myDrums.micOn();

myDrums.amplitude = new p5.Amplitude();
boom.setVolume(0.5);
//myDrums.amplitude.smooth(0.9);
//boom.setVolume(0.5);
myDrums.amplitude.setInput(mic);
myDrums.amplitude.smooth(0.9);

// /console.log(myDrums.amplitude.getLevel());
}

myDrums.draw = function () {
myDrums.background(0);
myDrums.fill(255);
var level = myDrums.amplitude.getLevel();
var size = myDrums.map(level, 0, 1, 0, 200);
//console.log(level);
var size = myDrums.map(level, 0, 1, 0, 1000);
myDrums.ellipse(myDrums.width/2, myDrums.height/2, size, size);
}

Expand Down Expand Up @@ -84,6 +88,7 @@ var mySketch = function(myDrums) {
}

myDrums.volumeControl = function () {

const volume = (event.data[2]);
console.log('amplitude ' + amplitude);
console.log('volume ' + volume);
Expand All @@ -95,6 +100,13 @@ var mySketch = function(myDrums) {
}

}
myDrums.micOn = function () {
// Create an Audio input
mic = new p5.AudioIn();
// start the Audio Input.
// By default, it does not .connect() (to the computer speakers)
mic.start();
}

}

Expand Down

0 comments on commit 7ab6e0c

Please sign in to comment.