From 20d6ef7f907edd0b9f60b974e1ba24b5005fe7a4 Mon Sep 17 00:00:00 2001 From: Peter Prince Date: Thu, 13 Sep 2018 15:54:34 +0100 Subject: [PATCH] Add readme --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 6cdec8f..dfd9557 100644 --- a/README.md +++ b/README.md @@ -1 +1,22 @@ # wav-spectrogram +A Node.js library for loading WAV files and drawing a spectrogram to a canvas. + +### Usage ### + +Load WAV file using a input object, read contents as an array buffer and pass to function with a canvas of the desired dimensions: +``` +var fileInput = document.getElementById('file-input'); +var canvasElem = document.getElementById('spectrogram-canvas'); + +var reader = new FileReader(); + +reader.onload = function() { + + var arrayBuffer = reader.result; + + wavSpectro.drawSpectrogram(arrayBuffer, canvasElem, 'jet'); + +}; + +reader.readAsArrayBuffer(fileInput.files[0]); +``` \ No newline at end of file