public string GetChordAsStringOld(Note rootNote, string chordType) { ChordManager chordManager = new ChordManager(); string output = "Chord: " + rootNote.ToString() + " " + chordType + " - "; List <Note> notes = chordManager.GetChordNotes(rootNote, chordType, StartingFretPos); for (int i = 0; i < NumberOfStrings; i++) { bool noteFound = false; foreach (Note n in notes) { if (!noteFound) { List <int> frets = GuitarStrings[i].GetNoteFretPositions(n, StartingFretPos); if (frets.Count > 0) { if (frets[0] < 5 && !noteFound) { output += n.ToString() + " fret " + frets[0] + ","; noteFound = true; } } } } } return(output); }
private Task Start() { if (Started) { return(Task.Factory.StartNew(() => { })); } if (_manager == null) { _manager = ChordManager.GetInstance(_activity); } _manager.SetTempDirectory(Path.Combine(Path.GetTempPath(), "Chord")); _manager.SetHandleEventLooper(Looper.MainLooper); _startSource = new TaskCompletionSource <bool>(); int result = _manager.Start(ChordManager.InterfaceTypeWifi, this); if (result != ChordManager.ErrorNone) { _startSource.SetException(result.ToException()); } return(_startSource.Task); }
/// <summary> /// Get chord diagram settings based on guitar model tuning/strings etc /// </summary> /// <param name="rootNote"></param> /// <param name="chordType"></param> /// <returns></returns> public ChordDiagram GetChordDiagramOld(Note rootNote, string chordType) { ChordManager chordManager = new ChordManager(); ChordDiagram chordDiagram = new ChordDiagram(); chordDiagram.RootNote = rootNote; chordDiagram.CurrentChordDefinition = chordManager.GetChordDefinition(chordType); //determine fretted notes per string based on current guitar model settings List <Note> notes = chordManager.GetChordNotes(rootNote, chordType, StartingFretPos); ///http://en.wikipedia.org/wiki/Chord_(music) bool hasChordSequenceStarted = false; //set to true once the target starting note is found, depending on the inversion (if any root, 1st pos , 2nd pos etc) for (int i = 0; i < NumberOfStrings; i++) { System.Diagnostics.Debug.WriteLine("Checking String:" + i); bool currentNoteFound = false; for (int n = 0; n < notes.Count; n++) { Note chordNote = notes[n]; System.Diagnostics.Debug.WriteLine("Checking Note:" + chordNote.ToString()); if (!currentNoteFound) { List <int> currentNoteFrets = GuitarStrings[i].GetNoteFretPositions(chordNote, StartingFretPos); if (currentNoteFrets.Count > 0) { if (currentNoteFrets[0] < MaximumChordPositionStretch) { if (!currentNoteFound) { if (n == 0) { hasChordSequenceStarted = true; } //only add fretted note if root note has been found if (hasChordSequenceStarted) { chordDiagram.FrettedStrings[i] = new Music.FrettedNote() { Fret = currentNoteFrets[0] }; } currentNoteFound = true; } } } } } } return(chordDiagram); }
/// <summary> /// returns the fretted notes of a chord based on root note and chord type /// </summary> /// <param name="rootNote"></param> /// <param name="chordType"></param> /// <returns></returns> public ChordDiagram GetChordDiagram(Note rootNote, string chordType) { ChordManager chordManager = new ChordManager(); ChordDiagram chordDiagram = new ChordDiagram(); chordDiagram.RootNote = rootNote; chordDiagram.CurrentChordDefinition = chordManager.GetChordDefinition(chordType); //determine notes in the given chord : http://en.wikipedia.org/wiki/Chord_(music) List <Note> notes = chordManager.GetChordNotes(rootNote, chordType, StartingFretPos); List <Note> notesFound = new List <Note>(); //determine which string/frets would be fretted based on current guitar model settings bool hasChordSequenceStarted = false; //set to true once the target starting note is found, depending on the inversion (if any root, 1st pos , 2nd pos etc) //basic algorithm is to fret the root note of the chord on the first string possible (low to high) //then we fret the note on each string with the lowest fret position regardless of which interval it is in chord for (int currentStringIndex = 0; currentStringIndex < NumberOfStrings; currentStringIndex++) { //System.Diagnostics.Debug.WriteLine("Checking String:" + i); var chordNotesOnString = new List <Music.FrettedNote>(); //get collection of notes applicable to this chord on current string for (int chordNoteIndex = 0; chordNoteIndex < notes.Count; chordNoteIndex++) { var frettedNote = FindChordNote(chordDiagram, notes[chordNoteIndex], ref hasChordSequenceStarted, currentStringIndex, chordNoteIndex); if (frettedNote != null) { chordNotesOnString.Add(frettedNote); } } //got a collection of notes for the chord on current string, decide which one to fret in chord diagram if (chordNotesOnString.Any()) { //if chord not yet started, use position of root/bass note on string (if any within range of fretted start position), otherwise choose note with minimum fret position if (!chordDiagram.FrettedStrings.Any(c => c != null)) { if (chordNotesOnString.Any(c => c.Note == notes[0])) { chordDiagram.FrettedStrings[currentStringIndex] = chordNotesOnString.Where(c => c.Note == notes[0]).First(); } } else { chordDiagram.FrettedStrings[currentStringIndex] = chordNotesOnString.OrderBy(f => f.Fret).First(); } } } return(chordDiagram); }