Package wellen

Class Pattern

All Implemented Interfaces:
Loopable

public class Pattern extends Loop implements Loopable
  • Constructor Details

    • Pattern

      public Pattern()
    • Pattern

      public Pattern(int in_point, int out_point, int loop)
  • Method Details

    • print

      public static void print(String s)
    • println

      public static void println()
    • println

      public static void println(String s)
    • run_test

      public static void run_test()
    • set_length

      public void set_length(int length)
      length defines the number of steps before beat is wrapped.

      e.g an interval of 3 would generate a pattern of 0, 1, 2, 0, 1, 2, 0, 1, …

      setting interval length affects the out point. e.g an interval of 3 and an in point of N would yield an out point of N + ( 3 - 1 ) and would generate a pattern of 0, 1, 2, 0, 1, 2, 0, 1, …

      Overrides:
      set_length in class Loop
      Parameters:
      length - number of steps before the beat is wrapped
    • get_loop

      public int get_loop()
      Specified by:
      get_loop in interface Loopable
    • set_loop

      public void set_loop(int pLoop)
      set the number of loops. while the length of a single cycle is set by set_length(int), the number of cycles or repetitions is defined by set_loop(int). if number of loops is set to Wellen.LOOP_INFINITE the loop is repearted infinitely. if set to Wellen.NO_LOOP only one cycle is processed.
      Parameters:
      pLoop - number of loops
    • get_in_point

      public int get_in_point()
      Specified by:
      get_in_point in interface Loopable
    • set_in_point

      public void set_in_point(int in_point)
      set in point for pattern. if out point is equal or smaller than in point length is set to 1 and out point accordingly.
      Parameters:
      in_point - set in point for pattern
    • get_out_point

      public int get_out_point()
      Specified by:
      get_out_point in interface Loopable
    • set_out_point

      public void set_out_point(int out_point)
      set out point for pattern. this method also affects the length of the pattern.
      Parameters:
      out_point - out point for pattern
    • event

      public boolean event(int beat, int event_at)
      querry whether an event occured. the first value is the absolute beat ( or beat ) to evalute, the second value specifies the position in to query. e.g if the pattern is of length 3 ( P(3), has an in point of 0 and loops infinitely, it will generate the following values:
      
           TICK   : 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
           P(3)   : 0  1  2  0  1  2  0  1  2  0  1  2  0  1  2  0  1
       

      if event is now for example tested againt 0 E(0) it will either return true + or false -:

      
           TICK   : 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
           P(3)   : 0  1  2  0  1  2  0  1  2  0  1  2  0  1  2  0  1
           E(0)   : +  -  -  +  -  -  +  -  -  +  -  -  +  -  -  +  -
       

      e.g an increasing value will produce an event every 3 beats:

      
           Pattern p = new Pattern();
           p.set_length(3);
           if (p.event(mTick, 0)) {
               println("event");
           }
       
      Overrides:
      event in class Loop
      Parameters:
      beat - absolute beat to evaluate
      event_at - local position to to test beat against
      Returns:
      true if an event occurs
    • get_relative_position

      public int get_relative_position(int absolut_position)
      returns the relative postion in repsect to in- and out point
      Parameters:
      absolut_position - current absolut position ( i.e beat )
      Returns:
      returns the relative postion. value may be negative.
    • get_loop_count

      public int get_loop_count(int absolut_position)
      returns the current loop where 0 is the first loop. this method always returns Wellen.NO_LOOP_COUNT if one of the following criteria is met:
      • no out point is specified ( i.e set_out_point(NO_OUTPOINT) )
      • loop is set to set_loop(NO_LOOP)
      • a number of loops is specified but the position is before the in point
      Overrides:
      get_loop_count in class Loop
      Parameters:
      absolut_position - current absolut position ( i.e beat )
      Returns:
      returns the current loop. value may be negative.
    • main

      public static void main(String[] args)