Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

asSynthDef and SynthDef.name should return symbols #661

Merged
merged 3 commits into from

2 participants

@timblechmann

comments?

@telephon
Owner
timblechmann added some commits
@timblechmann timblechmann sclang: increase initial size of symbol table
prevent some rehashing at startup

Signed-off-by: Tim Blechmann <tim@klingt.org>
44f1e69
@timblechmann timblechmann class library: SynthDef - convert SynthDef name and asDefName to Symbol
the SynthDescLib uses Symbols as keys, while SynthDef and asDefName used
Strings as name. this commit fixes this inconsistency.

Signed-off-by: Tim Blechmann <tim@klingt.org>
e53221c
@timblechmann timblechmann class library: Event - allow objects responding to asDefName as instr…
…ument

Signed-off-by: Tim Blechmann <tim@klingt.org>
9e4c080
@timblechmann timblechmann merged commit 99b1ba0 into supercollider:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 25, 2012
  1. @timblechmann

    sclang: increase initial size of symbol table

    timblechmann authored
    prevent some rehashing at startup
    
    Signed-off-by: Tim Blechmann <tim@klingt.org>
  2. @timblechmann

    class library: SynthDef - convert SynthDef name and asDefName to Symbol

    timblechmann authored
    the SynthDescLib uses Symbols as keys, while SynthDef and asDefName used
    Strings as name. this commit fixes this inconsistency.
    
    Signed-off-by: Tim Blechmann <tim@klingt.org>
  3. @timblechmann

    class library: Event - allow objects responding to asDefName as instr…

    timblechmann authored
    …ument
    
    Signed-off-by: Tim Blechmann <tim@klingt.org>
