Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function make_beat_wave(params)
- -- triangle wave - n results in the section above zero having width 1-n
- -- so triangle - (1-w) will give us width w
- -- time_wave_input is doubled and offset to put a peak on every beat.
- local triangle= {'triangle', {'+', .5, {'*', 2, params.time}}}
- local above_zero_is_width= {'-', triangle, {'-', 1, params.width}}
- -- height above zero needs to be 1, but is currently w.
- -- <result> / w will make the height 1
- local height_is_one= {'/', above_zero_is_width, params.width}
- -- then max is used to clip off the parts of the wave that are below
- -- zero, and we have a wave that is flat between peaks.
- local beat_wave= {'max', 0, height_is_one}
- local curved_wave= {'^', beat_wave, 2}
- return curved_wave
- end
- local function asymmetric_scaler(scale, time)
- return {'+', scale-1, {'*', scale, {'square', time}}}
- end
- local function shift_and_scale(thing, old_low, old_high, low, high)
- local old_size= old_high - old_low
- local new_size= high - low
- local scale_factor= new_size / old_size;
- return {'+', low, {'*', scale_factor, {'-', thing, old_low}}}
- end
- local custom_mods= {
- pound= {
- target= 'note_pos_x',
- equation= function(params, ops)
- local curved_wave= make_beat_wave{
- time= params.time,
- width= {'-', 1, make_beat_wave{time= params.time, width= .5}},
- }
- local inverter= {'square', {'+', .5, params.time}}
- local time_beat_factor= {'*', curved_wave, 20, inverter}
- -- On even beats, period will be 1 at the start of the animation,
- -- then go to 0 as the animation peaks.
- -- On odd beats, period will be 1 at the start, then go to 16 as the
- -- animation peaks.
- local period= {
- '-', 1,
- {'*', -1, asymmetric_scaler(17, {'+', .5, params.time}),
- make_beat_wave{time= params.time, width= .5},
- }
- }
- local note_beat_factor= check_op{
- ops.wave,
- {'+', params.wave_offset,
- pi_div{'/',
- params.note_input,
- {'*', period, params.period},
- },
- },
- }
- local time_and_beat= check_op{ops.factor, time_beat_factor, note_beat_factor}
- local equation= check_op{ops.level, params.level, time_and_beat}
- return equation
- end,
- params= {
- level= 1, note_input= 'y_offset', wave_offset= .5, period= 15,
- time= 'music_beat', width= .5,
- },
- ops= {
- level= '*', factor= '*', wave= 'sin',
- },
- },
- }
- local pound_params= {
- level= 4,
- -- slowing down time makes the animation visible.
- -- Applying a beat wave to the time slowdown makes it crazy.
- time= {mult= shift_and_scale(make_beat_wave{time= {'*', 'music_beat', .0625}, width= .5}, 0, 1, .25, 1)},
- note_input= {'^', 'y_offset', .75},
- wave_offset= {
- m= {'triangle', 'music_beat'},
- a= shift_and_scale(make_beat_wave{time= {'*', 'music_beat', .125}, width= .5}, 0, 1, -.5, 1.5)},
- }
- local mods= {
- columns= 4,
- {column= "all", start= 0, length= 256, 'pound', pound_params},
- }
- return mods, custom_mods
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement