*** empty log message ***
[chuck-blob.git] / v2 / chuck_ugen.h
blob16d72e8fc090eb8786723d330134b427a70a34c2
1 /*----------------------------------------------------------------------------
2 ChucK Concurrent, On-the-fly Audio Programming Language
3 Compiler and Virtual Machine
5 Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.cs.princeton.edu/
7 http://soundlab.cs.princeton.edu/
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 U.S.A.
23 -----------------------------------------------------------------------------*/
25 //-----------------------------------------------------------------------------
26 // name: chuck_ugen.h
27 // desc: chuck unit generator interface
29 // authors: Ge Wang (gewang@cs.princeton.edu)
30 // Perry R. Cook (prc@cs.princeton.edu)
31 // Rebecca Fiebrink (fiebrink@cs.princeton.edu)
32 // date: spring 2004 - 1.1
33 // spring 2005 - 1.2
34 // spring 2007 - UAna
35 //-----------------------------------------------------------------------------
36 #ifndef __CHUCK_UGEN_H__
37 #define __CHUCK_UGEN_H__
39 #include "chuck_def.h"
40 #include "chuck_oo.h"
41 #include "chuck_dl.h"
44 // forward reference
45 struct Chuck_VM_Shred;
46 struct Chuck_UAnaBlobProxy;
49 // op mode
50 #define UGEN_OP_PASS -1
51 #define UGEN_OP_STOP 0
52 #define UGEN_OP_TICK 1
54 //-----------------------------------------------------------------------------
55 // name: struct Chuck_UGen
56 // dsec: ugen base
57 //-----------------------------------------------------------------------------
58 struct Chuck_UGen : public Chuck_Object
60 public:
61 Chuck_UGen( );
62 virtual ~Chuck_UGen( );
63 virtual void init();
64 virtual void done();
66 public: // src
67 t_CKBOOL add( Chuck_UGen * src, t_CKBOOL isUpChuck );
68 t_CKBOOL remove( Chuck_UGen * src );
69 t_CKVOID remove_all( );
70 t_CKBOOL set_max_src( t_CKUINT num );
71 t_CKUINT get_num_src( );
72 t_CKBOOL is_connected_from( Chuck_UGen * src );
73 t_CKUINT disconnect( t_CKBOOL recursive );
74 t_CKUINT system_tick( t_CKTIME now );
76 protected:
77 t_CKVOID add_by( Chuck_UGen * dest, t_CKBOOL isUpChuck );
78 t_CKVOID remove_by( Chuck_UGen * dest );
80 public:
81 // tick function
82 f_tick tick;
83 // msg function
84 f_pmsg pmsg;
85 // channels (if more than one is required)
86 Chuck_UGen ** m_multi_chan;
87 // size of m_multi_chan;
88 t_CKUINT m_multi_chan_size;
89 // number of channels
90 t_CKUINT m_num_ins;
91 // number of channels
92 t_CKUINT m_num_outs;
93 // alloc multi channels
94 void alloc_multi_chan( t_CKUINT num_ins, t_CKUINT num_outs );
96 public: // data
97 Chuck_UGen ** m_src_list;
98 t_CKUINT m_src_cap;
99 t_CKUINT m_num_src;
100 Chuck_UGen ** m_dest_list;
101 t_CKUINT m_dest_cap;
102 t_CKUINT m_num_dest;
103 Chuck_UGen ** m_src_uana_list;
104 t_CKUINT m_src_uana_cap;
105 t_CKUINT m_num_uana_src;
106 Chuck_UGen ** m_dest_uana_list;
107 t_CKUINT m_dest_uana_cap;
108 t_CKUINT m_num_uana_dest;
109 t_CKUINT m_max_src;
110 t_CKTIME m_time;
111 t_CKBOOL m_valid;
112 t_CKBOOL m_use_next;
113 SAMPLE m_sum;
114 SAMPLE m_current;
115 SAMPLE m_next;
116 SAMPLE m_last;
117 SAMPLE m_gain;
118 SAMPLE m_pan;
119 t_CKINT m_op;
121 // the shred on which the ugen is created
122 Chuck_VM_Shred * shred;
123 // owner
124 Chuck_UGen * owner;
126 // what a hack!
127 t_CKBOOL m_is_uana;
133 //-----------------------------------------------------------------------------
134 // name: struct Chuck_UAna
135 // dsec: uana base
136 //-----------------------------------------------------------------------------
137 struct Chuck_UAna : public Chuck_UGen
139 public:
140 Chuck_UAna( );
141 virtual ~Chuck_UAna( );
143 public:
144 t_CKBOOL system_tock( t_CKTIME now );
145 t_CKBOOL is_up_connected_from( Chuck_UAna * src );
147 public: // blob retrieval
148 t_CKINT numIncomingUAnae() const;
149 Chuck_UAna * getIncomingUAna( t_CKUINT index ) const;
150 Chuck_UAnaBlobProxy * getIncomingBlob( t_CKUINT index ) const;
151 Chuck_UAnaBlobProxy * blobProxy() const;
153 public:
154 // tock function
155 f_tock tock;
157 public: // data
158 t_CKTIME m_uana_time;
159 // Chuck_UAnaBlobProxy * m_blob_proxy;
165 #endif