New sound mixer (patch version 2.2, r12941)

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
User avatar
orudge
Administrator
Administrator
Posts: 25218
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

New sound mixer (patch version 2.2, r12941)

Post by orudge »

Hi all,

Attached is the latest version of my new sound mixer patch for OpenTTD. Note that this doesn't include new music support (that's in a different patch), but it does lay the foundations for it.

This patch features:

- New sound mixing engine, mostly nicked from ScummVM with various modifications
- Support for 16-bit, stereo, 44.1KHz audio, as opposed to TTD's 8-bit, 11.25Khz audio
- Support for reading audio files from memory (ie, sample.cat/opensfx.cat/newgrf-style), or from separate files (currently, just .wav, although MP3, FLAC and Vorbis are supported in the music patch)

This patch also provides basic support for the Sound Replacement project. If it finds that sample.cat does not exist or does not match its md5sum, it will look for opensfx.cat and use that instead. (Future versions will check MD5 of this, but as opensfx.cat isn't finished yet, this check isn't implemented). A test opensfx.cat is available too (using the latest sounds posted to the Sound Replacement Project thread, with various "filler" sounds for those not implemented), along with a program to generate it. Note that all sounds in opensfx.cat must currently be signed 16-bit mono. (Frequency doesn't matter, although 44.1KHz is preferred.)

I don't forsee the patch being accepted into trunk for the time being due to the large number of files it adds, mostly miscellaneous classes used by the mixer for reading file and memory streams. But who knows. If the devs could offer some feedback, that would be useful. (I'll post this on flyspray once I've had a few comments about it here.)

The patch should build cleanly on Windows (MSVC and MinGW), Linux and Mac OS X. Not tested on any other systems, but I don't see why it shouldn't work. ;)

Note that depending on the tool you use to apply the patch, it may not create the mixer/ directory and place the mixer files in it. If you find a bunch of cpp and hpp files in your source root directory, that may be why. Move them to src/mixer/.

Any comments, queries, problems, please post here. :)

opensfx.cat

Available from http://www.owenrudge.net/various/opensfx-0.1.zip (7.82MB)

Note that you must rename/delete sample.cat for opensfx.cat to be used. Once opensfx.cat is finished, it can be made the default.

opensfx encoding utility

Available from http://www.owenrudge.net/various/opensfx-encode-0.1.zip (10.1MB). Win32 .exe included, source code available for other platforms. Uses a very simple input.txt file - reads a filename, and adds it to opensfx.cat. May be buggy, but seems to work for me. Includes all necessary sound files to build a .cat.

EDIT: Uploaded version 2.2.1 of the patch, which removes some unnecessary code.
Attachments
new-sound-mixer-v2.2-r12941.diff
The patch itself
(111.75 KiB) Downloaded 416 times
new-sound-mixer-v2.2.1-r12959.diff
Updated patch
(96.06 KiB) Downloaded 414 times
User avatar
Killer 11
Tycoon
Tycoon
Posts: 2463
Joined: 06 Jan 2004 18:38
Location: Kaunas, Lithuania
Contact:

Re: New sound mixer (patch version 2.2, r12941)

Post by Killer 11 »

Could someone post compiled windows binaries?
I tried BuildOTTD but if fails with both patches.
User avatar
orudge
Administrator
Administrator
Posts: 25218
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Re: New sound mixer (patch version 2.2, r12941)

Post by orudge »

Attached is a Win32 binary for r12956.
Attachments
openttd.zip
new sound mixer - r12956M
(1.08 MiB) Downloaded 323 times
User avatar
Killer 11
Tycoon
Tycoon
Posts: 2463
Joined: 06 Jan 2004 18:38
Location: Kaunas, Lithuania
Contact:

Re: New sound mixer (patch version 2.2, r12941)

Post by Killer 11 »

Thank you!
It works nicely except for steam whistle which is with nasty sound errors.
aapo
Engineer
Engineer
Posts: 10
Joined: 05 Dec 2008 16:44

