Exemplo n.º 1
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            UNote other = obj as UNote;

            if (other == null)
            {
                throw new ArgumentException("CompareTo object is not a Note");
            }

            if (other.PosTick < this.PosTick)
            {
                return(1);
            }
            else if (other.PosTick > this.PosTick)
            {
                return(-1);
            }
            else if (other.GetHashCode() < this.GetHashCode())
            {
                return(1);
            }
            else if (other.GetHashCode() > this.GetHashCode())
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 2
0
 public MoveNoteCommand(UVoicePart part, UNote note, int deltaPos, int deltaNoteNum)
 {
     this.Part = part;
     this.Notes = new UNote[] { note };
     this.DeltaPos = deltaPos;
     this.DeltaNoteNum = deltaNoteNum;
 }
Exemplo n.º 3
0
 public DeletePitchPointCommand(UVoicePart part, UNote note, int index)
 {
     this.Part = part;
     this.Note = note;
     this.Index = index;
     this.Point = Note.PitchBend.Points[Index];
 }
Exemplo n.º 4
0
 public override UExpression Clone(UNote newParent)
 {
     return(new IntExpression(newParent, Name, Abbr)
     {
         Min = Min, Max = Max, Data = Data
     });
 }
Exemplo n.º 5
0
 public UPhoneme Clone(UNote newParent)
 {
     var p = new UPhoneme()
     {
         Parent = newParent
     }; return(p);
 }
Exemplo n.º 6
0
 public EnvelopeExpression(UNote parent) : base(parent, "envelope", "env")
 {
     _data.Add(new ExpPoint(0, 0));
     _data.Add(new ExpPoint(0, 100));
     _data.Add(new ExpPoint(0, 100));
     _data.Add(new ExpPoint(0, 100));
     _data.Add(new ExpPoint(0, 0));
 }
Exemplo n.º 7
0
 public SetIntExpCommand(UVoicePart part, UNote note, string key, int newValue)
 {
     this.Part = part;
     this.Note = note;
     this.Key = key;
     this.NewValue = newValue;
     this.OldValue = (int)Note.Expressions[Key].Data;
 }
Exemplo n.º 8
0
 private void DrawNote(UNote note, DrawingContext cxt)
 {
     DrawNoteBody(note, cxt);
     if (!note.Error)
     {
         if (ShowPitch) DrawPitchBend(note, cxt);
         if (ShowPitch) DrawVibrato(note, cxt);
     }
 }
Exemplo n.º 9
0
        public override UExpression Split(UNote newParent, int offset)
        {
            var newdata = new List <ExpPoint>();

            // TODO
            return(new EnvelopeExpression(newParent)
            {
                Data = newdata
            });
        }
