| Googie 2005-02-27, 3:59 am |
| INTRO
-----
I've started with TclGame (SDL bindings) but I came to point, that in
Tcl better is to use [canvas] or - much better - TkZinc for 2D
graphics. Only thing that is missing in Tcl to make nice 2D games is
bad support for audio.
Yes, I know, there is Snack package, but it was designed for different
targets, than simple playback. It's quiet slow (latency), has too many
options, which aren't used recently in simple playback.
DESCRIPTION
-----------
So, here's TclMixer, SDL_mixer bindings for Tcl. It allows to play
multiple sounds at the same time using built-in software mixer. It
supports following sound formats: WAV/RIFF, MP3, OGG, MID (midi), MOD
(including standart MOD modules, but also S3M, IT, XM). There are
basic effects implemented, which would be very useful, such as 3D
sound positioning, stereo balance, fading in/out and sound source
distance. All these goodies closed in well known, simple Tcl syntax.
To make this extension work, end-user has to got installed SDL (in
version 1.2.x) and SDL_mixer (in version 1.2.x), which are quiet
famous and presents on most Unix desktop machines (in future
tclmixer.so could be linked statically with these libraries to takes
dependencies off).
Didn't tried to compile it on Windows yet, but should be fine, since
SDL and SDL_mixer works nice on Windows.
LICENCE
-------
It's LGPL (same as SDL).
WHERE TO GET IT?
----------------
http://scripts.one.pl/tclmixer/
There is also online documentation.
HOW TO START / CHECK IT OUT?
----------------------------
Get some supported sound file. If it's some effect (gun shot, or
explosion or sth) load it as short sound:
#!/usr/bin/env wish
load tclmixer.so
set snd [tclmixer::sound file.<mp3|wav|ogg>]
tclmixer::play $snd
if file is big, then load it as long sound, to prevent loading it into
memory:
#!/usr/bin/env wish
load tclmixer.so
set music [tclmixer::music file.<mp3|wav|ogg|mid|mod>]
tclmixer::play $music
There is 'wish' used, not 'tclsh', becouse we need some event loop,
since SDL_mixer hasn't its own. If you want to use 'tclsh', you can
use CALLBACK mechanism:
#!/usr/bin/env tclsh
load tclmixer.so
set sleep 0
proc musicFinished {} {
global sleep
set sleep 1
}
tclmixer::setCallback MUSIC musicFinished
set music [tclmixer::music file.<mp3|wav|ogg|mid|mod>]
tclmixer::play $music
while {$sleep} {after 1000}
See documentation for more.
--
Pozdrawiam (Greetings)!
Googie
|