예제 #1
0
        void _processPreDcsSoundCommand()
        {
            bool pendingVolumeCommand = writeQueue.ToArray()[0] == PREDCS_VOLUME_COMMAND;

            if (pendingVolumeCommand)
            {
                if (writeQueue.Count != 3)
                {
                    // WAIT UNTIL ALL BYTES ARRIVE
                    return;
                }
                byte?volume = SoundVolumeConvert.getRelativeVolumePreDcs(writeQueue.ToArray()[1], writeQueue.ToArray()[2]);
                if (volume != null)
                {
                    this.volume = (byte)volume;
                    _callbackMainVolume(this.volume);
                    Debug.Print("VOLUME_SET {0}", this.volume);
                }
                writeQueue.Clear();
                return;
            }

            bool isExtendedCommand = writeQueue.ToArray()[0] == PREDCS_EXTENDED_COMMAND;

            if (isExtendedCommand)
            {
                if (writeQueue.Count > 1)
                {
                    ushort extendedCommand = (ushort)((PREDCS_EXTENDED_COMMAND << 8) + writeQueue.ToArray()[1]);
                    _callbackPlaySample(extendedCommand);
                    writeQueue.Clear();
                }
            }
            else
            {
                _callbackPlaySample(writeQueue.ToArray()[0]);
                writeQueue.Clear();
            }
        }
예제 #2
0
        void _processDcsSoundCommand()
        {
            if (writeQueue.Count < 2)
            {
                return;
            }

            bool pendingVolumeCommand = writeQueue.ToArray()[0] == DCS_VOLUME_COMMAND;

            if (pendingVolumeCommand)
            {
                Debug.Print("-> pendingVolumeCommand {0}", writeQueue.Count);
                if (writeQueue.Count != 4)
                {
                    // WAIT UNTIL ALL BYTES ARRIVE
                    return;
                }

                bool changeGlobalVolume = writeQueue.ToArray()[1] == DCS_VOLUME_GLOBAL;
                if (changeGlobalVolume)
                {
                    byte?volume = SoundVolumeConvert.getRelativeVolumeDcs(writeQueue.ToArray()[2], writeQueue.ToArray()[3]);
                    if (volume != null)
                    {
                        this.volume = (byte)volume;
                        _callbackMainVolume(this.volume);
                        Debug.Print("VOLUME_SET {0}", this.volume);
                    }
                }
                else
                {
                    Debug.Print("ONLY GLOBAL VOLUME SUPPORTED NOW! ;(");
                }
                writeQueue.Clear();
                return;
            }

            ushort sampleId = (ushort)((writeQueue.ToArray()[0] << 8) | writeQueue.ToArray()[1]);

            switch (sampleId)
            {
            case SAMPLE_ID_STOP:
                Debug.Print("-> STOP ALL SAMPLES");
                _callbackStopAllSamples();
                break;

            case DCS_CHANNEL_0_OFF:
            case DCS_CHANNEL_1_OFF:
            case DCS_CHANNEL_2_OFF:
            case DCS_CHANNEL_3_OFF:
            case DCS_CHANNEL_4_OFF:
            case DCS_CHANNEL_5_OFF:
            case DCS_CHANNEL_6_OFF:
            {
                byte channel = (byte)(sampleId - DCS_CHANNEL_0_OFF);
                _callbackChannelOff(channel);
                break;
            }

            case DCS_UNKNOWN3D2:     //SAFE CRACKER: need to reply else soundboard is reset
            case DCS_UNKNOWN3D3:     //AFM + CONGO: need to reply else soundboard is reset
                readQueue.Enqueue(0x1);
                break;

            case DCS_GET_MAIN_VERSION:
                Debug.Print("DCS_GET_MAIN_VERSION");
                readQueue.Enqueue(0x10);
                break;

            case DCS_GET_MINOR_VERSION:
                Debug.Print("DCS_GET_MINOR_VERSION");
                readQueue.Enqueue(0x1);
                break;

            default:
                _callbackPlaySample(sampleId);
                break;
            }
            writeQueue.Clear();
        }