|
|
| (8 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| -- EDO Approximations Module
| | pailiaq is an electronic music producer who refuses to continue writing about himself in the third person. I make psychedelic glitch hop, dubstep and downtempo music, often with a microtonal twist. I teach music production and sound design and have worked as a professional audio systems engineer, running psychoacoustics experiments and researched multichannel surround sound audio. |
| -- Calculates EDO approximations for just intervals
| |
| -- Usage: {{#invoke:EDO_Approximations|main|interval=3/2|tolerance=9|min_edo=10|max_edo=60}}
| |
|
| |
|
| local p = {}
| | My special interests are in dual fifth tunings, particularly 23edo as a result of the TOTYW2025 effort in the XA discord to explore 23edo. |
|
| |
|
| -- Convert a frequency ratio to cents
| | I have a [https://www.youtube.com/@pailiaq youtube channel] where I livestream music production, teach sound design, and explore xen theory. |
| local function cents(ratio)
| |
| return 1200 * math.log(ratio, 2)
| |
| end
| |
|
| |
|
| -- Parse a ratio string like '3/2' into a number
| | == Music n Socials== |
| local function parse_ratio(ratio_str)
| |
| local num, denom = ratio_str:match("^(%d+)/(%d+)$")
| |
| if not num or not denom then
| |
| return nil
| |
| end
| |
| return tonumber(num) / tonumber(denom)
| |
| end
| |
|
| |
|
| -- Find the best approximation of an interval in a given EDO
| | [https://soundcloud.com/pailiaq Soundcloud] |
| local function find_best_approximation(ratio_cents, edo)
| |
| local edostep = 1200 / edo
| |
| -- Find the nearest step
| |
| local best_step = math.floor(ratio_cents / edostep + 0.5)
| |
| local approximation_cents = best_step * edostep
| |
| local absolute_error = approximation_cents - ratio_cents
| |
| local relative_error = (absolute_error / edostep) * 100
| |
|
| |
|
| return best_step, absolute_error, relative_error
| | [https://pailiaq.bandcamp.com/ Bandcamp] |
| end
| |
|
| |
|
| -- Calculate all EDO approximations within tolerance for a given ratio
| | [https://open.spotify.com/artist/202f1kyy3iB15e5ol3b7NG?si=AeYrFmeGSyOsXbgRSSU6vw Spotify] |
| local function calculate_edo_approximations(ratio, tolerance, min_edo, max_edo)
| |
| local ratio_cents = cents(ratio)
| |
| local results = {}
| |
|
| |
|
| for edo = min_edo, max_edo do
| | [https://tidal.com/artist/16403977/u Tidal] |
| local steps, abs_error, rel_error = find_best_approximation(ratio_cents, edo)
| |
|
| |
|
| if math.abs(rel_error) <= tolerance then
| | [https://www.instagram.com/pailiaq/ Instagram] |
| table.insert(results, {
| |
| edo = edo,
| |
| steps = steps,
| |
| abs_error = abs_error,
| |
| rel_error = rel_error
| |
| })
| |
| end
| |
| end
| |
|
| |
|
| return results
| | [https://www.twitch.tv/pailiaq Twitch] |
| end
| |
|
| |
|
| -- Format a number with sign and 2 decimal places
| | == Xen Tutorials == |
| local function format_error(value)
| |
| if value >= 0 then
| |
| return string.format("+%.2f", value)
| |
| else
| |
| return string.format("%.2f", value)
| |
| end
| |
| end
| |
|
| |
|
| -- Main function to generate the wikitable
| | [https://www.youtube.com/watch?v=tU052pvAfuc| Intro to Microtonal and Xenharmonic Theory ] |
| function p.main(frame)
| |
| -- Get parameters from template invocation
| |
| local args = frame.args
| |
| local interval_str = args.interval or args[1]
| |
| local tolerance = tonumber(args.tolerance) or 9.0
| |
| local min_edo = tonumber(args.min_edo) or 10
| |
| local max_edo = tonumber(args.max_edo) or 60
| |
|
| |
|
| -- Validate and parse interval
| | [https://www.youtube.com/watch?v=cwjbhD2fdZ4 Ableton Microtuner & Sound Design Tutorial] |
| if not interval_str then
| |
| return "Error: No interval specified"
| |
| end
| |
|
| |
|
| local ratio = parse_ratio(interval_str)
| | [https://www.youtube.com/watch?v=DHxp2CqE0Sc& 'Bleak' 26edo Track breakdown] |
| if not ratio then
| |
| return "Error: Invalid interval format (use format like '3/2')"
| |
| end
| |
|
| |
|
| -- Calculate approximations
| | == Contributions: == |
| local results = calculate_edo_approximations(ratio, tolerance, min_edo, max_edo)
| |
|
| |
|
| if #results == 0 then
| | === Articles === |
| return "No EDOs found within tolerance of " .. tolerance .. "%"
| |
| end
| |
|
| |
|
| -- Build the wikitable
| | [[Hobbled Scales]] |
| local output = {}
| |
| table.insert(output, '{| class="wikitable"')
| |
| table.insert(output, '|+ EDO Approximations for ' .. interval_str)
| |
| table.insert(output, '|-')
| |
| table.insert(output, '! EDO !! Step size !! Absolute Error ([[Cent|¢]]) !! [[Relative_interval_error|Relative Error]] ([[Relative_cent|%]])')
| |
|
| |
|
| for _, result in ipairs(results) do
| | [[Phith root of phi]] |
| local edo_link = string.format("[[%dedo|%d]]", result.edo, result.edo)
| |
| local step_size = string.format("%d\\%d", result.steps, result.edo)
| |
| local abs_err = format_error(result.abs_error)
| |
| local rel_err = format_error(result.rel_error)
| |
|
| |
|
| table.insert(output, '|-')
| | [[User:Pailiaq/Tritone substitution]] |
| table.insert(output, string.format('| %s || %s || %s || %s', edo_link, step_size, abs_err, rel_err))
| |
| end
| |
|
| |
|
| table.insert(output, '|}')
| | === Modules/Templates/Code === |
|
| |
|
| return table.concat(output, '\n')
| | <nowiki/>[[Module:Interval edo approximation]] |
| end
| |
|
| |
|
| return p
| | <nowiki/>[[Template:Interval edo approximation]] |
| | |
| | Chord modules |
| | |
| | [[Template:Chord edo approximation]] |
| | |
| | [[Module:Chord edo approximation]] |
| | |
| | https://en.xen.wiki/w/User:Pailiaq/common.js |
| | |
| | https://en.xen.wiki/w/User:Pailiaq/common.css |
pailiaq is an electronic music producer who refuses to continue writing about himself in the third person. I make psychedelic glitch hop, dubstep and downtempo music, often with a microtonal twist. I teach music production and sound design and have worked as a professional audio systems engineer, running psychoacoustics experiments and researched multichannel surround sound audio.
My special interests are in dual fifth tunings, particularly 23edo as a result of the TOTYW2025 effort in the XA discord to explore 23edo.
I have a youtube channel where I livestream music production, teach sound design, and explore xen theory.
Music n Socials
Soundcloud
Bandcamp
Spotify
Tidal
Instagram
Twitch
Xen Tutorials
Intro to Microtonal and Xenharmonic Theory
Ableton Microtuner & Sound Design Tutorial
'Bleak' 26edo Track breakdown
Contributions:
Articles
Hobbled Scales
Phith root of phi
User:Pailiaq/Tritone substitution
Modules/Templates/Code
Module:Interval edo approximation
Template:Interval edo approximation
Chord modules
Template:Chord edo approximation
Module:Chord edo approximation
https://en.xen.wiki/w/User:Pailiaq/common.js
https://en.xen.wiki/w/User:Pailiaq/common.css