Is VP AudioFade/Pan Messed Up?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #80940
    Scottacus
    Participant
      @scottacus
      MembervipContributor

      My brother is building a cab and plans on putting quad speakers under the playfield to reproduce quadrophonic sounds for the various table elements and ball rolling.  We were messing around with setting this up and it seemed like the sounds never really panned/faded fully so I took a look at the boiler plate script that we all use and I’m wondering if it needs to be modified?

      The guts of the functions look like this

          tmp = tableobj.y * 2 / table1.height-1
          If tmp > 0 Then
      AudioFade = Csng(tmp ^10)
          Else
              AudioFade = Csng(-((- tmp) ^10) )
          End If
      The first part “tmp = tableobj.y * 2 / table1.height-1” is perfect because it takes the x or y location of the object, multiplies it by 2, divides it by the table height/width and subtracts one.  Here are some examples of outputs for a table with a width of 1000:
       
      Object location = 0 (far left)   ((0*2)/1000) – 1 = -1
      Object location = 500 (middle) ((500*2)/1000) -1 = 0
      Object location = 1000 (far right) ((1000*2)/1000) -1 = 1
       
      This is perfect because far left or right get the full pan  :good:
      Now take a look at the rest of the code.  The -1 to +1 is raised to the 10th power and then subjected to a cosine function and then if/then’ed to make it positive or negative.  Cosines are not linear so what you get is exactly what you hear when you listed to the table output from the speakers.  The sound comes from dead center until the object is most of the way to the edge of the table and then it quickly moves toward +/- 1.   Also raising the -tmp to an even power does nothing because even powers always yield positive outputs.
      I think the way this should work is to get rid of the cosine part and just set Pan/Fade to equal tmp and leave it there.  Am I missing something here or is this feature not working as intended?
      #80996
      DJRobX
      Moderator
        @djrobx
        MemberModerator

        “Csng” is not cosine.  It is “Convert to single precision float”.

        The ^10 thing on a decimal value from 0-1 adds a very sharp response curve that reduces the amount of separation up until the extremes.    I’m not exactly sure why the Pan input value of PlaySound works this way.   See the effect on the graph here:

        Screen-Shot-2018-04-06-at-10.52.45-PM

        That’s the way virtually all tables have it.   Now, when I added surround sound support, Microsoft’s 3D sound API takes positional values the “linear” way you would expect, vs this logarithmic method the stereo API seems to use.    So I reverse this ^10 back into normal values.    I just went with the same type of input value for Fade to keep the two consistent.

        If you aren’t happy with the amount of stereo separation you can play with the ^10 number – the less the number is the more left/right separation you will get, but realize that the 3D code expects this strange equation and “reverses” it.

        On the negative side it will return a positive number, so it gives the negative answer to the ^10 of the positive value – remmeber,  -tmp  is positive if tmp is negative.  :)

        1 user thanked author for this post.
        #81011
        Scottacus
        Participant
          @scottacus
          MembervipContributor

          Thanks for the explanation!

          So if I’m following you, the function takes the “tmp” value and makes it single point to reduce the number of integers in the number to something like seven places.   This value is raised to the 10th power so that anything that is not near the outside edge is always near zero just like in your graph.  Then VP takes this value and converts it back to the original value of “tmp” by taking the 10th root?

          #81029
          DJRobX
          Moderator
            @djrobx
            MemberModerator

            Yes.

            I think CSng is primarily there to ensure that VBScript performs the mathematical operations as a floating point number, as opposed to an integer or string.    And yes, in surround mode, VP converts it back by raising it to the power of 1/10th (10th root).

            I’ve thought about adding a slider to VPX’s surround setting to let you meddle with that value to be able to tweak the way the positioning ends up.  So far you’re the first to even comment on the possibility that the positioning might not be quite right though.

            Full disclosure: There’s some additional funkiness if you’re in 7.1 mode (as opposed to quad mode).   Microsoft’s 7.1 virtual room has side surround speakers on your left and right, and your rear surrounds behind you.     This doesn’t match up exactly with where speakers are in your playfield, so I had to kind of experiment to find positioning calculations that give us the desired results for the cab outputs.     That’s why you’ll hear a little bleed through to the backglass speakers.    In quad mode (dedicated card to playfield) the calculations are much more clean.

            1 user thanked author for this post.
          Viewing 4 posts - 1 through 4 (of 4 total)

          Forums are currently locked.

          ©2024 VPinBall.com

          Log in with your credentials

          Forgot your details?