Page 2 of 5
Re: Sound effects
Posted: Fri Dec 04, 2015 10:16 pm
by Fritz
I've never worked with timers, but the BGS OXP seems to call it every 0.6 seconds, that's 100 times per minute. It could check if the speed has changed since the last call and change the volume (it probably does this already somehow for playing the accelerating or decelerating sounds).
Norby, please don't tell me that you did this including the wiki page in the last few minutes!
I'll download it immediately!
Re: Sound effects
Posted: Fri Dec 04, 2015 10:38 pm
by Cody
Fritz wrote:Norby, please don't tell me that you did this including the wiki page in the last few minutes!
<chortles> He's good at that, is Norby!
Re: Sound effects
Posted: Fri Dec 04, 2015 10:41 pm
by Norby
Fritz wrote:please don't tell me that you did this including the wiki page in the last few minutes!
No, it was about an hour.
It needed 25 sound files and a script with about 30 lines. A dual-timer which make 8 changes/second seems enough to emulate a continuous sound.
Re: Sound effects
Posted: Fri Dec 04, 2015 11:09 pm
by Fritz
I know people who would need around 50 edits to create a wiki page like this...
What you did is a very good start! Strangely the effect is even better when I play the different files with Winamp, because in Oolite there is a slight "switching" sound with each change, but perhaps this can be eliminated somehow by changing the timing of starting and stopping a sound. And I'm still trying to figure out why you use two timers.
There seems to be an issue with torus speed (the sound changes in a strange way and then stops completely) but that should be easy to find. One approach would be to not use the speed value directly but a percentage of max speed, so that there is no sudden change from, let's say, sound 17 to sound 25. And slower ships could use the whole set of files in this case.
Btw, what software did you use for changing the speed of the sound files?
Re: Sound effects
Posted: Sat Dec 05, 2015 12:44 am
by Norby
Fritz wrote:there is a slight "switching" sound with each change
I am afraid I can not fix this. I tried more ways but none helped.
Because the minimal allowed interval of a
Timer is 0.25s which is not enough seamless.
Fritz wrote:to not use the speed value directly but a percentage of max speed
I use the speed value willfully, in this way the sound at max. speed in an Anaconda will be much lower than in a Cobra. A check of
torusEngaged solved the problem in Engine Sound v1.1, thanks for spotting.
Fritz wrote:what software did you use for changing the speed of the sound files?
Audacity. I created this table to determine the steps of conversion:
Code: Select all
tone % file ship.speed
-24 -75 1 1
-23 -73,513 2 20
-22 -71,938 3 40
-21 -70,27 4 60
-20 -68,502 5 80
-19 -66,629 6 100
-18 -64,645 7 120
-17 -62,542 8 140
-16 -60,315 9 160
-15 -57,955 10 180
-14 -55,455 11 200
-13 -52,806 12 220
-12 -50 13 240
-11 -47,027 14 260
-10 -43,877 15 280
-9 -40,54 16 300
-8 -37,004 17 320
-7 -33,258 18 340
-6 -29,289 19 360
-5 -25,085 20 380
-4 -20,63 21 400
-3 -15,91 22 420
-2 -10,91 23 440
-1 -5,613 24 460
0 0 25 480 <-- this is the original file from BGS.
Re: Sound effects
Posted: Sat Dec 05, 2015 12:53 am
by Cody
Audacity is good stuff.
Re: Sound effects
Posted: Sat Dec 05, 2015 1:00 am
by Fritz
Meanwhile I've learned from the wiki that the timer limit is 0.25. I wonder, why. I tried it with this value but as you said, it isn't seamless enough. And I too tried several ways to prevent the switching sound (e.g. reducing volume to 0 before changing anything). But it isn't really bad, just imagine the thrust lever making some scraping sound...
I'm playing around with a version that uses sound #1 as a standby sound (with reduced volume) and the sounds #2 to #25 for normal speeds. For torus driving and injector use I keep the sound at #25, so there is no "step", but I've added the accelerating and decelerating sounds from the BGS OXP for engaging and disengaging torus drive. It's not sounding bad in my opinion, but I'll try to use torusEngaged because the sound effects are a little bit too late the way I did it (by just checking speed > 8*maxSpeed).
Re: Sound effects
Posted: Sat Dec 05, 2015 7:40 am
by Amah
interesting discussion.
@norby nice oxp. I'll keep it
Re: Sound effects
Posted: Sat Dec 05, 2015 12:00 pm
by Fritz
I have no idea anymore how to solve the switching sound problem...
I have tried almost everything, including playing two or even three SoundSource objects alternately and/or delaying the stopping of the old sound by one timer cycle (1/8 s), so for a short time two sounds were playing together. So it seemed that the switching sound is caused simply by starting a sound and not by starting the new sound immediately after stopping the old one.
So I tried a completely different approach, probably not very good from a resource management perspective, but on my computer it didn't affect performance in any measurable way: I created an array of 25 SoundSource objects and initialised and play them all (with volume 0) during startup. Speed changes now only change the volume, so there is no starting and stopping of sounds anymore. But even now, the switching sound effect is (almost?) identical to the original one.
Btw, you can create interesting sound effects by playing two or more of the sounds together, like two engines or other equipment running at slightly different rpm!
Re: Sound effects
Posted: Sat Dec 05, 2015 2:12 pm
by Norby
Yes, I tried these also, plus some other tricks like using
FCB instead of timer for smoother volume changes and totally silent sound files but the scraping remains.
Maybe interesting that there is scraping in my machine when I use the mouse wheel to make fast up-down changes on the master volume tool in my taskbar while either Oolite make a constant engine noise or I play these sound files with a media player, but nothing similar if I play anything else.
Re: Sound effects
Posted: Sat Dec 05, 2015 2:15 pm
by ocz
Kudos to norby.
@fritz: Define soundswitching problem further. I know it isn't simple but please try.
- Do you mean a light crackle (knistern) when changing speed? Like a slide clack, as If you plugged in a connector, when you start the soundfile? I found that fading-in and fading-out at the beginning and end of a soundfile, even if only the first and last few ms, help to get rid of that clack. It might reduce the crackle to. But I fear one has to edit the oggs and not fase them in and out via OXP script.
- Or do you mean gaps in between the sounds? Well, you already did let them overlap. That's what I would have suggested to do.
Re: Sound effects
Posted: Sat Dec 05, 2015 2:48 pm
by Fritz
It is a slight crackling (Knacken in German) like changing volume on an old radio. No gaps.
The first thing I tried yesterday was actually to keep the volume unchanged and use only .play() and .stop(), because I remember that changing volume caused a crackling problem on the C-64 SID sound chip. But it doesn't help here. I also tried to use volume = 0.01 instead of volume = 0, but it doesn't help either.
The starting or ending milliseconds of the sound files can't be the problem because they were playing continuously on my 25-object-array version and each one has a different length. As far as I can hear it there is no or almost no noise when the sound files loop.
So I really have run out of ideas...
Edit: One more idea: Perhaps is using the keyboard for changing thrust causing the problem... perhaps I'll try to somehow change speed by code.
Re: Sound effects
Posted: Sat Dec 05, 2015 2:55 pm
by ocz
If that keyboard idea shouldn't work out, could you upload your OXP (without the keyboard modifications if not necessary)?
Re: Sound effects
Posted: Sat Dec 05, 2015 3:01 pm
by Fritz
Which one? I've tried many things, and I haven't kept every version. I'm currently working on a version that uses only one SoundObject, like Norby's original version, but I should still have one of the array versions too.
Re: Sound effects
Posted: Sat Dec 05, 2015 3:08 pm
by ocz
The array version one sounds interesting and still has that problem, so that one.