Ejemplo n.º 1
0
        public TimingGrid GetGrid(string gridName, bool createIfNotFound = true)
        {
            // Gets existing track specified by Name if it already exists
            // Creates it if it does not
            TimingGrid ret = Sequence.FindTimingGrid(gridName, createIfNotFound);

            //TimingGrid ret = Sequence.TimingGrids.Find(gridName, MemberType.TimingGrid, true);
            if (ret == null)
            {
                if (createIfNotFound)
                {
                    // ERROR! Should not ever get here
                    System.Diagnostics.Debugger.Break();
                    //ret = Sequence.CreateTimingGrid(gridName);
                    //ret.Centiseconds = centiseconds;
                    //Sequence.AddTimingGrid(ret);
                }
            }
            else
            {
                // Clear any existing timings from a previous run
                if (ret.timings.Count > 0)
                {
                    ret.timings = new List <int>();
                }
            }
            return(ret);
        }
Ejemplo n.º 2
0
    private void OnMouseUpAsButton()
    {
        if (firstPlay)
        {
            AudioSource audio = GetComponent <AudioSource>();
            audio.clip = playOnFirstPlayPress;
            audio.Play();
            firstPlay = false;
        }
        else
        {
            AudioSource audio = GetComponent <AudioSource>();
            audio.Stop();
            //invert button every click, starting or stoping the subroutine
            isPlay = !isPlay;
            SpriteRenderer spriteRenderer = (SpriteRenderer)GetComponent <Renderer>();
            if (isPlay)
            {
                //wipe the current puck list
                CreateAndPlaySequence.ClearAllPitches();
                //Get all of the grids
                List <GameObject> GridsAsGameObj = timeline.TimingGrids;
                //for each grid
                CreateAndPlaySequence.stepCount = GridsAsGameObj.Count;
                CreateAndPlaySequence.Awake();
                for (int beat = 0; beat < GridsAsGameObj.Count; beat++)
                {
                    //find if there are any pucks added to the beat
                    TimingGrid Grid = GridsAsGameObj[beat].GetComponent <TimingGrid>();

                    for (int PuckIndex = Grid.Sprites.Count - 1; PuckIndex >= 0; PuckIndex--)
                    {
                        //get the puck's note and add the note to the corrisponding note in the sequence.
                        if (Grid.Sprites[PuckIndex].GetComponents <PlayableSprite>().Length != 0)
                        {
                            PlayableSprite SugarPuck = Grid.Sprites[PuckIndex].GetComponent <PlayableSprite>();
                            CreateAndPlaySequence.AddPitchAtStep(SugarPuck.PitchNumber + Grid.BeatNum, beat);
                        }
                        else
                        {
                            Grid.Sprites[PuckIndex].gameObject.GetComponent <SpriteRenderer>().enabled = false;
                            Grid.Sprites[PuckIndex].GetComponent <Collider2D>().enabled = false;
                            Destroy(Grid.Sprites[PuckIndex]);
                            Grid.Sprites.RemoveAt(PuckIndex);
                        }
                    }
                }

                CreateAndPlaySequence.StartSequencer();
                spriteRenderer.sprite = stop;
            }

            //Stop Stepp
            if (!isPlay)
            {
                CreateAndPlaySequence.StopSequencer();
                spriteRenderer.sprite = play;
            }
        }
    }
Ejemplo n.º 3
0
        public int ImportTimingGrid(TimingGrid beatGrid, xTimings xEffects)
        {
            int errs      = 0;
            int lastStart = -1;

            // If grid already has timings (from a previous run) clear them, start over fresh
            if (beatGrid.timings.Count > 0)
            {
                beatGrid.timings.Clear();
            }
            beatGrid.TimingGridType = TimingGridType.Freeform;
            for (int q = 0; q < xEffects.effects.Count; q++)
            {
                xEffect xef = xEffects.effects[q];
                int     t   = ms2cs(xef.starttime);
                if (t > lastStart)
                {
                    if (t < Sequence.Centiseconds)
                    {
                        beatGrid.AddTiming(t);
                    }
                }
                lastStart = t;
            }
            return(errs);
        }
Ejemplo n.º 4
0
        }         // end Beats

        public int xTimingsToLORtimings(xTimings timings, Sequence4 sequence)
        {
            // Ignore the timings passed in, and use the ones already cached for Bars and Beats
            // (Other transforms will use the one passed in)

            seqFunct.Sequence = sequence;
            int errs = 0;

            if (xOnsets != null)
            {
                if (xOnsets.effects.Count > 0)
                {
                    TimingGrid barGrid = seqFunct.GetGrid("Note Onsets", true);
                    seqFunct.ImportTimingGrid(barGrid, xOnsets);
                }
            }

            return(errs);
        }
Ejemplo n.º 5
0
    //allow clear to be called externally
    public void Clear()
    {
        //for each timeline grid
        List <GameObject> GridsAsGameObj = timeline.TimingGrids;

        foreach (var GridGameObj in GridsAsGameObj)
        {
            TimingGrid Grid = GridGameObj.GetComponent <TimingGrid>();
            //for each puck in an individual grid
            foreach (var PlayPuck in Grid.Sprites)
            {
                //destroy the objects  in the grid
                PlayPuck.gameObject.GetComponent <SpriteRenderer>().enabled = false;
                Destroy(PlayPuck);
            }

            //create a new list without any objects, so that new objects can be added.
            Grid.Sprites = new List <Collider2D>();
        }
    }
