Skip to content

Instantly share code, notes, and snippets.

@andr-ew
Created March 8, 2021 18:04
Show Gist options
  • Save andr-ew/b750fe981938990b79976753d713b7e8 to your computer and use it in GitHub Desktop.
Save andr-ew/b750fe981938990b79976753d713b7e8 to your computer and use it in GitHub Desktop.
norns scale data
local root, et = 440, 12
local tonics = {
['D#'] = -6,
['C#'] = -8,
['A'] = 0,
['A#'] = 1,
['G'] = -2,
['B'] = 2,
['G#'] = -1,
['F#'] = -3,
['C'] = -9,
['D'] = -7,
['E'] = -5,
['F'] = -4,
}
local intervals = {
['In Sen Pou'] = { 0, 1, 5, 2, 8, 12, },
['Gagaku Rittsu Sen Pou'] = { 0, 2, 5, 7, 9, 10, 12, },
['Neapolitan Minor'] = { 0, 1, 3, 5, 7, 8, 11, 12, },
['Whole Tone'] = { 0, 2, 4, 6, 8, 10, 12, },
['Balinese'] = { 0, 1, 3, 7, 8, 12, },
['Harmonic Major'] = { 0, 2, 4, 5, 7, 8, 11, 12, },
['Dorian'] = { 0, 2, 3, 5, 7, 9, 10, 12, },
['Hungarian Major'] = { 0, 3, 4, 6, 7, 9, 10, 12, },
['Natural Minor'] = { 0, 2, 3, 5, 7, 8, 10, 12, },
['Altered Scale'] = { 0, 1, 3, 4, 6, 8, 10, 12, },
['Major'] = { 0, 2, 4, 5, 7, 9, 11, 12, },
['Minor Pentatonic'] = { 0, 3, 5, 7, 10, 12, },
['Hungarian Minor'] = { 0, 2, 3, 6, 7, 8, 11, 12, },
['Locrian'] = { 0, 1, 3, 5, 6, 8, 10, 12, },
['Leading Whole Tone'] = { 0, 2, 4, 6, 8, 10, 11, 12, },
['Melodic Minor'] = { 0, 2, 3, 5, 7, 9, 11, 12, },
['Major Bebop'] = { 0, 2, 4, 5, 7, 8, 9, 11, 12, },
['Blues Scale'] = { 0, 3, 5, 6, 7, 10, 12, },
['Six Tone Symmetrical'] = { 0, 1, 4, 5, 8, 9, 11, 12, },
['Lydian Minor'] = { 0, 2, 4, 6, 7, 8, 10, 12, },
['Overtone'] = { 0, 2, 4, 6, 7, 9, 10, 12, },
['Major Locrian'] = { 0, 2, 4, 5, 6, 8, 10, 12, },
['Okinawa'] = { 0, 4, 5, 7, 11, 12, },
['Eight Tone Spanish'] = { 0, 1, 3, 4, 5, 6, 8, 10, 12, },
['Major Pentatonic'] = { 0, 2, 4, 7, 9, 12, },
['Lydian'] = { 0, 2, 4, 6, 7, 9, 11, 12, },
['Enigmatic'] = { 0, 1, 4, 6, 8, 10, 11, 12, },
['Double Harmonic'] = { 0, 1, 4, 5, 7, 8, 11, 12, },
['Phrygian'] = { 0, 1, 3, 5, 7, 8, 10, 12, },
['Mixolydian'] = { 0, 2, 4, 5, 7, 9, 10, 12, },
['Oriental'] = { 0, 1, 4, 5, 6, 9, 10, 12, },
['Neapolitan Major'] = { 0, 1, 3, 5, 7, 9, 11, 12, },
['East Indian Purvi'] = { 0, 1, 4, 6, 7, 8, 11, 12, },
['Persian'] = { 0, 1, 4, 5, 6, 8, 11, 12, },
['Prometheus'] = { 0, 2, 4, 6, 9, 10, 12, },
['Chromatic'] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, },
['Dorian Bebop'] = { 0, 2, 3, 4, 5, 7, 9, 10, 12, },
['Mixolydian Bebop'] = { 0, 2, 4, 5, 7, 9, 10, 11, 12, },
['Diminished Half Whole'] = { 0, 1, 3, 4, 6, 7, 9, 10, 12, },
['Harmonic Minor'] = { 0, 2, 3, 5, 7, 8, 11, 12, },
['Diminished Whole Half'] = { 0, 2, 3, 5, 6, 8, 9, 11, 12, },
}
return root, et, tonics, intervals
mu = require 'musicutil'
local function serialize(o, f, skip, dof, types, itab)
itab = itab or ""
local ntab = itab .. " "
if type(o) == "table" then
f("{")
local first = true
if #o then
f(" ")
for i,v in ipairs(o) do
if type(v) == "string" or type(v) == "number" then
serialize(v, f, skip, dof, types, ntab)
f(", ")
elseif type(v) == "table" then
if first then
f("\n")
first = false
end
f(ntab)
if v.serialize then v:serialize(f, skip, dof, types, ntab)
else serialize(v, f, skip, dof, types, ntab) end
f(",\n")
end
end
end
first = true
for k,v in pairs(o) do
if type(k) == 'string' then
if type(v) == 'function' then
if dof then
if first then
f("\n")
first = false
end
f(ntab .. k .. " = function() end")
f(",\n")
end
else
if first then
f("\n")
first = false
end
f(ntab .. "['" .. k .. "'] = ")
if type(v) == "table" and v.serialize then v:serialize(f, skip, dof, types, ntab)
else serialize(v, f, skip, dof, types, ntab) end
f(",\n")
end
end
end
if not first then f(itab) end
f("}")
else
f(o)
end
end
tonics = {}
for i,v in ipairs(mu.NOTE_NAMES) do
tonics[v] = -10 + i
end
intervals = {}
for i,v in ipairs(mu.SCALES) do
intervals[v.name] = v.intervals
end
name = name or norns.state.shortname
local filename = norns.state.data .. name .. ".lua"
local f, err = io.open(filename, "wb")
if err then
print("err: ")
print(err)
return
end
f:write('local root, et = 440, 12')
f:write("\n\n")
f:write("local tonics = ")
serialize(tonics, function(st)
f:write(st)
end)
f:write("\n\n")
f:write("local intervals = ")
serialize(intervals, function(st)
f:write(st)
end)
f:write("\n\n")
f:write("return root, et, tonics, intervals")
f:close()
@andr-ew
Copy link
Author

andr-ew commented May 5, 2021

some less ET-defaulting syntax

temperament = 'equal' --use 'just' for just intonation
tones = 12
center = 440 --use 432 for spiritual healing

@andr-ew
Copy link
Author

andr-ew commented May 5, 2021

meh I'm considering switching to YAML honestly

https://github.com/api7/lua-tinyyaml

@andr-ew
Copy link
Author

andr-ew commented May 5, 2021

ack --- JI is going to be slightly annoying in YAML since fractions aren't allowed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment