Skip to content

Commit

Permalink
improve UI
Browse files Browse the repository at this point in the history
  • Loading branch information
MikiraSora committed Nov 1, 2024
1 parent 598c7ce commit bfcb9c9
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using OngekiFumenEditor.Utils.ObjectPool;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -121,7 +122,8 @@ async Task load(SoundControl sound, string fileName)

if (!noError)
{
MessageBox.Show(Resources.WarnSomeSoundsNotLoad);
if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
MessageBox.Show(Resources.WarnSomeSoundsNotLoad);
source.SetResult(false);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private TimeSpan GetTime()
if (!IsPlaying)
return pauseTime;
var offset = TimeSpan.FromTicks(sw.ElapsedTicks) * manager.MusicSpeed;
var adjustedTime = offset + baseOffset - TimeSpan.FromMilliseconds(manager.SpeedCostDelayMs);
var adjustedTime = offset + baseOffset - TimeSpan.FromMilliseconds(manager.SpeedCostDelayMs / 2);
var actualTime = MathUtils.Max(TimeSpan.Zero, adjustedTime);
return actualTime;
}
Expand Down
2 changes: 1 addition & 1 deletion OngekiFumenEditor/Kernel/Audio/NAudioImpl/NAudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public NAudioManager()
enableSoundMultiPlay = AudioSetting.Default.EnableSoundMultiPlay;
targetSampleRate = AudioSetting.Default.AudioSampleRate;
enableVarspeed = AudioSetting.Default.EnableVarspeed;
SpeedCostDelayMs = AudioSetting.Default.VarspeedReadDurationMs;
SpeedCostDelayMs = enableVarspeed ? AudioSetting.Default.VarspeedReadDurationMs : 0;

Log.LogDebug($"targetSampleRate: {targetSampleRate}");
Log.LogDebug($"audioOutputType: {audioOutputType}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@
</StackPanel>
</StackPanel>
</GroupBox>
<GroupBox Margin="5" Header="{markup:Translate [Music]}">
<StackPanel Margin="10">
<CheckBox
VerticalContentAlignment="Center"
Content="允许变速播放音乐 (需要重启程序)"
IsChecked="{Binding Setting.EnableVarspeed}" />
<StackPanel
Margin="20,10,0,0"
IsEnabled="{Binding Setting.EnableVarspeed}"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="变速采样缓存时间窗口" />
<TextBox
Width="50"
Margin="5,0"
VerticalAlignment="Center"
Text="{Binding Setting.VarspeedReadDurationMs}">
</TextBox>
<TextBlock VerticalAlignment="Center" Text="毫秒" />
</StackPanel>
</StackPanel>
</GroupBox>
<GroupBox Margin="5" Header="{markup:Translate [Sound]}">
<StackPanel Margin="10">
<Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,26 +253,21 @@
Content="{markup:Translate [EnableVisualizerDisplay]}"
IsChecked="{Binding IsShowWaveform}">
</CheckBox>
<StackPanel

<Grid
Margin="5"
HorizontalAlignment="Stretch"
IsEnabled="{Binding AudioPlayer.IsPlaying, Converter={StaticResource ReverseBoolConverter}}"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="{markup:Translate [Speed]}" />
<Slider
Width="150"
Margin="5,0,0,0"
VerticalAlignment="Stretch"
VerticalContentAlignment="Center"
IsEnabled="{Binding AudioPlayer.IsAvaliable}"
IsSnapToTickEnabled="True"
Maximum="1.25"
Minimum="0.25"
TickFrequency="0.25"
TickPlacement="BottomRight"
Value="{Binding MusicSpeed}">
</Slider>
</StackPanel>
IsEnabled="{Binding AudioPlayer.IsPlaying, Converter={StaticResource ReverseBoolConverter}}">
<controls:RangeValue
Grid.ColumnSpan="2"
Padding="0,5,0,5"
CurrentValue="{Binding MusicSpeed, Mode=TwoWay}"
DisplayName="{markup:Translate [Speed]}"
MaxValue="1.25"
MinValue="0.75"
Step="0.05">
</controls:RangeValue>
</Grid>
<StackPanel
Margin="5"
HorizontalAlignment="Stretch"
Expand Down

0 comments on commit bfcb9c9

Please sign in to comment.