2019-11-25 00:11:47 +01:00
|
|
|
using System;
|
2021-11-28 01:47:36 +01:00
|
|
|
using Robust.Shared.Analyzers;
|
2019-11-25 00:11:47 +01:00
|
|
|
using Robust.Shared.Audio.Midi;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-07-12 01:32:10 -07:00
|
|
|
using Robust.Shared.GameStates;
|
2019-11-25 00:11:47 +01:00
|
|
|
using Robust.Shared.Serialization;
|
2021-11-28 01:47:36 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2020-10-30 10:34:22 +01:00
|
|
|
using Robust.Shared.ViewVariables;
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
namespace Content.Shared.Instruments;
|
|
|
|
|
|
|
|
|
|
[NetworkedComponent, Friend(typeof(SharedInstrumentSystem))]
|
2022-02-16 00:23:23 -07:00
|
|
|
public abstract class SharedInstrumentComponent : Component
|
2019-11-25 00:11:47 +01:00
|
|
|
{
|
2021-11-28 01:47:36 +01:00
|
|
|
[ViewVariables]
|
|
|
|
|
public bool Playing { get; set; }
|
2020-12-20 01:43:29 +01:00
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
[ViewVariables]
|
|
|
|
|
public uint LastSequencerTick { get; set; }
|
2020-12-20 01:43:29 +01:00
|
|
|
|
2021-12-25 02:02:14 +01:00
|
|
|
[DataField("program"), ViewVariables(VVAccess.ReadWrite)]
|
2021-11-28 01:47:36 +01:00
|
|
|
public byte InstrumentProgram { get; set; }
|
2020-12-20 01:43:29 +01:00
|
|
|
|
2021-12-25 02:02:14 +01:00
|
|
|
[DataField("bank"), ViewVariables(VVAccess.ReadWrite)]
|
2021-11-28 01:47:36 +01:00
|
|
|
public byte InstrumentBank { get; set; }
|
2020-10-30 10:34:22 +01:00
|
|
|
|
2021-12-25 02:02:14 +01:00
|
|
|
[DataField("allowPercussion"), ViewVariables(VVAccess.ReadWrite)]
|
2021-11-28 01:47:36 +01:00
|
|
|
public bool AllowPercussion { get; set; }
|
2020-12-20 01:43:29 +01:00
|
|
|
|
2021-12-25 02:02:14 +01:00
|
|
|
[DataField("allowProgramChange"), ViewVariables(VVAccess.ReadWrite)]
|
2021-11-28 01:47:36 +01:00
|
|
|
public bool AllowProgramChange { get ; set; }
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2021-12-25 02:02:14 +01:00
|
|
|
[DataField("respectMidiLimits"), ViewVariables(VVAccess.ReadWrite)]
|
2022-01-27 13:07:35 +01:00
|
|
|
public bool RespectMidiLimits { get; set; } = true;
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public bool DirtyRenderer { get; set; }
|
|
|
|
|
}
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2020-05-20 17:13:49 +02:00
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// This message is sent to the client to completely stop midi input and midi playback.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class InstrumentStopMidiEvent : EntityEventArgs
|
2021-11-28 01:47:36 +01:00
|
|
|
{
|
|
|
|
|
public EntityUid Uid { get; }
|
2020-05-20 15:15:17 +02:00
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
public InstrumentStopMidiEvent(EntityUid uid)
|
2019-11-25 00:11:47 +01:00
|
|
|
{
|
2021-11-28 01:47:36 +01:00
|
|
|
Uid = uid;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// This message is sent to the client to start the synth.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class InstrumentStartMidiEvent : EntityEventArgs
|
2021-11-28 01:47:36 +01:00
|
|
|
{
|
|
|
|
|
public EntityUid Uid { get; }
|
|
|
|
|
|
|
|
|
|
public InstrumentStartMidiEvent(EntityUid uid)
|
|
|
|
|
{
|
|
|
|
|
Uid = uid;
|
2019-11-25 00:11:47 +01:00
|
|
|
}
|
2021-11-28 01:47:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This message carries a MidiEvent to be played on clients.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class InstrumentMidiEventEvent : EntityEventArgs
|
2021-11-28 01:47:36 +01:00
|
|
|
{
|
|
|
|
|
public EntityUid Uid { get; }
|
|
|
|
|
public MidiEvent[] MidiEvent { get; }
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
public InstrumentMidiEventEvent(EntityUid uid, MidiEvent[] midiEvent)
|
2020-05-21 15:20:37 +02:00
|
|
|
{
|
2021-11-28 01:47:36 +01:00
|
|
|
Uid = uid;
|
|
|
|
|
MidiEvent = midiEvent;
|
2020-05-21 15:20:37 +02:00
|
|
|
}
|
2021-11-28 01:47:36 +01:00
|
|
|
}
|
2020-05-21 15:20:37 +02:00
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class InstrumentState : ComponentState
|
2021-11-28 01:47:36 +01:00
|
|
|
{
|
|
|
|
|
public bool Playing { get; }
|
|
|
|
|
public byte InstrumentProgram { get; }
|
|
|
|
|
public byte InstrumentBank { get; }
|
|
|
|
|
public bool AllowPercussion { get; }
|
|
|
|
|
public bool AllowProgramChange { get; }
|
|
|
|
|
public bool RespectMidiLimits { get; }
|
|
|
|
|
|
|
|
|
|
public InstrumentState(bool playing, byte instrumentProgram, byte instrumentBank, bool allowPercussion, bool allowProgramChange, bool respectMidiLimits, uint sequencerTick = 0)
|
2019-11-25 00:11:47 +01:00
|
|
|
{
|
2021-11-28 01:47:36 +01:00
|
|
|
Playing = playing;
|
|
|
|
|
InstrumentProgram = instrumentProgram;
|
|
|
|
|
InstrumentBank = instrumentBank;
|
|
|
|
|
AllowPercussion = allowPercussion;
|
|
|
|
|
AllowProgramChange = allowProgramChange;
|
|
|
|
|
RespectMidiLimits = respectMidiLimits;
|
2019-11-25 00:11:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-11-28 01:47:36 +01:00
|
|
|
|
|
|
|
|
[NetSerializable, Serializable]
|
|
|
|
|
public enum InstrumentUiKey
|
|
|
|
|
{
|
|
|
|
|
Key,
|
|
|
|
|
}
|