-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fade at the End #24
Comments
I'm not a contributor, but the feature you requested is not built in, as far as I know. You could try something like this: import threading
import time
from just_playback import Playback
class PlaybackFadeable(Playback):
def _fade(self, start_fade, init_vol, dest_vol):
self.set_volume(init_vol)
while True:
if not self.active:
break
secs_remaining = self.duration - self.curr_pos
if secs_remaining < start_fade:
self.set_volume( # simple linear fade
(init_vol - dest_vol) * secs_remaining / start_fade
+ dest_vol
)
time.sleep(0.1) # might not need this, IDK
self.set_volume(init_vol)
def play(self, start_fade=2, init_vol=1, dest_vol=0):
super().play()
p = threading.Thread(
target=self._fade,
args=(start_fade, init_vol, dest_vol),
daemon=True,
)
p.start()
playback = PlaybackFadeable()
playback.load_file("some audio file.wav")
playback.play(start_fade=2, init_vol=1, dest_vol=0) # fade from full volume to silence, starting 2 seconds before the end |
This helps me a lot, thank you. I had the same idea but didn't deal with the module enough. |
Hi everyone, Support for fading in/out would be great to have in the next release. Any ideas on how the API could look like ?? |
How about having them as (probably keyword-only) arguments in the |
Is there a way to fade the music out at the end of the file like in Pygame Mixer. And if there's no way is it possible for you to code it? Otherwise i can try on my own, but i think it would be faster if you do it.
Btw i'm a big fan of this module, i searched for sth like this for like 2 days and then i found this.
Thanks in advance,
Johannes
The text was updated successfully, but these errors were encountered: