Exemple #1
0
        // determines if this midi lane is exactly the same as an existing one
        // otherwise add it
        private int AddMidiLane(MidiLane midiLane)
        {
            foreach (var m in MidiLanes)
            {
                var duplicate = false;
                if (m.MidiEvents.Count == midiLane.MidiEvents.Count)
                {
                    duplicate = true;
                    for (var i = 0; i < m.MidiEvents.Count; i++)
                    {
                        if (m.MidiEvents[i].Note != midiLane.MidiEvents[i].Note ||
                            m.MidiEvents[i].Velocity != midiLane.MidiEvents[i].Velocity ||
                            m.MidiEvents[i].Type != midiLane.MidiEvents[i].Type ||
                            m.MidiEvents[i].TimeFromLastEvent != midiLane.MidiEvents[i].TimeFromLastEvent)
                        {
                            duplicate = false;
                            break;
                        }
                    }
                }

                if (duplicate)
                {
                    if (midiLane.MidiEvents.Count > 0)
                    {
                        midiLaneDupes++;
                    }

                    return(MidiLanes.IndexOf(m));
                }
            }

            MidiLanes.Add(midiLane);
            return(MidiLanes.IndexOf(midiLane));
        }
Exemple #2
0
        // restructures song elements int indexes lists
        public void Restructure(ILog logger)
        {
            // make list of all devices
            foreach (var t in Tracks)
            {
                foreach (var d in t.Devices)
                {
                    Devices.Add(d);
                }
            }

            // sort by devices type, keeping similar chunk data together, should be better for compressor
            Devices.Sort((x, y) => x.Id.CompareTo(y.Id));

            // link device id back to track
            foreach (var t in Tracks)
            {
                foreach (var d in t.Devices)
                {
                    t.DeviceIndices.Add(Devices.IndexOf(d));
                }
            }

            // create midi lanes from tracks and index them
            int midiLaneDupes = 0;

            foreach (var t in Tracks)
            {
                var midiLane = new MidiLane()
                {
                    MidiEvents = t.DeltaCodedEvents
                };
                t.MidiLaneId = AddMidiLane(midiLane, ref midiLaneDupes);
            }

            if (midiLaneDupes > 0)
            {
                logger.WriteLine("Found {0} duplicate midi lane(s)", midiLaneDupes);
            }

            var dupeCount = DedupeAutomations();

            if (dupeCount > 0)
            {
                logger.WriteLine("Removed {0} automation point(s)", dupeCount);
            }
        }