/// <summary> /// For a given flashcard, make a lilypond-compatible string that can be /// used to render the flashcard. /// </summary> /// <param name="flashcard">The flashcard to render.</param> /// <returns>A lilypond script.</returns> public static string MakeLilypondScript(Flashcard flashcard) { var leftHandNotes = flashcard.StaffNotes .Where(sn => sn.Staff == Staff.LeftHand) .OrderBy(sn => sn.NoteRepresentation.Note.Number) .Select(sn => ConvertStaffNoteToLilypondNote(sn)) .ToArray(); string leftHandString; if (leftHandNotes.Any()) leftHandString = String.Format("<{0}>", String.Join(" ", leftHandNotes)); else leftHandString = "r4"; var rightHandNotes = flashcard.StaffNotes .Where(sn => sn.Staff == Staff.RightHand) .OrderBy(sn => sn.NoteRepresentation.Note.Number) .Select(sn => ConvertStaffNoteToLilypondNote(sn)) .ToArray(); string rightHandString; if (rightHandNotes.Any()) rightHandString = String.Format("<{0}>", String.Join(" ", rightHandNotes)); else rightHandString = "r4"; return String.Format(LP_FORMAT, rightHandString, leftHandString); }
public static FlashcardResult Missed(Flashcard card) { return new FlashcardResult(card, FlashcardResultType.Missed); }
public static FlashcardResult Incorrect(Flashcard card, DateTime flashcardStartTime) { return new FlashcardResult(card, FlashcardResultType.Incorrect, flashcardStartTime); }
private FlashcardResult(Flashcard card, FlashcardResultType resultType, DateTime? flashcardStartTime = null) { ResultType = resultType; if(flashcardStartTime.HasValue) ResponseTime = (DateTime.Now - flashcardStartTime.Value).Ticks; }
public FlashcardEventArgs(Flashcard flashcard) { Flashcard = flashcard; }
/// <summary> /// Play the notes from a flashcard through the output device. /// </summary> /// <param name="f"></param> private void PlayFlashcard(Flashcard f) { ChannelMessageBuilder cbm = new ChannelMessageBuilder(); cbm.Command = ChannelCommand.NoteOn; cbm.Data2 = 75; cbm.MidiChannel = 0; cbm.Build(); cbm.Command = ChannelCommand.NoteOff; var onMessages = new ChannelMessage[f.StaffNotes.Length]; var offMessages = new ChannelMessage[f.StaffNotes.Length]; for (var i = 0; i < f.StaffNotes.Length; i++) { cbm.Data1 = f.StaffNotes[i].NoteRepresentation.Note.MIDINumber; cbm.Command = ChannelCommand.NoteOn; cbm.Build(); onMessages[i] = cbm.Result; cbm.Command = ChannelCommand.NoteOff; cbm.Build(); offMessages[i] = cbm.Result; } var t = new Timer(500) { AutoReset = false }; t.Elapsed += (s, a) => Array.ForEach(offMessages, m => _outputDevice.Send(m)); Array.ForEach(onMessages, m => _outputDevice.Send(m)); t.Start(); }
/// <summary> /// Advance to the next flashcard. /// </summary> private void GotoNextFlashcard() { var f = _flashcardSource.Next(); _currentFlashcard = f; // populate the response dictionary with the notes in the flashcard // and a False value so they can be checked off as they are received. _currentResponse.Clear(); foreach (var sn in f.StaffNotes) _currentResponse.Add(sn.NoteRepresentation.Note, false); _currentFlashcardStartTime = DateTime.Now; GameMode = Lightspeed.GameMode.InFlashcard; _flashcardTimer.Start(); if (NextFlashcard != null) NextFlashcard(this, new FlashcardEventArgs(_currentFlashcard)); }