本文整理汇总了C#中Envelope.TimeWarp方法的典型用法代码示例。如果您正苦于以下问题:C# Envelope.TimeWarp方法的具体用法?C# Envelope.TimeWarp怎么用?C# Envelope.TimeWarp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Envelope
的用法示例。
在下文中一共展示了Envelope.TimeWarp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TimeWarp
/// <summary>
/// Changes the msPositions of the BasicMidiChordDefs without changing the length of the MidiChordDef. Has no effect on Sliders.
/// ArgumentExceptions are thrown if BasicMidiChordDefs.Count==0 or distortion is less than 1.
/// A Debug.Assertion fails if an attempt is made to set a BasicMidiChordDef.MsDuration less than _minimumBasicMidiChordMsDuration.
/// See Envelope.TimeWarp() for a description of the arguments.
/// </summary>
/// <param name="envelope"></param>
/// <param name="distortion"></param>
public void TimeWarp(Envelope envelope, double distortion)
{
#region conditions
if(BasicMidiChordDefs.Count == 0)
{
throw new ArgumentException($"{nameof(BasicMidiChordDefs)}.Count must be greater than 0.");
}
if(distortion < 1)
{
throw new ArgumentException($"{nameof(distortion)} may not be less than 1.");
}
#endregion conditions
// if BasicMidiChordDefs.Count == 1, do nothing.
if(BasicMidiChordDefs.Count > 1)
{
int originalMsDuration = MsDuration;
List<int> originalPositions = new List<int>();
#region 1. create originalPositions
// originalPositions contains the msPositions of the BasicMidiChordDefs re the MidiChordDef
// plus the end msPosition of the final BasicMidiChordDef.
int msPos = 0;
foreach(BasicMidiChordDef bmcd in BasicMidiChordDefs)
{
originalPositions.Add(msPos);
msPos += bmcd.MsDuration;
}
originalPositions.Add(msPos); // end position of duration to warp.
#endregion
List<int> newPositions = envelope.TimeWarp(originalPositions, distortion);
for(int i = 0; i < BasicMidiChordDefs.Count; ++i)
{
BasicMidiChordDef bmcd = BasicMidiChordDefs[i];
bmcd.MsDuration = newPositions[i + 1] - newPositions[i];
Debug.Assert(_minimumBasicMidiChordMsDuration <= bmcd.MsDuration);
}
}
}
示例2: TimeWarp
/// <summary>
/// This function does not change the MsDuration of the Block.
/// See Envelope.TimeWarp() for a description of the arguments.
/// </summary>
/// <param name="envelope"></param>
/// <param name="distortion"></param>
public void TimeWarp(Envelope envelope, double distortion)
{
AssertNonEmptyBlockConsistency();
int originalMsDuration = MsDuration;
List<int> originalMsPositions = GetMsPositions();
Dictionary<int, int> warpDict = new Dictionary<int, int>();
#region get warpDict
List<int> newMsPositions = envelope.TimeWarp(originalMsPositions, distortion);
for(int i = 0; i < newMsPositions.Count; ++i)
{
warpDict.Add(originalMsPositions[i], newMsPositions[i]);
}
#endregion get warpDict
foreach(VoiceDef voiceDef in _voiceDefs)
{
List<IUniqueDef> iuds = voiceDef.UniqueDefs;
IUniqueDef iud = null;
int msPos = 0;
for(int i = 1; i < iuds.Count; ++i)
{
iud = iuds[i - 1];
msPos = warpDict[iud.MsPositionReFirstUD];
iud.MsPositionReFirstUD = msPos;
iud.MsDuration = warpDict[iuds[i].MsPositionReFirstUD] - msPos;
msPos += iud.MsDuration;
}
iud = iuds[iuds.Count - 1];
iud.MsPositionReFirstUD = msPos;
iud.MsDuration = originalMsDuration - msPos;
}
Debug.Assert(originalMsDuration == MsDuration);
for(int i = 0; i < _barlineMsPositionsReBlock.Count; ++i)
{
Debug.Assert(warpDict.ContainsKey(_barlineMsPositionsReBlock[i]));
_barlineMsPositionsReBlock[i] = warpDict[_barlineMsPositionsReBlock[i]];
}
AssertNonEmptyBlockConsistency();
}
示例3: TimeWarp
/// <summary>
/// This function does not change the MsDuration of the Seq.
/// See Envelope.TimeWarp() for a description of the arguments.
/// </summary>
/// <param name="envelope"></param>
/// <param name="distortion"></param>
public void TimeWarp(Envelope envelope, double distortion)
{
AssertSeqConsistency();
int originalMsDuration = MsDuration;
List<int> originalMsPositions = GetMsPositions();
Dictionary<int, int> warpDict = new Dictionary<int, int>();
#region get warpDict
List<int> newMsPositions = envelope.TimeWarp(originalMsPositions, distortion);
for(int i = 0; i < newMsPositions.Count; ++i)
{
warpDict.Add(originalMsPositions[i], newMsPositions[i]);
}
#endregion get warpDict
foreach(Trk trk in _trks)
{
List<IUniqueDef> iuds = trk.UniqueDefs;
IUniqueDef iud = null;
int msPos = 0;
for(int i = 1; i < iuds.Count; ++i)
{
iud = iuds[i - 1];
msPos = warpDict[iud.MsPositionReFirstUD];
iud.MsPositionReFirstUD = msPos;
iud.MsDuration = warpDict[iuds[i].MsPositionReFirstUD] - msPos;
msPos += iud.MsDuration;
}
iud = iuds[iuds.Count - 1];
iud.MsPositionReFirstUD = msPos;
iud.MsDuration = originalMsDuration - msPos;
}
Debug.Assert(originalMsDuration == MsDuration);
AssertSeqConsistency();
}