public static ChordModifier GetModifier(GuitarChord chord, ChordModifierType type)
        {
            ChordModifier ret = null;

            switch (type)
            {
            case ChordModifierType.ChordStrumHigh:
            case ChordModifierType.ChordStrumMed:
            case ChordModifierType.ChordStrumLow:
                if (Utility.GetStrumData1(chord.Difficulty).IsNotNull())
                {
                    ret = new GuitarChordStrum(chord, type);
                }
                break;

            case ChordModifierType.Hammeron:
                if (Utility.GetHammeronData1(chord.Difficulty).IsNotNull())
                {
                    ret = new GuitarHammeron(chord);
                }
                break;

            case ChordModifierType.Slide:
            case ChordModifierType.SlideReverse:
                if (Utility.GetSlideData1(chord.Difficulty).IsNotNull())
                {
                    ret = new GuitarSlide(chord, type == ChordModifierType.SlideReverse);
                }
                break;
            }
            return(ret);
        }
Ejemplo n.º 2
0
        public GuitarChord CloneToMemory(GuitarMessageList owner, GuitarDifficulty difficulty)
        {
            GuitarChord ret   = null;
            var         notes = Notes.Select(x => x.CloneToMemory(owner)).Where(x => x != null).ToList();

            if (notes.Any())
            {
                ret = GuitarChord.GetChord(owner, difficulty, notes, false);
                if (ret != null)
                {
                    if (HasSlide)
                    {
                        ret.AddSlide(HasSlideReversed, false);
                    }
                    if (HasStrum)
                    {
                        ret.AddStrum(StrumMode, false);
                    }
                    if (HasHammeron)
                    {
                        ret.AddHammeron(false);
                    }
                }
            }
            return(ret);
        }
 public GuitarSlide(GuitarChord chord, bool isReversed)
     : base(chord,
            isReversed ?  ChordModifierType.SlideReverse : ChordModifierType.Slide, GuitarMessageType.GuitarSlide)
 {
     Data1   = Utility.GetSlideData1(chord.Difficulty);
     Data2   = Utility.Data2Default;
     Channel = isReversed ? Utility.ChannelSlideReversed : Utility.ChannelSlide;
 }
Ejemplo n.º 4
0
 public GuitarHammeron(GuitarChord chord)
     : base(chord, ChordModifierType.Hammeron, GuitarMessageType.GuitarHammeron)
 {
     Data1   = Utility.GetHammeronData1(chord.Difficulty);
     Data2   = Utility.Data2Default;
     Channel = Utility.ChannelDefault;
     SetTicks(chord.TickPair);
 }
Ejemplo n.º 5
0
        public static GuitarChord GetChord(GuitarMessageList owner,
                                           GuitarDifficulty difficulty,
                                           TickPair ticks,
                                           GuitarChordConfig config)
        {
            GuitarChord ret = null;

            var lowE = Utility.GetStringLowE(difficulty);

            var notes = new List <GuitarNote>();

            for (int x = 0; x < config.Frets.Length; x++)
            {
                var fret    = config.Frets[x];
                var channel = config.Channels[x];

                if (!fret.IsNull() && fret >= 0 && fret <= 23)
                {
                    var note = GuitarNote.GetNote(owner,
                                                  difficulty, ticks, x, fret,
                                                  channel == Utility.ChannelTap,
                                                  channel == Utility.ChannelArpeggio,
                                                  channel == Utility.ChannelX);

                    if (note != null && note.NoteFretDown.IsNotNull() && note.NoteString.IsNotNull())
                    {
                        notes.Add(note);
                    }
                    else
                    {
                    }
                }
            }

            if (notes.Any())
            {
                ret             = new GuitarChord(owner, ticks, difficulty, notes);
                ret.chordConfig = config.Clone();

                if (ret != null)
                {
                    if (config.IsSlide || config.IsSlideReverse)
                    {
                        ret.AddSlide(config.IsSlideReverse, false);
                    }

                    if (config.IsHammeron)
                    {
                        ret.AddHammeron(false);
                    }

                    ret.AddStrum(config.StrumMode, false);
                }
            }

            return(ret);
        }
Ejemplo n.º 6
0
 public GuitarChord CloneAtTime(
     GuitarMessageList owner,
     TickPair ticks,
     int stringOffset = int.MinValue)
 {
     return(GuitarChord.CreateChord(owner, owner.Owner.CurrentDifficulty,
                                    owner.Owner.SnapLeftRightTicks(ticks, new SnapConfig(true, true, true)),
                                    new GuitarChordConfig(Notes.GetFretsAtStringOffset(stringOffset.GetIfNull(0)),
                                                          Notes.GetChannelsAtStringOffset(stringOffset.GetIfNull(0)),
                                                          HasSlide, HasSlideReversed, HasHammeron, StrumMode,
                                                          RootNoteConfig.GetIfNotNull(x => x.Clone()))));
 }
        public static GuitarChordStrum CreateStrum(GuitarChord chord, ChordStrum strum)
        {
            GuitarChordStrum ret = null;

            if (!chord.HasStrumMode(strum) && Utility.GetStrumData1(chord.Difficulty).IsNotNull())
            {
                ret       = new GuitarChordStrum(chord, strum.GetModifierType());
                ret.IsNew = true;
                ret.CreateEvents();
            }
            return(ret);
        }
        public static GuitarSlide CreateSlide(GuitarChord chord, bool reversed)
        {
            GuitarSlide ret = null;

            if (!chord.HasSlide && Utility.GetSlideData1(chord.Difficulty).IsNotNull())
            {
                ret       = new GuitarSlide(chord, reversed);
                ret.IsNew = true;
                ret.CreateEvents();
            }
            return(ret);
        }
        public AdjustResult AdjustChordTicks(GuitarChord chord, TickPair newTicks, AdjustOption option)
        {
            AdjustResult result;
            var          updatedTicks = GetAdjustChordTicks(newTicks, option, out result, chord);

            if (!result.HasFlag(AdjustResult.Error) && updatedTicks.IsNull == false)
            {
                chord.SetTicks(updatedTicks);
                chord.UpdateEvents();
            }
            return(result);
        }
Ejemplo n.º 10
0
        public static GuitarChord GetChord(GuitarMessageList owner,
                                           GuitarDifficulty difficulty,
                                           IEnumerable <GuitarNote> notes,
                                           bool findModifiers = true)
        {
            GuitarChord ret = null;

            try
            {
                if (notes != null && notes.Any())
                {
                    if (notes.Any(x => x.IsDeleted))
                    {
                        Debug.WriteLine("getting deleted note");
                    }

                    var tickPair = notes.GetTickPairSmallest();

                    if (!tickPair.IsValid)
                    {
                        Debug.WriteLine("short chord");
                        return(ret);
                    }

                    var unfit = notes.Where(x => x.TickPair != tickPair);
                    if (unfit.Any())
                    {
                        unfit.ForEach(x => x.SetTicks(tickPair));
                    }

                    ret = new GuitarChord(owner, tickPair, difficulty, notes.ToList());

                    if (findModifiers)
                    {
                        ret.Modifiers.AddRange(owner.Hammerons.Where(x => x.Chord == null).GetBetweenTick(ret.TickPair).ToList());
                        ret.Modifiers.AddRange(owner.Slides.Where(x => x.Chord == null).GetBetweenTick(ret.TickPair).ToList());
                        ret.Modifiers.AddRange(owner.ChordStrums.Where(x => x.Chord == null).GetBetweenTick(ret.TickPair).ToList());

                        ret.ChordNameEvents.SetNames(owner.ChordNames.GetAtTick(ret.AbsoluteTicks).ToList());

                        var mods = ret.Modifiers.Where(x => x.TickPair != ret.TickPair).ToList();
                        foreach (var mod in mods)
                        {
                            mod.SetTicks(ret.TickPair);
                        }
                        mods.ForEach(x => x.Chord = ret);
                    }
                }
            }
            catch (Exception ex) { Debug.WriteLine("GetChord: " + ex.Message); }
            return(ret);
        }
Ejemplo n.º 11
0
        public static GuitarHammeron CreateHammeron(GuitarChord chord)
        {
            GuitarHammeron ret = null;

            if (!chord.HasHammeron && Utility.GetHammeronData1(chord.Difficulty).IsNotNull())
            {
                ret       = new GuitarHammeron(chord);
                ret.IsNew = true;
                ret.SetTicks(chord.TickPair);
                ret.CreateEvents();
            }

            return(ret);
        }
