/// <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); }
/// <summary> /// Creates a new <see cref="TemporaryTone"/> instance. /// </summary> /// <param name="integra">The device to connect the model.</param> /// <param name="part">The associated part.</param> /// <remarks><i> /// - The temporary tone /// </i></remarks> internal TemporaryTone(Integra integra, Parts part) : base(integra, part, false) { Address = Attribute.Address; // 0x19, 0x19, 0x19, 0x19, 0x20, ... Address[0] += (byte)((int)part >> 2); // >> 2 equals division by 4 // 0x00, 0x20, 0x40, 0x60, 0x00, ... Address[1] += (byte)((int)part % 4 * 0x20); MFX = new MFX(this); Device.ToneChanged += ToneChanged; }