Exemplo n.º 1
0
        public void SetKeyAndScaleMode(MusicMathUtils.Note rootNote, MusicMathUtils.ScaleMode scaleMode)
        {
            _rootNote  = rootNote;
            _scaleMode = scaleMode;

            if (_droneSynthPtr == IntPtr.Zero)
            {
                return;
            }

            double baseFrequency = MusicMathUtils.ScaleIntervalToFrequency(ScaleInterval, _rootNote, _scaleMode, Octave);

            DroneSynth_SetOsc1TargetFrequency(_droneSynthPtr, baseFrequency * MusicMathUtils.SemitonesToPitch(Osc1Pitch), false);
            DroneSynth_SetOsc2TargetFrequency(_droneSynthPtr, baseFrequency * MusicMathUtils.SemitonesToPitch(Osc2Pitch), false);
        }
Exemplo n.º 2
0
        private void UpdateSettings(bool force)
        {
            if (PresetId != _presetId)
            {
                ApplyPreset();
            }

            if (_droneSynthPtr == IntPtr.Zero)
            {
                return;
            }

            bool updateOscFrequency = false;

            if (force || LfoCycleMultiplier != _lfoCycleMultiplier)
            {
                _lfoCycleMultiplier = LfoCycleMultiplier;
                DroneSynth_SetLfoFrequency(_droneSynthPtr, _mainLfoFrequency / _lfoCycleMultiplier);
            }

            if (force || ScaleInterval != _scaleInterval)
            {
                _scaleInterval     = ScaleInterval;
                updateOscFrequency = true;
            }

            if (force || Octave != _octave)
            {
                _octave            = Octave;
                updateOscFrequency = true;
            }

            if (force || MainVolume != _mainVolume)
            {
                _mainVolume = MainVolume;
                DroneSynth_SetMainVolume(_droneSynthPtr, _mainVolume);
            }

            if (force || Osc1Volume != _osc1Volume)
            {
                _osc1Volume = Osc1Volume;
                DroneSynth_SetOsc1Volume(_droneSynthPtr, _osc1Volume);
            }

            if (force || updateOscFrequency || Osc1Pitch != _osc1Pitch)
            {
                _osc1Pitch = Osc1Pitch;
                double baseFrequency = MusicMathUtils.ScaleIntervalToFrequency(ScaleInterval, _rootNote, _scaleMode, Octave);
                DroneSynth_SetOsc1TargetFrequency(_droneSynthPtr, baseFrequency * MusicMathUtils.SemitonesToPitch(Osc1Pitch), force);
            }

            if (force || Osc1WavetableAmount != _osc1WavetableAmount)
            {
                _osc1WavetableAmount = Osc1WavetableAmount;
                DroneSynth_SetOsc1WavetableAmount(_droneSynthPtr, _osc1WavetableAmount);
            }

            if (force || Osc2Volume != _osc2Volume)
            {
                _osc2Volume = Osc2Volume;
                DroneSynth_SetOsc2Volume(_droneSynthPtr, _osc2Volume);
            }

            if (force || updateOscFrequency || Osc2Pitch != _osc2Pitch)
            {
                _osc2Pitch = Osc2Pitch;
                double baseFrequency = MusicMathUtils.ScaleIntervalToFrequency(ScaleInterval, _rootNote, _scaleMode, Octave);
                DroneSynth_SetOsc2TargetFrequency(_droneSynthPtr, baseFrequency * MusicMathUtils.SemitonesToPitch(Osc2Pitch), force);
            }

            if (force || Osc2WavetableAmount != _osc2WavetableAmount)
            {
                _osc2WavetableAmount = Osc2WavetableAmount;
                DroneSynth_SetOsc2WavetableAmount(_droneSynthPtr, _osc2WavetableAmount);
            }
        }