Exemplo n.º 10
0
        private void DrawPhoneme(UNote note, DrawingContext cxt)
        {
            const double y = 23.5;
            const double height = 24;
            if (note.Error) return;
            for (int i = 0; i < note.Phonemes.Count; i++)
            {
                var phoneme = note.Phonemes[i];
                double x = Math.Round(note.PosTick * midiVM.QuarterWidth / DocManager.Inst.Project.Resolution) + 0.5;
                double x0 = (note.PosTick + DocManager.Inst.Project.MillisecondToTick(phoneme.Envelope.Points[0].X))
                    * midiVM.QuarterWidth / DocManager.Inst.Project.Resolution;
                double y0 = (1 - phoneme.Envelope.Points[0].Y / 100) * height;
                double x1 = (note.PosTick + DocManager.Inst.Project.MillisecondToTick(phoneme.Envelope.Points[1].X))
                    * midiVM.QuarterWidth / DocManager.Inst.Project.Resolution;
                double y1 = (1 - phoneme.Envelope.Points[1].Y / 100) * height;
                double x2 = (note.PosTick + DocManager.Inst.Project.MillisecondToTick(phoneme.Envelope.Points[2].X))
                    * midiVM.QuarterWidth / DocManager.Inst.Project.Resolution;
                double y2 = (1 - phoneme.Envelope.Points[2].Y / 100) * height;
                double x3 = (note.PosTick + DocManager.Inst.Project.MillisecondToTick(phoneme.Envelope.Points[3].X))
                    * midiVM.QuarterWidth / DocManager.Inst.Project.Resolution;
                double y3 = (1 - phoneme.Envelope.Points[3].Y / 100) * height;
                double x4 = (note.PosTick + DocManager.Inst.Project.MillisecondToTick(phoneme.Envelope.Points[4].X))
                    * midiVM.QuarterWidth / DocManager.Inst.Project.Resolution;
                double y4 = (1 - phoneme.Envelope.Points[4].Y / 100) * height;

                Pen pen = note.Selected ? penEnvSel : penEnv;
                Brush brush = note.Selected ? ThemeManager.NoteFillSelectedErrorBrushes : ThemeManager.NoteFillErrorBrushes[0];
                
                StreamGeometry g = new StreamGeometry();
                List<Point> poly = new List<Point>() {
                    new Point(x1, y + y1),
                    new Point(x2, y + y2),
                    new Point(x3, y + y3),
                    new Point(x4, y + y4),
                    new Point(x0, y + y0)
                };

                using (var gcxt = g.Open())
                {
                    gcxt.BeginFigure(new Point(x0, y + y0), true, false);
                    gcxt.PolyLineTo(poly, true, false);
                    gcxt.Close();
                }
                cxt.DrawGeometry(brush, pen, g);

                cxt.DrawLine(penEnvSel, new Point(x, y), new Point(x, y + height));

                string text = phoneme.Phoneme;
                if (!fTextPool.ContainsKey(text)) AddToFormattedTextPool(text);
                var fText = fTextPool[text];
                if (midiVM.QuarterWidth > UIConstants.MidiQuarterMinWidthShowPhoneme)
                    cxt.DrawText(fText, new Point(Math.Round(x), 8));
            }
        }
Exemplo n.º 11
0
        public UNote CreateNote()
        {
            UNote note = UNote.Create();

            foreach (var pair in ExpressionTable)
            {
                note.Expressions.Add(pair.Key, pair.Value.Clone(note));
            }
            note.PitchBend.Points[0].X = -25;
            note.PitchBend.Points[1].X = 25;
            return(note);
        }
Exemplo n.º 12
0
 public UNote Clone() {
     UNote _note = new UNote()
     {
         PosTick = PosTick,
         DurTick = DurTick,
         NoteNum = NoteNum,
         Lyric = Lyric
     };
     foreach (var phoneme in this.Phonemes) _note.Phonemes.Add(phoneme.Clone(_note));
     foreach (var pair in this.Expressions) _note.Expressions.Add(pair.Key, pair.Value.Clone(_note));
     _note.PitchBend = (PitchBendExpression)this.PitchBend.Clone(_note);
     return _note;
 }
Exemplo n.º 13
0
 public override UExpression Clone(UNote newParent)
 {
     return(new VibratoExpression(newParent)
     {
         _length = _length,
         _period = _period,
         _depth = _depth,
         _in = _in,
         _out = _out,
         _shift = _shift,
         _drift = _drift
     });
 }
Exemplo n.º 14
0
        public override UExpression Clone(UNote newParent)
        {
            var data = new List <ExpPoint>();

            foreach (var p in this._data)
            {
                data.Add(p.Clone());
            }
            return(new EnvelopeExpression(newParent)
            {
                Data = data
            });
        }
Exemplo n.º 15
0
        public override UExpression Split(UNote newParent, int offset)
        {
            var newdata = new List <PitchPoint>();

            while (_data.Count > 0 && _data.Last().X >= offset)
            {
                newdata.Add(_data.Last()); _data.Remove(_data.Last());
            }
            newdata.Reverse();
            return(new PitchBendExpression(newParent)
            {
                Data = newdata, SnapFirst = true
            });
        }
