public static void PlayPitch(McPitch pitch) { if (pitch.Volume >= 0.001f) { McNotePack parentNotePack = pitch.ParentNotePack; MusicCanvasControl canvas = parentNotePack.Canvas; McMeasure parentMeasure = parentNotePack.ParentMeasure; float num = ((parentMeasure.TemporaryInfo.RelativeX + McNotation.Margin.Left) + McRegularTrack.Margin.Left) - canvas.ScrollXSmooth; float num2 = ((((McRegularTrack.Margin.Bottom + McRegularTrack.Margin.Top) + McMeasure.Height) * parentMeasure.ParentRegularTrack.Index) + McNotation.Margin.Top) + McRegularTrack.Margin.Top; float x = (num + parentNotePack.TemporaryInfo.RelativeXSmooth) + 8f; if (parentNotePack.Staccato) { canvas.PlaySound(parentMeasure.InstrumentType, pitch.AlterantValue, pitch.Volume, (long)parentNotePack.TemporaryInfo.PlayingDurationTimeMs, 0.03f); } else { canvas.PlaySound(parentMeasure.InstrumentType, pitch.AlterantValue, pitch.Volume, (long)parentNotePack.TemporaryInfo.PlayingDurationTimeMs, 0.03f); } int num4 = parentNotePack.IsRest ? (((parentMeasure.ClefType == McMeasure.ClefTypes.L2G) ? 0x2c : 0x17) + 5) : pitch.Value; float measureLineRelativeY = pitch.MeasureLineRelativeY; float num6 = 3.141593f * (((float)num4) / 88f); Color color = parentNotePack.IsRest ? Color.FromArgb(0x80, Color.White) : Color.FromArgb(0xff, (int)(((Math.Cos((double)num6) + 1.0) / 2.0) * 255.0), (int)(((Math.Sin((double)num6) + 1.0) / 2.0) * 255.0), (int)(((Math.Cos((double)num6) + 1.0) / 2.0) * 255.0)); MusicCanvasControl.RippleAniManager.Append(x, num2 + measureLineRelativeY, color, 10 + ((int)(30f * parentNotePack.Volume)), 0.5f, parentNotePack); } }
public static Arpeggio AppendArpeggio(McNotePack notePack, float intervalSpeedScale = 2f) { McPitch[] validPitchArray = notePack.ValidPitchArray; switch (notePack.ArpeggioMode) { case ArpeggioTypes.Upward: PlayPitch(validPitchArray.First <McPitch>()); break; case ArpeggioTypes.Downward: PlayPitch(validPitchArray.Last <McPitch>()); break; case ArpeggioTypes.None: foreach (McPitch pitch in validPitchArray) { PlayPitch(pitch); } return(null); } Arpeggio item = new Arpeggio(notePack, intervalSpeedScale); ActivatedArpeggios.Add(item); return(item); }
private Arpeggio(McNotePack notePack, float intervalSpeedScale = 2f) { this.NotePack = notePack; this.ElapsedTimeMs = 0; this.PlayedPitchCount = 1; this.IntervalSpeedScale = intervalSpeedScale.Clamp(0.5f, 4f); }
public static McPitch FromNaturalPitchValue(McNotePack parent, int naturaPitch, PitchTypes pitchType = 2) { if (!IsNatural(naturaPitch)) { return(null); } return(new McPitch(parent, naturaPitch, pitchType)); }
public static int CalculateInterval(McNotePack notePack, float intervalSpeedScale = 2f) { if ((notePack == null) || (notePack.ArpeggioMode == ArpeggioTypes.None)) { return(0); } int num = (int)(((1000f / intervalSpeedScale) * 60f) / ((float)notePack.ParentMeasure.BeatsPerMinute)); return(num / notePack.ValidPitchCount.Clamp(4, 8)); }
private McPitch(McNotePack parent, int naturePitch, PitchTypes pitchType) { this._parentNotePack = parent; this._value = naturePitch; this._semitoneValue = GetSemitoneValue(naturePitch); this._toneValue = GetToneValue(naturePitch); this._scaleLevel = GetScaleLevel(naturePitch); this._pitchType = pitchType; if (((parent != null) && parent.IsViald) && (this._pitchType != PitchTypes.Temporary)) { McUtility.MarkModified(parent.ParentMeasure); } }
public static void Clear() { if (_hoveringNotePack != null) { _hoveringNotePack.IsHovering = false; } if (_hoveringMeasure != null) { _hoveringMeasure.IsHovering = false; McUtility.AppendRedrawingMeasure(_hoveringMeasure); } _hoveringInsertNotePackIndex = -1; _hoveringInsertPitchValue = 0; _hoveringNotePack = null; _hoveringMeasure = null; }
public McNotePack Clone(McMeasure measure) { McNotePack pack = new McNotePack(measure ?? this.ParentMeasure) { _isRest = this._isRest, _isDotted = this._isDotted, _tieType = this._tieType, _triplet = this._triplet, _durationType = this._durationType, _staccato = this._staccato, _arpeggioMode = this._arpeggioMode }; foreach (int num in this.ValidPitchValueArray) { McPitch pitch = this._pitches[num]; if (((pitch != null) && (pitch.PitchType == McPitch.PitchTypes.Enabled)) && pack.MarkPitch(pitch.Value, McPitch.PitchTypes.Enabled)) { pack.GetPitch(pitch.Value).AlterantType = pitch.RawAlterantType; } } return(pack); }
public static void DrawTie(this RenderTarget renderTarget, SharpDX.DirectWrite.Factory writeFactory, McNotePack startNotePack, McNotePack endNotePack, Color color, bool isTriplet = false) { float scrollXSmooth; RawVector2 startPos = new RawVector2(); RawVector2 endPos = new RawVector2(); bool flipVertical = false; if (startNotePack != null) { McNotePack.NpTemporaryInfo temporaryInfo = startNotePack.TemporaryInfo; temporaryInfo.TieMarkerRelativeYSmooth = temporaryInfo.TieMarkerRelativeYSmooth.Lerp(temporaryInfo.TieMarkerRelativeY, 0.2f); McMeasure parentMeasure = startNotePack.ParentMeasure; scrollXSmooth = parentMeasure.ParentRegularTrack.ParentNotation.Canvas.ScrollXSmooth; RawVector2 vector3 = new RawVector2(((parentMeasure.TemporaryInfo.RelativeX + McNotation.Margin.Left) + McRegularTrack.Margin.Left) - scrollXSmooth, (float)parentMeasure.Top); startPos = new RawVector2((vector3.X + temporaryInfo.RelativeXSmooth) + 8f, vector3.Y + temporaryInfo.TieMarkerRelativeYSmooth); flipVertical = temporaryInfo.IsFlipVerticalStemVoted; } if (endNotePack != null) { McNotePack.NpTemporaryInfo info2 = endNotePack.TemporaryInfo; info2.TieMarkerRelativeYSmooth = info2.TieMarkerRelativeYSmooth.Lerp(info2.TieMarkerRelativeY, 0.2f); McMeasure measure2 = endNotePack.ParentMeasure; scrollXSmooth = measure2.ParentRegularTrack.ParentNotation.Canvas.ScrollXSmooth; RawVector2 vector4 = new RawVector2(((measure2.TemporaryInfo.RelativeX + McNotation.Margin.Left) + McRegularTrack.Margin.Left) - scrollXSmooth, (float)measure2.Top); endPos = new RawVector2((vector4.X + info2.RelativeXSmooth) + 8f, vector4.Y + info2.TieMarkerRelativeYSmooth); } if (isTriplet) { if (endNotePack == null) { renderTarget.DrawTextLayout(writeFactory, "Tri", new RawVector2(startPos.X - 6f, startPos.Y - 5f), "Consolas", 10f, Color.FromArgb(0x80, Color.Aqua), SharpDX.DirectWrite.FontStyle.Italic); } } else if ((startNotePack != null) && (endNotePack == null)) { renderTarget.DrawTextLayout(writeFactory, startNotePack.TieType.ToString().Substring(0, 1), new RawVector2(startPos.X - 12f, startPos.Y - 4f), "Consolas", 10f, Color.FromArgb(0x40, Color.FloralWhite), SharpDX.DirectWrite.FontStyle.Italic); } else if ((startNotePack == null) && (endNotePack != null)) { renderTarget.DrawTextLayout(writeFactory, endNotePack.TieType.ToString().Substring(0, 1), new RawVector2(endPos.X - 12f, endPos.Y - 4f), "Consolas", 10f, Color.FromArgb(0x40, Color.FloralWhite), SharpDX.DirectWrite.FontStyle.Italic); } if ((startNotePack != null) && (endNotePack != null)) { renderTarget.DrawTie(writeFactory, startPos, endPos, color, flipVertical, isTriplet); } }