Skip to content

STK Doc Improvements #338

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions source/StkInst/sc/HelpSource/Classes/StkGlobals.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,20 @@ Examples::

code::

//a instrument that uses waveforms///////////////////
//an instrument that uses waveforms///////////////////
//first set rawfilepath to let Stk know where to look
{StkGlobals.ar(1,1,Platform.userExtensionDir ++"/SC3Plugins/StkInst/rawwaves")}.play;
({
var path = [
Platform.userExtensionDir ++ "/SC3Plugins/StkInst/rawwaves",
Platform.userExtensionDir ++ "/SC3Plugins/StkInst/rawwaves",
Platform.systemExtensionDir ++ "/SC3plugins/StkInst/rawwaves",
Platform.systemExtensionDir ++ "/SC3plugins/StkInst/rawwaves"
].select({ |possiblePath| File.exists(possiblePath) }).first;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably a more pragmatic way to handle this.

Also, I think the folder got renamed at some point in the history of these plugins.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the lines 35 and 36 as well as 37 and 37 seem to be the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@telephon - They're extremely similar. The only difference is the case of p/P.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen these paths declared in multiple ways and I'm wondering if the path has changed over time with the codebase. Is there a "correct" version of this filepath for the most updated version of SC?

Copy link
Member

@dyfer dyfer Jan 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's "correct", but previously I used the ".filenameSymbol" method to get the path of the class file, which allowed me to get a reference to where the class is installed, without any assumptions as to where the extension is installed.

Here we could do

var path = StkInst.filenameSymbol.asString.dirname.dirname +/+ "rawwaves";


if(path.isNil, {Error("audio files not found").throw;});

StkGlobals.ar(1,1,path)
}.play;)

