AddWhammyBarPoint() public method

public AddWhammyBarPoint ( AlphaTab.Model.BendPoint point ) : void
point AlphaTab.Model.BendPoint
return void
Ejemplo n.º 1
0
        public Beat Clone()
        {
            var beat = new Beat();

            for (int i = 0, j = WhammyBarPoints.Count; i < j; i++)
            {
                beat.AddWhammyBarPoint(WhammyBarPoints[i].Clone());
            }
            for (int i = 0, j = Notes.Count; i < j; i++)
            {
                beat.AddNote(Notes[i].Clone());
            }
            CopyTo(this, beat);
            for (int i = 0, j = Automations.Count; i < j; i++)
            {
                beat.Automations.Add(Automations[i].Clone());
            }
            return(beat);
        }
Ejemplo n.º 2
0
 public void ReadTremoloBarEffect(Beat beat)
 {
     Data.ReadByte(); // type
     ReadInt32(); // value
     var pointCount = ReadInt32();
     if (pointCount > 0)
     {
         for (int i = 0; i < pointCount; i++)
         {
             var point = new BendPoint();
             point.Offset = ReadInt32(); // 0...60
             point.Value = ReadInt32() / BendStep; // 0..12 (amount of quarters)
             ReadBool(); // vibrato
             beat.AddWhammyBarPoint(point);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts the given JavaScript object into a score object.
        /// </summary>
        /// <param name="jsObject">The javascript object created via <see cref="ScoreToJsObject"/></param>
        /// <param name="settings">The settings to use during conversion.</param>
        /// <returns>The converted score object.</returns>
        public static Score JsObjectToScore(object jsObject, Settings settings = null)
        {
            Score score  = jsObject.As <Score>();
            var   score2 = new Score();

            Score.CopyTo(score, score2);
            RenderStylesheet.CopyTo(score.Stylesheet, score2.Stylesheet);

            #region MasterBars

            for (var i = 0; i < score.MasterBars.Count; i++)
            {
                var masterBar  = score.MasterBars[i];
                var masterBar2 = new MasterBar();
                MasterBar.CopyTo(masterBar, masterBar2);
                if (masterBar.TempoAutomation != null)
                {
                    masterBar2.TempoAutomation = new Automation();
                    Automation.CopyTo(masterBar.TempoAutomation, masterBar2.TempoAutomation);
                }
                if (masterBar.Section != null)
                {
                    masterBar2.Section = new Section();
                    Section.CopyTo(masterBar.Section, masterBar2.Section);
                }

                foreach (var offset in masterBar.Fermata)
                {
                    var fermata  = masterBar.Fermata[offset];
                    var fermata2 = new Fermata();
                    Fermata.CopyTo(fermata, fermata2);
                    masterBar2.AddFermata(offset, fermata2);
                }


                score2.AddMasterBar(masterBar2);
            }

            #endregion

            #region Tracks

            for (int t = 0; t < score.Tracks.Count; t++)
            {
                var track  = score.Tracks[t];
                var track2 = new Track(track.Staves.Count);
                Track.CopyTo(track, track2);
                score2.AddTrack(track2);

                PlaybackInformation.CopyTo(track.PlaybackInfo, track2.PlaybackInfo);


                #region Staves

                for (var s = 0; s < track.Staves.Count; s++)
                {
                    var staff  = track.Staves[s];
                    var staff2 = track2.Staves[s];
                    Staff.CopyTo(staff, staff2);


                    foreach (var key in staff.Chords)
                    {
                        var chord  = staff.Chords[key];
                        var chord2 = new Chord();
                        Chord.CopyTo(chord, chord2);
                        staff2.Chords[key] = chord2;
                    }
                    #region Bars

                    for (int b = 0; b < staff.Bars.Count; b++)
                    {
                        var bar  = staff.Bars[b];
                        var bar2 = new Bar();
                        Bar.CopyTo(bar, bar2);
                        staff2.AddBar(bar2);

                        #region Voices

                        for (int v = 0; v < bar.Voices.Count; v++)
                        {
                            var voice  = bar.Voices[v];
                            var voice2 = new Voice();
                            Voice.CopyTo(voice, voice2);
                            bar2.AddVoice(voice2);

                            #region Beats

                            for (int bb = 0; bb < voice.Beats.Count; bb++)
                            {
                                var beat  = voice.Beats[bb];
                                var beat2 = new Beat();
                                Beat.CopyTo(beat, beat2);
                                voice2.AddBeat(beat2);

                                for (int a = 0; a < beat.Automations.Count; a++)
                                {
                                    var automation = new Automation();
                                    Automation.CopyTo(beat.Automations[a], automation);
                                    beat2.Automations.Add(automation);
                                }

                                for (int i = 0; i < beat.WhammyBarPoints.Count; i++)
                                {
                                    var point = new BendPoint();
                                    BendPoint.CopyTo(beat.WhammyBarPoints[i], point);
                                    beat2.AddWhammyBarPoint(point);
                                }

                                #region Notes

                                for (int n = 0; n < beat.Notes.Count; n++)
                                {
                                    var note  = beat.Notes[n];
                                    var note2 = new Note();
                                    Note.CopyTo(note, note2);
                                    beat2.AddNote(note2);

                                    for (int i = 0; i < note.BendPoints.Count; i++)
                                    {
                                        var point = new BendPoint();
                                        BendPoint.CopyTo(note.BendPoints[i], point);
                                        note2.AddBendPoint(point);
                                    }
                                }

                                #endregion
                            }

                            #endregion
                        }

                        #endregion
                    }

                    #endregion
                }
                #endregion
            }

            #endregion

            score2.Finish(settings);
            return(score2);
        }
Ejemplo n.º 4
0
 public Beat Clone()
 {
     var beat = new Beat();
     for (int i = 0, j = WhammyBarPoints.Count; i < j; i++)
     {
         beat.AddWhammyBarPoint(WhammyBarPoints[i].Clone());
     }
     for (int i = 0, j = Notes.Count; i < j; i++)
     {
         beat.AddNote(Notes[i].Clone());
     }
     CopyTo(this, beat);
     for (int i = 0, j = Automations.Count; i < j; i++)
     {
         beat.Automations.Add(Automations[i].Clone());
     }
     return beat;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Tries to apply a beat effect to the given beat.
        /// </summary>
        /// <returns>true if a effect could be applied, otherwise false</returns>
        private bool ApplyBeatEffect(Beat beat)
        {
            var syData = _syData.ToString().ToLower();
            if (syData == "f")
            {
                beat.FadeIn = true;
                NewSy();
                return true;
            }
            if (syData == "v")
            {
                beat.Vibrato = VibratoType.Slight;
                NewSy();
                return true;
            }
            if (syData == "s")
            {
                beat.Slap = true;
                NewSy();
                return true;
            }
            if (syData == "p")
            {
                beat.Pop = true;
                NewSy();
                return true;
            }
            if (syData == "dd")
            {
                beat.Dots = 2;
                NewSy();
                return true;
            }
            if (syData == "d")
            {
                beat.Dots = 1;
                NewSy();
                return true;
            }
            if (syData == "su")
            {
                beat.PickStroke = PickStrokeType.Up;
                NewSy();
                return true;
            }
            if (syData == "sd")
            {
                beat.PickStroke = PickStrokeType.Down;
                NewSy();
                return true;
            }
            if (syData == "tu")
            {
                NewSy();
                if (_sy != AlphaTexSymbols.Number)
                {
                    Error("tuplet", AlphaTexSymbols.Number);
                    return false;
                }
                var tuplet = (int)_syData;
                switch (tuplet)
                {
                    case 3:
                        beat.TupletNumerator = 3;
                        beat.TupletDenominator = 2;
                        break;
                    case 5:
                        beat.TupletNumerator = 5;
                        beat.TupletDenominator = 4;
                        break;
                    case 6:
                        beat.TupletNumerator = 6;
                        beat.TupletDenominator = 4;
                        break;
                    case 7:
                        beat.TupletNumerator = 7;
                        beat.TupletDenominator = 4;
                        break;
                    case 9:
                        beat.TupletNumerator = 9;
                        beat.TupletDenominator = 8;
                        break;
                    case 10:
                        beat.TupletNumerator = 10;
                        beat.TupletDenominator = 8;
                        break;
                    case 11:
                        beat.TupletNumerator = 11;
                        beat.TupletDenominator = 8;
                        break;
                    case 12:
                        beat.TupletNumerator = 12;
                        beat.TupletNumerator = 8;
                        beat.TupletDenominator = 8;
                        break;
                }
                NewSy();
                return true;
            }
            if (syData == "tb" || syData == "tbe")
            {
                var exact = syData == "tbe";
                // read points
                NewSy();
                if (_sy != AlphaTexSymbols.LParensis)
                {
                    Error("tremolobar-effect", AlphaTexSymbols.LParensis);
                    return false;
                }
                _allowNegatives = true;

                NewSy();
                while (_sy != AlphaTexSymbols.RParensis && _sy != AlphaTexSymbols.Eof)
                {
                    int offset;
                    int value;

                    if (exact)
                    {
                        if (_sy != AlphaTexSymbols.Number)
                        {
                            Error("tremolobar-effect", AlphaTexSymbols.Number);
                            return false;
                        }
                        offset = (int)_syData;

                        NewSy();
                        if (_sy != AlphaTexSymbols.Number)
                        {
                            Error("tremolobar-effect", AlphaTexSymbols.Number);
                            return false;
                        }
                        value = (int)_syData;
                    }
                    else
                    {
                        if (_sy != AlphaTexSymbols.Number)
                        {
                            Error("tremolobar-effect", AlphaTexSymbols.Number);
                            return false;
                        }
                        offset = 0;
                        value = (int)_syData;
                    }

                    beat.AddWhammyBarPoint(new BendPoint(offset, value));

                    NewSy();
                }

                while (beat.WhammyBarPoints.Count > 60)
                {
                    beat.RemoveWhammyBarPoint(beat.WhammyBarPoints.Count - 1);
                }

                // set positions
                if (!exact)
                {
                    var count = beat.WhammyBarPoints.Count;
                    var step = (60 / count);
                    var i = 0;
                    while (i < count)
                    {
                        beat.WhammyBarPoints[i].Offset = Math.Min(60, (i * step));
                        i++;
                    }
                }
                else
                {
                    beat.WhammyBarPoints.Sort((a, b) => a.Offset - b.Offset);
                }
                _allowNegatives = false;

                if (_sy != AlphaTexSymbols.RParensis)
                {
                    Error("tremolobar-effect", AlphaTexSymbols.RParensis);
                    return false;
                }
                NewSy();
                return true;
            }

            if (syData == "gr")
            {
                NewSy();
                if (_syData.ToString().ToLower() == "ob")
                {
                    beat.GraceType = GraceType.OnBeat;
                    NewSy();
                }
                else
                {
                    beat.GraceType = GraceType.BeforeBeat;
                }
                return true;
            }

            if (syData == "tp")
            {
                NewSy();
                var duration = Duration.Eighth;
                if (_sy == AlphaTexSymbols.Number)
                {
                    switch ((int)_syData)
                    {
                        case 8:
                            duration = Duration.Eighth;
                            break;
                        case 16:
                            duration = Duration.Sixteenth;
                            break;
                        case 32:
                            duration = Duration.ThirtySecond;
                            break;
                        default:
                            duration = Duration.Eighth;
                            break;
                    }
                    NewSy();
                }
                beat.TremoloSpeed = duration;

                return true;
            }

            return false;
        }