IF3Si/scd/gui_granul.scd

590 lines
15 KiB
Plaintext

/*
This file is part of "Interface Fractures III - Silicon".
Copyright (c) 2015 Luka Prinčič, All rights reserved.
This program is free software distributed under
GNU General Public Licence. See COPYING for more info.
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
gui_granul.scd - takes care of all GUI elements under
the 'granul' tab...
********************************************************** */
~tab_views[~tab_names.at("granul")].layout = HLayout(
VLayout( // left half starts here
//~tab_views[~tab_names.at("granul")].layout.add(nil);
//~granSynth1 = View.new(~tab_views[~tab_names.at("granul")]);
//~granSynth1.background = Color.gray(0.5);
//~granSynth1.layout = HLayout( // vert. layout:
// Synth starts here --------------------------------------------------------------------
HLayout(
VLayout(
StaticText().string_("GRANULATOR"),
Button()
.states_([
["OFF", Color.gray(0.2), Color.gray(0.8)],
["ON", Color.gray(0.8), Color.grey(0.2)] ])
.mouseDownAction_({
arg state;
state.value.postln;
if (state.value == 0) {
~granSynth = Synth(\Granny, [\bufnum, b]);
} {
~granSynth.free;
}
})
.minHeight_(70)
.minWidth_(70),
nil
),
VLayout(
PopUpMenu().items_(["buffer1","file2","file3"]).font_(Font("Sans",20)),
StaticText().string_("Filter vs. Position"),
Slider2D()
.x_(0.05)
.y_(0.05)
.action_({ arg slider;
~granSynth.set(\pos, slider.x);
~granSynth.set(\lpfFreq, slider.y.value.linexp(0,1,30,20000,nil))}),
StaticText().string_("Position variation"),
Slider(nil,Rect(0,0,50,10))
.minHeight_(20)
.thumbSize_(50)
.action_({ arg posvar;
posvar = posvar.value;
~granSynth.set(\posvar, posvar.value);
})
),
VLayout(
StaticText().string_("Frequency of grains"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
.action_({ arg freq;
freq = ((freq.value * 200) + 1).asInt;
~granSynth.set(\freq, freq.value); freq.value.postln;
~nbf.value_(freq)}),
VLayout(nil,
~nbf = NumberBox(nil,Rect(0,0,1,1))
.font_(Font("Sans",20))
.maxWidth_(50)
.minHeight_(30);
)
),
HLayout(
StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg fvar;
fvar = fvar.value * 2;
~granSynth.set(\fvar, fvar.value);
})
),
nil,
StaticText().string_("Duration of grains"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
.action_({ arg dur;
dur = dur.value;
~granSynth.set(\dur, dur.value);
~nbd.value_((dur.value * 100).asInt); }),
VLayout(nil,
~nbd = NumberBox(nil,Rect(0,0,1,1))
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
),
HLayout(StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg durvar;
durvar = durvar.value * 2;
~granSynth.set(\durvar, durvar.value);
})
),
nil,
StaticText().string_("Pitch"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
.action_({ arg pitch;
pitch = pitch.value * 2;
~granSynth.set(\pitch, pitch.value);
~nbp.value_(pitch.value); }),
VLayout(nil,
~nbp = NumberBox()
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
),
HLayout(StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg pitchvar;
pitchvar = pitchvar.value;
~granSynth.set(\pitchvar, pitchvar.value);
})
),
nil,
StaticText().string_("Width (Stereo)"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
.action_({ arg width;
width = width.value;
~granSynth.set(\width, width.value);
~nbw.value_(width.value);
}),
VLayout(nil,
~nbw = NumberBox()
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
)
),
VLayout(
StaticText().string_("Gain")
.align_(\center),
Slider(nil, Rect(0,0,1,2))
.minWidth_(50)
.thumbSize_(50)
.action_({ arg gain;
~granSynth.set(\gain, gain.value.linexp(0,1,0.01,10,nil)-0.01 * 0.05)})
.valueAction_(0)
;
)
), // synth ends here
HLayout( // bottom left synth starts here --------------------------------------------------------------------
VLayout(
StaticText().string_("GRANULATOR"),
Button()
.states_([
["OFF", Color.gray(0.2), Color.gray(0.8)],
["ON", Color.gray(0.8), Color.grey(0.2)] ])
.mouseDownAction_({
arg state;
state.value.postln;
if (state.value == 0) {
~granSynth = Synth(\Granny, [\bufnum, b]);
} {
~granSynth.free;
}
})
.minHeight_(70)
.minWidth_(70),
nil
),
VLayout(
PopUpMenu().items_(["buffer1","file2","file3"]).font_(Font("Sans",20)),
StaticText().string_("Filter vs. Position"),
Slider2D()
.x_(0.05)
.y_(0.05)
.action_({ arg slider;
~granSynth.set(\pos, slider.x);
~granSynth.set(\lpfFreq, slider.y.value.linexp(0,1,30,20000,nil))}),
StaticText().string_("Position variation"),
Slider(nil,Rect(0,0,50,10))
.minHeight_(20)
.thumbSize_(50)
.action_({ arg posvar;
posvar = posvar.value;
~granSynth.set(\posvar, posvar.value);
})
),
VLayout(
StaticText().string_("Frequency of grains"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
.action_({ arg freq;
freq = ((freq.value * 200) + 1).asInt;
~granSynth.set(\freq, freq.value); freq.value.postln;
~nbf.value_(freq)}),
VLayout(nil,
~nbf = NumberBox(nil,Rect(0,0,1,1))
.font_(Font("Sans",20))
.maxWidth_(50)
.minHeight_(30);
)
),
HLayout(
StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg fvar;
fvar = fvar.value * 2;
~granSynth.set(\fvar, fvar.value);
})
),
nil,
StaticText().string_("Duration of grains"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
.action_({ arg dur;
dur = dur.value;
~granSynth.set(\dur, dur.value);
~nbd.value_((dur.value * 100).asInt); }),
VLayout(nil,
~nbd = NumberBox(nil,Rect(0,0,1,1))
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
),
HLayout(StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg durvar;
durvar = durvar.value * 2;
~granSynth.set(\durvar, durvar.value);
})
),
nil,
StaticText().string_("Pitch"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
.action_({ arg pitch;
pitch = pitch.value * 2;
~granSynth.set(\pitch, pitch.value);
~nbp.value_(pitch.value); }),
VLayout(nil,
~nbp = NumberBox()
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
),
HLayout(StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg pitchvar;
pitchvar = pitchvar.value;
~granSynth.set(\pitchvar, pitchvar.value);
})
),
nil,
StaticText().string_("Width (Stereo)"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
.action_({ arg width;
width = width.value;
~granSynth.set(\width, width.value);
~nbw.value_(width.value);
}),
VLayout(nil,
~nbw = NumberBox()
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
)
),
VLayout(
StaticText().string_("Gain")
.align_(\center),
Slider(nil, Rect(0,0,1,2))
.minWidth_(50)
.thumbSize_(50)
.action_({ arg gain;
~granSynth.set(\gain, gain.value.linexp(0,1,0.01,10,nil)-0.01 * 0.05)})
.valueAction_(0)
;
)
); // bottom left synth ends here
), // left half ends here
VLayout( // right half starts here
// left top synth starts here --------------------------------------------------------------------
HLayout(
VLayout(
StaticText().string_("GRANULATOR"),
Button()
.states_([
["OFF", Color.gray(0.2), Color.gray(0.8)],
["ON", Color.gray(0.8), Color.grey(0.2)] ])
.mouseDownAction_({
arg state;
state.value.postln;
if (state.value == 0) {
~granSynth = Synth(\Granny, [\bufnum, b]);
} {
~granSynth.free;
}
})
.minHeight_(70)
.minWidth_(70),
nil
),
VLayout(
PopUpMenu().items_(["buffer1","file2","file3"]).font_(Font("Sans",20)),
StaticText().string_("Filter vs. Position"),
Slider2D()
.x_(0.05)
.y_(0.05)
.action_({ arg slider;
~granSynth.set(\pos, slider.x);
~granSynth.set(\lpfFreq, slider.y.value.linexp(0,1,30,20000,nil))}),
StaticText().string_("Position variation"),
Slider(nil,Rect(0,0,50,10))
.minHeight_(20)
.thumbSize_(50)
.action_({ arg posvar;
posvar = posvar.value;
~granSynth.set(\posvar, posvar.value);
})
),
VLayout(
StaticText().string_("Frequency of grains"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
.action_({ arg freq;
freq = ((freq.value * 200) + 1).asInt;
~granSynth.set(\freq, freq.value); freq.value.postln;
~nbf.value_(freq)}),
VLayout(nil,
~nbf = NumberBox(nil,Rect(0,0,1,1))
.font_(Font("Sans",20))
.maxWidth_(50)
.minHeight_(30);
)
),
HLayout(
StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg fvar;
fvar = fvar.value * 2;
~granSynth.set(\fvar, fvar.value);
})
),
nil,
StaticText().string_("Duration of grains"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
.action_({ arg dur;
dur = dur.value;
~granSynth.set(\dur, dur.value);
~nbd.value_((dur.value * 100).asInt); }),
VLayout(nil,
~nbd = NumberBox(nil,Rect(0,0,1,1))
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
),
HLayout(StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg durvar;
durvar = durvar.value * 2;
~granSynth.set(\durvar, durvar.value);
})
),
nil,
StaticText().string_("Pitch"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
.action_({ arg pitch;
pitch = pitch.value * 2;
~granSynth.set(\pitch, pitch.value);
~nbp.value_(pitch.value); }),
VLayout(nil,
~nbp = NumberBox()
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
),
HLayout(StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg pitchvar;
pitchvar = pitchvar.value;
~granSynth.set(\pitchvar, pitchvar.value);
})
),
nil,
StaticText().string_("Width (Stereo)"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
.action_({ arg width;
width = width.value;
~granSynth.set(\width, width.value);
~nbw.value_(width.value);
}),
VLayout(nil,
~nbw = NumberBox()
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
)
),
VLayout(
StaticText().string_("Gain")
.align_(\center),
Slider(nil, Rect(0,0,1,2))
.minWidth_(50)
.thumbSize_(50)
.action_({ arg gain;
~granSynth.set(\gain, gain.value.linexp(0,1,0.01,10,nil)-0.01 * 0.05)})
.valueAction_(0)
;
)
), // synth ends here
HLayout( // bottom right synth starts here --------------------------------------------------------------------
VLayout(
StaticText().string_("GRANULATOR"),
Button()
.states_([
["OFF", Color.gray(0.2), Color.gray(0.8)],
["ON", Color.gray(0.8), Color.grey(0.2)] ])
.mouseDownAction_({
arg state;
state.value.postln;
if (state.value == 0) {
~granSynth = Synth(\Granny, [\bufnum, b]);
} {
~granSynth.free;
}
})
.minHeight_(70)
.minWidth_(70),
nil
),
VLayout(
PopUpMenu().items_(["buffer1","file2","file3"]).font_(Font("Sans",20)),
StaticText().string_("Filter vs. Position"),
Slider2D()
.x_(0.05)
.y_(0.05)
.action_({ arg slider;
~granSynth.set(\pos, slider.x);
~granSynth.set(\lpfFreq, slider.y.value.linexp(0,1,30,20000,nil))}),
StaticText().string_("Position variation"),
Slider(nil,Rect(0,0,50,10))
.minHeight_(20)
.thumbSize_(50)
.action_({ arg posvar;
posvar = posvar.value;
~granSynth.set(\posvar, posvar.value);
})
),
VLayout(
StaticText().string_("Frequency of grains"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
.action_({ arg freq;
freq = ((freq.value * 200) + 1).asInt;
~granSynth.set(\freq, freq.value); freq.value.postln;
~nbf.value_(freq)}),
VLayout(nil,
~nbf = NumberBox(nil,Rect(0,0,1,1))
.font_(Font("Sans",20))
.maxWidth_(50)
.minHeight_(30);
)
),
HLayout(
StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg fvar;
fvar = fvar.value * 2;
~granSynth.set(\fvar, fvar.value);
})
),
nil,
StaticText().string_("Duration of grains"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(50).thumbSize_(50)
.action_({ arg dur;
dur = dur.value;
~granSynth.set(\dur, dur.value);
~nbd.value_((dur.value * 100).asInt); }),
VLayout(nil,
~nbd = NumberBox(nil,Rect(0,0,1,1))
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
),
HLayout(StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg durvar;
durvar = durvar.value * 2;
~granSynth.set(\durvar, durvar.value);
})
),
nil,
StaticText().string_("Pitch"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
.action_({ arg pitch;
pitch = pitch.value * 2;
~granSynth.set(\pitch, pitch.value);
~nbp.value_(pitch.value); }),
VLayout(nil,
~nbp = NumberBox()
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
),
HLayout(StaticText().string_("variation"),
Slider(nil,Rect(0,0,2,1)).thumbSize_(50)
.action_({ arg pitchvar;
pitchvar = pitchvar.value;
~granSynth.set(\pitchvar, pitchvar.value);
})
),
nil,
StaticText().string_("Width (Stereo)"),
HLayout(
Slider(nil,Rect(0,0,2,1)).minHeight_(20).thumbSize_(50)
.action_({ arg width;
width = width.value;
~granSynth.set(\width, width.value);
~nbw.value_(width.value);
}),
VLayout(nil,
~nbw = NumberBox()
.font_(Font("Sans", 20))
.maxWidth_(50)
.minHeight_(30);)
)
),
VLayout(
StaticText().string_("Gain")
.align_(\center),
Slider(nil, Rect(0,0,1,2))
.minWidth_(50)
.thumbSize_(50)
.action_({ arg gain;
~granSynth.set(\gain, gain.value.linexp(0,1,0.01,10,nil)-0.01 * 0.05)})
.valueAction_(0)
;
)
); // bottom right synth ends here
); // right half ends here
);
~tab_views[~tab_names.at("granul")].layout.margins = 2;