예제 #1
0
        public virtual global::alphatab.model.AccidentalType applyAccidental(global::alphatab.model.Note note, int noteLine)
        {
            unchecked
            {
                int noteValue = (note.fret + note.beat.voice.bar.track.tuning[((note.beat.voice.bar.track.tuning.length - ((note.@string - 1))) - 1)]);
                global::alphatab.model.MasterBar __temp_stmt608 = default(global::alphatab.model.MasterBar);
                {
                    global::alphatab.model.Bar _this = note.beat.voice.bar;
                    __temp_stmt608 = ((global::alphatab.model.MasterBar)(_this.track.score.masterBars[_this.index]));
                }

                int ks     = __temp_stmt608.keySignature;
                int ksi    = (ks + 7);
                int index  = (noteValue % 12);
                int octave = (noteValue / 12);
                global::alphatab.model.AccidentalType accidentalToSet = ((global::haxe.root.Array <global::alphatab.model.AccidentalType>)(global::haxe.root.Array <object> .__hx_cast <global::alphatab.model.AccidentalType>(((global::haxe.root.Array)(global::alphatab.rendering.utils.AccidentalHelper.AccidentalNotes[ksi])))))[index];
                bool updateAccidental = true;
                if (this._registeredAccidentals.exists(noteLine))
                {
                    global::haxe.lang.Null <global::alphatab.model.AccidentalType> registeredAccidental = this._registeredAccidentals.@get(noteLine);
                    if (global::haxe.lang.Runtime.eq((registeredAccidental).toDynamic(), accidentalToSet))
                    {
                        accidentalToSet  = global::alphatab.model.AccidentalType.None;
                        updateAccidental = false;
                    }
                    else
                    {
                        if ((accidentalToSet == global::alphatab.model.AccidentalType.None))
                        {
                            accidentalToSet = global::alphatab.model.AccidentalType.Natural;
                        }
                    }
                }

                if (updateAccidental)
                {
                    if (((accidentalToSet == global::alphatab.model.AccidentalType.None) || (accidentalToSet == global::alphatab.model.AccidentalType.Natural)))
                    {
                        this._registeredAccidentals.@remove(noteLine);
                    }
                    else
                    {
                        this._registeredAccidentals.@set(noteLine, accidentalToSet);
                    }
                }

                return(accidentalToSet);
            }
        }
        public virtual void createAccidentalGlyph(global::alphatab.model.Note n, global::alphatab.rendering.glyphs.AccidentalGroupGlyph accidentals)
        {
            unchecked
            {
                global::alphatab.rendering.ScoreBarRenderer sr = default(global::alphatab.rendering.ScoreBarRenderer);
                sr = ((global::alphatab.rendering.ScoreBarRenderer)(this.renderer));
                int noteLine = sr.getNoteLine(n);
                global::alphatab.model.AccidentalType accidental = sr.accidentalHelper.applyAccidental(n, noteLine);
                bool isGrace = (this.container.beat.graceType != global::alphatab.model.GraceType.None);
                switch (global::haxe.root.Type.enumIndex(accidental))
                {
                case 2:
                {
                    accidentals.addGlyph(new global::alphatab.rendering.glyphs.SharpGlyph(new global::haxe.lang.Null <int>(0, true), new global::haxe.lang.Null <int>(sr.getScoreY(noteLine, default(global::haxe.lang.Null <int>)), true), new global::haxe.lang.Null <bool>(isGrace, true)));
                    break;
                }


                case 3:
                {
                    accidentals.addGlyph(new global::alphatab.rendering.glyphs.FlatGlyph(new global::haxe.lang.Null <int>(0, true), new global::haxe.lang.Null <int>(sr.getScoreY(noteLine, default(global::haxe.lang.Null <int>)), true), new global::haxe.lang.Null <bool>(isGrace, true)));
                    break;
                }


                case 1:
                {
                    accidentals.addGlyph(new global::alphatab.rendering.glyphs.NaturalizeGlyph(new global::haxe.lang.Null <int>(0, true), new global::haxe.lang.Null <int>(sr.getScoreY((noteLine + 1), default(global::haxe.lang.Null <int>)), true), new global::haxe.lang.Null <bool>(isGrace, true)));
                    break;
                }


                default:
                {
                    {
                    }

                    break;
                }
                }
            }
        }