Tonejs / Tone.js

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

LFO has no effect on iOS #1225

Closed MartinTremblay closed 2 months ago

MartinTremblay commented 5 months ago

The LFO don't seem to have any effect on iOS.

This code works on desktop and android, but the oscillator is unchanged on iOS.

    let lfo;
    let osc;

    document.addEventListener("click", () =>
    {
        let options = { frequency: 1, min: 0, max: 4, amplitude: 1};
        lfo = new Tone.LFO(options).start().toDestination();
        osc = new Tone.Oscillator(440, "sine").toDestination().start();
    });
tambien commented 2 months ago

the LFO is going to be too low for you to hear (1hz) and it's connected directly to the speaker (toDestination()), try instead to connect the LFO to the oscillators detune or gain or some attribute that you want to modify with the LFO.

MartinTremblay commented 2 months ago

No I mean, the problem only occurs on iOS.

On other device (windows, android), we can hear a pulse with this code, but no on iOs. The value of the frequency doesn't really matter.

https://codesandbox.io/p/sandbox/tonejs-forked-y8r9ln?file=%2Fsrc%2Findex.js%3A6%2C1

chrisguttandin commented 2 months ago

Hi @MartinTremblay, I think what you're experiencing is the limiter or the absence of it in various browsers. It sounds the same everywhere when reducing the volume with a Gain.

https://stackblitz.com/edit/vitejs-vite-zslwp4?file=src%2Fmain.ts

MartinTremblay commented 2 months ago

Okay, but using straight AudioApi I can replicate the same effect on iOS.

https://codesandbox.io/p/sandbox/tonejs-forked-8dk3tv?file=%2Fsrc%2Findex.js%3A13%2C19

chrisguttandin commented 2 months ago

That's what I was trying to say with the comment above. It's not specified what the browser should do with a value outside of the range [-1, 1].

As far as I know Firefox and Safari do nothing and let the operating system decide what to do. Chrome has a limiter.