• Set volume for wave playup

    From =?UTF-8?Q?Jonas_Th=C3=B6rnvall?=@21:1/5 to All on Tue Dec 21 16:32:18 2021
    Could someone explain for me howto set volume on the played audio.
    I do not speak monkey gibberish.

    /* Here is some unintelligble syntax to decipher......
    // Create a gain node.
    var gainNode = audiostream.createGain();
    // Connect the source to the gain node.
    source.connect(gainNode);
    // Connect the gain node to the destination. gainNode.connect(audiostream.destination);
    */ Yeah what the fuck is source and destination....

    // Code below works and play up the audiostream of the URL
    const audiostream = new AudioContext();

    async function audioPlay(url){
    const audioBuffer = await fetch(url)
    .then(res => res.arrayBuffer())
    .then(ArrayBuffer => audiostream.decodeAudioData(ArrayBuffer));
    const playwav = audiostream.createBufferSource();
    playwav.buffer = audioBuffer;
    playwav.connect(audiostream.destination);
    playwav.start();
    };

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From luserdroog@21:1/5 to jonas.t...@gmail.com on Tue Dec 21 22:08:42 2021
    On Tuesday, December 21, 2021 at 6:32:23 PM UTC-6, jonas.t...@gmail.com wrote:
    Could someone explain for me howto set volume on the played audio.
    I do not speak monkey gibberish.

    /* Here is some unintelligble syntax to decipher......
    // Create a gain node.
    var gainNode = audiostream.createGain();
    // Connect the source to the gain node.
    source.connect(gainNode);
    // Connect the gain node to the destination. gainNode.connect(audiostream.destination);
    */ Yeah what the fuck is source and destination....


    I think you're just frustrated. The answer is right under your nose.
    // Code below works and play up the audiostream of the URL
    const audiostream = new AudioContext();

    async function audioPlay(url){
    const audioBuffer = await fetch(url)
    .then(res => res.arrayBuffer())
    .then(ArrayBuffer => audiostream.decodeAudioData(ArrayBuffer));
    const playwav = audiostream.createBufferSource();
    playwav.buffer = audioBuffer;
    playwav.connect(audiostream.destination);

    ^^^ Right here ^^^

    Bust up that call to playwav.connect() and put your gain node in the middle there.
    "playwav" is your "source". And "audiostream.destination" is already literally in
    the example.

    playwav.start();
    };

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)