This lets you transpose the white keys into an arbitary major or minor key. Press C# and a note to select a major key rooted on that note; D# and a note for a minor key; and F# toggles between major and minor.
desc: white key scale mapper jda
@init
function note(offset,channel,pitch,velocity) (
( velocity == 0 ) ? (
midisend(offset, 0x80 | channel,pitch,0);
) : (
midisend(offset, 0x90 | channel,pitch,velocity);
);
);
function whitekey(offset,channel,pitch,velocity) (
key1 = 1;
pc = pitch % 12;
oct = floor(pitch / 12);
( select == 1 ) ? (
( isminor == 0 ) ? (
root = pc;
select = 0;
) : (
root = (pc + 3) % 12;
select = 0;
);
) : (
( isminor == 1 ) ? (
( pc == 4 || pc == 9 || pc == 11 ) ? (
pc -= 1;
);
);
op = root + pc + (12*oct);
note(offset,channel,op,velocity);
)
);
function blackkey(offset,channel,pitch,velocity) (
key1 = 2;
pc = pitch % 12;
( velocity > 0 ) ? (
( pc == 1 ) ? (
select = 1;
isminor = 0;
) : ( pc == 3 ) ? (
select = 1;
isminor = 1;
) : ( pc == 6 ) ? (
isminor = 1 - isminor;
);
);
);
function key(offset,channel,pitch,velocity) (
( pitch == 21 ) ? (
key1 = 3;
( velocity > 0 ) ? (
bypass = 1 - bypass;
)
) : ( bypass == 0 ) ? (
key1 = 4;
pc = pitch % 12;
oct = floor(pitch / 12);
( pc == 0 || pc == 2 || pc == 4 || pc == 5 || pc == 7 || pc == 9 || pc == 11 ) ? (
whitekey(offset,channel,pitch,velocity);
) : (
blackkey(offset,channel,pitch,velocity);
);
) : (
note(offset,channel,pitch,velocity);
);
);
root = 0;
select = 0; // next key determines root == 1
isminor = 0; // major = 0, minor = 1
bypass = 0; // bypass > 0
@block
while(midirecv(offset,msg1,msg2,msg3)) (
status = msg1 & 0xF0;
channel = msg1 & 0x0F;
(status == 0x90) ? (
st = 1;
key(offset,channel,msg2,msg3);
) : (status == 0x80) ? (
st = 2;
key(offset,channel,msg2,0);
) : (
st = 3;
midisend(offset,msg1,msg2,msg3);
)
);
Scale Mapper 2
This one does one of four scales: major, natural minor, harmonic minor, ascending melodic minor. (The desceding melodic minor is the same as the natural/relative minor.)
desc: white key scale mapper 2 jda
// also does harmonic and melodic minors
@init
scale = 100;
scale_n = 0;
pc_to_degree = 12;
pc_to_degree[0] = 0;
pc_to_degree[1] = 0;
pc_to_degree[2] = 1;
pc_to_degree[3] = 0;
pc_to_degree[4] = 2;
pc_to_degree[5] = 3;
pc_to_degree[6] = 0;
pc_to_degree[7] = 4;
pc_to_degree[8] = 0;
pc_to_degree[9] = 5;
pc_to_degree[10] = 0;
pc_to_degree[11] = 6;
scale_base = 100; // major
scale_base[0] = 0;
scale_base[1] = 2;
scale_base[2] = 4;
scale_base[3] = 5;
scale_base[4] = 7;
scale_base[5] = 9;
scale_base[6] = 11;
scale_base = 200; // rel minor
scale_base[0] = 0;
scale_base[1] = 2;
scale_base[2] = 3;
scale_base[3] = 5;
scale_base[4] = 7;
scale_base[5] = 8;
scale_base[6] = 10;
scale_base = 300; // h minor
scale_base[0] = 0;
scale_base[1] = 2;
scale_base[2] = 3;
scale_base[3] = 5;
scale_base[4] = 7;
scale_base[5] = 8;
scale_base[6] = 11;
scale_base = 400; // asc m minor
scale_base[0] = 0;
scale_base[1] = 2;
scale_base[2] = 3;
scale_base[3] = 5;
scale_base[4] = 7;
scale_base[5] = 9;
scale_base[6] = 11;
function pc_in_scale(s,x) (
scale[s*100+x];
);
function note(offset,channel,pitch,velocity) (
( velocity == 0 ) ? (
midisend(offset, 0x80 | channel,pitch,0);
) : (
midisend(offset, 0x90 | channel,pitch,velocity);
);
);
function whitekey(offset,channel,pitch,velocity) (
key1 = 1;
pc = pitch % 12;
( select == 1 ) ? (
root = pc;
select = 0;
) : (
deg = pc_to_degree[pc];
oct = floor(pitch / 12);
tt = scale_n;
npitch = oct*12 + root + pc_in_scale(scale_n,deg);
note(offset,channel,npitch,velocity);
)
);
function blackkey(offset,channel,pitch,velocity) (
key1 = 2;
pc = pitch % 12;
( velocity > 0 ) ? (
( pc == 1 ) ? (
select = 1;
scale_n = 0;
) : ( pc == 3 ) ? (
select = 1;
scale_n = 1;
) : ( pc == 6 ) ? (
select = 1;
scale_n = 2;
) : ( pc == 8 ) ? (
select = 1;
scale_n = 3;
) : ( pc == 10 ) ? (
scale_n = (scale_n + 1) % 4;
);
);
);
function key(offset,channel,pitch,velocity) (
( pitch == 21 ) ? (
key1 = 3;
( velocity > 0 ) ? (
bypass = 1 - bypass;
)
) : ( bypass == 0 ) ? (
key1 = 4;
pc = pitch % 12;
oct = floor(pitch / 12);
( pc == 0 || pc == 2 || pc == 4 || pc == 5 || pc == 7 || pc == 9 || pc == 11 ) ? (
whitekey(offset,channel,pitch,velocity);
) : (
blackkey(offset,channel,pitch,velocity);
);
) : (
note(offset,channel,pitch,velocity);
);
);
root = 0;
select = 0; // next key determines root == 1
isminor = 0; // major = 0, minor = 1
bypass = 0; // bypass > 0
@block
while(midirecv(offset,msg1,msg2,msg3)) (
status = msg1 & 0xF0;
channel = msg1 & 0x0F;
(status == 0x90) ? (
st = 1;
key(offset,channel,msg2,msg3);
) : (status == 0x80) ? (
st = 2;
key(offset,channel,msg2,0);
) : (
st = 3;
midisend(offset,msg1,msg2,msg3);
)
);