public string NameFromStrings(TuningStrings tuning, bool isBass, bool inBem = true)
        {
            List <Int32>  Notes     = new List <Int32>();
            List <String> NoteNames = new List <String>();

            String[] notesNames   = new String[] { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
            String[] notesNamesHi = new String[] { "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B" };
            for (Byte s = 0; s < 6; s++)
            {
                Notes.Add(Sng2014FileWriter.GetMidiNote(tuning.ToShortArray(), s, 0, isBass, 0));
            }
            foreach (var mNote in Notes)
            {
                if (inBem)
                {
                    NoteNames.Add(notesNamesHi[mNote % 12]);       //oct = mNote / 12 - 1
                }
                else
                {
                    NoteNames.Add(notesNames[mNote % 12]);  //oct = mNote / 12 - 1
                }
            }
            return(String.Format("{0}{1}{2}{3}{4}{5}", NoteNames[0], NoteNames[1], NoteNames[2],
                                 NoteNames[3], NoteNames[4], NoteNames[5]));
        }
示例#2
0
        public Showlights Genegate(string xmlFile)
        {
            var midiNotes  = new List <Showlight>();
            var chordNotes = new List <Showlight>();
            var ShowL      = new Showlights();
            var song       = Song2014.LoadFromFile(xmlFile);

            // If vocals
            if (song.Phrases == null || song.Tuning == null)
            {
                return(null);
            }
            //Generate ShowlightList
            var tuning = song.Tuning.ToShortArray();

            if (song.Levels != null)
            {
                foreach (var lvl in song.Levels)
                {
                    for (int i = 0; i + 1 <= lvl.Notes.Count(); i++)
                    {
                        var mNote = Sng2014FileWriter.GetMidiNote(tuning,
                                                                  (Byte)lvl.Notes[i].String,
                                                                  (Byte)lvl.Notes[i].Fret,
                                                                  song.Arrangement == "Bass",
                                                                  song.Capo);

                        midiNotes.Add(new Showlight()
                        {
                            Time = lvl.Notes[i].Time, Note = mNote
                        });
                    }
                    for (int i = 0; i + 1 <= lvl.Chords.Count(); i++)
                    {
                        if (lvl.Chords[i].HighDensity == 1)
                        {
                            continue; //speedhack
                        }
                        int mNote = Sng2014FileWriter.getChordNote(tuning,
                                                                   lvl.Chords[i], song.ChordTemplates,
                                                                   song.Arrangement == "Bass",
                                                                   song.Capo);

                        chordNotes.Add(new Showlight()
                        {
                            Time = lvl.Chords[i].Time, Note = mNote
                        });
                    }
                }
            }

            ShowL.PopShList(midiNotes);
            ShowL.PopShList(chordNotes);
            ShowL.Count = ShowL.ShowlightList.Count;

            return(ShowL);
        }
        static string NoteName(TuningStrings tuning, byte s, bool flats = false)
        {
            String[] notesNamesHi = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
            String[] notesNamesLo = { "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B" };

            var id = Sng2014FileWriter.GetMidiNote(tuning.ToArray(), s, 0, false, 0) % 12;

            return(flats ? notesNamesLo[id] : notesNamesHi[id]);
        }
示例#4
0
        static int[] GetTuning(Song2014 arrangement)
        {
            // Guitar Pro expects the tuning as Midi note values
            // In Rocksmith, the tuning is given as the difference in half steps
            // from standard tuning for each string, so we need to convert that.
            bool isBass = arrangement.Title.ToLower() == "bass";

            int[] tuning = new int[6];
            for (byte s = 0; s < tuning.Length; ++s)
            {
                tuning[s] = Sng2014FileWriter.GetMidiNote(arrangement.Tuning.ToArray(), s, 0, isBass, 0);
            }
            return(tuning);
        }
示例#5
0
        /// <summary>
        /// Showlights Generator Rev3
        /// using arrangement and level with most notes and chords
        /// </summary>
        /// <param name="xmlFile">Xml file.</param>
        private void Generate(string xmlFile, int maxLevelNdx)
        {
            var midiNotes  = new List <Showlight>();
            var chordNotes = new List <Showlight>();
            var song       = Song2014.LoadFromFile(xmlFile);

            // error checking
            if (song.Phrases == null || song.Levels == null || song.Tuning == null)
            {
                throw new Exception("Arrangement: " + xmlFile + Environment.NewLine +
                                    "Contains no phrases, levels and/or tuning.");
            }

            // tuning used to get proper midi notes
            var tuning = song.Tuning.ToArray();

            foreach (var note in song.Levels[maxLevelNdx].Notes)
            {
                // make showlights changes occure on the beat/measure
                var measOffset = song.Ebeats.Where(eb => eb.Measure != -1 && eb.Time <= note.Time).Last();
                // forcing midi notes for guitar gives more consistent results even with bass arrangements
                var mNote = Sng2014FileWriter.GetMidiNote(tuning, (Byte)note.String, (Byte)note.Fret, false, song.Capo);
                // varying midi notes gives more color changes
                // var mNote = Sng2014FileWriter.GetMidiNote(tuning, (Byte)note.String, (Byte)note.Fret, song.Arrangement == "Bass", song.Capo);
                midiNotes.Add(new Showlight {
                    Time = measOffset.Time, Note = mNote
                });
            }

            foreach (var chord in song.Levels[maxLevelNdx].Chords)
            {
                if (chord.HighDensity == 1)
                {
                    continue; //speedhack
                }
                // make showlights occure on the beat/measure
                var measOffset = song.Ebeats.Where(eb => eb.Measure != -1 && eb.Time <= chord.Time).Last();
                // forcing midi notes for guitar gives more consistent results even with bass arrangements
                var mNote = Sng2014FileWriter.getChordNote(tuning, chord, song.ChordTemplates, false, song.Capo);
                // varying midi notes gives more color changes
                //var mNote = Sng2014FileWriter.getChordNote(tuning, chord, song.ChordTemplates, song.Arrangement == "Bass", song.Capo);
                chordNotes.Add(new Showlight {
                    Time = measOffset.Time, Note = mNote
                });
            }

            ShowlightList = new List <Showlight>();
            AddShowlights(midiNotes);
            AddShowlights(chordNotes);
        }
示例#6
0
        /// <summary>
        /// Showlights Generator Rev2
        /// max difficulty with most notes and chords
        /// </summary>
        /// <param name="xmlFile">Xml file.</param>
        public Showlights Generate(string xmlFile)
        {
            var midiNotes  = new List <Showlight>();
            var chordNotes = new List <Showlight>();
            var song       = Song2014.LoadFromFile(xmlFile);

            // If vocals
            if (song.Phrases == null || song.Tuning == null)
            {
                return(null);
            }
            //Generate ShowlightList
            var tuning = song.Tuning.ToArray();

            if (song.Levels != null)
            {
                var mf     = new ManifestFunctions(GameVersion.RS2014);
                int maxDif = mf.GetMaxDifficulty(song);

                for (int i = 0; i < song.Levels[maxDif].Notes.Length; i++)
                {
                    var mNote = Sng2014FileWriter.GetMidiNote(tuning, (Byte)song.Levels[maxDif].Notes[i].String, (Byte)song.Levels[maxDif].Notes[i].Fret, song.Arrangement == "Bass", song.Capo);
                    midiNotes.Add(new Showlight {
                        Time = song.Levels[maxDif].Notes[i].Time, Note = mNote
                    });
                }

                for (int i = 0; i < song.Levels[maxDif].Chords.Length; i++)
                {
                    if (song.Levels[maxDif].Chords[i].HighDensity == 1)
                    {
                        continue; //speedhack
                    }
                    int mNote = Sng2014FileWriter.getChordNote(tuning, song.Levels[maxDif].Chords[i], song.ChordTemplates, song.Arrangement == "Bass", song.Capo);
                    chordNotes.Add(new Showlight {
                        Time = song.Levels[maxDif].Chords[i].Time, Note = mNote
                    });
                }
            }

            PopShList(midiNotes);
            PopShList(chordNotes);

            return(this);
        }
示例#7
0
        private static string GetTuningName(TuningStrings tuning, bool isBass, int capo, bool inBem = true)
        {
            List <Int32>  Notes     = new List <Int32>();
            List <String> NoteNames = new List <String>();

            String[] notesNames   = new String[] { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
            String[] notesNamesHi = new String[] { "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B" };
            for (Byte s = 0; s < (isBass ? 4 : 6); s++)
            {
                Notes.Add(Sng2014FileWriter.GetMidiNote(tuning.ToShortArray(), s, 0, isBass, capo));
            }
            foreach (var mNote in Notes)
            {
                if (inBem)
                {
                    NoteNames.Add(notesNamesHi[mNote % 12]);        //oct = mNote / 12 - 1
                }
                else
                {
                    NoteNames.Add(notesNames[mNote % 12]);  //oct = mNote / 12 - 1
                }
            }
            return(String.Join(" ", NoteNames));
        }
示例#8
0
        private static Score CreateSong(Song2014 song, IEnumerable <SongNoteChordWrapper> allSounds)
        {
            var score = new Score();

            score.Album  = song.AlbumName;
            score.Artist = song.ArtistName;
            //score.copyright
            //score.instructions
            //score.music
            score.Notices = "Created by RockSmith Tab Explorer";
            //_score.subTitle
            //_score.tab
            score.Tempo      = (int)song.AverageTempo;
            score.TempoLabel = "avg. bpm";
            score.Title      = song.Title + " (" + song.Arrangement + ")";
            //_score.words

            bool isBass = song.Arrangement.ToLower() == "bass";

            var track = new Track();

            track.Name  = song.Arrangement;
            track.Index = 1;
            int capo = track.Capo;

            track.TuningName = GetTuningName(song.Tuning, isBass, capo);
            track.ShortName  = song.Arrangement;

            // Add string tunings in reverse order
            var tuning = new int[(isBass ? 4 : 6)];

            for (Byte s = 0; s < tuning.Length; s++)
            {
                tuning[tuning.Length - 1 - s] = Sng2014FileWriter.GetMidiNote(song.Tuning.ToShortArray(), s, 0, isBass, capo);
            }
            track.Tuning.AddRange(tuning);

            score.AddTrack(track);

            foreach (var chordTemplate in song.ChordTemplates.Where(ct => ct.ChordId != null))
            {
                var chord = new global::AlphaTab.Model.Chord();
                track.Chords[chordTemplate.ChordId.ToString()] = chord;

                chord.Name = chordTemplate.ChordName;
                chord.Strings.Add(chordTemplate.Fret0);
                chord.Strings.Add(chordTemplate.Fret1);
                chord.Strings.Add(chordTemplate.Fret2);
                chord.Strings.Add(chordTemplate.Fret3);
                chord.Strings.Add(chordTemplate.Fret4);
                chord.Strings.Add(chordTemplate.Fret5);
            }

            List <eBeatWrapper> ebeatMeasures      = new List <eBeatWrapper>();
            eBeatWrapper        currentMeasureBeat = null;

            foreach (var srcBeat in song.Ebeats)
            {
                if (srcBeat.Measure > 0)
                {
                    currentMeasureBeat = new eBeatWrapper()
                    {
                        MeasureStartBeat = srcBeat, MeasureSubBeats = new List <SongEbeat>()
                    };
                    ebeatMeasures.Add(currentMeasureBeat);
                }
                else
                {
                    if (currentMeasureBeat == null)
                    {
                        System.Diagnostics.Debug.WriteLine("Invalid ebeats in source file. Sub measure is before first measure!?");
                    }
                    else
                    {
                        currentMeasureBeat.MeasureSubBeats.Add(srcBeat);
                    }
                }
            }

            var notesStack  = new Stack <SongNoteChordWrapper>(allSounds.OrderByDescending(x => x.Time));
            var currentNote = notesStack.Pop();
            var nextNote    = notesStack.Pop();

            int   prevMeasureId       = 0;
            int   i                   = 1;
            float prevMeasureDuration = 0;

            foreach (var measure in ebeatMeasures)
            {
                var nextmeasure = i < ebeatMeasures.Count ? ebeatMeasures[i] : null;
                if (measure.MeasureStartBeat.Measure > prevMeasureId)
                {
                    var measureDuration = nextmeasure != null ? nextmeasure.MeasureStartBeat.Time - measure.MeasureStartBeat.Time : prevMeasureDuration;
                    AddMasterBarToScore(score, measure.MeasureStartBeat.Time.ToString("n2"), measure);
                    var voice = AddBarAndVoiceToTrack(track, isBass ? Clef.F4 : Clef.G2);

                    bool firstNoteInBar = true;
                    while (currentNote != null && (nextmeasure == null || currentNote.Time < nextmeasure.MeasureStartBeat.Time))
                    {
                        if (currentNote.IsNote() && currentNote.AsNote().Bend != 0)
                        {
                            System.Diagnostics.Debug.WriteLine("Bent detected. Bend value: {0}. Measure: {1}", currentNote.AsNote().Bend, measure.MeasureStartBeat.Measure);
                        }
                        Duration duration = Duration.Quarter;

                        if (firstNoteInBar && currentNote.Time > measure.MeasureStartBeat.Time)
                        {
                            var leadingSilenceTicks = Get64thsFromDuration(measure.MeasureStartBeat.Time, currentNote.Time, measureDuration);
                            while (leadingSilenceTicks >= 1)
                            {
                                if (leadingSilenceTicks >= 32)
                                {
                                    AddBeatAndSilenceToVoice(voice, Duration.Half);
                                    leadingSilenceTicks -= 32;
                                }
                                else if (leadingSilenceTicks >= 16)
                                {
                                    AddBeatAndSilenceToVoice(voice, Duration.Quarter);
                                    leadingSilenceTicks -= 16;
                                }
                                else if (leadingSilenceTicks >= 8)
                                {
                                    AddBeatAndSilenceToVoice(voice, Duration.Eighth);
                                    leadingSilenceTicks -= 8;
                                }
                                else if (leadingSilenceTicks >= 4)
                                {
                                    AddBeatAndSilenceToVoice(voice, Duration.Sixteenth);
                                    leadingSilenceTicks -= 4;
                                }
                                else if (leadingSilenceTicks >= 2)
                                {
                                    AddBeatAndSilenceToVoice(voice, Duration.ThirtySecond);
                                    leadingSilenceTicks -= 2;
                                }
                                else if (leadingSilenceTicks >= 1)
                                {
                                    AddBeatAndSilenceToVoice(voice, Duration.SixtyFourth);
                                    leadingSilenceTicks -= 1;
                                }
                            }
                        }


                        Single durationTime = 0;
                        if (nextNote != null)
                        {
                            duration     = GetBeatDuration(currentNote.Time, nextNote.Time, measureDuration);
                            durationTime = nextNote.Time - currentNote.Time;
                        }
                        else
                        {
                            durationTime = measureDuration;
                        }

                        if (currentNote.IsNote())
                        {
                            AddBeatAndNoteToVoice(voice, currentNote.AsNote(), duration, durationTime);
                        }
                        else
                        {
                            AddBeatWithChordToVoice(voice, currentNote.AsChord(), duration, durationTime);
                        }

                        currentNote = nextNote;
                        if (notesStack.Any())
                        {
                            nextNote = notesStack.Pop();
                        }
                        else
                        {
                            nextNote = null;
                        }
                        firstNoteInBar = false;
                    }

                    prevMeasureId       = measure.MeasureStartBeat.Measure;
                    prevMeasureDuration = measureDuration;
                }
                i++;
            }
            return(score);
        }
        private static Score CreateSong(Song2014 song, IEnumerable <SongNoteChordWrapper> allSounds)
        {
            var score = new Score();

            score.album  = song.AlbumName;
            score.artist = song.ArtistName;
            //score.copyright
            //score.instructions
            //score.music
            score.notices = "Created by RockSmith Tab Explorer";
            //_score.subTitle
            //_score.tab
            score.tempo      = (int)song.AverageTempo;
            score.tempoLabel = "avg. bpm";
            score.title      = song.Title + " (" + song.Arrangement + ")";
            //_score.words

            bool isBass = song.Arrangement.ToLower() == "bass";

            var track = new Track();

            track.name       = song.Arrangement;
            track.index      = 1;
            track.tuningName = GetTuningName(song.Tuning, isBass);
            track.shortName  = song.Arrangement;

            for (Byte s = 0; s < (isBass ? 4 : 6); s++)
            {
                track.tuning[(isBass ? 3 : 5) - s] = Sng2014FileWriter.GetMidiNote(song.Tuning.ToShortArray(), s, 0, isBass);
            }

            score.addTrack(track);

            int chordId = 0;

            foreach (var chordTemplate in song.ChordTemplates)
            {
                var chord = new global::alphatab.model.Chord();
                track.chords.set(chordId.ToString(), chord);

                chord.name       = chordTemplate.ChordName;
                chord.strings[0] = chordTemplate.Fret0;
                chord.strings[1] = chordTemplate.Fret1;
                chord.strings[2] = chordTemplate.Fret2;
                chord.strings[3] = chordTemplate.Fret3;
                chord.strings[4] = chordTemplate.Fret4;
                chord.strings[5] = chordTemplate.Fret5;
                chordId++;
            }

            var ebeatMeasures = song.Ebeats.Where(x => x.Measure > 0).OrderBy(x => x.Measure).ToList();

            var notesStack = new Stack <SongNoteChordWrapper>(allSounds.OrderByDescending(x => x.Time));

            var currentNote = notesStack.Pop();
            var nextNote    = notesStack.Pop();

            int   prevMeasureId       = 0;
            int   i                   = 1;
            float prevMeasureDuration = 0;

            foreach (var measure in ebeatMeasures)
            {
                var nextmeasure = i < ebeatMeasures.Count ? ebeatMeasures[i] : null;
                if (measure.Measure > prevMeasureId)
                {
                    var measureDuration = nextmeasure != null ? nextmeasure.Time - measure.Time : prevMeasureDuration;
                    AddMasterBarToScore(score, measure.Time.ToString("n2"));
                    var voice = AddBarAndVoiceToTrack(track, isBass ? Clef.F4 : Clef.G2);

                    bool firstNoteInBar = true;
                    while (currentNote != null && (nextmeasure == null || currentNote.Time < nextmeasure.Time))
                    {
                        Duration duration = Duration.Quarter;

                        if (firstNoteInBar && currentNote.Time > measure.Time)
                        {
                            var leadingSilenceTicks = Get64thsFromDuration(measure.Time, currentNote.Time, measureDuration);
                            while (leadingSilenceTicks >= 1)
                            {
                                if (leadingSilenceTicks >= 32)
                                {
                                    AddBeatAndNoteToVoice(voice, null, Duration.Half);
                                    leadingSilenceTicks -= 32;
                                }
                                else if (leadingSilenceTicks >= 16)
                                {
                                    AddBeatAndNoteToVoice(voice, null, Duration.Quarter);
                                    leadingSilenceTicks -= 16;
                                }
                                else if (leadingSilenceTicks >= 8)
                                {
                                    AddBeatAndNoteToVoice(voice, null, Duration.Eighth);
                                    leadingSilenceTicks -= 8;
                                }
                                else if (leadingSilenceTicks >= 4)
                                {
                                    AddBeatAndNoteToVoice(voice, null, Duration.Sixteenth);
                                    leadingSilenceTicks -= 4;
                                }
                                else if (leadingSilenceTicks >= 2)
                                {
                                    AddBeatAndNoteToVoice(voice, null, Duration.ThirtySecond);
                                    leadingSilenceTicks -= 2;
                                }
                                else if (leadingSilenceTicks >= 1)
                                {
                                    AddBeatAndNoteToVoice(voice, null, Duration.SixtyFourth);
                                    leadingSilenceTicks -= 1;
                                }
                            }
                        }

                        if (nextNote != null)
                        {
                            duration = GetBeatDuration(currentNote.Time, nextNote.Time, measureDuration);
                        }

                        if (currentNote.IsNote())
                        {
                            AddBeatAndNoteToVoice(voice, currentNote.AsNote(), duration);
                        }
                        else
                        {
                            AddBeatWithChordToVoice(voice, currentNote.AsChord(), duration);
                        }

                        currentNote = nextNote;
                        if (notesStack.Any())
                        {
                            nextNote = notesStack.Pop();
                        }
                        else
                        {
                            nextNote = null;
                        }
                        firstNoteInBar = false;
                    }

                    prevMeasureId       = measure.Measure;
                    prevMeasureDuration = measureDuration;
                }
                i++;
            }
            return(score);
        }