Esempio n. 1
0
        public void Trigger(object sender)
        {
            if (Signal == null || !Enabled)
            {
                return;
            }

            double val = Signal.SignalDelegate();

            val = VelocityMap.Map(val);

            if (Filter != null && FilterEnabled)
            {
                double filterVal = Filter.SignalDelegate();
                if (FilterMin != null && filterVal < FilterMin)
                {
                    return;
                }

                if (FilterMax != null && filterVal > FilterMax)
                {
                    return;
                }
            }

            foreach (var xsig in CrosstalkSignals)
            {
                if (IsCrosstalk(xsig))
                {
                    return;
                }
            }

            if (IsNote)
            {
                Brain.KB.Output.Note(MidiChannel, CCNumber, (int)(val * 127.0));
            }
            else
            {
                Brain.KB.Output.CC(MidiChannel, CCNumber, (int)(val * 127.0));
            }
        }
Esempio n. 2
0
        public void Process(object sender)
        {
            var    input = (IInput)sender;
            double sig   = input.Signals[0].SignalDelegate();

            Console.WriteLine("Signal triggered on channel " + ChannelName + ": " + sig);

            var a = InputA.SignalDelegate();
            var b = InputB.SignalDelegate();

            if (Mode == SignalMode.Add)
            {
                Output = a + b;
            }
            else if (Mode == SignalMode.Difference)
            {
                Output = Math.Abs(a - b);
            }
            else if (Mode == SignalMode.Divide)
            {
                if (b == 0.0)
                {
                    Output = Double.MaxValue;
                }
                else
                {
                    Output = a / b;
                }
            }
            else if (Mode == SignalMode.Maximum)
            {
                Output = (a > b) ? a : b;
            }
            else if (Mode == SignalMode.Minimum)
            {
                Output = (a < b) ? a : b;
            }
            else if (Mode == SignalMode.Multiply)
            {
                Output = a * b;
            }
            else if (Mode == SignalMode.Subtract)
            {
                Output = a - b;
            }
        }