Exemplo n.º 1
0
        /// <summary>
        /// Initializes the <see cref="TemporaryTone"/> with the given <see cref="IBankSelect"/> interface.
        /// </summary>
        /// <param name="bankselect"></param>
        /// <exception cref="IntegraException">When the type is <see cref="IntegraToneTypes.Unavailable"/>.</exception>
        /// <remarks><i>
        /// <b>Important</b><br/>
        /// The <see cref="StudioSetPart"/> has to be initialized before the <see cref="TemporaryTone"/>.<br/>
        /// The method is invoked when a <see cref="Integra.ToneChanged"/> event is received which is generated by the <see cref="StudioSetPart"/>.<br/>
        /// </i></remarks>
        private void InitializeTemporaryTone(IBankSelect bankselect)
        {
            // IMPORTANT! Quick tone changes can corrupt the model initialization queue, dequeue the temporary tone as prevention
            Device.Dequeue(this);

            SuperNATURALAcousticTone?.Dispose();
            SuperNATURALSynthTone?.Dispose();
            SuperNATURALDrumKit?.Dispose();
            PCMSynthTone?.Dispose();
            PCMDrumKit?.Dispose();
            MFX.Dispose();

            MSB        = bankselect.MSB;
            LSB        = bankselect.LSB;
            PC         = bankselect.PC;
            Type       = bankselect.ToneType();
            IsEditable = bankselect.IsEditable();

            MFX = new MFX(this);

            switch (Type)
            {
            case IntegraToneTypes.SuperNATURALAcousticTone:
                SuperNATURALAcousticTone = new SuperNATURALAcousticTone(this);
                MFX.Address |= SuperNATURALAcousticTone.Address;
                break;

            case IntegraToneTypes.SuperNATURALSynthTone:
                SuperNATURALSynthTone = new SuperNATURALSynthTone(this);
                MFX.Address          |= SuperNATURALSynthTone.Address;
                break;

            case IntegraToneTypes.SuperNATURALDrumkit:
                SuperNATURALDrumKit = new SuperNATURALDrumKit(this);
                MFX.Address        |= SuperNATURALDrumKit.Address;
                break;

            case IntegraToneTypes.PCMSynthTone:
                PCMSynthTone = new PCMSynthTone(this);
                MFX.Address |= PCMSynthTone.Address;
                break;

            case IntegraToneTypes.PCMDrumkit:
                PCMDrumKit   = new PCMDrumKit(this);
                MFX.Address |= PCMDrumKit.Address;
                break;

            default:
                throw new IntegraException($"[{nameof(TemporaryTone)}.{nameof(InitializeTemporaryTone)}({Part})]\n" +
                                           $"Unspecified temporary tone type.");
            }

            Device.Enqueue(this);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the <see cref="Tone"/> with the specified <see cref="IBankSelect"/> interface and enqueues a <see cref="ToneTemplate"/> request.
        /// </summary>
        /// <param name="bankselect">The <see cref="IBankSelect"/> interface to initialize the tone.</param>
        private void Initialize(IBankSelect bankselect)
        {
            MSB = bankselect.MSB;
            LSB = bankselect.LSB;
            PC  = bankselect.PC;

            IsEditable = this.IsEditable();
            ToneBank   = this.ToneBank();
            Type       = this.ToneType();

            IsInitialized = false;

            // IMPORTANT! Quick tone changes can corrupt the model initialization queue, dequeue the temporary tone as prevention
            Device.Dequeue(this);

            Device.Enqueue(this);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the tone bank of an <see cref="IBankSelect"/> implementing class.
        /// </summary>
        /// <param name="instance"></param>
        /// <returns></returns>
        public static IntegraToneBanks ToneBank(this IBankSelect instance)
        {
            ushort bank = (ushort)((instance.MSB << 8) | instance.LSB);

            // 0x5D11 ERROR
            // Check for single addressable tone banks
            // The low nibble can vary for big tone banks

            if (Enum.IsDefined(typeof(IntegraToneBanks), (ushort)(bank & 0xFF00)))
            {
                if (Enum.IsDefined(typeof(IntegraToneBanks), bank))
                {
                    return((IntegraToneBanks)bank);
                }
                else
                {
                    byte   i = (byte)(instance.LSB & 0x0F);
                    ushort b = (ushort)(bank & 0xFFF0);
                    //for (; i >= 0; i--)
                    //{
                    //    if (Enum.IsDefined(typeof(IntegraToneBanks), (ushort)(b | i)))
                    //        return (IntegraToneBanks)(b | i);
                    //}

                    i = instance.LSB;
                    b = (ushort)(bank & 0xFF00);

                    for (; i >= 0; i--)
                    {
                        if (Enum.IsDefined(typeof(IntegraToneBanks), (ushort)(b | i)))
                        {
                            return((IntegraToneBanks)(b | i));
                        }
                    }

                    throw new ArgumentOutOfRangeException($"[{nameof(IntegraToneExtensions)}.{nameof(ToneBank)}] 0x{instance.MSB:X2}{instance.MSB:X2}");
                }
            }
            else
            {
                throw new ArgumentOutOfRangeException($"[{nameof(IntegraToneExtensions)}.{nameof(ToneBank)}] 0x{instance.MSB:X2}{instance.MSB:X2}");
            }
        }
Exemplo n.º 4
0
 public static byte[] Bytes(this IBankSelect bankselect)
 {
     return(new byte[3] {
         bankselect.MSB, bankselect.LSB, bankselect.PC
     });
 }
Exemplo n.º 5
0
 /// <summary>
 /// Gets the tone's type defined by the <see cref="IntegraToneTypes"/> enumeration.
 /// </summary>
 /// <param name="instance">The <see cref="IBankSelect"/> implementing instance.</param>
 /// <returns>The tone's type based on the <see cref="IBankSelect"/> interface.</returns>
 /// <exception cref="ArgumentOutOfRangeException"/>
 public static IntegraToneTypes ToneType(this IBankSelect instance)
 {
     return(ToneType(instance.MSB));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates and initializes a new <see cref="IntegraToneChangedEventArgs"/> instance.
 /// </summary>
 /// <param name="tone">The <see cref="IBankSelect"/> interface of the new tone.</param>
 /// <param name="part">The tone's associated part.</param>
 public IntegraToneChangedEventArgs(IBankSelect tone, Parts part)
 {
     Tone = tone;
     Part = part;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Creates and initializes a new <see cref="Tone"/> instance from the given <see cref="IBankSelect"/> interface.
 /// </summary>
 /// <param name="device">The <see cref="Integra"/> to connect the model.</param>
 /// <param name="bankselect">The <see cref="IBankSelect"/> interface to initialize the model.</param>
 private Tone(Integra device, IBankSelect bankselect) : base(device)
 {
     Initialize(bankselect);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Updates the <see cref="Tone"/> with the specified <see cref="IBankSelect"/> interface.
 /// </summary>
 /// <param name="bankselect">The <see cref="IBankSelect"/> interface to update the tone.</param>
 public void Update(IBankSelect bankselect)
 {
     Initialize(bankselect);
 }