/// <summary>
        ///     Callback called when data dump is received from device
        /// </summary>
        private void OnSysExMessageReceived(object sender, SysExMessageEventArgs e)
        {
            switch (e.Message.Length)
            {
            case ExpectedCommonDumpLength + SysExUtils.DumpPaddingSize:
                _logger.Receive("Received Patch.Common");
                _commonDump = e.Message;
                break;

            case ExpectedVfxDumpLength + SysExUtils.DumpPaddingSize:
                _vfxDump = e.Message;
                _logger.Receive("Received Patch.VocalEffect");
                break;
            }

            _dumpCount++;

            if (_dumpCount == 2)
            {
                _timer.Stop();

                _device.StopRecording();
                _device.Dispose();

                DataDumpReceived?.Invoke(this,
                                         new CommonAndVocalFxDumpReceivedEventArgs(new CommonAndVocalEffectPatch(_commonDump, _vfxDump)));
            }
        }
示例#2
0
        /// <summary>
        ///     Callback called when data dump is received from device
        /// </summary>
        private void OnSysExMessageReceived(object sender, SysExMessageEventArgs e)
        {
            switch (e.Message.Length)
            {
            case ExpectedCommonDumpLength + SysExUtils.DumpPaddingSize:
                _commonDump = e.Message;
                _logger.Receive("Received Patch.Common");
                break;

            case ExpectedPartialDumpLength + SysExUtils.DumpPaddingSize:
            {
                // At 11 byte we have partial identifier, so we check value at that byte
                var key = (DrumKey)e.Message[10];
                _partialsDump[key] = e.Message;
                _logger.Receive($"Received Patch.Partials[{key}]");
                break;
            }
            }

            _dumpCount++;

            if (_dumpCount == 39)
            {
                _timer.Stop();

                _device.StopRecording();
                _device.Dispose();

                DataDumpReceived?.Invoke(this,
                                         new DrumKitPatchDumpReceivedEventArgs(new Patch(_commonDump, _partialsDump)));
            }
        }
        /// <summary>
        ///     Callback called when data dump is received from device
        /// </summary>
        private void OnSysExMessageReceived(object sender, SysExMessageEventArgs e)
        {
            // At 11 byte we have effect type, so we check value there
            var effect = (Effect)e.Message[10];

            var expectedDumpLength = ExpectedDumpLength(effect) + SysExUtils.DumpPaddingSize;
            var actualDumpLength   = e.Message.Length;

            if (actualDumpLength != expectedDumpLength)
            {
                throw new InvalidDumpSizeException(expectedDumpLength, actualDumpLength);
            }

            _logger.Receive($"Received {effect}");


            _dataDumps.Add(effect, e.Message);

            _dumpCount++;

            if (_dumpCount == 4)
            {
                _timer.Stop();

                _device.StopRecording();
                _device.Dispose();

                DataDumpReceived?.Invoke(this, new EffectsPatchDumpReceivedEventArgs(new Patch(_dataDumps)));
            }
        }
示例#4
0
        /// <summary>
        ///     Callback called when data dump is received from device
        /// </summary>
        private void OnSysExMessageReceived(object sender, SysExMessageEventArgs e)
        {
            _timer.Stop();

            _device.StopRecording();
            _device.Dispose();

            var actualLength = e.Message.Length - SysExUtils.DumpPaddingSize;

            if (actualLength != ExpectedDumpLength)
            {
                throw new InvalidDumpSizeException(ExpectedDumpLength, actualLength);
            }

            _logger.Receive("Received Patch");

            DataDumpReceived?.Invoke(this, new AnalogPatchDumpReceivedEventArgs(new Patch(e.Message)));
        }
示例#5
0
        /// <summary>
        ///     Callback called when data dump is received from device
        /// </summary>
        private void OnSysExMessageReceived(object sender, SysExMessageEventArgs e)
        {
            switch (e.Message.Length)
            {
            case ExpectedCommonDumpLength + SysExUtils.DumpPaddingSize:
                _logger.Receive("Received Patch.Common");
                _commonDump = e.Message;
                break;

            case ExpectedModifiersDumpLength + SysExUtils.DumpPaddingSize:
                _logger.Receive("Received Patch.Modifiers");
                _modifiersDump = e.Message;
                break;

            case ExpectedPartialDumpLength + SysExUtils.DumpPaddingSize:
            {
                // At 11 byte we have partial number, so we check value at that byte
                var partial = (DigitalPartial)e.Message[10];

                switch (partial)
                {
                case DigitalPartial.First:
                    _logger.Receive($"Received Patch.PartialOne");
                    _partialsDump[0] = e.Message;
                    break;

                case DigitalPartial.Second:
                    _logger.Receive($"Received Patch.PartialTwo");
                    _partialsDump[1] = e.Message;
                    break;

                case DigitalPartial.Third:
                    _logger.Receive($"Received Patch.PartialThree");
                    _partialsDump[2] = e.Message;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(partial), partial, null);
                }

                break;
            }

            default:
                throw new InvalidDumpSizeException();
            }

            _dumpCount++;

            if (_dumpCount == 5)
            {
                _timer.Stop();

                _device.StopRecording();
                _device.Dispose();

                DataDumpReceived?.Invoke(this, new DigitalPatchDumpReceivedEventArgs(
                                             new Patch(_commonDump, _partialsDump, _modifiersDump)
                                             ));
            }
        }