Author Topic: sciAudio - a new way to put sound in your games!  (Read 61884 times)

0 Members and 1 Guest are viewing this topic.

Offline gumby

sciAudio - a new way to put sound in your games!
« on: October 20, 2012, 02:35:21 PM »
sciAudio is here!  Check out the "LockerGnome Quest Redux" demo game to see it in action!

-------------------------------
 Features
-------------------------------
- Playback of WAV and MP3 files
- Unlimited number of sounds playing simultaneously
- Fade in/out, looping and volume control
- Classification of sounds for playback management
- Multiple commands may be issued simultaneously to the 'controller' file
- Multiple controller files to avoid resource contention
- Runs hidden in background & will terminate itself shortly upon game close
- Calls to sciAudio are performed very similarly to the built-in SCI sound calls
- Poor man's encryption (MP3's only) - simply rename your .MP3 to be .sciAudio
- Log file for troubleshooting sound playback ('sciAudio.log' located in same directory as sciAudio.exe)

-------------------------------
 Limitations
-------------------------------
 Works only in Windows (requires .NET framework)

-------------------------------
 Setup
-------------------------------
1) Place the 2 nAudio DLLs & executable into a subfolder within your game named 'sciAudio'
2) Create subfolders within sciAudio for your playback files.  Something like this
       <gamedir>\sciAudio\effects
       <gamedir>\sciAudio\music
3) Include the sciAudio.sc script & 'use' it in any script you wish to have sciAudio playback in
     
-------------------------------
 Available commands
-------------------------------
   command <playback command>
      play
        Begins playback of a sound

      stop
        Stops playback of a sound

      change
        Changes playback of a sound.  Used primarily for volume & loop control, very limited usefulness.

      playx (play exclusively based on sound class)
        This behaves just like the 'play' command, but will stop any currently playing sounds with
        the same sound class as the specified class.   
         
   fileName
       Filename to playback, including the path.
      
   soundClass
       Sound class to assign this sound.  This is simply a string to assign to the playback
      for the purpose of potentially changing or terminating all sounds with the same
      sound class at a later time.
   
       For example, you might have several sound effects playing simultaneously in a room.
      Upon leaving the room, you want to stop all the sound effects.  To to this you would
      issue a stop <soundclass> command, which would stop all currently playing sounds with
      the specified sound class.
      
      If no sound class is specified, a default sound class of "noClass" will be used
   
   volume
      Playback volume of sample.  Default is 100 (100% volume of sample).  Range: 0 to ~300?
      
   fadeInMillisecs
       Number of milliseconds to fade in the sample
      
   fadeOutMillisecs
       Number of milliseconds to fade out a sample.  Can be issued with a play or stop command
      
   loopFadeInMillisecs
       Number of milliseconds to fade in a sample between loops.  
      
   loopFadeOutMillisecs
       Number of milliseconds to fade out a sample between loops.
      
   loopCount
       Number of times to loop the sample.  Default is 0, -1 is infinite
      
   conductorFile
       'Conductor' file name used to place commands into.  This is how commands are passed between
      the SCI virtual machine & the sciAudio application.  The sciAudio application constantly polls all
      conductor files, looking for changes & executes them.  These files must have extension of .con.
      
      The default value for this parameter is command.con.
      
      Utilization of this parameter is useful in the event you have many near-simultaneous playback
      commands issued from within your game.  Multiple different conductor files can mitigate the
      issue of potential file contention of just using a single file.  Most game developers will
      probably not need to use this option.

   
   playXFadeOutMillisecs
       Only used for the 'playx' command.  Upon terminating any currently playing sounds for a
      sound class, this value will be used for the fade out.

-------------------------------
 Examples
-------------------------------
(use "sciAudio")

(local
    snd
)

(instance aud of sciAudio
   (properties)
   (method (init)
      (super:init())
   )
)

...

= snd aud

// basic playback
(send snd:
   command("play")
   fileName("effects\\score.sciAudio")   // important: note the two backslashes in path name!
   volume("35")
   loopCount("0")
   fadeInMillisecs("3000")   // fade in beginning by 3 secs
   fadeOutMillisecs("2000")  // fade out ending by 2 secs
   init()
)

// looping playback example
(send snd:
    command("play")
    fileName("effects\\loopedSound.sciAudio")
    volume("100")
    loopFadeInMillisecs("2000")
    loopFadeOutMillisecs("2000")
    loopCount("-1")  // loop forever
    init()
)

// stop with 5 second fade out
(send snd:
   command("stop")
   fileName("music\\introMusic.sciAudio")
   fadeOutMillisecs("5000")
   loopCount("0")
   init()
)

// change currently playing volume for a sound class
(send snd:
   command("change")
   soundClass("myMusicSoundClass")
   volume("50")   // set playback to 50% volume
   init()
)

// stop looping a particular sound file
(send snd:
   command("change")
   soundClass("music\\introMusic.sciAudio")
   loopCount("0")  // stop looping
   init()
)

// exclusive playback (starts new playback of sound
// & stops any already playing sounds (with fadeout) for same soundClass
(send snd:
   command("playx")
   soundClass("narration")
   conductorFile("speech\\narrate.con")
   fileName("speech\\newNarration.sciAudio")
   playXFadeOutMillisecs("1500") // will fade currently playing "narration" sound class sounds
   volume("200")
   init()
)

-------------------------------
 Notes
-------------------------------
If you decide to re-use the same sound instance for multiple sounds, it's up to you
to reset any previously specified properties, otherwise they will be carried over
into the next command

Use the sciAudio.log file (located in the same directory as executable) for troubleshooting sound playback.
« Last Edit: October 21, 2012, 10:05:27 AM by gumby »


In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: sciAudio - a new way to put sound in your games!
« Reply #1 on: October 20, 2012, 04:37:22 PM »
This is very welcome news! I've been having problems with sound before. This may be the solution. I'm gonna go check it out in locker gnome.

Thanks!

WOW! I downloaded it and it sounds sweet. I thought it would clash with the art style, but it works really well!

I've tinkered around abit, but I cannot seem to get the script to work. Best I could figure, I copied the sciAudio script from lockerGnome into my game, but when I try to (use "sciaudio") I get a compile error.
« Last Edit: October 20, 2012, 05:53:26 PM by Doan Sephim »
Artificial Intelligence Competition

Offline gumby

Re: sciAudio - a new way to put sound in your games!
« Reply #2 on: October 20, 2012, 06:15:37 PM »
Doan, what error do you get?  Is it maybe a problem with the script number?  You should be able to include the script just like any other, nothing special there.  You probably need to include the script in the game.ini.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: sciAudio - a new way to put sound in your games!
« Reply #3 on: October 20, 2012, 07:31:59 PM »
it says: "unable to open file:sciaudio.sco for reading!

Please forgive my ignorance (I'm not a programmer), but what do you mean by include the script in the game.ini?

Offline gumby

Re: sciAudio - a new way to put sound in your games!
« Reply #4 on: October 20, 2012, 08:23:08 PM »
Ah, I see the problem.  Open the sciAudio.sc script and compile it - this is probably sufficient.  That error is indicating that the sciAudio script hasn't been compiled yet.

I'm not sure if the game.ini file is an issue or not.  However, the game.ini file is a text file in your game directory that maps every script number to a script name.  The script number that I used for the sciAudio script in LockerGnome is 973.  If it's not already there, put this line in your game.ini:

Code: [Select]
 n973=sciAudio

That'll allow the compiler to resolve the (use "sciAudio") directive (I think!).

If you don't want to go through all this hassle, just create a new script in SCI Companion/Studio name it 'sciAudio', and then copy/paste the contents of my sciAudio.sc script into it.
« Last Edit: October 20, 2012, 08:39:34 PM by gumby »
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: sciAudio - a new way to put sound in your games!
« Reply #5 on: October 20, 2012, 10:57:51 PM »
I went into the game.ini and changed the name to sciAudio, but when I went back to SciStudio, the script became a closed file.

EDIT - Nevermind, I just went into the source folder and changed the file names from the room number to the script name. Everything compiled. Now I will try to see if I can get the audio to work
« Last Edit: October 20, 2012, 11:00:51 PM by Doan Sephim »
Artificial Intelligence Competition

Offline gumby

Re: sciAudio - a new way to put sound in your games!
« Reply #6 on: October 20, 2012, 11:00:57 PM »
A closed file?  I don't understand.  Were you able to compile the sciAudio script?

EDIT:  Just saw your edit, sweet!  Let me know if it works for you.

« Last Edit: October 20, 2012, 11:03:47 PM by gumby »
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: sciAudio - a new way to put sound in your games!
« Reply #7 on: October 21, 2012, 12:56:01 AM »
I have everything compiled and good to go, but when I call for the music to play, there is only silence. I am wondering if I have not set up my subfolders correctly? You wrote:
Quote
2) Create subfolders within sciAudio for your playback files.  Something like this
       <gamedir>/sciAudio/effects
      <gamedir>/sciAudio/music
Where do I write this?

Offline gumby

Re: sciAudio - a new way to put sound in your games!
« Reply #8 on: October 21, 2012, 09:43:57 AM »
You should be able to use the Locker Gnome Quest folder structure as a guide:

