Exemple #1
0
 public void MoveSelectionEnd(double time)
 {
     selectionRightBeatID = RightExpandBound(BeatEditor.GetNearestBeatID(time), AlignBeat);
     if (selectionRightBeatID <= selectionLeftBeatID)
     {
         selectionLeftBeatID = LeftExpandBound(selectionRightBeatID - 1, AlignBeat);
     }
 }
Exemple #2
0
        public void EditModeUpdate()
        {
            if (!Enabled)
            {
                return;
            }
            if (ShowRawChord)
            {
                DrawRawChords();
            }
            double curTime = TL.CurrentTime;

            pointLeftBeatID  = BeatEditor.GetPreviousBeatID(curTime);
            pointRightBeatID = BeatEditor.GetNextBeatID(curTime);

            //Fix for bound detect
            if (FixBoundOption)
            {
                if (pointRightBeatID < Info.beats.Count - 1 && pointLeftBeatID >= 0)
                {
                    double time1 = Info.beats[pointLeftBeatID].Time,
                           time2 = Info.beats[pointRightBeatID].Time;
                    if ((time2 - curTime) / (time2 - time1) < NEXT_CHORD_START_PERCENT &&
                        time2 - curTime < NEXT_CHORD_START_TIME)
                    {
                        pointLeftBeatID++;
                        pointRightBeatID++;
                    }
                }
            }
            pointRightBeatID = RightExpandBound(pointRightBeatID, AlignBeat);
            if (ForceFrontAlign)
            {
                pointLeftBeatID = LeftExpandBound(pointLeftBeatID, AlignBeat);
            }
            if (ValidPointer)
            {
                double time1   = Info.beats[pointLeftBeatID].Time,
                       time2   = Info.beats[pointRightBeatID].Time;
                int pos1       = TL.Time2Pos(time1),
                    pos2       = TL.Time2Pos(time2);
                Rectangle rect = new Rectangle(pos1, TL.HorizonHeight - 30, pos2 - pos1, 30);
                TL.G.FillRectangle(transbrush, rect);
                TL.G.DrawRectangle(pointPen, rect);
            }
            if (ValidSelection)
            {
                double time1   = Info.beats[selectionLeftBeatID].Time,
                       time2   = Info.beats[selectionRightBeatID].Time;
                int pos1       = TL.Time2Pos(time1),
                    pos2       = TL.Time2Pos(time2);
                Rectangle rect = new Rectangle(pos1, TL.HorizonHeight - 30, pos2 - pos1, 30);
                //TL.G.FillRectangle(transbrush, rect);
                TL.G.DrawRectangle(selectionPen, rect);
            }
        }
Exemple #3
0
        public void DrawChords()
        {
            double tempLeftMostTime = TL.LeftMostTime, tempRightMostTime = TL.RightMostTime;
            int    left = BeatEditor.GetPreviousBeatID(tempLeftMostTime) - 1, right = BeatEditor.GetNextBeatID(tempRightMostTime);

            // Get the previous of previous beat of the left bound and the next beat of the right bound.
            if (left < 0)
            {
                left = 0;
            }
            if (right >= Info.beats.Count)
            {
                right = Info.beats.Count - 1;
            }
            BeatInfo leftSameChord = Info.beats[left];

            for (int i = left; i <= right; ++i)
            {
                BeatInfo beat = Info.beats[i];
                if (beat.ChordTag?.ToString() != leftSameChord.ChordTag?.ToString() || i == right)
                {
                    DrawChordAt(leftSameChord, Info.beats[i]);
                    leftSameChord = beat;
                }
            }
            //Play chord parts
            if (AutoPlayMidi)
            {
                double curTime = TL.CurrentTime;
                pointLeftBeatID = BeatEditor.GetPreviousBeatID(curTime);
                if (pointLeftBeatID == -1)
                {
                    CurrentChord = null;
                }
                else
                {
                    Chord newChord = Info.beats[pointLeftBeatID].ChordTag;
                    if (CurrentChord?.ToString() != newChord?.ToString())
                    {
                        CurrentChord = newChord;
                        if (TL.Playing)
                        {
                            Program.MidiManager.PlayChordNotes(CurrentChord);
                        }
                    }
                }
            }
        }
Exemple #4
0
 public Timeline(PictureBox bindingPictureBox, SongInfo info, string mp3Path)
 {
     pictureBox = bindingPictureBox;
     bindingPictureBox.BackColor = Color.Black;
     Target    = bindingPictureBox.CreateGraphics();
     Info      = info;
     MP3stream = Bass.BASS_StreamCreateFile(mp3Path, 0, 0, BASSFlag.BASS_SAMPLE_SOFTWARE);
     Bass.BASS_ChannelPlay(MP3stream, true);
     TempCurrentTime = CurrentTime;
     myBuffer        = BufferedGraphicsManager.Current.Allocate(Target, new Rectangle(0, 0, TargetRightPos, AllHeight));
     G = myBuffer.Graphics;
     G.SmoothingMode   = SmoothingMode.HighQuality;
     G.PixelOffsetMode = PixelOffsetMode.HighQuality;
     ChordEditor       = new ChordEditor(this);
     BeatEditor        = new BeatEditor(this);
     ChromaVisualizer  = new ChromaVisualizer(this);
 }
Exemple #5
0
 public ChromaVisualizer(Timeline tl)
 {
     TL         = tl;
     Info       = TL.Info;
     BeatEditor = TL.BeatEditor;
 }