Advertisement
Guest User

Untitled

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