Author Topic: Parallel sounds  (Read 583 times)

0 Members and 1 Guest are viewing this topic.

Offline Leartin

  • Devotee
  • *
  • Posts: 843
  • Total likes: 301
  • Helpful: 44
  • !!!!!This user was banned for double posting!!!!!
  • Languages: DE, EN
Parallel sounds
« on: May 01, 2017, 09:31:02 AM »
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?

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4861
  • Total likes: 201
  • Helpful: 108
  • Languages: EN, NO
Re: Parallel sounds
« Reply #1 on: May 01, 2017, 10:37:52 AM »
The sound backends are very rudimentary, or at least some of them are.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15846
  • Total likes: 406
  • Helpful: 177
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Parallel sounds
« Reply #2 on: May 01, 2017, 12:13:50 PM »
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.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2594
  • Total likes: 290
  • Helpful: 89
  • D'oh
    • by An_dz
  • Languages: PT, EN, (it, de)
Re: Parallel sounds
« Reply #3 on: May 01, 2017, 04:57:56 PM »
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

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4861
  • Total likes: 201
  • Helpful: 108
  • Languages: EN, NO
Re: Parallel sounds
« Reply #4 on: May 01, 2017, 06:03:18 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.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2594
  • Total likes: 290
  • Helpful: 89
  • D'oh
    • by An_dz
  • Languages: PT, EN, (it, de)
Re: Parallel sounds
« Reply #5 on: May 02, 2017, 12:27:51 AM »
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.

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?

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4861
  • Total likes: 201
  • Helpful: 108
  • Languages: EN, NO
Re: Parallel sounds
« Reply #6 on: May 02, 2017, 05:35:36 AM »
Maybe MinGW64 can handle it?

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

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8821
  • Total likes: 322
  • Helpful: 229
  • Languages: De,EN,JP
Re: Parallel sounds
« Reply #7 on: May 02, 2017, 06:22:33 AM »
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.)