Debian Codegraph @

src/core/chuck_ugen.h

raw symbols SCIP
1 /*----------------------------------------------------------------------------
2 ChucK Strongly-timed Audio Programming Language
3 Compiler, Virtual Machine, and Synthesis Engine
4
5 Copyright (c) 2003 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.stanford.edu/
7 http://chuck.cs.princeton.edu/
8
9 This program is free software; you can redistribute it and/or modify
10 it under the dual-license terms of EITHER the MIT License OR the GNU
11 General Public License (the latter as published by the Free Software
12 Foundation; either version 2 of the License or, at your option, any
13 later version).
14
15 This program is distributed in the hope that it will be useful and/or
16 interesting, but WITHOUT ANY WARRANTY; without even the implied warranty
17 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 MIT Licence and/or the GNU General Public License for details.
19
20 You should have received a copy of the MIT License and the GNU General
21 Public License (GPL) along with this program; a copy of the GPL can also
22 be obtained by writing to the Free Software Foundation, Inc., 59 Temple
23 Place, Suite 330, Boston, MA 02111-1307 U.S.A.
24 -----------------------------------------------------------------------------*/
25
26 //-----------------------------------------------------------------------------
27 // file: chuck_ugen.h
28 // desc: chuck unit generator interface
29 //
30 // authors: Ge Wang ([email protected] | [email protected])
31 // Rebecca Fiebrink ([email protected])
32 // Spencer Salazar ([email protected])
33 // date: spring 2004 - 1.1
34 // spring 2005 - 1.2
35 // spring 2007 - UAna
36 //-----------------------------------------------------------------------------
37 #ifndef __CHUCK_UGEN_H__
38 #define __CHUCK_UGEN_H__
39
40 #include "chuck_def.h"
41 #include "chuck_oo.h"
42 #include "chuck_dl.h"
43 #include "util_buffers.h"
44
45
46 // forward reference
47 struct Chuck_VM_Shred;
48 struct Chuck_UAnaBlobProxy;
49
50
51 // op mode
52 #define UGEN_OP_PASS -1
53 #define UGEN_OP_STOP 0
54 #define UGEN_OP_TICK 1
55
56
57
58
59 //-----------------------------------------------------------------------------
60 // name: struct Chuck_UGen
61 // dsec: ugen base
62 //-----------------------------------------------------------------------------
63 struct Chuck_UGen : public Chuck_Object
64 {
65 public:
66 Chuck_UGen( );
67 virtual ~Chuck_UGen( );
68 virtual void init();
69 virtual void done();
70
71 public: // src
72 t_CKBOOL add( Chuck_UGen * src, t_CKBOOL isUpChuck );
73 t_CKBOOL remove( Chuck_UGen * src );
74 t_CKVOID remove_all( );
75 t_CKBOOL set_max_src( t_CKUINT num );
76 t_CKUINT get_num_src( );
77 t_CKBOOL is_connected_from( Chuck_UGen * src );
78 t_CKUINT disconnect( t_CKBOOL recursive );
79 t_CKUINT system_tick( t_CKTIME now );
80 t_CKUINT system_tick_v( t_CKTIME now, t_CKUINT numFrames );
81 t_CKBOOL alloc_v( t_CKUINT size );
82 t_CKBOOL set_is_buffered( t_CKBOOL buffered );
83 void get_buffer( SAMPLE * buffer, t_CKINT num_elem );
84
85 Chuck_UGen * src_chan( t_CKUINT chan );
86 Chuck_UGen * dst_for_src_chan( t_CKUINT chan );
87
88 protected:
89 t_CKVOID add_by( Chuck_UGen * dest, t_CKBOOL isUpChuck );
90 t_CKVOID remove_by( Chuck_UGen * dest );
91
92 public:
93 // tick function
94 f_tick tick;
95 // multichannel/vectorized tick function (added 1.3.0.0)
96 f_tickf tickf;
97 // msg function
98 f_pmsg pmsg;
99 // channels (if more than one is required)
100 Chuck_UGen ** m_multi_chan;
101 // size of m_multi_chan;
102 t_CKUINT m_multi_chan_size;
103 // number of channels
104 t_CKUINT m_num_ins;
105 // number of channels
106 t_CKUINT m_num_outs;
107 // alloc multi channels
108 void alloc_multi_chan( t_CKUINT num_ins, t_CKUINT num_outs );
109 // sets up ugen as a subgraph type ugen (added 1.3.0.0)
110 void init_subgraph();
111
112 public: // data
113 Chuck_UGen ** m_src_list;
114 t_CKUINT m_src_cap;
115 t_CKUINT m_num_src;
116 Chuck_UGen ** m_dest_list;
117 t_CKUINT m_dest_cap;
118 t_CKUINT m_num_dest;
119 Chuck_UGen ** m_src_uana_list;
120 t_CKUINT m_src_uana_cap;
121 t_CKUINT m_num_uana_src;
122 Chuck_UGen ** m_dest_uana_list;
123 t_CKUINT m_dest_uana_cap;
124 t_CKUINT m_num_uana_dest;
125 t_CKUINT m_max_src;
126 t_CKTIME m_time;
127 t_CKBOOL m_valid;
128 t_CKBOOL m_use_next;
129 SAMPLE m_sum;
130 SAMPLE m_current;
131 SAMPLE m_next;
132 SAMPLE m_last;
133 SAMPLE m_gain;
134 SAMPLE m_pan;
135 t_CKINT m_op;
136 t_CKINT m_max_block_size;
137
138 // SPENCERTODO: combine with block processing (added 1.3.0.0)
139 SAMPLE * m_multi_in_v;
140 SAMPLE * m_multi_out_v;
141
142 // SPENCERTODO: better way to handle this (added 1.3.0.0)
143 t_CKBOOL m_is_subgraph;
144 Chuck_UGen * m_inlet, * m_outlet;
145 Chuck_UGen * inlet();
146 Chuck_UGen * outlet();
147
148 // block processing
149 SAMPLE * m_sum_v;
150 SAMPLE * m_current_v;
151
152 // owner
153 Chuck_UGen * owner_ugen;
154
155 // what a hack!
156 t_CKBOOL m_is_uana;
157
158 // what a hack! (added some time after REFACTOR-2017)
159 t_CKBOOL m_is_buffered;
160 AccumBuffer m_buffer;
161 };
162
163
164
165
166 //-----------------------------------------------------------------------------
167 // name: struct Chuck_UAna
168 // dsec: uana base
169 //-----------------------------------------------------------------------------
170 struct Chuck_UAna : public Chuck_UGen
171 {
172 public:
173 Chuck_UAna( );
174 virtual ~Chuck_UAna( );
175
176 public:
177 t_CKBOOL system_tock( t_CKTIME now );
178 t_CKBOOL is_up_connected_from( Chuck_UAna * src );
179
180 public: // blob retrieval
181 t_CKINT numIncomingUAnae() const;
182 Chuck_UAna * getIncomingUAna( t_CKUINT index ) const;
183 Chuck_UAnaBlobProxy * getIncomingBlob( t_CKUINT index ) const;
184 Chuck_UAnaBlobProxy * blobProxy() const;
185
186 public:
187 // tock function
188 f_tock tock;
189
190 public: // data
191 t_CKTIME m_uana_time;
192 // Chuck_UAnaBlobProxy * m_blob_proxy;
193 };
194
195
196 // helper functions for abstracting input/output between arrays and multichan
197 t_CKINT ugen_generic_num_out( Chuck_Object * obj, t_CKBOOL isArray );
198 t_CKINT ugen_generic_num_in( Chuck_Object * obj, t_CKBOOL isArray );
199 Chuck_UGen *ugen_generic_get_src( Chuck_Object * obj, t_CKINT chan, t_CKBOOL isArray );
200 Chuck_UGen *ugen_generic_get_dst( Chuck_Object * obj, t_CKINT chan, t_CKBOOL isArray );
201
202
203
204
205 #endif