[Solved] How does one properly use the "Tight" audio command?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
User avatar
FulminisIctus
Regular
Posts: 32
Joined: Sun May 21, 2017 1:30 pm
Projects: Mycorrhiza, LoveSick Darlings, Human Reignition Project, Episicava, Caladria Chronicles, Ah My Girlfriend is a Demon Summoned from the Depths of Hell, Cautionary Tale, Visual Novel Audio Pack Vol 1 and Vol 2
Contact:

[Solved] How does one properly use the "Tight" audio command?

#1 Post by FulminisIctus »

Ren'Py Tom replied to my question on Twitter and told me that tight is in fact not for making cross fades, so that clears up why it didn't work the way I wanted it to! From what I understood, it just makes sure that a looping sound still continues looping while it's being faded out, so it won't suddenly stop at the end of the track while it's still not fully faded out.
--------------------------------------------
According to the documentation the tight command should allow you to crossfade between two tracks (fading one out while another one fades in). I haven't been able to get it to work, though, unfortunately. There's no crossfade, the music either fades out and then the other one starts afterwards or the other music track cuts the first one off suddenly. I went through many different variations, from

Code: Select all

$ renpy.music.play('Dreams in Green.mp3', channel='music', loop=True, tight=True)
 "Test."
stop music fadeout 4.0
$ renpy.music.queue('Dreams in Blue.mp3', channel='music', loop=True, tight=True)
to

Code: Select all

$ renpy.music.play('Dreams in Green.mp3', channel='music', loop=True, tight=True)
"Test."
stop music fadeout 4.0
play 'Dreams in Blue.mp3'
Does anyone by any chance have any way of getting it to work? Maybe I'm also misunderstanding it and crossfading is not what the command does. Using two music channels for crossfading is of course an option as well, but I'd like to know how to use the tight command in case I ever need it.

Edit: renpytom answered my question on Twitter. "All tight does is keep the sound looping even after you stop it, which means that a fadeout will keep going even after it loops."
Last edited by FulminisIctus on Thu Oct 22, 2020 4:23 am, edited 2 times in total.

User avatar
Jackkel Dragon
Veteran
Posts: 283
Joined: Mon Mar 31, 2014 7:17 pm
Organization: Nightshade, Team Despair
itch: jackkel-dragon
Location: USA
Contact:

Re: How does one properly use the "Tight" audio command?

#2 Post by Jackkel Dragon »

When I swap between BGM tracks without silence between them, I usually do something like:

Code: Select all

play music <2nd track> fadein 1.0 fadeout 1.0
This should fade out the first track, then fade in the second.

Not sure if this helps directly, but it can at least cut down the number of commands you need for quick-swapping music tracks. I may have to look into crossfade myself...