This page is out of date. Refresh to see the latest.
View
19 SCClassLibrary/Common/Audio/SynthDef.sc
@@ -33,14 +33,11 @@ SynthDef {
}
*new { arg name, ugenGraphFunc, rates, prependArgs, variants, metadata;
- ^this.prNew(name).variants_(variants).metadata_(metadata).children_(Array.new(64))
+ ^super.newCopyArgs(name.asSymbol).variants_(variants).metadata_(metadata).children_(Array.new(64))
.build(ugenGraphFunc, rates, prependArgs)
}
- *prNew { arg name;
- ^super.new.name_(name.asString)
- }
- storeArgs { ^[name.asSymbol, func] }
+ storeArgs { ^[name, func] }
build { arg ugenGraphFunc, rates, prependArgs;
protect {
@@ -60,6 +57,7 @@ SynthDef {
};
^UGen.buildSynthDef.buildUgenGraph(func, rates, prependArgs);
}
+
//only write if no file exists
*writeOnce { arg name, func, rates, prependArgs, variants, dir, metadata, mdPlugin;
this.new(name, func, rates, prependArgs, variants, metadata).writeOnce(dir, mdPlugin)
@@ -308,12 +306,12 @@ SynthDef {
.format(name), this).throw
}
}
-
+
writeDef { arg file;
// This describes the file format for the synthdef files.
var allControlNamesTemp, allControlNamesMap;
- file.putPascalString(name);
+ file.putPascalString(name.asString);
this.writeConstants(file);
@@ -380,7 +378,7 @@ SynthDef {
};
};
}
-
+
writeConstants { arg file;
var array = FloatArray.newClear(constants.size);
constants.keysValuesDo { arg value, index;
@@ -405,14 +403,13 @@ SynthDef {
};
};
if(firstErr.notNil) {
- ("SynthDef" + this.name + "build failed").postln;
+ "SynthDef % build failed".format(this.name).postln;
Error(firstErr).throw
};
^true
}
-
// UGens do these
addUGen { arg ugen;
if (rewriteInProgress.isNil) {
@@ -615,7 +612,7 @@ SynthDef {
lib.servers.do { arg server;
this.doSend(server.value, completionMsg)
};
- desc = lib[this.name.asSymbol];
+ desc = lib[this.name];
desc.metadata = metadata;
SynthDesc.populateMetadataFunc.value(desc);
desc.writeMetadata(path, mdPlugin);
View
26 SCClassLibrary/Common/Audio/SynthDefOld.sc
@@ -1,10 +1,10 @@
SynthDefOld : SynthDef {
-
+
*new { arg name, ugenGraphFunc, rates, prependArgs, variants, metadata;
- ^this.prNew(name).variants_(variants).metadata_(metadata).children_(Array.new(64))
+ ^super.new.name_(name.asSymbol).variants_(variants).metadata_(metadata).children_(Array.new(64))
.build(ugenGraphFunc, rates, prependArgs)
- }
-
+ }
+
writeDefFile { arg dir, overwrite;
if((metadata.tryPerform(\at, \shouldNotSend) ? false).not) {
super.writeDefFileOld(name, dir, overwrite);
@@ -16,12 +16,12 @@ SynthDefOld : SynthDef {
.format(name), this).throw
}
}
-
+
writeDef { arg file;
// This describes the file format for the synthdef files.
var allControlNamesTemp, allControlNamesMap;
- file.putPascalString(name);
+ file.putPascalString(name.asString);
this.writeConstants(file);
@@ -88,7 +88,7 @@ SynthDefOld : SynthDef {
};
}
}
-
+
writeConstants { arg file;
var array = FloatArray.newClear(constants.size);
constants.keysValuesDo { arg value, index;
@@ -100,7 +100,7 @@ SynthDefOld : SynthDef {
file.putFloat(item)
};
}
-
+
asBytes {
var stream = CollStream.on(Int8Array.new(256));
this.asArray.writeDefOld(stream);
@@ -110,7 +110,7 @@ SynthDefOld : SynthDef {
}
+ Collection {
-
+
writeDefOld { | file |
file.putString("SCgf");
file.putInt32(1); // file version
@@ -125,7 +125,7 @@ SynthDefOld : SynthDef {
}
+ UGen {
-
+
writeDefOld { arg file;
//[\WR, this.class.name, rate, this.numInputs, this.numOutputs].postln;
file.putPascalString(this.name);
@@ -140,7 +140,7 @@ SynthDefOld : SynthDef {
this.writeOutputSpecs(file);
//[this.class.name, file.length].postln;
}
-
+
writeInputSpecOld { arg file, synthDef;
file.putInt16(synthIndex);
file.putInt16(this.outputIndex);
@@ -148,7 +148,7 @@ SynthDefOld : SynthDef {
}
+ SimpleNumber {
-
+
writeInputSpecOld { arg file, synth;
var constIndex = synth.constants.at(this.asFloat);
if (constIndex.isNil) {
@@ -160,7 +160,7 @@ SynthDefOld : SynthDef {
}
+ Object {
-
+
writeDefFileOld { arg name, dir, overwrite = (true);
StartUp.defer { // make sure the synth defs are written to the right path
View
16 SCClassLibrary/Common/Collections/Event.sc
@@ -253,17 +253,14 @@ Event : Environment {
var synthLib, desc;
// if user specifies a msgFunc, prefer user's choice
if(~msgFunc.isNil) {
- instrument = ~instrument = if(instrument.class===Symbol) {
- instrument
- } {
- instrument.asDefName.asSymbol
- };
+ instrument = ~instrument = instrument.asDefName;
+
synthLib = ~synthLib ?? { SynthDescLib.global };
desc = synthLib.at(instrument);
if (desc.notNil) {
~hasGate = desc.hasGate;
~msgFunc = desc.msgFunc;
- }{
+ } {
~msgFunc = ~defaultMsgFunc;
};
} { ~msgFunc };
@@ -273,7 +270,7 @@ Event : Environment {
instrument = instrument.asDefName;
variant = variant.dereference;
if(variant.notNil and: { synthDesc.notNil and: { synthDesc.hasVariants } })
- { (instrument ++ "." ++ variant).asSymbol }
+ { "%.%".format(instrument, variant).asSymbol }
{ instrument.asSymbol };
},
@@ -975,12 +972,12 @@ Event : Environment {
group = ~group.asControlInput;
addAction = Node.actionNumberFor(~addAction);
synthLib = ~synthLib ?? { SynthDescLib.global };
- instrumentName = ~instrument.asSymbol;
+ instrumentName = ~instrument.asDefName;
desc = synthLib.synthDescs[instrumentName];
if (desc.notNil) {
msgFunc = desc.msgFunc;
~hasGate = desc.hasGate;
- }{
+ } {
msgFunc = ~defaultMsgFunc;
};
@@ -1000,7 +997,6 @@ Event : Environment {
server.sendBundle(server.latency ? 0 + ~lag, *bndl);
} {
server.sendBundle(server.latency, *bndl);
-
};
~id = ids;
~isPlaying = true;
View
14 SCClassLibrary/Common/Control/asDefName.sc
@@ -1,30 +1,26 @@
+ SynthDef {
-
asSynthDef { ^this }
- asDefName { ^name }
-
+ asDefName { ^name }
}
+ Object {
-
asSynthDef {
- error("Cannot convert this object to a SynthDef:" + this);
+ error("Cannot convert this object to a SynthDef: " + this);
this.dump;
^nil
}
asDefName {
^this.asSynthDef.name
}
-
}
+ String {
- asDefName { ^this }
+ asDefName { ^this.asSymbol }
}
+ Symbol {
- asDefName { ^this.asString }
+ asDefName { ^this }
}
+ Function {
@@ -50,7 +46,7 @@
}
asSynthDef { arg rates, prependArgs, outClass=\Out, fadeTime, name;
- ^GraphBuilder.wrapOut(name ?? { this.identityHash.abs.asString },
+ ^GraphBuilder.wrapOut(name ?? { this.identityHash.abs.asSymbol },
this, rates, prependArgs, outClass, fadeTime
);
}
View
2  lang/LangSource/PyrLexer.cpp
@@ -1882,7 +1882,7 @@ void initPassOne()
sClassExtFiles = 0;
void *ptr = pyr_pool_runtime->Alloc(sizeof(SymbolTable));
- gMainVMGlobals->symbolTable = new (ptr) SymbolTable(pyr_pool_runtime, 8192);
+ gMainVMGlobals->symbolTable = new (ptr) SymbolTable(pyr_pool_runtime, 65536);
//gFileSymbolTable = newSymbolTable(512);
Something went wrong with that request. Please try again.