Closed gilbertohasnofb closed 8 years ago
Did lightning-range work?
Nope, it's fixed at the value 3000. I think that's used for something else.
Btw, ehh.. where's the code that calls thunder()
I don't know where to put it!
Also, a mistake. Where I had:
var delay_seconds = lightning_distance * 340.29;
I should have:
var delay_seconds = lightning_distance / 340.29;
Also, I found a problem with the formula
You should add a call to setlistener()
somewhere on line 234 I think (before the reset_system()
call)
Listen for changes to /environment/lightning/lightning-pos-x
.
onox, this is a bit beyond me, could you give me a hand on how to program this setlistener()
code?
Look at the use of it on line 228. First parameter is the property you want to listen for. Second parameter is a function that is called when the property changes. So in your case it would be something like:
setlistener("/environment/lightning/lightning-pos-x", thunder)
;
Make sure you remove that 'timeout' parameter in thunder()
function. (Since it's useless)
Almost there. Now I get an error:
Nasal runtime error: undefined symbol: pow
Nasal runtime error: undefined symbol: sqrt
but according to the wiki, these are mathematical functions of Nasal. I tried both:
var lightning_distance = sqrt(pow(lightning_pos_X,2) + pow(lightning_pos_Y,2));
and
var lightning_distance = pow((pow(lightning_pos_X,2) + pow(lightning_pos_Y,2)),0.5);
Try math.pow
and math.sqrt
.
Now I get Nasal runtime error: non numeric argument to pow()
when using:
var lightning_distance = math.sqrt(math.pow(lightning_pos_X,2) + math.pow(lightning_pos_Y,2));
Call debug.dump(lightning_pos_x);
on the line before.
It's dumping [31m'/environment/lightning/lightning-pos-x'[m
Is there a :bulb: appearing above your head already? :wink:
Not really. I obviously can spot the interesting 31m
, and I guess the whole thing is a string not a float which is why math.pow is complaining. But I have no idea how to get the 31
out of the string in Nasal.
[31m is just ASCII code to give the text a red color. What's more important is that it's dumping a string, not a number. math.pow
wants to get a number. It can do nothing with strings.
I'll give you another hint: look at somewhere around line 73. Then look back at where you define lightning_pos_X
.
getprop()
....
:clap: :smile:
It works!!! :smile: I am pushing it now. Thanks a lot, onox!
Also, I was thinking about adding a rain sound to our plane, what do you think? Is there a way of telling if it's raining (but not snowing!) in the sim?
What do you think about that?
What do you think about that?
Great idea, I think you can use /environment/rain-norm
.
:+1:
@gilbertohasnofb Have you heard Sounds/thunder.wav
in FGData?
Yes I have, but I don't like it, it has so much clipping and it also sounds too artificial to me. Do you like it better than ours?
I cannot hear it right now, because FG is running currently. The problem right now is that we're assuming there's only one flash every 20 seconds. If a second flash occurs, the first is interrupted. We basically need n instances of <thunder>
if the maximum number of flashes in 20 seconds is n, in order to prevent interrupting.
It's a bit sad the XML sound system doesn't support templates + Nasal API to trigger sounds :disappointed:
@gilbertohasnofb It would be nice if you could strip off that half a second of silence in the beginning and remove some of the near-silence at the end of the file, so that the duration become quite a bit less than 20 seconds.
I see, I will remove that silence in the beginning and fade the sound earlier.
Ok, I managed to shorten it to 9 seconds. I will work on the rain sound now.
Thanks.
Rain implemented. So now the only thing missing is to change the volume of the thunder (within a certain range) according to the distance, and then we can make a PR for this branch. And then, if one day someone implements dynamic changes in the position of sounds (I asked for it in the mailing list) then we can make thunder strikes directional.
As for the volume according to the distance, how can I do that? I guess I can already do the math inside that Nasal function so that it outputs some variable proportionally to lightning_distance
and between 0 and 1, what do you say?
Lets first merge the other branch.
Which other branch?
Ah, the louder wind and engine branch, of course.
Is the rain to be positional, like the wind?
AFAIK (0,0,0) means no position.
Since the rain's sound is constant (doesn't change with speed) I would say let it be non-positional, so any camera will have the sound of rain. What do you think?
Yeah, ok, that's is fine.
Do you have any more commits or not? If not, then I can rebase this branch onto latest master.
I don't have any other commits, so let's rebase it before working on the volume.
Try git pull --force
again.
Do we also have a light rain sound and a rain sound of rain hitting the wind shield (front window)?
Try git pull --force again.
Ok, seems to be fine (at least my additions to those files are still there). Output from the command:
git pull --force
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 15 (delta 6), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (15/15), done.
From https://github.com/Juanvvc/c172p-detailed
+ 2ad1903...24812b1 bug-443 -> origin/bug-443 (forced update)
20e29f3..147ca4b master -> origin/master
Auto-merging c172-sound.xml
Merge made by the 'recursive' strategy.
Systems/c172p-sounds.xml | 2 +-
Systems/sounds.xml | 82 ++++++++++++++++++++++++++++++++++++++++++++++++
c172-sound.xml | 81 ++++++++++++++++++++++++++++++++++++-----------
c172p-set.xml | 4 +++
4 files changed, 150 insertions(+), 19 deletions(-)
create mode 100644 Systems/sounds.xml
Do we also have a light rain sound and a rain sound of rain hitting the wind shield?
I just have the sound of some medium rain, which should be fine for all conditions. But I found a good sound licensed as CC-BY-3.0: http://freesound.org/people/geodylabs/sounds/122795/
What do you think? Should we use both sounds (external rain + rain on windshield) when inside the cockpit, and only external rain for other views?
Hmm... no, git did a merge for you. Can you do git log --oneline
and paste me like first 10 commits?
gilberto@gilberto-Inspiron-7520 ~/WorkingFG/c172p/c172p $ git log --oneline
da1b7fd Merge branch 'bug-443' of https://github.com/Juanvvc/c172p-detailed into
24812b1 rain sound and implementation
3b02b08 shorter thunder sound
fde28f4 thunder sound implementation
0000c0b Add thunder sound
ac74795 Add 'delay' parameter to click() function
ec870e2 thunder sound
147ca4b Merge pull request #478 from Juanvvc/bug-117b
2ad1903 rain sound and implementation
ad335b7 shorter thunder sound
0cb2746 thunder sound implementation
5825581 Add thunder sound
a8c06e8 Add 'delay' parameter to click() function
Make that first 20.
Can you try git merge-base bug-443 master
?
gilberto@gilberto-Inspiron-7520 ~/WorkingFG/c172p/c172p $ git log --oneline
da1b7fd Merge branch 'bug-443' of https://github.com/Juanvvc/c172p-detailed into
24812b1 rain sound and implementation
3b02b08 shorter thunder sound
fde28f4 thunder sound implementation
0000c0b Add thunder sound
ac74795 Add 'delay' parameter to click() function
ec870e2 thunder sound
147ca4b Merge pull request #478 from Juanvvc/bug-117b
2ad1903 rain sound and implementation
ad335b7 shorter thunder sound
0cb2746 thunder sound implementation
5825581 Add thunder sound
a8c06e8 Add 'delay' parameter to click() function
09cadff thunder sound
9c94395 Position wind sound
3248f33 Move volume boost logic to <property-rule> file
f47cc56 Attenuate engine and wind volume if one or both doors are closed
20e29f3 Merge pull request #477 from Juanvvc/bug-476
878fa8d Disable mouse zooming for Chase View Without Yaw as well
8257edb Use mouse scroll wheel to zoom in and out for 'lookat' views
310f3bb Merge pull request #475 from Juanvvc/cleanup
0a1a38e new splash screen no. 10
207e3fe Cleanup miscellaneous files.
Sure:
gilberto@gilberto-Inspiron-7520 ~/WorkingFG/c172p/c172p $ git merge-base bug-443 master
20e29f3dd9e0c4f4832011a1bc21ef99bfbc842b
Nice, that's what I expected. 20e29f3dd9e0c4f4832011a1bc21ef99bfbc842b
Do this:
git reset --hard 20e29f3dd9e0c4f4832011a1bc21ef99bfbc842b
git pull
gilberto@gilberto-Inspiron-7520 ~/WorkingFG/c172p/c172p $ git reset --hard 20e29f3dd9e0c4f4832011a1bc21ef99bfbc842b
HEAD is now at 20e29f3 Merge pull request #477 from Juanvvc/bug-476
gilberto@gilberto-Inspiron-7520 ~/WorkingFG/c172p/c172p $ git pull
Updating 20e29f3..24812b1
Fast-forward
Nasal/c172p.nas | 36 +++++++++++----
Sounds/rain.wav | Bin 0 -> 621258 bytes
Sounds/thunder.wav | Bin 0 -> 837944 bytes
Systems/c172p-sounds.xml | 2 +-
Systems/sounds.xml | 82 ++++++++++++++++++++++++++++++++++
c172-sound.xml | 112 +++++++++++++++++++++++++++++++++++++++--------
c172p-set.xml | 4 ++
7 files changed, 209 insertions(+), 27 deletions(-)
create mode 100644 Sounds/rain.wav
create mode 100644 Sounds/thunder.wav
create mode 100644 Systems/sounds.xml
:+1:
Cool! So back to work: what about those two things I proposed?:
Yes, first thing you can do is replace <factor>1.0</factor>
in <thunder>
with <property>/sim/model/c172p/sound/volume-boost-doors</property>
.
@gilbertohasnofb Make sure you use spaces, I found tabs in your code :worried:
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).