Ejemplo n.º 1
0
 public static int CompareByStartSample(TempoSectionDef first, TempoSectionDef second)
 {
     if (first.StartSample < second.StartSample)
     {
         return -1;
     }
     else if (first.StartSample == second.StartSample)
     {
         return 0;
     }
     else
     {
         return 1;
     }
 }
Ejemplo n.º 2
0
 public bool RemoveTempoSection(TempoSectionDef sectionDef)
 {
     return RemoveTempoSectionAtIndex(GetIndexOfTempoSection(sectionDef));
 }
Ejemplo n.º 3
0
 public int GetIndexOfTempoSection(TempoSectionDef sectionDef)
 {
     return mTempoSections.IndexOf(sectionDef);
 }
Ejemplo n.º 4
0
    public TempoSectionDef InsertTempoSectionAtIndex(int idxToInsert)
    {
        TempoSectionDef newSectionDef = null;

        if (idxToInsert >= 0 && idxToInsert <= mTempoSections.Count)
        {
            newSectionDef = new TempoSectionDef();
            if (idxToInsert == mTempoSections.Count)
            {
                mTempoSections.Add(newSectionDef);
            }
            else
            {
                mTempoSections.Insert(idxToInsert, newSectionDef);
            }
        }

        return newSectionDef;
    }
Ejemplo n.º 5
0
    void DrawBeatLinesForSection(Rect contentRect, WaveDisplayState displayState, TempoSectionDef tempoSection, int startSample, int endSample, Color sectionColor)
    {
        // Only draw the lines if our current zoom level is reasonable.
        if (tempoSection.SamplesPerBeat >= displayState.samplesPerPixel * 2)		// Check that we will not just be drawing a line (or multiple lines!) for each pixel.  Require at least one gap.
        {
            // Draw our background box.
            {
                Color bgColor = GUI.backgroundColor;
                GUI.backgroundColor = sectionColor;
                Rect boxRect = new Rect(contentRect);
                boxRect.xMin += (float)(startSample - displayState.firstSamplePackToDraw) / displayState.samplesPerPixel;
                boxRect.xMax -= contentRect.width - (float)(endSample - displayState.firstSamplePackToDraw) / displayState.samplesPerPixel;
                GUI.Box(boxRect, "");
                GUI.backgroundColor = bgColor;
            }

            if (Event.current.type.Equals(EventType.Repaint))
            {
                // Set us up to draw the first beat.  Initially, assume we start somewhere within the view.
                float lineLoc = (float)tempoSection.StartSample - displayState.firstSamplePackToDraw;
                int beatNum = 0;

                // Get us onto the current beat boundary if our content begins beyond that first beat.
                if (startSample > tempoSection.StartSample)
                {
                    lineLoc %= tempoSection.SamplesPerBeat;
                    beatNum = ((int)((float)(startSample - tempoSection.StartSample) / tempoSection.SamplesPerBeat));
                }

                float grayValue = 170f / 255f;
                Color firstBeatColor = new Color(grayValue, grayValue, grayValue, KoreographerColors.HandleFullAlpha);

                grayValue = 96f / 255f;
                Color normalBeatColor = new Color(grayValue, grayValue, grayValue, KoreographerColors.HandleFullAlpha);

                // Draw all the beat lines!
                for (; lineLoc < (float)endSample - displayState.firstSamplePackToDraw; lineLoc += tempoSection.SamplesPerBeat)
                {
                    int x = (int)(contentRect.x + (lineLoc / displayState.samplesPerPixel));
                    Handles.color = (beatNum % tempoSection.BeatsPerMeasure == 0) ? firstBeatColor : normalBeatColor;
                    Handles.DrawLine(new Vector2(x, contentRect.yMin), new Vector2(x, contentRect.yMax));

                    // Increment the beat count!
                    beatNum++;
                }
            }
        }
    }