-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Data from the Music Visualiser
James Hancock edited this page Feb 1, 2019
·
2 revisions
0. Access the bars array.
for (let i = 0; i < mV.bars.length; i++){ //For each bar in the music visualisation,
drawBar(i, mV.bars[i], mV.bars.length); //Draw that bar to the screen by some function.
}1. Take a sample of the sound data array.
- Returns the average of a small sample of the soundDataArray.
- Index declares which sample you want, the numSampleSections is
- how many sections you've split the array up into.
getSampleOfSoundData(index, numSampleSections)2. Get the average amplitude of the music.
- Returns the overall amplitude of the soundDataArray.
- The result is normalized between 0 and 1, where 0 is min, 1 is max.
getAmplitude()3. Get amplitude of the bass.
- Returns the average amplitude of the lowest 12th of the frequency spectrum.
getBass()4. Get amplitude of the midrange.
- Returns the average amplitude of the middle third of the frequency spectrum.
getMidrange()5. Get amplitude of the treble.
- Returns the average amplitude of the upper third of the frequency spectrum.
getTreble()