Difference between revisions of "SciAudio"

From SCI Wiki
Jump to navigationJump to search
 
(37 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{SCISoftwareInfobox
+
{{FanSCISoftwareInfobox
 
| Software = sciAudio
 
| Software = sciAudio
| image = Command Line Tool
+
| Image = [[Image:SciAudio.png|200px]]<br />
| Version = 2
+
''sciAudio Example''
| ReleaseDate =  
+
| Version = 1.2.1
| Developers = {{Gumby}}
+
| ReleaseDate = Oct. 20, 2012
| ProgLanguage = C#
+
| Company = N/A
| Platform = {{WindowsTool}}
+
| Published = {{Published}}
 +
| Developers = {{JeremiahNellisToolDev}}
 +
| Interface =
 +
| ProgLanguage = {{CSharp}}
 +
| OpenSource = {{Open}}
 +
| Source = {{SourceSW}}
 +
| License = None
 +
| Platform = {{WinTool}}
 
| Type = {{ModTool}}
 
| Type = {{ModTool}}
| Localization = English
+
| Localization = {{EnglishTool}}
| Website =  
+
| Website = https://bitbucket.org/nellisjp/sciaudio/
}}  
+
}}
  
 
<div align="center"><span style="font-size: 22pt">sciAudio</span><br />
 
<div align="center"><span style="font-size: 22pt">sciAudio</span><br />
Version 1.0<br />
+
Version 1.1<br />
''Author: [[Gumby]]''</div>
+
''Developer: [[Jeremiah Nellis]]''</div>
 
<br />
 
<br />
 
==<br /><br /> Description ==
 
==<br /><br /> Description ==
  
 
<blockquote>
 
<blockquote>
sciAudio is here!  Check out the "LockerGnome Quest Redux" demo game to see it in action!
+
sciAudio is here!  Check out the "[[LockerGnome Quest Redux]]" demo game to see it in action!
 +
 
 +
Announcement here: http://sciprogramming.com/community/index.php?topic=634.0
 
</blockquote>
 
</blockquote>
  
 
==<br /> Features ==
 
==<br /> Features ==
  
- Playback of WAV and MP3 files
+
* Playback of WAV and MP3 files
- Unlimited number of sounds playing simultaneously
+
* Unlimited number of sounds playing simultaneously
- Fade in/out, looping and volume control
+
* Fade in/out, looping and volume control
- Classification of sounds for playback management
+
* Classification of sounds for playback management
- Multiple commands may be issued simultaneously to the 'controller' file
+
* Multiple commands may be issued simultaneously to the 'controller' file
- Multiple controller files to avoid resource contention
+
* Multiple controller files to avoid resource contention
- Runs hidden in background & will terminate itself shortly upon game close
+
* 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
+
* 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
+
* 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)
+
* Log file for troubleshooting sound playback ('sciAudio.log' located in same directory as sciAudio.exe)
  
 
&nbsp;
 
&nbsp;
Line 45: Line 54:
 
==<br /> Usage ==
 
==<br /> Usage ==
  
<div align="center">[[File:sciAudio.png|sciAudio]]</div>
+
<blockquote>
 +
===<br />Setup ===
 +
 
 +
# Place the 2 nAudio DLLs & executable into a subfolder within your game named 'sciAudio'
 +
# Create subfolders within sciAudio for your playback files. Something like this<blockquote><gamedir>\sciAudio\effects<br /><gamedir>\sciAudio\music</blockquote>
 +
# Include the sciAudio.sc script & 'use' it in any script you wish to have sciAudio playback in
 +
 
 +
===<br /> Available commands ===
  
 
<blockquote>
 
<blockquote>
SciAudio
+
command <playback command>
 +
<blockquote>
 +
play<blockquote>
 +
        Begins playback of a sound</blockquote>
 +
 
 +
stop<blockquote>
 +
        Stops playback of a sound</blockquote>
 +
 
 +
change<blockquote>
 +
Changes playback of a sound.  Used primarily for volume & loop control, very limited usefulness.</blockquote>
 +
 
 +
playx (play exclusively based on sound class)<blockquote>
 +
This behaves just like the 'play' command, but will stop any currently playing sounds with the same sound class as the specified class.</blockquote>
 
</blockquote>
 
</blockquote>
 +
fileName
 +
<blockquote>Filename to playback, including the path.</blockquote>
 +
     
 +
soundClass
 +
<blockquote>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</blockquote>
 +
 +
volume
 +
<blockquote>Playback volume of sample.  Default is 100 (100% volume of sample).  Range: 0 to ~300?</blockquote>
 +
     
 +
fadeInMillisecs
 +
<blockquote>Number of milliseconds to fade in the sample
 +
     
 +
fadeOutMillisecs
 +
<blockquote>Number of milliseconds to fade out a sample.  Can be issued with a play or stop command</blockquote>
 +
     
 +
loopFadeInMillisecs
 +
<blockquote>Number of milliseconds to fade in a sample between loops.</blockquote> 
 +
     
 +
loopFadeOutMillisecs
 +
<blockquote>Number of milliseconds to fade out a sample between loops.</blockquote>
 +
     
 +
loopCount
 +
<blockquote>Number of times to loop the sample.  Default is 0, -1 is infinite</blockquote>
 +
     
 +
conductorFile
 +
<blockquote>'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.</blockquote>
 +
 +
playXFadeOutMillisecs
 +
<blockquote>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.
 +
</blockquote>
 +
</blockquote>
 +
</blockquote>
 +
</blockquote>
 +
 +
==<br /> Examples ==
 +
 +
<blockquote>
 +
<div class="CodeBlockHeader">Code:</div>
 +
<syntaxhighlight lang="sci">
 +
(use "sciAudio")
 +
 +
(local
 +
    snd
 +
)
 +
 +
(instance aud of sciAudio
 +
  (properties)
 +
  (method (init)
 +
      (super:init())
 +
  )
 +
)
 +
</syntaxhighlight>
 +
 +
 +
<div class="CodeBlockHeader">Code:</div>
 +
<syntaxhighlight lang="sci">
 +
// 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()
 +
)
 +
</syntaxhighlight>
 +
 +
 +
<div class="CodeBlockHeader">Code:</div>
 +
<syntaxhighlight lang="sci">
 +
// looping playback example
 +
(send snd:
 +
    command("play")
 +
    fileName("effects\\loopedSound.sciAudio")
 +
    volume("100")
 +
    loopFadeInMillisecs("2000")
 +
    loopFadeOutMillisecs("2000")
 +
    loopCount("-1")  // loop forever
 +
    init()
 +
)
 +
</syntaxhighlight>
 +
 +
 +
<div class="CodeBlockHeader">Code:</div>
 +
<syntaxhighlight lang="sci">
 +
// stop with 5 second fade out
 +
(send snd:
 +
  command("stop")
 +
  fileName("music\\introMusic.sciAudio")
 +
  fadeOutMillisecs("5000")
 +
  loopCount("0")
 +
  init()
 +
)
 +
</syntaxhighlight>
 +
 +
 +
<div class="CodeBlockHeader">Code:</div>
 +
<syntaxhighlight lang="sci">
 +
// change currently playing volume for a sound class
 +
(send snd:
 +
  command("change")
 +
  soundClass("myMusicSoundClass")
 +
  volume("50")  // set playback to 50% volume
 +
  init()
 +
)
 +
</syntaxhighlight>
 +
 +
 +
<div class="CodeBlockHeader">Code:</div>
 +
<syntaxhighlight lang="sci">
 +
// stop looping a particular sound file
 +
(send snd:
 +
  command("change")
 +
  soundClass("music\\introMusic.sciAudio")
 +
  loopCount("0")  // stop looping
 +
  init()
 +
)
 +
</syntaxhighlight>
 +
 +
 +
<div class="CodeBlockHeader">Code:</div>
 +
<syntaxhighlight lang="sci">
 +
// 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()
 +
)
 +
</syntaxhighlight>
 +
</blockquote>
 +
 +
==<br /><br /> Version 1.2/1.2.1 ==
 +
 +
New version attached here and also put all this code into a git repo, apparently it wasn't before:  https://bitbucket.org/nellisjp/sciaudio/
 +
 +
Now there is an sciAudio.ini file (needs to be in the sciAudio subdirectory of your game) that is read in and used for monitoring a list of (5) possible applications to monitor to determine when to kill sciAudio.  It's a bit hacky, and 5 applications might be overkill but it gives a little flexibility and is backward-compatible with the previous versions which monitored either 'RUN', 'DosBox' or 'ntvdm'.  I also improved the logging around all of this so it's a bit easier to troubleshoot.
 +
 +
Here's what the included INI file looks like, modify it to suit your needs:
 +
 +
<div class="CodeBlockHeader">Code:</div>
 +
<syntaxhighlight lang="sci">
 +
[sciAudio]
 +
GameExecutableName1=RUN
 +
GameExecutableName2=DOSBox
 +
GameExecutableName3=ntvdm
 +
GameExecutableName4=
 +
GameExecutableName5=
 +
</syntaxhighlight>
 +
 +
Version 1.2.1 includes a fix that was causing the application to not work reliably because it was checking for the game application 'too soon' and would abruptly exit.  Fix consists of a 5 second delay before watching currently running processes.
 +
 +
==<br /> 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.
  
 
==<br /> Download ==
 
==<br /> Download ==
Line 55: Line 253:
 
<blockquote>
 
<blockquote>
 
Download from here (source included):
 
Download from here (source included):
* [[Image:ZIP.PNG|ZIP File]] [[scidl:AudioUtilities/sciAudio10_wSRC.zip|sciAudio 1.0]]<span class="DLInfo"> (ZIP file) [200 KB]</span>
+
* [[Image:ZIP.png|ZIP File]] [[scidl:AudioUtilities/SciAudio_v1.2.1.zip|sciAudio 1.2.1]]<span class="DLInfo"> (ZIP file) [193 KB]</span>
 +
* [[Image:ZIP.png|ZIP File]] [[scidl:AudioUtilities/sciAudio10_wSRC.zip|sciAudio 1.0]]<span class="DLInfo"> (ZIP file) [200 KB]</span>
 
</blockquote>
 
</blockquote>
 +
 +
==<br /> References ==
 +
 +
<references />
  
 
==<br /> Also See ==
 
==<br /> Also See ==
  
* [[:Category:SCI Tools|SCI Tools]]
+
*

Latest revision as of 01:16, 20 May 2024

sciAudio
SciAudio.png
sciAudio Example
Latest Version:  1.2.1
Release Date:  Oct. 20, 2012
Company: N/A
Publication Status:  Published
Developer(s): Jeremiah Nellis
Interface:
Language: C#
Open Source: Open
Source Availability: 
License: None
Type: Mod Tool
Platform: Windows
Localization: English
Website: https://bitbucket.org/nellisjp/sciaudio/


sciAudio

Version 1.1

Developer: Jeremiah Nellis




Description

sciAudio is here! Check out the "LockerGnome Quest Redux" demo game to see it in action!

Announcement here: http://sciprogramming.com/community/index.php?topic=634.0


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)


Usage


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

Code:
(use "sciAudio")

(local
    snd
)

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


Code:
// 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()
)


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


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


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


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


Code:
// 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()
)



Version 1.2/1.2.1

New version attached here and also put all this code into a git repo, apparently it wasn't before: https://bitbucket.org/nellisjp/sciaudio/

Now there is an sciAudio.ini file (needs to be in the sciAudio subdirectory of your game) that is read in and used for monitoring a list of (5) possible applications to monitor to determine when to kill sciAudio. It's a bit hacky, and 5 applications might be overkill but it gives a little flexibility and is backward-compatible with the previous versions which monitored either 'RUN', 'DosBox' or 'ntvdm'. I also improved the logging around all of this so it's a bit easier to troubleshoot.

Here's what the included INI file looks like, modify it to suit your needs:

Code:
[sciAudio]
GameExecutableName1=RUN
GameExecutableName2=DOSBox
GameExecutableName3=ntvdm
GameExecutableName4=
GameExecutableName5=

Version 1.2.1 includes a fix that was causing the application to not work reliably because it was checking for the game application 'too soon' and would abruptly exit. Fix consists of a 5 second delay before watching currently running processes.


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.


Download

Download from here (source included):


References



Also See