Giter Site home page Giter Site logo

dariowouters / ts-fmod-plugin Goto Github PK

View Code? Open in Web Editor NEW
40.0 9.0 12.0 2.14 MB

A telemetry plugin for ATS/ETS2 to use FMOD sound mods (to a limited extent) for example in TruckersMP

License: MIT License

C 20.55% C++ 79.45%
ats american-truck-simulator ets2 euro-truck-simulator-2 truckersmp

ts-fmod-plugin's Introduction

FMOD sound plugin for ATS/ETS2

A telemetry plugin for ATS/ETS2 that includes an FMOD instance so that you can use FMOD sound mods.

This is pretty useless in singleplayer because you could just load the mod directly in the game.
But since I'm mostly playing TruckersMP, where sound mods are not supported (which are much better than the base game sounds), this is something I kinda quickly put together after the broken sounds in 1.37 TruckersMP, and then didn't really update it once it worked except for fixing some bugs and making it compatible with the newer versions, so it is pretty basic.

Currently this uses a mix of the telemetry channels provided by the SCS sdk and directly reading values from the game's memory.

I'm not that great at c(++) and reverse engineering so it might just stay this way, and also with more reverse engineering making updating slower and more complicated.

Some limitations/issues

  • Will keep playing sound even when alt-tabbed.
  • Sound level/direction does not change with the camera, the sound is always as if you are in the truck looking forward, with the exception of interior sounds not being played when on an exterior camera.
  • You will need to mute or lower some of the in-game audio channels for your truck (or you will hear double audio).
  • Can (and most probably will) break and possibly crash your game with every major game update because it needs to read some values directly from memory, and this structure can change with updates.
  • Only very basic volume control (might look into something better/easier in the future).
  • Probably some more that I forgot.

How to use

Download the latest release, copy the ts-fmod-plugin.dll and the ts-fmod-plugin folder to <game_install_location>/bin/win_x64/plugins. (if the plugins folder does not exists, you can create one)
Copy the master.bank file from the Release for the specific game you are installing it to and copy it to the ts-fmod-plugin folder.

Here's the correct folder structure:

<game_install_location>/bin/win_x64/eurotrucks2.exe # or amtrucks.exe for ATS
│   ... # hidden to keep this list smaller
│
└───plugins # create if not existsts-fmod-plugin.dll # copy from release
    │
    └───ts-fmod-plugin # copy from release
            master.bank # copy from specific game folder in release
            selected.bank.txt # copy from release | edit text in file with sound mod filename(s) you want
            sound_levels.txt # copy from release | edit the sound levels to your liking
            the_sound_mod_you_want_to_use.bank # example of sound mod
            the_sound_mod_you_want_to_use.bank.guids # example of sound mod

For any sound mods you want to add you have to copy the (usually located in /sound/truck/) <sound_mod_name>.bank and the <sound_mod_name>.bank.guids files from the mod to the ts-fmod-plugin folder, and then open the selected.bank.txt file in a text editor and change the text in the file to the filename of the mod (without the file extension).
So for example if the sound mod files are named sound_mod.bank and sound_mod.bank.guids you have to change the text in the selected.bank.txt file to sound_mod.

You can load multiple sound banks at the same time by having the sound banks in selected.bank.txt each on a new line. These sound banks will be loaded top to bottom. If multiple sound banks include the same sound event it will only load the event from the first sound bank.

Now you can load the game and the sound should work when you start your truck.

Some extra info

You will generally need to mute/lower the truck engine, exhaust and turbo sound channels in the in-game settings to prevent double sounds. If the sound mod you're using includes interior sounds you will also have to mute/lower them in-game.

For using navigation sound mods you have to have the voice navigation enabled (with a voice pack selected) in the game settings, but the 'Voice navigation volume' needs to be muted.

If you have the developer console enabled in-game you can switch sound mods without restarting by changing the filename in selected.bank.txt and then in the game console enter sdk reload. This will reload all telemetry plugins and cause this plugin to load the newly selected sound mod.

You can change the sound levels in the sound_levels.txt file, you will just kind of need to play with them until you get something you like. Again you can use the sdk reload console command after you've changed these to reload the plugin with these new values.

Supported FMOD events and parameters

Events:

  • engine/engine
  • engine/exhaust
  • engine/turbo
  • interior/air_warning
  • interior/blinker_on (and off)
  • interior/stick_blinker (and off)
  • interior/stick_park_brake (and off)
  • interior/stick_retarder
  • interior/stick_hazard_warning
  • interior/stick_high_beam
  • interior/stick_light_horn
  • interior/stick_lights
  • interior/stick_wipers
  • interior/window_move
  • interior/window_click
  • and_then_exit_left
  • and_then_exit_right
  • and_then_go_straight
  • and_then_keep_left
  • and_then_keep_right
  • and_then_turn_left
  • and_then_turn_right
  • compound_exit_left
  • compound_exit_right
  • compound_go_straight
  • compound_keep_left
  • compound_keep_right
  • compound_turn_left
  • compound_turn_right
  • exit_left
  • exit_now
  • exit_right
  • finish
  • go_straight
  • keep_left
  • keep_right
  • prepare_exit_left
  • prepare_exit_right
  • prepare_turn_left
  • prepare_turn_right
  • recomputing
  • roundabout_1
  • roundabout_2
  • roundabout_3
  • roundabout_4
  • roundabout_5
  • roundabout_6
  • speed_signal
  • speed_warning
  • start
  • turn_left
  • turn_right
  • u_turn

