mirror of
https://github.com/unclshura/ABStemPlayer.git
synced 2026-08-07 00:43:38 +00:00
Live mixer settings change works, but not instantly (playback buffer is filled in already).
This commit is contained in:
parent
21e1f1e3f5
commit
5d3dceb89e
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
@ -132,6 +133,41 @@ public sealed partial class PlaybackViewModel : ObservableObject
|
|||||||
await _engine.PlayAsync();
|
await _engine.PlayAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial void OnMixerChanged(MixerViewModel? oldValue, MixerViewModel newValue)
|
||||||
|
{
|
||||||
|
if (oldValue != null)
|
||||||
|
{
|
||||||
|
foreach (var stem in oldValue.Stems)
|
||||||
|
{
|
||||||
|
stem.PropertyChanged -= OnMixerSettingsChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newValue != null)
|
||||||
|
{
|
||||||
|
foreach (var stem in newValue.Stems)
|
||||||
|
{
|
||||||
|
stem.PropertyChanged += OnMixerSettingsChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMixerSettingsChanged(object? sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is not StemChannelViewModel stem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var mixerSettings = new MixerSettings
|
||||||
|
{
|
||||||
|
Stems = Mixer.Stems.Select(x => new StemMixSettings
|
||||||
|
{
|
||||||
|
GainDb = x.GainDb,
|
||||||
|
Enabled = x.Enabled,
|
||||||
|
Pan = x.Pan
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
Task.Run(async () => await _engine.UpdateMixerAsync(mixerSettings));
|
||||||
|
}
|
||||||
|
|
||||||
partial void OnCurrentTimeChanged(TimeSpan value)
|
partial void OnCurrentTimeChanged(TimeSpan value)
|
||||||
{
|
{
|
||||||
foreach (var band in Bands)
|
foreach (var band in Bands)
|
||||||
|
|||||||
@ -4,9 +4,9 @@ public partial class StemChannelViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
public StemType Type { get; }
|
public StemType Type { get; }
|
||||||
|
|
||||||
[ObservableProperty] private bool _enabled = true;
|
[ObservableProperty] private bool _enabled = true;
|
||||||
[ObservableProperty] private float _gainDb = 0f;
|
[ObservableProperty] private float _gainDb;
|
||||||
[ObservableProperty] private float _pan = 0f;
|
[ObservableProperty] private float _pan;
|
||||||
|
|
||||||
public StemChannelViewModel(StemType type)
|
public StemChannelViewModel(StemType type)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,6 +5,8 @@ public sealed class StemMixSettings
|
|||||||
public bool Enabled { get; init; } = true;
|
public bool Enabled { get; init; } = true;
|
||||||
public float GainDb { get; init; } = 0f;
|
public float GainDb { get; init; } = 0f;
|
||||||
public float Pan { get; init; } = 0f; // -1..+1
|
public float Pan { get; init; } = 0f; // -1..+1
|
||||||
|
|
||||||
|
public override string ToString() => $"{(Enabled ? "[x]": "[ ]")} {GainDb:N2} {Pan:N2}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class MixerSettings
|
public sealed class MixerSettings
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user