LockerGnomeRedux\src
LockerGnomeRedux\sciAudio\effects
LockerGnomeRedux\sciAudio\music

And of course I just realized that some of my examples are inconsistent with regard to folder structure (I'll update them now).  If you are using my sciAudio script, all paths are relative to the sciAudio subfolder.  So make calls like this:

Code: [Select]
// basic playback
(send snd:
   command("play")
   fileName("effects\\score.sciAudio")   // note the two backslashes!
   volume("35")
   loopCount("0")
   fadeInMillisecs("3000")   // fade in beginning by 3 secs
   fadeOutMillisecs("2000")  // fade out ending by 2 secs
   init()
)

This will play the <gamedir>\sciAudio\effects\score.sciAudio file (in lockergnome's case LockerGnomeRedux\sciAudio\effects\score.sciAudio).

Important note:  Be sure to use two backslashes in path names!

I also forgot to mention that there is log file created in the sciAudio directory called 'sciAudio.log' to assist you with troubleshooting your playback.  I've updated the documentation & original post.
« Last Edit: October 21, 2012, 10:06:39 AM by gumby »
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: sciAudio - a new way to put sound in your games!
« Reply #9 on: October 21, 2012, 11:02:55 AM »
I think I found why I am experiencing the problem I am. Whenever I run dosbox for my game I type in mount d d:/game and then I type in sciv.exe.

With GnomeQuestRedux, there is a shortcut button that runs it in dosbox without having to do all the typing. When I load GQR this way, the music and sound work, but when I run they game by typing in sciv.exe the sound isn't there.

So I guess my next question is, how do I create the shortcut like you have done for GQR?
« Last Edit: October 21, 2012, 11:15:25 AM by Doan Sephim »
Artificial Intelligence Competition

Offline gumby

Re: sciAudio - a new way to put sound in your games!
« Reply #10 on: October 21, 2012, 11:34:49 AM »
I would recommend using Collectors customized DosBox installer for sciAudio that is included in the Locker Gnome Redux demo game (DBRunSetup-sciAudio.exe).  Put it in your game directory & run it - then just use the newly created RUN.EXE to launch your game.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Doan Sephim

Re: sciAudio - a new way to put sound in your games!
« Reply #11 on: October 21, 2012, 01:25:35 PM »
Great! It all seems to be in working order now! Thanks for troubleshooting with me  :)

Offline gumby

Re: sciAudio - a new way to put sound in your games!
« Reply #12 on: October 21, 2012, 01:28:31 PM »
Awesome, glad its working for you!  Looking forward to seeing what you put together.
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition

Offline Collector

Re: sciAudio - a new way to put sound in your games!
« Reply #13 on: October 22, 2012, 03:19:31 AM »
I think I found why I am experiencing the problem I am. Whenever I run dosbox for my game I type in mount d d:/game and then I type in sciv.exe.

With GnomeQuestRedux, there is a shortcut button that runs it in dosbox without having to do all the typing. When I load GQR this way, the music and sound work, but when I run they game by typing in sciv.exe the sound isn't there.

So I guess my next question is, how do I create the shortcut like you have done for GQR?

If you drop "DOSBoxRunSetup.exe" (or "DBRunSetup-sciAudio.exe" for use with an sciAudio game) in the template folder of Studio/Companion and edit the template game's game.ini's Executable line from:

Code: [Select]
Executable=SCIV.EXEto

Code: [Select]
Executable=DOSBoxRunSetup.exe
it will copy the setup to every newly created game. The first time that you click the Run button in Studio or Companion the setup will automatically run and then start you game in DOSBox. Every time you click the Run button thereafter, the game will automatically start in DOSBox. No manual mounting or configuration needed. There are two versions of the App. The original an one modified for sciAudio. If you want to use sciAudio in a game that you are developing, you need to either rename  "DBRunSetup-sciAudio.exe" to "DOSBoxRunSetup.exe" or edit the new game's game.ini from

Code: [Select]
Executable=DOSBoxRunSetup.exe
to

Code: [Select]
Executable=DBRunSetup-sciAudio.exe
« Last Edit: October 22, 2012, 03:24:17 AM by Collector »
KQII Remake Pic

Offline Doan Sephim

Re: sciAudio - a new way to put sound in your games!
« Reply #14 on: October 22, 2012, 10:57:28 AM »
New problems ;)

I can only seem to get the sounds you included in GnomeQuestRedux to play. I have changed midi and wav files to mp3 (via itunes), put the mp3s in the correct folder, changed the extension to .sciAudio but no sound.

You mentioned that it could play WAV or MP3, but how do I convert these files to sciAudio files? Thanks


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

Page created in 0.054 seconds with 23 queries.