Parameters:

  • brake
  • load
  • rpm
  • wnd_left (and right)
  • surr_type
  • cabin_rot
  • cabin_out

ts-fmod-plugin's People

Contributors

dariowouters avatar pupplestar77 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ts-fmod-plugin's Issues

Support future game versions

Hello,

I can see that it is challenging to predict future game versions and in the same time keep plugin working for the largest number of game binary versions.

To do it effectively, you could first verify what you need, if it fails, then inform user that different plugin version is needed, if it succeeds let it load.
To make it happen, you could use __try and __except keywords.
https://stackoverflow.com/a/7049836

int FilterException(int code, PEXCEPTION_POINTERS ex) {
    return EXCEPTION_EXECUTE_HANDLER;
}

void SomeCheckingOfNeededGameStuff()
{
  // check if game_ctrl_u object is really game_ctrl
  // check if game_actor_u object is really game_actor
  // etc
  // if anything goes bad and throws exception, it will be catched in __except block.
}

bool ShouldPluginBeRunning()
{
    __try {
        SomeCheckingOfNeededGameStuff();
        return true; // all went fine
    }
    __except(FilterException(GetExceptionCode(), GetExceptionInformation())) {
        return false;
    }
}

Real code might be different, and I am not sure if you can return false just like that from __except block. But I think it should be all possible.

Thank you for understanding.

Write game events from external source.

Hello.

I need a small help.

I want create a custom fines (etc: Driving time exceeded). Your plugin can write datas to ETS2/ATS or just read it?

Thank you.

ATS v1.49 Crashes on startup/sdk reload

Hi.
Game crashes after editing "selected.bank.txt" and doing a sdk reload on console, or simply after loading the profile once .txt is edited (it crashes on loading screen).

On thing i noticed on "game.log.txt" (under the same release, v1.49) is that ETS2 says this:

00:00:26.605 : [ts-fmod-plugin V1.49] Searching for memory offsets... If this is one of the last messages in the log after a crash, try disabling this plugin after choosing profile.
00:00:26.616 : [ts-fmod-plugin] Found base_ctrl @ 1d079a0 and unk_interior @1d07998
00:00:26.718 : [ts-fmod-plugin] Found output device[0] Altavoces (Realtek(R) Audio)
00:00:26.718 : [ts-fmod-plugin] Found output device[1] Realtek Digital Output (Realtek(R) Audio)
00:00:26.718 : [ts-fmod-plugin] Found output device[2] VoiceMeeter Aux Input (VB-Audio VoiceMeeter AUX VAIO)
00:00:26.719 : [ts-fmod-plugin] Found output device[3] 1 - LG IPS FULLHD (AMD High Definition Audio Device)
00:00:26.719 : [ts-fmod-plugin] Found output device[4] VoiceMeeter Input (VB-Audio VoiceMeeter VAIO)
00:00:26.719 : [ts-fmod-plugin] Selecting default output device (0)
00:00:26.888 : [ts-fmod-plugin] Using sound bank[0]: 'rckps_v8op'
00:00:26.888 : [ts-fmod-plugin] Loading the events and busses for 'rckps_v8op'
00:00:26.909 : [ts-fmod-plugin] Loading event 'engine/engine'
00:00:26.909 : [ts-fmod-plugin] Loading event 'engine/exhaust'
00:00:26.909 : [ts-fmod-plugin] Loading event 'engine/start_bad'
00:00:26.909 : [ts-fmod-plugin] Loading event 'engine/turbo'
00:00:26.909 : [ts-fmod-plugin] Did not find any navigation event. You will not have navigation voices.
00:00:26.926 : [ts-fmod-plugin] Plugin loaded

Note: ETS2 works fine, that's after selecting a .bank

...while on the ATS "game.log.txt" says:

00:03:14.009 : [ts-fmod-plugin V1.46] Searching for economy offset... If this is one of the last messages in the log after a crash, try disabling this plugin.
00:03:14.031 : [ts-fmod-plugin] Found economy offset &1d04528
00:03:14.144 : [ts-fmod-plugin] Found output device[0] Altavoces (Realtek(R) Audio)
00:03:14.144 : [ts-fmod-plugin] Found output device[1] Realtek Digital Output (Realtek(R) Audio)
00:03:14.145 : [ts-fmod-plugin] Found output device[2] VoiceMeeter Aux Input (VB-Audio VoiceMeeter AUX VAIO)
00:03:14.145 : [ts-fmod-plugin] Found output device[3] 1 - LG IPS FULLHD (AMD High Definition Audio Device)
00:03:14.145 : [ts-fmod-plugin] Found output device[4] VoiceMeeter Input (VB-Audio VoiceMeeter VAIO)
00:03:14.145 : [ts-fmod-plugin] Selecting default output device (0)
00:03:14.267 : [ts-fmod-plugin] Using sound bank[0]: '903_v8'
00:03:14.267 : [ts-fmod-plugin] Loading the events and busses for '903_v8'
00:03:14.284 : [ts-fmod-plugin] Setting sound level for 'master' to 0.5
00:03:14.284 : [ts-fmod-plugin] Setting sound level for 'engine' to 0.5
00:03:14.284 : [ts-fmod-plugin] Setting sound level for 'exhaust' to 0.5
00:03:14.284 : [ts-fmod-plugin] Setting sound level for 'turbo' to 0.5
00:03:14.284 : [ts-fmod-plugin] Setting sound level for 'interior' to 1
00:03:14.284 : [ts-fmod-plugin] Setting sound level for 'exterior_when_windows_closed' to 0.75
00:03:14.284 : [ts-fmod-plugin] Plugin loaded

