Commit ee33013e authored by thomas's avatar thomas
Browse files

no message


git-svn-id: https://svn.grrrr.org/ext/trunk@181 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent 809054b0
......@@ -90,6 +90,10 @@ SOURCE=.\readme.txt
# End Group
# Begin Source File
SOURCE=.\flatom.cpp
# End Source File
# Begin Source File
SOURCE=.\flbase.cpp
# End Source File
# Begin Source File
......@@ -114,6 +118,10 @@ SOURCE=.\fldsp.cpp
# End Source File
# Begin Source File
SOURCE=.\fldsp.h
# End Source File
# Begin Source File
SOURCE=.\flext.cpp
# End Source File
# Begin Source File
......
......@@ -87,7 +87,7 @@ Version history:
- added AddInBang/AddOutBang (same as Add*Symbol - unchecked)
- buffer class: added "bool Ok()" check function
- switched on error posting for unhandled messages
- added XletCode and AddInlets/AddOutlets for multiple Inlet/Outlet addition
- added XletCode and AddInlets/AddOutlets for multiple Inlet/Outlet addition (max. 9 inlets/outlets)
- if float or int message is not handled explicitly then [list float/int( is tried
0.2.2:
......@@ -173,6 +173,7 @@ general:
bugs:
- PD: problems with timed buffer redrawing (takes a lot of cpu time)
- introduce timed thread termination upon object destruction
tests:
- PD: figure out what "pointer" messages do and where they occur
......
#include "atoms.h"
//#include <math.h>
/*
flext - C++ layer for Max/MSP and pd (pure data) externals
AtomList::AtomList(I argc,t_atom *argv):
Copyright (c) 2001,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.
*/
/*! \file flatom.cpp
\brief Definitions for handling the t_atom type and lists thereof.
*/
#include <flext.h>
flext_base::AtomList::AtomList(int argc,t_atom *argv):
cnt(argc)
{
lst = new t_atom[cnt];
if(argv) {
for(I i = 0; i < argc; ++i) {
for(int i = 0; i < argc; ++i) {
switch(lst[i].a_type = argv[i].a_type) {
case A_FLOAT:
lst[i].a_w.w_float = argv[i].a_w.w_float;
......@@ -35,7 +47,7 @@ AtomList::AtomList(I argc,t_atom *argv):
}
}
AtomList::~AtomList()
flext_base::AtomList::~AtomList()
{
if(lst) delete[] lst;
}
......
......@@ -389,8 +389,38 @@ public:
};
#endif // FLEXT_THREADS
// --- list creation stuff ----------------------------------------
// --- atom list stuff -------------------------------------------
class AtomList
{
public:
AtomList(int argc,t_atom *argv = NULL);
~AtomList();
int Count() const { return cnt; }
t_atom &operator [](int ix) { return lst[ix]; }
const t_atom &operator [](int ix) const { return lst[ix]; }
t_atom *Atoms() { return lst; }
const t_atom *Atoms() const { return lst; }
protected:
int cnt;
t_atom *lst;
};
class AtomAnything:
public AtomList
{
public:
AtomAnything(const t_symbol *h,int argc,t_atom *argv): AtomList(argc,argv),hdr(h) {}
const t_symbol *Header() const { return hdr; }
protected:
const t_symbol *hdr;
};
// --- clock stuff ------------------------------------------------
......@@ -485,7 +515,7 @@ private:
class qmsg;
qmsg *qhead,*qtail;
t_clock *qclk;
pthread_mutex_t qmutex;
ThrMutex qmutex;
static void QTick(flext_base *th);
void Queue(qmsg *m);
......@@ -535,92 +565,4 @@ private:
#endif
};
// === flext_dsp ==================================================
/*! \class flext_dsp
\brief dsp enabled base object
*/
class flext_dsp:
public flext_base
{
FLEXT_HEADER_S(flext_dsp,flext_base,Setup)
public:
//! returns current sample rate
float Samplerate() const { return srate; }
//! returns current block size
int Blocksize() const { return blksz; }
//! returns number of audio system input channels
int ChannelsIn() const { return chnsin; }
//! returns number of audio system output channels
int ChannelsOut() const { return chnsout; }
// --- inheritable virtual methods --------------------------------
/*! \brief Called on every dsp init.
\remark Don't expect any valid data in the signal vectors!
@param n: frames (aka samples) in one signal vector
@param insigs: array of input vectors (get number with function CntInSig())
@param outsigs: array of output vectors (get number with function CntOutSig())
*/
virtual void m_dsp(int n,t_sample *const *insigs,t_sample *const *outsigs);
/*! \brief Called with every signal vector.
Here you do the dsp calculation
@param n: frames (aka samples) in one signal vector
@param insigs: array of input vectors (get number with function CntInSig())
@param outsigs: array of output vectors (get number with function CntOutSig())
*/
virtual void m_signal(int n,t_sample *const *insigs,t_sample *const *outsigs) = 0;
#ifndef MAXMSP
//! called with "enable" message: pauses/resumes dsp - implicitely defined in MaxMSP
virtual void m_enable(bool on);
#endif
// --- inlet/outlet stuff -----------------------------------------
//! add signal inlet
void AddInSignal(int m = 1) { AddInlet(xlet::tp_sig,m); }
//! add signal outlet
void AddOutSignal(int m = 1) { AddOutlet(xlet::tp_sig,m); }
protected:
flext_dsp();
~flext_dsp();
private:
// not static, could be different in different patchers..
float srate;
int blksz;
int chnsin,chnsout;
// setup function
static void Setup(t_class *c);
// callback functions
static void cb_dsp(t_class *c,t_signal **s);
#ifndef MAXMSP
static void cb_enable(t_class *c,t_flint on);
bool dspon;
#endif
// dsp stuff
static t_int *dspmeth(t_int *w);
t_sample **invecs,**outvecs;
};
#endif
/*
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001,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.
*/
/*! \file fldsp.h
\brief Declares the flext dsp class
!Lacking Details.!
*/
#ifndef __FLDSP_H
#define __FLDSP_H
//! include the header file declaring the base classes
#include <flext.h>
// === flext_dsp ==================================================
/*! \class flext_dsp
\brief dsp enabled base object
*/
class flext_dsp:
public flext_base
{
FLEXT_HEADER_S(flext_dsp,flext_base,Setup)
public:
//! returns current sample rate
float Samplerate() const { return srate; }
//! returns current block size
int Blocksize() const { return blksz; }
//! returns number of audio system input channels
int ChannelsIn() const { return chnsin; }
//! returns number of audio system output channels
int ChannelsOut() const { return chnsout; }
// --- inheritable virtual methods --------------------------------
/*! \brief Called on every dsp init.
\remark Don't expect any valid data in the signal vectors!
@param n: frames (aka samples) in one signal vector
@param insigs: array of input vectors (get number with function CntInSig())
@param outsigs: array of output vectors (get number with function CntOutSig())
*/
virtual void m_dsp(int n,t_sample *const *insigs,t_sample *const *outsigs);
/*! \brief Called with every signal vector.
Here you do the dsp calculation
@param n: frames (aka samples) in one signal vector
@param insigs: array of input vectors (get number with function CntInSig())
@param outsigs: array of output vectors (get number with function CntOutSig())
*/
virtual void m_signal(int n,t_sample *const *insigs,t_sample *const *outsigs) = 0;
#ifndef MAXMSP
//! called with "enable" message: pauses/resumes dsp - implicitely defined in MaxMSP
virtual void m_enable(bool on);
#endif
// --- inlet/outlet stuff -----------------------------------------
//! add signal inlet
void AddInSignal(int m = 1) { AddInlet(xlet::tp_sig,m); }
//! add signal outlet
void AddOutSignal(int m = 1) { AddOutlet(xlet::tp_sig,m); }
protected:
flext_dsp();
~flext_dsp();
private:
// not static, could be different in different patchers..
float srate;
int blksz;
int chnsin,chnsout;
// setup function
static void Setup(t_class *c);
// callback functions
static void cb_dsp(t_class *c,t_signal **s);
#ifndef MAXMSP
static void cb_enable(t_class *c,t_flint on);
bool dspon;
#endif
// dsp stuff
static t_int *dspmeth(t_int *w);
t_sample **invecs,**outvecs;
};
#endif
......@@ -142,7 +142,6 @@ flext_base::flext_base():
thrcount = 0;
shouldexit = false;
qhead = qtail = NULL;
pthread_mutex_init(&qmutex,NULL);
qclk = clock_new(this,(t_method)QTick);
#endif
}
......@@ -156,7 +155,6 @@ flext_base::~flext_base()
while(qhead) QTick(this);
clock_free(qclk);
pthread_mutex_destroy(&qmutex);
#endif
if(inlist) delete inlist;
......@@ -214,6 +212,13 @@ unsigned long flext_base::XletCode(xlet::type tp,...)
int cnt = 0;
xlet::type *args = NULL,arg = tp;
for(; arg; ++cnt) {
#ifdef _DEBUG
if(cnt > 9) {
error("%s - Too many in/outlets defined - truncated to 9",thisName());
break;
}
#endif
code = code*10+(int)arg;
arg = (xlet::type)va_arg(marker,int);
}
......
......@@ -22,12 +22,15 @@ WARRANTIES, see the file, "license.txt," in this distribution.
//! flext version string
#define FLEXT_VERSTR "0.3.0pre"
// include all the important flext interface definitions
// include all the flext interface definitions
#include <fldefs.h>
// include the basic flext object classes
#include <flclass.h>
// include the flext dsp class
#include <fldsp.h>
// include pthreads if threading is enabled
#ifdef FLEXT_THREADS
#include <flthr.h>
......
......@@ -14,9 +14,9 @@ WARRANTIES, see the file, "license.txt," in this distribution.
bool flext_base::StartThread(void *(*meth)(thr_params *p),thr_params *p,char *methname)
{
#ifdef DEBUG
#ifdef _DEBUG
if(!p) {
error("%s - No parameters given for method launch!",methname);
ERRINTERNAL();
return false;
}
#endif
......@@ -86,12 +86,12 @@ void flext_base::QTick(flext_base *th)
{
#ifdef DEBUG
if(!th->IsSystemThread()) {
error("Queue tick called by wrong thread!");
error("flext - Queue tick called by wrong thread!");
return;
}
#endif
pthread_mutex_lock(&th->qmutex);
th->qmutex.Lock();
while(th->qhead) {
qmsg *m = th->qhead;
......@@ -112,15 +112,15 @@ void flext_base::QTick(flext_base *th)
m->nxt = NULL;
delete m;
}
pthread_mutex_unlock(&th->qmutex);
th->qmutex.Unlock();
}
void flext_base::Queue(qmsg *m)
{
pthread_mutex_lock(&qmutex);
qmutex.Lock();
if(qhead) qtail->Add(m);
else qhead = qtail = m;
pthread_mutex_unlock(&qmutex);
qmutex.Unlock();
clock_delay(qclk,0);
}
......
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