Example #1
0
 public void Setup()
 {
     timingPoints = new TimingPointList
     {
         new AbsoluteTimingPoint(1, 120, CommonTimeSignature),
         new RelativeTimingPoint(new MeasuredTimePosition(2, 1, 0), 120, CommonTimeSignature),   // should be at 3.000 seconds
         new RelativeTimingPoint(new MeasuredTimePosition(3, 1, 0), 180, CommonTimeSignature),   // should be at 5.000 seconds
         new RelativeTimingPoint(new MeasuredTimePosition(4, 1, 0), 180, WaltzTimeSignature),    // should be at 6.333 seconds
         new RelativeTimingPoint(new MeasuredTimePosition(6, 3, 0), 180, UncommonTimeSignature), // should be at 9.000 seconds
     };
 }
Example #2
0
        /// <summary>Parses a <seealso cref="GuidelineEditorPreset"/> from raw data wtih a specified name.</summary>
        /// <param name="name">The name of the preset.</param>
        /// <param name="rawData">The raw data of the preset that will be parsed.</param>
        public static GuidelineEditorPreset Parse(string name, string rawData)
        {
            var patternPool  = new List <GuidelineEditorPresetPattern>();
            var tracks       = new GuidelineEditorPresetTrackList();
            var timingPoints = new TimingPointList();

            var lines = rawData.GetLines().ToList();

            lines.RemoveAll(s => s.StartsWith("//"));
            int    currentLineIndex = 0;
            string currentLine;

            // Pattern pool
            for (; (currentLine = lines[currentLineIndex]).Length > 0; currentLineIndex++)
            {
                patternPool.Add(GuidelineEditorPresetPattern.Parse(currentLine));
                currentLineIndex++;
            }

            // Intermediate parameters
            currentLineIndex++;
            var split  = lines[currentLineIndex].Split('|');
            var offset = ToDouble(split[0]);
            var start  = MeasuredTimePosition.Parse(split[1]);
            var end    = MeasuredTimePosition.Parse(split[2]);

            currentLineIndex++;

            // Timing points
            for (; (currentLine = lines[currentLineIndex]).Length > 0; currentLineIndex++)
            {
                timingPoints.Add(TimingPoint.Parse(currentLine));
                currentLineIndex++;
            }

            // Tracks
            for (currentLineIndex++; currentLineIndex < lines.Count; currentLineIndex++)
            {
                // TODO: Consider caring about the track indices
                var events = new List <GuidelineEditorPresetEvent>();
                for (currentLineIndex++; currentLineIndex < lines.Count && (currentLine = lines[currentLineIndex]).Length > 0; currentLineIndex++)
                {
                    events.Add(GuidelineEditorPresetEvent.Parse(currentLine, patternPool));
                }
                tracks.Add(new GuidelineEditorPresetTrack(events));
            }

            return(new GuidelineEditorPreset(name, offset, start, end, tracks, timingPoints));
        }
Example #3
0
        /// <summary>Gets all the events of this track list and generates a track list that contains the smallest number of tracks where the events are not overlapping in any track.</summary>
        /// <param name="timingPoints">The timing points based on which to compact the tracks.</param>
        public GuidelineEditorPresetTrackList CompactTracks(TimingPointList timingPoints)
        {
            var result        = new GuidelineEditorPresetTrackList();
            var unifiedTracks = UnifyTracks();

            foreach (var e in unifiedTracks)
            {
                bool found = false;
                for (int i = 0; i < result.Count && !found; i++)
                {
                    if (found = MeasuredTimePosition.CompareByAbsolutePosition(result.tracks[i].GetEnd(timingPoints), e.TimePosition) < 0)
                    {
                        result.tracks[i].Add(e);
                    }
                }
                if (!found)
                {
                    result.Add(new GuidelineEditorPresetTrack(e));
                }
            }
            return(result);
        }
 /// <summary>Gets the duration of the track based on the <seealso cref="TimingPointList"/> of the <seealso cref="GuidelineEditorPreset"/>.</summary>
 /// <param name="timingPoints">The <seealso cref="TimingPointList"/> of the <seealso cref="GuidelineEditorPreset"/>.</param>
 public MeasuredDuration GetTrackDuration(TimingPointList timingPoints) => new MeasuredDuration(GetEnd(timingPoints));
        /// <summary>Gets the end time position of the track based on the <seealso cref="TimingPointList"/> of the <seealso cref="GuidelineEditorPreset"/>.</summary>
        /// <param name="timingPoints">The <seealso cref="TimingPointList"/> of the <seealso cref="GuidelineEditorPreset"/>.</param>
        public MeasuredTimePosition GetEnd(TimingPointList timingPoints)
        {
            var max = events.Maximum;

            return(max.GetEnd(timingPoints.TimingPointAtTime(max.TimePosition).TimeSignature));
        }
Example #6
0
 /// <summary>Creates a new instance of the <seealso cref="GuidelineEditorPreset"/> class.</summary>
 /// <param name="name">The name of the preset.</param>
 /// <param name="offset">The offset, in seconds, of the preset.</param>
 /// <param name="start">The starting position from which to generate the guidelines.</param>
 /// <param name="end">The ending position at which to stop generating the guidelines.</param>
 /// <param name="presetTracks">The tracks of the preset.</param>
 /// <param name="presetTimingPoints">The timing points of the preset.</param>
 public GuidelineEditorPreset(string name, double offset, MeasuredTimePosition start, MeasuredTimePosition end, GuidelineEditorPresetTrackList presetTracks, TimingPointList presetTimingPoints)
     : this(name, offset, start, end)
 {
     Tracks       = presetTracks.Clone();
     TimingPoints = presetTimingPoints;
 }