aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/vasp/source/vasp.h
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2002-12-02 19:21:08 +0000
committerThomas Grill <xovo@users.sourceforge.net>2002-12-02 19:21:08 +0000
commit9815096db22c73cacdbb65512d1b61d633db7fa8 (patch)
tree4a6582ead85b8efd031f68e717fbc8a5b3a3df3f /externals/grill/vasp/source/vasp.h
parent0a109da279e9df66fb5ea7d6bdaeffed16592f02 (diff)
"version 0.1.1"
svn path=/trunk/; revision=267
Diffstat (limited to 'externals/grill/vasp/source/vasp.h')
-rw-r--r--externals/grill/vasp/source/vasp.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/externals/grill/vasp/source/vasp.h b/externals/grill/vasp/source/vasp.h
new file mode 100644
index 00000000..ab4530c7
--- /dev/null
+++ b/externals/grill/vasp/source/vasp.h
@@ -0,0 +1,142 @@
+/*
+
+VASP modular - vector assembling signal processor / objects for Max/MSP and PD
+
+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 __VASP__H
+#define __VASP__H
+
+#include "vbuffer.h"
+
+class Vasp
+{
+public:
+ class Ref {
+ public:
+ Ref(): sym(NULL) {}
+ Ref(VBuffer &b);
+ Ref(VSymbol &s,I c,I o);
+ Ref(const Ref &r) { operator =(r); }
+ ~Ref();
+
+ Ref &operator =(const Ref &r);
+
+ V Clear() { sym.Clear(); }
+ BL Ok() const { return sym.Ok(); }
+
+ VSymbol &Symbol() { return sym; }
+ const VSymbol &Symbol() const { return sym; }
+ V Symbol(const VSymbol &s);
+ I Channel() const { return chn; }
+ V Channel(I c) { chn = c; }
+ I Offset() const { return offs; }
+ V Offset(I o) { offs = o; }
+ V OffsetD(I o) { offs += o; }
+
+ protected:
+ VSymbol sym;
+ I chn;
+ I offs; // counted in frames
+ };
+
+ Vasp();
+ Vasp(I argc,const t_atom *argv);
+ Vasp(const Vasp &v);
+ Vasp(I frames,const Ref &r);
+ ~Vasp();
+
+ static BL ChkArgs(I argc,const t_atom *argv);
+
+ const C *thisName() const { return typeid(*this).name(); }
+
+ // check if vasp reference is valid
+ BL Check() const;
+
+ Vasp &operator =(const Vasp &v);
+ Vasp &operator ()(I argc,const t_atom *argv /*,BL withvasp = false*/);
+
+ // add another vector
+ Vasp &operator +=(const Ref &r);
+ // add vectors of another vasp
+ Vasp &operator +=(const Vasp &v);
+
+ // set used channels to 0
+ Vasp &Clear() { frames = 0; chns = 0; return *this; }
+
+ // used vectors
+ I Vectors() const { return chns; }
+
+ // length of the vasp (in frames)
+ I Frames() const { return frames; }
+ // set frame count
+ V Frames(I fr) { frames = fr; }
+ // set frame count differentially
+ V FramesD(I frd) { if(frames >= 0) frames += frd; }
+ // set frame count
+ V FramesM(R f) { if(frames >= 0) frames = (int)(frames*f); }
+ // set frame count
+ V FramesR(R f) { if(f) FramesM(1./f); else Frames(0); }
+
+ // set buffer sizes
+ V Size(I fr);
+ // set frame count differentially
+ V SizeD(I frd);
+ // set frame count
+ V SizeM(R f);
+ // set frame count
+ V SizeR(R f) { if(f) SizeM(1./f); else Size(0); }
+
+ // actual length of the vasp (in frames)
+ I ChkFrames() const;
+
+ // set offset(s)
+ V Offset(I fr);
+ // set offset(s) differentially
+ V OffsetD(I fr);
+
+ // set channel(s)
+ V Channel(I ch);
+
+ BL Ok() const { return ref && Vectors() > 0; }
+ BL IsComplex() const { return ref && Vectors() >= 2 && ref[1].Ok(); }
+
+ // get any vector - test if in range 0..Vectors()-1!
+ const Ref &Vector(I ix) const { return ref[ix]; }
+ Ref &Vector(I ix) { return ref[ix]; }
+
+ // get real part - be sure that Ok!
+ const Ref &Real() const { return Vector(0); }
+ Ref &Real() { return Vector(0); }
+
+ // get imaginary part - be sure that Complex!
+ const Ref &Imag() const { return Vector(1); }
+ Ref &Imag() { return Vector(1); }
+
+ // get buffer associated to a channel
+ VBuffer *Buffer(I ix) const;
+
+ // Real/Complex
+ VBuffer *ReBuffer() const { return Buffer(0); }
+ VBuffer *ImBuffer() const { return Buffer(1); }
+
+ // prepare and reference t_atom list for output
+ flext::AtomList *MakeList(BL withvasp = true);
+
+ // make a graphical update of all buffers in vasp
+ V Refresh();
+
+protected:
+ I frames; // length counted in frames
+ I chns; // used channels
+ I refs; // allocated channels (>= chns)
+ Ref *ref;
+
+ V Resize(I rcnt);
+};
+
+#endif