Skip to content

Commit

Permalink
Make sampleRate value integer strings.
Browse files Browse the repository at this point in the history
Fixes supercollider / sc3-plugins #244
supercollider/sc3-plugins#224
  • Loading branch information
mtmccrea committed Oct 25, 2018
1 parent e4ec543 commit 6b7456c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 46 deletions.
94 changes: 49 additions & 45 deletions Classes/ATKMatrix.sc
Original file line number Diff line number Diff line change
Expand Up @@ -1952,8 +1952,13 @@ FoaDecoderKernel {
var databasePath, subjectPath;
var chans;
var errorMsg;
var sampleRateStr;

if((server.serverRunning.not) && (sampleRate.isNil) && (score.isNil), {
if(sampleRate.notNil, {
sampleRateStr = sampleRate.asInteger.asString;
});

if((server.serverRunning.not) && (sampleRateStr.isNil) && (score.isNil), {
Error(
"Please boot server: %, or provide a CtkScore or Score.".format(
server.name.asString
Expand All @@ -1970,35 +1975,33 @@ FoaDecoderKernel {
// init dirChannels (output channel (speaker) directions) and kernel sr
if ( kind == 'uhj', {
dirChannels = [ pi/6, pi.neg/6 ];
sampleRate = "None";
sampleRateStr = "None";
}, {
dirChannels = [ 5/9 * pi, 5/9 * pi.neg ];
if(sampleRate.isNil, {
sampleRate = server.sampleRate.asString;
}, {
sampleRate = sampleRate.asString;
});
if(sampleRateStr.isNil, {
sampleRateStr = server.sampleRate.asInteger.asString;
});
});

// init kernelSize if need be (usually for HRIRs)
if ( kernelSize == nil, {
kernelSize = Dictionary.newFrom([
'None', 512,
'44100', 512,
'48000', 512,
'88200', 1024,
'96000', 1024,
'176400', 2048,
'192000', 2048,
]).at(sampleRate.asSymbol)
kernelSize = switch(sampleRateStr.asSymbol,
'None', 512,
'44100', 512,
'48000', 512,
'88200', 1024,
'96000', 1024,
'176400', 2048,
'192000', 2048
);
});


// init kernel root, generate subjectPath and kernelFiles
databasePath = this.initPath;

subjectPath = databasePath +/+ PathName.new(
sampleRate ++ "/" ++
sampleRateStr ++ "/" ++
kernelSize ++ "/" ++
subjectID.asString.padLeft(4, "0")
);
Expand All @@ -2024,7 +2027,7 @@ FoaDecoderKernel {
("\t" + folder.folderName).postln;
});

errorMsg = "Samplerate = % is not available for".format(sampleRate)
errorMsg = "Samplerate = % is not available for".format(sampleRateStr)
+
"% kernel decoder.".format(kind)
}
Expand Down Expand Up @@ -2240,8 +2243,13 @@ FoaEncoderKernel {
var databasePath, subjectPath;
var chans;
var errorMsg;
var sampleRateStr;

if(sampleRate.notNil, {
sampleRateStr = sampleRate.asInteger.asString;
});

if((server.serverRunning.not) && (sampleRate.isNil) && (score.isNil), {
if((server.serverRunning.not) && (sampleRateStr.isNil) && (score.isNil), {
Error(
"Please boot server: %, or provide a CtkScore or Score.".format(
server.name.asString
Expand All @@ -2257,30 +2265,26 @@ FoaEncoderKernel {
switch ( kind,
'super', {
dirChannels = [ pi/4, pi.neg/4 ]; // approx, doesn't include phasiness
sampleRate = "None";
sampleRateStr = "None";
chans = 3; // [w, x, y]
},
'uhj', {
dirChannels = [ inf, inf ];
if(sampleRate.isNil, {
sampleRate = server.sampleRate.asString;
}, {
sampleRate = sampleRate.asString;
});
if(sampleRateStr.isNil, {
sampleRateStr = server.sampleRate.asInteger.asString;
});
chans = 3; // [w, x, y]
},
'spread', {
dirChannels = [ inf ];
if(sampleRate.isNil, {
sampleRate = server.sampleRate.asString;
}, {
sampleRate = sampleRate.asString;
});
if(sampleRateStr.isNil, {
sampleRateStr = server.sampleRate.asInteger.asString;
});
chans = 4; // [w, x, y, z]
},
'diffuse', {
dirChannels = [ inf ];
sampleRate = "None";
sampleRateStr = "None";
chans = 4; // [w, x, y, z]
}

Expand All @@ -2292,40 +2296,40 @@ FoaEncoderKernel {
// },
// 'greathall', {
// dirChannels = [ inf ];
// sampleRate = server.sampleRate.asString;
// sampleRateStr = server.sampleRate.asInteger.asString;
// chans = 4; // [w, x, y, z]
// },
// 'octagon', {
// dirChannels = [ inf ];
// sampleRate = server.sampleRate.asString;
// sampleRateStr = server.sampleRate.asInteger.asString;
// chans = 4; // [w, x, y, z]
// },
// 'classroom', {
// dirChannels = [ inf ];
// sampleRate = server.sampleRate.asString;
// sampleRateStr = server.sampleRate.asInteger.asString;
// chans = 4; // [w, x, y, z]
// }
);

// init kernelSize if need be
if ( kernelSize == nil, {
kernelSize = Dictionary.newFrom([
'None', 512,
'44100', 512,
'48000', 512,
'88200', 1024,
'96000', 1024,
'176400', 2048,
'192000', 2048,
]).at(sampleRate.asSymbol)
kernelSize = switch(sampleRateStr.asSymbol,
'None', 512,
'44100', 512,
'48000', 512,
'88200', 1024,
'96000', 1024,
'176400', 2048,
'192000', 2048
);
});


// init kernel root, generate subjectPath and kernelFiles
databasePath = this.initPath;

subjectPath = databasePath +/+ PathName.new(
sampleRate ++ "/" ++
sampleRateStr ++ "/" ++
kernelSize ++ "/" ++
subjectID.asString.padLeft(4, "0")
);
Expand All @@ -2351,7 +2355,7 @@ FoaEncoderKernel {
("\t" + folder.folderName).postln;
});

errorMsg = "Samplerate = % is not available for".format(sampleRate)
errorMsg = "Samplerate = % is not available for".format(sampleRateStr)
+
"% kernel encoder.".format(kind)
}
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ Ambisonic Toolkit.
List of Changes
---------------

Version 4.0.3

* Issue fixes:
* Make sampleRate value integer strings to support SC 3.10. Fixes
[supercollider/sc3-plugins #244](https://github.com/supercollider/sc3-plugins/issues/224).


Version 4.0.2

* Issue fixes:
Expand Down Expand Up @@ -337,6 +344,10 @@ are copyright the Ambisonic Toolkit Community and Joseph Anderson,

Contributors
------------
Version 4.0.3
* Michael McCrea (@mtmccrea)
* Eirik Arthur Blekesaune (@blacksound)

Version 4.0.2
* Michael McCrea (@mtmccrea)
* David Granström (@davidgranstrom)
Expand Down
2 changes: 1 addition & 1 deletion atk-sc3.quark
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\author: "Joseph Anderson, Josh Parmenter, Michael McCrea, & the Ambisonic Toolkit Community",
\copyright: "Ambisonic Toolkit Community, Joseph Anderson, Josh Parmenter, and Michael McCrea 2011, 2016-18",
\license: "GPL",
\version: "4.0.2",
\version: "4.0.3",
\schelp: "Intro-to-the-ATK",
\url: "https://github.com/ambisonictoolkit/atk-sc3",
\dependencies: [
Expand Down

0 comments on commit 6b7456c

Please sign in to comment.