Make filters easier to use and pitchshift filter
Description
Removed the main example which was too much complicate for a first approach. In the futere I'll make a new GitHub repository with that. For now there are 2 little example:
- a metronome
- a filter use case
Added pitch shift filter to somehow resolve #98.
This filter has these parameters:
shift: a value of 0.5 means one octave down (12 semitones down), a value of 2.0 means one octave up (12 semitones up).semitones: increases or decrease using semitones (ยน/12 of an octave).
This filter can be used in conjunction with SoLoud.setRelativePlaySpeed() to for example play a sound with voices at double speed without changing the tone speech.
The filters can now be used for single sounds instead of using them only globally.
IMPORTANT: filters for individual sounds are not supported on the web platform. On the other platforms the filter must be added before playing. Only voice handles played after adding the filter will play with the filter chosen.
Filters can now be accessed globally using SoLoud.instance.filters or for single [AudioSource] sounds with sound.filters to resolve #108. With something like:
/// For global filters.
final ps = SoLoud.instance.filters.pitchShiftFilter;
ps.activate();
ps.shift(soundHandle: soundHandle).value = 0.6; // set value.
final shift = ps.shift(soundHandle: soundHandle).value; // get value.
ps.fadeFilterParameter(to: 3, time: const Duration(milliseconds: 2500));
ps.oscillateFilterParameter(from: 0.5 to: 1.5, time: const Duration(milliseconds: 2500));
ps.queryShift.[min | max | def] // to get filter min, max and default values.
/// For single sound filters.
final ps = sound.filters.pitchShiftFilter;
[as for global]
Look at the respective documentation to see how to use them.
Type of Change
- [x] โจ New feature (non-breaking change which adds functionality)
- [ ] ๐ ๏ธ Bug fix (non-breaking change which fixes an issue)
- [ ] โ Breaking change (fix or feature that would cause existing functionality to change)
- [x] ๐งน Code refactor
- [ ] โ Build configuration change
- [ ] ๐ Documentation
- [ ] ๐๏ธ Chore
For this PR we should think about the version to choose, the check fails on CHANGELOG.md which doesn't have it. On pub.dev this plugin has not been updated to the main branch since PR 85 so we may think of releasing 2.1.0 or a major 3.0 since the news are important.
For this review, regarding the new filters' way to manage them, in the filters dir there are 10 source files for the same number of filters. These sources differ only in their different parameter count and names, so looking only at one will be enough I think.
filters/filters.dart is the source for managing those filters. There is a FiltersSingle class which is instantiated as AudioSource.filters class and a FilterGlobal class which is instantiated as SoLoud.filters.
update: I have fixed the CHANGELOG just to see if this PR is mergeable
LGTM! Thanks!
Also verified the examples on macOS. Love the new tests/tests.dart test app, btw!