Author Topic: SCI Audio - how to set up a music on/off toggle  (Read 5808 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

SCI Audio - how to set up a music on/off toggle
« on: February 13, 2020, 08:20:02 AM »
This is mainly a question for Gumby, since he made the SCIAudio script. I was wondering a couple things:
1. How would I set up a volume toggle for the audio. Everything in the script (including volume) is set to -111, and that baffles me.

2. Assuming the volume can be toggled easily, could I do this without having to load the SCIAudio script at all times? Since the volume would be accesed via the menubar, would it be as easy as setting up a global variable and using that in the SCIAudio script?


Artificial Intelligence Competition

Offline Collector

Re: SCI Audio - how to set up a music on/off toggle
« Reply #1 on: February 14, 2020, 02:18:34 PM »
Perhaps store it as a global and every time you invoke an sciAudio script have the first thing the script does is to get the volume variable?
KQII Remake Pic

Offline gumby

Re: SCI Audio - how to set up a music on/off toggle
« Reply #2 on: February 15, 2020, 09:43:29 AM »
So volume can be a value from 0 to about 300.  If it's set to -111 that indicates to use the default of 100?  To retain the selected volume setting in-game between rooms/scripts, a global in main sounds right to me.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: SCI Audio - how to set up a music on/off toggle
« Reply #3 on: February 15, 2020, 02:04:00 PM »
So volume can be a value from 0 to about 300.  If it's set to -111 that indicates to use the default of 100?  To retain the selected volume setting in-game between rooms/scripts, a global in main sounds right to me.
Cool, got it. That explains the -111 I see all through the script.

I'm a little confused still. In the properties I see the following (In Studio Script, which I'm using for BA 1):
Code: [Select]
(class sciAudio
(properties
command -111
fileName -111
soundClass -111
volume 9000//-111
fadeInMillisecs -111
fadeOutMillisecs -111
loopFadeInMillisecs -111
loopFadeOutMillisecs -111
loopCount -111
conductorFile -111
playXFadeOutMillisecs -111  // used only for playx command
)
I've set Volume to -111, -1, 0, 300, 9000 and at no time did it make any difference to the sound volume. I'm assuming it's checked and set elsewhere also, but all I can find is:
(if(<> volume -111)
        
Code: [Select]
StrCat(@msgBuf "   volume ")
      StrCat(@msgBuf volume)
      StrCat(@msgBuf "\n")
   )
And I'm just not sure what this does.

Offline Collector

Re: SCI Audio - how to set up a music on/off toggle
« Reply #4 on: February 15, 2020, 04:00:57 PM »
I'm a little confused still. In the properties I see the following (In Studio Script, which I'm using for BA 1)

Have you considered converting to Sierra script? It would be a good excuse to familiarize yourself with it.
KQII Remake Pic

Offline Doan Sephim

Re: SCI Audio - how to set up a music on/off toggle
« Reply #5 on: February 15, 2020, 04:23:13 PM »
I'm a little confused still. In the properties I see the following (In Studio Script, which I'm using for BA 1)

Have you considered converting to Sierra script? It would be a good excuse to familiarize yourself with it.
I'm using Sierra Script for the follow-up, but this one was written in the old code and I don't want to go through the process of transcribing it again and then dealing with the compilation errors.

Offline gumby

Re: SCI Audio - how to set up a music on/off toggle
« Reply #6 on: February 17, 2020, 01:39:10 PM »
I took a look as to how I controlled volume in 120 Below.  Make sure your command looks something like this, note that you need quotes around the numerics:

Code: [Select]
         // Play the music
(send snd:
           command("playx")
           fileName("music\\snow.sciAudio")
           volume("10")
           loopCount("-1")
           init()
        )

When I fiddled with the volume and pumped it up to 200, I was able to hear that the volume increased.  For additional troubleshooting, verify that the COMMAND.CON file in the sciAudio folder looks something like this:

Code: [Select]
(sciAudio
   command stop
   soundClass noSoundClass
)
(sciAudio
   command play
   fileName "music\snow.sciAudio"
   soundClass noSoundClass
   volume 10
   loopCount -1
)
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: SCI Audio - how to set up a music on/off toggle
« Reply #7 on: February 17, 2020, 05:11:46 PM »
Thanks Gumby. By the looks of it, I will have to have the SCIAudio script at all times loaded to have a volume setting.

Also, when you do this change with playx, will that start the song over in order to adjust the volume?

Offline gumby

Re: SCI Audio - how to set up a music on/off toggle
« Reply #8 on: February 17, 2020, 06:33:41 PM »
For what I think you want (changing volume on-the-fly), try using the 'change' command which should allow you to adjust the volume of a currently playing sound file.  This should work:

Code: [Select]
(send snd:
   command("change")
   fileName("music\\snow.sciAudio")
   volume("50")
   init()
)
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: SCI Audio - how to set up a music on/off toggle
« Reply #9 on: February 17, 2020, 07:01:43 PM »
For what I think you want (changing volume on-the-fly), try using the 'change' command which should allow you to adjust the volume of a currently playing sound file.  This should work:

Code: [Select]
(send snd:
   command("change")
   fileName("music\\snow.sciAudio")
   volume("50")
   init()
)
Ah! Perfect. Now the only issue is the added heap to the rest of the game

Offline EricOakford

Re: SCI Audio - how to set up a music on/off toggle
« Reply #10 on: February 18, 2020, 09:37:42 AM »
I'm a little confused still. In the properties I see the following (In Studio Script, which I'm using for BA 1)

Have you considered converting to Sierra script? It would be a good excuse to familiarize yourself with it.
I'm using Sierra Script for the follow-up, but this one was written in the old code and I don't want to go through the process of transcribing it again and then dealing with the compilation errors.

Leave that to me. I've been working to convert the game to Sierra Script. I've already replaced the system scripts with those from my newer SCI0 template, and have moved the sciAudio, InitRooms, and Dying scripts into the 800 range (since they're not actually system scripts). Things like the custom window will have to be re-implemented into specific instances.
My SCI templates
SCI0 SCI0.1 SCI1.0 SCI1.1
SCI2.1 planned


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.047 seconds with 23 queries.