Exemplo n.º 16
0
        public UNote Clone()
        {
            UNote _note = new UNote()
            {
                PosTick = PosTick,
                DurTick = DurTick,
                NoteNum = NoteNum,
                Lyric   = Lyric
            };

            foreach (var phoneme in this.Phonemes)
            {
                _note.Phonemes.Add(phoneme.Clone(_note));
            }
            foreach (var pair in this.Expressions)
            {
                _note.Expressions.Add(pair.Key, pair.Value.Clone(_note));
            }
            _note.PitchBend = (PitchBendExpression)this.PitchBend.Clone(_note);
            return(_note);
        }
Exemplo n.º 17
0
 public IntExpression(UNote parent, string name, string abbr) : base(parent, name, abbr)
 {
 }
Exemplo n.º 18
0
 public abstract UExpression Split(UNote newParent, int offset);
Exemplo n.º 19
0
 public abstract UExpression Clone(UNote newParent);
Exemplo n.º 20
0
 public SnapPitchPointCommand(UNote note)
 {
     this.Note = note;
     this.X = Note.PitchBend.Points.First().X;
     this.Y = Note.PitchBend.Points.First().Y;
 }
Exemplo n.º 21
0
 public VibratoExpression(UNote parent) : base(parent, "vibrato", "VBR")
 {
 }
Exemplo n.º 22
0
 public RemoveNoteCommand(UVoicePart part, UNote note) { this.Part = part; this.Notes = new UNote[] { note }; }
Exemplo n.º 23
0
 public ChangeNoteLyricCommand(UVoicePart part, UNote note, string newLyric) { this.Part = part; this.Note = note; this.NewLyric = newLyric; this.OldLyric = note.Lyric; }
Exemplo n.º 24
0
        private void DrawVibrato(UNote note, DrawingContext cxt)
        {
            if (note.Vibrato == null) return;
            var vibrato = note.Vibrato;
            double periodPix = DocManager.Inst.Project.MillisecondToTick(vibrato.Period) * midiVM.QuarterWidth / DocManager.Inst.Project.Resolution;
            double lengthPix = note.DurTick * vibrato.Length / 100 * midiVM.QuarterWidth / DocManager.Inst.Project.Resolution;

            double startX = (note.PosTick + note.DurTick * (1 - vibrato.Length / 100)) * midiVM.QuarterWidth / DocManager.Inst.Project.Resolution;
            double startY = TrackHeight * (UIConstants.MaxNoteNum - 1.0 - note.NoteNum) + TrackHeight / 2;
            double inPix = lengthPix * vibrato.In / 100;
            double outPix = lengthPix * vibrato.Out / 100;
            double depthPix = vibrato.Depth / 100 * midiVM.TrackHeight;

            /*if (vibrato.Length > 0 && vibrato.Depth > 0)
            {
                StreamGeometry g = new StreamGeometry();
                using (var gcxt = g.Open())
                {
                    gcxt.BeginFigure(new Point(startX, startY), true, true);
                    gcxt.LineTo(new Point(startX + inPix, startY + depthPix), false, false);
                    gcxt.LineTo(new Point(startX + lengthPix - outPix, startY + depthPix), false, false);
                    gcxt.LineTo(new Point(startX + lengthPix, startY), false, false);
                    gcxt.LineTo(new Point(startX + lengthPix - outPix, startY - depthPix), false, false);
                    gcxt.LineTo(new Point(startX + inPix, startY - depthPix), false, false);
                    gcxt.Close();
                }
                cxt.DrawGeometry(Brushes.White, null, g);
            }*/

            double _x0 = 0, _y0 = 0, _x1 = 0, _y1 = 0;
            while (_x1 < lengthPix)
            {
                cxt.DrawLine(penPit, new Point(startX + _x0, startY + _y0), new Point(startX + _x1, startY + _y1));
                _x0 = _x1;
                _y0 = _y1;
                _x1 += Math.Min(2, periodPix / 8);
                _y1 = -Math.Sin(2 * Math.PI * (_x1 / periodPix + vibrato.Shift / 100)) * depthPix;
                if (_x1 < inPix) _y1 = _y1 * _x1 / inPix;
                else if (_x1 > lengthPix - outPix) _y1 = _y1 * (lengthPix - _x1) / outPix;
            }
        }
Exemplo n.º 25
0
 private void notesCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (midiVM.Part == null) return;
     _inMove = false;
     _inResize = false;
     _noteHit = null;
     _inPitMove = false;
     _pitHit = null;
     DocManager.Inst.EndUndoGroup();
     // End selection
     selectionStart = null;
     if (selectionBox != null)
     {
         Canvas.SetZIndex(selectionBox, -100);
         selectionBox.Visibility = System.Windows.Visibility.Hidden;
     }
     midiVM.DoneTempSelect();
     ((Canvas)sender).ReleaseMouseCapture();
     Mouse.OverrideCursor = null;
 }
Exemplo n.º 26
0
 public PitchBendExpression(UNote parent) : base(parent, "pitch", "PIT")
 {
     _data.Add(new PitchPoint(0, 0));
     _data.Add(new PitchPoint(0, 0));
 }
Exemplo n.º 27
0
 public UExpression(UNote parent, string name, string abbr)
 {
     _parent = parent; _name = name; _abbr = abbr;
 }
Exemplo n.º 28
0
        private void notesCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (midiVM.Part == null) return;
            Point mousePos = e.GetPosition((Canvas)sender);

            var hit = VisualTreeHelper.HitTest(notesCanvas, mousePos).VisualHit;
            System.Diagnostics.Debug.WriteLine("Mouse hit " + hit.ToString());

            var pitHitResult = midiHT.HitTestPitchPoint(mousePos);

            if (pitHitResult != null)
            {
                if (pitHitResult.OnPoint)
                {
                    _inPitMove = true;
                    _pitHit = pitHitResult.Note.PitchBend.Points[pitHitResult.Index];
                    _pitHitIndex = pitHitResult.Index;
                    _noteHit = pitHitResult.Note;
                    DocManager.Inst.StartUndoGroup();
                }
            }
            else
            {
                UNote noteHit = midiHT.HitTestNote(mousePos);
                if (noteHit != null) System.Diagnostics.Debug.WriteLine("Mouse hit" + noteHit.ToString());

                if (Keyboard.Modifiers == ModifierKeys.Control || Keyboard.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift))
                {
                    selectionStart = new Point(midiVM.CanvasToQuarter(mousePos.X), midiVM.CanvasToNoteNum(mousePos.Y));

                    if (Keyboard.IsKeyUp(Key.LeftShift) && Keyboard.IsKeyUp(Key.RightShift)) midiVM.DeselectAll();

                    if (selectionBox == null)
                    {
                        selectionBox = new Rectangle()
                        {
                            Stroke = Brushes.Black,
                            StrokeThickness = 2,
                            Fill = ThemeManager.BarNumberBrush,
                            Width = 0,
                            Height = 0,
                            Opacity = 0.5,
                            RadiusX = 8,
                            RadiusY = 8,
                            IsHitTestVisible = false
                        };
                        notesCanvas.Children.Add(selectionBox);
                        Canvas.SetZIndex(selectionBox, 1000);
                        selectionBox.Visibility = System.Windows.Visibility.Visible;
                    }
                    else
                    {
                        selectionBox.Width = 0;
                        selectionBox.Height = 0;
                        Canvas.SetZIndex(selectionBox, 1000);
                        selectionBox.Visibility = System.Windows.Visibility.Visible;
                    }
                    Mouse.OverrideCursor = Cursors.Cross;
                }
                else
                {
                    if (noteHit != null)
                    {
                        _noteHit = noteHit;
                        if (!midiVM.SelectedNotes.Contains(noteHit)) midiVM.DeselectAll();

                        if (!midiHT.HitNoteResizeArea(noteHit, mousePos))
                        {
                            // Move note
                            _inMove = true;
                            _tickMoveRelative = midiVM.CanvasToSnappedTick(mousePos.X) - noteHit.PosTick;
                            _tickMoveStart = noteHit.PosTick;
                            _lastNoteLength = noteHit.DurTick;
                            if (midiVM.SelectedNotes.Count != 0)
                            {
                                _noteMoveNoteMax = _noteMoveNoteMin = noteHit;
                                _noteMoveNoteLeft = _noteMoveNoteRight = noteHit;
                                foreach (UNote note in midiVM.SelectedNotes)
                                {
                                    if (note.PosTick < _noteMoveNoteLeft.PosTick) _noteMoveNoteLeft = note;
                                    if (note.EndTick > _noteMoveNoteRight.EndTick) _noteMoveNoteRight = note;
                                    if (note.NoteNum < _noteMoveNoteMin.NoteNum) _noteMoveNoteMin = note;
                                    if (note.NoteNum > _noteMoveNoteMax.NoteNum) _noteMoveNoteMax = note;
                                }
                            }
                            DocManager.Inst.StartUndoGroup();
                        }
                        else // if (!noteHit.IsLyricBoxActive()) FIXME
                        {
                            // Resize note
                            _inResize = true;
                            Mouse.OverrideCursor = Cursors.SizeWE;
                            if (midiVM.SelectedNotes.Count != 0)
                            {
                                _noteResizeShortest = noteHit;
                                foreach (UNote note in midiVM.SelectedNotes)
                                    if (note.DurTick < _noteResizeShortest.DurTick) _noteResizeShortest = note;
                            }
                            DocManager.Inst.StartUndoGroup();
                        }
                    }
                    else // Add note
                    {
                        UNote newNote = DocManager.Inst.Project.CreateNote(
                            midiVM.CanvasToNoteNum(mousePos.Y),
                            midiVM.CanvasToSnappedTick(mousePos.X),
                            _lastNoteLength);

                        DocManager.Inst.StartUndoGroup();
                        DocManager.Inst.ExecuteCmd(new AddNoteCommand(midiVM.Part, newNote));
                        DocManager.Inst.EndUndoGroup();
                        midiVM.MarkUpdate();
                        // Enable drag
                        midiVM.DeselectAll();
                        _inMove = true;
                        _noteHit = newNote;
                        _tickMoveRelative = 0;
                        _tickMoveStart = newNote.PosTick;
                        DocManager.Inst.StartUndoGroup();
                    }
                }
            }
            ((UIElement)sender).CaptureMouse();
        }
Exemplo n.º 29
0
        private void DrawNoteBody(UNote note, DrawingContext cxt)
        {
            double left = note.PosTick * midiVM.QuarterWidth / DocManager.Inst.Project.Resolution + 1;
            double top = midiVM.TrackHeight * ((double)UIConstants.MaxNoteNum - 1 - note.NoteNum) + 1;
            double width = Math.Max(2, note.DurTick * midiVM.QuarterWidth / DocManager.Inst.Project.Resolution - 1);
            double height = Math.Max(2, midiVM.TrackHeight - 2);
            cxt.DrawRoundedRectangle(
                note.Error ?
                note.Selected ? ThemeManager.NoteFillSelectedErrorBrushes : ThemeManager.NoteFillErrorBrushes[0] :
                note.Selected ? ThemeManager.NoteFillSelectedBrush : ThemeManager.NoteFillBrushes[0],
                null, new Rect(new Point(left, top), new Size(width, height)), 2, 2);
            if (height >= 10)
            {
                if (note.Lyric.Length == 0) return;
                string displayLyric = note.Lyric;

                if (!fTextPool.ContainsKey(displayLyric)) AddToFormattedTextPool(displayLyric);
                var fText = fTextPool[displayLyric];

                if (fTextWidths[displayLyric] + 5 > width)
                {
                    displayLyric = note.Lyric[0] + "..";
                    if (!fTextPool.ContainsKey(displayLyric)) AddToFormattedTextPool(displayLyric);
                    fText = fTextPool[displayLyric];
                    if (fTextWidths[displayLyric] + 5 > width) return;
                }

                cxt.DrawText(fText, new Point((int)left + 5, Math.Round(top + (height - fTextHeights[displayLyric]) / 2)));
            }
        }
