예제 #1
0
        private void ManageButtonsActivation(List <Button> buttons, Oscillator oscillator)
        {
            foreach (Button button in buttons)
            {
                //The tag should look like this: 1S  ->  Oscillator 1, sine waveform
                string tag = button.Tag.ToString();
                //The second char of the tag is the type of waveform
                SignalGeneratorType signalGeneratorType = GetSignalGeneratorType(tag[1]);

                button.Enabled = signalGeneratorType != oscillator.WaveType;
            }
        }
예제 #2
0
        public MIDIPlayer(int pDeviceIndex, Oscillator o1, Oscillator o2, Oscillator o3)
        {
            DeviceIndex = pDeviceIndex;
            Device      = new MidiIn(DeviceIndex);

            O1 = o1;
            O2 = o2;
            O3 = o3;

            _midiNotes = ComputeMidiNotes();

            _disposed = false;
        }
예제 #3
0
        public SynthView()
        {
            InitializeComponent();
            KeyPreview = true;
            o1         = new Oscillator();
            o2         = new Oscillator();
            o3         = new Oscillator();

            Oscillator1Buttons = new List <Button>()
            {
                btnNoise1,
                btnSawTooth1,
                btnSine1,
                btnSquare1,
                btnTriangle1
            };
            Oscillator2Buttons = new List <Button>()
            {
                btnNoise2,
                btnSawTooth2,
                btnSine2,
                btnSquare2,
                btnTriangle2
            };
            Oscillator3Buttons = new List <Button>()
            {
                btnNoise3,
                btnSawTooth3,
                btnSine3,
                btnSquare3,
                btnTriangle3
            };

            //If there is a midi device, we create a new midi player
            if (MidiIn.NumberOfDevices > 0)
            {
                midiPlayer = new MIDIPlayer(DEFAULT_MIDI_DEVICE_ID, o1, o2, o3);
            }
        }
예제 #4
0
        private void ManageEnabledActivation(List <Button> buttons, ref TrackBar trb, ref Oscillator oscillator, bool enabled)
        {
            oscillator.IsEnabled = enabled;
            foreach (Button btn in buttons)
            {
                btn.Enabled = enabled;
            }
            trb.Enabled = enabled;

            if (enabled)
            {
                ManageButtonsActivation(buttons, oscillator);
            }
        }
예제 #5
0
 private void ChangeWaveType(ref Oscillator oscillator, List <Button> buttons, SignalGeneratorType signalGeneratorType)
 {
     oscillator.WaveType = signalGeneratorType;
     ManageButtonsActivation(buttons, oscillator);
 }