leezer3 / OpenBVE

OpenBVE- A free train simulator
http://www.openbve-project.net
275 stars 52 forks source link

[Request][Train plugin]Control position of sounds played via the plugin #746

Open HUN-Droid opened 2 years ago

HUN-Droid commented 2 years ago

Description

I can write a plugin, which can handle, which sound should be played on which car. But the sounds are played at the front of the selected car, and it cannot be parameterized, where the sound source is in the car. I would be happy if it could be parameterized either in the sound.cfg file or from the plugin via OpenBveApi.Runtime.PlayCarSoundDelegate. Not only the speed, volume, continuity (looped or not) and the car of the sound, but also the exact position inside the car. It is possible, to set the position of the sound in .animated files, but I didn't find any way to do this from the plugin. I didn't find this feature, but if it exists, please let me know! Thanks!

leezer3 commented 2 years ago

Convert the train to XML format, and it'll allow this, by editing the position tag for each CarSound entry.

I'm deliberately now trying to avoid any major extensions to the legacy formats, as this just creates a bigger mess.

ginga81 commented 2 years ago

If you want to use each car sound immediately, you can use FMS.

https://sites.google.com/view/d-redtrain/bvedata/ats/fmsplugin?authuser=0

FMS, Five Motor Sound can use unlimited sound the same as Bve5. If you write to CarList section that is what numbers of the motorcars, each motor cars sounds as your request.

Please read my manual how to use. https://bveworldwide.forumotion.com/t2171-now-the-openbve-s-motor-and-brake-sound-tracks-are-become-unlimited#20880

HUN-Droid commented 2 years ago

Convert the train to XML format, and it'll allow this, by editing the position tag for each CarSound entry.

Is there any documentation from this? The https://openbve-project.net/documentation_hugo/en/trains/train_xml.html site is not enough to this problem.

HUN-Droid commented 2 years ago

@ginga81 I don't want to use any external dll files, programs or code. More and more licenses and restrictions would be needed, and I don’t want that at all. That's why I just want to know and use the features of OpenBVE.

leezer3 commented 2 years ago

Sorry, documentation updates have never been a strong point :/

If you give the main site a little while to update, the XML train sound format should now be there. (n.b. Still a WIP, and there may possibly be one or two bits I've missed)

Possibly the easiest way to demonstrate is probably to run an existing train through CarXMLConvertor.

HUN-Droid commented 2 years ago

@leezer3 I see, that the documentation isn't the strongest point of this project :D I hate writing documentation too, but I know, if someone else wants to use my app/code, they need it. And I need it too, when I extending my code 2 years later :D

leezer3 commented 2 years ago

At the minute, we load the train.dat first, then the XML file, primarily because the implementation of this format has been a somewhat gradual affair. The convertor may not sort motor sounds either, would need to check that....

Object Viewer should support the XML, I think if you drop in the train.dat. Ought to support the XML too, again will need to check that.

Coupler objects: Add an <Object> node to the coupler definition.

leezer3 commented 2 years ago

Updated the documentation some more, give it a little while :)

Mixing seperate car files and couplers is fine, they just need to go in order, e.g.

<?xml version="1.0" encoding="utf-8"?>
<openBVE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Train>
        <Car>Car0.xml</Car>
        <Coupler>
            <Minimum>0</Minimum>
            <Maximum>1</Maximum>
            <Object>coupler.b3d</Object>
        <Coupler>
        <Car>Car1.xml</Car>
        <Coupler>
            <Minimum>1</Minimum>
            <Maximum>1</Maximum>
            <Object>coupler1.b3d</Object>
        <Coupler>
        <Car>Car2.xml</Car>
        <Car>Car3.xml</Car>
        <Car>Car4.xml</Car>
        <Car>Car5.xml</Car>
        <Car>Car6.xml</Car>
        <Car>Car7.xml</Car>
        <Car>Car8.xml</Car>
    </Train>
</openBVE>

Will try and look at the convertor later / tomorrow.

HUN-Droid commented 2 years ago

@leezer3 Thanks the works! I have another question: do you plan to convert the ats.cfg and train.txt files into an xml file? Maybe to a node in the train.xml? Or this is available, but not yet documented?

leezer3 commented 2 years ago

Nothing (yet...)

leezer3 commented 2 years ago

Latest build will accept the following (and converted via CarXMLConvertor):

...
<Plugin>BVEC_ATS.dll</Plugin>
<Description>British Railways Class 52 'Western' - D1015
-------------------------------------------

This locomotive runs on the latest version of the BVEC_ATS
train systems plugin, and represents what I feel to be a
very reasonable portrayal of the prototype!
Feature Include:
* Single and twin engine operation.
* Prototypical startup sequence.
* Working turbocharger.
* Working AWS.
* Full external view.

As with all of my recent products, this locomotive has been
designed to work on any platform that OpenBVE supports.

This release has been configured with a full set of 8 MK1 
coaches on the drawhook (280 tons!)

Driver's Guide
--------------

http://www.bvecornwall.co.uk/wordpress/br-class-52-western-drivers-guide/</Description>
...
HUN-Droid commented 2 years ago

@leezer3 Should these two new parts be between the and tags? At the same level with the and tags? Or inside one of the tags? If I had to guess from the documentation, I'd do this (not yet tried): \ \ \car.xml\ \ ... \ \car.xml\ \plugin.dll\ \ ... \ \ \ Please check, is this correct?

leezer3 commented 2 years ago

Correct, within the train tags.