Module hw06

Class ABCUtil

java.lang.Object
provided.abcMusic.utils.ABCUtil

public class ABCUtil extends Object
Singleton utility class that has methods for parsing, reading file content and getting the list of instruments.
  • Field Details

    • logger

      private ILogger logger
      logger to use
    • Singleton

      public static final ABCUtil Singleton
      Singleton instance of the class
  • Constructor Details

    • ABCUtil

      private ABCUtil()
      private constructor
  • Method Details

    • parseFraction

      public double parseFraction(String frac)
      Return the evaluation of a string "a/b".
      Parameters:
      frac - - a string containing a fraction
      Returns:
      - the result of evaluating the fraction
    • parseTempo

      public double parseTempo(String tempo, double defaultNotesPerQuarterNote)
      Return the tempo given by the input string. The returned value is in the units of quarter notes per minute as is required to configure the MIDI sequence player.
      Accepts a tempo in terms of default notes per minute or "a/b=tempo" (a/b notes per minute = default notes per minute where a/b is the default note).
      In order to do the conversion to to quarter notes per minute, the value of quarter notes per default note is required.
      Parameters:
      tempo - - tempo represented as a string as default note per minute or a particular a/b note per minute
      defaultNotesPerQuarterNote - - default notes per quarter note
      Returns:
      - the tempo indicated by the string in quarter notes per minute
    • getFileContents

      public String getFileContents(String filename)
      Returns the contents of a text file, e.g. an abc file, as a single string.
      Parameters:
      filename - the name of the file with respect to the default package, where "/" refers to the default package, e.g. a file in the "data" package would "/data/myfile.abc"
      Returns:
      the contents of the file
    • getInstruments

      public ABCInstrument[] getInstruments()
      Get an array of all the available instruments as ABCInstruments where the instrument's value is the MIDI instrument number
      Returns:
      an array of ABCInstruments