got sound modifiers working, by registering my own type o.O
Code: Select all
g_soundManager:registerModifierType("LOGS_WINCH", LogsWinch.pitchModifierFunc, LogsWinch.pitchModifierMinFunc, LogsWinch.pitchModifierMaxFunc)
Anyone tried using g_soundManager:registerModifierType already, to define his own modifiers?
by official luadoc it accepts three functions. However signature of them is unknown,. I know what their return values have to be, but do not know how to connected them to sound samples.
oh yeah sounds finally work as they should
with custom modifier type
so for tajfun I got sound defined like this:
Code: Select all
<sounds>
<running file="$data/sounds/vehicles/retarder/retarder_loop_01.ogg">
<volume indoor="1.0" outdoor="1.0">
<modifier type="LOGS_WINCH" value="0.00" modifiedValue="0.3" />
<modifier type="LOGS_WINCH" value="1.00" modifiedValue="0.75" />
</volume>
<pitch indoor="1.0" outdoor="1.0" >
<modifier type="LOGS_WINCH" value="0.00" modifiedValue="0.8" />
<modifier type="LOGS_WINCH" value="0.50" modifiedValue="0.61" />
<modifier type="LOGS_WINCH" value="1.00" modifiedValue="0.65" />
</pitch>
</running>
</sounds>
"value" and "modifiedValue" are like keyframes in animations. So "value" defines timeline of modifier, where usually we have timeline from 0 to 1 and modifiedValue on the otherhand is a factor with which indoor/outdor values are multiplied in given time. so
Code: Select all
<modifier type="LOGS_WINCH" value="0.00" modifiedValue="0.8" />
-> actually gives you outdoor*modifiedValue when modifier is at value 0. now "value" for the timeline is sth that was causing problems to me. I didn't know how to change it in code. it turns out that it is return value from registerModifierType "func" argument
PölöToday at 3:03 PM
Does it increase/decrease in linear manner between the values, or by stepping always to next stage when the value is reached?
50kedaToday at 3:04 PM
well that is on the code to decide, "func" function is sth that you write for your modifier type, so it's on you what you return. I currently don't have any interpolation done, but could have
Eep²Today at 3:25 PM
still no generic way to play a sound without having to define a mod type?
50kedaToday at 3:25 PM
niouce everything with sounds finally works as it should
sure it is
but old way of changing pitch and volume dynamically doesn't work as expected
which makes perfect sense to me now as I understand how modifiers work
you have zero extra code for any sound change
only thing you care is setting your modifier value on sound sample properly