Edit: Maybe this? (Guessing from how other Ren'Py commands work in similar situations.)

Code: Select all

play music <2nd track> fadein 1.0 fadeout 1.0 tight True
Main Website
Includes information about and links to many of my current and past projects.

Major Game Projects
[Nightshade] Eldritch Academy, Eldritch University, Blooming Nightshade, Flowering Nightshade, Life as Designed
[Team Despair] Corpse Party D2 series

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: How does one properly use the "Tight" audio command?

#3 Post by Imperf3kt »

Try adding multiple files to the one play statement using a list
[myfile.mp3, myfile2.mp3]
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
FulminisIctus
Regular
Posts: 32
Joined: Sun May 21, 2017 1:30 pm
Projects: Mycorrhiza, LoveSick Darlings, Human Reignition Project, Episicava, Caladria Chronicles, Ah My Girlfriend is a Demon Summoned from the Depths of Hell, Cautionary Tale, Visual Novel Audio Pack Vol 1 and Vol 2
Contact:

Re: How does one properly use the "Tight" audio command?

#4 Post by FulminisIctus »

Jackkel Dragon wrote: Tue Jul 07, 2020 3:01 pm When I swap between BGM tracks without silence between them, I usually do something like:

Code: Select all

play music <2nd track> fadein 1.0 fadeout 1.0
This should fade out the first track, then fade in the second.
This isn't quite what I'm looking for since I'm looking into crossfades specifically, but this is still a great way to cut down on code for non-crossfade tracks, thanks a lot for letting me know about this!
Jackkel Dragon wrote: Tue Jul 07, 2020 3:01 pm Maybe this? (Guessing from how other Ren'Py commands work in similar situations.)

Code: Select all

play music <2nd track> fadein 1.0 fadeout 1.0 tight True
I've tried this, but it unfortunately returns an error with the arrow pointing at the word "tight":
File "game/script/intro.rpy", line 13: could not parse statement.
play music "Dreams in Blue.mp3" fadein 1.0 fadeout 1.0 tight True

Imperf3kt wrote: Tue Jul 07, 2020 6:46 pm Try adding multiple files to the one play statement using a list
[myfile.mp3, myfile2.mp3]
Does this make the first track loop indefinitely until I let it proceed to the next item in the list? And how should I go about making it proceed to the next item in the list while still controlling the amount of fadeout and fadein? I unfortunately haven't had much experience with lists yet.
I'm a composer and sound designer! You can find more info about my services - and if I'm free to take on a job at the moment - by viewing my commission doc (https://docs.google.com/document/d/1i0Z ... sp=sharing)!

User avatar
Jackkel Dragon
Veteran
Posts: 283
Joined: Mon Mar 31, 2014 7:17 pm
Organization: Nightshade, Team Despair
itch: jackkel-dragon
Location: USA
Contact:

Re: How does one properly use the "Tight" audio command?

#5 Post by Jackkel Dragon »

Taking a closer look at the documentation, you may have to use the python command version of starting music (renpy.music.play) to use "tight", as far as I can tell. (Haven't taken the time to test it myself yet. Not sure how the base command could do it... Maybe "tight=True"?) So you'd have to have "loop" and "tight" set to be true in the track to be faded out when it first starts to play. Then, you make sure to use one command to start the next track (see below code block). I may have to look into to myself.

Code: Select all

play fadein fadeout ## one command, might work

stop fadeout ## two commands to swap tracks, we know this doesn't work
play fadein
Alternatively, you can use multiple audio channels to get around the "one track per channel" limitation. (The raw "audio" channel can have many files playing, but no ability to stop playing sounds mid-track.) After looking up some Ren'Py crossfade stuff, I found these:

http://sleepyagents.blogspot.com/2015/0 ... racks.html
https://pastebin.com/Cn7xMcu0

Basically, a summary:
Step 1: Start playing track #1 on one music channel.
Step 2A: Start playing track #2 on a second music channel.
Step 2B: Fade out the first music channel.

If there are no pauses or anything between the two parts of step 2, it will sound like a cross fade to the user (a delay in milliseconds).

The key here is that you need to define a second music channel, but that is in these links and the main documentation. So if you just need a cross fade, maybe try this method if the "tight" command continues to have no obvious effect.

Side note about multiple music channels: you may need to modify your settings screen if you use this method. Since the music is played on multiple tracks, you'll have to connect the music volume bar to all the related channels. It should be an easy change from a single entry to a (Python) list of entries, but I've not tested it myself yet.
Main Website
Includes information about and links to many of my current and past projects.

Major Game Projects
[Nightshade] Eldritch Academy, Eldritch University, Blooming Nightshade, Flowering Nightshade, Life as Designed
[Team Despair] Corpse Party D2 series

User avatar
FulminisIctus
Regular
Posts: 32
Joined: Sun May 21, 2017 1:30 pm
Projects: Mycorrhiza, LoveSick Darlings, Human Reignition Project, Episicava, Caladria Chronicles, Ah My Girlfriend is a Demon Summoned from the Depths of Hell, Cautionary Tale, Visual Novel Audio Pack Vol 1 and Vol 2
Contact:

Re: How does one properly use the "Tight" audio command?

#6 Post by FulminisIctus »

Thanks for your reply @Jackkel! I've tried different variations of the python command version, but unfortunately haven't gotten it to work yet, I'd appreciate it if you could let me know if you have more luck than me if you get around to trying it out!

And no worries, I already know about multiple channels and how to use them to crossfade tracks, as mentioned at the very end of the OP. I'd mainly like to know how the tight parameter works (it could turn out to be more convenient than two channels in some cases) since it's a mystery to me why it doesn't work at all.
As far as I know there's no need to modify the settings screen since you can assign a channel to a mixer when defining it.
I'm a composer and sound designer! You can find more info about my services - and if I'm free to take on a job at the moment - by viewing my commission doc (https://docs.google.com/document/d/1i0Z ... sp=sharing)!

Post Reply

Who is online

Users browsing this forum: No registered users