Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
vitreo12 committed Oct 14, 2022
2 parents 8129232 + 83ea1c3 commit c6e6a48
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 46 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 1.3.1

## Bug fixes

- `AlgaTemp`: fixed support everywhere (e.g, within a `Pfunc`) for `AlgaTemp`s declared with a already compiled `AlgaSynthDef`s.

- `AlgaProxySpace`: removed the overrides for `Symbol.ar` and `Symbol.kr`.

- `AlgaNode`: fixed help filed for `replacePlayTime`.

# 1.3.0

## New features
Expand Down
54 changes: 30 additions & 24 deletions Classes/AlgaParser.sc
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,21 @@ AlgaParser {
{ defDef.isFunction } {
var defName = ("alga_" ++ UniqueID.next).asSymbol;

//AlgaTemp can be sampleAccurate in AlgaPatterns!
functionSynthDefDict[defName] = [
AlgaSynthDef.new_inner(
defName,
defDef,
sampleAccurate: algaTemp.sampleAccurate,
makeFadeEnv: false,
makePatternDef: false,
makeOutDef: false
),
algaTemp
];
//Protection
if(functionSynthDefDict != nil, {
//AlgaTemp can be sampleAccurate in AlgaPatterns!
functionSynthDefDict[defName] = [
AlgaSynthDef.new_inner(
defName,
defDef,
sampleAccurate: algaTemp.sampleAccurate,
makeFadeEnv: false,
makePatternDef: false,
makeOutDef: false
),
algaTemp
];
});

defDef = defName;
def[\def] = defName;
Expand All @@ -153,18 +156,21 @@ AlgaParser {
{ def.isFunction } {
var defName = ("alga_" ++ UniqueID.next).asSymbol;

//AlgaTemp can be sampleAccurate in AlgaPatterns!
functionSynthDefDict[defName] = [
AlgaSynthDef.new_inner(
defName,
def,
sampleAccurate: algaTemp.sampleAccurate,
makeFadeEnv: false,
makePatternDef: false,
makeOutDef: false
),
algaTemp
];
//Protection
if(functionSynthDefDict != nil, {
//AlgaTemp can be sampleAccurate in AlgaPatterns!
functionSynthDefDict[defName] = [
AlgaSynthDef.new_inner(
defName,
def,
sampleAccurate: algaTemp.sampleAccurate,
makeFadeEnv: false,
makePatternDef: false,
makeOutDef: false
),
algaTemp
];
});

defDef = defName;
algaTemp.setDef(defName); //Substitute .def with the Symbol
Expand Down
19 changes: 12 additions & 7 deletions Classes/AlgaPattern.sc
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,8 @@ AlgaPattern : AlgaNode {
createAlgaTempGroup = false, isFX = false |
var tempBus, tempSynth;
var tempSynthArgs = [ \gate, 1 ];
var tempNumChannels = algaTemp.numChannels;
var tempRate = algaTemp.rate;
var def, algaTempDef, tempControlNames;
var tempNumChannels, tempRate, tempControlNames;
var def, algaTempDef;
var defIsEvent = false;

//New AlgaTemp at top level: create a new currentAlgaTempGroup.
Expand All @@ -536,8 +535,12 @@ AlgaPattern : AlgaNode {

//Check AlgaTemp validity
if(algaTemp.valid.not, {
"AlgaPattern: Invalid AlgaTemp, using default parameter".error;
^nil
//Try to evaluate once more. It could be an AlgaTemp(\validDef) in a Pfunc
this.parseAlgaTempParam(algaTemp);
if(algaTemp.valid.not, {
"AlgaPattern: Invalid AlgaTemp, using default parameter".error;
^nil
});
});

//Unpack SynthDef
Expand All @@ -550,7 +553,9 @@ AlgaPattern : AlgaNode {
defIsEvent = true;
});

//Unpack controlNames
//Unpack channels, rate, controlNames
tempNumChannels = algaTemp.numChannels;
tempRate = algaTemp.rate;
tempControlNames = algaTemp.controlNames;

//Loop around the controlNames to set relevant parameters
Expand Down Expand Up @@ -595,7 +600,7 @@ AlgaPattern : AlgaNode {
//Scalar parameters

//Unpack value
var paramValue = entry.algaNext;
var paramValue = entry.algaNext(this.getCurrentEnvironment);

//If Symbol, skip iteration
if(paramValue.isSymbol, {
Expand Down
30 changes: 29 additions & 1 deletion Classes/AlgaProxySpace.sc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
AlgaProxySpace {
classvar <paramsArgs;
classvar <currentNode;
/*
// SystemOverwrites/extSymbol
classvar <isTriggerDef = false;
*/
var <nodes;
var <objects;
var <patternsEvents;
Expand All @@ -34,12 +37,26 @@ AlgaProxySpace {
^newSpace;
}

*forceBoot { | onBoot, server, algaServerOptions, clock |
var newSpace = this.new.init;
newSpace.push;
server = server ? Server.default;
Alga.fBoot(onBoot, server, algaServerOptions, clock);
^newSpace;
}

*fBoot { | onBoot, server, algaServerOptions, clock |
^this.forceBoot(onBoot, server, algaServerOptions, clock)
}

*initClass {
paramsArgs = IdentityDictionary(10);
}

*addParamArgs { | param, value |
if(paramsArgs[currentNode] == nil, { paramsArgs[currentNode] = IdentityDictionary() });
if(paramsArgs[currentNode] == nil, {
paramsArgs[currentNode] = IdentityDictionary()
});
paramsArgs[currentNode][param] = value;
}

Expand Down Expand Up @@ -134,6 +151,11 @@ AlgaProxySpace {

pop { Environment.pop }

quit { | onQuit |
Alga.quit(onQuit, server);
this.pop;
}

keys { ^nodes.keys }

//////////////////////
Expand Down Expand Up @@ -187,6 +209,8 @@ AlgaProxySpace {
^node
}

/*
// SystemOverwrites/extSymbol
//This allows to retrieve Symbol.kr / Symbol.ar BEFORE they're sent to the server.
triggerDef { | node, def |
currentNode = node;
Expand All @@ -196,6 +220,7 @@ AlgaProxySpace {
};
isTriggerDef = false;
}
*/

explicitNode { | node, key, def |
node.clear;
Expand Down Expand Up @@ -282,6 +307,8 @@ AlgaProxySpace {
}

replaceNode { | node, key, def |
/*
// SystemOverwrites/extSymbol
//The args replacement ONLY works with AlgaNode
if(node.isAlgaPattern.not, {
var currentArgsID, currentArgs;
Expand All @@ -304,6 +331,7 @@ AlgaProxySpace {
});
});
});
*/

//Standard replace
^node.replace(def: def);
Expand Down
12 changes: 8 additions & 4 deletions Classes/AlgaUtilities.sc
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,22 @@ AlgaTemp {
def = argDef
}

checkValidSynthDef { | def |
var synthDesc = SynthDescLib.alga.at(def);
checkValidSynthDef { | argDef |
var synthDesc;
var synthDef;

argDef = argDef ? def;
if(argDef.isEvent, { argDef = argDef[\def] });

synthDesc = SynthDescLib.alga.at(argDef);
if(synthDesc == nil, {
("AlgaTemp: Invalid AlgaSynthDef: '" ++ def.asString ++ "'").error;
("AlgaTemp: Invalid AlgaSynthDef: '" ++ argDef.asString ++ "'").error;
^nil;
});

synthDef = synthDesc.def;
if(synthDef.isKindOf(SynthDef).not, {
("AlgaTemp: Invalid AlgaSynthDef: '" ++ def.asString ++"'").error;
("AlgaTemp: Invalid AlgaSynthDef: '" ++ argDef.asString ++ "'").error;
^nil;
});

Expand Down
2 changes: 1 addition & 1 deletion Classes/SystemOverwrites/extEventStreamPlayer.sc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
//[inTime.asStringPrec(17), nextBeat.asStringPrec(17)].debug("inTime, nextBeat");
roundedBeat = nextBeat.round;
deltaFromRounded = roundedBeat - nextBeat;
if (deltaFromRounded.abs < 1e-14 and: { deltaFromRounded != 0 }) {
if (deltaFromRounded.abs < 1e-15 and: { deltaFromRounded != 0 }) {
nextBeat = roundedBeat;
nextTime = nextTime + deltaFromRounded;
//nextTime.asStringPrec(17).debug("corrected time");
Expand Down
10 changes: 7 additions & 3 deletions Classes/SystemOverwrites/extSymbol.sc
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//Support for AlgaNode and AlgaArg
//Support for AlgaNode and AlgaArg.
//This has been commented out because I could not yet figure out a safe way to implement it
//so that I would be sure of the instantiation of the AlgaNode sender.
/*
+Symbol {
ar { | val, lag, spec |
if((val.isAlgaNode).or(val.isAlgaArg), {
AlgaProxySpace.addParamArgs(this, val);
if(AlgaProxySpace.isTriggerDef.not, {
^NamedControl.ar(this, 0, lag, spec);
}, {
AlgaProxySpace.addParamArgs(this, val);
^DC.ar(0)
});
});
Expand All @@ -34,10 +37,10 @@
kr { | val, lag, fixedLag = false, spec |
if((val.isAlgaNode).or(val.isAlgaArg), {
AlgaProxySpace.addParamArgs(this, val);
if(AlgaProxySpace.isTriggerDef.not, {
^NamedControl.kr(this, 0, lag, fixedLag, spec)
}, {
AlgaProxySpace.addParamArgs(this, val);
^DC.kr(0)
});
});
Expand All @@ -60,3 +63,4 @@
maxLocalBufs { ^nil }
maxLocalBufs_ { }
}
*/
6 changes: 4 additions & 2 deletions Examples/Extras/AlgaProxySpace.scd
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ p = AlgaProxySpace.boot;
//A simple node
~a = { SinOsc.ar(100) };

(
//Use it as FM input for another node
~b.play(chans:2);
~b.interpTime = 2;
~b.playTime = 0.5;
~b = { SinOsc.ar(\freq.ar(~a).range(200, 400)) };
~b = { SinOsc.ar(\freq.ar(440)) }; ~b.from(~a, \freq, scale: [220, 440]);
)

//Replace
~a = { SinOsc.ar(440) };

//New connection as usual
~b.from({ LFNoise1.ar(100) }, \freq, time:3)
~b.from({ LFNoise1.ar(100) }, \freq, time: 3, scale: [330, 660])

//Reset state
p.clear(time:2);
Expand Down
2 changes: 1 addition & 1 deletion HelpSource/Classes/AlgaNode.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Shortcut for emphasis::playTime::.


METHOD:: replacePlayTime
Specify fade in / fade out times when calling emphasis::replace:: on a node that was playing.
Specify a boolean to determine whether to use code::playTime:: as the time parameter when calling emphasis::replace:: on a node that was playing.


METHOD:: rpt
Expand Down
13 changes: 11 additions & 2 deletions HelpSource/Classes/AlgaProxySpace.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ An instance of link::Classes/AlgaServerOptions:: to boot the server with. If not
ARGUMENT:: clock
The emphasis::Clock:: for the internal link::Classes/AlgaScheduler::. If not specified, a default link::Classes/TempoClock:: will be created.

METHOD:: forceBoot
Same as code::boot::, but using link::Classes/Alga::'s code::forceBoot::.

METHOD:: fBoot
Alias for code::forceBoot::.

private:: addParamArgs
private:: currentNode
private:: nodes
Expand All @@ -41,11 +47,14 @@ The link::Classes/Symbol:: key.
ARGUMENT:: def
This can be any def supported by an link::Classes/AlgaNode:: / link::Classes/AlgaPattern::.

METHOD:: push
Push the link::Classes/AlgaProxySpace:: as the new code::currentEnvironment::.

METHOD:: pop
Restore the previous link::Classes/Environment::.

METHOD:: push
Push the link::Classes/AlgaProxySpace:: as the new code::currentEnvironment::.
METHOD:: quit
Quit link::Classes/Alga:: and restore the previous link::Classes/Environment::.

METHOD:: clear
Clear all nodes.
Expand Down
2 changes: 1 addition & 1 deletion HelpSource/Classes/AlgaSequencer.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ INSTANCEMETHODS::
EXAMPLES::
code::
(
Alga.fBoot({
Alga.boot({
//Poly sequencer featuring AlgaTemps modulating at audio rate
~seq = AlgaSequencer((
freq: (
Expand Down

0 comments on commit c6e6a48

Please sign in to comment.