This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.ietf.org/rfc/rfc2781.txt | |
function decodeUtf16(w) { | |
var i = 0; | |
var len = w.length; | |
var w1, w2; | |
var charCodes = []; | |
while (i < len) { | |
var w1 = w[i++]; | |
if ((w1 & 0xF800) !== 0xD800) { // w1 < 0xD800 || w1 > 0xDFFF | |
charCodes.push(w1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!FileReader.prototype.readAsArrayBuffer) { | |
FileReader.prototype.readAsArrayBuffer = function readAsArrayBuffer () { | |
this.readAsBinaryString.apply(this, arguments); | |
this.__defineGetter__('resultString', this.__lookupGetter__('result')); | |
this.__defineGetter__('result', function () { | |
var string = this.resultString; | |
var result = new Uint8Array(string.length); | |
for (var i = 0; i < string.length; i++) { | |
result[i] = string.charCodeAt(i); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var typedArrays = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array]; | |
if (window.Float64Array) { | |
typedArrays.push(Float64Array); | |
} | |
// fix for webkit pre slice rename | |
// https://bugs.webkit.org/show_bug.cgi?id=53618 | |
if (!Float32Array.prototype.subarray) { | |
typedArrays.forEach(function (cls) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ | |
function buildWaveHeader(opts) { | |
var numFrames = opts.numFrames; | |
var numChannels = opts.numChannels || 2; | |
var sampleRate = opts.sampleRate || 44100; | |
var bytesPerSample = opts.bytesPerSample || 2; | |
var blockAlign = numChannels * bytesPerSample; | |
var byteRate = sampleRate * blockAlign; | |
var dataSize = numFrames * blockAlign; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test for the Web Audio API <http://chromium.googlecode.com/svn/trunk/samples/audio/specification/specification.html> | |
Modernizr.addTest('webAudioApi', function () { | |
return !!(window.webkitAudioContext || window.AudioContext); | |
}); | |
// Test for the Audio Data API <https://wiki.mozilla.org/Audio_Data_API> | |
Modernizr.addTest('audioDataApi', function () { | |
return !!new Audio().mozSetup; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Analyze</title> | |
<script src="nest.js" type="text/javascript"></script> | |
</head> | |
<body> | |
<h1>Analyze</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Nest(api_key) { | |
this.api_key = api_key; | |
} | |
Nest.prototype = { | |
analyzeFile: function(file, type, options) { | |
var form = new FormData(); | |
form.append('api_key', this.api_key); | |
form.append('track', file); | |
form.append('filetype', type); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
import json | |
import sys | |
class RDQ(object): | |
def __init__(self, f): | |
self.f = f | |
self.read = f.read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- make a synchronous cross-domain request to The Echo Nest API --> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Echo Nest API Cross-Domain Example</title> | |
</head> | |
<body> | |
<h1>Echo Nest API Cross-Domain Example</h1> | |
<p><strong>Results:</strong></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh # ruby wants to see its name in the shebang | |
# valid python, ruby and bash | |
ignore=""" " | |
ignore=\ | |
=begin | |
unset ignore | |
echo only bash sees this | |
python $0 |