Exemplo n.º 1
0
        // On-click event handlers for faders, knobs and buttons, etc.

        private void Button_Click(object sender, EventArgs e) // When button clicked on interface
        {
            Label  L   = (Label)sender;
            string tag = Regex.Match((string)L.Tag, @"\d+").Value; // extract integer value from tag
            int    k   = Int32.Parse(tag) - 1;                     // parse as integer and make zero indexed

            if (L.BackColor == System.Drawing.Color.Green)         // if the button is active
            {
                L.BackColor = System.Drawing.Color.Red;
                HardwareSetup.FormSender = true;
                parameters.setY(k, false);
                if (HardwareSetup.BCF2000_i != null)
                {
                    HardwareSetup.noteMess(k, false);
                }
                HardwareSetup.FormSender = false;
            }
            else // if button is inactive
            {
                L.BackColor = System.Drawing.Color.Green;
                HardwareSetup.FormSender = true;
                parameters.setY(k, true);
                if (HardwareSetup.BCF2000_i != null)
                {
                    HardwareSetup.noteMess(k, true);
                }
                HardwareSetup.FormSender = false;
            }
        }
Exemplo n.º 2
0
        private static void CaptureDelegates()
        {
            HardwareSetup temp = new HardwareSetup();

            HardwareSetup.RunInit    = new Action(temp.initialise);
            HardwareSetup.RunRelease = new Action(temp.release);
        }
Exemplo n.º 3
0
 protected override void OnLoad(EventArgs e) // On form load check for and set up input devices
 {
     SetUpTrayIcon();
     FormSetup = new HardwareSetup(this);
     parameters.setForm(this);
     parameters.loadScale();
     FormSetup.initialise();
     ChangeStatusText();
     return;
 }
Exemplo n.º 4
0
 public static void Init()
 {
     if (FirstRun)
     {
         CaptureDelegates();
     }
     InitSender = true;
     HardwareSetup.RunInit();
     InitSender = false;
 }
Exemplo n.º 5
0
        public static void setY(int index, bool val) // Set the value of a button
        {
            Button[index] = val;

            if (!HardwareSetup.FormSender && !HardwareSetup.ControlSender && HardwareSetup.BCF2000_i != null)
            {
                HardwareSetup.noteMess(index, val);

                if (inForm != null)
                {
                    inForm.setButton(index, val);
                }
            }
        }
Exemplo n.º 6
0
        private void Knob_ValueChanged(object sender, EventArgs e) // If knob value is changed
        {
            NumericUpDown N     = (NumericUpDown)sender;
            int           index = 7 + Int32.Parse(N.Tag.ToString().Last().ToString());
            float         value = (float)N.Value;   // interface value

            if (value != parameters.Control[index]) // if the current value on the interface differs from stored parameter
            {
                HardwareSetup.FormSender = true;
                parameters.setX(index, value);
                if (HardwareSetup.BCF2000_i != null)
                {
                    HardwareSetup.controlMess(index, value);
                }
                HardwareSetup.FormSender = false;
            }
        }
Exemplo n.º 7
0
        public static void setX(int index, float val) // Set the value of a fader/knob
        {
            Control[index] = val;
            if (!HardwareSetup.FormSender && !HardwareSetup.ControlSender && (HardwareSetup.BCF2000_i != null && HardwareSetup.BCF2000_o != null))
            {
                HardwareSetup.controlMess(index, val);
            }
            // Old method of setting fader values:
            //if (index < 8)
            //{
            //    /*
            //    float increment = (ScaleUpperBound[index] - ScaleLowerBound[index]) / (float)127.0;
            //    Knobs[index] = ScaleLowerBound[index] + (increment * Control[index + 8]);
            //    increment /= (float)127.0;
            //     * Faders[index] = Knobs[index] + (increment * Control[index]);
            //     */
            //    float Range = ScaleUpperBound[index] - ScaleLowerBound[index];
            //    float StepCoarse = Range/127f;
            //    float ValueCoarse = ScaleLowerBound[index] + ((float)Control[index + 8] / 127f) * Range;
            //    float RangeFine = StepCoarse * FineScaleRatio[index];
            //    float ValueFine = (((float)Control[index] - 63f) / 127f) * RangeFine;

            //    Faders[index] = ValueCoarse + ValueFine;
            //}
            //else
            //{
            //    index -= 8;

            //    float Range = ScaleUpperBound[index] - ScaleLowerBound[index];
            //    float ValueCoarse = ScaleLowerBound[index] + ((float)Control[index + 8] / 127f) * Range;
            //    float RangeFine = Range * FineScaleRatio[index];
            //    float ValueFine = (((float)Control[index] - 63f) / 127f) * RangeFine;
            //    Faders[index] = ValueCoarse + ValueFine;

            //    /*
            //    float increment = (ScaleUpperBound[index] - ScaleLowerBound[index]) / (float)127.0;
            //    Knobs[index] = ScaleLowerBound[index] + (increment * Control[index + 8]);
            //    increment /= (float)127.0;
            //    Faders[index] = Knobs[index] + (increment * Control[index]);
            //     */
            //}

            if (index > 7) // if index is greater than 7, it refers to a knob, hence reduce by 8 for associated pair
            {
                index -= 8;
            }

            float Range       = ScaleUpperBound[index] - ScaleLowerBound[index];            // Total range of faders
            float StepCoarse  = Range / 127f;
            float ValueCoarse = ScaleLowerBound[index] + (Control[index + 8] * StepCoarse); // Knob value
            float RangeFine   = Range * (1f - FineScaleRatio[index]);                       // Range of fader within coarse range

            if (RangeFine == 0)
            {
                RangeFine += 0.01f; // Make sure faders always do something at least
            }
            float ValueFine = ((Control[index] - 63f) / 127f) * RangeFine;

            Faders[index] = ValueCoarse + ValueFine;

            if (inForm != null)
            {
                inForm.ChangePair(index, Faders[index]);
            }
        }
Exemplo n.º 8
0
 private void resetButton_Click(object sender, EventArgs e)
 {
     HardwareSetup.resetControlValues();
 }
Exemplo n.º 9
0
 public static void Rel()
 {
     HardwareSetup.RunRelease();
 }