Ejemplo n.º 1
0
        /// <summary>
        ///     Copy data from sysex dump
        /// </summary>
        public void CopyFrom(SysExMessage message)
        {
            /**
             * 12   -> SysEx header & address offset
             * 13   -> Tone Name(12) + Reserve(1)
             * 9    -> LFO
             * 10   -> Oscillator
             * 10   -> Filter
             * 7    -> Amplifier
             * 7    -> Common(6) + Reserve(1)
             * 8    -> LFO Mod Control(4) + Reserve(4)
             * 1    -> Checksum
             * 1    -> Footer (0xF7)
             */

            var data = message.GetBytes().Skip(12).ToArray();

            if (data.Length - 2 != DumpLength)
            {
                throw new InvalidDumpSizeException(DumpLength, data.Length);
            }

            Name = Encoding.ASCII.GetString(data.Take(12).ToArray());

            Lfo.CopyFrom(data.Skip(13).Take(9).ToArray());
            Oscillator.CopyFrom(data.Skip(22).Take(10).ToArray());
            Filter.CopyFrom(data.Skip(32).Take(10).ToArray());
            Amplifier.CopyFrom(data.Skip(42).Take(7).ToArray());
            Common.CopyFrom(data.Skip(49).Take(7).ToArray());
            LfoModControl.CopyFrom(data.Skip(56).Take(8).ToArray());
        }
Ejemplo n.º 2
0
 /// <inheritdoc />
 public void CopyFrom(IPatch patch)
 {
     if (patch is Patch p)
     {
         Name = p.Name;
         Lfo.CopyFrom(p.Lfo);
         Oscillator.CopyFrom(p.Oscillator);
         Filter.CopyFrom(p.Filter);
         Amplifier.CopyFrom(p.Amplifier);
         Common.CopyFrom(p.Common);
         LfoModControl.CopyFrom(p.LfoModControl);
     }
     else
     {
         throw new NotSupportedException("Copying from that type is not supported");
     }
 }