How can I get sound data?

I have this library
and this code

var context = new AudioContext();
var fileInput = document.getElementById("fileInput");

fileInput.onchange = function () {
  var files = fileInput.files;

  if (files.length == 0) return;
  var reader = new FileReader();

  reader.onload = function(fileEvent) {
    context.decodeAudioData(, calcTempo);

var calcTempo = function (buffer) {
  var audioData = [];
  // Take the average of the two channels
  if (buffer.numberOfChannels == 2) {
    var channel1Data = buffer.getChannelData(0);
    var channel2Data = buffer.getChannelData(1);
    var length = channel1Data.length;
    for (var i = 0; i < length; i++) {
      audioData[i] = (channel1Data[i] + channel2Data[i]) / 2;
  } else {
    audioData = buffer.getChannelData(0);
  var mt = new MusicTempo(audioData);


But how do I point to a file from a project without file input?

Not sure about your specific library if it’s not in its documentation, I assume you looked there or in the code/examples.

I’ve been using the minim library (

Here are some of the features of Minim:

  • AudioPlayer: Mono and Stereo playback of WAV, AIFF, AU, SND, and MP3 files.
  • AudioMetaData: An object filled with metadata about a file, such as ID3 tags.
  • AudioRecorder: Mono and Stereo audio recording either buffered or direct to disk.
  • AudioInput: Mono and Stereo input monitoring.
  • AudioOutput: Mono and Stereo sound synthesis.
  • FFT: perform a Fourier Transform on audio data to generate a frequency spectrum.
  • BeatDetect: a class for doing beat detection.
  • A real-time synthesis framework based around unit generators, which we call UGens.