Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make filters easier to use and pitchshift filter #110

Merged
merged 31 commits into from
Aug 23, 2024
Merged

Make filters easier to use and pitchshift filter #110

merged 31 commits into from
Aug 23, 2024

Conversation

alnitak
Copy link
Owner

@alnitak alnitak commented Jul 29, 2024

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

  • ✨ 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)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@alnitak alnitak changed the title chore Make filters easier to use and pitchshift filter Jul 29, 2024
@alnitak
Copy link
Owner Author

alnitak commented Jul 29, 2024

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

@alnitak alnitak marked this pull request as ready for review August 6, 2024 17:37
@alnitak alnitak mentioned this pull request Aug 6, 2024
@alnitak alnitak requested a review from filiph August 23, 2024 05:39
@filiph
Copy link
Collaborator

filiph commented Aug 23, 2024

LGTM! Thanks!

@filiph
Copy link
Collaborator

filiph commented Aug 23, 2024

Also verified the examples on macOS. Love the new tests/tests.dart test app, btw!

@filiph filiph merged commit a13c85f into main Aug 23, 2024
1 check passed
@alnitak alnitak deleted the pitch branch August 28, 2024 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: make filters easier to use feat: set relative speed without changing the pitch
2 participants