Skip to content

Commit

Permalink
Merge branch 'main' into ytmm-export-update
Browse files Browse the repository at this point in the history
  • Loading branch information
KaddaOK authored Jul 2, 2024
2 parents d6bf7cb + 27bc7fd commit 136d7ae
Show file tree
Hide file tree
Showing 66 changed files with 4,451 additions and 896 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,30 @@ jobs:
- name: Set version number
shell: pwsh
run: |
$version = "0.1.0"
echo $version
echo "VERSION_NUMBER=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
$versionNumber = "2.0.0"
$versionSuffix = "beta.1"
$infoVersion = "$versionNumber-$versionSuffix"
echo $infoVersion
echo "VERSION_NUMBER=$versionNumber" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
echo "VERSION_SUFFIX=$versionSuffix" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
echo "INFO_VERSION=$infoVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: Publish for win-x64
run: dotnet publish KaddaOK.AvaloniaApp.Windows/KaddaOK.AvaloniaApp.Windows.csproj /p:Version=${{ env.VERSION_NUMBER }}.0 /p:Configuration=Release /p:RuntimeIdentifier=win-x64 /p:PublishSingleFile=true /p:PublishDir=${{ github.workspace }}/publish
run: dotnet publish KaddaOK.AvaloniaApp.Windows/KaddaOK.AvaloniaApp.Windows.csproj /p:VersionPrefix=${{ env.VERSION_NUMBER }} /p:VersionSuffix=${{ env.VERSION_SUFFIX }} /p:Configuration=Release /p:RuntimeIdentifier=win-x64 /p:PublishSingleFile=true /p:PublishDir=${{ github.workspace }}/publish
- name: Zip for win-x64
shell: pwsh
run: Compress-Archive -Path ${{ github.workspace }}/publish/* -DestinationPath KaddaOKTools_win-x64_${{ env.VERSION_NUMBER }}.zip
run: Compress-Archive -Path ${{ github.workspace }}/publish/* -DestinationPath KaddaOKTools_win-x64_${{ env.INFO_VERSION }}.zip
- name: Upload win-x64 Artifact
uses: actions/upload-artifact@v4
with:
name: KaddaOKTools_win-x64_${{ env.VERSION_NUMBER }}
path: KaddaOKTools_win-x64_${{ env.VERSION_NUMBER }}.zip
name: KaddaOKTools_win-x64_${{ env.INFO_VERSION }}
path: KaddaOKTools_win-x64_${{ env.INFO_VERSION }}.zip
- name: Create Release
uses: ncipollo/release-action@v1.13.0
with:
artifacts: "KaddaOKTools_win-x64_${{ env.VERSION_NUMBER }}.zip"
tag: ${{ env.VERSION_NUMBER }}
artifacts: "KaddaOKTools_win-x64_${{ env.INFO_VERSION }}.zip"
tag: ${{ env.INFO_VERSION }}
21 changes: 16 additions & 5 deletions KaddaOK.AvaloniaApp.Tests/ViewModels/EditLinesViewModelTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Collections.ObjectModel;
using Avalonia.Input;
using FluentAvalonia.Core;
using KaddaOK.AvaloniaApp.Models;
using KaddaOK.AvaloniaApp.ViewModels;
using KaddaOK.AvaloniaApp.Views;
using KaddaOK.Library;
using NAudio.Wave;

Expand All @@ -26,14 +28,22 @@ private static KaraokeProcess GetNewCurrentProcess() =>
}
};

public class DummyEditLinesView : IEditLinesView
{
public bool Focus(NavigationMethod method = NavigationMethod.Unspecified, KeyModifiers keyModifiers = KeyModifiers.None)
{
return true;
}
}
public class MoveLineToPrevious
{
[Fact]
public void ShouldMergeLines()
{
var currentProcess = GetNewCurrentProcess();

var viewModel = new EditLinesViewModel(currentProcess, new LineSplitter(), new MinMaxFloatWaveStreamSampler());
var viewModel = new EditLinesViewModel(currentProcess, new LineSplitter(), new WordMerger(), new MinMaxFloatWaveStreamSampler())
{ EditLinesView = new DummyEditLinesView() };

viewModel.MoveLineToPrevious(currentProcess.ChosenLines!.Last());

Expand All @@ -47,7 +57,8 @@ public void ShouldAddSpaceToPreviousWordWhenMergingLines()
{
var currentProcess = GetNewCurrentProcess();

var viewModel = new EditLinesViewModel(currentProcess, new LineSplitter(), new MinMaxFloatWaveStreamSampler());
var viewModel = new EditLinesViewModel(currentProcess, new LineSplitter(), new WordMerger(), new MinMaxFloatWaveStreamSampler())
{ EditLinesView = new DummyEditLinesView()};

viewModel.MoveLineToPrevious(currentProcess.ChosenLines!.Last());

Expand Down Expand Up @@ -92,7 +103,7 @@ public void ShouldSetWordText()
var currentProcess = GetNewCurrentProcess();
var modelWord = currentProcess.ChosenLines![0].Words[4];
Assert.Equal("model ", modelWord.Text);
var viewModel = new EditLinesViewModel(currentProcess, new LineSplitter(), new MinMaxFloatWaveStreamSampler())
var viewModel = new EditLinesViewModel(currentProcess, new LineSplitter(), new WordMerger(), new MinMaxFloatWaveStreamSampler())
{
EditingTextOfWord = modelWord
};
Expand All @@ -107,7 +118,7 @@ public void ShouldSplitCorrectlyOnSpaces()
var currentProcess = GetNewCurrentProcess();
var modelWord = currentProcess.ChosenLines![0].Words[4];
Assert.Equal("model ", modelWord.Text);
var viewModel = new EditLinesViewModel(currentProcess, new LineSplitter(), new MinMaxFloatWaveStreamSampler())
var viewModel = new EditLinesViewModel(currentProcess, new LineSplitter(), new WordMerger(), new MinMaxFloatWaveStreamSampler())
{
EditingTextOfWord = modelWord
};
Expand All @@ -122,7 +133,7 @@ public void ShouldSplitCorrectlyOnPipes()
var currentProcess = GetNewCurrentProcess();
var modelWord = currentProcess.ChosenLines![0].Words[4];
Assert.Equal("model ", modelWord.Text);
var viewModel = new EditLinesViewModel(currentProcess, new LineSplitter(), new MinMaxFloatWaveStreamSampler())
var viewModel = new EditLinesViewModel(currentProcess, new LineSplitter(), new WordMerger(), new MinMaxFloatWaveStreamSampler())
{
EditingTextOfWord = modelWord
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AssemblyName>KaddaOKTools</AssemblyName>
<VersionPrefix>0.0.0</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 10 additions & 0 deletions KaddaOK.AvaloniaApp/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,20 @@
<Setter Property="DialogMargin" Value="0" />
<Setter Property="dialogHost:DialogHostStyle.CornerRadius" Value="10" />
</Style>
<Style Selector="TextBlock.pageTitleHeader">
<Setter Property="FontSize" Value="28" />
<Setter Property="Margin" Value="0,0,0,10" />
<Setter Property="Foreground" Value="{DynamicResource SystemBaseMediumColor}" />
</Style>
</Application.Styles>
<Application.Resources>
<local:WaveformToPointConverter x:Key="WaveformToPointConverter" />
<local:WaveformToLengthConverter x:Key="WaveformToLengthConverter" />
<local:ObjectEqualityBooleanConverter x:Key="ObjectEqualityBooleanConverter" />
<local:EnumEqualityBooleanConverter x:Key="EnumEqualityBooleanConverter" />
<local:RoundingConverter x:Key="RoundingConverter" />
<local:TimingWordIsPlayingConverter x:Key="TimingWordIsPlayingConverter" />
<local:TimingWordStartHasBeenSetConverter x:Key="TimingWordStartHasBeenSetConverter" />
<local:TimingWordEndHasBeenSetConverter x:Key="TimingWordEndHasBeenSetConverter" />
</Application.Resources>
</Application>
5 changes: 4 additions & 1 deletion KaddaOK.AvaloniaApp/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override void Initialize()

KaraokeProcess = new KaraokeProcess
{
KaraokeSource = InitialKaraokeSource.AzureSpeechService
KaraokeSource = InitialKaraokeSource.NotSelected
};

services.AddSingleton(KaraokeProcess);
Expand All @@ -37,6 +37,7 @@ public override void Initialize()
services.AddTransient<IKbpImporter, KbpImporter>();
services.AddTransient<IKbpSerializer, KbpSerializer>();
services.AddTransient<ILineSplitter, LineSplitter>();
services.AddTransient<IWordMerger, WordMerger>();
services.AddTransient<IMinMaxFloatWaveStreamSampler, MinMaxFloatWaveStreamSampler>();
services.AddTransient<IResultRanker, ResultRanker>();
services.AddTransient<IRzlrcContentsGenerator, RzlrcContentsGenerator>();
Expand All @@ -52,6 +53,8 @@ public override void Initialize()
services.AddTransient<LyricsViewModel>();
services.AddTransient<NarrowingViewModel>();
services.AddTransient<RecognizeViewModel>();
services.AddTransient<StartViewModel>();
services.AddTransient<ManualAlignViewModel>();

// Build the service provider
ServiceProvider = services.BuildServiceProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
xmlns:models="clr-namespace:KaddaOK.AvaloniaApp.Models"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="KaddaOK.AvaloniaApp.Controls.Dialogs.EditLineTimingDialog"
x:DataType="models:EditingLine">
x:DataType="models:EditingLine"
Focusable="True"
AttachedToVisualTree="UserControl_AttachedToVisualTree"
KeyDown="UserControl_KeyDown">
<dialogs:ModalDialogChrome Title="Edit Line Timing">
<Grid
RowDefinitions="50,85,100,85,90,50"
Expand Down
11 changes: 11 additions & 0 deletions KaddaOK.AvaloniaApp/Controls/Dialogs/EditLineTimingDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,16 @@ private void NewRectanglesItemsControl_PointerReleased(object? sender, PointerRe
{
EditLinesViewModel?.EditLineTimingDialogPointerReleased(sender, args);
}

private void UserControl_KeyDown(object? sender, Avalonia.Input.KeyEventArgs e)
{
EditLinesViewModel?.EditLineTimingDialogKeyDown(sender, e);
e.Handled = true;
}

private void UserControl_AttachedToVisualTree(object? sender, Avalonia.VisualTreeAttachmentEventArgs e)
{
this.Focus();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,26 @@
<Grid RowDefinitions="*,*,*,*" MaxWidth="500">
<Label
Content="{Binding StartSecond}"
IsVisible="{Binding Converter={StaticResource TimingWordStartHasBeenSetConverter}}"
HorizontalAlignment="Left" />
<Label
Content="{Binding Text}"
HorizontalAlignment="Center" />
<Label
Content="{Binding EndSecond}"
IsVisible="{Binding Converter={StaticResource TimingWordEndHasBeenSetConverter}}"
HorizontalAlignment="Right" />
<TextBlock Grid.Row="1" TextWrapping="Wrap">
Enter the new text for this timed syllable. (You may break it up into multiple words or syllables by using space or | characters,
and the timing dialog will open automatically for you to check the new distribution.)
Enter the new text for this timed syllable. (You may break it up into multiple words or syllables by using space, /, or | characters.)
</TextBlock>
<TextBox
AttachedToVisualTree="TextBox_AttachedToVisualTree"
Grid.Row="2"
Margin="0 8 0 0"
HorizontalAlignment="Stretch"
x:Name="EditWordTextBox"
Text="{Binding Text, Mode=OneWay}" />
Text="{Binding Text, Mode=OneWay}"
KeyDown="TextBox_KeyDown"/>
<StackPanel
Grid.Row="3"
Orientation="Horizontal"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.VisualTree;
using DialogHostAvalonia;

namespace KaddaOK.AvaloniaApp.Controls.Dialogs
{
public partial class EditSyllableTextDialog : UserControl
{
private DialogHost? dialogHost;

public EditSyllableTextDialog()
{
InitializeComponent();
}

private void TextBox_AttachedToVisualTree(object? sender, Avalonia.VisualTreeAttachmentEventArgs e)
{
(sender as TextBox)?.Focus();
dialogHost = this.FindAncestorOfType<DialogHost>();
}

private void TextBox_KeyDown(object? sender, Avalonia.Input.KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
dialogHost?.CloseDialogCommand.Execute(((TextBox)sender).Text);

Check warning on line 27 in KaddaOK.AvaloniaApp/Controls/Dialogs/EditSyllableTextDialog.axaml.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

Check warning on line 27 in KaddaOK.AvaloniaApp/Controls/Dialogs/EditSyllableTextDialog.axaml.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}

if (e.Key == Key.Escape)
{
dialogHost?.CloseDialogCommand.Execute(null);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Enter the text for the new line.
</TextBlock>
<TextBlock TextWrapping="Wrap">
(To separate syllables, use a | (pipe) character.)
(To separate syllables, use a / or | character.)
</TextBlock>
<Grid ColumnDefinitions="36,*,36" RowDefinitions="*,*,*,*">
<Label FontSize="10" Content="{Binding PreviousLine.StartSecond}" />
Expand Down
59 changes: 59 additions & 0 deletions KaddaOK.AvaloniaApp/Controls/Dialogs/NudgeTimingsDialog.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dialogs="clr-namespace:KaddaOK.AvaloniaApp.Controls.Dialogs"
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
xmlns:library="clr-namespace:KaddaOK.Library;assembly=KaddaOK.Library"
xmlns:viewModels="clr-namespace:KaddaOK.AvaloniaApp.ViewModels"
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="350"
x:Class="KaddaOK.AvaloniaApp.Controls.Dialogs.NudgeTimingsDialog"
x:DataType="viewModels:NudgeTimingsViewModel">
<dialogs:ModalDialogChrome Title="Nudge All Timings">
<Grid RowDefinitions="170,30,100" MaxWidth="500">
<StackPanel>
<TextBlock TextWrapping="Wrap" Margin="2">
Shift all the starts and stops in the entire song by an offset value in seconds.
</TextBlock>
<TextBlock TextWrapping="Wrap" Margin="2">
Positive values will move everything later relative to the music, and should
be applied if the scroll is happening too early.
</TextBlock>
<TextBlock TextWrapping="Wrap" Margin="2">
Negative values will move everything earlier relative to the music, and should
be applied if the scroll isn't happening early enough.
</TextBlock>
<TextBlock TextWrapping="Wrap" Margin="2">
For instance, to move everything 100ms earlier in the song to give singers more
time to react, enter -0.1 in the input below.
</TextBlock>
</StackPanel>
<Grid Grid.Row="1" ColumnDefinitions="*, 30">

<NumericUpDown
Increment="0.01"
FormatString="{}{0:#,0.00}"
Value="{Binding NudgeBy}"/>
<TextBlock Grid.Column="1" Text="s" Margin="5"/>
</Grid>

<StackPanel
Grid.Row="2"
Orientation="Horizontal"
HorizontalAlignment="Right"
Margin="0,10,0,0">
<Button
Content="Apply"
Classes="accent"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHost:DialogHost}, Path=CloseDialogCommand}"
CommandParameter="{Binding}" />

<Button
Content="Cancel"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHost:DialogHost}, Path=CloseDialogCommand}" />
</StackPanel>

</Grid>

</dialogs:ModalDialogChrome>
</UserControl>
36 changes: 36 additions & 0 deletions KaddaOK.AvaloniaApp/Controls/Dialogs/NudgeTimingsDialog.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.VisualTree;
using DialogHostAvalonia;

namespace KaddaOK.AvaloniaApp.Controls.Dialogs
{
public partial class NudgeTimingsDialog : UserControl
{
private DialogHost? dialogHost;

public NudgeTimingsDialog()
{
InitializeComponent();
}

private void TextBox_AttachedToVisualTree(object? sender, Avalonia.VisualTreeAttachmentEventArgs e)
{
(sender as TextBox)?.Focus();
dialogHost = this.FindAncestorOfType<DialogHost>();
}

private void TextBox_KeyDown(object? sender, Avalonia.Input.KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
dialogHost?.CloseDialogCommand.Execute(((TextBox)sender).Text);

Check warning on line 27 in KaddaOK.AvaloniaApp/Controls/Dialogs/NudgeTimingsDialog.axaml.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

Check warning on line 27 in KaddaOK.AvaloniaApp/Controls/Dialogs/NudgeTimingsDialog.axaml.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}

if (e.Key == Key.Escape)
{
dialogHost?.CloseDialogCommand.Execute(null);
}
}
}
}
Loading

0 comments on commit 136d7ae

Please sign in to comment.