Ejemplo n.º 12
0
        public static GuitarChord CreateChord(GuitarMessageList owner, GuitarDifficulty difficulty, TickPair ticks,
                                              GuitarChordConfig config)
        {
            GuitarChord ret = null;

            ret = GetChord(owner, difficulty, ticks, config);

            if (ret != null)
            {
                ret.IsNew = true;
                ret.CreateEvents();
            }
            return(ret);
        }
        public static ChordModifier CreateModifier(GuitarChord chord, ChordModifierType type)
        {
            ChordModifier ret = null;

            switch (type)
            {
            case ChordModifierType.ChordStrumLow:
            {
                ret = GuitarChordStrum.CreateStrum(chord, ChordStrum.Low);
            }
            break;

            case ChordModifierType.ChordStrumMed:
            {
                ret = GuitarChordStrum.CreateStrum(chord, ChordStrum.Mid);
            }
            break;

            case ChordModifierType.ChordStrumHigh:
            {
                ret = GuitarChordStrum.CreateStrum(chord, ChordStrum.High);
            }
            break;

            case ChordModifierType.Hammeron:
            {
                ret = GuitarHammeron.CreateHammeron(chord);
            }
            break;

            case ChordModifierType.Slide:
            {
                ret = GuitarSlide.CreateSlide(chord, false);
            }
            break;

            case ChordModifierType.SlideReverse:
            {
                ret = GuitarSlide.CreateSlide(chord, true);
            }
            break;
            }

            return(ret);
        }
        public GuitarChord Deserialize(GuitarMessageList owner, GuitarDifficulty diff, TickPair ticks)
        {
            int[]      frets;
            int[]      channels;
            ChordStrum chordStrum;
            bool       isSlide;
            bool       isSlideReverse;
            bool       isHammeron;
            GuitarChordRootNoteConfig rootConfig;

            GetProperties(out frets, out channels, out chordStrum, out isSlide, out isSlideReverse, out isHammeron, out rootConfig);

            var ret = GuitarChord.CreateChord(owner, diff, ticks,
                                              new GuitarChordConfig(frets, channels,
                                                                    isSlide,
                                                                    isSlideReverse,
                                                                    isHammeron,
                                                                    chordStrum,
                                                                    rootConfig));

            return(ret);
        }
