Closed gilbertohasnofb closed 8 years ago
About the interruption of the sounds: it seems AW will spawn at most 2 thunderstorms. Each can trigger a flash at most every second. That would mean an upper bound of 18 sounds :sob:
Make sure you use spaces
Just changed my indentation preferences in gedit.
Yes, first thing you can do is replace
1.0 inwith /sim/model/c172p/sound/volume-boost-doors .
Will do that.
About the interruption of the sounds: it seems AW will spawn at most 2 thunderstorms. Each can trigger a flash at most every second. That would mean an upper bound of 18 sounds
Yep, I realised that. Maybe we could convince Thorsten to diminish a bit the number of lightnings for the Thunderstorm theme, but anyway there should be some METAR which produce less lightnings per second
Question: in xml, how do I work with multiple conditions inside an
<condition>
<or>
I think we need a Nasal API to trigger an arbitrary amount of sounds. This would also be useful for the click sounds.
I think we need a Nasal API to trigger an arbitrary amount of sounds.
Yes, that would be ideal. Also, right now the sounds stop when a lightning strikes, not when the thunder sound comes, which makes a clear interruption between thunder sounds. If we managed to at least interrupt the previous playback only at the moment of the new one, the cut would not be so noticiable.
And I fix all the indentation on the previous additions of mine.
I'm writing to the mailing list about it.
Perfect. I just committed now the wind shield rain sound and code. Can you test and see what you think? I included all four internal views.
@gilbertohasnofb I would use <property>/sim/current-view/internal</property>
.
And make sure you indent the whole block to the same level as the other sounds :wink:
Ok!
Should be okay now. Can you test the sounds and see what you think? I particularly like the result :smile:
I don't see <property>/sim/model/c172p/sound/volume-boost-doors</property>
in <thunder>
and <rain>
yet?
No need to add it to <rain-windshield>
, but it can be added to the other two sounds.
You need to check your :eyes: , it's there :wink:
Ok, had to do another git pull
:smile:
No, I am joking, I just added after you wrote me :smile:
Oh, haha. It sounds nice.
How about increasing the volume a bit depending on airspeed?
Oh the windshield rain? Or both?
Just the wind shield.
I just did that, but I am having some troubles setting up the parameters for a decent result. I am actually preferring the constant volume sound.
I'll be AFK for now. If you want to work on the airspeed thing, I think you could add a new <filter>
to Systems/sounds.xml
and then add a <property>
to the <volume>
block of <rain-windshield>
.
About the <position>
element of <rain-windshield>
: you can try to use <x>-0.5</x>
. That should make it directional.
We can use constant volume for now then.
I had added a block:
<volume>
<property>velocities/airspeed-kt</property>
<factor>0.0015</factor>
<min>0.03</min>
<max>0.25</max>
</volume>
Ok, so I will not push. I also have to go, so we continue some other time. Take care and thanks a lot for all the help!
That block might work just as well.
I'll fix <x>
.
It works, but the parameters aren't giving a good result. Let's try some other time to play around with that, if not we leave the constant volume.
I think we need <offset>0.7</offset>
instead.
Inside that volume block?
Yes, let me test.
Ok!
Committed. Create a PR?
Sure. Do you want me to do it myself?
You can create a PR if you want. Just mention this issue in the PR to create a reference on Github.
Ok, I will do that right now.
Shall we merge it now? Thunder sound might need some work (depending on work by core devs) in a new issue.
I would still make the thunder sound volume depend on the distance, what do you think? Then we can merge and wait to see what the core devs say.
Hmm... yeah, I want the rain sounds merged :stuck_out_tongue_winking_eye:
Thunder sound is not good anyway right now because of the interruptions.
I want the rain sounds merged
Hehehe me as well, I like it a lot! So let's just merge it, and then later we see what to do with the thunders.
OK. We can keep the branch and reopen the issue once simgear has been patched.
I'd say let's not delete branch bug-443
yet if we plan to do more work on these thunder sounds.
@onox Here is a crazy idea: if the devs won't implement the feature we need for proper thunder, what about instead of using a simple listener we also use a counter with module 20, so that when the listener detects a change the counter is incremented and it calls one of the 20 copies of the thunder function? Sounds ridiculous and it would look ugly in the code, but it would get the job done I believe.
This function doesn't have a way of finding out if a sound it still active and if so activating a different one, it simply stops the previous sound.
@gilbertohasnofb, you beat me to it. I was getting ready to propose something similar. If we have a var telling us a sound has been played and we know how long that sound is then we have all we need to make our own function to manage the sounds. It doesn't have to be a hack or ugly, it's just done in nasal space instead of c space. I think it could work.
Oh and by the way, great job with this whole implementation.
With that said, I know next to nothing about sound implementation in FG. Can you play multiple sounds at the same time? If so then I don't understand where the problem is exactly. I'll explain if the answer to my last question is true!
I just finished testing the thunder sound implementation, really cool. While I was at it I noticed the engine sound and the thunder at the same time, so multiple sounds can be played at the same time.
So why can't we do something like the following pseudo code? This is a really rough idea of the code, only meant as an example of how it might work. Syntax is not even close to reality but should get the point across.
array thunderSounds=[10][bool=false];
# array of 10 thunderSounds available, all initially set to false (not currently playing)
if thunder is triggered
{
doWhile thunderSounds[randomNumber][true]
{
#loop until we find a sound that is not already playing
thunderSounds[theRandomNumber][now=true];
#found one that is not playing already, make it true (it's playing now)
}
generateSound(theRandomNumber);
}
func generateSound(theRandomNumber){
soundFile = theRandomNumber;
lengthOfSound = lengthOf(soundFile);
playSound(soundFile);
if lengthOfSound is finished
{
thunderSounds[theRandomNumber][false]
}
}
It doesn't have to be a hack or ugly, it's just done in nasal space instead of c space. I think it could work.
Great, so let's try implementing it!
Oh and by the way, great job with this whole implementation.
Thanks a lot, I am taking my first baby steps towards learning Nasal :smile:
Can you play multiple sounds at the same time?
Yes, you can. The problem is not about playing multiple sounds, the problem is that the listener was trigering a same function, which would stop any previous sound it had been playing. So if we had n instances of this function, we could rotate them with a counter+module and thus the problem would be solved. I think 18 or 20 instances would suffice (@onox did the maths yesterday)
This is a really rough idea of the code
I just don't get why you are using randomNumber. I would say that the counter with module 20 is the way to go.
According to: http://wiki.flightgear.org/FlightGear_Newsletter_August_2015#Atmospheric_Light_Scattering
So it would be cool if we implement some thunder sounds in our plane. I can come up with the sound and maybe @onox could give me a hand implementing it.
(Both could be supported if we can spawn sounds at absolute positions).