Adding new sounds [coders needed]

Got an idea for a new feature in TTDPatch? Post it here.

Moderator: TTDPatch Moderators

User avatar
Sanchimaru
Tycoon
Tycoon
Posts: 1542
Joined: 05 Feb 2004 22:39
Location: Kobe, Japan
Contact:

Adding new sounds [coders needed]

Post by Sanchimaru »

Edit by Csaboka
I'm sorry to hijack your post Sanchimaru, but I can't add my introduction correctly since some limitations of the forum software.

This is a split from Michael Blunck's new graphics topic.

To make the long story short, new sounds can only be added if someone is willing to rewrite the sound drivers of TTD. This seems easy for Windows and difficult for DOS, see my later post for explanation. I won't write either driver, but if someone is willing to do it, I'll gladly help in interfacing with TTD. That's why the topic says "coders needed".
End of edit

Now that the new industries are a reality, what about the new sounds for TT? The brewery doing Prrtzz, blong, dindin chufchufchuugf doesn't sound quite good... not to mention the fishing spots sounding like monkeys
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

Sanchimaru: Unfortunately, this is harder than it sounds. To make this possible, you'd need a new TTD sound driver for the DOS version (that is, one for Sound Blaster, one for AdLib etc...) and a new mpssnd_c.dll for the Windows version. This is not entirely impossible (we have dxmci.dll after all), but I'm not good enough to either DOS sound programming or DirectSound to do such a thing.

If anyone is interested in writing those, though, I'd gladly help interfacing it with TTD.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
User avatar
krtaylor
Tycoon
Tycoon
Posts: 11784
Joined: 07 Feb 2003 01:58
Location: Texas, USA
Contact:

Post by krtaylor »

Could you expand on this theme a little more? Disregard DOS, it sounds like that would be a LOT more work than for Windows.
Development Projects Site:
http://www.as-st.com/ttd
Japan, American Transition, Planeset, and Project Generic Stations available there
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

Well, given that Michael has the DOS version, it wouldn't help him much if the Windows version had new sounds...

The Windows DLL wouldn't be too hard to write (for someone familiar with DirectSound, that is). You could write it in any language you like as long as it can be compiled to a DLL, and IIRC it would need to implement some simple functions only (load samples from sample.cat, play sound with stereo panning, stop sound, adjust volume, and some function to add new sound effects to the built-in list).

The DOS drivers, OTOH, would need knowing the low-level programming of a sound card (using DMA, ports used etc.)
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
User avatar
krtaylor
Tycoon
Tycoon
Posts: 11784
Joined: 07 Feb 2003 01:58
Location: Texas, USA
Contact:

Post by krtaylor »

If somebody wrote an extended sound driver for Windows, I'm sure the US set would use it too.
Development Projects Site:
http://www.as-st.com/ttd
Japan, American Transition, Planeset, and Project Generic Stations available there
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13235
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Post by Hyronymus »

As will the Dutch Trainset but a DOS version would be welcome too because I think there are still people playing TTD in DOS.
User avatar
krtaylor
Tycoon
Tycoon
Posts: 11784
Joined: 07 Feb 2003 01:58
Location: Texas, USA
Contact:

Post by krtaylor »

Yeah, yeah, I know, but the point is, it's a heck of a lot more possible to do for Windows than it is for DOS. It's perfectly possible in Windows; it's very dicey, if possible at all, for DOS. There's no reason the difficulties of DOS should hold back the ability to do it in DOS.
Development Projects Site:
http://www.as-st.com/ttd
Japan, American Transition, Planeset, and Project Generic Stations available there
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

Well, just to put this straight. "still .. in DOS" sounds as if you´re talking about some doddery "oldtimers". Let me tell you that TTDs/patch DOS version runs much more smoothly than the windows version.

BTW, that´s the reason I have a PC exclusively for TTD running under 98SE (DOS).

And BTW2, I´m quite sure that it wouldn´t be harder to have more sounds for the DOS version than for Windows.

But who cares for sounds? There are already 72 different ones for the game.

regards
Michael
User avatar
krtaylor
Tycoon
Tycoon
Posts: 11784
Joined: 07 Feb 2003 01:58
Location: Texas, USA
Contact:

Post by krtaylor »

Look, if people want to use the DOS version, they are free to do so, and that is fine. It is a fact, however, that it woudl be much, much, much, much easier to make an extensible sound system for the Windows version than for the DOS one - so much so as for it to be more or less accurate to say, that for Windows it's fairly easy, and for DOS, impossible. You use DOS, and that's fine; you don't think we need more sounds, and that's fine too. But there have always been enquiries about adding more / different sounds as part of GRF files, and now someone has a practical suggestion as to how to do it.
Development Projects Site:
http://www.as-st.com/ttd
Japan, American Transition, Planeset, and Project Generic Stations available there
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

> It is a fact, however, that it woudl be much, much, much, much easier to make an extensible sound system for the Windows version than for the DOS one [...]

Aha. You´re just guessing, am I right?

regards
Michael
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13235
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Post by Hyronymus »

I can't see what would be so much difficult about DOS either to be honest. I expect you can't go too advanced without making something unsupportable by TTD (I bet even sound is severly limited) anyhow. And if you map the DOS-limitations first you can prevent yourself from making something that's only partly supported in the first place, right?
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

About the sound driver:

You ask why the DOS version is harder to do. In Windows, you have device drivers. You just tell the OS you want to play a sound with given parameters, the driver does the rest, so you don't need to know how the sound card works at all. If new sound cards are manufactured, your program will keep working with them as long as a correct driver is installed in the OS.

OTOH, DOS doesn't have such an abstraction, so a DOS program must handle the sound card directly. This means it will work on a limited set of sound cards only, and new sound cards work only if they are designed to be backwards compatible, or have some sort of emulation. This is why most sound cards wanted to be "100% Sound Blaster compatible" in the DOS era, since virtually all games knew how to use a Sound Blaster card. (I think the only sound cards that still can be made SB compatible are manufactured by Creative itself) Not having a driver also meant you had to set up each game to use your sound card, which usually meant giving the base port, IRQ and DMA of the card.

To make the long story short: DOS TTD has sound drivers for the sound cards that were common in 1995 (setup.exe lists ten of them). To rewrite those drivers, one needs to know how that sound card works, and this involves some low level hardware programming (using I/O ports, interrupts and DMA). On the other hand, rewring the Windows driver only needs knowing one programming interface (that is DirectSound), the operating system does all the hard work behind the scenes.

This doesn't mean rewriting the DOS drivers is impossible, but it's significantly more work than the Windows driver.

We're going very off-topic here, BTW. Should I create a new topic in Suggestions to discuss this further?
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Post by wallyweb »

Csaboka wrote:About the sound driver:
...
We're going very off-topic here, BTW. Should I create a new topic in Suggestions to discuss this further?
Good idea ... there might be someone out there who would be able and willing to work on this sound opportunity (pun intended :D ) who might not notice the discussion in this thread.
Start it with your last post Csaboka ... It says a lot.
nilsi
Transport Coordinator
Transport Coordinator
Posts: 268
Joined: 20 Nov 2002 16:20
Location: Dresden, Germany

Post by nilsi »

Well,
I still do not get it :-(
In what way is *adding new sounds i.e. midi files*
related to *adding new supported output devices i.e. soundcards*

It seems to me quite mixed in this thread, altough it is
an entirely different issue.
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

> In what way is *adding new sounds i.e. midi files*
related to *adding new supported output devices i.e. soundcards*

Yeah. Seconded.

TTD/patch is already able to address the usual number of soundcard types, i.e. nobody needs to fiddle around with IRQs, DMA channels or I/O port mappings.

IMO, adding new sounds would require only to (virtually) add those sounds to "sample.cat" and enable referencing them from the patch with a higher opcode byte than 48h.

regards
Michael
User avatar
eis_os
TTDPatch Developer
TTDPatch Developer
Posts: 3603
Joined: 07 Mar 2003 13:10
Location: Germany
Contact:

Post by eis_os »

Well but how you would change these cat samples via grf? We finally moved from exe files to grfs, not again such problems with the sample.cat ...

(Ohh, and TTD lives in a Box (protected mode), the soundsystem is really outside TTD in realmode... )
Last edited by eis_os on 31 Jul 2005 12:33, edited 1 time in total.
TTDPatch dev in retirement ... Search a grf, try Grf Crawler 0.9 - now with even faster details view and new features...
Image
User avatar
orudge
Administrator
Administrator
Posts: 25223
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Post by orudge »

michael blunck wrote:IMO, adding new sounds would require only to (virtually) add those sounds to "sample.cat" and enable referencing them from the patch with a higher opcode byte than 48h.
Well, I did some investigation into this a while ago, and indeed got new sounds added to the end of sample.cat (and modified others), and attempted to modify TTD to load these new sounds. It played the modified sounds fine, but I personally couldn't get it to read past the end of the file (I wasn't going to try to make it read another file). But then, that's probably just due to my very primitive assembly skills and so on. ;)
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

The rewrite is necessary because it isn't TTD code that loads sample.cat - it's the sound driver code. The main TTD code only gives the parameters to the driver, it doesn't care about the samples associated to the numbers at all. This means, I can't patch it from inside TTDPatch, and even if I could, loading sounds from GRFs would involve an awful lot of patching. Since the interface between TTD and the sound driver is given, it's possible to rewrite it from scratch with extended features instead of patching around the existing code.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

> The main TTD code only gives the parameters to the driver [...]

Then, could you figure out what parameters TTD handles over to the sound driver? Possibly the name of the sound file (sample.cat) and the index of the sound.

Sounds easy. :)

regards
Michael
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Post by Csaboka »

It doesn't pass the name of sample.cat to the driver - this name is simply hardcoded into the driver. The parameters passed are the sample number, the left/right panning and the volume.

There is a ray of hope, though. After a closer examination, the DOS sound driver seems to consist of two parts: a soundcard-independent part (sound.com) and a soundcard-dependent part (soundrv.com). Since the string "sample.cat" is found in sound.com only, it seems only that part would need to be rewritten, which is much less work than rewriting all the soundcard-dependent drivers.

I don't know whether it could work from GRFs yet. I'm currently examining the disassembled sound.com to find out how it works.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
Post Reply

Return to “Suggestions”

Who is online

Users browsing this forum: No registered users and 15 guests