2023-07-16 21:12:53 +02:00
|
|
|
using System.Collections;
|
2019-11-25 00:11:47 +01:00
|
|
|
using Robust.Shared.Audio.Midi;
|
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
|
|
|
namespace Content.Shared.Instruments;
|
|
|
|
|
|
2023-07-16 21:12:53 +02:00
|
|
|
[NetworkedComponent]
|
|
|
|
|
[Access(typeof(SharedInstrumentSystem))]
|
|
|
|
|
public abstract partial class SharedInstrumentComponent : Component
|
2019-11-25 00:11:47 +01:00
|
|
|
{
|
2023-09-12 14:43:06 +10:00
|
|
|
[ViewVariables]
|
2021-11-28 01:47:36 +01:00
|
|
|
public bool Playing { get; set; }
|
2020-12-20 01:43:29 +01:00
|
|
|
|
2023-09-12 14:43:06 +10: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
|
|
|
|
2023-09-12 14:43:06 +10: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
|
|
|
|
2023-09-12 14:43:06 +10: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
|
|
|
|
2023-09-12 14:43:06 +10: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
|
|
|
|
2023-09-12 14:43:06 +10: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
|
|
|
|
2023-09-12 14:43:06 +10:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2023-07-16 21:12:53 +02:00
|
|
|
public EntityUid? Master { get; set; } = null;
|
|
|
|
|
|
2023-09-12 14:43:06 +10:00
|
|
|
[ViewVariables]
|
2023-07-16 21:12:53 +02:00
|
|
|
public BitArray FilteredChannels { get; set; } = new(RobustMidiEvent.MaxChannels, true);
|
2021-11-28 01:47:36 +01:00
|
|
|
}
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2023-09-12 14:43:06 +10:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class InstrumentComponentState : ComponentState
|
|
|
|
|
{
|
|
|
|
|
public bool Playing;
|
|
|
|
|
|
|
|
|
|
public byte InstrumentProgram;
|
|
|
|
|
|
|
|
|
|
public byte InstrumentBank;
|
|
|
|
|
|
|
|
|
|
public bool AllowPercussion;
|
|
|
|
|
|
|
|
|
|
public bool AllowProgramChange;
|
|
|
|
|
|
|
|
|
|
public bool RespectMidiLimits;
|
|
|
|
|
|
|
|
|
|
public NetEntity? Master;
|
|
|
|
|
|
|
|
|
|
public BitArray FilteredChannels = default!;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Uid { get; }
|
2020-05-20 15:15:17 +02:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public InstrumentStopMidiEvent(NetEntity 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
|
|
|
|
2023-07-16 21:12:53 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Send from the client to the server to set a master instrument.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class InstrumentSetMasterEvent : EntityEventArgs
|
|
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Uid { get; }
|
|
|
|
|
public NetEntity? Master { get; }
|
2023-07-16 21:12:53 +02:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public InstrumentSetMasterEvent(NetEntity uid, NetEntity? master)
|
2023-07-16 21:12:53 +02:00
|
|
|
{
|
|
|
|
|
Uid = uid;
|
|
|
|
|
Master = master;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Send from the client to the server to set a master instrument channel.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class InstrumentSetFilteredChannelEvent : EntityEventArgs
|
|
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Uid { get; }
|
2023-07-16 21:12:53 +02:00
|
|
|
public int Channel { get; }
|
|
|
|
|
public bool Value { get; }
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public InstrumentSetFilteredChannelEvent(NetEntity uid, int channel, bool value)
|
2023-07-16 21:12:53 +02:00
|
|
|
{
|
|
|
|
|
Uid = uid;
|
|
|
|
|
Channel = channel;
|
|
|
|
|
Value = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Uid { get; }
|
2021-11-28 01:47:36 +01:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public InstrumentStartMidiEvent(NetEntity uid)
|
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 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
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Uid { get; }
|
2022-04-08 16:22:05 +02:00
|
|
|
public RobustMidiEvent[] MidiEvent { get; }
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public InstrumentMidiEventEvent(NetEntity uid, RobustMidiEvent[] 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
|
|
|
[NetSerializable, Serializable]
|
|
|
|
|
public enum InstrumentUiKey
|
|
|
|
|
{
|
|
|
|
|
Key,
|
|
|
|
|
}
|