Advertisement
Guest User

Untitled

a guest
May 15th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.52 KB | None | 0 0
  1. --[[===========================================================================
  2. Euclidean Rhythms.lua
  3. ===========================================================================]]--
  4.  
  5. return {
  6. arguments = {
  7.   {
  8.       name = "a_steps",
  9.       value = 16,
  10.       properties = {
  11.           max = 32,
  12.           min = 1,
  13.           display_as = "integer",
  14.           zero_based = false,
  15.       },
  16.       description = "",
  17.   },
  18.   {
  19.       name = "a_pulses",
  20.       value = 6,
  21.       properties = {
  22.           max = 32,
  23.           min = 1,
  24.           display_as = "integer",
  25.           zero_based = false,
  26.       },
  27.       description = "",
  28.   },
  29.   {
  30.       name = "a_offset",
  31.       value = 0,
  32.       properties = {
  33.           max = 16,
  34.           min = -16,
  35.           display_as = "integer",
  36.           zero_based = false,
  37.       },
  38.       description = "",
  39.   },
  40.   {
  41.       name = "a_cyclelength",
  42.       value = 32,
  43.       properties = {
  44.           max = 255,
  45.           min = 0,
  46.           display_as = "integer",
  47.           zero_based = false,
  48.       },
  49.       description = "restart cycle every n number of lines",
  50.   },
  51.   {
  52.       name = "a_invert",
  53.       value = false,
  54.       properties = {
  55.           display_as = "checkbox",
  56.       },
  57.       description = "make notes become rests and vice versa",
  58.   },
  59.   {
  60.       name = "a_blanknotes",
  61.       value = false,
  62.       properties = {
  63.           display_as = "checkbox",
  64.       },
  65.       description = "do not paste rests, and paste blank lines as notes (a mute generator)",
  66.   },  
  67.   {
  68.       name = "a_pitch",
  69.       value = 36.23781479452,
  70.       properties = {
  71.           max = 119,
  72.           display_as = "note",
  73.           min = 0,
  74.       },
  75.       description = "",
  76.   },
  77.   {
  78.       name = "a_instrument",
  79.       value = 1,
  80.       properties = {
  81.           min = 0,
  82.           max = 128,
  83.           display_as = "hex",
  84.           zero_based = false,
  85.       },
  86.       description = "",
  87.   },  
  88.   {
  89.       name = "a_velocity",
  90.       value = 128,
  91.       properties = {
  92.           min = 0,
  93.           max = 128,
  94.           display_as = "hex",
  95.           zero_based = false,
  96.       },
  97.       description = "",
  98.   },
  99.   {
  100.       name = "a_column",
  101.       value = 1,
  102.       properties = {
  103.           min = 1,
  104.           max = 12,
  105.           display_as = "integer",
  106.           zero_based = false,
  107.       },
  108.       description = "",
  109.   },
  110. },
  111. presets = {
  112.   {
  113.       name = "",
  114.       a_offset = 0,
  115.       a_column = 1,
  116.       a_steps = 16,
  117.       a_pitch = 36.23781479452,
  118.       a_instrument = 1,
  119.       a_cyclelength = 32,
  120.       a_invert = false,
  121.       a_blanknotes = false,
  122.       a_velocity = 128,
  123.       a_pulses = 6,
  124.   },
  125. },
  126. data = {
  127. },
  128. options = {
  129.  color = 0x000000,
  130. },
  131. callback = [[
  132. -------------------------------------------------------------------------------
  133. -- Euclidean Rhythms
  134. -------------------------------------------------------------------------------
  135.  
  136. local generate = function(steps,pulses,offset,cyclelength,invert,blanknotes,pitch,instrument,velocity,column)
  137.   local rslt = nil
  138.   local step_size = steps/pulses
  139.   local cyclemod = (xinc%cyclelength)
  140.   local position = (cyclemod%steps)
  141.   local pulses_table = {}
  142.   for k = 0,(pulses-1) do
  143.     local pulse = math.ceil(step_size * k)+offset
  144.     table.insert(pulses_table,pulse % steps)
  145.   end
  146.   local do_output = table.find(pulses_table,position)
  147.   if invert then
  148.     do_output = not do_output
  149.   end
  150.   if do_output and not blanknotes then
  151.     xline.note_columns[column] = {
  152.       note_value = pitch,
  153.       volume_value = velocity == 0x80 and EMPTY_VOLUME_VALUE or velocity,
  154.       instrument_value = instrument
  155.     }
  156.   elseif blanknotes then
  157.     if do_output then
  158.       xline.note_columns[column] = {
  159.         volume_value = 255,
  160.         note_value = 121,
  161.         instrument_value = 255,
  162.       }
  163.     end
  164.   else
  165.     xline.note_columns[column] = {}
  166.   end
  167. end
  168. generate(args.a_steps,
  169.   args.a_pulses,
  170.   args.a_offset,
  171.   args.a_cyclelength,
  172.   args.a_invert,
  173.   args.a_blanknotes,
  174.   args.a_pitch,
  175.   args.a_instrument,
  176.   args.a_velocity,
  177.   args.a_column)
  178.  
  179. -- here are some additional generators
  180. -- (arguments are specified manually...)
  181. --generate(16,2,4,32,false,false,49,1,0x60,2)
  182. --generate(13,11,0,32,false,false,50,2,0x40,3)
  183. --generate(16,2,4,32,false,true,49,1,0x60,1) -- mute kick on snare
  184. --generate(16,5,0,32,false,true,50,3,0x40,3) -- mute hat on kick
  185. --generate(16,2,4,32,false,true,50,3,0x40,3) -- mute hat on snare
  186. --generate(14,4,1,32,false,false,51,1,0x60,4)
  187. --generate(13,5,4,32,false,false,52,1,0x60,5)
  188.  
  189.  
  190.  
  191. ]],
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement