0

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.

  • You wish to play wma audio in a web browser? It sounds like you want html – Evan Benn Jun 06 '19 at 01:07
  • How do I get the frequency of audio at currentTime? I think that would help move a sound file to an array of frequencies – John Porter Jun 06 '19 at 04:25
  • I don't know why you want to convert WMA audio into frequencies, then synthesise them with an oscillator. You can just use the browser to play the wma file directly. If you do want to synthesise you need to perform an FFT. But beware, your current approach can only produce monophonic audio (1980s style). – Evan Benn Jun 07 '19 at 00:39
  • A mid file maybe – John Porter Apr 04 '21 at 21:17

0 Answers0