示例#1
0
        public Beat FindBeatAtPos(float x, float y)
        {
            BeatBounds beat = null;

            for (int i = 0; i < Bars.Count; i++)
            {
                var b = Bars[i].FindBeatAtPos(x);
                if (b != null && (beat == null || beat.RealBounds.X < b.RealBounds.X))
                {
                    beat = b;
                }
            }
            return(beat == null ? null : beat.Beat);
        }
示例#2
0
        public static BoundsLookup FromJson(object json, Score score)
        {
            var lookup = new BoundsLookup();

            var staveGroups = json.Member <FastList <StaveGroupBounds> >("StaveGroups");

            foreach (var staveGroup in staveGroups)
            {
                var sg = new StaveGroupBounds();
                sg.VisualBounds = staveGroup.VisualBounds;
                sg.RealBounds   = staveGroup.RealBounds;
                lookup.AddStaveGroup(sg);

                foreach (var masterBar in staveGroup.Bars)
                {
                    var mb = new MasterBarBounds();
                    mb.Index             = masterBar.Index;
                    mb.IsFirstOfLine     = masterBar.IsFirstOfLine;
                    mb.LineAlignedBounds = masterBar.LineAlignedBounds;
                    mb.VisualBounds      = masterBar.VisualBounds;
                    mb.RealBounds        = masterBar.RealBounds;
                    sg.AddBar(mb);

                    foreach (var bar in masterBar.Bars)
                    {
                        var b = new BarBounds();
                        b.VisualBounds = bar.VisualBounds;
                        b.RealBounds   = bar.RealBounds;
                        mb.AddBar(b);

                        foreach (var beat in bar.Beats)
                        {
                            var bb = new BeatBounds();
                            bb.VisualBounds = beat.VisualBounds;
                            bb.RealBounds   = beat.RealBounds;
                            bb.Beat         = score
                                              .Tracks[beat.Member <int>("TrackIndex")]
                                              .Staves[beat.Member <int>("StaffIndex")]
                                              .Bars[beat.Member <int>("BarIndex")]
                                              .Voices[beat.Member <int>("VoiceIndex")]
                                              .Beats[beat.Member <int>("BeatIndex")];

                            b.AddBeat(bb);
                        }
                    }
                }
            }

            return(lookup);
        }
示例#3
0
        public static BoundsLookup FromJson(object json, Score score)
        {
            var lookup = new BoundsLookup();

            var staveGroups = json.Member("StaveGroups").As<FastList<StaveGroupBounds>>();
            foreach (var staveGroup in staveGroups)
            {
                var sg = new StaveGroupBounds();
                sg.VisualBounds = staveGroup.VisualBounds;
                sg.RealBounds = staveGroup.RealBounds;
                lookup.AddStaveGroup(sg);

                foreach (var masterBar in staveGroup.Bars)
                {
                    var mb = new MasterBarBounds();
                    mb.IsFirstOfLine = masterBar.IsFirstOfLine;
                    mb.VisualBounds = masterBar.VisualBounds;
                    mb.RealBounds = masterBar.RealBounds;
                    sg.AddBar(mb);

                    foreach (var bar in masterBar.Bars)
                    {
                        var b = new BarBounds();
                        b.VisualBounds = bar.VisualBounds;
                        b.RealBounds = bar.RealBounds;
                        mb.AddBar(b);

                        foreach (var beat in bar.Beats)
                        {
                            var bb = new BeatBounds();
                            bb.VisualBounds = beat.VisualBounds;
                            bb.RealBounds = beat.RealBounds;
                            bb.Beat = score
                                .Tracks[beat.Member("TrackIndex").As<int>()]
                                .Staves[beat.Member("StaffIndex").As<int>()]
                                .Bars[beat.Member("BarIndex").As<int>()]
                                .Voices[beat.Member("VoiceIndex").As<int>()]
                                .Beats[beat.Member("BeatIndex").As<int>()];

                            b.AddBeat(bb);
                        }
                    }
                }
            }

            return lookup;
        }
示例#4
0
        public BeatBounds FindBeatAtPos(float x)
        {
            BeatBounds beat = null;

            for (int i = 0; i < Beats.Count; i++)
            {
                if (beat == null || Beats[i].RealBounds.X < x)
                {
                    beat = Beats[i];
                }
                else if (Beats[i].RealBounds.X > x)
                {
                    break;
                }
            }
            return(beat);
        }
示例#5
0
 public void AddBeat(BeatBounds bounds)
 {
     _beatLookup[bounds.Beat.Id] = bounds;
 }
示例#6
0
 public void AddBeat(BeatBounds bounds)
 {
     bounds.BarBounds = this;
     Beats.Add(bounds);
     MasterBarBounds.AddBeat(bounds);
 }
示例#7
0
 public void AddBeat(BeatBounds bounds)
 {
     StaveGroupBounds.BoundsLookup.AddBeat(bounds);
 }
示例#8
0
        public virtual void BuildBoundingsLookup(MasterBarBounds masterBarBounds, float cx, float cy)
        {
            var barBounds = new BarBounds();
            barBounds.Bar = Bar;
            barBounds.VisualBounds = new Bounds
            {
                X = cx + X,
                Y = cy + Y + TopPadding,
                W = Width,
                H = Height - TopPadding - BottomPadding
            };
            barBounds.RealBounds = new Bounds
            {
                X = cx + X,
                Y = cy + Y,
                W = Width,
                H = Height
            };
            masterBarBounds.AddBar(barBounds);

            foreach (var voice in _voiceContainers)
            {
                var c = _voiceContainers[voice];
                if (!c.Voice.IsEmpty)
                {
                    for (int i = 0, j = c.BeatGlyphs.Count; i < j; i++)
                    {
                        var bc = c.BeatGlyphs[i];

                        var beatBoundings = new BeatBounds();
                        beatBoundings.Beat = bc.Beat;
                        beatBoundings.VisualBounds = new Bounds
                        {
                            X = cx + X + c.X + bc.X + bc.OnNotes.X,
                            Y = barBounds.VisualBounds.Y,
                            W = bc.OnNotes.Width,
                            H = barBounds.VisualBounds.H
                        };
                        beatBoundings.RealBounds = new Bounds
                        {
                            X = cx + X + c.X + bc.X,
                            Y = barBounds.RealBounds.Y,
                            W = bc.Width,
                            H = barBounds.RealBounds.H
                        };
                        barBounds.AddBeat(beatBoundings);
                    }
                }
            }
        }
示例#9
0
 public void AddBeat(BeatBounds bounds)
 {
     _beatLookup[GetBeatId(bounds.Beat)] = bounds;
 }
示例#10
0
 public void AddBeat(BeatBounds bounds)
 {
     bounds.BarBounds = this;
     Beats.Add(bounds);
     MasterBarBounds.AddBeat(bounds);
 }
示例#11
0
 public void AddBeat(BeatBounds bounds)
 {
     StaveGroupBounds.BoundsLookup.AddBeat(bounds);
 }
示例#12
0
 public void AddBeat(BeatBounds bounds)
 {
     _beatLookup[bounds.Beat.Id] = bounds;
 }