Commit 110068c6 authored by thomas's avatar thomas
Browse files

no message


git-svn-id: https://svn.grrrr.org/ext/trunk@454 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent a169d5af
#include "flext.h"
#include "flstk.h"
flext_stk::flext_stk():
blsz(0)
{}
bool flext_sndobj::Init()
{
bool ret = flext_dsp::Init();
return ret;
}
void flext_sndobj::Exit()
{
ClearObjs();
flext_dsp::Exit();
}
void flext_sndobj::ClearObjs()
{
FreeObjs();
}
void flext_sndobj::m_dsp(int n,t_sample *const *in,t_sample *const *out)
{
// called on every rebuild of the dsp chain
int i;
if(Blocksize() != blsz || Samplerate() != smprt) {
// block size or sample rate has changed... rebuild all objects
ClearObjs();
blsz = Blocksize();
Stk::setSampleRate(SampleRate())
// set up sndobjs for inlets and outlets
inobj = new Input(InSigs(),in,blsz);
outobj = new Output(OutSigs(),out,blsz);
NewObjs();
}
else {
// assign changed input/output vectors
inobj->SetBuf(InSigs(),in);
outobj->SetBuf(OutSigs(),out);
}
}
void flext_sndobj::m_signal(int n,t_sample *const *in,t_sample *const *out)
{
ProcessObjs();
}
flext_stk::Input::Input(int c,const t_sample **b,int vecsz):
chns(c),bufs(b)
{}
short flext_stk::Input::Tick()
{
if(!m_error) {
for(m_vecpos = 0; m_vecpos < m_samples; m_vecpos++)
m_output[m_vecpos] = buf[m_vecpos];
return 1;
}
else return 0;
}
flext_stk::Output::Output(int c,t_sample **b,int vecsz):
chns(c),bufs(b)
{}
short flext_stk::Output::Tick()
{
if(!m_error) {
if(m_IOobjs[0])
for(m_vecpos = 0; m_vecpos < m_samples; m_vecpos++)
buf[m_vecpos] = m_IOobjs[0]->Output(m_vecpos);
return 1;
}
else return 0;
}
/*
Copyright (c) 2002 Thomas Grill (xovo@gmx.net)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
#ifndef __FLSTK_H
#define __FLSTK_H
#include "flext.h"
#include <stk.h>
class FLEXT_SHARE flext_stk:
public flext_dsp
{
FLEXT_HEADER(flext_stk,flext_dsp)
public:
flext_stk();
// these have to be overridden in child classes
virtual void NewObjs() {}
virtual void FreeObjs() {}
virtual void ProcessObjs() {}
protected:
virtual bool Init();
virtual void Exit();
virtual void m_dsp(int n,t_sample *const *in,t_sample *const *out);
virtual void m_signal(int n,t_sample *const *in,t_sample *const *out);
private:
//! STK object for reading from inlet buffer
class Input:
public Stk
{
public:
Input(int chns,const t_sample **b,int vecsz,float sr);
int Chns() const { return chns; }
void SetBufs(int c,const t_sample **b) { chns = c,buf = b; }
t_sample tick();
t_sample *tick(t_sample *vector,unsigned int vectorSize);
const t_sample *tickFrame();
t_sample *tickFrame(t_sample *frameVector,unsigned int frames);
private:
int chns;
const t_sample **buf;
};
//! STK object for writing to outlet buffer
class Output:
public Stk
{
public:
Output(int chns,t_sample **b,int vecsz,float sr);
int Chns() const { return chns; }
void SetBufs(int c,t_sample **b) { chns = c,buf = b; }
void tick(const t_sample sample);
void tick(const t_sample *vector,unsigned int vectorSize);
void tickFrame(const t_sample *frameVector,unsigned int frames = 1);
private:
int chns;
t_sample **buf;
};
void ClearObjs();
Input *inobj;
Output *outobj;
int blsz;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment