Implementation of Extra Horn Sounds

If you have suggestions on how to make the game better, post here. Preferred is to discuss the ideas until they mature into something worth implementing.

Implementation of Extra Horn Sounds

Postby Kawasaki_Plant on Thu, 29th Oct 2009, 21:09

Hello Michelle,

It is apparent that BVE2 and BVE4 are only capable of handling 2 horn sounds at the max using the sounds of Klaxon0 and Klaxon1. I was wondering if you could implement a 3rd 4th and maybe even 5th horn through the openBVE controls chart and selecting an option that would use the sounds of Klaxon2, Klaxon3, and so on. I was thinking about this because some trains have extra announcements and require the extra 2 to be played.

Thanks for your time!

-Simon
Kawasaki_Plant
 
Posts: 66
Joined: Thu, 29th May 2008, 01:45

Re: Implementation of Extra Horn Sounds

Postby Guille3600 on Thu, 29th Oct 2009, 21:32

I thought the other day the posibility to make like a "playlist" for the station announcements with a key. Is this possible?
Guille3600
 
Posts: 6
Joined: Sat, 24th Oct 2009, 21:31
Location: Valencia, Spain

Re: Implementation of Extra Horn Sounds

Postby sladen on Thu, 29th Oct 2009, 21:55

It should be possible to do this with Track.Beacon input to a plugin to trigger the sound at the correct point.
sladen
 
Posts: 99
Joined: Wed, 15th Apr 2009, 23:56

Re: Implementation of Extra Horn Sounds

Postby Kawasaki_Plant on Thu, 29th Oct 2009, 22:56

I understand, but the ability of implementing such a function would put the driver in more command of things. Anyways, this function would be a great improvement to add for this already fantastic product.
Kawasaki_Plant
 
Posts: 66
Joined: Thu, 29th May 2008, 01:45

Re: Implementation of Extra Horn Sounds

Postby alvinwong on Sat, 31st Oct 2009, 14:34

There are three built-in (but only two work by pressing one button and play once).
If you make use of plugin, there will be a maximum of 256 more.
Problems, solutions, problems, solutions...
Tired on these, and trying to make openBVE train Exterior, then...
Problems... ###again### Crazy...
Please visit http://www.hochun.nets.hk/discuz/index.php
User avatar
alvinwong
 
Posts: 218
Joined: Sat, 24th Jan 2009, 05:16
Location: Hong Kong

Re: Implementation of Extra Horn Sounds

Postby Kawasaki_Plant on Sat, 31st Oct 2009, 15:27

That's what I'm aware of. But since I know very limited coding, I do not have the capability of creating such a plugin, so I'm asking anybody to make one.
Kawasaki_Plant
 
Posts: 66
Joined: Thu, 29th May 2008, 01:45

Re: Implementation of Extra Horn Sounds

Postby alvinwong on Sat, 31st Oct 2009, 15:52

Em...

plugin.cpp: (explain later)
Code: Select all
#include "plugin.h"
#include <windows.h>

bool horn1, horn2;

extern "C" {

    // called when the plugin is loaded
    ATS_API void WINAPI Load () {
      horn1=false;
      horn2=false;
    }

    // called when the plugin is unloaded
    ATS_API void WINAPI Dispose () {
    }

    // called to query the API version
    ATS_API int WINAPI GetPluginVersion () {
        return ATS_VERSION;
    }

    // called to inform the plugin about the specs of the train
    ATS_API void WINAPI SetVehicleSpec (ATS_VEHICLESPEC vehicleSpec) {
    }

    // called to inform the plugin about the starting mode of the security system
    ATS_API void WINAPI Initialize (int brake) {
    }

    // called every frame
    ATS_API ATS_HANDLES WINAPI Elapse (ATS_VEHICLESTATE vehicleState, int* panel, int* sound) {
      if (horn1) {
         if (sound[0]==ATS_SOUND_PLAY) {
            sound[0]=ATS_SOUND_CONTINUE;
            horn1=false;
         } else
            sound[0]=ATS_SOUND_PLAY;
         }
      }
      if (horn2) {
         if (sound[1]==ATS_SOUND_PLAY) {
            sound[1]=ATS_SOUND_CONTINUE;
            horn2=false;
         } else
            sound[1]=ATS_SOUND_PLAY;
         }
      }
    }

    // called when the power notch is changed
    ATS_API void WINAPI SetPower (int notch) {
    }

    // called when the brake notch is changed
    ATS_API void WINAPI SetBrake (int notch) {
    }

    // called when the reverser is changed
    ATS_API void WINAPI SetReverser (int pos) {
    }

    // called when a plugin key is pressed
    ATS_API void WINAPI KeyDown (int atsKeyCode) {
        switch(atsKeyCode){
            case ATS_KEY_S:  // SECURITY_S     Space
                // nothing
                break;
            case ATS_KEY_A1: // SECURITY_A1    Insert
                // nothing
                break;
            case ATS_KEY_A2: // SECURITY_A2    Del
                // nothing
                break;
            case ATS_KEY_B1: // SECURITY_B1    Home
                // nothing
                break;
            case ATS_KEY_B2: // SECURITY_B2    End
                // nothing
                break;
            case ATS_KEY_C1: // SECURITY_C1    Page up
                // nothing
                break;
            case ATS_KEY_C2: // SECURITY_C2    Page down
                // nothing
                break;
            case ATS_KEY_D:  // SECURITY_D     2
            horn1=true;
                // nothing
                break;
            case ATS_KEY_E:  // SECURITY_E     3
            horn2=true;
                // nothing
                break;
            case ATS_KEY_F:  // SECURITY_F     4
                // nothing
                break;
            case ATS_KEY_G:  // SECURITY_G     5
                // nothing
                break;
            case ATS_KEY_H:  // SECURITY_H     6
                // nothing
                break;
            case ATS_KEY_I:  // SECURITY_I     7
                // nothing
                break;
            case ATS_KEY_J:  // SECURITY_J     8
                // nothing
                break;               
            case ATS_KEY_K:  // SECURITY_K     9
                // nothing               
                break;               
            case ATS_KEY_L:  // SECURITY_L     0
                // nothing               
                break;
            default:
                // nothing
                break;
        }
    }

    // called when a plugin key is released
    ATS_API void WINAPI KeyUp (int atsKeyCode) {
        switch(atsKeyCode){
            case ATS_KEY_S:  // SECURITY_S     Space
                // nothing               
                break;               
            case ATS_KEY_A1: // SECURITY_A1    Insert
                // nothing               
                break;               
            case ATS_KEY_A2: // SECURITY_A2    Del
                // nothing               
                break;               
            case ATS_KEY_B1: // SECURITY_B1    Home
                // nothing               
                break;               
            case ATS_KEY_B2: // SECURITY_B2    End
                // nothing               
                break;               
            case ATS_KEY_C1: // SECURITY_C1    Page up
                // nothing               
                break;               
            case ATS_KEY_C2: // SECURITY_C2    Page down
                // nothing               
                break;               
            case ATS_KEY_D:  // SECURITY_D     2
                // nothing               
                break;               
            case ATS_KEY_E:  // SECURITY_E     3
                // nothing               
                break;               
            case ATS_KEY_F:  // SECURITY_F     4
                // nothing               
                break;               
            case ATS_KEY_G:  // SECURITY_G     5
                // nothing               
                break;               
            case ATS_KEY_H:  // SECURITY_H     6
                // nothing               
                break;               
            case ATS_KEY_I:  // SECURITY_I     7
                // nothing               
                break;               
            case ATS_KEY_J:  // SECURITY_J     8
                // nothing               
                break;               
            case ATS_KEY_K:  // SECURITY_K     9
                // nothing               
                break;               
            case ATS_KEY_L:  // SECURITY_L     0
                // nothing               
                break;
            default:
                // nothing
                break;
        }
    }

    // called when a horn is played (or stopped)
    ATS_API void WINAPI HornBlow (int hornType) {
    }

    // called when the doors start opening
    ATS_API void WINAPI DoorOpen () {
    }

    // called when the doors have closed
    ATS_API void WINAPI DoorClose () {
    }

    // called when the state of the upcoming signal changes
    ATS_API void WINAPI SetSignal (int signal) {
    }

    // called when a beacon is passed
    ATS_API void WINAPI SetBeaconData (ATS_BEACONDATA beaconData) {
    }

}
Problems, solutions, problems, solutions...
Tired on these, and trying to make openBVE train Exterior, then...
Problems... ###again### Crazy...
Please visit http://www.hochun.nets.hk/discuz/index.php
User avatar
alvinwong
 
Posts: 218
Joined: Sat, 24th Jan 2009, 05:16
Location: Hong Kong

Re: Implementation of Extra Horn Sounds

Postby michelle on Sat, 31st Oct 2009, 17:26

Essentially, manual station announcements are a good idea, but there are a number of problems for any current implementation. More horns in general is problematic either way.

First of all, the way station announcements work in a real train can differ greatly. On some trains, the driver makes a manual announcement via microphone, on others, the driver might press a button that plays the announcement and automatically increments it to the next station, on others, the selection of sounds might be beacon-assisted, on otherrs, the player may need to manually hit a play and pause button (e.g. old-fashioned tape), on others, the driver might need to specifically select the sound to be played from a terminal, etc... Endless variations on how it can be done.

Any manual variant with new horn keys as Kawasaki_Plant suggested is impractical in general, because there isn't an endless amount of keys available on the keyboard. How about 10 new horns? Well, a route with 11 stations would be problematic then. So how about 20? Then, 21 stations would be problematic. So how about 100? In the end, it's not only impractial to assign the sounds to the keyboard, but also to play them manually by having to remember the right key.

Eventually, if the driver makes an announcement via microphone manually, the best way would be to incorporate the right sound via additions to the route format (e.g. similar to Track.Announce), but then have a single key the player can press at any time to actually play the sound (i.e. make the announcement). Anything more or less computer or tape-based differs too greatly in the way it works and is best left to (future) plugins.

Either way, the general idea is on my consideration list for openBVE's successor.
User avatar
michelle
Site Admin
 
Posts: 1135
Joined: Mon, 14th Apr 2008, 20:36


Return to Suggestion Corner

Who is online

Users browsing this forum: No registered users and 0 guests