Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected double CalcCurrentVolume(bool ignoreVelocity)
        {
            double v = 1;

            v *= ParentModule.Expressions[NoteOnEvent.Channel] / 127d;
            v *= ParentModule.Volumes[NoteOnEvent.Channel] / 127d;
            if (!ignoreVelocity && string.IsNullOrWhiteSpace(Timbre.MDS.VelocityMap))
            {
                v *= NoteOnEvent.Velocity / 127d;
            }

            CombinedTimbreSettings parent = ParentModule.TryGetBaseTimbreSettings(NoteOnEvent, Timbre, BaseTimbreIndex);

            if (AdsrEngine != null)
            {
                v *= AdsrEngine.OutputLevel;
            }

            if (FxEngine != null)
            {
                v *= FxEngine.OutputLevel;
            }

            v *= ArpeggiateLevel;

            if (parent != null)
            {
                v += parent.VolumeOffest;
            }
            if (v > 1.0)
            {
                v = 1.0;
            }
            else if (v < 0.0)
            {
                v = 0.0;
            }

            return(v);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected double CalcCurrentPitchDeltaNoteNumber()
        {
            CombinedTimbreSettings parent = ParentModule.TryGetBaseTimbreSettings(NoteOnEvent, Timbre, BaseTimbreIndex);
            int pKeyShift   = parent != null ? parent.KeyShift : 0;
            int pPitchShift = parent != null ? parent.PitchShift : 0;

            var pitch = (int)ParentModule.Pitchs[NoteOnEvent.Channel] - 8192;
            var range = (int)ParentModule.PitchBendRanges[NoteOnEvent.Channel];
            var scale = (int)ParentModule.ScaleTunings[NoteOnEvent.Channel].ScalesNums[(int)Math.Abs(NoteOnEvent.NoteNumber + Timbre.MDS.KeyShift + pKeyShift) % 12];

            double d1 = ((double)pitch / 8192d) * range;
            double d  = d1 + ModultionDeltaNoteNumber + PortamentoDeltaNoteNumber + ArpeggiateDeltaNoteNumber +
                        pKeyShift + Timbre.MDS.KeyShift +
                        ((pPitchShift + Timbre.MDS.PitchShift) / 100d) + (scale / 100d);

            if (FxEngine != null)
            {
                d += FxEngine.DeltaNoteNumber;
            }

            lastPitch = d;
            return(d);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected byte CalcCurrentPanpot()
        {
            int pan = ParentModule.Panpots[NoteOnEvent.Channel] - 1;

            if (FxEngine != null)
            {
                pan += FxEngine.PanShift;
            }

            if (ParentModule.ChannelTypes[NoteOnEvent.Channel] == ChannelType.Drum)
            {
                pan += (int)ParentModule.DrumTimbres[NoteOnEvent.NoteNumber].PanShift;
            }
            else
            {
                pan += Timbre.MDS.PanShift;
            }

            CombinedTimbreSettings parent = ParentModule.TryGetBaseTimbreSettings(NoteOnEvent, Timbre, BaseTimbreIndex);

            if (parent != null)
            {
                pan += parent.PanShift;
            }

            if (pan < 0)
            {
                pan = 0;
            }
            else if (pan > 127)
            {
                pan = 127;
            }

            return((byte)pan);
        }