Class PitchGrid

java.lang.Object
eu.bandm.music.applications.tabstaff.PitchGrid

public class PitchGrid extends Object
Represents the assigment of the 8x8 "Ableton Push"-style grid of keys to pitch codes and diatonic roles. The pitches (encoded as offsets relative to some absolute MIDI key number) are used when some hardware device is used for input; the roles are used for coloring the hardware pads.

Initial configuration parameters are:

  • Diatonic or Chromatic mode ("InKey" mode)
  • Scale = distance of diatonic pitches.
  • Distance from row to next row (diatonic third, diatonic fourth, or sequential)

"Orientation" (horizontal vs. vertical) is not maintained in this class, but has to be maintained by some outer software level, linking this instance to hardware etc.

"Base pitch" is not maintained in this class, but all pitch information is in indexes relative to a MIDI key number, maintained outside this class.

There are two ways of configuring:

  • Initial configurations are created from scratch according to the above-listed parameters.
  • Fixed mode derivations take the current state and alter it, according to one altered parameter, and aim at changing the MIDI key assignment as little as possible.
The latter can lead to ptich and role distributions which differ from the initial configurations, esp. w.r.t. the role and pitch of pad (1,1).
  • Field Details

    • inKey

      boolean inKey
    • scale

    • distance

    • pitchOffsets

      final int[][] pitchOffsets
      Pitches are assigned to pads as numeric offsets to an arbitrary base pitch. (This base pitch is maintained outside this instance.) The array is indexed by row and column, but zero based. (The "offical names" of rows and columns are one based!)
    • roles

      final ScalaNumAbstrPOcts.Functio[][] roles
      The roles of the pads are the roles of the assigned pitch (pitch offset) with respect to the current scale. The array is indexed by row and column.
    • initial

      boolean initial
      Whether no fixed deriations have happend since the last initialization.
    • diatonicIntervalRule

      PitchGrid.diatonicIntervals diatonicIntervalRule
      Configuration parameter. Can be overwritten on construction by "{{a=b;}}".
    • strictChromaticFourths

      boolean strictChromaticFourths
      In chromatic mode, take five half-tone steps for a fourth, not considering the scale. Configuration parameter, can be overwritten on construction by "{{a=b;}}".
  • Constructor Details

    • PitchGrid

      public PitchGrid()
  • Method Details

    • getOffset

      public int getOffset(int row, int column)
    • getRole

      public ScalaNumAbstrPOcts.Functio getRole(int row, int column)
    • isInitial

      public boolean isInitial()
    • initPads

      public void initPads(boolean inKey, ScalaNumAbstrPOcts scale, Tabstaff.distance distance)
      Calculate the initial roles and pitch offsets of all squares. Parameters are inKey, scale, and (row) distance. Since in this class only relative indices are maintained, pitch is not a parameter, but the grid is initialized to start at offset = 0. The generated layout for distance=thirds and scale=major will be n chromatic mode / inKey = false:
         |  
         |invalid input: '<'7>  8  invalid input: '<'9> 10   invalid input: '<'11>[12]13 (14)  
         |  
         |(4)  (5) 6  invalid input: '<'7>   8  (9) 10 (11) 
         |  
         |[0]  1  (2)  3   (4) (5)  6 invalid input: '<'7> 
         |_________________________________
      
         with [w] = finalis,  = repercussa, (y) = inTonos, and z = extraTonos
        
      and will be in iatonic mode / inKey = true :
         |  
         |4   5  invalid input: '<'7> 9    11 [12] 14 16  
         |  
         |[0]  2  4  5    invalid input: '<'7> 9   11 [12] 
         |_________________________________
         with [w] = finalis,  = repercussa, and y = inTonos.
        

      (Vertical mode and absolute pitch are maintained outside of this class.)

      (The value of

      invalid reference
      #diatonicIntervals
      comes in play for more irregular scales like "[0]12567910".)
      Parameters:
      scale - classifies relative indices modulo 12.
      distance - how the leftmost pad in each row is related to the leftmost pad one row higher/lower.
    • cacheRoles

      void cacheRoles()
    • deriveFixed_basePitch

      public void deriveFixed_basePitch(int diff)
      Change the base pitch in fixed mode.

      In chromatic mode, all pads keep their pitch and only the highlighting / the scale roles must adopt.

      In diatonic mode, additionally few or more pitches must be exchanged.

      Parameters:
      diff - the difference "oldBasePitch - newBasePitch". This will be added to all pads' values, so that "oldBasePitch + oldPadValue" gives the same MIDI key value as "newBasePitch + (oldPadValue + diff)".
    • deriveFixed_scale

      public void deriveFixed_scale(ScalaNumAbstrPOcts newScale)
      Change the scale in fixed mode. All scales are always started at index=0.

      In chromatic mode, all pads keep their pitch and only the highlighting / the scale roles must adopt.

      In diatonic mode, additionally few or more pitches must be exchanged.

      Parameters:
      scale - the new scale
    • deriveFixed_distance

      public void deriveFixed_distance(Tabstaff.distance newDistance)
      In both modes all rows except the bottom row must be recalculated. (If the argument is already the current value, no change happens.)
    • deriveFixed_inKey

      public void deriveFixed_inKey(boolean newInkey)
      When switching between diatonic and chromatic, all pads except at [1][1] must be recalculated.