Class Translator

java.lang.Object
com.softsynth.jmsl.Translator
Direct Known Subclasses:
KeyTranslator

public class Translator
extends java.lang.Object
Translators are used for converting from one numeric system to another. Examples might be converting a generic note index to a midi value in the key of D minor. This would be a key translator.
Author:
Phil Burk and Nick Didkovsky
  • Constructor Summary

    Constructors
    Constructor Description
    Translator()  
    Translator​(int[] array, int modulus)  
  • Method Summary

    Modifier and Type Method Description
    int detranslate​(int n)
    Detranslate an integer value generated by the translate method.
    void setArray​(int[] array)
    Set array to be used for table lookup.
    void setModulus​(int modulus)
    Set length of the repeating pattern in the output.
    void setOffset​(int offset)
    Set offset to be added at end of translation.
    int translate​(int n)
    Translate input to output.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Translator

      public Translator()
    • Translator

      public Translator​(int[] array, int modulus)
  • Method Details

    • setArray

      public void setArray​(int[] array)
      Set array to be used for table lookup.
    • setOffset

      public void setOffset​(int offset)
      Set offset to be added at end of translation.
    • setModulus

      public void setModulus​(int modulus)
      Set length of the repeating pattern in the output. For western scales this might be 12 for 12 notes per octave.
    • translate

      public int translate​(int n)
      Translate input to output. The formula for translation may vary with the subclass of translator. Essentially they divide the input by the size, multiply the result by the modulus, and do a table lookup with the remainder of the division. Those two are then added.
    • detranslate

      public int detranslate​(int n) throws java.lang.Exception
      Detranslate an integer value generated by the translate method.
      Throws:
      java.lang.Exception