Skip to content
Browse files

fixed minor issues in DBAP4, DBAP4e

  • Loading branch information...
1 parent 42baa1d commit 0a2b514978c5a00a81f232e3c2dedaaed0ce18da @hoch hoch committed Oct 24, 2012
Showing with 23 additions and 9 deletions.
  1. +1 −0 panning/DBAP4.ck
  2. +22 −9 panning/DBAP4e.ck
View
1 panning/DBAP4.ck
@@ -33,6 +33,7 @@ class DBAP4 extends Chubgraph
// NOTE: for plain 4-ch setup, use this code
_in => _out[i] => dac.chan(i);
// NOTE: for binaural mixdown, use the line below
+ // b4 is an instance of Binaural4 class
// _in => _out[i] => b4.pssp[i];
20::ms => _out[i].duration;
0.0 => _out[i].target;
View
31 panning/DBAP4e.ck
@@ -3,12 +3,22 @@
// @desc General purpose panner for 4-channel configuration. Based
// on DBAP (distance based amplitude panning) method.
// Some experimental effects are added to enhance spatial cues.
-// @revision 2
+// @note This class requires Binaural4.ck as a public class
+// @revision 4
// @version chuck-1.3.1.3
class DBAP4e extends Chubgraph
{
+ // switch
+ 0 => int _BINAURAL;
+
+ // warning
+ if (dac.channels() < 4) {
+ cherr <= "[DBAP4] Insufficient output ports. Add Binaural4 class to VM.\n";
+ 1 => _BINAURAL;
+ }
+
// position of speakers: LF, RF, LR, RR (Z-config)
[[-1.0, 1.0], [1.0, 1.0], [-1.0, -1.0], [1.0, -1.0]]
@=> float _spks[][];
@@ -21,19 +31,22 @@ class DBAP4e extends Chubgraph
Envelope _out[4];
DelayA _d[4];
NRev _r[4];
+ Binaural4 _b4;
// initialization
inlet => _in;
20::ms => _in.duration;
1.0 => _in.target;
for (0 => int i; i < 4; ++i) {
- _in => _out[i] => d[i] => r[i] => dac.chan(i);
- // NOTE: for binaural mixdown, use the line below
- // _in => _out[i] => d[i] => r[i] => b4.pssp[i];
+ if (_BINAURAL == 0) {
+ _in => _out[i] => _d[i] => _r[i] => dac.chan(i);
+ } else {
+ _in => _out[i] => _d[i] => _r[i] => _b4.input[i];
+ }
20::ms => _out[i].duration;
- 1.0 => _out[i].target;
+ 0.0 => _out[i].target;
20::ms => _d[i].max;
- 0.1 => r[i].mix;
+ 0.1 => _r[i].mix;
}
.5::ms => _d[0].delay;
@@ -47,8 +60,8 @@ class DBAP4e extends Chubgraph
x => _x;
y => _y;
for(0 => int i; i < 4; ++i) {
- _spks[i][0] - _x => float dx;
- _spks[i][1] - _y => float dy;
+ _spks[i][0] - x => float dx;
+ _spks[i][1] - y => float dy;
dx * dx => dx;
dy * dy => dy;
Math.sqrt(dx + dy) => float dist;
@@ -73,7 +86,7 @@ class DBAP4e extends Chubgraph
// NOTE: an array of 4 floats between 0.5 ~ 20(ms)
// ex) d4e.setDelayTime([0.5, 10, 5, 17]);
fun void setDelayTime(float dt[]) {
- if (dt.cap < 4) {
+ if (dt.cap() < 4) {
<<< "[DBAP4e] Invalid array." >>>;
return;
} else {

0 comments on commit 0a2b514

Please sign in to comment.
Something went wrong with that request. Please try again.