-
Notifications
You must be signed in to change notification settings - Fork 23
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
docs: How to play same short sound multiple time (concurrent) with different pitch? #155
Comments
Hi @dvmatyun, sorry for the late reply! A filter can be applied only once to a sound, so the best way I can see is to duplicate the audio file and load them into separate You can do something like this: /// Load all the sounds
sound1 = await soLoud.loadAsset('assets/audio/tic-1.wav');
sound2 = await soLoud.loadAsset('assets/audio/tic-2.wav');
sound1!.filters.pitchShiftFilter.activate();
sound2!.filters.pitchShiftFilter.activate(); then call a method like this and pass the Future<void> playWithPitchShift(AudioSource source, double value) async {
source.filters.pitchShiftFilter.shift(soundHandle: handle).value = value;
final handle = await soLoud.play(source);
} |
@alnitak thanks you for the reply. I guess I can load file into memory (by reading it from assets) and create 2 Soloud instances with same in-memory file (list of bytes I guess?) ? Or that is not possible / won't work? |
Nope, you can't create more instances of My best solution is to duplicate the audio files to apply different filters to them. I know this could be a problem if the files are taking up much memory, but for now it is the only solution I think. I'd leave this open, maybe in the near future I will think of a solution! Maybe in something like force to load an already loaded sound into a new AudioSource parameter somewhere. |
@alnitak to be honest this is not what I was meaning. So I was suggesting following:
Not sure if this will work, that is just the first thought that came to me. PS I just know that in "Unreal Engine" for example you are using single file and can apply different pitch to it each call - to make "attack" sound for example to sound a little bit different. |
Got it! Yes it is possible to use loadMem for this purpose:
Doing so you will have the same sound in both I'll leave this open because I think there could be a better way to manage this kind of thing, but if you have more thoughts please let me know. |
@alnitak Nope, just want to say it would be cool (if it's possible) to apply pitch to sound without any kind of manipulations, something like:
But I guess there might be some platform limitations for that. Anyway, this is by far the best library to play sounds in flutter I have found. Others just either throw errors, or play sound with huge delay or have other kind of problems. This issue is not a big problem for me, so thank you for your help! |
Thanks for your kind words, appreciate it!
You are correct, this plugin is heavily based on the SoLoud c++ lib, but can be improved with the help of people like you! |
Description
In gamedev some short sound effects (hit sound for example) need to be played in parallel with different pitch (to not sound exactly the same). What is correct approach to do this in Flutter Soloud?
Requirements
The text was updated successfully, but these errors were encountered: