//arp!0 sort transform: sample
//  steps alternate between first/last; 2nd/2nd from last; etc

// name:
//  short sequence of ascii numbers which give a name for the sort 
//  transform.
115,97,109,112,108,101,0 //name: sample

// steps:
//  specifies how the number of notes generated by a sort transform is
//  calculated from the current number of input notes.  a series of value
//  pairs.  the first value is added to the number of input notes.  the the
//  second value multiplies that sum. these line pairs can repeat.  the last
//  pair ends with a multiplier of zero; which is not used.

-2 //minus 2: don't do top 2 notes that wrap
4 //times 4
0 //plus nothing
0 //times nothing: end

// prefix:
//  specifies the initial notes generated by the sort transform. positive
//  numbers specify notes from the beginning of the input notes: with one
//  meaning the first; two the second; etc. negative numbers specify notes
//  from the end of the input notes: minus one is last; minus two previous
//  to that; etc. this section ends with a zero value.

1, 2, 3, 1 //abs: 1st 2nd 3rd 1st steps

0  //0: end

// repeat:
//  specifies additional notes after the prefix notes.  this section is
//  calculated repeatedly up to the number of transform notes specified by
//  the steps section.  values can be simple positive and negative numbers
//  that work like the prefix section.  when a value in the repeat section
//  is a zero followed by a negative number; the two values after the zero
//  specify a note relative to previous notes generated by the transform. 
//  the negative value after zero is the number of steps back to the
//  relative value.  the value after that is the offset from the earlier
//  value for this step.  so 0;-2;1 means look two steps back
//  and add one to that value.  this section ends with two zero values.

0, -4, 1  //relative to 4 steps back; offset +1 from that step

0,0 //2x 0: end

// special rules:
//   a zero followed by a positive number specifies a special rule.  the
//   positive number indicates the type of rule.  following numbers qualify
//   the rule.  currently recognized special rules are:
//
// - 0;1;<probability>;<min step>;<max step>: specifies a random step in 
//   the min/max range entered.  the first value is the probability that the
//   random value will occur.  otherwise the step coming sequentially after
//   the previous one will be generated.  min/max values can be positive or
//   negative for offsets from the start or end of the input notes as in the
//   prefix section.  so 0;1;1;-3;0.5 means a random note from the first to
//   the third from the last; 50% of the time.  the random note is
//   recalculated whenever a new sort transform is loaded; or when the
//   number of input notes changes; or when one of the events in the "update
//   transform on:" section in the arp!0 settings pane is enabled.  these
//   events will create a new sequence of transformed input notes when they
//   occur; including new random steps.
//
// - 0;2;<probability>;<skip count>: skips a number of following rules.
//   the first value is the probability that the skip will occur.  the
//   following number is how many following rules to skip.
//
// - 0;3;<probability>;<value specifier>;<min value>;<max value>;<skip count>
//   the first value is the probability that the conditional skip will occur
//   at all.  next is an integer which specifies a source value.  if
//   negative this is an offset back to a previously generated step which
//   supplies the value.  if zero or higher the value is the current output
//   step number.  note that negative values refer to indices of *input*
//   notes.  but zero and above refer to the index of the current *output*
//   note.  if the integer is greater than zero the min and max values are
//   modified to be relative to a multiple of the count of input notes. 
//   otherwise positive min/max are relative to the first input step and
//   negative relative to the last input step as in the relative value
//   rules.  the final value is how many following rules to skip if the
//   specified value is greater than or equal to the minimum and less than
//   or equal to the maximum values.  ...fwiw all this may seem pretty
//   magical.  there was a comment at one point in the original unix source
//   code to the effect that "you probably won't understand this.  just know
//   that it works."  if this too brief explaination is beyond understanding
//   please know that this rule makes some very cool sort transforms
//   possible.  or contact the author who is happy to help.  :^)

// ps- semicolons used instead of commas because Js parses another number
//   after every comma

//arp!0 sort transform: sample2
//  steps alternate between first/last; 2nd/2nd from last; etc

// name:
115,97,109,112,108,101,50,0 //name: sample2

// steps:
-2-3 //minus 2: don't do top 2 notes that wrap; minus 3: don't do 1st 3
4 //times 4
0 //plus nothing
0 //times nothing: end

// prefix:
0  //0: end

0,1,1, 1,3 //random from 1st 3

0,3,1, -4,1,3,2 //skip relative if 4th back in 1st 3
0,-4,1  //relative to 4 steps back; offset +1 from that step
0,2,1, 1 //skip 1
5

0,3,1, -4,1,3,2 //skip relative if 4th back in 1st 3
0,-4,1  //relative to 4 steps back; offset +1 from that step
0,2,1, 1 //skip 1
6

0,3,1, -4,1,3,2 //skip relative if 4th back in 1st 3
0,-4,1  //relative to 4 steps back; offset +1 from that step
0,2,1, 1 //skip 1
4

0,0 //2x 0: end

