*** empty log message ***
[chuck-blob.git] / v2 / chuck_ugen.h
blob91cf0020c9ba03815f7531dee523a15a3dad3e75
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 );
75 t_CKUINT system_tick_v( t_CKTIME now, t_CKUINT numFrames );
76 t_CKBOOL alloc_v( t_CKUINT size );
78 protected:
79 t_CKVOID add_by( Chuck_UGen * dest, t_CKBOOL isUpChuck );
80 t_CKVOID remove_by( Chuck_UGen * dest );
82 public:
83 // tick function
84 f_tick tick;
85 // msg function
86 f_pmsg pmsg;
87 // channels (if more than one is required)
88 Chuck_UGen ** m_multi_chan;
89 // size of m_multi_chan;
90 t_CKUINT m_multi_chan_size;
91 // number of channels
92 t_CKUINT m_num_ins;
93 // number of channels
94 t_CKUINT m_num_outs;
95 // alloc multi channels
96 void alloc_multi_chan( t_CKUINT num_ins, t_CKUINT num_outs );
98 public: // data
99 Chuck_UGen ** m_src_list;
100 t_CKUINT m_src_cap;
101 t_CKUINT m_num_src;
102 Chuck_UGen ** m_dest_list;
103 t_CKUINT m_dest_cap;
104 t_CKUINT m_num_dest;
105 Chuck_UGen ** m_src_uana_list;
106 t_CKUINT m_src_uana_cap;
107 t_CKUINT m_num_uana_src;
108 Chuck_UGen ** m_dest_uana_list;
109 t_CKUINT m_dest_uana_cap;
110 t_CKUINT m_num_uana_dest;
111 t_CKUINT m_max_src;
112 t_CKTIME m_time;
113 t_CKBOOL m_valid;
114 t_CKBOOL m_use_next;
115 SAMPLE m_sum;
116 SAMPLE m_current;
117 SAMPLE m_next;
118 SAMPLE m_last;
119 SAMPLE m_gain;
120 SAMPLE m_pan;
121 t_CKINT m_op;
123 // block processing
124 SAMPLE * m_sum_v;
125 SAMPLE * m_current_v;
127 // the shred on which the ugen is created
128 Chuck_VM_Shred * shred;
129 // owner
130 Chuck_UGen * owner;
132 // what a hack!
133 t_CKBOOL m_is_uana;
139 //-----------------------------------------------------------------------------
140 // name: struct Chuck_UAna
141 // dsec: uana base
142 //-----------------------------------------------------------------------------
143 struct Chuck_UAna : public Chuck_UGen
145 public:
146 Chuck_UAna( );
147 virtual ~Chuck_UAna( );
149 public:
150 t_CKBOOL system_tock( t_CKTIME now );
151 t_CKBOOL is_up_connected_from( Chuck_UAna * src );
153 public: // blob retrieval
154 t_CKINT numIncomingUAnae() const;
155 Chuck_UAna * getIncomingUAna( t_CKUINT index ) const;
156 Chuck_UAnaBlobProxy * getIncomingBlob( t_CKUINT index ) const;
157 Chuck_UAnaBlobProxy * blobProxy() const;
159 public:
160 // tock function
161 f_tock tock;
163 public: // data
164 t_CKTIME m_uana_time;
165 // Chuck_UAnaBlobProxy * m_blob_proxy;
171 #endif