Commit a91aa9ad authored by thomas's avatar thomas
Browse files

no message


git-svn-id: https://svn.grrrr.org/ext/trunk@168 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent 1205ba62
......@@ -71,6 +71,9 @@ see flext.h for the documented base classes
Version history:
0.2.4:
- check/update function for buffer change (resize etc.)
0.2.3:
- restructured files and started usable inline documentation
- found that there was no method to output a bang?! Ugh! -> corrected
......
......@@ -23,6 +23,7 @@ flext_base::buffer::buffer(t_symbol *bn,bool delayed):
chns(0),frames(0)
{
#ifdef PD
arr = NULL;
interval = DIRTY_INTERVAL;
isdirty = false;
ticking = false;
......@@ -59,16 +60,16 @@ int flext_base::buffer::Set(t_symbol *s,bool nameonly)
else if(!nameonly) {
#ifdef PD
int frames1;
float *data1;
t_sample *data1;
t_garray *a = (t_garray *)pd_findbyclass(sym, garray_class);
if(!a)
arr = (t_garray *)pd_findbyclass(sym, garray_class);
if(!arr)
{
if (*sym->s_name) error("buffer: no such array '%s'",sym->s_name);
sym = NULL;
if(valid) ret = -1;
}
else if (!garray_getfloatarray(a, &frames1, &data1))
else if(!garray_getfloatarray(arr, &frames1, &data1))
{
error("buffer: bad template '%s'", sym->s_name);
data = NULL;
......@@ -76,7 +77,7 @@ int flext_base::buffer::Set(t_symbol *s,bool nameonly)
if(valid) ret = -1;
}
else {
garray_usedindsp(a);
garray_usedindsp(arr);
if(frames != frames1) { frames = frames1; if(!ret) ret = 1; }
if(data != data1) { data = data1; if(!ret) ret = 1; }
chns = 1;
......@@ -108,6 +109,43 @@ int flext_base::buffer::Set(t_symbol *s,bool nameonly)
return ret;
}
bool flext_base::buffer::Update()
{
if(!Ok()) return false;
#ifdef PD
int frames1;
t_sample *data1;
if(!garray_getfloatarray(arr, &frames1, &data1)) {
frames = 0;
data = NULL;
chns = 0;
return true;
}
else if(data != data1 || frames != frames1) {
frames = frames1;
data = data1;
return true;
}
else
return false;
#else // MAXMSP
if(!sym->s_thing)
return false;
else {
const _buffer *p = (const _buffer *)sym->s_thing;
if(data != p->b_samples || chns != p->b_nchans || frames != p->b_frames) {
data = p->b_samples;
chns = p->b_nchans;
frames = p->b_frames;
return true;
}
else
return false;
}
#endif
}
#ifdef PD
void flext_base::buffer::SetRefrIntv(float intv)
......@@ -156,8 +194,8 @@ void flext_base::buffer::Dirty(bool force)
#ifdef PD
void flext_base::buffer::cb_tick(buffer *b)
{
t_garray *a = (t_garray *)pd_findbyclass(b->sym, garray_class);
if (a) garray_redraw(a);
// t_garray *a = (t_garray *)pd_findbyclass(b->sym, garray_class);
if(b->arr) garray_redraw(b->arr);
// else bug("tabwrite_tilde_tick");
if(b->isdirty && b->interval) {
b->isdirty = false;
......
......@@ -92,6 +92,10 @@ public:
*/
bool Ok() const { return sym != NULL && data != NULL; }
/*! \brief Check and update if the buffer has been changed (e.g. resized)
*/
bool Update();
/*! \brief Set to specified buffer.
@param nameonly: if true sets name only, but doesn't look at buffer actually
*/
......@@ -124,6 +128,7 @@ public:
t_sample *data;
int chns,frames;
#ifdef PD
t_garray *arr;
float interval;
bool isdirty,ticking;
t_clock *tick;
......
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