public static D_Note noteFromToken(String token, int current_scope_octave, D_Note previous_note) { NoteLevel noteLevel = noteLevelDictionary[token[0]]; int length_in_sixteenths = 16 / StringUtil.getNumberFromString(token); if (token.Contains('.')) { length_in_sixteenths = (int)((double)length_in_sixteenths * 1.5); } if (noteLevel == NoteLevel.rest) { return(D_NoteFactory.create_rest(length_in_sixteenths)); } else { NoteAlteration alteration = getNoteNoteAlteration(token); int octave = getNoteOctave(token, current_scope_octave); D_Note new_note = D_NoteFactory.create_note(noteLevel, alteration, octave, length_in_sixteenths); if (previous_note != null) { setRelativeOctave(new_note, previous_note); } return(new_note); } }
public void fillBarsWithNotes(List <D_Note> notes) { // Warning: this does not take notes into account that span multiple bars int current_bar_index = 0; foreach (D_Note note in notes) { D_Note to_append = this.bars[current_bar_index].addNote(note); if (to_append != null) { // overflow! current_bar_index++; D_Note please_dont_return = this.bars[current_bar_index].addNote(to_append); if (please_dont_return != null) { throw new Exception("Somehow there's a note that's longer than an entire bar. wot de fok"); } } if (this.bars[current_bar_index].isFull()) { current_bar_index++; } } if (!this.bars[this.bars.Count - 2].isFull()) { throw new Exception("Second last bar is not full, something probablt went wrong here."); } if (!this.bars[this.bars.Count - 1].isFull()) { // fill with rests int to_fill = this.bars[current_bar_index].spaceLeft(); this.bars[current_bar_index].addNote(D_NoteFactory.create_rest(to_fill)); } }
public static D_Note create_rest(int beats) { return(D_NoteFactory.create_rest(beats)); }