<h1>Teensy Audio Wav2Sketch Utility</h1> | <h1>Teensy Audio Wav2Sketch Utility</h1> | ||||
<p>Upload an audio file to convert it into Teensy audio format.</p> | <p>Upload an audio file to convert it into Teensy audio format.</p> | ||||
<form> | <form> | ||||
<input id="audioFileChooser" name="audioFileChooser" type="file" accept="audio/*" multiple> | |||||
<label>Sample rate</label> | |||||
<select> | |||||
<option>Auto</option> | |||||
<option>44100</option> | |||||
<option>22050</option> | |||||
<option>11025</option> | |||||
</select><br/><br/> | |||||
<input id="audioFileChooser" name="audioFileChooser" type="file" accept="audio/wav" multiple> | |||||
<div id="outputFileHolder"></div> | <div id="outputFileHolder"></div> | ||||
</form> | </form> | ||||
<script type="text/javascript" src="wav2sketch.js"></script> | <script type="text/javascript" src="wav2sketch.js"></script> |
} | } | ||||
function processFile(file, fileName) { | function processFile(file, fileName) { | ||||
var context = new OfflineAudioContext(1,10*44100,44100); | |||||
var context = new OfflineAudioContext(1,100*44100,44100); // 100 seconds for now | |||||
context.decodeAudioData(file, function(buffer) { | context.decodeAudioData(file, function(buffer) { | ||||
console.log(buffer.sampleRate); | |||||
var monoData = []; | var monoData = []; | ||||
if(buffer.numberOfChannels == 1) { | if(buffer.numberOfChannels == 1) { | ||||
monoData = buffer.getChannelData(0); | monoData = buffer.getChannelData(0); |