-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b435f09
commit 2fe3ce5
Showing
323 changed files
with
8,315 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Melanchall.DryWetMidi.Nativeless" Version="7.0.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using ChartTools.IO; | ||
using ChartTools.IO.Chart; | ||
using ChartTools.Extensions.Linq; | ||
using ChartTools.Lyrics; | ||
|
||
namespace ChartTools.Events; | ||
|
||
/// <summary> | ||
/// Provides additional methods for events. | ||
/// </summary> | ||
public static class EventExtensions | ||
{ | ||
public static void ToFile(this IEnumerable<GlobalEvent> events, string path) => ExtensionHandler.Write(path, events, (".chart", (path, events) => ChartFile.ReplaceGlobalEvents(path, events))); | ||
public static async Task ToFileAsync(this IEnumerable<GlobalEvent> events, string path, CancellationToken cancellationToken) => await ExtensionHandler.WriteAsync(path, events, (".chart", (path, events) => ChartFile.ReplaceGlobalEventsAsync(path, events, cancellationToken))); | ||
|
||
/// <summary> | ||
/// Gets the lyrics from an enumerable of <see cref="GlobalEvent"/> | ||
/// </summary> | ||
/// <returns>Enumerable of <see cref="Phrase"/></returns> | ||
public static IEnumerable<Phrase> GetLyrics(this IEnumerable<GlobalEvent> globalEvents) | ||
{ | ||
Phrase? phrase = null; | ||
|
||
foreach (GlobalEvent globalEvent in globalEvents.OrderBy(e => e.Position)) | ||
switch (globalEvent.EventType) | ||
{ | ||
// Change active phrase | ||
case EventTypeHelper.Global.PhraseStart: | ||
if (phrase is not null) | ||
yield return phrase; | ||
|
||
phrase = new Phrase(globalEvent.Position); | ||
break; | ||
// Add syllable to the active phrase using the event argument | ||
case EventTypeHelper.Global.Lyric: | ||
phrase?.Syllables.Add(new(globalEvent.Position - phrase.Position, VocalPitchValue.None) { RawText = globalEvent.Argument ?? string.Empty }); | ||
break; | ||
// Set length of active phrase | ||
case EventTypeHelper.Global.PhraseEnd: | ||
if (phrase is not null) | ||
phrase.LengthOverride = globalEvent.Position - phrase.Position; | ||
break; | ||
} | ||
|
||
if (phrase is not null) | ||
yield return phrase; | ||
} | ||
/// <summary> | ||
/// Gets a set of <see cref="GlobalEvent"/> where phrase and lyric events are replaced with the events making up a set of <see cref="Phrase"/>. | ||
/// </summary> | ||
/// <returns>Enumerable of <see cref="GlobalEvent"/></returns> | ||
public static IEnumerable<GlobalEvent> SetLyrics(this IEnumerable<GlobalEvent> events, IEnumerable<Phrase> lyrics) | ||
{ | ||
IEnumerable<GlobalEvent>[] collections = | ||
[ | ||
events.Where(e => !e.IsLyricEvent), | ||
lyrics.SelectMany(p => p.ToGlobalEvents()) | ||
]; | ||
|
||
foreach (var globalEvent in collections.AlternateBy(i => i.Position)) | ||
yield return globalEvent; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.