If i'm missing something or need anything for further debug, please let me know.
Have a nice day/night!

SCS Update 1.45

This has ceased to work on both ATS and ETS 2 with Open Beta 1.45.*
I am not saying this in a whining fashion but just to let you know if you don't already and I will patiently await the update for 1.45.*

Many Thanks

ATS 1.48 UPDATE

Just letting you know ATS has been updated to 1.48, The mod no longer works it crashers the game due to incompatibility.
Thank so much.

Events don't work

So, I was using a sound mod with ts fmod plugin, but I had to reinstall the game, I placed the plugins and the ts fmod archives just in the same way as they were before, turns out that now the sound mod doesn't work and when I check the in-game console the following errors display
plugin error

ets2 1.47 fix

when the game is loading the engine already starts i cant find a fix for this maybe you can help i always use your plugin

t.i.a.

new game ver.

Is there an easy way to make this add-on compatible with the new game version? So can you briefly explain how it's done?

This isn't an issue, more a request for info / help

Hi there, love this plugin, the game is so much better with it, my request for info / help is this:

I have an air brake sound mod that I use, can this be added to this plugin?

I have tried to see if it works myself but have had no joy, any help on this would be much appreciated.

Thanks in advance

Карта ATS

Нет возможности сделать карту ATS - выдает ошибку при создании
Операция прервана (Исключение из HRESULT: 0x80004004 (E_ABORT))

1.46 ATS

ATS 1.46 Has dropped and sound pack don't work again due to update.

Thanks

Implement navigation_sound_event feature

Euro Truck Simulator 2 (ETS2) has navigation voice sounds in numerous languages. However, there are still unsupported countries and languages, and there are also many low-quality voice instructions. In the Multi-mode(TruckerMP), Eurotruck mode is not available. Therefore, I implemented the navigation_sound_event feature using the provided code.
I am not good with English, C++, and reverse engineering, but I have tried my best and put in a lot of effort.
This feature allows receiving navigation event sounds. Before proceeding with a pull request, I want to confirm if it is needed and desired by the project maintainers.

The new classes added are:

class sound_event_t
{
    class sound_player* sound_player; //0x0000
    char pad_0008[0x28];              //0x0008
    uint32_t is_playing;              //0x0030  1:playing, 4:stop? maybe?
    uint32_t something;               //0x0034
    class gl* glsl;                   //0x0038
    char pad_003c[0x18];              //0x0040
    class gl* glsl2;                  //0x0060
    char* sound_event_name_with_file; //0x0060
    char pad_0068[0x50];              //0x0068

public:
    uint32_t get_is_playing() const {
        return is_playing;
    }
    const char* const get_sound_event_name_with_file_name() const {
        return sound_event_name_with_file;
    }
};


class navigation_sound_event
{
    uint32_t pad_0000;                  //0x0000
    uint32_t pad_0004;                  //0x0004
    char *event_name;                   //0x0008
    uint32_t pad_0010;                  //0x0010
    uint32_t pad_0014;                  //0x0014
    class navigation* navi_instance;    //0x0018
    sound_event_t *sound_event;          //0x0020

public:
    sound_event_t *get_sound_event() const{
        return sound_event;
    }
    char* get_event_name() const {
        return event_name;
    }
};

To utilize the feature, you can use the following code snippet:

navigation_sound_event** ev = (unk_interior_parent->get_navigation_sound_events());
            for (short i = 0; i < unk_interior_parent->get_navigation_sound_events_count(); i++)
            {
                auto snd = ev + i;
                auto  now = (*snd)->get_sound_event()->get_is_playing();
                if (now == 1)
                {
                    if (played.size() < i)
                    {
                        played.resize(i + 1);
                    }
                    if (now != played[i])
                    {
                        fmod_manager_instance->set_event_state((*snd)->get_event_name(), true, true);
                        {
                            std::stringstream ss;
                            ss << "[ts-fmod-plugin] PlaySound : " << (*snd)->get_event_name();
                            scs_log(0, ss.str().c_str());
                        }
                    }
                }
                if (played.size() < i)
                {
                    played.resize(i + 1);
                }
                played[i] = now;

            }

ntdll error.

When I use sdk reload twice(not in the same time)

I'm having this error:

image

.NET is installed.
Runtimes are installed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.