Community
SCI Programming => SCI Community How To's & Tutorials => Topic started by: Doan Sephim on December 03, 2013, 10:47:16 PM
-
Gumby has supplied a really awesome sound script that not only allows for multiple sounds at once (something we couldn't do before), but also allows mp3s opening up a whole new scope to sound in sci games.
While I will be sticking with midi-music for Betrayed Alliance, I will be using sciAudio to play it for many reasons (mainly I had constant sound issues before). As I began coding in the music I noticed that Gumby's sound script was substantially larger than the sound script that comes with the program and some of my rooms could not support any additional heap load.
Luckily for me there is a workaround. I often set up a blank room with little more than a Print command as an introduction. These rooms are small in size and allow me to play the sciAudio music in the last cycle before switching the room. The effect is rather seemless.
For the seasoned coders out there this may not be necessary, but for amateurs like me who only learned to code specifically to make an SCI game, it may be a helpful trick ;)
-
Is there a way to unload the sciAudio script after it is used? Since the only thing that it is doing is writing a file and all of the sound handling is being done out side of the game, it shouldn't only add to heap if invoked?
-
Yeah, that is a beefy script (3.07K vs. the sound.sc script which is 0.42K). The main memory hog is the 1000 character 'message buffer' array that I set up which sends the commands over to the external executable.
Admittedly, 1000 characters is probably overkill and I might be able to do it without specifying a statically-sized array. But it should be safe to lower the size of the array - looking at a typical string length of the sound command is about 100 characters. Could probably safely lower that from 1000 to 250 and save a little on the heap.
-
Can it be unloaded after sending the command to be able to get some heap back?
-
It added it to the list of files scripts that gets unloaded whenever a room change happens. It works the same as any other script.
-
Can it be unloaded after sending the command to be able to get some heap back?
Possibly, but we might run into issues if there are multiple calls to the sciAudio script within the same room.
-
Too bad that SCI does not allow you to instantiate new elements. This may be a little moot as I assume that much of a room's heap would be assigned on load, so regaining space later on might not gain you much.
I need to become more familiar with Studio/Companion's scripting, especially about heap and hunk management. Too bad Studio/Companion's scripting has no garbage collector the way managed code does.