/// <summary> /// Frets the notes on the <see cref="IStringInstrument"/> and gets back the note values /// </summary> /// <param name="guitar"></param> /// <param name="multipleNotes"></param> /// <returns></returns> private IEnumerable <string> GetNoteList(IStringInstrument guitar, string[] multipleNotes) { foreach (var singleNote in multipleNotes) { yield return(GetNoteFromGuitar(guitar, singleNote)); } }
/// <summary> /// Converts <see cref="Tablature"/> to a list of <see cref="NoteGroup"/> using <see cref="IStringInstrument"/> to <see cref="SongKey"/> /// </summary> /// <param name="guitar"></param> /// <param name="tabDefinition"></param> public void ConvertTabsToNoteSequence(IStringInstrument guitar, Tablature tabDefinition) { var frettedNotes = tabDefinition.TabString.Split(','); Song = new SongKey(tabDefinition.Name, null); NoteSequence = CreatePlayableNotesFromTabs(guitar, frettedNotes); }
public IList <IStringInstrumentChord> GetChords(IStringInstrument stringInstrument, INote note) { var chords = this.ChordService.GetChords(note); var ret = chords .Select(chord => this.GetStringInstrumentChord(stringInstrument, chord)) .ToList(); return(ret); }
/// <summary> /// Frets a single noite on the <see cref="IStringInstrument"/> /// </summary> /// <param name="guitar"></param> /// <param name="singleNote"></param> /// <returns></returns> private string GetNoteFromGuitar(IStringInstrument guitar, string singleNote) { var noteParts = singleNote.Split('-'); var stringNum = GetString(noteParts); var fret = GetFret(noteParts); var timing = GetNoteDuration(noteParts); var note = guitar.GetNote(stringNum, fret); return($"{note}-{timing}"); }
/// <summary> /// Converts a string array of fretted notes to using <see cref="Guitar"/> to /// </summary> /// <param name="guitar"></param> /// <param name="tabbedNotes"></param> /// <returns></returns> private IEnumerable <NoteGroup> CreatePlayableNotesFromTabs(IStringInstrument guitar, IEnumerable <string> tabbedNotes) { foreach (var currentNote in tabbedNotes) { var multipleNotes = currentNote.Split('|'); var noteList = GetNoteList(guitar, multipleNotes); yield return(new NoteGroup() { Notes = noteList.ToArray(), PrimaryNote = noteList.First() }); } }
private IStringInstrumentChord GetStringInstrumentChord(IStringInstrument stringInstrument, IChord chord) { var possibilities = new List <IStringInstrumentChordPossibility>(); var ret = new StringInstrumentChord(); ret.Chord = chord; // semi tone index. for (var sti = 0; sti < stringInstrument.SemiToneCount; sti++) { // string note index. var stringNotePositions = stringInstrument.Strings .Select(currentString => { var notePositions = stringNotePositionForString(currentString, chord, sti, _typicalFingerSemiToneStretch); return(notePositions); }) .ToList(); stringNotePositions.ForEach(t => t.Insert(0, null)); var allCombinations = Combos(stringNotePositions); var combinationCases = allCombinations .Select(t => IsChord(chord, t)) .ToList(); var tempPossibilities = combinationCases .Where(t => t.isValidChord) .Select(t => new StringInstrumentChordPossibility { NotePositions = t.notePositions }); possibilities.AddRange(tempPossibilities); } ret.ChordPossibilities = possibilities .Aggregate(new List <IStringInstrumentChordPossibility>(), (prev, current) => { if (!prev.Any(t => t.Equals(current))) { prev.Add(current); } return(prev); }); return(ret); }
public IStringInstrumentChord GetChord(IStringInstrument stringInstrument, INote note, Chords type) { var chord = ChordService.GetChord(note, type); return(GetStringInstrumentChord(stringInstrument, chord)); }