Ejemplo n.º 15
0
        public void GetMessages(GuitarDifficulty difficulty, bool includeDifficultyAll = true)
        {
            if (difficulty.IsAll())
            {
                difficulty = difficulty ^ GuitarDifficulty.All;
            }

            var validData1List = Utility.GetKnownData1ForDifficulty(IsPro,
                                                                    includeDifficultyAll ? GuitarDifficulty.All | difficulty : difficulty).ToList();

            Messages = new GuitarMessageList(owner);
            var events = checkForInvalidNotes(Messages, midiTrack, validData1List);

            var ret        = Messages;
            var tempoTrack = GetTempoTrack();

            ret.AddRange(GetTempoMessages(ret, tempoTrack));
            ret.AddRange(GetTimeSigMessages(ret, tempoTrack));
            try
            {
                if (IsPro)
                {
                    events.GetEventPairs(Utility.AllArpeggioData1)
                    .Select(x => new GuitarArpeggio(x)).ToList().ForEach(x => x.AddToList());

                    events.GetEventPairs(Utility.SoloData1.MakeEnumerable()).Select(x => new GuitarSolo(x)).ToList().ForEach(x => x.AddToList());
                    events.GetEventPairs(Utility.PowerupData1.MakeEnumerable()).Select(x => new GuitarPowerup(x)).ToList().ForEach(x => x.AddToList());
                    events.GetEventPairs(Utility.MultiStringTremeloData1.MakeEnumerable()).Select(x => new GuitarMultiStringTremelo(x)).ToList().ForEach(x => x.AddToList());
                    events.GetEventPairs(Utility.SingleStringTremeloData1.MakeEnumerable()).Select(x => new GuitarSingleStringTremelo(x)).ToList().ForEach(x => x.AddToList());

                    GetBigRockEnding(ret, events);

                    events.GetEventPairs(Utility.AllSlideData1).Select(x => new GuitarSlide(x)).ToList().ForEach(x => x.AddToList());
                    events.GetEventPairs(Utility.AllHammeronData1).Select(x => new GuitarHammeron(x)).ToList().ForEach(x => x.AddToList());
                    events.GetEventPairs(Utility.AllStrumData1).Select(x => new GuitarChordStrum(x)).ToList().ForEach(x => x.AddToList());

                    events.GetEventPairs(Utility.ChordNameEvents).ToList().
                    Select(x => new GuitarChordName(x)).ToList().ForEach(x => x.AddToList());

                    var notes = events.GetEventPairs(Utility.GetStringsForDifficulty6(difficulty)).Select(x => new GuitarNote(x)).ToList();
                    notes.ForEach(x => x.AddToList());
                    if (notes.Any())
                    {
                        var closeNotes = notes.GroupBy(x => x.DownTick).ToList();
                        var chordNotes = closeNotes.Select(n => GuitarChord.GetChord(ret, difficulty, n, true)).ToList().Where(x => x != null).ToList();
                        chordNotes.ForEach(x => x.AddToList());
                    }

                    var textEvents = midiTrack.Meta.Where(x => x.IsTextEvent()).Select(x => new GuitarTextEvent(ret, x)).ToList();
                    textEvents.ForEach(x => x.AddToList());

                    LoadTrainers(ret, ret.TextEvents).ToList().ForEach(x => x.AddToList());

                    events.GetEventPairs(Utility.HandPositionData1.MakeEnumerable()).ToList().Select(x => new GuitarHandPosition(x)).ToList().ForEach(x => x.AddToList());
                }
                else
                {
                    events.GetEventPairs(new[] { Utility.ExpertSoloData1_G5, Utility.SoloData1 }).ToList().Select(x => new GuitarSolo(x)).ForEach(x => x.AddToList());
                    events.GetEventPairs(Utility.PowerupData1.MakeEnumerable()).Select(x => new GuitarPowerup(x)).ForEach(x => x.AddToList());

                    var notes = events.GetEventPairs(Utility.GetStringsForDifficulty5(difficulty)).Select(x => new GuitarNote(x)).ToList();
                    notes.ForEach(x => x.AddToList());

                    if (notes.Any())
                    {
                        var chans  = notes.GroupBy(x => x.Channel);
                        var chords = new List <GuitarChord>();
                        foreach (var channelNotes in chans.Where(x => x.Key == 0))
                        {
                            var closeNotes = channelNotes.GroupByCloseTick().ToList();

                            chords.AddRange(closeNotes.Select(x => GuitarChord.GetChord(ret, difficulty, x, false)).Where(x => x != null).ToList());
                        }
                        foreach (var channelNotes in chans.Where(x => x.Key != 0))
                        {
                            var closeNotes = channelNotes.GroupByCloseTick().ToList();
                            var chords1    = closeNotes.Select(x => GuitarChord.GetChord(ret, difficulty, x, false)).Where(x => x != null).ToList();
                            foreach (var chord in chords1)
                            {
                                if (!chords.AnyBetweenTick(chord.TickPair))
                                {
                                    chords.Add(chord);
                                }
                            }
                        }
                        chords.OrderBy(x => x.DownTick).ToList().ForEach(x => x.AddToList());
                    }

                    var textEvents = midiTrack.Meta.Where(x => x.IsTextEvent()).ToList().Select(x => new GuitarTextEvent(ret, x)).ToList();
                    textEvents.ForEach(x => x.AddToList());

                    GetBigRockEnding(ret, events);
                }
            }
            catch { }
        }
