Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[===========================================================================
- Euclidean Rhythms.lua
- ===========================================================================]]--
- return {
- arguments = {
- {
- name = "a_steps",
- value = 16,
- properties = {
- max = 32,
- min = 1,
- display_as = "integer",
- zero_based = false,
- },
- description = "",
- },
- {
- name = "a_pulses",
- value = 6,
- properties = {
- max = 32,
- min = 1,
- display_as = "integer",
- zero_based = false,
- },
- description = "",
- },
- {
- name = "a_offset",
- value = 0,
- properties = {
- max = 16,
- min = -16,
- display_as = "integer",
- zero_based = false,
- },
- description = "",
- },
- {
- name = "a_cyclelength",
- value = 32,
- properties = {
- max = 255,
- min = 0,
- display_as = "integer",
- zero_based = false,
- },
- description = "restart cycle every n number of lines",
- },
- {
- name = "a_invert",
- value = false,
- properties = {
- display_as = "checkbox",
- },
- description = "make notes become rests and vice versa",
- },
- {
- name = "a_blanknotes",
- value = false,
- properties = {
- display_as = "checkbox",
- },
- description = "do not paste rests, and paste blank lines as notes (a mute generator)",
- },
- {
- name = "a_pitch",
- value = 36.23781479452,
- properties = {
- max = 119,
- display_as = "note",
- min = 0,
- },
- description = "",
- },
- {
- name = "a_instrument",
- value = 1,
- properties = {
- min = 0,
- max = 128,
- display_as = "hex",
- zero_based = false,
- },
- description = "",
- },
- {
- name = "a_velocity",
- value = 128,
- properties = {
- min = 0,
- max = 128,
- display_as = "hex",
- zero_based = false,
- },
- description = "",
- },
- {
- name = "a_column",
- value = 1,
- properties = {
- min = 1,
- max = 12,
- display_as = "integer",
- zero_based = false,
- },
- description = "",
- },
- },
- presets = {
- {
- name = "",
- a_offset = 0,
- a_column = 1,
- a_steps = 16,
- a_pitch = 36.23781479452,
- a_instrument = 1,
- a_cyclelength = 32,
- a_invert = false,
- a_blanknotes = false,
- a_velocity = 128,
- a_pulses = 6,
- },
- },
- data = {
- },
- options = {
- color = 0x000000,
- },
- callback = [[
- -------------------------------------------------------------------------------
- -- Euclidean Rhythms
- -------------------------------------------------------------------------------
- local generate = function(steps,pulses,offset,cyclelength,invert,blanknotes,pitch,instrument,velocity,column)
- local rslt = nil
- local step_size = steps/pulses
- local cyclemod = (xinc%cyclelength)
- local position = (cyclemod%steps)
- local pulses_table = {}
- for k = 0,(pulses-1) do
- local pulse = math.ceil(step_size * k)+offset
- table.insert(pulses_table,pulse % steps)
- end
- local do_output = table.find(pulses_table,position)
- if invert then
- do_output = not do_output
- end
- if do_output and not blanknotes then
- xline.note_columns[column] = {
- note_value = pitch,
- volume_value = velocity == 0x80 and EMPTY_VOLUME_VALUE or velocity,
- instrument_value = instrument
- }
- elseif blanknotes then
- if do_output then
- xline.note_columns[column] = {
- volume_value = 255,
- note_value = 121,
- instrument_value = 255,
- }
- end
- else
- xline.note_columns[column] = {}
- end
- end
- generate(args.a_steps,
- args.a_pulses,
- args.a_offset,
- args.a_cyclelength,
- args.a_invert,
- args.a_blanknotes,
- args.a_pitch,
- args.a_instrument,
- args.a_velocity,
- args.a_column)
- -- here are some additional generators
- -- (arguments are specified manually...)
- --generate(16,2,4,32,false,false,49,1,0x60,2)
- --generate(13,11,0,32,false,false,50,2,0x40,3)
- --generate(16,2,4,32,false,true,49,1,0x60,1) -- mute kick on snare
- --generate(16,5,0,32,false,true,50,3,0x40,3) -- mute hat on kick
- --generate(16,2,4,32,false,true,50,3,0x40,3) -- mute hat on snare
- --generate(14,4,1,32,false,false,51,1,0x60,4)
- --generate(13,5,4,32,false,false,52,1,0x60,5)
- ]],
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement