Пример #1
0
        /// <summary>
        /// ACHTUNG: This function is deprecated!! Use the other AdjustVelocitiesHairpin(...).
        /// First creates a hairpin in the velocities from beginIndex to endIndex (non-inclusive),
        /// then adjusts all the remaining velocities in this VoiceDef by the finalFactor.
        /// endIndex must be greater than beginIndex + 1.
        /// The factors by which the velocities are multiplied change arithmetically: The velocities
        /// at beginIndex are multiplied by 1.0, and the velocities from endIndex to the end of the
        /// VoiceDef by finalFactor.
        /// Can be used to create a diminuendo or crescendo.
        /// </summary>
        /// <param name="beginDimIndex"></param>
        /// <param name="endDimIndex"></param>
        /// <param name="p"></param>
        public void AdjustVelocitiesHairpin(int beginIndex, int endIndex, double finalFactor)
        {
            Debug.Assert(((beginIndex + 1) < endIndex) && (finalFactor >= 0) && (endIndex <= Count));

            int nNonMidiChordDefs = GetNumberOfNonMidiOrInputChordDefs(beginIndex, endIndex);

            double factorIncrement = (finalFactor - 1.0) / (endIndex - beginIndex - nNonMidiChordDefs);
            double factor          = 1.0;

            for (int i = beginIndex; i < endIndex; ++i)
            {
                MidiChordDef iumdd = _uniqueDefs[i] as MidiChordDef;
                if (iumdd != null)
                {
                    iumdd.AdjustVelocities(factor);
                    factor += factorIncrement;
                }
            }

            for (int i = endIndex; i < _uniqueDefs.Count; ++i)
            {
                MidiChordDef iumdd = _uniqueDefs[i] as MidiChordDef;
                if (iumdd != null)
                {
                    iumdd.AdjustVelocities(factor);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Multiplies each velocity value in the MidiChordDefs
 /// from beginIndex to (not including) endIndex by the argument factor.
 /// </summary>
 public void AdjustVelocities(int beginIndex, int endIndex, double factor)
 {
     CheckIndices(beginIndex, endIndex);
     for (int i = beginIndex; i < endIndex; ++i)
     {
         MidiChordDef iumdd = _uniqueDefs[i] as MidiChordDef;
         if (iumdd != null)
         {
             iumdd.AdjustVelocities(factor);
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Grp objects own unique IUniqueDefs, but can share Gamuts. The Gamut may not be null.
        /// </summary>
        /// <param name="gamut">can not be null</param>
        /// <param name="rootOctave">must be greater than or equal to 0</param>
        /// <param name="nPitchesPerChord">must be greater than 0</param>
        /// <param name="msDurationPerChord">must be greater than 0</param>
        /// <param name="nChords">must be greater than 0</param>
        /// <param name="velocityFactor">must be greater than 0.0</param>
        public Grp(Gamut gamut, int rootOctave, int nPitchesPerChord, int msDurationPerChord, int nChords, double velocityFactor)
            : base(0, 0, new List<IUniqueDef>())
        {
            Debug.Assert(gamut != null);
            Debug.Assert(rootOctave >= 0);
            Debug.Assert(nPitchesPerChord > 0);
            Debug.Assert(msDurationPerChord > 0);
            Debug.Assert(nChords > 0);
            Debug.Assert(velocityFactor > 0.0);

            _gamut = gamut;

            for(int i = 0; i < nChords; ++i)
            {
                int rootNotatedPitch;
                if(i == 0)
                {
                    rootNotatedPitch = gamut.AbsolutePitchHierarchy[i] + (12 * rootOctave);
                    rootNotatedPitch = (rootNotatedPitch <= gamut.MaxPitch) ? rootNotatedPitch : gamut.MaxPitch;
                }
                else
                {
                    List<byte> previousPitches = ((MidiChordDef)_uniqueDefs[i - 1]).BasicMidiChordDefs[0].Pitches;
                    if(previousPitches.Count > 1)
                    {
                        rootNotatedPitch = previousPitches[1];
                    }
                    else
                    {
                        rootNotatedPitch = gamut.AbsolutePitchHierarchy[i];
                        while(rootNotatedPitch < previousPitches[0])
                        {
                            rootNotatedPitch += 12;
                            if(rootNotatedPitch > gamut.MaxPitch)
                            {
                                rootNotatedPitch = gamut.MaxPitch;
                                break;
                            }
                        }
                    }
                }
                MidiChordDef mcd = new MidiChordDef(msDurationPerChord, gamut, rootNotatedPitch, nPitchesPerChord, null);
                mcd.AdjustVelocities(velocityFactor);
                _uniqueDefs.Add(mcd);
            }

            SetBeamEnd();
        }
Пример #4
0
        /// Creates a hairpin in the velocities from startMsPosition to endMsPosition (non-inclusive).
        /// This function does NOT change velocities outside the range given in its arguments.
        /// There must be at least two IUniqueMidiDurationDefs in the msPosition range given in the arguments.
        /// The factors by which the velocities are multiplied change arithmetically:
        /// The velocity of the first IUniqueMidiDurationDefs is multiplied by startFactor, and the velocity
        /// of the last MidiChordDef in range by endFactor.
        /// Can be used to create a diminueno or crescendo.
        public void AdjustVelocitiesHairpin(int startMsPosition, int endMsPosition, double startFactor, double endFactor)
        {
            int beginIndex = FindIndexAtMsPosition(startMsPosition);
            int endIndex   = FindIndexAtMsPosition(endMsPosition);

            Debug.Assert(((beginIndex + 1) < endIndex) && (startFactor >= 0) && (endFactor >= 0) && (endIndex <= Count));

            int nNonMidiChordDefs = GetNumberOfNonMidiOrInputChordDefs(beginIndex, endIndex);

            double            factorIncrement = (endFactor - startFactor) / (endIndex - beginIndex - nNonMidiChordDefs);
            double            factor          = startFactor;
            List <IUniqueDef> lmdds           = _uniqueDefs;

            for (int i = beginIndex; i < endIndex; ++i)
            {
                MidiChordDef iumdd = _uniqueDefs[i] as MidiChordDef;
                if (iumdd != null)
                {
                    iumdd.AdjustVelocities(factor);
                    factor += factorIncrement;
                }
            }
        }