Exemplo n.º 30
0
 public UPhoneme Clone(UNote newParent) { var p = new UPhoneme() { Parent = newParent }; return p; }
Exemplo n.º 31
0
 public override UExpression Split(UNote newParent, int postick)
 {
     var exp = Clone(newParent); return(exp);
 }
Exemplo n.º 32
0
        private void DrawPitchBend(UNote note, DrawingContext cxt)
        {
            var _pitchExp = note.PitchBend as PitchBendExpression;
            var _pts = _pitchExp.Data as List<PitchPoint>;
            if (_pts.Count < 2) return;

            double pt0Tick = note.PosTick + MusicMath.MillisecondToTick(_pts[0].X, DocManager.Inst.Project.BPM, DocManager.Inst.Project.BeatUnit, DocManager.Inst.Project.Resolution);
            double pt0X = midiVM.QuarterWidth * pt0Tick / DocManager.Inst.Project.Resolution;
            double pt0Pit = note.NoteNum + _pts[0].Y / 10.0;
            double pt0Y = TrackHeight * ((double)UIConstants.MaxNoteNum - 1.0 - pt0Pit) + TrackHeight / 2;

            if (note.PitchBend.SnapFirst) cxt.DrawEllipse(ThemeManager.WhiteKeyNameBrushNormal, penPit, new Point(pt0X, pt0Y), 2.5, 2.5);
            else cxt.DrawEllipse(null, penPit, new Point(pt0X, pt0Y), 2.5, 2.5);

            for (int i = 1; i < _pts.Count; i++)
            {
                double pt1Tick = note.PosTick + MusicMath.MillisecondToTick(_pts[i].X, DocManager.Inst.Project.BPM, DocManager.Inst.Project.BeatUnit, DocManager.Inst.Project.Resolution);
                double pt1X = midiVM.QuarterWidth * pt1Tick / DocManager.Inst.Project.Resolution;
                double pt1Pit = note.NoteNum + _pts[i].Y / 10.0;
                double pt1Y = TrackHeight * ((double)UIConstants.MaxNoteNum - 1.0 - pt1Pit) + TrackHeight / 2;

                // Draw arc
                double _x = pt0X;
                double _x2 = pt0X;
                double _y = pt0Y;
                double _y2 = pt0Y;
                if (pt1X - pt0X < 5)
                {
                    cxt.DrawLine(penPit, new Point(pt0X, pt0Y), new Point(pt1X, pt1Y));
                }
                else
                {
                    while (_x2 < pt1X)
                    {
                        _x = Math.Min(_x + 4, pt1X);
                        _y = MusicMath.InterpolateShape(pt0X, pt1X, pt0Y, pt1Y, _x, _pts[i - 1].Shape);
                        cxt.DrawLine(penPit, new Point(_x, _y), new Point(_x2, _y2));
                        _x2 = _x;
                        _y2 = _y;
                    }
                }

                pt0Tick = pt1Tick;
                pt0X = pt1X;
                pt0Pit = pt1Pit;
                pt0Y = pt1Y;
                cxt.DrawEllipse(null, penPit, new Point(pt0X, pt0Y), 2.5, 2.5);
            }
        }
