Advertisement
Guest User

Untitled

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