• Welcome to PiBoSo Official Forum. Please login or sign up.
 
April 25, 2024, 11:03:43 AM

News:

World Racing Series beta14 available! :)


Engine SCL (sound editing)

Started by Warlock, January 02, 2014, 05:17:23 AM

Previous topic - Next topic

Warlock

Piboso, can you explain a bit these parameters in engine.scl?
-Value (in each point)
-RefPitch


Warlock

Please Piboso can you throw some light on this
I'm going nuts trying to understand this file, doing changes and restarting the game each time to see what happens .
It's also possible to add or remove samples from the file?.... is mandatory to have 11 samples?

Im able to deal with programing, but thats not the problem, is the goal for each variable what i want to understand.

thank you

Stout Johnson

Quote from: Warlock on January 02, 2014, 05:17:23 AM
Piboso, can you explain a bit these parameters in engine.scl?
-Value (in each point)
-RefPitch

I can tell you what I remember these things were:
*Value (in each point) refers to the rpm-point that each point represents (that rpm-point can be calculated via "Value x MaxValue" (multiplication that is) - with those value and volume combinations you can change where sound kicks in or fade them in and out....
*RefPitch is the rpm-point each sample represents (can be calculated via "RefPitch x MaxValue" say idle sound RefPitch=0.15 and MaxValue=15.000rpm then the sample will represent an idle engine sound at 2250rpm - just an example)

maybe Piboso can confirm/correct and add things that might be helpful to know...
    -----------   WarStout Kawasaki Team   -----------

HornetMaX

My understanding of it (not 100% sure, as it's all reverse engineering):

  • All the samples should be mono and loopable. That's sure.
  • You have 2 layers (Layer0 and Layer1) that correspond (roughly) to open/close throttle (respectively).
  • Each layer can have an arbitrary number of samples (.wav files), specified in "Numamples".
  • Each sample (within a layer) is named sample0, sample1, ... and contains:

         
    • The .wav filename.
    • An arbitrary number of points (NumPoints); I think there should always be at least 3 points. each point (point0, point1, ...) has:

              
      • A Value: the value multiplied by the MaxValue (top of the file) gives you the RPMs.
      • A Volume (between 0 and 1).
    • Values for RefPitch, MinPitch and MaxPitch.

For the Murasama (just a part of the file):
MaxValue = 17000.000000
AutoPitch = 1
Layer0
{
NumSamples = 5
sample0
{
wav = sb2_onidle.wav
NumPoints = 3
point0
{
Value = 0.000000
Volume = 1.000000
}
point1
{
Value = 0.177647
Volume = 1.000000
}
point2
{
Value = 0.224706
Volume = 0.000000
}
RefPitch = 0.176471
MinPitch = 0.000000
MaxPitch = 1.273335
}
sample1
{
wav = sb2_onverylow.wav
NumPoints = 4
point0
{
Value = 0.175294
Volume = 0.000000
}
point1
{
Value = 0.222353
Volume = 1.000000
}
point2
{
Value = 0.260000
Volume = 1.000000
}
point3
{
Value = 0.307059
Volume = 0.000000
}
RefPitch = 0.235294
MinPitch = 0.745000
MaxPitch = 1.304998
}
sample2
{
wav = sb2_onlow.wav
NumPoints = 4
point0
{
Value = 0.262353
Volume = 0.000000
}
point1
{
Value = 0.303529
Volume = 1.000000
}
point2
{
Value = 0.396470
Volume = 1.000000
}
point3
{
Value = 0.455294
Volume = 0.000000
}
RefPitch = 0.323530
MinPitch = 0.810907
MaxPitch = 1.407271
}
sample3
{
wav = sb2_onmid.wav
NumPoints = 4
point0
{
Value = 0.395294
Volume = 0.000000
}
point1
{
Value = 0.450589
Volume = 1.000000
}
point2
{
Value = 0.536471
Volume = 1.000000
}
point3
{
Value = 0.602353
Volume = 0.000000
}
RefPitch = 0.500000
MinPitch = 0.790588
MaxPitch = 1.204706
}
sample4
{
wav = sb2_onhigh.wav
NumPoints = 3
point0
{
Value = 0.536471
Volume = 0.000000
}
point1
{
Value = 0.598824
Volume = 1.000000
}
point2
{
Value = 1.000000
Volume = 1.000000
}
RefPitch = 0.676471
MinPitch = 0.793043
MaxPitch = 1.478260
}
}



The basics: within a layer (e.g. layer0 for throttle ON), you want to "play" one specific sample (e.g. sample0) only over a given range of RPM.
Of course GPB will "modulate" (alter the pitch, in fact) of that sample depending on the RPMs in the range. This is done this way:

  • RefPitch is 0.176471: if you multiply it by MaxValue (17000) you get 3,000 RPM. This is probably the RPMs at which the sample was captured/generated.
  • MinPitch is 0.000000: you multiply that by RefPitch and by MaXValue and you get ...well, 0,000 RPM.
  • MaxPitch is 1.273335: you multiply that by RefPitch and by MaXValue and you get ...well, 3,820 RPM.
  • This means that this specific sample will be used for RPMS between 0 and 3,820. The pitch of the .wav will be varied according to the RPMs.
Now, when RPM gets above 3,820 you  want to switch to the next sample. But doing it naively would be terrible. Here's how it's done:

  • sample0 has 3 points: if you multiply the points' Value by MaxValue you get (respectively) 0, 3,020 and 3,820 RPMs. Notice how the first and last point (0 and 3,820) match the RPM values of MinPitch and MaxPitch.
  • Each of the 3 points has Volume of  (respectively) 1, 1 and 0: this means that between 1st and 2nd point (0 and 3,020 RPM) we'll play the sample at volume 1, while between 3,020 and 3,820 the volume will (linearly, I guess) go down to 0.
  • Now look the next sample (sample 1): if you redo the math for RefPitch, MinPitch and MaxPitch you get 4,000, 2,980 and 5,020 RPM.
  • If you redo the math for the 4 points of sample1 you get: 2,980, 3,780, 4,420 and 5,220 RPM for vlumes 0, 1, 1, 0 respectively.
  • This means that sample0 fades-out between RPMs 3,020 and 3,820 while sample1 fades-in between RPMs 2,980 and 3,780. No idea why there's a slight difference between the two ranges (most likely, it's an oversight).

You can check the rest of Layer0 and, of course, do the same for Layer1.

The final thing is that Layer0 (throttle ON) and Layer1 (throttle OFF) are blended in an undocumented manner by GPB, but maybe we shouldn't care.

You can easily build a small spreadsheet to help understanding and tuning.

MaX.

Warlock

Hey Max, thank you man !!   for such a good explanation, really apreciated

I already did thought about how it worked, fading points , volume , on off throttle, etc.
Maxvalue was what i was missing to calculate everythig.

So based on this i can remove samples if i want, if the range of rpms is full covered by the existing samples (even with only one sample, it will sound like crap for sure , but should be possible)
Thanks !!

Warlock

I calculated all the RPM values of the engine.scl from the Murasama (only onthrottle without idles or pitches to make it easier) , just to try to understand it.
Used formula : Maxvalue(17000) X points value.
And i discovered weird values that dont match with what i thought it should be.
For example fading margins, i thought they should be all the same , so all the samples will connect smoothly without overlapping

         fade in  ---> fade in starts |
                                                  | fading margin
         in          --->fade in ends   |


         out      ---> fade out starts |
                                                    |  fading margin
         fade out --->fade out ends |


onverylow:
-----------
         fade in  ---> 2980 |
                            | 800
         in       ---> 3780 |


         out      ---> 4420 |
                            | 800
         fade out ---> 5220 |

onlow:
-------
         fade in  ---> 4460 |
                            | 700
         in       ---> 5160 |


         out      ---> 6740 |
                            | 1000
         fade out ---> 7740 |


onmid:
-------
         fade in  ---> 6720 |
                            | 940
         in       ---> 7660 |


         out      ---> 9120 |
                            | 1120
         fade out --->10240 |


onhigh: 
----------
        fade in --->  9120  |
                            | 1060
        in      --->  10180 |


        top     --->  17000



Other thing i ask myself is what method is used to divide the full RPM range into sections
Full rpm  range divisions (values took from point 1 of each section, where the fading in finish , where volume =1)
3020 (idle)
3780 (Verylow)     
5160 (low)
7660 (mid)
10180 (high)

onhigh is the longer one:  from 10180rpm  to 17000(maxvalue) , almost half of the full range for one sample


Sorry if something here doesn't makes sense, i'm just trying to understand

HornetMaX

Quote from: Warlock on January 28, 2014, 04:01:39 AM
I calculated all the RPM values of the engine.scl from the Murasama (only onthrottle without idles or pitches to make it easier) , just to try to understand it.
Spreadsheet comes handy: https://docs.google.com/spreadsheet/ccc?key=0AjmU7Qoo77i1dGZUMDJFalRUeXVZZXhOX01TRkFaNVE&usp=sharing

Quote from: Warlock on January 28, 2014, 04:01:39 AM
And i discovered weird values that dont match with what i thought it should be.
For example fading margins, i thought they should be all the same , so all the samples will connect smoothly without overlapping
They don not need to be all the same but typically the 2 fade-out points (fade-out start, fade-out finish) of sample N must be the same of the two fade-in points (start, finish) of sample N+1.
On the 990 the points are not exactly identical (they seem to be off by 20, 40 or 60 RPM depending on the sample).
I think I recall saying this to Piboso and he said it was a "bug".

Quote from: Warlock on January 28, 2014, 04:01:39 AM
Other thing i ask myself is what method is used to divide the full RPM range into sections
Full rpm  range divisions (values took from point 1 of each section, where the fading in finish , where volume =1)
3020 (idle)
3780 (Verylow)     
5160 (low)
7660 (mid)
10180 (high)

onhigh is the longer one:  from 10180rpm  to 17000(maxvalue) , almost half of the full range for one sample
I think here there's no specific method. I haven't tried yet but I guess that a sample taken at, let's say, 4000 RPM cannot be stretched (i.e. varied in pitch) too much, otherwise a single sample for the whole range (except idle and limiter) would do it. Hence single sample is good only over a certain range of RPMs (e.g. between 6000 and 10000), That should be what drives the partitioning (plus the fact that you need one sample for idle).

MaX.

Warlock

Quote from: HornetMaX on January 28, 2014, 12:16:17 PM
Spreadsheet comes handy: https://docs.google.com/spreadsheet/ccc?key=0AjmU7Qoo77i1dGZUMDJFalRUeXVZZXhOX01TRkFaNVE&usp=sharing

Thank you ;) , i'm an artist , not familiar with this kind of tools lol  ;D

Quote from: HornetMaX on January 28, 2014, 12:16:17 PM
They don not need to be all the same but typically the 2 fade-out points (fade-out start, fade-out finish) of sample N must be the same of the two fade-in points (start, finish) of sample N+1.

Yes exactly, that's what i wanted to say but didn't know how  :P

Quote from: HornetMaX on January 28, 2014, 12:16:17 PM
On the 990 the points are not exactly identical (they seem to be off by 20, 40 or 60 RPM depending on the sample).
I think I recall saying this to Piboso and he said it was a "bug".

I did try to use same sample for onmid and onhigh with 1000rpm range for fading between them. Refpitch were the same for both as both samples are identical, but still a jump in the sound ingame.....maybe i did a mistake calculating max and min pitches.... ???
Ill try again tonight.

Thx for help

HornetMaX

January 28, 2014, 02:57:28 PM #8 Last Edit: January 29, 2014, 02:52:50 PM by HornetMaX
Quote from: Warlock on January 28, 2014, 02:11:51 PM
I did try to use same sample for onmid and onhigh with 1000rpm range for fading between them. Refpitch were the same for both as both samples are identical, but still a jump in the sound ingame.....maybe i did a mistake calculating max and min pitches.... ???
Ill try again tonight.
Let's say you want to use the same sample twice. You have two samples (onmid and onhigh) and they are identical.
This means that their RefPitch is the same: it should correspond to the RPMs at which the sample has been captured.
Let's say the bike has maxRPM 17,000 and your sample was taken at 8,500RPM, then the RefPitch is 0.500.

