New music system for OpenTTD

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

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

New music system for OpenTTD

Post by orudge »

Yes, at last, here is the patch and Win32 binary for my new music version. Some notes though: this patch is not complete!
  • The playlist GUI does not quite behave correctly (the right-hand scroll box does not scroll correctly).
  • The patch doesn't seem to like to work too well on Linux (not tested it with any other operating systems, well, apart from OS/2). I found that you had to comment out the fclose() command in music/decoders/ogg.c in ogg_close_file to stop it crashing after every song (probably a race condition... indeed, I wonder, it might be calling the new ogg_open_file before ogg_close_file on the old one perhaps - will maybe do some more investigation). Anyway. That's a bit broken, unless you hack it up a bit. Also, when I tried playing an MP3 file on Linux, it played it at a much faster rate than it should have... seems to be an issue with the buffering code. If someone wants to look into these issues, I'd really appreciate it.
  • If you play a file that isn't 44.1KHz, it will not sound very nice.
Off the top of my head, I think that's all that's broken, but I might be wrong. ;)

How to use this thing, then... for a start, it plays MIDI (through the existing driver system), MP3 (using libmad) and Ogg Vorbis (using vorbisfile, part of libvorbis - you need libogg as well, though). If you don't provide an openttd.m3u file, the game will just use the standard MIDI files, as in older versions, if it can find them. However, if you create an openttd.m3u file, it will try to play this instead. Winamp M3U files should work fine, otherwise, you can just create a text file in Notepad with the following format:

Song 1
C:\music\song1.mp3
Faithless - Insomnia
/home/orudge/music/Faithless - Insomnia.ogg
TTD Title Theme
music/gm_tt00.gm

(ie, title on one line, song on the next)

OpenTTD currently supports a maximum of 100 songs in the playlist. Any more than that will be ignored.

A sample M3U is provided with the Win32 version in this archive. To use it, download the FM MP3s from http://users.tt-forums.net/jfs/ and place them in the fm-mp3s directory.

The makefile doesn't automatically detect libmad, libogg or libvorbis at the moment, you must call make with WITH_VORBIS=1 WITH_MP3=1 parameters.

Hmm, there's probably more I should say, but I can't really think of much just now. Have fun, let me know about any problems you have - particularly on systems other than Windows - and if you are able to help fix those problems, it'd be even better!

As for the attachments, it should be fairly self-explanatory:

openttd-music-r3289-2005-12-11.diff is the diff against r3289 (don't worry, it upgrades fine to the latest SVN without any conflicts). I find TortoiseSVN seems to have some trouble creating the music/decoders directory and doing things with that, though, so you may want to extract those files from the source RAR.

openttd-music-win32-r3317m-18-12-05.rar is the Win32 version of the patch, against the latest SVN as of right now. Hopefully everything is included that is needed.

openttd-music-fullsrc-r3317m-18-12-05.rar is the full source code, which should compile out of the box, if you're lucky.

Again, have fun, and please let me know of any bugs, etc! I'm not submitting this to SourceForge yet as it is indeed incomplete, but I'd like to see what everyone thinks. It's taken me a long time to get this done, partially due to lack of time and partially due to laziness, but here it is at last.
Attachments
openttd-music-fullsrc-r3317m-18-12-05.rar
Full source code, against r3317
(1.97 MiB) Downloaded 1687 times
openttd-music-win32-r3317m-18-12-05.rar
Win32 binary
(1.22 MiB) Downloaded 745 times
openttd-music-r3289-2005-12-11.diff
Diff against r3289
(93.52 KiB) Downloaded 598 times
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

Quite fun this package! Downloaded the source and compiled using MSVC6:
Build : warning : failed to (or don't know how to) build 'C:\$games\openttd_music_fullsrc_r3317m_18_12_05_318\openttd\lang\lithuanian.txt'
Performing Custom Build Step on .\lang\lithuanian.txt
lang\lithuanian.txt:2789: FATAL: Cannot open file
Error executing d:\windows\system32\cmd.exe.

openttd.exe - 1 error(s), 1 warning(s)
So I made an empty lithuanian.txt and it compiled the languages...
But It also gave some other errors :P (see the attached build-log)

Guess I'll have to download the pre-compiled one, downloaded it, extracted it, added a MP3 by Eminem and it works like a charm :)
Attachments
Output - Build.txt
(12.91 KiB) Downloaded 488 times
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
User avatar
orudge
Administrator
Administrator
Posts: 25223
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Post by orudge »

Oops, it seems music.c and music.h got left out somehow... they're attached here.
Attachments
music.zip
music.c / music.h
(3.67 KiB) Downloaded 499 times
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

webfreakz.nl wrote:Quite fun this package! Downloaded the source and compiled using MSVC6:
Build : warning : failed to (or don't know how to) build 'C:\$games\openttd_music_fullsrc_r3317m_18_12_05_318\openttd\lang\lithuanian.txt'
Performing Custom Build Step on .\lang\lithuanian.txt
lang\lithuanian.txt:2789: FATAL: Cannot open file
Error executing d:\windows\system32\cmd.exe.

openttd.exe - 1 error(s), 1 warning(s)
That's because lithuanian.txt was moved back to unfinished in r3268, but no one thiought it appropriate to fix the VC6 and VC.net project files. Just delete lithuanian.txt from the project until someone fixes them. (<strikeout>Report en route to bugs.openttd.org, as soon as I can construct a diff.</strikeout>. Scratch that; it's already been submitted.)
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
nicfer
Director
Director
Posts: 529
Joined: 03 May 2005 20:50
Location: Somewhere in a country called Argentina

Post by nicfer »

A bug: if I am in the last file and try to skip to the next the current track becomes "-" characters and for can change again the track I have to put the "all" button. Here I will put bugs if I found them.
Sorry for my english I am argentinian
TTO don't crashes in Windows XP; XP crashes TTO

Formerly known as UnderBuilder.

MyMiniCity
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

@Dalestan:
So I made an empty lithuanian.txt and it compiled the languages...
my previous post ;)

Still some error?
mp3.c
C:\$games\openttd_music_fullsrc_r3317m_18_12_05_318\openttd\music\decoders\mp3.c(16) : fatal error C1083: Cannot open include file: 'mad.h': No such file or directory
pathfinder.c
shared.c
trolly.c
vorbis.c
C:\$games\openttd_music_fullsrc_r3317m_18_12_05_318\openttd\music\decoders\vorbis.c(16) : fatal error C1083: Cannot open include file: 'ogg/ogg.h': No such file or directory
Generating Code...
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
User avatar
orudge
Administrator
Administrator
Posts: 25223
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Post by orudge »

webfreakz.nl:

As I say, you need libmad and the Ogg Vorbis libraries, links to both of which can be found in my original post.
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

This is strange :
At home, on XP pro, works like a charm.
At the office, still in XP pro, no luck.

I have an assertion failed error:
File : gfxinit.c
Line :88
Expression : b

Sorry to report bad news...
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

probably newgrf file(s).
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

Can you devs say something more about whether this feature will be added to SVN or not? IMHO you could just achieve the same working of this patch when you just hit the STOP button of the OpenTTD music player, and then start your favorite-mp3-player playing your favorite music, and return back to OpenTTD and you've got the same... ???
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

Darkvater wrote:probably newgrf file(s).
Yep, that did the trick.
I refreshed the OpenTTD grf files with current nightly and it works now.

orudge, one case less...
Darkvater, one thumb up
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
User avatar
orudge
Administrator
Administrator
Posts: 25223
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Post by orudge »

webfreakz.nl wrote:Can you devs say something more about whether this feature will be added to SVN or not? IMHO you could just achieve the same working of this patch when you just hit the STOP button of the OpenTTD music player, and then start your favorite-mp3-player playing your favorite music, and return back to OpenTTD and you've got the same... ???
Well, I'm hoping it will be implemented, once it's been tidied up a bit. I've put rather a lot of work into it and it's been requested for ages, since before OpenTTD even existed. ;) And the point of it isn't necessarily so that people can play their own music, it's so that new music can be created for OpenTTD that isn't in the MIDI format. Of course, people can use their own music if desired.
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

