Esempio n. 1
0
        private void SetPluginBpm(VstPlugin plugin)
        {
            if (plugin == null)
            {
                return;
            }
            if (BpmProvider == null)
            {
                return;
            }

            if (!plugin.Parameters.Any(x => x.SyncToBpm))
            {
                return;
            }

            var bpm = BpmProvider.GetCurrentBpm();
            var quarterNoteLength = BpmHelper.GetDefaultDelayLength(bpm);
            var fullNoteLength    = quarterNoteLength * 4;

            var syncParameters = plugin.Parameters.Where(p => p.SyncToBpm).ToList();

            var mutePlugin = syncParameters.Any(p => p.SyncNotes == 0);

            BassVst.BASS_VST_SetBypass(plugin.Id, mutePlugin);

            if (mutePlugin)
            {
                return;
            }

            foreach (var parameter in syncParameters)
            {
                var syncLength    = fullNoteLength * (double)parameter.SyncNotes;
                var vstDelayValue = GetVstSyncValue(syncLength, parameter);
                BassVst.BASS_VST_SetParam(plugin.Id, parameter.Id, vstDelayValue);
            }
        }