Created
October 20, 2017 13:31
-
-
Save diversen/d85f77638221455adbd4235c74e8d4c9 to your computer and use it in GitHub Desktop.
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
var samplePromise = require('get-audio-sample-promise'); | |
var rand = require('random-float'); | |
var waveSurfer = require('wavesurfer.js') | |
// let [foo, bar] = await Promise.all([getFoo(), getBar()]); | |
// let audiobuf = await samplePromise(ctx, 'raven.mp3'); | |
function randomDoubleFromInterval(min, max){ | |
return Math.random()*(max-min); | |
} | |
let promise = samplePromise(ctx, 'raven.mp3').then(function(instrument){ | |
// console.log('loaded'); | |
// Promise success. You have a simple audioBufferInstrument | |
// Which you can get and connect | |
var audioBuf = instrument.get(); | |
console.log(audioBuf); | |
var length = audioBuf.buffer.duration; | |
console.log(length); | |
var random = rand(0, length); | |
console.log(random); | |
//audioBuf.connect(ctx.destination); | |
// audioBuf.start(2); | |
}).catch(function(err){ | |
console.log(err) | |
}); | |
var wavesurfer = WaveSurfer.create({ | |
container: '#waveform' | |
}); | |
wavesurfer.load('http://ia902606.us.archive.org/35/items/shortpoetry_047_librivox/song_cjrg_teasdale_64kb.mp3'); | |
wavesurfer.on('ready', function () { | |
// wavesurfer.play(); | |
console.log('ok'); | |
}); | |
wavesurfer.on('audioprocess', function (e) { | |
// console.log(e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment