xxxxxxxxxx
49
// sketch.js
// fftSize must be at least 32, and a power of 2 (32,64,128,256 etc.)
var fftSize = 32
function setup() {
createCanvas( windowWidth, windowHeight )
drums = EDrums('x*o*x*o-')
drums.amp = .5
bass = FM('bass')
.note.seq( [440,660,495,495,742.5,660,495,660,495,440,495,660,495,440,440,495,742.5,495,660,495,660,742.5,440,742.5,660,495,495,495,742.5,742.5,660,660,440,495,742.5,742.5,495,495,495,440,495,495,495,495,495,440,440,495,495,742.5,495,495,660,495,495,495,742.5,495,495,742.5,495,440,742.5,495,742.5,742.5,742.5,440,495,742.5,495,495,495,495,742.5,495,742.5,495,495,495,440,495,742.5,660,742.5,440,495,495,742.5,440,495,742.5,495,495,440,495,660,440,660,660,440,495,660,495,495,742.5,495,440,495,495,440,495,440,440,660,660,742.5,742.5,495,660,660,495,660,495,742.5,495,742.5,440,495,440,495,495,495,742.5,660,495,495,495,495,742.5,495,440,495,742.5,495,742.5,440,495,660,495,495,742.5,495,742.5,495,495,742.5,495,742.5,742.5,495,742.5,440,495,742.5,742.5,742.5,742.5,495,660,495,440,495,660,495,742.5,660,660,495,742.5,495,660,495,742.5,495,742.5,495,742.5,495,495,742.5,440,440,495,495,495,660,660,742.5,660,440,742.5,742.5,495,742.5,495,742.5,495,495,495,742.5,742.5,660,495,742.5,440,495,495,495,742.5,742.5,742.5,742.5,495,495,440,742.5,742.5,742.5,495,495,742.5,742.5,495,440,495,742.5,660,440,660,495,440,495,742.5,495,660,440,440,495,660,742.5,440,742.5,495,495,440,495,495,742.5,742.5,742.5,440,742.5,495,742.5,660,660,742.5,742.5,495,742.5,660,660,495,660,495,742.5,495,495,742.5,742.5,495,660,495,660,495,660,495,440,660,440,660,495,660,742.5,742.5,495,742.5,495,660,660,495,742.5,495,660,495,660,660,742.5,495,495,495,440,742.5,742.5,742.5,742.5,495,440,742.5,660,742.5,495,742.5,495,742.5,660,495,440,660,495,495,742.5,440,742.5,660,440,495,440,495,660,742.5,440,495,742.5,495,742.5,742.5,742.5,660,495,495,660,495,742.5,440,742.5,742.5,440,495,495,495,660,495,495,495,495,495,660,440,495,495,495,495,660,495,495,495,495,440,440,440,660,742.5,742.5,742.5,440,742.5,742.5,742.5,440,742.5,440,660,742.5,742.5,742.5,495,660,742.5,440,495,495,742.5,495,495,742.5,742.5,495,495,495,660,742.5,495,742.5,742.5,495,742.5,660,660,440,742.5,440,495,742.5,660,660,495,495,742.5,742.5,742.5,742.5,660,440,660,495,495,742.5,495,495,742.5,742.5,660,742.5,742.5,742.5,742.5,742.5,495,742.5,495,742.5,742.5,660,742.5,742.5,660,495,495,742.5,660,440,495,495,495,742.5,742.5,742.5,440,742.5,742.5,495,440,495,495,440,742.5,742.5,660,440,495,660,495,495,660,495,660,495,495,742.5,742.5,660,440,495,742.5,742.5,742.5,495,742.5,495,440,660,660,742.5,495,440,440,440,495,440,495,495,495,495,742.5,440,660,660,742.5,742.5,440,495,495,495,440,495,440,660,742.5,495,495,660,660,660,495,742.5,495,495,495,660,742.5,742.5,742.5,660,660,440,440,495,495,742.5,742.5,495,495,495,440,742.5,495,495,742.5,660,495,440,742.5,742.5,742.5,495,742.5,495,440,495,660,742.5,660,495,495,742.5,495,440,660,495,495,495,742.5,660,660,495,495,495,495,495,495,660,440,660,440,495,660,742.5,742.5,742.5,495,495,742.5,495,440,660,495,660,495,440,495,742.5,742.5,495,440,440,440,495,495,495,742.5,742.5,495,495,495,660,742.5,495,495,440,495,495,660,495,660,495,495,440,495,742.5,495,495,742.5,495,495,495,742.5,495,742.5,742.5,660,495,495,440,742.5,742.5,495,495,495,660,440,495,495,440,495,742.5,660,495,440,660,495,495,440,742.5,495,495,495,495,495,495,742.5,742.5,495,495,495,742.5,495,495,495,660,742.5,742.5,495,742.5,660,742.5,495,742.5,440,440,742.5,495,742.5,440,495,440,742.5,742.5,660,660,742.5,495,495,660,440,440,660,742.5,742.5,660,495,440,742.5,660,742.5,495,495,495,660,440,440,495,495,742.5,742.5,660,440,742.5,742.5,742.5,660,742.5,742.5,495,495,742.5,742.5,660,742.5,742.5,495,440,440,495,742.5,495,660,495,495,660,495,495,742.5,440,742.5,495,742.5,742.5,495,742.5,742.5,660,742.5,742.5,742.5,495,660,440,495,495,742.5,742.5,495,495,660,440,660,495,660,495,742.5,742.5,742.5,495,742.5,495,440,742.5,660,495,495,742.5,742.5,742.5,495,495,742.5,742.5,742.5,495,495,495,495,742.5,742.5,660,742.5,495,440,660,440,742.5,742.5,495,495,660,440,495,440,495,742.5,495,495,495,742.5,495,742.5,660,495,742.5,742.5,660,495,440,742.5,742.5,495,495,660,660,495,742.5,495,495,440,660,660,495,440,742.5,440,495,742.5,440,495,742.5,660,495,742.5,495,495,495,495,742.5,660,495,495,660,495,742.5,495,742.5,742.5,440,742.5,660,742.5,495,742.5,660,742.5,495,660,495,440,660,495,660,440,660,495,742.5,495,742.5,660,742.5,742.5,440,495,495,495,742.5,440,440,495,660,742.5,440,742.5,495,495,742.5,495,495,495,495,742.5,495,440,440,495,742.5,660,660,742.5,660,440,495,495,495,495,495,742.5,660,440,440,742.5,660,660,495,742.5,742.5,660,660,742.5,440,495,440,660,440,495,440,440,495,495,495,495,495,495,495,440,660,742.5,495,440,440,742.5,495,495,660,660,742.5,495,660,495,495,440,495,495,495,495,660,495,742.5,440,660,440,495,440], [1/8,1/16].rnd(1/16,2) )
rhodes = Synth( 'rhodes', {amp:.1} )
.chord.seq( Rndi(0,6,3), 1 )
.fx.add( Delay() )
fft = FFT( fftSize )
Gibber.scale.root.seq( ['c6','ab3','bb3'], [4,2,2] )
Gibber.scale.mode.seq( ['Minor','Mixolydian'], [6,2] )
noStroke()
colorMode( HSB, 255 )
}
function draw() {
background( 64 )
var numBars = fftSize / 2,
barHeight = ( height - 1 ) / numBars,
barColor = null,
value = null
for( var i = 0; i < numBars; i++ ) {
barColor = color( ( i / numBars ) * 255, 255, 255 )
fill( barColor )
// read FFT value, which ranges from 0-255, and scale it.
value = ( fft[ i ] / 255 ) * width
rect( 0, barHeight * i, value, barHeight )
}
}