orudge: This is a difficult thing... But how is it difficult to rewrite the game so the OTTD sounds are a packed archive (like compressed savegames) and I can call a sound using a function like PlaySound('name',parameters);?

From the gameplay side, it is changing .gm files to other files much more user friendly

This would also mean OTTD will have more sounds, also we won't use TTD sounds (going legal, just like with graphics)

Calling a sound would be much easier

However, amount of work on it may be big. What do you think about that?
Alltaken
Tycoon
Tycoon
Posts: 1285
Joined: 03 Dec 2003 06:24
Location: Christchurch, New Zealand
Contact:

Post by Alltaken »

MeusH i was planning on having sounds stored in the same format as new graphics, but with different info file.

Alltaken
User avatar
orudge
Administrator
Administrator
Posts: 25223
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Post by orudge »

MeusH wrote:orudge: This is a difficult thing... But how is it difficult to rewrite the game so the OTTD sounds are a packed archive (like compressed savegames) and I can call a sound using a function like PlaySound('name',parameters);?
Such a thing is quite possible. For now though, I'm concentrating on the new music system. A new sound system can come later. ;)
User avatar
orudge
Administrator
Administrator
Posts: 25223
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Post by orudge »

Anyone else tried this? Anyone vaguely interested in it at all? Or has it been waste of, hm, over a year basically? :?
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

orudge wrote:Anyone else tried this? Anyone vaguely interested in it at all? Or has it been waste of, hm, over a year basically? :?
Not wasted at all!! Ive overlooked trying out this patch, as, well, I play OTTD (and TTDLX before that) with the music off. After hours of gameplay I would have the music spinning around my head too much!

If I can get it to compile (I hate coping with new libraries), I'll give it some testing. 8)
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

I'm downloading it again to check it :) Of course, I'm much interested in this, but I'm more interested in the sound system
User avatar
AlienDNA
Engineer
Engineer
Posts: 97
Joined: 12 Apr 2004 08:53
Location: Leiden, Netherlands

Post by AlienDNA »

It's really a shame that this patch is falling back on the forum. I think the sound system is very important. If this patch already has so much work in it, why don't we get it finished for inclusion in the trunk? Then maybe some of us can work on good sounds to replace the origionals, or even add more vehicle-specific sounds! Although I can't do either, I still encourage these improvements to be finished.
"I'm gonna rip his leg off and kick him with it!", Sanjuro, Shogo-MAD
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

Because it's very hard to get some code in /trunk/ if you're not a OpenTTD developer...
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 5 guests