Now let's imagine that you want:

  • onmid between 0 and 5000 RPM, fading-out until 6000 RPM
  • onhigh fading-in between 5000 and 6000 RPM, then going up to 17,000

You should have something like this (I've detailed the computations):
MaxValue = 17000.000000
AutoPitch = 1
Layer0
{
NumSamples = 2
sample0
{
wav = onmid.wav
NumPoints = 3
point0
{
Value = 0.000000
Volume = 1.000000
}
point1
{
Value = 5000 / 17000 = 0.294
Volume = 1.000000
}
point2
{
Value = 6000 / 17000 = 0.353
Volume = 0.000000
}
RefPitch = 8500/17000 = 0.500
MinPitch = 0.000000
MaxPitch = 6000 / 8500 = 0.706 (this is unusual as typically RefPitch is not outside the range, hence usually minpitch is <1  and maxpitch is >1)
}
sample1
{
wav = onhigh.wav
NumPoints = 3
point0
{
Value = 5000 / 17000 = 0.294
Volume = 0.000000
}
point1
{
Value = 6000 / 17000 = 0.353
Volume = 1.000000
}
point2
{
Value = 1.0000     <--- this goes all the way up top 17000
Volume = 1.000000
}
RefPitch = 8500/17000 = 0.500
MinPitch = 5000 / 8500 = 0.588
MaxPitch = 17000 / 8500 = 2.000
}

... ... ...


Now with the above, if you take one sample from the murasama and use it as your two samples, I don't expect to hear any overlapping between 5000 and 6000.
Actually, even if you use one of your samples and you use it twice as above you should not hear any overlapping.

The problem is when you use two different samples. The murasama ones do not generate any (audible) overlapping, all the others I've come across yes.
Could be due to many things: samples not cut at the right place and/or not loopable correctly, or samples with wrong refpitches ...

MaX.

Warlock

Ok, i did try this.
Used the example you posted here (without calculations of course  :P) and one of the murasama samples.
Result : still a small but noticeably jump  ??? , same jump as my loop did last night.
I did use few samples from the murasama, same results.
So i'm starting to think that "bug" you said its just some manual adjusting?  :-X

Can anyone else try this to really confirm i'm not doing something wrong?   (i don't think so, it's easy enough to copy your code, delete calculations and add 'sb2_' to the wave names)

Anyway thanks for your time explaining those calculations, helped me a lot understanding the file. Hope we can find a solution for this also the trick to 'hide' that 2 layers sound effect so we can start making good sounds.

Warlock

I will try tonight increasing and reducing the fading range to see what happen

Warlock

wav = onmid.wav
NumPoints = 3
point0
{
Value = 0.000000
Volume = 1.000000
}
point1
{
Value = 5000 / 17000 = 0.294
Volume = 1.000000
}
point2
{
Value = 6000 / 17000 = 0.353
Volume = 0.000000
}
RefPitch = 8500/17000 = 0.500
MinPitch = 0.000000
MaxPitch = 5000 / 8500 = 0.588 (this is unusual as typically RefPitch is not outside the range, hence usually minpitch is <1  and maxpitch is >1)



Maybe 'MaxPitch = 5000 / 8500 ='   should be  'MaxPitch = 6000 / 8500 ='  ?  as it still sounding untill it completely fades off ?

HornetMaX

Quote from: Warlock on January 29, 2014, 02:48:50 PM
Maybe 'MaxPitch = 5000 / 8500 ='   should be  'MaxPitch = 6000 / 8500 ='  ?  as it still sounding untill it completely fades off ?
Yep, my bad. I've fixed it above.

MaX.

Warlock

Great, it worked now, perfectly smooth, also with my sample  :). Now i have to discover what is the refpitch of my sample lol  ;D
Thank you.

HornetMaX

Quote from: Warlock on January 30, 2014, 04:05:56 AM
Great, it worked now, perfectly smooth, also with my sample  :). Now i have to discover what is the refpitch of my sample lol  ;D
Thank you.
I can probably tell you that. Which are the samples you are working on ?

MaX.