Exemplo n.º 33
0
        static UNote NoteFromUst(UNote note, List<string> lines, UstVersion version)
        {
            string pbs = "", pbw = "", pby = "", pbm = "";

            foreach (string line in lines)
            {
                if (line.StartsWith("Lyric="))
                {
                    note.Phonemes[0].Phoneme = note.Lyric = line.Trim().Replace("Lyric=", "");
                    if (note.Phonemes[0].Phoneme.StartsWith("?"))
                    {
                        note.Phonemes[0].Phoneme = note.Phonemes[0].Phoneme.Substring(1);
                        note.Phonemes[0].AutoRemapped = false;
                    }
                }
                if (line.StartsWith("Length=")) note.DurTick = int.Parse(line.Trim().Replace("Length=", ""));
                if (line.StartsWith("NoteNum=")) note.NoteNum = int.Parse(line.Trim().Replace("NoteNum=", ""));
                if (line.StartsWith("Velocity=")) note.Expressions["velocity"].Data = int.Parse(line.Trim().Replace("Velocity=", ""));
                if (line.StartsWith("Intensity=")) note.Expressions["volume"].Data = int.Parse(line.Trim().Replace("Intensity=", ""));
                if (line.StartsWith("PreUtterance="))
                {
                    if (line.Trim() == "PreUtterance=") note.Phonemes[0].AutoEnvelope = true;
                    else { note.Phonemes[0].AutoEnvelope = false; note.Phonemes[0].Preutter = double.Parse(line.Trim().Replace("PreUtterance=", "")); }
                }
                if (line.StartsWith("VoiceOverlap=")) note.Phonemes[0].Overlap = double.Parse(line.Trim().Replace("VoiceOverlap=", ""));
                if (line.StartsWith("Envelope="))
                {
                    var pts = line.Trim().Replace("Envelope=", "").Split(new[] { ',' });
                    if (pts.Count() > 5) note.Expressions["decay"].Data = 100 - (int)double.Parse(pts[5]);
                }
                if (line.StartsWith("VBR=")) VibratoFromUst(note.Vibrato, line.Trim().Replace("VBR=", ""));
                if (line.StartsWith("PBS=")) pbs = line.Trim().Replace("PBS=", "");
                if (line.StartsWith("PBW=")) pbw = line.Trim().Replace("PBW=", "");
                if (line.StartsWith("PBY=")) pby = line.Trim().Replace("PBY=", "");
                if (line.StartsWith("PBM=")) pbm = line.Trim().Replace("PBM=", "");
            }

            if (pbs != "")
            {
                var pts = note.PitchBend.Data as List<PitchPoint>;
                pts.Clear();
                // PBS
                if (pbs.Contains(';'))
                {
                    pts.Add(new PitchPoint(double.Parse(pbs.Split(new[] { ';' })[0]), double.Parse(pbs.Split(new[] { ';' })[1])));
                        note.PitchBend.SnapFirst = false;
                }
                else
                {
                    pts.Add(new PitchPoint(double.Parse(pbs), 0));
                    note.PitchBend.SnapFirst = true;
                }
                double x = pts.First().X;
                if (pbw != "")
                {
                    string[] w = pbw.Split(new[] { ',' });
                    string[] y = null;
                    if (w.Count() > 1) y = pby.Split(new[] { ',' });
                    for (int i = 0; i < w.Count() - 1; i++)
                    {
                        x += w[i] == "" ? 0 : float.Parse(w[i]);
                        pts.Add(new PitchPoint(x, y[i] == "" ? 0 : double.Parse(y[i])));
                    }
                    pts.Add(new PitchPoint(x + double.Parse(w[w.Count() - 1]), 0));
                }
                if (pbm != "")
                {
                    string[] m = pbw.Split(new[] { ',' });
                    for (int i = 0; i < m.Count() - 1; i++)
                    {
                        pts[i].Shape = m[i] == "r" ? PitchPointShape.o :
                                       m[i] == "s" ? PitchPointShape.l :
                                       m[i] == "j" ? PitchPointShape.i : PitchPointShape.io;
                    }
                }
            }
            return note;
        }
Exemplo n.º 34
0
 public ResizeNoteCommand(UVoicePart part, UNote note, int deltaDur) { this.Part = part; this.Notes = new UNote[] { note }; this.DeltaDur = deltaDur; }
Exemplo n.º 35
0
 public bool HitNoteResizeArea(UNote note, Point mousePos)
 {
     double x = midiVM.QuarterToCanvas((double)note.EndTick / Project.Resolution);
     return mousePos.X <= x && mousePos.X > x - UIConstants.ResizeMargin;
 }
Exemplo n.º 36
0
 public AddPitchPointCommand(UNote note, PitchPoint point, int index)
 {
     this.Note = note;
     this.Index = index;
     this.Point = point;
 }