Ejemplo n.º 16
0
 public GuitarChordNoteList(GuitarChord owner)
 {
     this.owner = owner;
     notes      = new List <GuitarNote>();
 }
 public IEnumerable <Pitch.PitchTracker.PitchRecord> GetPitchRecords(GuitarChord chord)
 {
     return(GetPitchRecords(getChordSamples(chord)));
 }
 public GuitarChordStrum(GuitarChord chord, ChordModifierType type)
     : base(chord, type, GuitarMessageType.GuitarChordStrum)
 {
 }
        public float[] getChordSamples(GuitarChord chord)
        {
            var chordSamples = ReadPixelSamples(chord.StartTime, chord.EndTime);

            return(chordSamples.SelectMany(x => x.Samples).ToArray());
        }
 public ChordModifier(GuitarChord chord, ChordModifierType type, GuitarMessageType gt) :
     base(chord.Owner, chord.TickPair, gt)
 {
     ModifierType = type;
     Chord        = chord;
 }
 public ChordModifier(MidiEventPair pair, ChordModifierType type, GuitarMessageType gt) :
     base(pair, gt)
 {
     Chord        = null;
     ModifierType = type;
 }
 public GuitarChordNameList(GuitarChord owner)
 {
     this.owner = owner;
     names      = new List <GuitarChordName>();
 }
        public TickPair GetAdjustChordTicks(TickPair newTicks, AdjustOption option, out AdjustResult result, GuitarChord chord = null)
        {
            result = AdjustResult.NoResult;

            var existingTicks = new TickPair(newTicks.Down, newTicks.Up);

            var queryTicks = new TickPair(newTicks.Down, newTicks.Up);

            if (option.HasFlag(AdjustOption.AllowGrow) || option.HasFlag(AdjustOption.AllowShift))
            {
                queryTicks = new TickPair(newTicks.Down, newTicks.Up);
            }

            var between = Chords.GetBetweenTick(queryTicks);

            if (chord != null)
            {
                between = between.Where(x => x != chord);
            }

            if (!between.Any())
            {
                result = AdjustResult.Success;
                return(newTicks);
            }
            else
            {
                var closeToBegin = between.Where(x => x.TickPair.IsCloseUpDown(newTicks));
                var closeToEnd   = between.Where(x => x.TickPair.IsCloseDownUp(newTicks));
                var closeChords  = closeToBegin.Concat(closeToEnd).Distinct();

                if (!closeChords.Any())
                {
                    result = AdjustResult.Success;
                    return(newTicks);
                }
                else
                {
                    TickPair updatedTicks = new TickPair(newTicks.Down, newTicks.Up);

                    var min = closeToBegin.GetMaxTick(updatedTicks.Down);
                    var max = closeToEnd.GetMinTick(updatedTicks.Up);

                    var updatedLen = updatedTicks.Up - updatedTicks.Down;

                    var space = max - min;

                    if (space <= 0)
                    {
                        result = AdjustResult.Error;
                        return(TickPair.NullValue);
                    }

                    if (updatedLen <= 0)
                    {
                        result = AdjustResult.Error;
                        return(TickPair.NullValue);
                    }

                    if (updatedLen == space)
                    {
                        result = AdjustResult.Success;
                        return(updatedTicks);
                    }
                    if ((updatedLen < space && option.HasFlag(AdjustOption.AllowGrow)) ||
                        (updatedLen > space && option.HasFlag(AdjustOption.AllowShrink)))
                    {
                        if (updatedTicks.Down < min)
                        {
                            result |= AdjustResult.AdjustedDownTickRight;
                        }
                        else if (updatedTicks.Down > min)
                        {
                            result |= AdjustResult.AdjustedDownTickLeft;
                        }
                        updatedTicks.Down = min;

                        if (updatedTicks.Up < max)
                        {
                            result |= AdjustResult.AdjustedUpTickRight;
                        }
                        else if (updatedTicks.Up > max)
                        {
                            result |= AdjustResult.AdjustedUpTickLeft;
                        }
                        updatedTicks.Up = max;

                        updatedLen = updatedTicks.Up - updatedTicks.Down;

                        if (updatedLen <= 0)
                        {
                            result = AdjustResult.Error;
                            return(TickPair.NullValue);
                        }
                        else
                        {
                            if (updatedLen < Utility.NoteCloseWidth)
                            {
                                result |= AdjustResult.ShortResult;
                            }
                            result |= AdjustResult.Success;
                            return(updatedTicks);
                        }
                    }
                    else if (updatedLen < space && option.HasFlag(AdjustOption.AllowShift))
                    {
                        if (updatedTicks.Down < min)
                        {
                            updatedTicks.Down = min;
                            updatedTicks.Up   = min + updatedLen;
                            result           |= AdjustResult.AdjustedDownTickRight | AdjustResult.AdjustedUpTickRight;
                        }
                        else
                        {
                            updatedTicks.Up   = max;
                            updatedTicks.Down = max - updatedLen;
                            result           |= AdjustResult.AdjustedDownTickLeft | AdjustResult.AdjustedUpTickLeft;
                        }

                        updatedLen = updatedTicks.Up - updatedTicks.Down;

                        if (updatedLen <= 0)
                        {
                            result = AdjustResult.Error;
                            return(TickPair.NullValue);
                        }
                        else
                        {
                            if (updatedLen < Utility.NoteCloseWidth)
                            {
                                result |= AdjustResult.ShortResult;
                            }
                            result |= AdjustResult.Success;

                            return(updatedTicks);
                        }
                    }
                    else
                    {
                        result = AdjustResult.Error;
                        return(TickPair.NullValue);
                    }
                }
            }
        }