mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Fix up midi stuff, support mild black midis (#1092)
This commit is contained in:
@@ -135,7 +135,12 @@ namespace Robust.Client.Audio.Midi
|
||||
_settings["synth.lock-memory"].IntValue = 0;
|
||||
_settings["synth.threadsafe-api"].IntValue = 1;
|
||||
_settings["synth.gain"].DoubleValue = 1.0d;
|
||||
_settings["synth.polyphony"].IntValue = 1024;
|
||||
_settings["synth.cpu-cores"].IntValue = 2;
|
||||
_settings["synth.overflow.age"].DoubleValue = 3000;
|
||||
_settings["audio.driver"].StringValue = "file";
|
||||
_settings["audio.periods"].IntValue = 8;
|
||||
_settings["audio.period-size"].IntValue = 4096;
|
||||
_settings["midi.autoconnect"].IntValue = 1;
|
||||
_settings["player.reset-synth"].IntValue = 0;
|
||||
_settings["synth.midi-bank-select"].StringValue = "gm";
|
||||
@@ -310,11 +315,20 @@ namespace Robust.Client.Audio.Midi
|
||||
renderer.Source.SetOcclusion(occlusion);
|
||||
}
|
||||
|
||||
if (!renderer.Source.SetPosition(pos.Position))
|
||||
if (renderer.Source.SetPosition(pos.Position))
|
||||
{
|
||||
_midiSawmill?.Warning("Interrupting positional audio, can't set position.");
|
||||
renderer.Source.StopPlaying();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (float.IsNaN(pos.Position.X) || float.IsNaN(pos.Position.Y))
|
||||
{
|
||||
// just duck out instead of move to NaN
|
||||
renderer.Source.SetOcclusion(float.MaxValue);
|
||||
continue;
|
||||
}
|
||||
|
||||
_midiSawmill?.Warning("Interrupting positional audio, can't set position.");
|
||||
renderer.Source.StopPlaying();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ namespace Robust.Client.Audio.Midi
|
||||
uint SequencerTick { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Time Scale of the sequencer in ticks per second. Default is 1000 for 1 tick per millisecond.
|
||||
/// Gets the Time Scale of the sequencer in ticks per second. Default is 1000 for 1 tick per millisecond.
|
||||
/// </summary>
|
||||
double SequencerTimeScale { get; set; }
|
||||
double SequencerTimeScale { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Start listening for midi input.
|
||||
@@ -235,12 +235,7 @@ namespace Robust.Client.Audio.Midi
|
||||
public int PlayerTotalTick => _player?.GetTotalTicks ?? 0;
|
||||
public int PlayerTick => _player?.CurrentTick ?? 0;
|
||||
public uint SequencerTick => _sequencer?.Tick ?? 0;
|
||||
|
||||
public double SequencerTimeScale
|
||||
{
|
||||
get => _sequencer.TimeScale;
|
||||
set => _sequencer.TimeScale = value;
|
||||
}
|
||||
public double SequencerTimeScale => _sequencer?.TimeScale ?? 0;
|
||||
|
||||
public bool Mono { get; set; }
|
||||
public MidiRendererStatus Status { get; private set; } = MidiRendererStatus.None;
|
||||
@@ -455,7 +450,7 @@ namespace Robust.Client.Audio.Midi
|
||||
if (Disposed || Status != MidiRendererStatus.File && _player?.Status == FluidPlayerStatus.Playing) return 0;
|
||||
var timestamp = SequencerTick;
|
||||
var midiEv = (Shared.Audio.Midi.MidiEvent) midiEvent;
|
||||
midiEv.Timestamp = timestamp;
|
||||
midiEv.Tick = timestamp;
|
||||
SendMidiEvent(midiEv);
|
||||
return 0;
|
||||
}
|
||||
@@ -465,7 +460,7 @@ namespace Robust.Client.Audio.Midi
|
||||
if (Disposed || Status != MidiRendererStatus.Input) return 0;
|
||||
var timestamp = SequencerTick;
|
||||
var midiEv = (Shared.Audio.Midi.MidiEvent) midiEvent;
|
||||
midiEv.Timestamp = timestamp;
|
||||
midiEv.Tick = timestamp;
|
||||
SendMidiEvent(midiEv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ namespace Robust.Shared.Asynchronous
|
||||
_runtimeLog = runtimeLog;
|
||||
}
|
||||
|
||||
private readonly BlockingCollection<(SendOrPostCallback d, object state)> _pending = new BlockingCollection<(SendOrPostCallback, object)>();
|
||||
private readonly ConcurrentQueue<(SendOrPostCallback d, object state)> _pending
|
||||
= new ConcurrentQueue<(SendOrPostCallback, object)>();
|
||||
|
||||
public override void Send(SendOrPostCallback d, object state)
|
||||
{
|
||||
@@ -33,12 +34,12 @@ namespace Robust.Shared.Asynchronous
|
||||
|
||||
public override void Post(SendOrPostCallback d, object state)
|
||||
{
|
||||
_pending.Add((d, state));
|
||||
_pending.Enqueue((d, state));
|
||||
}
|
||||
|
||||
public void ProcessPendingTasks()
|
||||
{
|
||||
while (_pending.TryTake(out var task))
|
||||
while (_pending.TryDequeue(out var task))
|
||||
{
|
||||
#if EXCEPTION_TOLERANCE
|
||||
try
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Robust.Shared.Audio.Midi
|
||||
|
||||
public byte Pitch { get; set; }
|
||||
|
||||
public uint Timestamp { get; set; }
|
||||
public uint Tick { get; set; }
|
||||
|
||||
public static explicit operator MidiEvent(NFluidsynth.MidiEvent midiEvent)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user