//Define mandolin synthdef
(
Expand Down
17 changes: 13 additions & 4 deletions source/StkInst/sc/HelpSource/Classes/StkInst.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ SynthDef(\helpStkbowed,{arg out=0,freq=220,gate=1,amp=1,bowpressure = 64, bowpos

//Use it.
(

Pbind(
\instrument, \helpStkbowed,
\dur , 0.25,
Expand All @@ -58,9 +57,20 @@ Pbind(
).play;
)

//now a instrument that uses waveforms///////////////////
//an instrument that uses waveforms///////////////////
//first set rawfilepath to let Stk know where to look
{StkGlobals.ar(1,1,Platform.userExtensionDir ++"/SC3Plugins/StkInst/rawwaves")}.play;
({
var path = [
Platform.userExtensionDir ++ "/SC3Plugins/StkInst/rawwaves",
Platform.userExtensionDir ++ "/SC3Plugins/StkInst/rawwaves",
Platform.systemExtensionDir ++ "/SC3plugins/StkInst/rawwaves",
Platform.systemExtensionDir ++ "/SC3plugins/StkInst/rawwaves"
].select({ |possiblePath| File.exists(possiblePath) }).first;

if(path.isNil, {Error("audio files not found").throw;});

StkGlobals.ar(1,1,path)
}.play;)

//Define mandolin synthdef
(
Expand All @@ -74,7 +84,6 @@ SynthDef(\helpMandolin,{arg out=0,freq=220,gate=1,amp=1;

//Use it.
(

Pbind(
\instrument, \helpMandolin,
\dur , 0.25,
Expand Down
4 changes: 2 additions & 2 deletions source/StkUGens/StkAll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,11 @@ void StkBowed_next(StkBowed *unit, int inNumSamples)
*/
if(gate != unit->gate){
if(gate){
Print("Starting\n");
//Print("Starting\n");
unit->bowed->noteOn(freq, 1000.f);
// unit->bowed->startBowing(1.f, IN0(7)); // IN0(7) is attackrate
}else{
Print("Stopping\n");
//Print("Stopping\n");
unit->bowed->noteOff(1000.f);
// unit->bowed->stopBowing(IN0(8)); // IN0(8) is decayrate
}
Expand Down
41 changes: 41 additions & 0 deletions source/StkUGens/sc/HelpSource/Classes/StkClarinet.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
TITLE:: StkClarinet
summary:: Synthesis Toolkit Clarinet
categories:: UGens>PhysicalModels>StkUGens
related:: Classes/Stk, Classes/StkInst

CLASSMETHODS::

METHOD:: ar
ARGUMENT:: freq
ARGUMENT:: reedstiffness
ARGUMENT:: noisegain
ARGUMENT:: vibfreq
ARGUMENT:: vibgain
ARGUMENT:: breathpressure
ARGUMENT:: trig
ARGUMENT:: mul
ARGUMENT:: add

EXAMPLES::

code::
( // Add SynthDef
SynthDef.ar(\helpStkClarinet, {
arg freq=440, reedstiffness=64, noisegain=4, vibfreq=64, vibgain=11, breathpressure=64, gate=1, amp=1, out=0;

var env = EnvGen.kr(Env.new(times: [0, 0.1]), gate: gate, doneAction: 2);
var sig = StkClarinet.ar(freq, reedstiffness, noisegain, vibfreq, vibgain, breathpressure, trig: gate);

sig = sig * env * amp;

Out.ar(out, sig.dup);
}).add;
)

( // Play SynthDef
Pbind(
\instrument, \helpStkClarinet,
\degree, Pseq([0,2,4,7], 2)
).play;
)
::
38 changes: 38 additions & 0 deletions source/StkUGens/sc/HelpSource/Classes/StkFlute.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
TITLE:: StkFlute
summary:: Synthesis Toolkit Flute
categories:: UGens>PhysicalModels>StkUGens
related:: Classes/Stk, Classes/StkInst

CLASSMETHODS::

METHOD:: ar
ARGUMENT:: freq
ARGUMENT:: jetDelay
ARGUMENT:: noisegain
ARGUMENT:: jetRatio
ARGUMENT:: mul
ARGUMENT:: add


EXAMPLES::
code::
( // Add SynthDef
SynthDef(\helpStkFlute, {
arg freq=440, jetDelay=49, noisegain=0.15, jetRatio=0.32, amp=0.2, gate=1, out=1;

var env = EnvGen.kr(Env.asr(0, 1, 0.1), gate, doneAction: 2);
var sig = StkFlute.ar(freq, jetDelay: jetDelay, noisegain: noisegain, jetRatio: jetRatio);
sig = sig * env * amp;

Out.ar(0, sig.dup);
}).add;
)

( // Play SynthDef
Pbind(
\instrument, \helpStkFlute,
\degree, Pseq((0..7)),
\octave, 6
).play;
)
::
58 changes: 58 additions & 0 deletions source/StkUGens/sc/HelpSource/Classes/StkPluck.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
TITLE:: StkPluck
summary:: Synthesis Toolkit Pluck
categories:: UGens>PhysicalModels>StkUGens
related:: Classes/Stk, Classes/StkInst

CLASSMETHODS::

METHOD:: ar
ARGUMENT:: freq
ARGUMENT:: decay
ARGUMENT:: mul
ARGUMENT:: add


EXAMPLES::
code::
( // Add SynthDef.
SynthDef(\helpStkPluck, {
arg freq=440, decay=0.99, amp=0.2, gate=1, out=0;

var env = EnvGen.kr(Env.asr(0,1,0.1), gate, doneAction:2);
var sig = StkPluck.ar(freq, decay);
sig = sig * env * amp;

Out.ar(out, sig.dup);
}).add;
)

( // Play SynthDef
Pbind(
\instrument, \helpStkPluck,
\degree, Pseq([0,2,4,7], 1),
\dur, 1
).play;
)

( // Guitar tuning.
var midinotes=[40, 45, 50, 55, 59, 64];
Pbind(
\instrument, \helpStkPluck,
\midinote, Pseq(midinotes),
\dur, 1
).play;
)

( // Guitar chords.
var midinotes=[40, 45, 50, 55, 59, 64];
var fretsE=[ 0, 2, 2, 1, 0, 0];
var fretsA=[Rest(0), 0, 2, 2, 2, 0];
Pbind(
\instrument, \helpStkPluck,
\midinote, midinotes + Pseq([Pn(fretsE, 6), Pn(fretsA, 6)], 2),
\strum, Pseq([1, -1], inf) * Pgauss(0.0125, 0.005),
\dur, Pseq([1/2, 1/4, 1/2, 1/4, 1/4, 1/4], inf),
\legato, 0.95
).play;
)
::
47 changes: 47 additions & 0 deletions source/StkUGens/sc/HelpSource/Classes/StkSaxofony.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
TITLE:: StkSaxofony
summary:: Synthesis Toolkit Saxophony
categories:: UGens>PhysicalModels>StkUGens
related:: Classes/Stk, Classes/StkInst

CLASSMETHODS::

METHOD:: ar

ARGUMENT:: freq
ARGUMENT:: reedstiffness
ARGUMENT:: reedaperture
ARGUMENT:: noisegain
ARGUMENT:: blowposition
ARGUMENT:: vibratofrequency
ARGUMENT:: vibratogain
ARGUMENT:: breathpressure
ARGUMENT:: trig
ARGUMENT:: mul
ARGUMENT:: add


EXAMPLES::

code::
( // Add SynthDef
SynthDef(\helpStkSaxofony, {
arg freq=220, reedstiffness=64, reeddeparture=64, noisegain=20,
blowposition=26, vibratofrequency=20, vibratogain=20, breathpressure=128, gate=1, amp=1, out=0;

var env = EnvGen.kr(Env.new(times: [0, 0.1]), gate: gate, doneAction: 2);
var sig = StkSaxofony.ar(freq, reedstiffness, reeddeparture, noisegain,
blowposition, vibratofrequency, vibratogain, breathpressure, trig: gate);

sig = sig * env * amp;

Out.ar(out, sig.dup);
}).add;
)

( // Play SynthDef
Pbind(
\instrument, \helpStkSaxofony,
\degree, Pseq([0,2,4,7], 2)
).play;
)
::
49 changes: 49 additions & 0 deletions source/StkUGens/sc/HelpSource/Classes/StkShakers.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
TITLE:: StkShakers
summary:: Synthesis Toolkit Shakers
categories:: UGens>PhysicalModels>StkUGens
related:: Classes/Stk, Classes/StkInst

CLASSMETHODS::

METHOD:: ar

ARGUMENT:: instr
An integer between 0 and 21, inclusive. Instruments can be found with link::#-directory::
ARGUMENT:: energy
ARGUMENT:: decay
ARGUMENT:: objects
ARGUMENT:: resfreq
ARGUMENT:: mul
ARGUMENT:: add

METHOD:: directory
Returns a dictionary of shaker instrument numbers.
RETURNS:: A link::Classes/Dictionary::
code::
StkShakers.directory;
::

EXAMPLES::

code::
(
SynthDef(\helpStkShakers, {
arg instr=0, energy=64, decay=64, objects=64, resfreq=64, amp=0.2, gate=1;

var env = EnvGen.kr(Env.asr(0, 1, 0.1), gate: gate, doneAction: 2);
var sig = StkShakers.ar(instr, energy, decay, objects, resfreq);
sig = sig * env * amp;

Out.ar(0, sig.dup);
}).add;
)

(
Pbind(
\instrument, \helpStkShakers,
\instr, 11,
\dur, Pseq([2, Rest(2), 2, Rest(2), 2]),
\amp, 0.5
).play;
)
::
34 changes: 34 additions & 0 deletions source/StkUGens/sc/STKclassdefs.sc
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,46 @@ StkSaxofony : UGen {
}

StkShakers : UGen {
classvar shakerTypes;

*initClass {
shakerTypes = Dictionary[
"Maraca" -> 0,
"Cabasa" -> 1,
"Sekere" -> 2,
"Guiro" -> 3,
"Water Drops" -> 4,
"Bamboo Chimes" -> 5,
"Tambourine" -> 6,
"Sleigh Bells" -> 7,
"Sticks" -> 8,
"Crunch" -> 9,
"Wrench" -> 10,
"Sand Paper" -> 11,
"Coke Can" -> 12,
"Next Mug" -> 13,
"Penny + Mug" -> 14,
"Nickle + Mug" -> 15, // Mispelling of "Nickel" in original STK docs
"Dime + Mug" -> 16,
"Quarter + Mug" -> 17,
"Franc + Mug" -> 18,
"Peso + Mug" -> 19,
"Big Rocks" -> 20,
"Little Rocks" -> 21,
"Tuned Bamboo Chimes" -> 22
].freeze;
}

*ar { arg instr=0, energy=64, decay=64, objects=64, resfreq=64, mul = 1.0, add = 0.0;
^this.multiNew('audio',instr, energy, decay, objects, resfreq).madd(mul, add)
}
*kr { arg instr=0, energy=64, decay=64, objects=64, resfreq=64, mul = 1.0, add = 0.0;
^this.multiNew('control', instr, energy, decay, objects, resfreq ).madd(mul, add)
}

*directory {
^shakerTypes
}
}


Expand Down