Skip to content

Change Voice.Volume to be a persistent volume for the Voice itself. Fix #2976#2978

Merged
Dunbaratu merged 1 commit intoKSP-KOS:developfrom
CodeLeopard:Persistent-SKID-Voice-Volume-2976
Jul 16, 2021
Merged

Change Voice.Volume to be a persistent volume for the Voice itself. Fix #2976#2978
Dunbaratu merged 1 commit intoKSP-KOS:developfrom
CodeLeopard:Persistent-SKID-Voice-Volume-2976

Conversation

@CodeLeopard
Copy link
Contributor

Voice.Volume is now independent of the currently playing Note's volume.
This is done by adding a private variable to hold the volume as it was specified by the sound or note being played, leaving Voice.Volume to be the volume for the Voice itself.
Both volume values are multiplied together to get the final volume for the sound.

Fixes #2976

Example script:

Local v0 to GetVoice(0).
Set v0:loop to False.

Local softNote is Note(440, 1, 1, 0.5).
Local loudNote is Note(440, 1, 1, 1).

Local Function PlayNotes
{
	Print("Playing soft note...").
	v0:Play(softNote).
	wait softNote:duration.
	Print("Voice volume is now: " + v0:Volume).

	Print("Playing loud note...").
	v0:Play(loudNote).
	wait loudNote:duration.
	Print("Voice volume is now: " + v0:Volume).
}

Until false {
	Set v0:volume to 1.
	Print("Set Voice:Volume to: " + v0:Volume).

	PlayNotes().

	set v0:volume to 0.5.
	Print("Set Voice:Volume to: " + v0:Volume).

	PlayNotes().

	wait 0.5.
}

@Dunbaratu Dunbaratu merged commit 8e5b5ec into KSP-KOS:develop Jul 16, 2021
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

Successfully merging this pull request may close these issues.

SKID voice volume is always clobbered by PLAY, making it meaningless.

2 participants