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

feat: Initial configuration for an AudioSource #165

Open
1 task
te8uekm12 opened this issue Jan 3, 2025 · 2 comments
Open
1 task

feat: Initial configuration for an AudioSource #165

te8uekm12 opened this issue Jan 3, 2025 · 2 comments

Comments

@te8uekm12
Copy link

te8uekm12 commented Jan 3, 2025

Description

It would be convenient if the AudioSource supported the ability to perform an initial setup, so that all required properties, such as the equalizerFilter and other filters, could be configured immediately after loading. This would simplify the use of the AudioSource API, as the creation and configuration of the sound could be encapsulated in a single initialization phase.

Here is simple example:

  final Map<String,AudioSource> cache= {};

 Future<void> initializeGameAudioPhase() async{
  
   final audioSource1 = await SoLoud.instance.loadAsset('assets/audio/IveSeenThings.mp3');
   audioSource1.filters.equalizerFilter.activate();
   audioSource1.filters.equalizerFilter.band1().value=1;
   audioSource1.filters.equalizerFilter.band2().value=3;

   audioSource1.filters.bassBoostFilter.activate();
   audioSource1.filters.bassBoostFilter.boost().value=2;
   
   final audioSource2 = await SoLoud.instance.loadAsset('assets/audio/8_bit_mentality.mp3');
   audioSource2.filters.equalizerFilter.activate();
   audioSource2.filters.equalizerFilter.band3().value=3;
   audioSource2.filters.equalizerFilter.band4().value=2;

   audioSource2.filters.echoFilter.activate();
   audioSource2.filters.echoFilter.decay().value=1;
   

   cache['audioSource1']=audioSource1;
   cache['audioSource1']=audioSource2;
 }
 

 Future<void> play(String cacheKey) async {
   
    await SoLoud.instance.play(cache[cacheKey]!, looping: true);
 }

Requirements

  • Checklist of requirements to be fulfilled

Additional Context

Add any other context or screenshots about the feature request go here.

@alnitak
Copy link
Owner

alnitak commented Jan 3, 2025

Do you mean that could be convenient to set parameters before playing and get back the SoundHandle to pass for example to band(soundHandle: newHandle)? Yes, that is a doubt I got in the other issue. I must see if it is feasible because the SoLoud C++ lib needs the handle to set a parameter and this is because you can set a parameter value to a plying sound (handle) and another one to another handle of the same AudioSource.

Better for now if you make your own AudioSource manager to play and set the desired effects, ie: final Map<String, MyAudioSourceManager> cache= {};

I'll leave this issue open for further investigation, thanks.

@te8uekm12
Copy link
Author

It would be convenient to set filters for the AudioSource during application initialization, allowing the use of preconfigured sounds later without needing to return to the configuration phase.

The band(soundHandle: newHandle) function could remain as it is -> the modification of parameters for a specific playback of an AudioSource.

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

No branches or pull requests

2 participants