public override Task<List<TrackChunk>> Process() { var trackChunk = new List<TrackChunk> { Song.TrackContainers[ProcessorConfig.Track].SourceTrackChunk }.Concat(ProcessorConfig.IncludedTracks.Select(track => Song.TrackContainers[track].SourceTrackChunk)).Merge(); var lyricEvents = new List<TimedEvent>(); var lyricLineCount = 0; var tempoMap = Song.SourceTempoMap.Clone(); foreach (var midiEvent in trackChunk.GetTimedEvents().Where(e => e.Event.EventType == MidiEventType.Lyric)) { lyricLineCount++; midiEvent.Time = midiEvent.TimeAs<MetricTimeSpan>(tempoMap).TotalMicroseconds / 1000 + 120000; lyricEvents.Add(midiEvent); } var trackChunks = new List<TrackChunk>(); for (var i = 0; i < ProcessorConfig.PlayerCount; i++) { trackChunk = new TrackChunk(); trackChunk.AddObjects(lyricEvents); trackChunk.AddObjects(new List<ITimedObject>{new TimedEvent(new SequenceTrackNameEvent("lyric:"+lyricLineCount))}); trackChunks.Add(trackChunk); } return Task.FromResult(trackChunks); }
/// <summary> /// Creates a track chunk with the specified objects. /// </summary> /// <remarks> /// Note that only MIDI events allowed by SMF specification will be added to result track chunk. /// So instances of <see cref="TimedEvent"/> containing <see cref="SystemCommonEvent"/> or /// <see cref="SystemRealTimeEvent"/> won't be added. /// </remarks> /// <param name="timedObjects">Collection of objects to create a track chunk from.</param> /// <returns><see cref="TrackChunk"/> containing the <paramref name="timedObjects"/>.</returns> /// <exception cref="ArgumentNullException"><paramref name="timedObjects"/> is <c>null</c>.</exception> public static TrackChunk ToTrackChunk(this IEnumerable <ITimedObject> timedObjects) { ThrowIfArgument.IsNull(nameof(timedObjects), timedObjects); var trackChunk = new TrackChunk(); trackChunk.AddObjects(timedObjects); return(trackChunk); }