alnitak / flutter_soloud

Flutter low-level audio plugin using SoLoud C++ library and FFI
MIT License
156 stars 15 forks source link

feat: Deprecate waveforms #97

Open filiph opened 2 weeks ago

filiph commented 2 weeks ago

Description

I think we might consider trying to drop support for generating waveforms. I think most game and app development will exclusively use samples. Even music playing apps and sequencers will, at some point, use samples, even if very short ones — unless they go all in with signal processing. But we can't compete with signal-processing audio engines.

My point is that there's a lot of code in player.cpp and elsewhere that supports a feature that I don't think anyone is using in production. That code needs to be maintained, reviewed, etc.

Requirements

filiph commented 2 weeks ago

If there are other features like waveforms that are unlikely to be used by apps and games, and that have non-trivial amount of code (e.g. more than 5-10 lines), please add them here.

We want flutter_soloud to be easily maintainable for the long run.

sbauly commented 2 weeks ago

I don't think anyone is using in production

I am!

I’d have to respectfully disagree here. The waveform features in SoLoud are great, fairly lightweight and offer some unique possibilities not readily accessible in other flutter packages out there currently.

I sincerely hope that they remain in this package as I, and I'm sure others using this package, have found them very useful. I’m happy to help contribute to their maintenance in any way I can.

filiph commented 2 weeks ago

Thanks for the reply! And especially for offering help with maintenance — that's rare to see.

May I ask what your exact use case is?

sbauly commented 2 weeks ago

Sure! The app primarily makes use of SoLoud’s 3D audio features and lets users generate different waveforms (like binaural beats), update their frequencies, move them around a 3D space and add effects such as reverb .etc.

Generating the waveforms, as opposed to using samples, is important so users can alter the frequencies on the fly.

I’d previously been using the sound_generator package for waveform generation, but it was much more limited and no longer maintained. Technically… the app is not in production yet, otherwise I’d happily share it here - but almost there with it now.

ekuleshov commented 1 week ago

I am also considering to switch to waveforms from samples, but struggling to find a good example of generating and playing basic sine wave.

sbauly commented 1 week ago

Admittedly, there’s not a super clear-cut example in the example app right now, but maybe this can help, @ekuleshov

/// Initialize SoLoud
await SoLoud.instance.init();

/// Setup an AudioSource and SoundHandle for the waveform
AudioSource? _waveform;
SoundHandle? _waveHandle;

/// Load a sine wave
_waveform = await SoLoud.instance.loadWaveform(
        WaveForm.sin,
        false,
        1,
        1,
      );

/// Play the sine wave
_waveHandle = await SoLoud.instance.play(
          _waveform!,
        );

/// Set a new frequency for the waveform .etc
SoLoud.instance.setWaveformFreq(_waveform, 432);

For the additional controls, soloud.dart has pretty good documentation, so definitely check that out to understand the other loadWaveform() parameters .etc. Hope that helps!

lukepighetti commented 1 day ago

Actually I want to also push back on deprecating wave forms. I've been looking for a way to play waveforms in flutter for many years now and was grateful to find this issue which happens to explain how to achieve it in flutter_soloud