made some helpfile examples

nix
Ted Moore 4 years ago
parent ebe4156f9b
commit 6502386867

@ -27,37 +27,51 @@ INSTANCEMETHODS::
EXAMPLES::
code::
// make a buffer with some data in it
~buf = Buffer.loadCollection(s,[0,1,2,3,4,7]);
// play it on the server and read out of this buffer!
// fill a 1-channel buffer with 7 numbers
~buf = Buffer.loadCollection(s,{exprand(100,4000)} ! 7);
// in a synth, read those numbers out of the buffer and get them as a control stream
(
{
var sig = FluidBufToKr.kr(~buf);
~synth = {
arg buf;
var freqs = FluidBufToKr.kr(buf,numFrames:7);
var sig = SinOsc.ar(freqs.lag(0.03)) * 0.1;
sig.poll;
}.play;
Splay.ar(sig);
}.play(args:[\buf,~buf]);
)
// =============== passing a buffer as an argument ======================
// then you can change what's in the buffer and it will get read out by the synth
~buf.setn(0,{exprand(100,4000)} ! 7);
::
Use with other FluCoMa objects:
code::
// create an neural network for classification
~mlp = FluidMLPClassifier(s);
// load a model that has been pre-trained to classify between a tone and noise, simple, i know, but...
~mlp.read(FluidFilesPath("../Resources/bufToKrExample.json"));
// create a synth that both writes into a buffer (with FluidKrToBuf) and reads
// out of the same buffer (with FluidBufToKr)
// can be used to demonstrate that...
(
~synth = {
arg buf = 999;
FluidKrToBuf.kr(SinOsc.kr(Array.fill(5,{rrand(0.0,1.0)})),buf);
{
var input_buf = LocalBuf(7);
var out_buf = LocalBuf(1);
var sig = Select.ar(ToggleFF.kr(Dust.kr(1)),[SinOsc.ar(440),PinkNoise.ar]);
var analysis = FluidSpectralShape.kr(sig);
FluidKrToBuf.kr(analysis,input_buf);
// you need to specify the 5 so the synth here will know how many channels to make
// the output proxy
FluidBufToKr.kr(buf,numFrames:5).poll;
// the output prediction is written into a buffer
~mlp.kr(Impulse.kr(30),input_buf,out_buf);
// and FluidBufToKr can be used to read the prediction out into a control rate stream
FluidBufToKr.kr(out_buf).poll;
sig.dup * -30.dbamp
}.play;
// you should see all zeros! (unless your buffer #999 has something in it already!)
)
// ...then after it is running, instantiate the buffer
~buffer = Buffer.alloc(s,2);
// ...then send it to the buffer
~synth.set(\buf,~buffer);
// you should be able to see the sine oscillators now!
::

@ -32,25 +32,48 @@ INSTANCEMETHODS::
EXAMPLES::
code::
(
// FluidKrToBuf test
s.waitForBoot{
Routine{
var buf = Buffer.alloc(s,5);
s.sync;
(
~synth = {
var buf = LocalBuf(512).clear;
var sig = SinOsc.ar([440,441]);
var lfos = Array.fill(512,{arg i; SinOsc.ar(i.linlin(0,511,0.01,0.2))});
FluidKrToBuf.kr(lfos,buf);
sig = Shaper.ar(buf,sig);
sig.dup * -40.dbamp;
}.scope;
)
{
var sig = SinOsc.kr(rrand(1.0.dup(buf.numFrames),4.0));
FluidKrToBuf.kr(sig,buf);
}.play;
::
Use with other FluCoMa objects:
code::
1.wait;
// make a new dataset
~ds = FluidDataSet(s);
defer{buf.plot};
}.play;
}
// run a synth with varying sounds and an mfcc analysis
(
~synth = {
arg t_trig;
var buf = LocalBuf(13);
var n = 7;
var sig = BPF.ar(PinkNoise.ar.dup(n),LFDNoise1.kr(2.dup(n)).exprange(100,4000)).sum * -20.dbamp;
var mfccs = FluidMFCC.kr(sig,buf.numFrames,startCoeff:1,maxNumCoeffs:buf.numFrames);
// write the real-time mfcc analysis into this buffer so that...
FluidKrToBuf.kr(mfccs,buf);
// it can be added to the dataset from that buffer by sending a trig to the synth
FluidDataSetWr.kr(~ds,"point-",PulseCount.kr(t_trig),buf:buf,trig:t_trig);
sig.dup;
}.play;
)
// send a bunch of triggers and...
~synth.set(\t_trig,1);
// see how your dataset grows
~ds.print;
::

@ -0,0 +1,107 @@
{
"labels": {
"labels": [
"tone",
"noise"
],
"rows": 2
},
"mlp": {
"layers": [
{
"activation": 1,
"biases": [
9.475189836135217e-245,
-7.312978302687739e-296,
0.0,
0.0,
0.0
],
"cols": 5,
"rows": 7,
"weights": [
[
-0.7070957130289968,
0.2529529084252004,
-0.6315006118399392,
0.2641365029014226,
-0.11879484878940468
],
[
-0.5210842572299229,
0.25356340881888756,
0.04200241621968997,
0.12583197506255497,
0.2845264672854667
],
[
0.36148051326296066,
0.614748588906755,
0.24204178015383798,
0.6087291285844215,
0.5802812834026664
],
[
-0.05847754423619632,
-0.16475294200213061,
-0.6962199018410693,
0.48955391140174614,
0.3708040237508281
],
[
0.04633987154978883,
0.02745889671058346,
-0.16487516786286913,
0.03808304248049002,
-0.33594219806125813
],
[
-0.3974517302751846,
0.4680556811476128,
-0.6125775823484346,
-0.5770487854150471,
-0.6399818221697359
],
[
-0.6405756468993841,
-0.65821443359875,
-0.1166924540077695,
0.21767428398943345,
0.3338702030112145
]
]
},
{
"activation": 1,
"biases": [
-0.3628999139757816,
-0.42250374321781475
],
"cols": 2,
"rows": 5,
"weights": [
[
-0.31804841180355814,
-0.46839296834399485
],
[
-4.2805091183479895,
4.474227050298208
],
[
0.4747799633725462,
0.4122869489228666
],
[
0.5463246485585964,
0.04662010562772569
],
[
3.913863778074305,
-3.7226634012685995
]
]
}
]
}
}
Loading…
Cancel
Save