rsc3/doc-schelp/Help-3.12.2/Classes/Interface.html

463 lines
25 KiB
HTML
Raw Permalink Normal View History

2022-08-24 13:53:18 +00:00
<!doctype html><html lang='en'><head><title>Interface | SuperCollider 3.11.1 Help</title>
<link rel='stylesheet' href='./../scdoc.css' type='text/css' />
<link rel='stylesheet' href='./../codemirror.css' type='text/css' />
<link rel='stylesheet' href='./../editor.css' type='text/css' />
<link rel='stylesheet' href='./../frontend.css' type='text/css' />
<link rel='stylesheet' href='./../custom.css' type='text/css' />
<meta name='viewport' content='width=device-width, initial-scale=1'>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<script src='./../lib/jquery.min.js'></script>
<script src='./../lib/codemirror-5.39.2.min.js' type='text/javascript'></script>
<script src='./../lib/codemirror-addon-simple-5.39.2.min.js' type='text/javascript'></script>
<script>
var helpRoot = './..';
var scdoc_title = 'Interface';
var scdoc_sc_version = '3.11.1';
</script>
<script src='./../scdoc.js' type='text/javascript'></script>
<script src='./../docmap.js' type='text/javascript'></script>
<script src='qrc:///qtwebchannel/qwebchannel.js' type='text/javascript'></script>
</head>
<body onload='fixTOC()'>
<div id='toc'>
<div id='toctitle'>Interface:</div>
<span class='toc_search'>Filter: <input id='toc_search'></span><ul class='toc'><li class='toc1'><a href='#description'>Description</a></li>
<ul class='toc'></ul><li class='toc1'><a href='#classmethods'>Class methods</a></li>
<ul class='toc'><li class='toc3'><a href='#*new'>new</a> </li>
<li class='toc2'><a href='#Inherited%20class%20methods'>Inherited class methods</a></li>
</ul><li class='toc1'><a href='#instancemethods'>Instance methods</a></li>
<ul class='toc'><li class='toc3'><a href='#-interfaceDef'>interfaceDef</a> </li>
<li class='toc3'><a href='#-args'>args</a> </li>
<li class='toc3'><a href='#-onPrepareToBundle'>onPrepareToBundle</a> </li>
<li class='toc3'><a href='#-onPlay'>onPlay</a> </li>
<li class='toc3'><a href='#-onStop'>onStop</a> </li>
<li class='toc3'><a href='#-onFree'>onFree</a> </li>
<li class='toc3'><a href='#-onNoteOn'>onNoteOn</a> </li>
<li class='toc3'><a href='#-onNoteOff'>onNoteOff</a> </li>
<li class='toc3'><a href='#-onCC'>onCC</a> </li>
<li class='toc3'><a href='#-guiFunction'>guiFunction</a> </li>
<li class='toc3'><a href='#-guiBodyFunction'>guiBodyFunction</a> </li>
<li class='toc3'><a href='#-keyDownAction'>keyDownAction</a> </li>
<li class='toc3'><a href='#-keyUpAction'>keyUpAction</a> </li>
<li class='toc3'><a href='#-init'>init</a> </li>
<li class='toc3'><a href='#-createArgs'>createArgs</a> </li>
<li class='toc3'><a href='#-prepareToBundle'>prepareToBundle</a> </li>
<li class='toc3'><a href='#-didSpawn'>didSpawn</a> </li>
<li class='toc3'><a href='#-didStop'>didStop</a> </li>
<li class='toc3'><a href='#-freeToBundle'>freeToBundle</a> </li>
<li class='toc3'><a href='#-gui'>gui</a> </li>
<li class='toc3'><a href='#-guiClass'>guiClass</a> </li>
<li class='toc3'><a href='#-guiBody'>guiBody</a> </li>
<li class='toc3'><a href='#-use'>use</a> </li>
<li class='toc3'><a href='#-defer'>defer</a> </li>
<li class='toc3'><a href='#-storeArgs'>storeArgs</a> </li>
<li class='toc3'><a href='#-storeModifiersOn'>storeModifiersOn</a> </li>
<li class='toc2'><a href='#Inherited%20instance%20methods'>Inherited instance methods</a></li>
</ul><li class='toc1'><a href='#examples'>Examples</a></li>
<ul class='toc'></ul><li class='toc1'><a href='#GUI'>GUI</a></li>
<ul class='toc'></ul><li class='toc1'><a href='#MIDI'>MIDI</a></li>
<ul class='toc'></ul><li class='toc1'><a href='#onPlay%20onStop%20onFree'>onPlay onStop onFree</a></li>
<ul class='toc'></ul></ul></div><div id='menubar'></div>
<div class='contents'>
<div class='header'>
<div id='label'>
<span id='folder'>Classes (extension)</span>
| <span id='categories'><a href='./../Browse.html#Libraries'>Libraries</a>&#8201;&gt;&#8201;<a href='./../Browse.html#Libraries>crucial'>crucial</a>&#8201;&gt;&#8201;<a href='./../Browse.html#Libraries>crucial>Instr'>Instr</a> | <a href='./../Browse.html#Libraries'>Libraries</a>&#8201;&gt;&#8201;<a href='./../Browse.html#Libraries>crucial'>crucial</a>&#8201;&gt;&#8201;<a href='./../Browse.html#Libraries>crucial>Players'>Players</a></span>
</div><h1>Interface<span id='superclasses'> : <a href="../Classes/AbstractPlayerProxy.html">AbstractPlayerProxy</a> : <a href="../Classes/AbstractPlayer.html">AbstractPlayer</a> : <a href="../Classes/AbstractFunction.html">AbstractFunction</a> : <a href="../Classes/Object.html">Object</a></span>
<div class='extension-indicator-ctr' title='This help file originates from a third-party quark or plugin for SuperCollider.'><img class='extension-indicator-icon' alt='Extension' src='./../images/plugin.png'><span class='extension-indicator-text'>Extension</span></div></h1>
<div id='summary'>Sets up an environment in which you can build a player, a GUI and responders for midi and keyboard control</div>
</div>
<div class='subheader'>
<div id='filename'>Source: <a href='file:///Users/zzk/Library/Application Support/SuperCollider/downloaded-quarks/crucial-library/Instr/Interface.sc' title='/Users/zzk/Library/Application Support/SuperCollider/downloaded-quarks/crucial-library/Instr/Interface.sc'>Interface.sc</a></div><div id='related'>See also: <a href="./../Classes/Instr.html">Instr</a>, <a href="./../Classes/Patch.html">Patch</a>, <a href="./../Classes/Mx">Mx</a></div>
</div>
<h2><a class='anchor' name='description'>Description</a></h2>
<p>This sets up an environment in which you can build a player, build a gui for that player, and respond to midi and keyboard control.
<p>The gui is quite optional, and in fact non-screen-staring is one of its primary goals.<h2><a class='anchor' name='classmethods'>Class Methods</a></h2>
<h3 class='method-code'><span class='method-prefix'>Interface.</span><a class='method-name' name='*new' href='./../Overviews/Methods.html#new'>new</a>(<span class='argstr'>interfaceDef</span>, <span class='argstr'>args</span>)</h3>
<div class='method'><h4>Arguments:</h4>
<table class='arguments'>
<tr><td class='argumentname'>interfaceDef<td class='argumentdesc'><tr><td class='argumentname'>args<td class='argumentdesc'></table></div><h3><a class='anchor' name='Inherited%20class%20methods'>Inherited class methods</a></h3>
<div id='inheritedclassmets'></div><h2><a class='anchor' name='instancemethods'>Instance Methods</a></h2>
<h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-interfaceDef' href='./../Overviews/Methods.html#interfaceDef'>interfaceDef</a></h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-args' href='./../Overviews/Methods.html#args'>args</a></h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onPrepareToBundle' href='./../Overviews/Methods.html#onPrepareToBundle'>onPrepareToBundle</a></h3>
<h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onPrepareToBundle' href='./../Overviews/Methods.html#onPrepareToBundle'>onPrepareToBundle</a> = value</h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onPlay' href='./../Overviews/Methods.html#onPlay'>onPlay</a></h3>
<h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onPlay' href='./../Overviews/Methods.html#onPlay'>onPlay</a> = value</h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onStop' href='./../Overviews/Methods.html#onStop'>onStop</a></h3>
<h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onStop' href='./../Overviews/Methods.html#onStop'>onStop</a> = value</h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onFree' href='./../Overviews/Methods.html#onFree'>onFree</a></h3>
<h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onFree' href='./../Overviews/Methods.html#onFree'>onFree</a> = value</h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onNoteOn' href='./../Overviews/Methods.html#onNoteOn'>onNoteOn</a></h3>
<h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onNoteOn' href='./../Overviews/Methods.html#onNoteOn'>onNoteOn</a> = value</h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onNoteOff' href='./../Overviews/Methods.html#onNoteOff'>onNoteOff</a></h3>
<h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onNoteOff' href='./../Overviews/Methods.html#onNoteOff'>onNoteOff</a> = value</h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onCC' href='./../Overviews/Methods.html#onCC'>onCC</a></h3>
<h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-onCC' href='./../Overviews/Methods.html#onCC'>onCC</a> = value</h3>
<div class='method'>
<p>the control change handler is installed (via <a href="./../Classes/CCResponder.html">CCResponder</a>) when play starts and unistalled when play stops.
<p>It can be a simple function:<textarea class='editor'>interface.onCC = { arg src,chan,num,value;
[num,value].postln;
};</textarea>
<p>a CCResponder that responds on a specific number. (note: tell it NOT to install itself, because the Interface will install and uninstall it when play starts or stops)<textarea class='editor'> onCC = CCResponder(num,{ },install: false);</textarea>
<p>or a custom class:<textarea class='editor'>onCC = KorgMicroKontrolCC(
[\slider,0,{ }],
[\slider,1,{ }],
[\encoder,0,{ }],
[\encoder,1,{ }],
[\x,{ }],
[\y, { }]
);</textarea>
<p>whatever it is will be asked to respond to 'value' :<textarea class='editor'> thing.value(src,chan,num,value);</textarea>
</div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-guiFunction' href='./../Overviews/Methods.html#guiFunction'>guiFunction</a></h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-guiBodyFunction' href='./../Overviews/Methods.html#guiBodyFunction'>guiBodyFunction</a></h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-keyDownAction' href='./../Overviews/Methods.html#keyDownAction'>keyDownAction</a></h3>
<h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-keyDownAction' href='./../Overviews/Methods.html#keyDownAction'>keyDownAction</a> = value</h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-keyUpAction' href='./../Overviews/Methods.html#keyUpAction'>keyUpAction</a></h3>
<h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-keyUpAction' href='./../Overviews/Methods.html#keyUpAction'>keyUpAction</a> = value</h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-init' href='./../Overviews/Methods.html#init'>init</a>(<span class='argstr'>i</span>, <span class='argstr'>a</span>)</h3>
<div class='method'><h4>Arguments:</h4>
<table class='arguments'>
<tr><td class='argumentname'>i<td class='argumentdesc'><tr><td class='argumentname'>a<td class='argumentdesc'></table></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-createArgs' href='./../Overviews/Methods.html#createArgs'>createArgs</a>(<span class='argstr'>argargs</span>)</h3>
<div class='method'><h4>Arguments:</h4>
<table class='arguments'>
<tr><td class='argumentname'>argargs<td class='argumentdesc'></table></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-prepareToBundle' href='./../Overviews/Methods.html#prepareToBundle'>prepareToBundle</a>(<span class='argstr'>agroup</span>, <span class='argstr'>bundle</span>, <span class='argstr'>private: false</span>, <span class='argstr'>bus</span>, <span class='argstr'>defWasLoaded: false</span>)</h3>
<div class='method'><h4>Arguments:</h4>
<table class='arguments'>
<tr><td class='argumentname'>agroup<td class='argumentdesc'><tr><td class='argumentname'>bundle<td class='argumentdesc'><tr><td class='argumentname'>private<td class='argumentdesc'><tr><td class='argumentname'>bus<td class='argumentdesc'><tr><td class='argumentname'>defWasLoaded<td class='argumentdesc'></table></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-didSpawn' href='./../Overviews/Methods.html#didSpawn'>didSpawn</a></h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-didStop' href='./../Overviews/Methods.html#didStop'>didStop</a></h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-freeToBundle' href='./../Overviews/Methods.html#freeToBundle'>freeToBundle</a>(<span class='argstr'>b</span>)</h3>
<div class='method'><h4>Arguments:</h4>
<table class='arguments'>
<tr><td class='argumentname'>b<td class='argumentdesc'></table></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-gui' href='./../Overviews/Methods.html#gui'>gui</a></h3>
<h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-gui' href='./../Overviews/Methods.html#gui'>gui</a> = <span class='argstr'>f</span></h3>
<div class='supmethod'>From superclass: <a href='./../Classes/Object.html'>Object</a></div>
<div class='method'><h4>Arguments:</h4>
<table class='arguments'>
<tr><td class='argumentname'>f<td class='argumentdesc'></table></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-guiClass' href='./../Overviews/Methods.html#guiClass'>guiClass</a></h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-guiBody' href='./../Overviews/Methods.html#guiBody'>guiBody</a>( <span class='argstr'>... args</span>)</h3>
<div class='method'><h4>Arguments:</h4>
<table class='arguments'>
<tr><td class='argumentname'>... args<td class='argumentdesc'></table></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-use' href='./../Overviews/Methods.html#use'>use</a>(<span class='argstr'>function</span>)</h3>
<div class='method'><h4>Arguments:</h4>
<table class='arguments'>
<tr><td class='argumentname'>function<td class='argumentdesc'></table></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-defer' href='./../Overviews/Methods.html#defer'>defer</a>(<span class='argstr'>function</span>)</h3>
<div class='method'><h4>Arguments:</h4>
<table class='arguments'>
<tr><td class='argumentname'>function<td class='argumentdesc'></table></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-storeArgs' href='./../Overviews/Methods.html#storeArgs'>storeArgs</a></h3>
<div class='method'></div><h3 class='method-code'><span class='method-prefix'>.</span><a class='method-name' name='-storeModifiersOn' href='./../Overviews/Methods.html#storeModifiersOn'>storeModifiersOn</a>(<span class='argstr'>stream</span>)</h3>
<div class='method'><h4>Arguments:</h4>
<table class='arguments'>
<tr><td class='argumentname'>stream<td class='argumentdesc'></table></div><h3><a class='anchor' name='Inherited%20instance%20methods'>Inherited instance methods</a></h3>
<div id='inheritedinstmets'></div><h2><a class='anchor' name='examples'>Examples</a></h2>
<textarea class='editor'>(
m = Interface({
// an environment is in place here
~freq = KrNumberEditor(400,[100,1200,\exp]);
~syncFreq = KrNumberEditor(800,[100,12000,\exp]);
~amp = KrNumberEditor(0.1,\amp);
Patch({ arg freq,syncFreq,amp=0.3;
SyncSaw.ar(syncFreq,freq) * amp
},[
~freq,
~syncFreq,
~amp
])
});
// setting the gui
m.gui = { arg layout,metaPatch;
var joy;
// the same environment is again in place
~freq.gui(layout);
ActionButton(layout,"twitch",{
var x,y;
// action button now remembers the environment !
~freq.setUnmappedValue( x = 1.0.rand );
~syncFreq.setUnmappedValue( y = 1.0.rand );
joy.x_(x).y_(y).changed;
});
joy = GUI.slider2D.new(layout, 100 @ 100)
.action_({ arg sl;
// at this time not in environment
metaPatch.use({ // use the metaPatch's environment
~freq.setUnmappedValue(sl.x);
~syncFreq.setUnmappedValue(sl.y );
})
});
EZNumber(layout,30 @ 30,"amp",[0.01,0.4,\exp],{ arg ez;
metaPatch.use({
~amp.value_(ez.value).changed;
})
});
};
// creating a gui
m.gui
)
// You can place them on any window
(
w = GUI.window.new("other",Rect(20,20,700,200));
w.front;
g = m.gui(w,Rect(30,30,500,200));
g.background = Color.blue(alpha:0.4);
)
// MIDI handler installed on play
// takes some seconds to start up, then play your midi keyboard
(
Instr([\klankperc,\k2a],{ arg trig=0.0,sfreqScale=1.0,sfreqOffset=0.0,stimeScale=1.0,foldAt=0.1;
Klank.ar(
`[
FloatArray[ 87.041, 198.607 ],
nil,
FloatArray[ 0.165394, 0.15595 ]
],
K2A.ar(trig),
sfreqScale,sfreqOffset,stimeScale
).squared.fold2(foldAt)
},[
nil,
[0.01,100],
[0,10000],
[0.01,100]
]);
// Create 5 patches, cycle through them on each midi key
Interface({ arg quantity=5;
~quantity = quantity.poll;
~a = Array.fill(~quantity,{ arg i;
Patch.new([\klankperc,\k2a],
[
BeatClockPlayer(16),
i * (3.midiratio),
i * (3.midiratio),
1.0,
~foldAt = KrNumberEditor(0.1,[1.0,0.01])
]);
});
~pool = PlayerPool( ~a,
env: Env.asr(0.01,releaseTime: 0.01),
round: 0.25);
}).onNoteOn_({ arg note,vel;
// the same environment is in place here
//~foldAt.setUnmappedValue(vel / 127.0).changed;
~pool.select(note % ~quantity)
}).play
)
// fast triggering still trips it up. working on it.
// Simple CC example
(
Interface({
~freq = KrNumberEditor(400,[100,1200,\exp]);
~syncFreq = KrNumberEditor(800,[100,12000,\exp]);
~amp = KrNumberEditor(0.1,\amp);
Patch({ arg freq,syncFreq,amp=0.3;
SyncSaw.ar(syncFreq,freq) * amp
},[
~freq,
~syncFreq,
~amp
])
}).onCC_({ arg src,chan,num,value;
if(num == 80,{ ~freq.setUnmappedValue(value/127);});
if(num == 81,{ ~syncFreq.setUnmappedValue(value/127);});
if(num == 82,{ ~amp.setUnmappedValue(value/127);});
})
.play
)
(
Interface({
~freq = KrNumberEditor(400,[100,1200,\exp]);
~syncFreq = KrNumberEditor(800,[100,12000,\exp]);
~amp = KrNumberEditor(0.1,\amp);
Patch({ arg freq,syncFreq,amp=0.3;
SyncSaw.ar(syncFreq,freq) * amp
},[
~freq,
~syncFreq,
~amp
])
}).onCC_(
ResponderArray(
// these normally install themselves immediately, but the Interface will be handling that
CCResponder(80,{ arg value; ~freq.setUnmappedValue(value/127);},install: false),
CCResponder(81,{ arg value; ~syncFreq.setUnmappedValue(value/127);},install: false),
CCResponder(82,{ arg value; ~amp.setUnmappedValue(value/127);},install: false)
)
)
.play
)
(
// beat juggler
Interface({ arg sample;
~beatStart1 = NumberEditor(0.0,[0.0,8.0,\lin,0.25]);
~beatStart2 = NumberEditor(0.0,[0.0,8.0,\lin,0.25]);
~durations = [ 2.0,2.0];
~patch = InstrGateSpawner({ arg sample,dur, pchRatio,beatStart,amp=0.3,envadsr,tempo;
var gate;
gate = Trig1.kr(1.0,dur / tempo);
pchRatio = pchRatio * sample.pchRatioKr;
beatStart = beatStart * sample.beatsizeIr;
PlayBuf.ar(sample.numChannels,
sample.bufnumIr,
pchRatio,
1.0,
beatStart,
1.0)
* EnvGen.kr(envadsr, gate,amp,doneAction: 2 )
},[
sample,
// dur uses a Pfunc to ask the delta till the next event
Pfunc({ arg igs; (igs.delta * 0.9) }),
// get an .ir input into the synth function
~pchRatio = IrNumberEditor(1.0,[-2,2,\lin,0.25]),
// patterns naturally create an .ir input
Pswitch1([
~beatStart1,
~beatStart2
],Pseq([0,1],inf)) // juggle back and forth
],
// stream of beat durations
Pseq(~durations,inf));
~patch
},[
// a blank sample
Sample.new(nil)
])
.gui_({ arg layout; // we are given a FlowView
var env,ddsp,bdsp;
CXLabel(layout,"Click the sample path (nil) to browse for a sample. You can choose new samples even while playing.");
layout.startRow;
/* the environment from the build function above is available here */
~sample.gui(layout,500@100);
/* but when view actions fire you will be in a different environment
so save it here in a variable for use later */
env = currentEnvironment;
// .vert returns an SCVLayoutView so we can stack each 2d over its caption
layout.vert({ arg layout;
GUI.slider2D.new(layout,100@100)
.action_({ arg sl;
env.use({
// set a 0..1 value, map it to the spec ranges of the NumberEditors
~beatStart1.setUnmappedValue(sl.x);
~beatStart2.setUnmappedValue(sl.y);
bdsp.object_( [~beatStart1.value,~beatStart2.value]).changed;
})
});
GUI.staticText.new(layout,100@13).object_("Beat starts:");
bdsp = GUI.staticText.new(layout,100@13).object_([~beatStart1.value,~beatStart2.value].asString);
},100@120);
layout.vert({ arg layout;
GUI.slider2D.new(layout,100@100)
.action_({ arg sl;
env.use({
var stride,part;
stride = 2 ** [3,4,5,6].at((sl.x * 3).asInteger) * 0.125;
part = (stride * (1.0 - sl.y)).round(0.25).clip(0.25,stride - 0.25);
~durations.put(0,part);
~durations.put(1,stride - part);
ddsp.object_(~durations.sum.asString + "=" + ~durations).changed;
});
});
GUI.staticText.new(layout,100@13).object_("beats");
ddsp = GUI.staticText.new(layout,100@13).object_(~durations.sum.asString + "=" + ~durations);
},100@120);
CXLabel(layout,"pchRatio:");
~pchRatio.gui(layout);
})
.gui
)</textarea>
<h2><a class='anchor' name='GUI'>GUI</a></h2>
<p>You can set a custom gui function. This can use any combination of .gui style and normal Views The Interface can be placed on any other windows of any style. You may decline to customize your gui.<h2><a class='anchor' name='MIDI'>MIDI</a></h2>
<p>If you set any of these handler functions: onNoteOn onNoteOff onPitchBend onCC then appropriate midi responders will be enabled when the player starts to play and disabled when it stops. This includes if the player is being started/stopped by external mixers, PlayerPool etc.
<p>KeyDown/KeyUp keyDownAction keyUpAction (only when guied, only when focus is within the MetaPatch's views)
<p>Interface is great for having no gui at all. Personally I use the gui stuff to set up parameters for performing, and then when performing I use no gui, only MIDI controllers and key commands.
<p>The function that builds the player is actually an <a href="./../Classes/InterfaceDef.html">InterfaceDef</a>. These can be created and stored in the same fashion as Instr and kept in the same folder. You can then address them by name, supply paramaters as you do for Patch and you will get an Interface which will use the gui and midi functions from the InterfaceDef.<h2><a class='anchor' name='onPlay%20onStop%20onFree'>onPlay onStop onFree</a></h2>
<textarea class='editor'>(
Interface({
~freq = KrNumberEditor(400,[100,1200,\exp]);
~amp = KrNumberEditor(0.1,[0.01,0.4,\exp]);
Patch({ arg freq,amp;
SinOsc.ar(freq) * amp
},[
~freq,
~amp
])
})
.onPlay_({
"playing".postln;
})
.onStop_({ // also on command-.
"stopping".postln;
})
.onFree_({
"freeing".postln;
}).play
)</textarea>
<div class='doclink'>helpfile source: <a href='file:///Users/zzk/Library/Application Support/SuperCollider/downloaded-quarks/crucial-library/HelpSource/Classes/Interface.schelp'>/Users/zzk/Library/Application Support/SuperCollider/downloaded-quarks/crucial-library/HelpSource/Classes/Interface.schelp</a><br>link::Classes/Interface::<br></div></div><script src='./../editor.js' type='text/javascript'></script>
</body></html>