private NoteStemDirection GetStemDirection(Note note) { var direction = NoteStemDirection.Up; if (note.Octave >= Octaves.Five || (note.Name == Names.B && note.Octave == Octaves.Four)) { direction = NoteStemDirection.Down; } return(direction); }
private void AddNote(Note note) { // set modifier; negative for flats, positive for sharp int modifier = 0; if (note.Modifier == Modifiers.Flat) { modifier = -1; } else if (note.Modifier == Modifiers.Sharp) { modifier = 1; } // set stem direction var direction = GetStemDirection(note); var amount = AmountOfBeams(note.Duration); if (amount > 0) { _buffer.Add(new NoteBeams { Note = note, Beams = Enumerable.Repeat(NoteBeamType.Single, amount).ToList() }); if (_buffer.Count > 3) { FlushBuffer(); } return; // don't add anything till buffer is full or flushed } // if buffer has items, flush before adding new notes if (_buffer.Count > 0) { FlushBuffer(); } var psamNote = new PSAMNote(note.Name.ToString(), modifier, (int)note.Octave, (MusicalSymbolDuration)note.Duration, direction, NoteTieType.None, new List <NoteBeamType> { NoteBeamType.Single }); // set dots psamNote.NumberOfDots = note.Dots; _notes.Add(psamNote); }
public TokenScoreBuilder() { _lastTimeSignature = new TimeSignature { Beat = Durations.Quarter, Ticks = 4 }; _currentGroup = new SymbolGroup(); _currentGroup.Meter = _lastTimeSignature; _score = new Score { SymbolGroups = { _currentGroup } }; _relativeOctave = Octaves.Three; _previous = new Common.Models.Note(Names.C, _relativeOctave); }
private Common.Models.Note GetNote(Note note) { var name = Regex.Replace(note.Value, @"[\d',.]", string.Empty); int.TryParse(Regex.Replace(note.Value, @"[A-Za-z',.]", string.Empty), out var duration); AlterOctave(note.Value); // set previous to the new note _previous = new Common.Models.Note((Names)name[0], _relativeOctave, DurationUtils.GetClosestDuration(duration)); if (name.EndsWith("es") || name.EndsWith("as")) { _previous.Modifier = Common.Definitions.Modifiers.Flat; } else if (name.EndsWith("is")) { _previous.Modifier = Common.Definitions.Modifiers.Sharp; } _previous.Dots = note.Value.ToCharArray().Count(dot => dot == '.'); return(_previous); }
private void SetRelative(string value) { AlterOctave(value); _previous = new Common.Models.Note(Names.C, _relativeOctave); }