Author Topic: Using Gumby's sciAudio script and avoiding Heap Issues  (Read 2531 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

Using Gumby's sciAudio script and avoiding Heap Issues
« 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 ;)


Artificial Intelligence Competition

Offline Collector

Re: Using Gumby's sciAudio script and avoiding Heap Issues
« Reply #1 on: December 03, 2013, 11:24:59 PM »
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?
KQII Remake Pic

Offline gumby

Re: Using Gumby's sciAudio script and avoiding Heap Issues
« Reply #2 on: December 04, 2013, 09:59:03 AM »
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.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Collector

Re: Using Gumby's sciAudio script and avoiding Heap Issues
« Reply #3 on: December 04, 2013, 11:48:10 AM »
Can it be unloaded after sending the command to be able to get some heap back?
KQII Remake Pic

Offline Doan Sephim

Re: Using Gumby's sciAudio script and avoiding Heap Issues
« Reply #4 on: December 04, 2013, 12:31:11 PM »
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.

Offline gumby

Re: Using Gumby's sciAudio script and avoiding Heap Issues
« Reply #5 on: December 04, 2013, 01:11:06 PM »
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. 
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Collector

Re: Using Gumby's sciAudio script and avoiding Heap Issues
« Reply #6 on: December 04, 2013, 02:05:11 PM »
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.
KQII Remake Pic


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.094 seconds with 23 queries.