News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

Parallel sounds

Started by Leartin, May 01, 2017, 09:31:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Leartin

I played around with factory sounds a bit, and it's amazing. However, I realized that only one sound could be played at a time. At a busy stations, earning money and vehicles starting constantly interupt the factoy sound if it's longer than a second. Is this something that could be changed, or is it platform/version dependent?

Ters

The sound backends are very rudimentary, or at least some of them are.

jamespetts

It would definitely be a good thing to allow multiple sounds at once.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

An_dz

Sound is so rudimentary that if you disregard my commit for translating comments, the last change in the sound folder is from Feb 2015. ;D

Ters

Quote from: An_dz on May 01, 2017, 04:57:56 PM
last change in the sound folder is from Feb 2015

That recent? Oh, it's just some global changes related to compiler compatibility. The last true change to the sound backends was in 2014, as is actually about stopping the currently playing sound.

To elaborate a bit more on the state of the sound. The Windows-backend uses a very old API for playing sounds. It does not contain a mixer, so Simutrans uses the master volume control to set the correct volume for the sound it wants to play. Naturally, this means that two sounds can't be played at the same time at the correct volume. (Pre-Vista, I suspect that the volume Simutrans changes is the global volume. For Vista and later, it is probably the application specific volume. I haven't tested, as I have turned Simutrans sounds off.)

There are two SDL backends, one with mixer in the name. Both seems to be able to play multiple sounds. The Allegro backend seems able to play four sounds at the same time. I can't tell what the core-audio backend is capable of.

A couple of years ago, I tried making an alternative backend for Windows based on DirectX 8. Unfortunately, MinGW32 does not support DirectX 8. It is capable of playing as many sounds as the sound driver can, but it can currently only play one instance of the same sound at the same time. I do however not remember how complete it even is.

An_dz

Quote from: Ters on May 01, 2017, 06:03:18 PM
That recent? Oh, it's just some global changes related to compiler compatibility. The last true change to the sound backends was in 2014, as is actually about stopping the currently playing sound.
Ha, that's true.

Quote from: Ters on May 01, 2017, 06:03:18 PM
A couple of years ago, I tried making an alternative backend for Windows based on DirectX 8. Unfortunately, MinGW32 does not support DirectX 8. It is capable of playing as many sounds as the sound driver can, but it can currently only play one instance of the same sound at the same time. I do however not remember how complete it even is.
Maybe MinGW64 can handle it?

Ters

Quote from: An_dz on May 02, 2017, 12:27:51 AM
Maybe MinGW64 can handle it?

I think so. I haven't looked into that particular API, but it does support many newer ones.

prissi

Use the SDL interface, that can easily play more than one sound. For many reasons I made now SDL2 the default download format.

Simutrans had supported the mixer until in 2004 with XP the API was changed in an uncompatible way and I quickly put in the current routines. (The midi routines are using the mixer.)