Re: New sound mixer (patch version 2.2, r12941)

Post by aapo »

This sound replacing project is equally important than graphics replacement project.

It is possibly to make sample.cat file with some encode-program? So there are no (yet) needs to new-mixer.

Encode-program doesn't work with linux. I got it compiled and runned, but it makes file that looks pretty much input.txt (there are some funny characters).

I updated sound-mixer patch to working with svn 14657. (So it can be used same time with open graphics)
(patch -p1)

If you patch with this, you must

Code: Select all

./configure --without-allegro
Updating was trivial, I think it works good as original patch.
Attachments
new_mixer_r14657.diff
(110.65 KiB) Downloaded 360 times
User avatar
orudge
Administrator
Administrator
Posts: 25218
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Re: New sound mixer (patch version 2.2, r12941)

Post by orudge »

aapo wrote:It is possibly to make sample.cat file with some encode-program? So there are no (yet) needs to new-mixer.
The encode program I supplied should work, although I'm not sure why it doesn't work on Linux. It was just a quick hack, really, a proper program would need to be written ideally.
aapo wrote:If you patch with this, you must

Code: Select all

./configure --without-allegro
Could I ask why? I may look into this over Christmas, there should be no reason it doesn't work with Allegro, although I guess you'd have to modify the Allegro driver a bit to use the new mixer interface.

Cheers,
aapo
Engineer
Engineer
Posts: 10
Joined: 05 Dec 2008 16:44

Re: New sound mixer (patch version 2.2, r12941)

Post by aapo »

I tried to update new-music-mixer from http://www.tt-forums.net/viewtopic.php?f=33&t=22483
But it is too old, and I'm not skilled enough.

Am I right that sound mixer and music mixer are somehow connected, so they should replaced sametime?

I tried make sound mixer which plays wavs (from http://wiki.openttd.org/wiki/index.php/ ... eplacement ) and music mixer which gets some textfile as playlist and plays mp3/ogg/mid. I got it working with svn 14657 so it can be used sametime than opengraphics.

It uses SDL_mixer. Yes I have readed about sdl, but at least there are now someway to use Totally open Openttd. I clean the code and made patch. And hope that there are someday official TotallyOpen OpenTtd.
User avatar
orudge
Administrator
Administrator
Posts: 25218
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Re: New sound mixer (patch version 2.2, r12941)

Post by orudge »

aapo wrote:I tried to update new-music-mixer from http://www.tt-forums.net/viewtopic.php?f=33&t=22483
But it is too old, and I'm not skilled enough.
There is a new, improved version of the music mixer which uses the new sound mixer released in this topic. However, I don't think I uploaded it to the forums. I'll look into it later.
Am I right that sound mixer and music mixer are somehow connected, so they should replaced sametime?
Well, the sound mixer can operate without the music mixer, but the music mixer requires the sound mixer.
aapo
Engineer
Engineer
Posts: 10
Joined: 05 Dec 2008 16:44

Re: New sound mixer (patch version 2.2, r12941)

Post by aapo »

I finalized my patch (it is against svn14884). It uses SDL_mixer and plays wav-files on data/sounds (named 0.wav...72.wav).
It doesn't need all wav-files (no dummy files for missing).

It also loads data/playlist.m3u and plays it content. Like this:
  • example1.ogg
    example2.mp3
    example3.mid
    example4.mod
    music/example5.s3m
    ../../musics/example6.mp3
Playlist can be empty. Missing entryes are skipped.

Start with:

Code: Select all

openttd -s sdl -m sdl
I made script that downloads ready wav-files. Look http://www.tt-forums.net/viewtopic.php?t=41310
Attachments
free_mixer.patch
SDL_mixer: plays wav-soundeffects and ogg/mp3/mid/mod musics. For svn14884
(10.04 KiB) Downloaded 640 times
User avatar
StopRightThere
Chief Executive
Chief Executive
Posts: 761
Joined: 18 Dec 2005 20:10
Location: United Kingdom

Re: New sound mixer (patch version 2.2, r12941)

Post by StopRightThere »

orudge wrote: There is a new, improved version of the music mixer which uses the new sound mixer released in this topic. However, I don't think I uploaded it to the forums. I'll look into it later.
Hi orudge, how are you progressing with this?
Bye Bye OpenBVE :(
Official TT-Hot young ginger Doctor Who assistant FanClub
Formerly known as AdditionalData
User avatar
orudge
Administrator
Administrator
Posts: 25218
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Re: New sound mixer (patch version 2.2, r12941)

Post by orudge »

AdditionalData wrote:Hi orudge, how are you progressing with this?
At the moment, I'm in the middle of exams, and have just reinstalled my OS. I'll need to ideally a) finish my exams and b) reinstall my development environment, then I shall have a look into it!
User avatar
kyosuke1989
Transport Coordinator
Transport Coordinator
Posts: 273
Joined: 24 Mar 2008 13:04
Location: Finland

