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

internal automation mod source #77

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 24 additions & 5 deletions src/mruby-zest/example/ZynAddGlobal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,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 @@ -68,12 +69,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 @@ -91,6 +93,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 @@ -109,7 +113,8 @@ Widget {
{
e_ = {:filter => "FilterLfo/",
:amplitude => "AmpLfo/",
:frequency => "FreqLfo/"}[tab]
:frequency => "FreqLfo/",
:generic => "GenericLfo/"}[tab]
return if e_.nil?
row1.extern = ext + e_
row1.content = Qml::LfoVis
Expand All @@ -120,7 +125,8 @@ Widget {
{
e_ = {:filter => "FilterEnvelope/",
:amplitude => "AmpEnvelope/",
:frequency => "FreqEnvelope/"}[tab]
:frequency => "FreqEnvelope/",
:generic => "GenericEnvelope/"}[tab]
return if e_.nil?
row1.extern = ext + e_
row1.content = Qml::ZynEnvEdit
Expand Down Expand Up @@ -185,6 +191,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 + "GenericEnvelope/"
amp_lfo.extern = base + "GenericLfo/"
amp_env.content = Qml::ZynFilterEnv
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 + "PGenEnvelopeEnabled"
amp_lfo.children[0].toggleable = base + "PGenLfoEnabled"
}

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