Exemplo n.º 1
0
        /// <summary>
        /// The rootPitch and all the pitches in the MidiChordDef must be contained in the gamut.
        /// The vertical velocity sequence remains unchanged except when notes are removed because they are duplicates.
        /// Calculates the number of steps to transpose, and then calls TransposeStepsInGamut.
        /// When this function returns, rootPitch is the lowest pitch in both BasicMidiChordDefs[0] and NotatedMidiPitches.
        /// </summary>
        public void TransposeToRootInGamut(Gamut gamut, int rootPitch)
        {
            #region conditions
            Debug.Assert(gamut != null);
            Debug.Assert(gamut.Contains(rootPitch));
            Debug.Assert(gamut.Contains(BasicMidiChordDefs[0].Pitches[0]));
            #endregion conditions

            int stepsToTranspose = gamut.IndexOf(rootPitch) - gamut.IndexOf(BasicMidiChordDefs[0].Pitches[0]);

            // checks that all the pitches are in the gamut.
            TransposeStepsInGamut(gamut, stepsToTranspose);
        }
Exemplo n.º 2
0
        private byte DoTranspose(byte initialValue, Gamut gamut, int steps)
        {
            int index = gamut.IndexOf(initialValue);
            int newIndex = index + steps;
            newIndex = (newIndex >= 0) ? newIndex : 0;
            newIndex = (newIndex < gamut.Count) ? newIndex : gamut.Count - 1;

            return (byte)gamut[newIndex];
        }
Exemplo n.º 3
0
 private void OppositePitches(Gamut gamut, Gamut oppositeGamut, List<byte> pitches)
 {
     for(int i = 0; i < pitches.Count; ++i)
     {
         int pitchIndex = gamut.IndexOf(pitches[i]);
         // N.B. it is not necessarily true that gamut.Count == oppositeGamut.Count.
         pitchIndex = (pitchIndex < oppositeGamut.Count) ? pitchIndex : oppositeGamut.Count - 1;
         pitches[i] = (byte)oppositeGamut[pitchIndex];
     }
 }