


This code loops through every possible value of ORG volume and pan, calculates
the relative amplitude of the left and right channels, then finds the MIDI
volume and pan that is the closest match for the desired amplitudes. The code
outputs text of C array initializers, which can then be used in the ORG to MIDI
converter code.



Ranges

                          values      range         notes
  ____________________________________________________________________________

  ORG volume              0 to 254     254    255 used for "no change"

  MIDI note on velocity   1 to 127     126      0 used for "note off"

  MIDI volume             0 to 127     127

  MIDI expression         0 to 127     127

  ORG pan                 0 to  12      12

  MIDI pan                1 to 127     126      0 and 1 both mean "hard left"*
  ____________________________________________________________________________


To convert values to 0 to 1:

  if minimum value is 0, use   (  value / range )
  if minimum value is 1, use   ( (value - 1) / range )



* Default Pan Formula
http://www.midi.org/techspecs/rp36.php

  "Since MIDI controller values range from 0 to 127, the exact center of
  the range, 63.5, cannot be represented. Therefore, the effective range
  for CC#10 is modified to be 1 to 127, and values 0 and 1 both pan hard
  left."

  from The Complete MIDI 1.0 Detailed Specification
  (http://www.midi.org/techspecs/midispec.php),
  section "MIDI 1.0 Detailed Specification Addenda"


