6 #include "audio/audio.h"
10 /******************************************************************************
11 *******************************************************************************
15 *******************************************************************************
16 *******************************************************************************/
18 #define kMaxBuffer 4096
20 class oscdsp
: public audio
, public oscfaust::OSCIO
{
22 float ** fInBuffers
, **fOutBuffers
;
25 oscdsp(const char * dst
, int argc
, char *argv
[]) : OSCIO(dst
), fDsp(0), fInBuffers(0), fOutBuffers(0)
27 for (int i
= 1; i
< argc
-1; i
++)
28 if (!strcmp(argv
[i
], "-iodst")) setDest (argv
[i
+1]);
30 virtual ~oscdsp() { stop(); }
32 virtual bool init(const char*name
, dsp
* DSP
) {
35 fInBuffers
= new float*[numInputs()];
36 fOutBuffers
= new float*[numOutputs()];
37 for (int i
= 0; i
< numInputs(); i
++)
38 fInBuffers
[i
] = new float[kMaxBuffer
];
39 for (int i
= 0; i
< numOutputs(); i
++)
40 fOutBuffers
[i
] = new float[kMaxBuffer
];
44 virtual bool start() { return true; }
45 virtual void stop() {}
47 void compute( int nframes
) {
48 fDsp
->compute(nframes
, fInBuffers
, fOutBuffers
);
49 for (int i
= 0; i
< numOutputs(); i
++)
50 send( nframes
, fOutBuffers
[i
], i
);
53 void receive( int nvalues
, float * val
) {
54 int inChans
= numInputs();
60 for (int i
=0; i
< nvalues
; i
++) {
62 int frame
= i
/ inChans
;
63 fInBuffers
[c
][frame
] = val
[i
];
65 compute (nvalues
/ inChans
);
67 int numOutputs() const { return fDsp
? fDsp
->getNumOutputs() : 0; }
68 int numInputs() const { return fDsp
? fDsp
->getNumInputs() : 0; }