private int GetValue(Note n) { if (_track.IsPercussion) { return(PercussionMapper.MapNoteForDisplay(n)); } else { return(n.RealValue); } }
private int GetValue(Note n) { if (_track.IsPercussion) { return(PercussionMapper.MapNoteForDisplay(n)); } else { return(n.RealValue - _track.DisplayTranspositionPitch); } }
private int GetValue(Note n) { if (_staff.StaffKind == StaffKind.Percussion) { return(PercussionMapper.MapNoteForDisplay(n.DisplayValue)); } else { return(n.DisplayValue); } }
private int RegisterNoteLine(Note n) { var value = n.Beat.Voice.Bar.Staff.Track.IsPercussion ? PercussionMapper.MapNoteForDisplay(n) : n.RealValue; var ks = n.Beat.Voice.Bar.MasterBar.KeySignature; var clef = n.Beat.Voice.Bar.Clef; var index = value % 12; var octave = (value / 12); // Initial Position var steps = OctaveSteps[(int)clef]; // Move to Octave steps -= (octave * StepsPerOctave); // get the step list for the current keySignature var stepList = ModelUtils.KeySignatureIsSharp(ks) || ModelUtils.KeySignatureIsNatural(ks) ? SharpNoteSteps : FlatNoteSteps; //Add offset for note itself int offset = 0; switch (n.AccidentalMode) { // TODO: provide line according to accidentalMode case NoteAccidentalMode.Default: case NoteAccidentalMode.SwapAccidentals: case NoteAccidentalMode.ForceNatural: case NoteAccidentalMode.ForceFlat: case NoteAccidentalMode.ForceSharp: default: // normal behavior: simply use the position where // the keysignature defines the position offset = stepList[index]; break; } steps -= stepList[index]; // TODO: It seems note heads are always one step above the calculated line // maybe the SVG paths are wrong, need to recheck where step=0 is really placed var line = steps + NoteStepCorrection; _appliedScoreLines[GetNoteId(n)] = line; return(line); }
private int RegisterNoteLine(Note n) { var track = n.Beat.Voice.Bar.Staff.Track; var value = track.IsPercussion ? PercussionMapper.MapNoteForDisplay(n) : n.RealValue - track.DisplayTranspositionPitch; var ks = n.Beat.Voice.Bar.MasterBar.KeySignature; var clef = n.Beat.Voice.Bar.Clef; var index = value % 12; var octave = (value / 12) - 1; // Initial Position var steps = OctaveSteps[(int)clef]; // Move to Octave steps -= (octave * StepsPerOctave); // get the step list for the current keySignature var stepList = ModelUtils.KeySignatureIsSharp(ks) || ModelUtils.KeySignatureIsNatural(ks) ? SharpNoteSteps : FlatNoteSteps; //Add offset for note itself int offset = 0; switch (n.AccidentalMode) { // TODO: provide line according to accidentalMode case NoteAccidentalMode.Default: case NoteAccidentalMode.SwapAccidentals: case NoteAccidentalMode.ForceNatural: case NoteAccidentalMode.ForceFlat: case NoteAccidentalMode.ForceSharp: default: // normal behavior: simply use the position where // the keysignature defines the position offset = stepList[index]; break; } steps -= stepList[index]; _appliedScoreLines[n.Id] = steps; return(steps); }
/// <summary> /// Calculates the accidental for the given note and assignes the value to it. /// The new accidental type is also registered within the current scope /// </summary> /// <param name="note"></param> /// <returns></returns> public AccidentalType ApplyAccidental(Note note) { var staff = _bar.Staff; var noteValue = staff.StaffKind == StaffKind.Percussion ? PercussionMapper.MapNoteForDisplay(note.DisplayValue) : note.DisplayValue; bool quarterBend = note.HasQuarterToneOffset; var line = RegisterNoteLine(note, noteValue); if (MinNoteValue == -1 || noteValue < MinNoteValue) { MinNoteValue = noteValue; MinNoteValueBeat = note.Beat; } if (MaxNoteValue == -1 || noteValue > MaxNoteValue) { MaxNoteValue = noteValue; MaxNoteValueBeat = note.Beat; } return(GetAccidental(line, noteValue, quarterBend)); }
/// <summary> /// Calculates the accidental for the given note and assignes the value to it. /// The new accidental type is also registered within the current scope /// </summary> /// <param name="note"></param> /// <returns></returns> public AccidentalType ApplyAccidental(Note note) { var track = note.Beat.Voice.Bar.Staff.Track; var noteValue = track.IsPercussion ? PercussionMapper.MapNoteForDisplay(note) : note.RealValue - track.DisplayTranspositionPitch; var ks = note.Beat.Voice.Bar.MasterBar.KeySignature; var ksi = (ks + 7); var index = (noteValue % 12); var accidentalToSet = AccidentalType.None; var line = RegisterNoteLine(note); if (!note.Beat.Voice.Bar.Staff.Track.IsPercussion) { // the key signature symbol required according to var keySignatureAccidental = ksi < 7 ? AccidentalType.Flat : AccidentalType.Sharp; // determine whether the current note requires an accidental according to the key signature var hasNoteAccidentalForKeySignature = KeySignatureLookup[ksi][index]; var isAccidentalNote = AccidentalNotes[index]; var isAccidentalRegistered = _registeredAccidentals.ContainsKey(line); if (hasNoteAccidentalForKeySignature != isAccidentalNote && !isAccidentalRegistered) { _registeredAccidentals[line] = true; accidentalToSet = isAccidentalNote ? keySignatureAccidental : AccidentalType.Natural; } else if (hasNoteAccidentalForKeySignature == isAccidentalNote && isAccidentalRegistered) { _registeredAccidentals.Remove(line); accidentalToSet = isAccidentalNote ? keySignatureAccidental : AccidentalType.Natural; } } // TODO: change accidentalToSet according to note.AccidentalMode return(accidentalToSet); }
/// <summary> /// Calculates the accidental for the given note value and assignes the value to it. /// The new accidental type is also registered within the current scope /// </summary> /// <param name="relatedBeat"></param> /// <param name="noteValue"></param> /// <param name="quarterBend"></param> /// <returns></returns> public AccidentalType ApplyAccidentalForValue(Beat relatedBeat, int noteValue, bool quarterBend) { var staff = _bar.Staff; if (staff.StaffKind == StaffKind.Percussion) { noteValue = PercussionMapper.MapNoteForDisplay(noteValue); } var line = RegisterNoteValueLine(noteValue); if (MinNoteValue == -1 || noteValue < MinNoteValue) { MinNoteValue = noteValue; MinNoteValueBeat = relatedBeat; } if (MaxNoteValue == -1 || noteValue > MaxNoteValue) { MaxNoteValue = noteValue; MaxNoteValueBeat = relatedBeat; } return(GetAccidental(line, noteValue, quarterBend)); }