jm.util

## Class Convert

- java.lang.Object
- - jm.util.Convert

-     public class Convert
      extends java.lang.Object

  Static methods allowing conversion of standard JMusic data types (like Phrase) to and from XML. Also supports a separate custom encoding for pitch and rhythm values pairs which is much terser than XML.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DEFAULT_SEPARATOR`
    `static java.lang.String` | `LEFT_BRACKET`
    `static java.lang.String` | `RIGHT_BRACKET`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static float` | `getFrequencyByMidiPitch(int midiPitch)` Get the frequency of a given MIDI pitch
    `static int` | `getMidiPitchByFrequency(float frequency)` Get the midi pitch of a given frequency.
    `static java.lang.String` | `getNameOfMidiPitch(int pitch)` Get the midi note name for a given pitch value.
    `static java.lang.String` | `noteToXMLString(Note note)`
    `static java.lang.String` | `partToXMLString(Part part)`
    `static java.lang.String` | `phraseToPitchAndRhythmString(Phrase phrase)` Converts a Phrase, to a list of comma separated values alternately describing the pitch and rhyhtm value of each Note in the phrase.
    `static java.lang.String` | `phraseToPitchRhythmAndDynamicString(Phrase phrase)` Converts a Phrase, to a list of comma separated values alternately describing the pitch, rhyhtm value and dynamic of each Note in the phrase.
    `static java.lang.String` | `phraseToXMLString(Phrase phrase)`
    `static Phrase` | `pitchAndRhythmStringToPhrase(java.lang.String string)` Converts a list of pitch and rhythm-value pairs, each value separated by a non-digit, to the Phrase that those values represent.
    `static Phrase` | `pitchRhythmAndDynamicStringToPhrase(java.lang.String string)` Converts a list of pitch, rhythm-value and dynamic sets, each value separated by a non-digit, to the Phrase that those values represent.
    `static java.lang.String` | `scoreToXMLString(Score score)`
    `static Note` | `xmlStringToNote(java.lang.String string)`
    `static Part` | `xmlStringToPart(java.lang.String string)`
    `static Phrase` | `xmlStringToPhrase(java.lang.String string)`
    `static Score` | `xmlStringToScore(java.lang.String string)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_SEPARATOR

          public static final java.lang.String DEFAULT_SEPARATOR

      See Also:
        Constant Field Values

    - #### LEFT_BRACKET

          public static final java.lang.String LEFT_BRACKET

      See Also:
        Constant Field Values

    - #### RIGHT_BRACKET

          public static final java.lang.String RIGHT_BRACKET

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### pitchAndRhythmStringToPhrase

          public static Phrase pitchAndRhythmStringToPhrase(java.lang.String string)

      Converts a list of pitch and rhythm-value pairs, each value separated by a non-digit, to the Phrase that those values represent.
      Parameters:
        `string` - String of value separated by commas
      Returns:
        Phrase described by the String.

    - #### phraseToPitchAndRhythmString

          public static java.lang.String phraseToPitchAndRhythmString(Phrase phrase)

      Converts a Phrase, to a list of comma separated values alternately describing the pitch and rhyhtm value of each Note in the phrase.
      Parameters:
        `phrase` - Phrase to be converted
      Returns:
        String describing the Phrase

    - #### pitchRhythmAndDynamicStringToPhrase

          public static Phrase pitchRhythmAndDynamicStringToPhrase(java.lang.String string)

      Converts a list of pitch, rhythm-value and dynamic sets, each value separated by a non-digit, to the Phrase that those values represent.
      Parameters:
        `string` - String of value separated by commas
      Returns:
        Phrase described by the String.

    - #### phraseToPitchRhythmAndDynamicString

          public static java.lang.String phraseToPitchRhythmAndDynamicString(Phrase phrase)

      Converts a Phrase, to a list of comma separated values alternately describing the pitch, rhyhtm value and dynamic of each Note in the phrase.
      Parameters:
        `phrase` - Phrase to be converted
      Returns:
        String describing the Phrase

    - #### scoreToXMLString

          public static java.lang.String scoreToXMLString(Score score)

    - #### partToXMLString

          public static java.lang.String partToXMLString(Part part)

    - #### phraseToXMLString

          public static java.lang.String phraseToXMLString(Phrase phrase)

    - #### noteToXMLString

          public static java.lang.String noteToXMLString(Note note)

    - #### xmlStringToScore

          public static Score xmlStringToScore(java.lang.String string)
                                        throws ConversionException

      Throws:
        `ConversionException`

    - #### xmlStringToPart

          public static Part xmlStringToPart(java.lang.String string)
                                      throws ConversionException

      Throws:
        `ConversionException`

    - #### xmlStringToPhrase

          public static Phrase xmlStringToPhrase(java.lang.String string)
                                          throws ConversionException

      Throws:
        `ConversionException`

    - #### xmlStringToNote

          public static Note xmlStringToNote(java.lang.String string)
                                      throws ConversionException

      Throws:
        `ConversionException`

    - #### getFrequencyByMidiPitch

          public static final float getFrequencyByMidiPitch(int midiPitch)

      Get the frequency of a given MIDI pitch
      Parameters:
        `midiPitch` - pitch value from 0 - 127
      Returns:
        frequency a value in hertz
      See Also:
        `description of {@link Pitches}.`, `description of {@link Frequencies}.`

    - #### getMidiPitchByFrequency

          public static final int getMidiPitchByFrequency(float frequency)

      Get the midi pitch of a given frequency.
      Parameters:
        `frequency` - frequency value in Hz
      Returns:
        pitch a value from 0..127
      See Also:
        `description of {@link Pitches}.`, `description of {@link Frequencies}.`

    - #### getNameOfMidiPitch

          public static final java.lang.String getNameOfMidiPitch(int pitch)

      Get the midi note name for a given pitch value.
      Parameters:
        `pitch` - a value from 0..127
      Returns:
        midi note name like in `Pitches`
      See Also:
        `description of {@link Pitches}.`, `description of {@link Frequencies}.`