Module:MOS: Difference between revisions
Bugfixes; complement code handles negative intervals; code simplifications |
Added function for making arbitrary intervals; renamed interval() to interval_from_mos() to be more descriptive |
||
| Line 273: | Line 273: | ||
---------------- INTERVAL FUNCTIONS FOR ARBITRARY INTERVALS -------------------- | ---------------- INTERVAL FUNCTIONS FOR ARBITRARY INTERVALS -------------------- | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- Create a new interval using step counts (the quantities of L's and s's). | |||
function p.interval_from_step_counts(i, j) | |||
return { ['L'] = i, ['s'] = j } | |||
end | |||
-- Compute an arbitrary mos interval as a vector of L's and s's. | -- Compute an arbitrary mos interval as a vector of L's and s's. | ||
| Line 286: | Line 291: | ||
-- EG, a perfect 4-diastep (perf. 5th) is 4 steps. Since it's the large size, | -- EG, a perfect 4-diastep (perf. 5th) is 4 steps. Since it's the large size, | ||
-- the offset is 0, but to get the diminished 5th, the offset should be -1. | -- the offset is 0, but to get the diminished 5th, the offset should be -1. | ||
function p. | function p.interval_from_mos(mos, step_count, size_offset) | ||
local size_offset = size_offset or 0 -- Optional param; defaults to large size | local size_offset = size_offset or 0 -- Optional param; defaults to large size | ||
local step_sequence = p.brightest_mode(mos) | local step_sequence = p.brightest_mode(mos) | ||
| Line 300: | Line 305: | ||
-- Compute an arbitrary mos interval (as a string of steps) as a vector of L's | -- Compute an arbitrary mos interval (as a string of steps) as a vector of L's | ||
-- and s's. This also serves as a helper function for p. | -- and s's. This also serves as a helper function for p.interval_from_mos(). | ||
-- Sequences of steps can be entered, where each step is one of five sizes: | -- Sequences of steps can be entered, where each step is one of five sizes: | ||
-- - L: large step. | -- - L: large step. | ||
| Line 385: | Line 390: | ||
local size_offset = size_offset or 0 -- Default of 0. | local size_offset = size_offset or 0 -- Default of 0. | ||
local step_count = p.interval_step_count(interval) | local step_count = p.interval_step_count(interval) | ||
local base_interval = p. | local base_interval = p.interval_from_mos(mos, step_count, 0) | ||
return interval['L'] - base_interval['L'] - size_offset | return interval['L'] - base_interval['L'] - size_offset | ||
| Line 579: | Line 584: | ||
--return p.interval_chroma_count(interval, p.new(5,2), -1) | --return p.interval_chroma_count(interval, p.new(5,2), -1) | ||
--return p.equave_reduce({['L']=-3,['s']=-1},p.new(5,2)) | --return p.equave_reduce({['L']=-3,['s']=-1},p.new(5,2)) | ||
--return p. | --return p.interval_from_mos(p.new(5,2), 4, 1) | ||
return p.interval_from_step_sequence("LLLdLLc") | --return p.interval_from_step_sequence("LLLdLLc") | ||
return p.interval_as_string({['L']=5,['s']=0}) | |||
end | end | ||
return p | return p | ||