Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modulation Matrix for AddSynth #111

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
3 changes: 3 additions & 0 deletions src/mruby-zest/example/MainWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ Widget {
elsif(type == :automate)
main_widget.extern = "/"
main_widget.content = Qml::ZynAutomation
elsif(type == :matrix)
main_widget.extern = "/part#{prt}/kit#{kit}/adpars/GlobalPar/Matrix/"
main_widget.content = Qml::ZynMat
elsif(type == :colors)
main_widget.extern = "/"
main_widget.content = Qml::ColorScheme
Expand Down
29 changes: 24 additions & 5 deletions src/mruby-zest/example/ZynAddGlobal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ Widget {

function setTab(id)
{
(0..2).each do |ch_id|
(0..3).each do |ch_id|
children[ch_id].value = (ch_id == id)
children[ch_id].damage_self
end
mapping = {0 => :amplitude,
1 => :frequency,
2 => :filter}
2 => :filter,
3 => :generic}
root.set_view_pos(:subsubview, mapping[id])
root.change_view
#db.update_values
Expand All @@ -69,12 +70,13 @@ Widget {
TabButton { label: "amplitude"; whenClick: lambda {footer.setTab(0)}; highlight_pos: :top}
TabButton { label: "frequency"; whenClick: lambda {footer.setTab(1)}; highlight_pos: :top}
TabButton { label: "filter"; whenClick: lambda {footer.setTab(2)}; highlight_pos: :top}
TabButton { label: "generic"; whenClick: lambda {footer.setTab(3)}; highlight_pos: :top}
}

function set_view()
{
subsubview = root.get_view_pos(:subsubview)
types = [:amplitude, :frequency, :filter]
types = [:amplitude, :frequency, :filter, :generic]
if(!types.include?(subsubview))
subsubview = :amplitude
root.set_view_pos(:subsubview, subsubview)
Expand All @@ -92,6 +94,8 @@ Widget {
set_freq(self.extern)
elsif(subsubview == :filter)
set_filter(self.extern)
elsif(subsubview == :generic)
set_generic(self.extern)
end

if(vis == :lfo)
Expand All @@ -110,7 +114,8 @@ Widget {
{
e_ = {:filter => "FilterLfo/",
:amplitude => "AmpLfo/",
:frequency => "FreqLfo/"}[tab]
:frequency => "FreqLfo/",
:generic => "GenericLfo1/"}[tab]
return if e_.nil?
row1.extern = ext + e_
row1.content = Qml::LfoVis
Expand All @@ -121,7 +126,8 @@ Widget {
{
e_ = {:filter => "FilterEnvelope/",
:amplitude => "AmpEnvelope/",
:frequency => "FreqEnvelope/"}[tab]
:frequency => "FreqEnvelope/",
:generic => "GenericEnvelope1/"}[tab]
return if e_.nil?
row1.extern = ext + e_
row1.content = Qml::ZynEnvEdit
Expand Down Expand Up @@ -186,6 +192,19 @@ Widget {
amp_lfo.children[0].whenClick = lambda {row1.setDataVis(:lfo, :filter)}
}

function set_generic(base)
{
footer.children[3].value = true
amp_env.extern = base + "GenericEnvelope1/"
amp_lfo.extern = base + "GenericLfo1/"
amp_env.content = Qml::ZynAmpEnv
amp_lfo.content = Qml::ZynLFO
amp_env.children[0].whenClick = lambda {row1.setDataVis(:env, :generic)}
amp_lfo.children[0].whenClick = lambda {row1.setDataVis(:lfo, :generic)}
amp_env.children[0].toggleable = base + "PGenEnvelope1Enabled"
amp_lfo.children[0].toggleable = base + "PGenLfo1Enabled"
}

function set_vis_oscilloscope()
{
row1.content = Qml::ZynAddOscilloscope
Expand Down
70 changes: 60 additions & 10 deletions src/mruby-zest/example/ZynAutomationMidiChan.qml
Original file line number Diff line number Diff line change
@@ -1,28 +1,66 @@
TextBox {
Widget {
id: midi_chan
onExtern: {
ext = midi_chan.extern

learn_ref = OSC::RemoteParam.new($remote, ext + "learning")
midi_ref = OSC::RemoteParam.new($remote, ext + "midi-cc")
nrpn_ref = OSC::RemoteParam.new($remote, ext + "midi-nrpn")
internal_ref = OSC::RemoteParam.new($remote, ext + "internal")

midi_ref.mode = true
nrpn_ref.mode = true
internal_ref.mode = true
learn_ref.mode = true

learn_ref.callback = lambda {|x| midi_chan.learning = x; update_text()}
midi_ref.callback = lambda {|x| midi_chan.cc = x; update_text()}
nrpn_ref.callback = lambda {|x| midi_chan.nrpn = x; update_text()}
internal_ref.callback = lambda {|x| midi_chan.internal = x; update_text()}

midi_chan.valueRef = [learn_ref, midi_ref, nrpn_ref, internal_ref]
}

//Workaround due to buggy nested properties
function valueRef=(value_ref)
{
@value_ref = value_ref
}

midi_chan.valueRef = [learn_ref, midi_ref]
function valueRef()
{
@value_ref
}

function onSetup(old=nil) {
@cc = nil
@nrpn = nil
@internal = nil
@learning = nil
}

function cc=(x) {@cc = x}
function nrpn=(x) {@nrpn = x}
function internal=(x) {@internal = x}
function learning=(x) {@learning = x}

function update_text() {
@cc = nil if(@cc.nil? || @cc < 0)
@nrpn = nil if(@nrpn.nil? || @nrpn < 0)
@internal = nil if(@internal.nil? || @internal < 1)
@learning = nil if(@learning.nil? || @learning < 0)

new_label = self.label;
if(@cc && !@learning)
new_label = text.label;
if(@internal && !@learning)
if(@internal==1)
new_label = "generic modulator ENV"
elsif(@internal==2)
new_label = "generic modulator LFO"
end
elsif(@cc && !@learning)
new_label = "MIDI CC #{@cc}"
elsif(@nrpn && !@learning)
new_label = "MIDI NRPN #{@nrpn}"
elsif(!@cc && @learning)
new_label = "Learning Queue #{@learning}"
elsif(@cc && @learning)
Expand All @@ -31,18 +69,30 @@ TextBox {
new_label = "Unbound"
end

intcc.extern = extern + "internal"
midicc.extern = extern + "midi-cc"
midinrpn.extern = extern + "midi-nrpn"

if(new_label != self.label)
self.label = new_label
text.label = new_label
damage_self
end

}

function onSetup(old=nil) {
@cc = nil
@learning = nil
TextBox {
id: text
}

function cc=(x) {@cc = x}
function learning=(x) {@learning = x}
Selector {
id: intcc
extern: midi_chan.extern + "internal"
}

NumEntry {id: midicc; extern: midi_chan.extern + "midi-cc"; label: "CC"}
NumEntry {id: midinrpn; extern: midi_chan.extern + "midi-nrpn"; label: "NRPN"}

function layout(l, selfBox) {
Draw::Layout::hfill(l, selfBox, children, [0.7,0.1,0.1,0.1,0.1])
}
}
5 changes: 3 additions & 2 deletions src/mruby-zest/example/ZynLFO.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Group {
function layout(l, selfBox) {
Draw::Layout::hfill(l, selfBox, children, [0.72, 0.28])
}

Col {
ParModuleRow {
id: top
Expand All @@ -31,10 +31,11 @@ Group {
Col {
Selector {extern: box.extern+"PLFOtype"}
ToggleButton { label: "sync"; extern: box.extern+"Pcontinous"}
ToggleButton { label: "midi"; extern: box.extern+"Psync"}
TextBox {}
NumEntry {
id: numerator
extern: box.extern + "numerator";
extern: box.extern + "numerator";
label: "Numerator"
whenValue: lambda {
freq.active = true if numerator.value == 0
Expand Down
19 changes: 19 additions & 0 deletions src/mruby-zest/example/ZynMat.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Widget {
id: mat
property Object valueRef: nil
h: 400
w: 800

onExtern: {
}

ZynMatTable {
extern: mat.extern
h: 300
w: 500
}

function layout(l, selfBox) {
Draw::Layout::vfill(l, selfBox, children, [1.0])
}
}
33 changes: 33 additions & 0 deletions src/mruby-zest/example/ZynMatRow.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Widget {
id: mat_row
property Int rownum: nil
property Int offset: 0

function class_name() { "matrow" }
function layout(l, selfBox) {
Draw::Layout::hpack(l, selfBox, children)
}

Text {
label: parent.sources[rownum]
}

function onSetup(old=nil)
{

parent.params.each_with_index do |param, i|
knob = Qml::Knob.new(db)
knob.type = :float
knob.extern = mat_row.extern + "location0/" + "parameter#{i}"
Qml::add_child(self, knob)
end
}

function switchLocation(location)
{

self.children[1..-1].each_with_index do |child, i|
child.extern = mat_row.extern + "location#{location}/" + "parameter#{i}"
end
}
}
100 changes: 100 additions & 0 deletions src/mruby-zest/example/ZynMatTable.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Widget {
id: mattable
property Object valueRef: nil
property Array sources: []
property Array locations: []
property Array params: []
property Array tabs: []
property Int curOff: 0
property Int oldOff: 0
property Array rows: []
property Object titleLine: nil

Widget {
id: header

function layout(l, selfBox) {
Draw::Layout::tabpack(l, selfBox, self)
}

function onSetup(old=nil) {
mattable.locations.each_with_index do |loc, id|
button = Qml::TabButton.new(db)
button.label = loc
button.value = true if (id == 0)
button.whenClick = lambda {parent.setTab(id)}
Qml::add_child(self, button)
parent.tabs << button
end
}
}

function setTab(id) {

self.tabs.each_with_index do |tab, i|
tab.value = (i==id)
tab.damage_self
end

self.rows.each do |row|
row.switchLocation(id)
row.damage_self
end
}

function onSetup(old=nil)
{
meta = OSC::RemoteMetadata.new($remote, mattable.extern + "PSources")
mattable.label = meta.short_name
mattable.tooltip = meta.tooltip
if(meta.options)
mattable.sources = []
meta.options.each do |x|
mattable.sources << x[1]
end
end

meta = OSC::RemoteMetadata.new($remote, mattable.extern + "PDestLocations")
mattable.label = meta.short_name
mattable.tooltip = meta.tooltip
if(meta.options)
mattable.locations = []
meta.options.each do |x|
mattable.locations << x[1]
end
end

meta = OSC::RemoteMetadata.new($remote, mattable.extern + "PDestParameters")
mattable.label = meta.short_name
mattable.tooltip = meta.tooltip
if(meta.options)
mattable.params = []
meta.options.each do |x|
mattable.params << x[1]
end
end

self.titleLine = Qml::ZynMatTitles.new(db)
Qml::add_child(self, titleLine)

mattable.sources.each_with_index do |src, index|
row = Qml::ZynMatRow.new(db)
row.label = src
row.rownum = index
row.extern = mattable.extern + "source#{index}/"
rows << row
Qml::add_child(self, row)
end
}

function class_name() { "mattable" }
function layout(l, selfBox) {
Draw::Layout::vpack(l, selfBox, children)
}

onExtern: {
mattable.valueRef = OSC::RemoteParam.new($remote, mattable.extern)
mattable.valueRef.mode = :options
}

}