flsndobj.h 1.69 KB
Newer Older
thomas's avatar
thomas committed
1
2
/* 

thomas's avatar
thomas committed
3
4
flext - C++ layer for Max/MSP and pd (pure data) externals

thomas's avatar
thomas committed
5
Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org)
thomas's avatar
thomas committed
6
7
8
9
10
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.  

*/

thomas's avatar
thomas committed
11
12
#ifndef __FLSNDOBJ_H
#define __FLSNDOBJ_H
thomas's avatar
thomas committed
13

thomas's avatar
thomas committed
14
#include "flext.h"
thomas's avatar
thomas committed
15
16
17
18

#ifndef FLEXT_THREADS
#define NOPTHREAD
#endif
thomas's avatar
thomas committed
19
#include <SndObj/AudioDefs.h>
thomas's avatar
thomas committed
20
#undef NOPTHREAD
thomas's avatar
thomas committed
21

thomas's avatar
thomas committed
22

thomas's avatar
thomas committed
23
class FLEXT_SHARE flext_sndobj:
thomas's avatar
thomas committed
24
    public flext_dsp
thomas's avatar
thomas committed
25
{
thomas's avatar
thomas committed
26
    FLEXT_HEADER(flext_sndobj,flext_dsp)
thomas's avatar
thomas committed
27
28
 
public:
thomas's avatar
thomas committed
29
    flext_sndobj();
thomas's avatar
thomas committed
30

thomas's avatar
thomas committed
31
32
33
34
    // these have to be overridden in child classes
    virtual bool NewObjs() { return true; }
    virtual void FreeObjs() {}
    virtual void ProcessObjs() {}
thomas's avatar
thomas committed
35

thomas's avatar
thomas committed
36
37
38
    // inputs and outputs
    SndObj &InObj(int i) { return *tmpobj[i]; }
    SndIO &OutObj(int i) { return *outobj[i]; }
thomas's avatar
thomas committed
39
40

protected:
thomas's avatar
thomas committed
41
42
    virtual bool Init();
    virtual void Exit();
thomas's avatar
thomas committed
43

thomas's avatar
thomas committed
44
private:
thomas's avatar
thomas committed
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    //! SndObj for reading from inlet buffer
    class Inlet:
        public SndIO
    {
    public:
        Inlet(const t_sample *b,int vecsz,float sr);
        virtual short Read();
        virtual short Write();

        void SetBuf(const t_sample *b) { buf = b; }

    private:
        const t_sample *buf;
    };

    //! SndObj for writing to outlet buffer
    class Outlet:
        public SndIO
    {
    public:
        Outlet(t_sample *b,int vecsz,float sr);
        virtual short Read();
        virtual short Write();

        void SetBuf(t_sample *b) { buf = b; }

    private:
        t_sample *buf;
    };

75
76
77
    virtual bool CbDsp(); 
    virtual void CbSignal(); 

thomas's avatar
thomas committed
78
79
80
81
82
83
84
85
86
    void ClearObjs();

    int inobjs,outobjs;
    SndObj **tmpobj;
    Inlet **inobj;
    Outlet **outobj;

    float smprt;
    int blsz;
thomas's avatar
thomas committed
87
88
89
};

#endif