Ejemplo n.º 6
0
    //this is a long one and should be broken into helpers
    //convert whats between the ///////// to helper
    private void RecomendChord()
    {
        List <GameObject> GridsAsGameObj = timeline.TimingGrids;
        //for each grid
        TimingGrid CurrGrid = GridsAsGameObj[0].GetComponent <TimingGrid>();

        for (int beat = 0; beat < GridsAsGameObj.Count; beat++)
        {
            //find if there are any pucks added to the beat
            TimingGrid Grid = GridsAsGameObj[beat].GetComponent <TimingGrid>();
            if (Grid.Sprites.Count > 0)
            {
                //get the last grid with anything in it
                CurrGrid = Grid;
            }
        }


        //if there is a grid update
        if (CurrGrid.Sprites.Count > 0 && (CurrGrid != lastGrid || SpritesInLastGrid != CurrGrid.Sprites.Count))
        {
            CanWiggle             = false;
            transform.eulerAngles = new Vector3(0, 0, 0);
            lastGrid          = CurrGrid;
            SpritesInLastGrid = CurrGrid.Sprites.Count;

            //these should be moved to a helper method.

            //if there's only 1 note in the last grid
            if (lastGrid.Sprites.Count == 1)
            {
                //find the notes in the key
                int pitchNum = lastGrid.Sprites[0].GetComponent <PlayableSprite>().PitchNumber;

                //find the note in the key that the current sprite is.
                //if the sprite is A in the key of A, the index would be 0
                //B in the key of A would be 1... ect
                int keyNumIndex = -1;
                for (int index = 0; index < Keychanger.NumInKey.Count; index++)
                {
                    if (Keychanger.NumInKey[index] == pitchNum)
                    {
                        keyNumIndex = index;
                    }
                }

                //if the current puck in the last gridspace is in the key AND this sugar puck is the next note in the triad, wiggle ths puck
                if (keyNumIndex != -1 && Keychanger.NumInKey[(keyNumIndex + 2) % Keychanger.NumInKey.Count] ==
                    PlaySprite.GetComponent <PlayableSprite>().PitchNumber % 12)
                {
                    CanWiggle = true;
////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//for each section of code between the left and right carrots,
//The code is implemented for use in the lessons only.
//Each of these sections follow the same logic.
//and determins how far away the next note in the basic triad is,
//either 3 or 4 steps away. As the notes are arranged linearly in one octave from A to G#
//there may be wrapping, where the user goes back to the bottom of the list, requireing a longer indicator.
//IE, a step from A to B would be up two pucks, yet a step from G# to A again would require moving down 12 pucks.
//A smaller example, from A to E is as follows:
//IE D to A instead of A to C
//  e
//|-d
//| c<|
//| b |
//|>a-|

                    //clear all chord indicators
                    Keychanger.ClearAllPuckChordLines();

                    //if the note wraps around, IE, if the next note in the chord is "below" the first note instead of
                    //above, use a long arrow to point to this next puck instead of a short arrow
                    if (Keychanger.NumInKey[(keyNumIndex) % Keychanger.NumInKey.Count] > Keychanger.NumInKey[(keyNumIndex + 2) % Keychanger.NumInKey.Count])
                    {
                        if ((keyNumIndex + 2) % Keychanger.NumInKey.Count == 4 || (keyNumIndex + 2) % Keychanger.NumInKey.Count == 1 || (keyNumIndex + 2) % Keychanger.NumInKey.Count == 3 || (keyNumIndex + 2) % Keychanger.NumInKey.Count == 0)
                        {
                            //use a long 3 step arrow, the arrowhead pointing at,and starting from the new puck in the list
                            GameObject Step = Instantiate(VisualSteps[2]);
                            VisualSteps.Add(Step);
                            Step.GetComponent <SpriteRenderer>().enabled = true;
                            Vector3 StepPos = Step.transform.position;
                            Step.transform.position = new Vector3(StepPos.x + 1f,
                                                                  StepPos.y - (TopPos - transform.position.y), StepPos.z);
                        }
                        else
                        {
                            //use a long 4 step arrow, the arrowhead pointing at,and starting from the new puck in the list
                            GameObject Step = Instantiate(VisualSteps[3]);
                            VisualSteps.Add(Step);
                            Step.GetComponent <SpriteRenderer>().enabled = true;
                            Vector3 StepPos = Step.transform.position;
                            Step.transform.position = new Vector3(StepPos.x + 1f,
                                                                  StepPos.y - (TopPos - transform.position.y), StepPos.z);
                        }
                    }
                    //this puck is 3 steps above the previous note, no wrapping indicate it with the 3 step arrow
                    else if ((keyNumIndex + 2) % Keychanger.NumInKey.Count == 4 || (keyNumIndex + 2) % Keychanger.NumInKey.Count == 1 || (keyNumIndex + 2) % Keychanger.NumInKey.Count == 3 || (keyNumIndex + 2) % Keychanger.NumInKey.Count == 0)
                    {
                        GameObject Step = Instantiate(VisualSteps[0]);
                        VisualSteps.Add(Step);
                        Step.GetComponent <SpriteRenderer>().enabled = true;
                        Vector3 StepPos = Step.transform.position;
                        Step.transform.position = new Vector3(StepPos.x + 1f,
                                                              StepPos.y + (transform.position.y -
                                                                           ZeroPos), StepPos.z);
                    }
                    //this puck is 4 steps above the previous note, no wrapping indicate it with the 3 step arrow
                    else
                    {
                        GameObject Step = Instantiate(VisualSteps[1]);
                        VisualSteps.Add(Step);
                        Step.GetComponent <SpriteRenderer>().enabled = true;
                        Vector3 StepPos = Step.transform.position;
                        Step.transform.position = new Vector3(StepPos.x + 1f,
                                                              StepPos.y + (transform.position.y -
                                                                           ZeroPos), StepPos.z);
                    }
////<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                }
            }

            //if there are 2 notes in the grid
            if (lastGrid.Sprites.Count == 2)
            {
                //find the notes in the key
                int pitchNum1 = lastGrid.Sprites[0].GetComponent <PlayableSprite>().PitchNumber;
                int pitchNum2 = lastGrid.Sprites[1].GetComponent <PlayableSprite>().PitchNumber;

                int keyNumIndex1 = -1;
                int keyNumIndex2 = -1;
                //find the notes in the key from the sugar pucks in the last grid.
                for (int index = 0; index < Keychanger.NumInKey.Count; index++)
                {
                    if (Keychanger.NumInKey[index] == pitchNum1)
                    {
                        keyNumIndex1 = index;
                    }
                    if (Keychanger.NumInKey[index] == pitchNum2)
                    {
                        keyNumIndex2 = index;
                    }
                }


                //find which note is the base of the triad, after assessing if the notes can be a triad
                if (keyNumIndex1 != -1 && keyNumIndex2 != -1)
                {
                    //assess if the first index is the base of the triad
                    if ((keyNumIndex1 + 2) % Keychanger.NumInKey.Count == keyNumIndex2)
                    {
                        //wiggle the last note in the triad
                        if (Keychanger.NumInKey[(keyNumIndex2 + 2) % Keychanger.NumInKey.Count] ==
                            PlaySprite.GetComponent <PlayableSprite>().PitchNumber % 12)
                        {
                            CanWiggle = true;

////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

                            if (Keychanger.NumInKey[(keyNumIndex2) % Keychanger.NumInKey.Count] > Keychanger.NumInKey[(keyNumIndex2 + 2) % Keychanger.NumInKey.Count])
                            {
                                if ((keyNumIndex2 + 2) % Keychanger.NumInKey.Count == 4 || (keyNumIndex2 + 2) % Keychanger.NumInKey.Count == 1 || (keyNumIndex2 + 2) % Keychanger.NumInKey.Count == 3 || (keyNumIndex2 + 2) % Keychanger.NumInKey.Count == 0)
                                {
                                    GameObject Step = Instantiate(VisualSteps[2]);
                                    VisualSteps.Add(Step);
                                    Step.GetComponent <SpriteRenderer>().enabled = true;
                                    Vector3 StepPos = Step.transform.position;
                                    Step.transform.position = new Vector3(StepPos.x + 1f,
                                                                          StepPos.y - (TopPos - transform.position.y), StepPos.z);
                                }
                                else
                                {
                                    GameObject Step = Instantiate(VisualSteps[3]);
                                    VisualSteps.Add(Step);
                                    Step.GetComponent <SpriteRenderer>().enabled = true;
                                    Vector3 StepPos = Step.transform.position;
                                    Step.transform.position = new Vector3(StepPos.x + 1f,
                                                                          StepPos.y - (TopPos - transform.position.y), StepPos.z);
                                }
                            }
                            else if ((keyNumIndex2 + 2) % Keychanger.NumInKey.Count == 4 || (keyNumIndex2 + 2) % Keychanger.NumInKey.Count == 1 || (keyNumIndex2 + 2) % Keychanger.NumInKey.Count == 3 || (keyNumIndex2 + 2) % Keychanger.NumInKey.Count == 0)
                            {
                                GameObject Step = Instantiate(VisualSteps[0]);
                                VisualSteps.Add(Step);
                                Step.GetComponent <SpriteRenderer>().enabled = true;
                                Vector3 StepPos = Step.transform.position;
                                Step.transform.position = new Vector3(StepPos.x + 1f,
                                                                      StepPos.y + (transform.position.y -
                                                                                   ZeroPos), StepPos.z);
                            }
                            else
                            {
                                GameObject Step = Instantiate(VisualSteps[1]);
                                VisualSteps.Add(Step);
                                Step.GetComponent <SpriteRenderer>().enabled = true;
                                Vector3 StepPos = Step.transform.position;
                                Step.transform.position = new Vector3(StepPos.x + 1f,
                                                                      StepPos.y + (transform.position.y -
                                                                                   ZeroPos), StepPos.z);
                            }
////<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                        }
                    }
                    //assess if the second index is the base of the triad
                    if ((keyNumIndex2 + 2) % Keychanger.NumInKey.Count == keyNumIndex1)
                    {
                        //wiggle the last note in the triad
                        if (Keychanger.NumInKey[(keyNumIndex1 + 2) % Keychanger.NumInKey.Count] ==
                            PlaySprite.GetComponent <PlayableSprite>().PitchNumber % 12)
                        {
                            CanWiggle = true;

////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                            if (Keychanger.NumInKey[(keyNumIndex1) % Keychanger.NumInKey.Count] > Keychanger.NumInKey[(keyNumIndex1 + 2) % Keychanger.NumInKey.Count])
                            {
                                if ((keyNumIndex1 + 2) % Keychanger.NumInKey.Count == 4 || (keyNumIndex1 + 2) % Keychanger.NumInKey.Count == 1 || (keyNumIndex1 + 2) % Keychanger.NumInKey.Count == 3 || (keyNumIndex1 + 2) % Keychanger.NumInKey.Count == 0)
                                {
                                    GameObject Step = Instantiate(VisualSteps[2]);
                                    VisualSteps.Add(Step);
                                    Step.GetComponent <SpriteRenderer>().enabled = true;
                                    Vector3 StepPos = Step.transform.position;
                                    Step.transform.position = new Vector3(StepPos.x + 1f,
                                                                          StepPos.y - (TopPos - transform.position.y), StepPos.z);
                                }
                                else
                                {
                                    GameObject Step = Instantiate(VisualSteps[3]);
                                    VisualSteps.Add(Step);
                                    Step.GetComponent <SpriteRenderer>().enabled = true;
                                    Vector3 StepPos = Step.transform.position;
                                    Step.transform.position = new Vector3(StepPos.x + 1f,
                                                                          StepPos.y - (TopPos - transform.position.y), StepPos.z);
                                }
                            }
                            else if ((keyNumIndex1 + 2) % Keychanger.NumInKey.Count == 4 || (keyNumIndex1 + 2) % Keychanger.NumInKey.Count == 1 || (keyNumIndex1 + 2) % Keychanger.NumInKey.Count == 3 || (keyNumIndex1 + 2) % Keychanger.NumInKey.Count == 0)
                            {
                                GameObject Step = Instantiate(VisualSteps[0]);
                                VisualSteps.Add(Step);
                                Step.GetComponent <SpriteRenderer>().enabled = true;
                                Vector3 StepPos = Step.transform.position;
                                Step.transform.position = new Vector3(StepPos.x + 1f,
                                                                      StepPos.y + (transform.position.y -
                                                                                   ZeroPos), StepPos.z);
                            }
                            else
                            {
                                GameObject Step = Instantiate(VisualSteps[1]);
                                VisualSteps.Add(Step);
                                Step.GetComponent <SpriteRenderer>().enabled = true;
                                Vector3 StepPos = Step.transform.position;
                                Step.transform.position = new Vector3(StepPos.x + 1f,
                                                                      StepPos.y + (transform.position.y -
                                                                                   ZeroPos), StepPos.z);
                            }
////<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 7
0
        }         // end Beats

        public int xTimingsToLORtimings(xTimings timings, Sequence4 sequence)
        {
            // Ignore the timings passed in, and use the ones already cached for Bars and Beats
            // (Other transforms will use the one passed in)

            seqFunct.Sequence = sequence;
            int errs = 0;

            if (xBars != null)
            {
                if (xBars.effects.Count > 0)
                {
                    TimingGrid barGrid = seqFunct.GetGrid("Bars", true);
                    seqFunct.ImportTimingGrid(barGrid, xBars);
                }
            }
            //if (chkBeatsFull.Checked)
            if (true)
            {
                if (xBeatsFull != null)
                {
                    if (xBeatsFull.effects.Count > 0)
                    {
                        TimingGrid barGrid = seqFunct.GetGrid("Beats-Full", true);
                        seqFunct.ImportTimingGrid(barGrid, xBeatsFull);
                    }
                }
            }
            //if (chkBeatsHalf.Checked)
            if (true)
            {
                if (xBeatsHalf != null)
                {
                    if (xBeatsHalf.effects.Count > 0)
                    {
                        TimingGrid barGrid = seqFunct.GetGrid("Beats-Half", true);
                        seqFunct.ImportTimingGrid(barGrid, xBeatsHalf);
                    }
                }
            }
            //if (chkBeatsThird.Checked)
            if (true)
            {
                if (xBeatsThird != null)
                {
                    if (xBeatsThird.effects.Count > 0)
                    {
                        TimingGrid barGrid = seqFunct.GetGrid("Beats-Third", true);
                        seqFunct.ImportTimingGrid(barGrid, xBeatsThird);
                    }
                }
            }
            //if (chkBeatsQuarter.Checked)
            if (true)
            {
                if (xBeatsQuarter != null)
                {
                    if (xBeatsQuarter.effects.Count > 0)
                    {
                        TimingGrid barGrid = seqFunct.GetGrid("Beats-Quarter", true);
                        seqFunct.ImportTimingGrid(barGrid, xBeatsQuarter);
                    }
                }
            }
            if (xFrames != null)
            {
                if (xFrames.effects.Count > 0)
                {
                    TimingGrid barFrame = seqFunct.GetGrid(xFrames.timingName, true);
                    seqFunct.ImportTimingGrid(barFrame, xFrames);
                }
            }

            return(errs);
        }
Ejemplo n.º 8
0
        private void MergeTimingGrids(TimingGrid destGrid, TimingGrid sourceGrid)
        {
            int t2Idx = 0;
            int exIdx = 0;

            if (sourceGrid.timings.Count > 0)
            {
                if (destGrid.timings.Count > 0)
                {
                    t2Idx = 0;
                    exIdx = 0;
                    int dir = 0;

                    List <int> t2Timings = sourceGrid.timings;
                    List <int> exTimings = destGrid.timings;

                    while ((t2Idx < t2Timings.Count) && (exIdx < exTimings.Count))
                    {
                        if (t2Idx == exIdx)
                        {
                            // Already there!  Do Nothing!
                            // Increment BOTH indexes
                            exIdx++;
                            t2Idx++;
                        }
                        else
                        {
                            if (t2Idx > exIdx)
                            {
                                // Haven't reached same point yet
                                // Increment new index
                                exIdx++;
                            }
                            else
                            {
                                // t2Idx < exIdx
                                // Didn't exist in new sequence
                                // Add it
                                destGrid.CopyTimings(sourceGrid.timings, true);
                                // Increment BOTH indexes
                                exIdx++;
                                t2Idx++;
                            }             // haven't reached it
                        }                 // Not already there
                    }                     // while indexes are below counts
                }
                else
                {
                    // Unlikely situation here, but nonetheless plausible
                    // Sequence2 and New Sequence have timing grids with the same name
                    // but in the New Sequence the grid is empty, and in Sequence2 it is not
                    // Names match, but are they the same type?  (might be why it's empty)
                    if (sourceGrid.TimingGridType == destGrid.TimingGridType)
                    {
                        // So--- Add all of them
                        //destGrid.itemCount = sourceGrid.itemCount;
                        //Array.Resize(ref seqTwo.TimingGrids[seqNewGridIdx].timings, sourceGrid.itemCount);
                        foreach (int tc in sourceGrid.timings)
                        //for (int t = 0; t < sourceGrid.itemCount; t++)
                        {
                            destGrid.timings.Add(tc);
                            //sourceGrid.timings[t];
                        }
                    }
                    else
                    {
                        //? Not sure what to do here
                        string sMsg = "Help!  This situation was not programmed for!\r\n";
                        sMsg += "Both sequences contain a timing grid named '" + sourceGrid.Name;
                        sMsg += "' but they are not the same type!\r\n";
                        sMsg += "It is highly recommended that you rename one (or both) of the timing grids in one (or both) ";
                        sMsg += "sequences and re-perform this merge.";
                        MessageBox.Show(this, sMsg, "Grid Conflict", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }         // end new timing grid has timings (or not)
            }             // end 2nd timing grid had items
        }
Ejemplo n.º 9
0
        private void OldMergeSequences()
        {
            mergeTracks         = Properties.Settings.Default.MergeTracks;
            mergeTracksByName   = Properties.Settings.Default.MergeTracksByName;
            duplicateNameAction = Properties.Settings.Default.DuplicateNameAction;
            numberFormat        = Properties.Settings.Default.AddNumberFormat;

            bool matched = false;
            int  t2Idx   = 0;
            int  exIdx   = 0;


            List <Map> groupMap       = new List <Map>();
            List <Map> trackMap       = new List <Map>();
            List <Map> timingMap      = new List <Map>();
            int        newGroupCount  = 0;
            int        newTrackCount  = 0;
            int        newTimingCount = 0;

            /////////////////////
            //  TIMING GRIDS  //
            ///////////////////

            // Make sure existing time grids are in order (they should be, but make sure anyway)
            for (int t = 0; t < seqNew.TimingGrids.Count; t++)
            {
                seqNew.TimingGrids[t].timings.Sort();
            }

            for (int timings2Idx = 0; timings2Idx < seqTwo.TimingGrids.Count; timings2Idx++)
            {
                seqTwo.TimingGrids[timings2Idx].timings.Sort();
                matched = false;
                int matchingExTimingsGridIdx = utils.UNDEFINED;
                for (int exTimingGridsIdx = 0; exTimingGridsIdx < seqNew.TimingGrids.Count; exTimingGridsIdx++)
                {
                    // Compare names
                    if (seqTwo.TimingGrids[timings2Idx].CompareTo(seqNew.TimingGrids[exTimingGridsIdx]) == 0)
                    {
                        // Matching names found
                        matched = true;
                        matchingExTimingsGridIdx = exTimingGridsIdx;
                        exTimingGridsIdx         = seqNew.TimingGrids.Count; // Break out of loop
                    }
                }                                                            // end loop thru new sequence's timing grids
                if (matched)
                {
                    //MergeTimingGrids(timings2Idx, matchingExTimingsGridIdx);
                }
                else
                {
                    // No timing grid with matching name found, so add this one
                    // Create a new timing grid and copy the name and type
                    int newSaveID = seqNew.Members.HighestSaveID + 1;

                    TimingGrid tGrid = seqNew.CreateTimingGrid(seqTwo.TimingGrids[timings2Idx].Name);
                    //tGrid.type = seqTwo.TimingGrids[timings2Idx].type;
                    tGrid.spacing = seqTwo.TimingGrids[timings2Idx].spacing;
                    // Create a new array for timings, and copy them
                    tGrid.CopyTimings(seqTwo.TimingGrids[timings2Idx].timings, false);
                }         // end if matched, or not
            }             // end loop thru 2nd sequence's timing grids

            ///////////////
            //  TRACKS  //
            /////////////

            foreach (Track track2 in seqTwo.Tracks)
            //for (int tracks2Idx = 0; tracks2Idx < seqTwo.Tracks.Count; tracks2Idx++)
            {
                matched = false;
                if (mergeTracks)
                {
                    int matchedExTracksIdx = utils.UNDEFINED;
                    foreach (Track newTrack in seqNew.Tracks)
                    //for (int exTracksIdx = 0; exTracksIdx < seqNew.Tracks.Count; exTracksIdx++)
                    {
                        if (mergeTracksByName)
                        {
                            // Merge by Name
                            if (track2.CompareTo(newTrack) == 0)
                            {
                                matched = true;
                                t2Idx   = track2.Index;
                                exIdx   = newTrack.Index;
                                //exTracksIdx = seqNew.Tracks.Count; // Break out of loop
                                break;
                            }
                        }
                        else
                        {
                            // Merge by Number
                            if (track2.Index == newTrack.Index)
                            {
                                matched = true;
                                t2Idx   = track2.Index;
                                exIdx   = newTrack.Index;
                                //exTracksIdx = seqNew.trackCount; // Break out of loop
                                break;
                            }
                        }
                    }                     // New Sequence Track Loop
                    if (matched)
                    {
                        //MergeTracks(t2Idx, exIdx);

                        newTrackCount++;
                    }
                }



                ///////////////////////
                //  CHANNEL GROUPS  //
                /////////////////////

                foreach (ChannelGroup group2 in seqTwo.ChannelGroups)
                //for (int groups2Idx = 0; groups2Idx < seqTwo.channelGroupCount; groups2Idx++)
                {
                    int matchedExGroupsIdx = utils.UNDEFINED;
                    foreach (ChannelGroup newGroup in seqNew.ChannelGroups)
                    //for (int exGroupsIdx = 0; exGroupsIdx < seqNew.channelGroupCount; exGroupsIdx++)
                    {
                        matched = false;
                        if (group2.CompareTo(newGroup) == 0)
                        {
                            matchedExGroupsIdx = newGroup.Index;
                            //exGroupsIdx = seqNew.channelGroupCount;
                            break;
                        }
                        //Array.Resize(ref groupMap, newGroupCount + 1);
                        Map gm = new Map(group2, newGroup);
                        groupMap.Add(gm);
                        if (matchedExGroupsIdx == utils.UNDEFINED)
                        {
                            ChannelGroup group3 = seqNew.CreateChannelGroup(group2.Name);
                            gm = new Map(group3, newGroup);
                            groupMap.Add(gm);
                        }
                        else
                        {
                        }
                        newGroupCount++;
                    }



                    /////////////////////
                    //  RGB CHANNELS  //
                    ///////////////////



                    ///////////////////////////
                    //  (Regular) CHANNELS  //
                    /////////////////////////
                }
            }
        }
Ejemplo n.º 10
0
        private void MergeSequences()
        {
            mergeTracks         = Properties.Settings.Default.MergeTracks;
            mergeTracksByName   = Properties.Settings.Default.MergeTracksByName;
            duplicateNameAction = Properties.Settings.Default.DuplicateNameAction;
            mergeEffects        = Properties.Settings.Default.MergeEffects;
            numberFormat        = Properties.Settings.Default.AddNumberFormat;

            bool matched = false;
            int  exIdx   = 0;


            List <Map> groupMap       = new List <Map>();
            List <Map> trackMap       = new List <Map>();
            List <Map> timingMap      = new List <Map>();
            int        newGroupCount  = 0;
            int        newTrackCount  = 0;
            int        newTimingCount = 0;
            bool       found          = false;



            /////////////////////
            //  TIMING GRIDS  //
            ///////////////////
            if (mergeGrids)
            {
                for (int g2Idx = 0; g2Idx < seqTwo.TimingGrids.Count; g2Idx++)
                {
                    TimingGrid sourceGrid = seqTwo.TimingGrids[g2Idx];
                    sourceGrid.timings.Sort();
                    TimingGrid destGrid = null;
                    // Grids treated like tracks.  Merge or Append?
                    if (mergeTracks)
                    {
                        found = true;                         // Reset to default
                        // Search for it, do NOT create if not found
                        destGrid = (TimingGrid)seqNew.Members.Find(sourceGrid.Name, MemberType.TimingGrid, false);
                        if (destGrid == null)                         // no match found
                        {
                            found    = false;
                            destGrid = seqNew.CreateTimingGrid(sourceGrid.Name);
                        }
                        else                         // match found!
                        {
                            // Check for conflicting types and warn user
                            if (sourceGrid.TimingGridType == TimingGridType.FixedGrid)
                            {
                                if (destGrid.TimingGridType == TimingGridType.Freeform)
                                {
                                    GridMismatchError(sourceGrid.Name);
                                }
                            }
                            if (sourceGrid.TimingGridType == TimingGridType.Freeform)
                            {
                                if (destGrid.TimingGridType == TimingGridType.FixedGrid)
                                {
                                    GridMismatchError(sourceGrid.Name);
                                }
                            }
                            // What to do if match is found?
                            if (duplicateNameAction == ACTIONkeepBoth)
                            {
                                destGrid = seqNew.CreateTimingGrid(sourceGrid.Name);
                            }
                            if (duplicateNameAction == ACTIONaddNumber)
                            {
                                destGrid = seqNew.CreateTimingGrid(sourceGrid.Name + " (2)");
                            }
                            if (duplicateNameAction == ACTIONuseSecond)
                            {
                                destGrid.timings.Clear();
                            }
                        }
                    }
                    else                     // Append
                    {
                        destGrid = seqNew.CreateTimingGrid(sourceGrid.Name);
                        destGrid.TimingGridType = sourceGrid.TimingGridType;
                    }                     // Enbd if merge or append

                    // if not found, or any action other than keep first
                    if (!found || (duplicateNameAction != ACTIONkeepFirst))
                    {
                        // Copy type, spacing and timings
                        destGrid.TimingGridType = sourceGrid.TimingGridType;
                        destGrid.spacing        = sourceGrid.spacing;
                        if (destGrid.TimingGridType == TimingGridType.Freeform)
                        {
                            destGrid.CopyTimings(sourceGrid.timings, false);
                        }
                    }
                }         // end loop thru 2nd sequence's timing grids
            }             // if Merge Grids

            ///////////////
            //  TRACKS  //
            /////////////

            if (mergeTracks)
            {
                //foreach (Track track2 in seqTwo.Tracks)
                for (int t2Idx = 0; t2Idx < seqTwo.Tracks.Count; t2Idx++)
                {
                    Track sourceTrack = seqTwo.Tracks[t2Idx];
                    Track destTrack   = null;
                    if (mergeTracksByNumber)
                    {
                        // Merge by number or name?
                        // If by number, do we even have that many in the destination?
                        if (t2Idx < seqNew.Tracks.Count)
                        {
                            destTrack = seqNew.Tracks[t2Idx];
                        }
                        else
                        {
                            // Not enough, make one
                            destTrack = seqNew.CreateTrack(sourceTrack.Name);
                        }
                    }
                    if (mergeTracksByName)
                    {
                        found     = true;                     // reset to default
                        destTrack = (Track)seqNew.Members.Find(sourceTrack.Name, MemberType.Track, false);
                        if (destTrack == null)                // no matching name found
                        {
                            found     = false;
                            destTrack = seqNew.CreateTrack(sourceTrack.Name);
                        }
                        else                         // matching name found!
                        {
                        }
                    }
                    if (appendTracks)
                    {
                        destTrack = seqNew.CreateTrack(sourceTrack.Name);
                    }
                    MergeMembers(destTrack.Members, sourceTrack.Members);

                    Console.WriteLine(destTrack.Name);
                }
            }
        }