Announcement

Collapse
No announcement yet.

rounding option?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • rounding option?

    Hi Camille,

    Is there a way of controlling how an integer is reached , i.e. rounding, truncation? I saw the "[i]" integer version, but I get what seems to be wrong results (the lighting software spits out MIDI intensities 0-127, and I need to get 0-100, which I have done via the scaling option, but the result when using the integer function in OSC routing is often out by 1...)

    Cheers,

    Freddy

  • #2
    Hi Fred,

    I had a look at the code and I think the rounding occurring when scaling integers could be improved.

    However, please note that when scaling from 127 (128 values) to 100 (101 values), the rounding error will always be present, regardless of the rounding technique used.

    Is there any chance that you keep the original scalings (0-127), or work with floating point values?

    I will come back to you next week when I can check in more details this rounding issue!

    Camille

    Comment


    • #3
      That's cool - of course there has to be a rounding error ... I was just curious why both softwares round differently... but maybe that has to do with converting from 0-255 (DMX internally) to 0-100 (for the software's own display) as well as 0-127 (for midi export) - I am not sure if this happens straight from 0-255 or from the already rounded value... I would prefer not showing decimals if I can - with quite a few channels, it clutters the display . So yeah, happy to hear from you when you get to it!

      Shaaaanks,

      Freddy

      Comment


      • #4
        PS, enquired with the other software, this is what they do:

        All levels are internally represented in floating point format in the range 0.0 to 100.0. They are converted to DMX (0-255) output using the standard formula:

        dmx = round((level/100)*255)

        The values are stored in a file in hex format using standard USITT ASCII and converted to and from percentages as outlined above.

        A similar formula is followed for MIDI, except the range is, of course, 0-127 rather than 0-255.

        midi = round((level/100)*127)

        Comment


        • #5
          Hi Camille,

          Just tested how rounding could work in a simple excel spreadsheet - in theory, if you round mathematically, _after_ having done the scaling of the values that you do, you should arrive at the same values, with a formula that goes something like this:

          outputValue=ROUND(((inputValue-inputScalingLowerBoundary)/(inputScalingUpperBoundary-inputScalingLowerBoundary))*(outputScalingUpperBou ndary-outputScalingLowerBoundary))+outputScalingLowerBou ndary
          Here is the spread sheet, in case you want to have a look .
          Last edited by freadZdead; 10-28-2013, 11:59 PM. Reason: added the link

          Comment


          • #6
            Freddy, I have prepared a new build and I will send it to your email.
            Please let me know if that works better for you.

            Comment


            • #7
              Salut Camille - it works! !

              Great job, and interesting formula - it does arrive at the same place as the one I mentioned above, so perfect!

              Merci mille fois,

              Freddy

              Comment


              • #8
                Salut Freddy,

                That's great, thank you for the feedback!

                Best,
                Cam

                Comment

                Working...
                X