/// <summary> /// Each IUniqueChordDef is transposed by the interval current at its position. /// The argument contains a dictionary[msPosition, transposition]. /// </summary> /// <param name="msPosTranspositionDict"></param> public void TransposeToDict(Dictionary <int, int> msPosTranspositionDict) { List <int> dictPositions = new List <int>(msPosTranspositionDict.Keys); int currentMsPos = dictPositions[0]; int j = 0; for (int i = 1; i < msPosTranspositionDict.Count; ++i) { int transposition = msPosTranspositionDict[currentMsPos]; int nextMsPos = dictPositions[i]; while (j < _uniqueDefs.Count && _uniqueDefs[j].MsPosition < nextMsPos) { if (_uniqueDefs[j].MsPosition >= currentMsPos) { IUniqueChordDef iucd = _uniqueDefs[j] as IUniqueChordDef; if (iucd != null) { iucd.Transpose(transposition); } } ++j; } currentMsPos = nextMsPos; } }
public CautionaryChordDef(IUniqueChordDef chordDef, int msPosition, int msDuration) { _midiPitches = new List<byte>(); foreach(byte midiPitch in chordDef.NotatedMidiPitches) { _midiPitches.Add(midiPitch); } MsPosition = msPosition; MsDuration = msDuration; }
public CautionaryChordDef(IUniqueChordDef chordDef, int msPosition, int msDuration) { _midiPitches = new List <byte>(); foreach (byte midiPitch in chordDef.NotatedMidiPitches) { _midiPitches.Add(midiPitch); } MsPosition = msPosition; MsDuration = msDuration; }
public CautionaryChordDef(IUniqueChordDef chordDef, int msPositionReFirstIUD, int msDuration) { NotatedMidiPitches = chordDef.NotatedMidiPitches; if (chordDef is MidiChordDef midiChordDef) { NotatedMidiVelocities = chordDef.NotatedMidiVelocities; } MsPositionReFirstUD = msPositionReFirstIUD; MsDuration = msDuration; }
/// <summary> /// Transpose all the IUniqueChordDefs from beginIndex to (not including) endIndex /// up by the number of semitones given in the interval argument. /// IUniqueChordDefs are MidiChordDef, InputChordDef and CautionaryChordDef. /// Negative interval values transpose down. /// It is not an error if Midi pitch values would exceed the range 0..127. /// In this case, they are silently coerced to 0 or 127 respectively. /// </summary> /// <param name="interval"></param> public void Transpose(int beginIndex, int endIndex, int interval) { CheckIndices(beginIndex, endIndex); for (int i = beginIndex; i < endIndex; ++i) { IUniqueChordDef iucd = _uniqueDefs[i] as IUniqueChordDef; if (iucd != null) { iucd.Transpose(interval); } } }
public CautionaryChordDef(IUniqueChordDef chordDef, int msPositionReFirstIUD, int msDuration) { NotatedMidiPitches = chordDef.NotatedMidiPitches; MidiChordDef midiChordDef = chordDef as MidiChordDef; if(midiChordDef != null) { NotatedMidiVelocities = chordDef.NotatedMidiVelocities; } MsPositionReFirstUD = msPositionReFirstIUD; MsDuration = msDuration; }
/// <summary> /// Transposes all the MidiHeadSymbols in this VoiceDef by the number of semitones in the argument /// without changing the sound. Negative arguments transpose downwards. /// If the resulting midiHeadSymbol would be less than 0 or greater than 127, /// it is silently coerced to 0 or 127 respectively. /// </summary> /// <param name="p"></param> public void TransposeNotation(int semitonesToTranspose) { foreach (IUniqueDef iud in _uniqueDefs) { IUniqueChordDef iucd = iud as IUniqueChordDef; if (iucd != null) { List <byte> midiPitches = iucd.NotatedMidiPitches; for (int i = 0; i < midiPitches.Count; ++i) { midiPitches[i] = M.MidiValue(midiPitches[i] + semitonesToTranspose); } } } }
/// <summary> /// Transposes the UniqueDefs from the beginIndex upto (but not including) endIndex /// by an equally increasing amount, so that the final MidiChordDef or InputChordDef is transposed by glissInterval. /// beginIndex must be less than endIndex. /// glissInterval can be negative. /// </summary> public void StepwiseGliss(int beginIndex, int endIndex, int glissInterval) { CheckIndices(beginIndex, endIndex); Debug.Assert(beginIndex < endIndex); int nNonMidiChordDefs = GetNumberOfNonMidiOrInputChordDefs(beginIndex, endIndex); int nSteps = (endIndex - beginIndex - nNonMidiChordDefs); double interval = ((double)glissInterval) / nSteps; double step = interval; for (int i = beginIndex; i < endIndex; ++i) { MidiChordDef mcd = _uniqueDefs[i] as MidiChordDef; InputChordDef icd = _uniqueDefs[i] as InputChordDef; IUniqueChordDef iucd = (mcd == null) ? (IUniqueChordDef)icd : (IUniqueChordDef)mcd; if (iucd != null) { iucd.Transpose((int)Math.Round(interval)); interval += step; } } }