Class Score


  • public class Score
    extends Object
    A musical score, or piece of sheet music. Scores consist of notes in the four parts of barbershop music, in the order defined by the constants in VoicePart, i.e. VoicePart.TENOR = 0. Scores can also contain lyrics and chords.
    • Constructor Detail

      • Score

        public Score()
        Creates a score with an empty title and composer, a key of C major, and a 4/4 time signature.
      • Score

        public Score​(String title,
                     String composer,
                     String key,
                     int quartersPerMeasure)
        Creates a score with the given title, composer, key, and time signature. Time signatures that are not in quarters are currently not supported.
        Parameters:
        title -
        composer -
        key -
        quartersPerMeasure -
    • Method Detail

      • addNote

        public void addNote​(int part,
                            Note note)
        Adds the given note to the end of the given voice part.
        Parameters:
        part -
        note -
      • getPart

        public List<Note> getPart​(int part)
        Returns the notes in the given voice part.
        Parameters:
        part -
        Returns:
      • getKey

        public String getKey()
        Returns the key of this score.
        Returns:
      • getTitle

        public String getTitle()
        Returns the title of this score.
        Returns:
      • getComposer

        public String getComposer()
        Returns the composer of this score.
        Returns:
      • getQuartersPerMeasure

        public int getQuartersPerMeasure()
        Returns the time signature of this score, in quarters per measure.
        Returns:
      • setKey

        public void setKey​(String key)
        Changes the key of this score.
        Parameters:
        key -
      • setTitle

        public void setTitle​(String title)
        Changes the title of this score.
        Parameters:
        title -
      • setComposer

        public void setComposer​(String composer)
        Changes the composer of this score.
        Parameters:
        composer -
      • setQuartersPerMeasure

        public void setQuartersPerMeasure​(int quartersPerMeasure)
        Changes the time signature of thi score, in quarters per measure.
        Parameters:
        quartersPerMeasure -
      • getTempo

        public String getTempo()
        Returns the tempo of the song, as per the "Q:" field in the ABC notation.
        Returns:
      • setTempo

        public void setTempo​(String tempo)
      • addChord

        public void addChord​(int startTime,
                             Chord chord)
        Adds a chord at the end of this score. The "startTime" is the time in 1/8 notes since the beginning of the score at which this chord is to be played. This makes it possible to hold the same chord over several notes in the music.
        Parameters:
        startTime -
        chord -
      • addWord

        public void addWord​(String word)
        Adds a word to the end of the lyrics.
        Parameters:
        word -
      • getLyrics

        public List<String> getLyrics()
        Returns the lyrics of the song, as a list of words.
        Returns:
      • getChordAtTime

        public Chord getChordAtTime​(int time)
        Returns the chord that is played at the given time. Time is counted in 1/8 notes since the beginning of the score.
        Parameters:
        time -
        Returns:
      • cloneWithoutNotes

        public Score cloneWithoutNotes()
        Returns a copy of this score with all the notes removed.
        Returns:
      • foreachNoteAndChord

        public void foreachNoteAndChord​(int part,
                                        BiConsumer<Note,​Chord> fn)
        Iterates over all the notes in the given part. With each note, the corresponding chord is passed to the given consumer "fn".
        Parameters:
        part -
        fn -
      • countNotes

        public int countNotes​(int part)
        Counts the number of notes in the given part.
        Parameters:
        part -
        Returns: