Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.41k stars 976 forks source link

How to get Waveform getValue() from a multichannel source? #921

Closed joex92 closed 3 years ago

joex92 commented 3 years ago

Hi, I've been testing the Tone.Waveform() object, but when using getValue() method I only get like 1 channel values... I'm trying to get the waveform values of Left and Right channels from a stereo source (Tone.Destination or Tone.Channel)...

How do I give a Waveform object only 1 channel from a stereo signal object?

joex92 commented 3 years ago

well, checked this comment in #588 and figured it out like this:

    master = new Tone.Channel({channelCount: 2});
    splitter = new Tone.Split(2);
    for (let w = 0; w < 2; w++){
      wave[w] = new Tone.Waveform(16);
    }
    for (let ch = 0; ch < 4; ch++){
      mixer[ch] = new Tone.Channel({channelCount: 2}).fan(Tone.Destination, master);
    }
    master.connect(splitter);
    splitter.connect(wave[0],0);
    splitter.connect(wave[1],1);

and it works as intended, I get each waveform values of each channel from the multichannel Tone.Channel obj...