Re: New sound mixer (patch version 2.2, r12941)

Post by kyosuke1989 »

orudge wrote: - Support for 16-bit, stereo, 44.1KHz audio, as opposed to TTD's 8-bit, 11.25Khz audio
- Support for reading audio files from memory (ie, sample.cat/opensfx.cat/newgrf-style), or from separate files (currently, just .wav, although MP3, FLAC and Vorbis are supported in the music patch)
Did i understand right, that eventually, when this patch is done, anyone could have 16-bit stereo 44100 kHz sounds on newgrf's? If so, sound effect quality could be vastly improved on running/acceleration/idling-sounds. Also, i think that 64 kb limit is too little for sound effects, especially on that format..
User avatar
orudge
Administrator
Administrator
Posts: 25218
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Re: New sound mixer (patch version 2.2, r12941)

Post by orudge »

The patch here is never going to make it into OpenTTD; for a start it's woefully out of date.

I did start work on another, vaguely more up-to-date system for streaming high quality music into the OpenTTD mixer, but due to lack of enthusiasm, time, etc, I've not done anything with that in a couple of years, and probably won't.

My patch would not have affected NewGRFs, anyway. Technically it could play a high quality sound effect from a NewGRF, yes; implementing support for high quality sounds, or increasing any limits, was not what I was working on, though. (Is that 64KB limit even still an issue, particularly with these NewGRF changes for 32-bit graphics?)
Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: New sound mixer (patch version 2.2, r12941)

Post by Supercheese »

When I've been about adding sound effects to my NewGRFs, the 64kb limit was really, really annoying. It would be very nice to have it raised. :)
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 991
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: New sound mixer (patch version 2.2, r12941)

Post by frosch »

Supercheese wrote:When I've been about adding sound effects to my NewGRFs, the 64kb limit was really, really annoying. It would be very nice to have it raised. :)
With GRF container version 2 it is raised to a significantly higher limit. (likely OTTD cannot deal with files bigger than 4GB though.)
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: New sound mixer (patch version 2.2, r12941)

Post by Eddi »

frosch wrote:(likely OTTD cannot deal with files bigger than 4GB though.)
taking bets on which project will reach that limit first :p
User avatar
Toni Babelony
Tycoon
Tycoon
Posts: 1389
Joined: 07 Jul 2006 09:34
Skype: toni_babelony
Location: Sagamihara-shi, Japan
Contact:

Re: New sound mixer (patch version 2.2, r12941)

Post by Toni Babelony »

I just spotted this. AWESOME!

Recently, I implicated quite a bit of sounds in my TIAS NewGRF which are used simultaneously (starting sound, running sound per 1 running tick (motor), running sound per 16 running bits (clickety-clack) and loading/unloading sound). Whenever this gets into the standard OpenTTD releases I'll certainly add more sounds to my set(s). I also noticed that the idling sound also plays during running, but that's not really relevant in this topic I think.
Retired JapanSet developer and creator of TIAS.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 18 guests