c172p-team / c172p

A high detailed version of the Cessna 172P aircraft for FlightGear
GNU General Public License v2.0
78 stars 44 forks source link

Improve stall horn sound #85

Closed gilbertohasnofb closed 9 years ago

gilbertohasnofb commented 9 years ago

improve stall horn sound, use this as reference: https://www.youtube.com/watch?v=4tLWIvnVnCQ#t=42

gilbertohasnofb commented 9 years ago

(as a reference, listen to this stall horn at 0:35 of this video. This is the sound I analysed for that synthesis: https://www.youtube.com/watch?v=zTq8Jvoks2U )

onox commented 9 years ago

@gilbertohasnofb Yours sound a little bit better, but both sound artificial. If we decide to use this, then we need to make sure we can accurately adjust the volume and pitch during a stall, so that it will sound like a screaming kitty :crying_cat_face: just like in those YouTube video's.

onox commented 9 years ago

Please create a branch bug-85 and a PR in that case.

gilbertohasnofb commented 9 years ago

both sound artificial

I agree completely, but that's the route that was decided. So now it's up to the magicians/programmers among us to implement this in a realistic way. I can of course cater to what is needed (e.g., I can create other variations of the stall sound, or a version that is cracking instead of constant, etc.).

Please create a branch bug-85 and a PR in that case.

Okay, I can do that, but from my part this will be only an upload of a wav file, nothing more. I really can't program in Nasal.

onox commented 9 years ago

Okay, I can do that, but from my part this will be only an upload of a wav file, nothing more. I really can't program in Nasal.

That's ok. As long as it's in a separate branch.

gilbertohasnofb commented 9 years ago

Okay, I will do that! Could you please tell me how to create a branch on my local repository?

onox commented 9 years ago
  1. Check you're in master: git branch
  2. git pull
  3. git checkout -b bug-85
  4. Add the .wav file
gilbertohasnofb commented 9 years ago

Okay, I did that all, then added, committed and pushed it, but I can't see the branch bug-85 on our repository using the GitHub webpage.

And by the way, the option -b on git checkout means what? Does it create a new branch in case it doesn't exist?

onox commented 9 years ago

-b means you create the branch and then do a checkout. git pull gives me nothing. Can you do git branch and tell me what you see?

gilbertohasnofb commented 9 years ago

I see:

andgi-add-water-sounds
    bug-238
    bug-80
* bug-85
    master

I was reading that I may need to push using git push -A -u instead of git push -A. Does that make sense to you?

onox commented 9 years ago

You need to do: git push -u origin bug-85

gilbertohasnofb commented 9 years ago

Done. Thanks a lot for the help, onox!

onox commented 9 years ago

Ok, now I get it:

remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/Juanvvc/c172p-detailed
 * [new branch]      bug-85     -> origin/bug-85
Already up-to-date.

Thanks! :+1:

dany93 commented 9 years ago

@wkitty42 has written https://github.com/Juanvvc/c172p-detailed/issues/117#issuecomment-112890435

the idea is to find the pressures at the two points on the wing related to the stall horn... point A at the front (where you suck on the stall horn to test it) where the air exits the stall horn and point B where the high pressure air enters the stall horn's air scoop to be directed through the reed or valve assembly...

the idea is if we know the pressures at these two points, we can then calculate (or fake) the speed of the air through the reeds or valves... that speed will determine the pitch of the note..

if we can get qbar(??) from the front edge of the wing and from the bottom of the wing where the pressure is higher when in a stall, this might work out...

In JSBSim, qbar-psf is the dynamic pressure 1/2*ro*V^2. General value, not the detailed values at different locations. I think that these detailed value are not available (I do not know everything from JSBSim, if you find them, please tell me).

Even assuming that you have these differences,

we can then calculate (or fake) the speed of the air through the reeds or valves... that speed will determine the pitch of the note..

How?

As I've written here https://github.com/Juanvvc/c172p-detailed/issues/117#issuecomment-112883955 @dany93 wrote

I rather think you will have to use the AoA. It is the best indicator, admitted by everyone. By a non-linear relation if you prefer, you do all that you want. Anyway, at best imagine you have the pressure (difference), you have to apply a law to transform it into a note. And you ignore the physical law. Non linear for sure. The pitch and volume of the note are connected to the pressure by a law that you do not know, and the pressure is connected to the AoA, maybe to the velocity too. As the AoA is directly available, better to use the AoA. In any case you have to guess a law. You can add a velocity contribution if you wish, but with no better knowledge of the physical law. All of that is guess, or preferably comparison with IRL if someone can tell.

onox commented 9 years ago

@dany93 Let us say we have a function f(AoA) = (volume, pitch). We'll define how this function works precisely later. First question is: do we need to add more input variables to this function f?

dany93 commented 9 years ago

Not easy to answer because (as I wrote above) we do not know which parameters have an effect on volume and pitch. The velocity may have an effect on the pressure difference. A stall can happen in straight and levelled flight conditions (that is around 45 KIAS) or dynamically, during a steep turn with high roll angle (higher velocity). Also at high g due to a strong pitch up. I completely ignore the possible effect on the volume and pitch. I think you will have to guess something based on the observations and subjective memory of c172 pilots. The first I would do is increasing volume (and pitch?) with the AoA. Then (maybe) volume with the velocity. Purely guess. Even for the pitch, I do not know why it changes. In a reed instrument, the pitch modulation is much more complex than only an air-pressure difference or velocity effect. In an accordion, the volume of the note depends on the pressure difference, but not the pitch (the note). In a oboe, the reed is in pursed (held) in the lips of the instrumentalist. Anyway, it can suffer some approximation with no important loss in realism....

onox commented 9 years ago

Currently the volume is controlled by /sim/alarms/stall-warning which is controlled in src/FDM/JSBSim/models/FGAerodynamics.cpp as follows:

161   if (alphaclmax != 0) {
162     if (in.Alpha > 0.85*alphaclmax) {
163       impending_stall = 10*(in.Alpha/alphaclmax - 0.85);
164     } else {
165       impending_stall = 0;
166     }
167   }

alphaclmax should be <aerodynamics><alphalimits><max> in c172p.xml, which is 0.28 rad.

dany93 commented 9 years ago

That is: volume varies linearly with AoA only, with a threshold at Alpha/alphaclmax = 0.85. (true ?)

onox commented 9 years ago

So I think we could definitely write our own function that increases pitch when the AoA is in certain regions.

onox commented 9 years ago

What do you mean with volume?

dany93 commented 9 years ago

If you want to include pitch, yes. "How to" remains to be seen.

The volume is the intensity of the sound, the power. Like the volume knob on an amplifier. The pitch is the frequency, the note itself (A, B, ... G). The volume can be increased by a continuous manner, but I do not call it pitch.

onox commented 9 years ago

I know.

onox commented 9 years ago

I think @wkitty42 posted some video somewhere that showed the different musical notes of the stall horn?

onox commented 9 years ago

@gilbertohasnofb Shall I update bug-85 to use a property which controls the pitch? You can then set this property to certain number (0.9, 1.0, 1.1, etc.) and give us a list of reasonable number.

dany93 commented 9 years ago

At least gsagostinho on the forum http://forum.flightgear.org/viewtopic.php?f=4&t=25157&start=1995#p247508

onox commented 9 years ago

That's not the video I mean. It was a youtube link posted by @wkitty42

onox commented 9 years ago

This is the post I'm talking about: https://github.com/Juanvvc/c172p-detailed/issues/117#issuecomment-112844657 :smile:

onox commented 9 years ago

Can someone compute the angles where the pitch changes from that video?

gilbertohasnofb commented 9 years ago

Hi guys, Erik uploaded another version of his stall sound on this address http://www.adalin.com/ehtw.info/html/images/stall.wav . I personally still feel my version is a bit better, it sounds a bit rougher and gritier and more annoying (as it's supposed to be IMO). I also think that spectral analysis and resynthesis is the way to go instead of trying to approximate the sound via saw tooth generators and adding effects (it gets much closer to the sound we want to imitate). Anyway, I leave it up to you to see which sound you prefer. If you like his sound better, then I can exchange it myself in the repository, okay? Just please let me know.

onox commented 9 years ago

@gilbertohasnofb I think yours sounds better.

onox commented 9 years ago

Can I chop off that commit from @wlbragg in master? It gives the regular pontoons front gears :confused:

gilbertohasnofb commented 9 years ago

@onox @dany93 Erik posted a code snippet of how this could be implemented in our forum thread. Could you please have a look on it?

onox commented 9 years ago

I have force pushed master and bug-85.

onox commented 9 years ago

@gilbertohasnofb I'll take a look at the code snippet.

gilbertohasnofb commented 9 years ago

@onox thanks!

onox commented 9 years ago

Can you still take a look at the video in https://github.com/Juanvvc/c172p-detailed/issues/117#issuecomment-112844657 and try to estimate the difference in angles?

gilbertohasnofb commented 9 years ago

Yes I can do that but only a bit later, right now I have to leave. I will try to do it by tonight, okay?

onox commented 9 years ago

Ok.

dany93 commented 9 years ago

I'd say an angle difference of about 8 to 10 deg between the beginning and the end.

onox commented 9 years ago

But currently the horn starts at 13.63 and ends at 16.04.

dany93 commented 9 years ago

I find that it does not end. I had it up to high values. More than 20 - 22 deg at idle, 30 - 40 deg and more by climbing full throttle and cutting the throttle. It has no reason to end.

onox commented 9 years ago

Yeah, sorry, you're right about that.

onox commented 9 years ago

/sim/alarms/stall-warning is 0.0 at 85 % of the alphalimit and 1.5 at 100 %.

onox commented 9 years ago

I'm writing two <fcs_function>'s to control volume and pitch because I'm not too happy with the snippet posted by Erik.

dany93 commented 9 years ago

For the code snippet, http://forum.flightgear.org/viewtopic.php?f=4&t=25157&start=2010#p247690 how do you understand it? I read 0.745 * log(alpha) Which would be a nonsense (alpha can take the value 0) And where is the threshold?

onox commented 9 years ago

This is what I have currently:

 277    <volume>
 278     <property>/fdm/jsbsim/sounds/stall-horn-volume</property>
 279    </volume>
 280    <pitch>
 281     <property>/fdm/jsbsim/sounds/stall-horn-pitch</property>
 282     <offset>0.0</offset>
 283    </pitch>
onox commented 9 years ago

Using a pitch between 0.9 and 1.1.

dany93 commented 9 years ago

What is wrong with the original code https://github.com/Juanvvc/c172p-detailed/issues/85#issuecomment-113135864?

onox commented 9 years ago

The volume is linear.

dany93 commented 9 years ago

And something like if alpha > alpha-threshold log(k * alpha/alpha-threshold) ? Linear at alphas close to alpha-threshold, then it tends to saturate with the log. The k factor enables setting the gain with alpha.