Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="instrumentType"></param>
        public static InstrumentBase AddInstrument(InstrumentType instrumentType)
        {
            try
            {
                InstrumentManager.InstExclusiveLockObject.EnterWriteLock();
                Program.SoundUpdating();

                if (instruments[(int)instrumentType].Count < 8)
                {
                    Assembly asm  = Assembly.GetAssembly(typeof(InstrumentType));
                    string   name = Enum.GetName(typeof(InstrumentType), instrumentType);
                    Type     t    = asm.GetType("zanac.MAmidiMEmo.Instruments.Chips." + name);

                    var inst = (InstrumentBase)Activator.CreateInstance(t, (uint)instruments[(int)instrumentType].Count);
                    inst.PrepareSound();
                    instruments[(int)instrumentType].Add(inst);
                    InstrumentAdded?.Invoke(typeof(InstrumentManager), EventArgs.Empty);
                    if (VgmRecodring)
                    {
                        inst.StartVgmRecordingTo(LastVgmOutputDir);
                    }

                    return(inst);
                }
            }
            finally
            {
                Program.SoundUpdated();
                InstrumentManager.InstExclusiveLockObject.ExitWriteLock();
            }
            return(null);
        }
Esempio n. 2
0
 protected virtual void OnInstrumentAdded(DataEventArgs args)
 {
     InstrumentAdded.Raise(this, args);
 }