Example #1
0
        public async Task DrawChord(double x, IChordDefinition chord)
        {
            x += this.Location.X;
            var y = this.Owner.GetHeight(VoicePart.Treble, x);

            await this.PrimitiveRenderer.DrawChord(chord, x, y);
        }
Example #2
0
        public Task <Rect> DrawChord(IChordDefinition chord, double x, double y)
        {
            var name      = chord.DisplayName;
            var fingering = "null";

            if (chord.Fingering != null)
            {
                var builder = new StringBuilder();

                builder.Append('[');

                foreach (var note in chord.Fingering.Notes)
                {
                    switch (note.Fret)
                    {
                    case Chord.FingeringSkipString:
                        builder.Append("'x'");
                        break;

                    case 0:
                        builder.Append("0");
                        break;

                    default:

                        builder.Append('{');

                        builder.Append("fret:")
                        .Append(note.Fret)
                        .Append(',');

                        if (note.FingerIndex != null)
                        {
                            builder.Append("finger:")
                            .Append((int)note.FingerIndex.Value)
                            .Append(',');
                        }

                        if (note.IsImportant)
                        {
                            builder.Append("important: true,");
                        }

                        builder.Append('}');
                        break;
                    }

                    builder.Append(',');
                }


                builder.Append(']');

                fingering = builder.ToString();
            }

            return(this.InvokeRenderMethodReturnBoundingBox("drawChord", x, y, name, new JsonString(fingering)));
        }
Example #3
0
        public static int GetMinStringIndex(this IChordDefinition chord)
        {
            for (var i = chord.Fingering.Notes.Count - 1; i >= 0; --i)
            {
                if (chord.Fingering.Notes[i].Fret != Chord.FingeringSkipString)
                {
                    return(chord.Fingering.Notes.Count - i - 1);
                }
            }

            return(-1);
        }
Example #4
0
        public IChord GetChord(INote note, IChordDefinition definition)
        {
            var noteIntervals = NoteIntervalService.GetNoteIntervals(note);
            var notes         = definition.SemiTones.Select(st =>
            {
                var safe     = SafeSemiTone(st);
                var interval = noteIntervals.First(ni => ni.Interval.DistanceInSemiTones == safe);
                return(interval.Note.DeepClone());
            }).ToList();

            return(new Chord
            {
                Key = note.DeepClone(),
                ChordDefinition = definition.DeepClone(),
                Notes = notes
            });
        }
Example #5
0
        public IChord GetChord(string name, IChordDefinition definition)
        {
            var note = NoteService.GetNoteByName(name);

            return(GetChord(note, definition));
        }
Example #6
0
 public bool Equals(IChordDefinition other) => Equals(other.Type);