-- ここにボタン押下時動作する関数を定義 -- [string, 'C-0' - 'G-9', 'OFF' or '---'] function note_it (note) if renoise.song().transport.edit_mode == true then renoise.song().selected_note_column.note_string = note print (note) else return nil end end -- あるtableに対応した新たな空の多重tableを用意する関数 -- 多次元配列の用意のため。 function set_ini(tbl) local new ={} for i,val in pairs(tbl) do if type(val) ~= "table" then new[i] = nil else new[i] = set_ini(val) end end return new end -- 以下、表、行、段の3次元で表されるデータに合わせて、ボタンを配置します。 -- -- 50音データtable。 -- 例:tbl_ons[1][2][3]は「く」。 local tbl_ons = { { {"あ","い","う","え","お"}, {"か","き","く","け","こ"}, {"さ","し","す","せ","そ"}, {"た","ち","つ","て","と"}, {"な","に","ぬ","ね","の"}, {"は","ひ","ふ","へ","ほ"}, {"ま","み","む","め","も"}, {"や","","ゆ","いぇ","よ"}, {"ら","り","る","れ","ろ"}, {"わ","ん","OFF"} }, { {"が","ぎ","ぐ","げ","ご"}, {"ざ","じ","ず","ぜ","ぞ"}, {"だ","でぃ","どぅ","で","ど"}, {"ば","び","ぶ","べ","ぼ"}, {"ぱ","ぴ","ぷ","ぺ","ぽ"} } } -- 音階データ。 -- 'C-0' - 'G-9', 'OFF' or '---' -- 上のtbl_onsに合わせる必要がある。 local tbl_notes = { { {"C-4","C#4","D-4","D#4","E-4"}, {"F-4","F#4","G-4","G#4","A-4"}, {"C-5","C#5","D-5","D#5","E-5"}, {"F-5","F#5","G-5","G#5","A-5"}, {"C-6","C#6","D-6","D#6","E-6"}, {"F-6","F#6","G-6","G#6","A-6"}, {"C-7","C#7","D-7","D#7","E-7"}, {"C-8","---","C#8","D-8","D#8",}, {"F-7","F#7","G-7","G#7","A-7"}, {"E-8","F-8","OFF"} }, { {"F-1","F#1","G-1","G#1","A-1"}, {"C-2","C#2","D-2","D#2","E-2"}, {"F-2","F#2","G-2","G#2","A-2"}, {"C-3","C#3","D-3","D#3","E-3"}, {"F-3","F#3","G-3","G#3","A-3"} } } -- 以下、tableの長さの取得。#でなくtable.maxnを使う事。 -- 表の数。入れ子になったtbl_onsの中の最上層のtableの数。 function hmax() return table.maxn(tbl_ons) end -- 行の数。h番目の表の中の行数。 function gmax(h) return table.maxn(tbl_ons[h]) end -- 段の数。h番目の表中のg番目の行の中の音数。 function dmax(h,g) return table.maxn(tbl_ons[h][g]) end -- GUI立ち上げ用関数 function test_50on_mini () local vb = renoise.ViewBuilder() -- tbl_onsに合わせて、多次元の配列用意。 -- s0は全体、s1は表の集まり、s2は行の集まり、s3は音の集まり、にしようとしてる。 -- 例:s1[1]は1番目の表。s2[1][2]は,か行。s3[1][2][3]は「く」のボタン。 -- 添付図参照。 -- その前に初期化。 -- 面倒なんでs0以外全部同じ次元で。 local s0 local s1 = set_ini(tbl_ons) local s2 = set_ini(tbl_ons) local s3 = set_ini(tbl_ons) -- s3にボタンを入れていく。 for h = 1,hmax() do for g = 1,gmax(h) do for d = 1,dmax(h,g) do s3[h][g][d] = vb:button ({ width = 35, height = 30, text = tbl_ons[h][g][d], notifier = function() note_it(tbl_notes[h][g][d]) end }) end end end -- s2にs3の要素を横に並べた塊を入れていく。 for h = 1,hmax() do for g = 1,gmax(h) do s2[h][g] = vb:row(s3[h][g]) end end -- s1にs2の要素を縦に並べた塊を入れていく。 for h = 1,hmax() do s1[h] = vb:column(s2[h]) end -- s0にs1の要素を横に並べた塊を入れて、全体とする。 -- s0 = vb:row(s1) -- s1の要素(表)の間をあけたい時は以下のように -- spacingを挟んだり。 s0 = vb:row{s1[1], spacing =12, s1[2]} -- 表示。 renoise.app():show_custom_dialog("test 50on" ,s0) end -- 実行 test_50on_mini ()