Could someone please assist me with setting up background music for my Ren'Py game?
In my game, I require background music that transitions smoothly between tracks. The music setup entails playing a song and seamlessly transitioning to the next song (cross-fade) before the current one ends. The next song should be randomly selected from a pool of available songs. I aim to establish the background music logic to operate autonomously in the background without requiring constant intervention. This means the cross-fade to the next song should occur automatically and independently from the ongoing events in the game.
Do you have any tips or strategies for accomplishing my goals? Thanks in advance for any assistance!
Endless Random Background Music with Seamless Cross-Fade
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Re: Endless Random Background Music with Seamless Cross-Fade
I stumbled upon a code snippet for random sound playback in Ren'Py in viewtopic.php?p=453546#p453546.
However, I've encountered an unexpected hiccup: audio stuttering, particularly noticeable when dealing with larger sound files.
As it stands, due to the severe audio stuttering issue, Ren'Py proves ineffective for my project goals. Is this a known issue?
However, I've encountered an unexpected hiccup: audio stuttering, particularly noticeable when dealing with larger sound files.
As it stands, due to the severe audio stuttering issue, Ren'Py proves ineffective for my project goals. Is this a known issue?
Code: Select all
define sounds = ['sounds/explosion.wav', 'sounds/glass.wav', 'sounds/shot.wav']
init python:
def s_callback():
if s_callback.queue_silence:
silence = "<silence {0}>".format(renpy.random.random() * 2 + 0.5)
renpy.sound.queue(silence)
else:
renpy.sound.set_volume(renpy.random.random())
renpy.sound.queue(renpy.random.choice(sounds))
s_callback.queue_silence = not s_callback.queue_silence
s_callback.queue_silence = False
renpy.sound.set_queue_empty_callback(s_callback)
label start:
"Just sit here and listen to the sounds"
return
Re: Endless Random Background Music with Seamless Cross-Fade
I attach a recording of the audio stuttering for reference. The audio stuttering becomes more noticeable, especially during the third sound, the explosion.
- Attachments
-
- stuttering.zip
- (2.77 MiB) Downloaded 4 times
Re: Endless Random Background Music with Seamless Cross-Fade
The code below does not stutter.
I couldn't tell you why my version seems to function differently, but it's curious that I didn't even require the original "silence generator" in the process.
Now, onto the realm of randomness, as I tackle the task of infusing some unpredictability into the song selector.
Code: Select all
init python:
sounds = ["audio_split_p48/part{}.wav".format(i) for i in range(1, 48)]
init python:
def s_callback():
renpy.sound.queue(renpy.random.choice(sounds))
renpy.sound.set_queue_empty_callback(s_callback)
label start:
"Just sit here and listen to the sounds"
return
Now, onto the realm of randomness, as I tackle the task of infusing some unpredictability into the song selector.
Who is online
Users browsing this forum: No registered users