Reputation: 51
I am recording sounds for a game on my computer, but I am only able to use the audio context to play sounds. I cannot download audio from a server, so how do I convert WMA to a playable array with audio context.
It is easy to record audio on my computer and play it back with Windows Media Player. I have set up some code for playing frequencies with different timing. But I cannot move the sound from my computer to my website.
This is what I use to play some climbing notes
<html>
<head>
<meta charset="utf-8">
<title>head ache</title>
</head>
<body>
<script>
var notes = [];
for(var i = 0; i < 8; i ++){
notes.push([i*25+80,i/2,0.5])
}
for(var i = 0; i < 8; i ++){
notes.push([i*25+100,i/2+4,0.5])
}
for(var i = 0; i < 8; i ++){
notes.push([-i*25+425,i/2+8,0.5])
}
var play = 1;
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
if(play){
for(var i = notes.length; i --;){
if(notes[i].length<3){continue;}
var oscillator = audioCtx.createOscillator();
oscillator.type = 'sawtooth';
oscillator.frequency.setValueAtTime(notes[i][0], audioCtx.currentTime);
oscillator.connect(audioCtx.destination);
oscillator.start(notes[i][1]);
oscillator.stop(notes[i][1]+notes[i][2])
}
}
</script>
</body>
</html>
I am unable to move the file from my computer to my website. I should be able to play the noises when I am able to get the frequencies and durations of the WMA file.
Upvotes: 0
Views: 251