| 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: ugen_stk.cpp |
| 28 | // desc: ChucK import for Synthesis ToolKit (STK) |
| 29 | // by Perry Cook and Gary Scavone |
| 30 | // |
| 31 | // author: Ge Wang ([email protected] | [email protected]) |
| 32 | // Perry R. Cook ([email protected]) |
| 33 | // Ananya Misra ([email protected]) |
| 34 | // Ari Lazier ([email protected]) |
| 35 | // Philip L. Davidson ([email protected]) |
| 36 | // Mark Daly ([email protected]) |
| 37 | // date: Spring 2004 |
| 38 | //----------------------------------------------------------------------------- |
| 39 | #include "ugen_stk.h" |
| 40 | #include "chuck_type.h" |
| 41 | #include "chuck_vm.h" |
| 42 | #include "chuck_instr.h" |
| 43 | #include "chuck_compile.h" |
| 44 | #include "chuck_lang.h" |
| 45 | #include "chuck_carrier.h" |
| 46 | #include "chuck_errmsg.h" |
| 47 | #include "chuck_io.h" |
| 48 | #include "chuck_oo.h" |
| 49 | #include "util_math.h" |
| 50 | #include "util_platforms.h" |
| 51 | #include "util_string.h" |
| 52 | #include <stdlib.h> |
| 53 | #include <string.h> |
| 54 | #include <time.h> |
| 55 | #include <float.h> |
| 56 | #include <limits.h> |
| 57 | #include <string> |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | //------------------------------------------------------------------------------ |
| 63 | // name: union what |
| 64 | // desc: the litmus |
| 65 | //------------------------------------------------------------------------------ |
| 66 | union what { long x; char y[sizeof(long)]; }; |
| 67 | t_CKBOOL little_endian = FALSE; |
| 68 | |
| 69 | // test for baseclass pointers; throw exception and halt shred if NULL | 1.5.4.2 (ge & nshaheed) added |
| 70 | t_CKBOOL stk_verify_baseclass( void * ptr, const std::string & typeName, Chuck_VM_Shred * shred ); |
| 71 | |
| 72 | // static t_CKUINT g_srate = 0; |
| 73 | // filter member data offset |
| 74 | |
| 75 | static t_CKUINT Instrmnt_offset_data = 0; |
| 76 | //static t_CKUINT BandedWG_offset_data = 0; |
| 77 | //static t_CKUINT BlowBotl_offset_data = 0; |
| 78 | //static t_CKUINT BlowHole_offset_data = 0; |
| 79 | //static t_CKUINT Bowed_offset_data = 0; |
| 80 | //static t_CKUINT Brass_offset_data = 0; |
| 81 | //static t_CKUINT Clarinet_offset_data = 0; |
| 82 | //static t_CKUINT Flute_offset_data = 0; |
| 83 | //static t_CKUINT Mandolin_offset_data = 0; |
| 84 | //static t_CKUINT ModalBar_offset_data = 0; |
| 85 | //static t_CKUINT Moog_offset_data = 0; |
| 86 | //static t_CKUINT Saxofony_offset_data = 0; |
| 87 | //static t_CKUINT Shakers_offset_data = 0; |
| 88 | //static t_CKUINT Sitar_offset_data = 0; |
| 89 | //static t_CKUINT StifKarp_offset_data = 0; |
| 90 | //static t_CKUINT VoicForm_offset_data = 0; |
| 91 | static t_CKUINT FM_offset_data = 0; |
| 92 | //static t_CKUINT BeeThree_offset_data = 0; // NOTE: TX81Z Algorithm 8 (lots of Organs) |
| 93 | //static t_CKUINT FMVoices_offset_data = 0; // NOTE: TX81Z Algorithm 6 |
| 94 | //static t_CKUINT HevyMetl_offset_data = 0; // NOTE: TX81Z Algorithm 3 (Trumpet too) |
| 95 | //static t_CKUINT HnkyTonk offset_data = 0; // 1.4.1.0 (prc) REPAIRATHON2021 ADDITION, TX81Z Algorithm 1 |
| 96 | //static t_CKUINT FrencHrn offset_data = 0; // 1.4.1.0 (prc) REPAIRATHON2021 ADDITION, TX81Z Algorithm 2 |
| 97 | //static t_CKUINT KrstlChr offset_data = 0; // 1.4.1.0 (prc) REPAIRATHON2021 ADDITION, TX81Z Algorithm 7 |
| 98 | //static t_CKUINT PercFlut_offset_data = 0; // NOTE: TX81Z Algorithm 4 |
| 99 | //static t_CKUINT Rhodey_offset_data = 0; // NOTE: TX81Z Algorithm 5 (also Wurley, TubeBell) |
| 100 | //static t_CKUINT TubeBell_offset_data = 0; // NOTE: TX81Z Algorithm 5 (also Rhodey, Wurley) |
| 101 | //static t_CKUINT Wurley_offset_data = 0; // NOTE: TX81Z Algorithm 5 (also Rhodey, TubeBell) |
| 102 | static t_CKUINT FormSwep_offset_data = 0; |
| 103 | static t_CKUINT Delay_offset_data = 0; |
| 104 | static t_CKUINT DelayA_offset_data = 0; |
| 105 | static t_CKUINT DelayL_offset_data = 0; |
| 106 | static t_CKUINT Echo_offset_data = 0; |
| 107 | static t_CKUINT Envelope_offset_data = 0; |
| 108 | // static t_CKUINT Envelope_offset_data = 0; |
| 109 | static t_CKUINT BiQuad_offset_data = 0; |
| 110 | static t_CKUINT FilterStk_offset_data = 0; |
| 111 | static t_CKUINT OnePole_offset_data = 0; |
| 112 | static t_CKUINT TwoPole_offset_data = 0; |
| 113 | static t_CKUINT OneZero_offset_data = 0; |
| 114 | static t_CKUINT TwoZero_offset_data = 0; |
| 115 | static t_CKUINT PoleZero_offset_data = 0; |
| 116 | static t_CKUINT JCRev_offset_data = 0; |
| 117 | static t_CKUINT NRev_offset_data = 0; |
| 118 | static t_CKUINT PRCRev_offset_data = 0; |
| 119 | static t_CKUINT Chorus_offset_data = 0; |
| 120 | static t_CKUINT Modulate_offset_data = 0; |
| 121 | static t_CKUINT SubNoise_offset_data = 0; |
| 122 | static t_CKUINT WvIn_offset_data = 0; |
| 123 | //static t_CKUINT WaveLoop_offset_data = 0; |
| 124 | static t_CKUINT WvOut_offset_data = 0; |
| 125 | static t_CKUINT PitShift_offset_data = 0; |
| 126 | static t_CKUINT BLT_offset_data = 0; |
| 127 | static t_CKUINT JetTabl_offset_data = 0; |
| 128 | |
| 129 | static t_CKUINT Mesh2D_offset_data = 0; |
| 130 | |
| 131 | static t_CKUINT MidiFileIn_offset_data = 0; |
| 132 | |
| 133 | static t_CKINT ADSR_state_ATTACK = ADSR::ATTACK; |
| 134 | static t_CKINT ADSR_state_DECAY = ADSR::DECAY; |
| 135 | static t_CKINT ADSR_state_SUSTAIN = ADSR::SUSTAIN; |
| 136 | static t_CKINT ADSR_state_RELEASE = ADSR::RELEASE; |
| 137 | static t_CKINT ADSR_state_DONE = ADSR::DONE; |
| 138 | |
| 139 | // SKINI |
| 140 | /* |
| 141 | SkiniIn SkiniMessage => while(skin.getnextmessage(msg)) |
| 142 | msg - type, data parameters, time stamp |
| 143 | SkiniOut.send( midi message ) |
| 144 | horn ok please -> written at the back of trucks, always, makes no sense. |
| 145 | */ |
| 146 | |
| 147 | |
| 148 | // ADSR |
| 149 | CK_DLL_CTOR( ADSR_ctor ); |
| 150 | CK_DLL_DTOR( ADSR_dtor ); |
| 151 | CK_DLL_TICK( ADSR_tick ); |
| 152 | CK_DLL_PMSG( ADSR_pmsg ); |
| 153 | CK_DLL_CTOR( ADSR_ctor_floats ); |
| 154 | CK_DLL_CTOR( ADSR_ctor_durs ); |
| 155 | CK_DLL_CTRL( ADSR_ctrl_attackTime ); |
| 156 | CK_DLL_CTRL( ADSR_ctrl_attackRate ); |
| 157 | CK_DLL_CTRL( ADSR_ctrl_decayTime ); |
| 158 | CK_DLL_CTRL( ADSR_ctrl_decayRate ); |
| 159 | CK_DLL_CTRL( ADSR_ctrl_sustainLevel ); |
| 160 | CK_DLL_CTRL( ADSR_ctrl_releaseTime ); |
| 161 | CK_DLL_CTRL( ADSR_ctrl_releaseRate ); |
| 162 | CK_DLL_CTRL( ADSR_ctrl_set ); |
| 163 | CK_DLL_CTRL( ADSR_ctrl_set2 ); |
| 164 | CK_DLL_CGET( ADSR_cget_attackTime ); |
| 165 | CK_DLL_CGET( ADSR_cget_attackRate ); |
| 166 | CK_DLL_CGET( ADSR_cget_decayTime ); |
| 167 | CK_DLL_CGET( ADSR_cget_decayRate ); |
| 168 | CK_DLL_CGET( ADSR_cget_sustainLevel ); |
| 169 | CK_DLL_CGET( ADSR_cget_releaseTime ); |
| 170 | CK_DLL_CGET( ADSR_cget_releaseRate ); |
| 171 | CK_DLL_CGET( ADSR_cget_state ); |
| 172 | |
| 173 | // BiQuad |
| 174 | CK_DLL_CTOR( BiQuad_ctor ); |
| 175 | CK_DLL_DTOR( BiQuad_dtor ); |
| 176 | CK_DLL_TICK( BiQuad_tick ); |
| 177 | CK_DLL_PMSG( BiQuad_pmsg ); |
| 178 | CK_DLL_CTRL( BiQuad_ctrl_b2 ); |
| 179 | CK_DLL_CTRL( BiQuad_ctrl_b1 ); |
| 180 | CK_DLL_CTRL( BiQuad_ctrl_b0 ); |
| 181 | CK_DLL_CTRL( BiQuad_ctrl_a2 ); |
| 182 | CK_DLL_CTRL( BiQuad_ctrl_a1 ); |
| 183 | CK_DLL_CGET( BiQuad_ctrl_a0 ); |
| 184 | CK_DLL_CTRL( BiQuad_ctrl_pfreq ); |
| 185 | CK_DLL_CTRL( BiQuad_ctrl_prad ); |
| 186 | CK_DLL_CTRL( BiQuad_ctrl_zfreq ); |
| 187 | CK_DLL_CTRL( BiQuad_ctrl_zrad ); |
| 188 | CK_DLL_CTRL( BiQuad_ctrl_norm ); |
| 189 | CK_DLL_CTRL( BiQuad_ctrl_eqzs ); |
| 190 | CK_DLL_CGET( BiQuad_cget_b2 ); |
| 191 | CK_DLL_CGET( BiQuad_cget_b1 ); |
| 192 | CK_DLL_CGET( BiQuad_cget_b0 ); |
| 193 | CK_DLL_CGET( BiQuad_cget_a2 ); |
| 194 | CK_DLL_CGET( BiQuad_cget_a1 ); |
| 195 | CK_DLL_CGET( BiQuad_cget_a0 ); |
| 196 | CK_DLL_CTRL( BiQuad_cget_pfreq ); |
| 197 | CK_DLL_CTRL( BiQuad_cget_prad ); |
| 198 | CK_DLL_CTRL( BiQuad_cget_zfreq ); |
| 199 | CK_DLL_CTRL( BiQuad_cget_zrad ); |
| 200 | |
| 201 | // Chorus |
| 202 | CK_DLL_CTOR( Chorus_ctor ); |
| 203 | CK_DLL_CTOR( Chorus_ctor_freq ); |
| 204 | CK_DLL_CTOR( Chorus_ctor_freq_depth ); |
| 205 | CK_DLL_CTOR( Chorus_ctor_freq_depth_mix ); |
| 206 | CK_DLL_DTOR( Chorus_dtor ); |
| 207 | CK_DLL_TICK( Chorus_tick ); |
| 208 | CK_DLL_PMSG( Chorus_pmsg ); |
| 209 | CK_DLL_CTRL( Chorus_ctrl_modDepth ); |
| 210 | CK_DLL_CTRL( Chorus_ctrl_modFreq ); |
| 211 | CK_DLL_CTRL( Chorus_ctrl_baseDelay ); |
| 212 | CK_DLL_CTRL( Chorus_ctrl_set ); |
| 213 | CK_DLL_CTRL( Chorus_ctrl_mix ); |
| 214 | CK_DLL_CGET( Chorus_cget_modDepth ); |
| 215 | CK_DLL_CGET( Chorus_cget_modFreq ); |
| 216 | CK_DLL_CGET( Chorus_cget_baseDelay ); |
| 217 | CK_DLL_CGET( Chorus_cget_mix ); |
| 218 | |
| 219 | // Delay |
| 220 | CK_DLL_CTOR( Delay_ctor ); |
| 221 | CK_DLL_CTOR( Delay_ctor_delay ); |
| 222 | CK_DLL_CTOR( Delay_ctor_delay_max ); |
| 223 | CK_DLL_DTOR( Delay_dtor ); |
| 224 | CK_DLL_TICK( Delay_tick ); |
| 225 | CK_DLL_PMSG( Delay_pmsg ); |
| 226 | CK_DLL_CTRL( Delay_ctrl_set ); |
| 227 | CK_DLL_CTRL( Delay_ctrl_delay ); |
| 228 | CK_DLL_CTRL( Delay_ctrl_max ); |
| 229 | CK_DLL_CGET( Delay_cget_delay ); |
| 230 | CK_DLL_CGET( Delay_cget_max ); |
| 231 | CK_DLL_CGET( Delay_clear ); |
| 232 | |
| 233 | // DelayA |
| 234 | CK_DLL_CTOR( DelayA_ctor ); |
| 235 | CK_DLL_CTOR( DelayA_ctor_delay ); |
| 236 | CK_DLL_CTOR( DelayA_ctor_delay_max ); |
| 237 | CK_DLL_DTOR( DelayA_dtor ); |
| 238 | CK_DLL_TICK( DelayA_tick ); |
| 239 | CK_DLL_PMSG( DelayA_pmsg ); |
| 240 | CK_DLL_CTRL( DelayA_ctrl_set ); |
| 241 | CK_DLL_CTRL( DelayA_ctrl_delay ); |
| 242 | CK_DLL_CTRL( DelayA_ctrl_max ); |
| 243 | CK_DLL_CGET( DelayA_cget_delay ); |
| 244 | CK_DLL_CGET( DelayA_cget_max ); |
| 245 | CK_DLL_CGET( DelayA_clear ); |
| 246 | |
| 247 | // DelayL |
| 248 | CK_DLL_CTOR( DelayL_ctor ); |
| 249 | CK_DLL_CTOR( DelayL_ctor_delay ); |
| 250 | CK_DLL_CTOR( DelayL_ctor_delay_max ); |
| 251 | CK_DLL_DTOR( DelayL_dtor ); |
| 252 | CK_DLL_TICK( DelayL_tick ); |
| 253 | CK_DLL_PMSG( DelayL_pmsg ); |
| 254 | CK_DLL_CTRL( DelayL_ctrl_set ); |
| 255 | CK_DLL_CTRL( DelayL_ctrl_delay ); |
| 256 | CK_DLL_CTRL( DelayL_ctrl_max ); |
| 257 | CK_DLL_CGET( DelayL_cget_delay ); |
| 258 | CK_DLL_CGET( DelayL_cget_max ); |
| 259 | CK_DLL_CGET( DelayL_clear ); |
| 260 | |
| 261 | // Echo |
| 262 | CK_DLL_CTOR( Echo_ctor ); |
| 263 | CK_DLL_CTOR( Echo_ctor_delay ); |
| 264 | CK_DLL_CTOR( Echo_ctor_delay_max ); |
| 265 | CK_DLL_DTOR( Echo_dtor ); |
| 266 | CK_DLL_TICK( Echo_tick ); |
| 267 | CK_DLL_PMSG( Echo_pmsg ); |
| 268 | CK_DLL_CTRL( Echo_ctrl_set ); |
| 269 | CK_DLL_CTRL( Echo_ctrl_delay ); |
| 270 | CK_DLL_CTRL( Echo_ctrl_max ); |
| 271 | CK_DLL_CTRL( Echo_ctrl_mix ); |
| 272 | CK_DLL_CGET( Echo_cget_delay ); |
| 273 | CK_DLL_CGET( Echo_cget_max ); |
| 274 | CK_DLL_CGET( Echo_cget_mix ); |
| 275 | |
| 276 | // Envelope |
| 277 | CK_DLL_CTOR( Envelope_ctor ); |
| 278 | CK_DLL_DTOR( Envelope_dtor ); |
| 279 | CK_DLL_TICK( Envelope_tick ); |
| 280 | CK_DLL_PMSG( Envelope_pmsg ); |
| 281 | CK_DLL_CTOR( Envelope_ctor_duration ); |
| 282 | CK_DLL_CTOR( Envelope_ctor_float ); |
| 283 | CK_DLL_CTOR( Envelope_ctor_duration_target ); |
| 284 | CK_DLL_CTOR( Envelope_ctor_float_target ); |
| 285 | CK_DLL_MFUN( Envelope_mfun_duration_target ); |
| 286 | CK_DLL_MFUN( Envelope_mfun_float_target ); |
| 287 | CK_DLL_CTRL( Envelope_ctrl_rate ); |
| 288 | CK_DLL_CTRL( Envelope_ctrl_target ); |
| 289 | CK_DLL_CTRL( Envelope_cget_target ); |
| 290 | CK_DLL_CTRL( Envelope_ctrl_time ); |
| 291 | CK_DLL_CTRL( Envelope_ctrl_duration ); |
| 292 | CK_DLL_CTRL( Envelope_ctrl_value ); |
| 293 | CK_DLL_CTRL( Envelope_cget_value ); |
| 294 | CK_DLL_CTRL( Envelope_ctrl_keyOn0 ); |
| 295 | CK_DLL_CTRL( Envelope_ctrl_keyOn ); |
| 296 | CK_DLL_CTRL( Envelope_ctrl_keyOff0 ); |
| 297 | CK_DLL_CTRL( Envelope_ctrl_keyOff ); |
| 298 | CK_DLL_CGET( Envelope_cget_rate ); |
| 299 | CK_DLL_CGET( Envelope_cget_target ); |
| 300 | CK_DLL_CGET( Envelope_cget_time ); |
| 301 | CK_DLL_CGET( Envelope_cget_duration ); |
| 302 | CK_DLL_CGET( Envelope_cget_value ); |
| 303 | |
| 304 | // FilterStk (originally Filter) |
| 305 | CK_DLL_CTOR( FilterStk_ctor ); |
| 306 | CK_DLL_DTOR( FilterStk_dtor ); |
| 307 | CK_DLL_TICK( FilterStk_tick ); |
| 308 | CK_DLL_PMSG( FilterStk_pmsg ); |
| 309 | CK_DLL_CTRL( FilterStk_ctrl_coefs ); |
| 310 | CK_DLL_CGET( FilterStk_cget_coefs ); |
| 311 | |
| 312 | // OnePole |
| 313 | CK_DLL_CTOR( OnePole_ctor ); |
| 314 | CK_DLL_DTOR( OnePole_dtor ); |
| 315 | CK_DLL_TICK( OnePole_tick ); |
| 316 | CK_DLL_PMSG( OnePole_pmsg ); |
| 317 | CK_DLL_CTRL( OnePole_ctrl_a1 ); |
| 318 | CK_DLL_CTRL( OnePole_ctrl_b0 ); |
| 319 | CK_DLL_CTRL( OnePole_ctrl_pole ); |
| 320 | CK_DLL_CGET( OnePole_cget_a1 ); |
| 321 | CK_DLL_CGET( OnePole_cget_b0 ); |
| 322 | CK_DLL_CGET( OnePole_cget_pole ); |
| 323 | |
| 324 | // TwoPole |
| 325 | CK_DLL_CTOR( TwoPole_ctor ); |
| 326 | CK_DLL_DTOR( TwoPole_dtor ); |
| 327 | CK_DLL_TICK( TwoPole_tick ); |
| 328 | CK_DLL_PMSG( TwoPole_pmsg ); |
| 329 | CK_DLL_CTRL( TwoPole_ctrl_a1 ); |
| 330 | CK_DLL_CTRL( TwoPole_ctrl_a2 ); |
| 331 | CK_DLL_CTRL( TwoPole_ctrl_b0 ); |
| 332 | CK_DLL_CTRL( TwoPole_ctrl_freq ); |
| 333 | CK_DLL_CTRL( TwoPole_ctrl_radius ); |
| 334 | CK_DLL_CTRL( TwoPole_ctrl_norm ); |
| 335 | CK_DLL_CGET( TwoPole_cget_a1 ); |
| 336 | CK_DLL_CGET( TwoPole_cget_a2 ); |
| 337 | CK_DLL_CGET( TwoPole_cget_b0 ); |
| 338 | CK_DLL_CGET( TwoPole_cget_freq ); |
| 339 | CK_DLL_CGET( TwoPole_cget_radius ); |
| 340 | CK_DLL_CGET( TwoPole_cget_norm ); |
| 341 | |
| 342 | |
| 343 | // OneZero |
| 344 | CK_DLL_CTOR( OneZero_ctor ); |
| 345 | CK_DLL_DTOR( OneZero_dtor ); |
| 346 | CK_DLL_TICK( OneZero_tick ); |
| 347 | CK_DLL_PMSG( OneZero_pmsg ); |
| 348 | CK_DLL_CTRL( OneZero_ctrl_zero ); |
| 349 | CK_DLL_CTRL( OneZero_ctrl_b0 ); |
| 350 | CK_DLL_CTRL( OneZero_ctrl_b1 ); |
| 351 | CK_DLL_CGET( OneZero_cget_zero ); |
| 352 | CK_DLL_CGET( OneZero_cget_b0 ); |
| 353 | CK_DLL_CGET( OneZero_cget_b1 ); |
| 354 | |
| 355 | // TwoZero |
| 356 | CK_DLL_CTOR( TwoZero_ctor ); |
| 357 | CK_DLL_DTOR( TwoZero_dtor ); |
| 358 | CK_DLL_TICK( TwoZero_tick ); |
| 359 | CK_DLL_PMSG( TwoZero_pmsg ); |
| 360 | CK_DLL_CTRL( TwoZero_ctrl_b0 ); |
| 361 | CK_DLL_CTRL( TwoZero_ctrl_b1 ); |
| 362 | CK_DLL_CTRL( TwoZero_ctrl_b2 ); |
| 363 | CK_DLL_CTRL( TwoZero_ctrl_freq ); |
| 364 | CK_DLL_CTRL( TwoZero_ctrl_radius ); |
| 365 | CK_DLL_CGET( TwoZero_cget_b0 ); |
| 366 | CK_DLL_CGET( TwoZero_cget_b1 ); |
| 367 | CK_DLL_CGET( TwoZero_cget_b2 ); |
| 368 | CK_DLL_CGET( TwoZero_cget_freq ); |
| 369 | CK_DLL_CGET( TwoZero_cget_radius ); |
| 370 | |
| 371 | // PoleZero |
| 372 | CK_DLL_CTOR( PoleZero_ctor ); |
| 373 | CK_DLL_DTOR( PoleZero_dtor ); |
| 374 | CK_DLL_TICK( PoleZero_tick ); |
| 375 | CK_DLL_PMSG( PoleZero_pmsg ); |
| 376 | CK_DLL_CTRL( PoleZero_ctrl_a1 ); |
| 377 | CK_DLL_CTRL( PoleZero_ctrl_b0 ); |
| 378 | CK_DLL_CTRL( PoleZero_ctrl_b1 ); |
| 379 | CK_DLL_CTRL( PoleZero_ctrl_blockZero ); |
| 380 | CK_DLL_CTRL( PoleZero_ctrl_allpass ); |
| 381 | CK_DLL_CGET( PoleZero_cget_a1 ); |
| 382 | CK_DLL_CGET( PoleZero_cget_b0 ); |
| 383 | CK_DLL_CGET( PoleZero_cget_b1 ); |
| 384 | CK_DLL_CGET( PoleZero_cget_blockZero ); |
| 385 | CK_DLL_CGET( PoleZero_cget_allpass ); |
| 386 | |
| 387 | // Noise |
| 388 | CK_DLL_CTOR( Noise_ctor ); |
| 389 | CK_DLL_DTOR( Noise_dtor ); |
| 390 | CK_DLL_TICK( Noise_tick ); |
| 391 | CK_DLL_PMSG( Noise_pmsg ); |
| 392 | CK_DLL_CTRL( Noise_ctrl_seed ); |
| 393 | CK_DLL_CGET( Noise_cget_seed ); |
| 394 | |
| 395 | // SubNoise |
| 396 | CK_DLL_CTOR( SubNoise_ctor ); |
| 397 | CK_DLL_DTOR( SubNoise_dtor ); |
| 398 | CK_DLL_TICK( SubNoise_tick ); |
| 399 | CK_DLL_PMSG( SubNoise_pmsg ); |
| 400 | CK_DLL_CTRL( SubNoise_ctrl_rate ); |
| 401 | CK_DLL_CGET( SubNoise_cget_rate ); |
| 402 | |
| 403 | // BLT |
| 404 | CK_DLL_CTOR( BLT_ctor ); |
| 405 | CK_DLL_DTOR( BLT_dtor ); |
| 406 | CK_DLL_TICK( BLT_tick ); |
| 407 | CK_DLL_PMSG( BLT_pmsg ); |
| 408 | CK_DLL_CTRL( BLT_ctrl_phase ); |
| 409 | CK_DLL_CGET( BLT_cget_phase ); |
| 410 | CK_DLL_CTRL( BLT_ctrl_freq ); |
| 411 | CK_DLL_CGET( BLT_cget_freq ); |
| 412 | CK_DLL_CTRL( BLT_ctrl_harmonics ); |
| 413 | CK_DLL_CGET( BLT_cget_harmonics ); |
| 414 | |
| 415 | // Blit |
| 416 | CK_DLL_CTOR( Blit_ctor ); |
| 417 | CK_DLL_DTOR( Blit_dtor ); |
| 418 | CK_DLL_TICK( Blit_tick ); |
| 419 | CK_DLL_PMSG( Blit_pmsg ); |
| 420 | |
| 421 | // BlitSaw |
| 422 | CK_DLL_CTOR( BlitSaw_ctor ); |
| 423 | CK_DLL_DTOR( BlitSaw_dtor ); |
| 424 | CK_DLL_TICK( BlitSaw_tick ); |
| 425 | CK_DLL_PMSG( BlitSaw_pmsg ); |
| 426 | |
| 427 | // BlitSquare |
| 428 | CK_DLL_CTOR( BlitSquare_ctor ); |
| 429 | CK_DLL_DTOR( BlitSquare_dtor ); |
| 430 | CK_DLL_TICK( BlitSquare_tick ); |
| 431 | CK_DLL_PMSG( BlitSquare_pmsg ); |
| 432 | |
| 433 | // JCRev |
| 434 | CK_DLL_CTOR( JCRev_ctor ); |
| 435 | CK_DLL_CTOR( JCRev_ctor_mix ); |
| 436 | CK_DLL_DTOR( JCRev_dtor ); |
| 437 | CK_DLL_TICK( JCRev_tick ); |
| 438 | CK_DLL_PMSG( JCRev_pmsg ); |
| 439 | CK_DLL_CTRL( JCRev_ctrl_mix ); |
| 440 | CK_DLL_CGET( JCRev_cget_mix ); |
| 441 | |
| 442 | // NRev |
| 443 | CK_DLL_CTOR( NRev_ctor ); |
| 444 | CK_DLL_CTOR( NRev_ctor_mix ); |
| 445 | CK_DLL_DTOR( NRev_dtor ); |
| 446 | CK_DLL_TICK( NRev_tick ); |
| 447 | CK_DLL_PMSG( NRev_pmsg ); |
| 448 | CK_DLL_CTRL( NRev_ctrl_mix ); |
| 449 | CK_DLL_CGET( NRev_cget_mix ); |
| 450 | |
| 451 | // PRCRev |
| 452 | CK_DLL_CTOR( PRCRev_ctor ); |
| 453 | CK_DLL_CTOR( PRCRev_ctor_mix ); |
| 454 | CK_DLL_DTOR( PRCRev_dtor ); |
| 455 | CK_DLL_TICK( PRCRev_tick ); |
| 456 | CK_DLL_PMSG( PRCRev_pmsg ); |
| 457 | CK_DLL_CTRL( PRCRev_ctrl_mix ); |
| 458 | CK_DLL_CGET( PRCRev_cget_mix ); |
| 459 | |
| 460 | // WaveLoop |
| 461 | CK_DLL_CTOR( WaveLoop_ctor ); |
| 462 | CK_DLL_DTOR( WaveLoop_dtor ); |
| 463 | CK_DLL_TICK( WaveLoop_tick ); |
| 464 | CK_DLL_PMSG( WaveLoop_pmsg ); |
| 465 | CK_DLL_CTRL( WaveLoop_ctrl_freq ); |
| 466 | CK_DLL_CTRL( WaveLoop_ctrl_rate ); |
| 467 | CK_DLL_CTRL( WaveLoop_ctrl_phase ); |
| 468 | CK_DLL_CTRL( WaveLoop_ctrl_phaseOffset ); |
| 469 | CK_DLL_CTRL( WaveLoop_ctrl_path ); |
| 470 | CK_DLL_CGET( WaveLoop_cget_freq ); |
| 471 | CK_DLL_CGET( WaveLoop_cget_rate ); |
| 472 | CK_DLL_CGET( WaveLoop_cget_phase ); |
| 473 | CK_DLL_CGET( WaveLoop_cget_phaseOffset ); |
| 474 | CK_DLL_CGET( WaveLoop_cget_path ); |
| 475 | |
| 476 | // WvIn |
| 477 | CK_DLL_CTOR( WvIn_ctor ); |
| 478 | CK_DLL_DTOR( WvIn_dtor ); |
| 479 | CK_DLL_TICK( WvIn_tick ); |
| 480 | CK_DLL_PMSG( WvIn_pmsg ); |
| 481 | CK_DLL_CTRL( WvIn_ctrl_rate ); |
| 482 | CK_DLL_CTRL( WvIn_ctrl_path ); |
| 483 | CK_DLL_CGET( WvIn_cget_rate ); |
| 484 | CK_DLL_CGET( WvIn_cget_path ); |
| 485 | |
| 486 | #ifndef __DISABLE_WVOUT__ |
| 487 | // WvOut |
| 488 | CK_DLL_CTOR( WvOut_ctor ); |
| 489 | CK_DLL_DTOR( WvOut_dtor ); |
| 490 | CK_DLL_TICK( WvOut_tick ); |
| 491 | CK_DLL_PMSG( WvOut_pmsg ); |
| 492 | CK_DLL_CTRL( WvOut_ctrl_filename ); |
| 493 | CK_DLL_CTRL( WvOut_ctrl_aifFilename ); |
| 494 | CK_DLL_CTRL( WvOut_ctrl_aifFilename2 ); |
| 495 | CK_DLL_CTRL( WvOut_ctrl_matFilename ); |
| 496 | CK_DLL_CTRL( WvOut_ctrl_matFilename2 ); |
| 497 | CK_DLL_CTRL( WvOut_ctrl_sndFilename ); |
| 498 | CK_DLL_CTRL( WvOut_ctrl_sndFilename2 ); |
| 499 | CK_DLL_CTRL( WvOut_ctrl_wavFilename ); |
| 500 | CK_DLL_CTRL( WvOut_ctrl_wavFilename2 ); |
| 501 | CK_DLL_CTRL( WvOut_ctrl_rawFilename ); |
| 502 | CK_DLL_CTRL( WvOut_ctrl_rawFilename2 ); |
| 503 | CK_DLL_CTRL( WvOut_ctrl_closeFile ); |
| 504 | CK_DLL_CTRL( WvOut_ctrl_record ); |
| 505 | CK_DLL_CTRL( WvOut_ctrl_autoPrefix ); |
| 506 | CK_DLL_CGET( WvOut_cget_filename ); |
| 507 | CK_DLL_CGET( WvOut_cget_record ); |
| 508 | CK_DLL_CGET( WvOut_cget_autoPrefix ); |
| 509 | CK_DLL_CTRL( WvOut_ctrl_fileGain ); |
| 510 | CK_DLL_CGET( WvOut_cget_fileGain ); |
| 511 | // WvOut2 |
| 512 | CK_DLL_TICKF( WvOut2_tickf ); |
| 513 | #endif |
| 514 | |
| 515 | |
| 516 | // FM |
| 517 | CK_DLL_CTOR( FM_ctor ); |
| 518 | CK_DLL_DTOR( FM_dtor ); |
| 519 | CK_DLL_TICK( FM_tick ); |
| 520 | CK_DLL_PMSG( FM_pmsg ); |
| 521 | CK_DLL_CTRL( FM_ctrl_freq ); |
| 522 | CK_DLL_CTRL( FM_ctrl_noteOn ); |
| 523 | CK_DLL_CTRL( FM_ctrl_noteOff ); |
| 524 | CK_DLL_CTRL( FM_ctrl_modDepth ); |
| 525 | CK_DLL_CTRL( FM_ctrl_modSpeed ); |
| 526 | CK_DLL_CTRL( FM_ctrl_control1 ); |
| 527 | CK_DLL_CTRL( FM_ctrl_control2 ); |
| 528 | CK_DLL_CTRL( FM_ctrl_controlChange ); |
| 529 | CK_DLL_CTRL( FM_ctrl_afterTouch ); |
| 530 | // 1.4.1.0 (prc) REPAIRATHON2021 NEW Set/Get access functions |
| 531 | CK_DLL_CTRL( FM_ctrl_opADSR ); |
| 532 | CK_DLL_CTRL( FM_ctrl_opRatio ); |
| 533 | CK_DLL_CGET( FM_cget_opRatio ); |
| 534 | CK_DLL_CTRL( FM_ctrl_opGain ); |
| 535 | CK_DLL_CGET( FM_cget_opGain ); |
| 536 | CK_DLL_CTRL( FM_ctrl_opAM ); |
| 537 | CK_DLL_CTRL( FM_cget_opAM ); |
| 538 | CK_DLL_CTRL( FM_ctrl_opWave ); |
| 539 | CK_DLL_CTRL( FM_ctrl_op4Feedback ); |
| 540 | CK_DLL_CTRL( FM_cget_op4Feedback ); |
| 541 | CK_DLL_CGET( FM_cget_getFMTableGain ); |
| 542 | CK_DLL_CGET( FM_cget_getFMTableTime ); |
| 543 | CK_DLL_CGET( FM_cget_getFMTableSusLevel ); |
| 544 | // 1.4.1.0 (prc) END NEW REPAIRATHON2021 Set/Get access functinos |
| 545 | |
| 546 | CK_DLL_CGET( FM_cget_freq ); |
| 547 | CK_DLL_CGET( FM_cget_modDepth ); |
| 548 | CK_DLL_CGET( FM_cget_modSpeed ); |
| 549 | CK_DLL_CGET( FM_cget_control1 ); |
| 550 | CK_DLL_CGET( FM_cget_control2 ); |
| 551 | CK_DLL_CGET( FM_cget_afterTouch ); |
| 552 | |
| 553 | // FormSwep |
| 554 | CK_DLL_CTOR( FormSwep_ctor ); |
| 555 | CK_DLL_DTOR( FormSwep_dtor ); |
| 556 | CK_DLL_TICK( FormSwep_tick ); |
| 557 | CK_DLL_PMSG( FormSwep_pmsg ); |
| 558 | CK_DLL_CTRL( FormSwep_ctrl_frequency ); |
| 559 | CK_DLL_CGET( FormSwep_cget_frequency ); |
| 560 | CK_DLL_CTRL( FormSwep_ctrl_radius ); |
| 561 | CK_DLL_CGET( FormSwep_cget_radius ); |
| 562 | CK_DLL_CTRL( FormSwep_ctrl_gain ); |
| 563 | CK_DLL_CGET( FormSwep_cget_gain ); |
| 564 | CK_DLL_CTRL( FormSwep_ctrl_sweepRate ); |
| 565 | CK_DLL_CTRL( FormSwep_ctrl_sweepTime ); |
| 566 | CK_DLL_CGET( FormSwep_cget_sweepRate ); |
| 567 | CK_DLL_CGET( FormSwep_cget_sweepTime ); |
| 568 | |
| 569 | // Modulate |
| 570 | CK_DLL_CTOR( Modulate_ctor ); |
| 571 | CK_DLL_CTOR( Modulate_ctor_rate ); |
| 572 | CK_DLL_CTOR( Modulate_ctor_rate_gain ); |
| 573 | CK_DLL_CTOR( Modulate_ctor_rate_gain_random ); |
| 574 | CK_DLL_DTOR( Modulate_dtor ); |
| 575 | CK_DLL_TICK( Modulate_tick ); |
| 576 | CK_DLL_PMSG( Modulate_pmsg ); |
| 577 | CK_DLL_CTRL( Modulate_ctrl_vibratoGain ); |
| 578 | CK_DLL_CTRL( Modulate_ctrl_vibratoRate ); |
| 579 | CK_DLL_CTRL( Modulate_ctrl_randomGain ); |
| 580 | CK_DLL_CGET( Modulate_cget_vibratoGain ); |
| 581 | CK_DLL_CGET( Modulate_cget_vibratoRate ); |
| 582 | CK_DLL_CGET( Modulate_cget_randomGain ); |
| 583 | |
| 584 | // PitShift |
| 585 | CK_DLL_CTOR( PitShift_ctor ); |
| 586 | CK_DLL_CTOR( PitShift_ctor_shift ); |
| 587 | CK_DLL_CTOR( PitShift_ctor_shift_mix ); |
| 588 | CK_DLL_DTOR( PitShift_dtor ); |
| 589 | CK_DLL_TICK( PitShift_tick ); |
| 590 | CK_DLL_PMSG( PitShift_pmsg ); |
| 591 | CK_DLL_CTRL( PitShift_ctrl_shift ); |
| 592 | CK_DLL_CTRL( PitShift_ctrl_effectMix ); |
| 593 | CK_DLL_CGET( PitShift_cget_shift ); |
| 594 | CK_DLL_CGET( PitShift_cget_effectMix ); |
| 595 | |
| 596 | // Sampler |
| 597 | CK_DLL_CTOR( Sampler_ctor ); |
| 598 | CK_DLL_DTOR( Sampler_dtor ); |
| 599 | CK_DLL_TICK( Sampler_tick ); |
| 600 | CK_DLL_PMSG( Sampler_pmsg ); |
| 601 | |
| 602 | // Drummer |
| 603 | CK_DLL_CTOR( Drummer_ctor ); |
| 604 | CK_DLL_DTOR( Drummer_dtor ); |
| 605 | CK_DLL_TICK( Drummer_tick ); |
| 606 | CK_DLL_PMSG( Drummer_pmsg ); |
| 607 | |
| 608 | // Instrmnt |
| 609 | CK_DLL_CTOR( Instrmnt_ctor ); |
| 610 | CK_DLL_DTOR( Instrmnt_dtor ); |
| 611 | CK_DLL_TICK( Instrmnt_tick ); |
| 612 | CK_DLL_PMSG( Instrmnt_pmsg ); |
| 613 | CK_DLL_CTRL( Instrmnt_ctrl_freq ); |
| 614 | CK_DLL_CGET( Instrmnt_cget_freq ); |
| 615 | CK_DLL_CTRL( Instrmnt_ctrl_noteOn ); |
| 616 | CK_DLL_CTRL( Instrmnt_ctrl_noteOff ); |
| 617 | CK_DLL_CTRL( Instrmnt_ctrl_controlChange ); |
| 618 | |
| 619 | // BandedWG |
| 620 | CK_DLL_CTOR( BandedWG_ctor ); |
| 621 | CK_DLL_DTOR( BandedWG_dtor ); |
| 622 | CK_DLL_TICK( BandedWG_tick ); |
| 623 | CK_DLL_PMSG( BandedWG_pmsg ); |
| 624 | CK_DLL_CTRL( BandedWG_ctrl_bowPressure ); |
| 625 | CK_DLL_CGET( BandedWG_cget_bowPressure ); |
| 626 | CK_DLL_CTRL( BandedWG_ctrl_bowMotion ); |
| 627 | CK_DLL_CGET( BandedWG_cget_bowMotion ); |
| 628 | CK_DLL_CTRL( BandedWG_ctrl_strikePosition ); |
| 629 | CK_DLL_CGET( BandedWG_cget_strikePosition ); |
| 630 | CK_DLL_CTRL( BandedWG_ctrl_vibratoFreq ); |
| 631 | CK_DLL_CGET( BandedWG_cget_vibratoFreq ); |
| 632 | CK_DLL_CTRL( BandedWG_ctrl_modesGain ); |
| 633 | CK_DLL_CGET( BandedWG_cget_modesGain ); |
| 634 | CK_DLL_CTRL( BandedWG_ctrl_bowRate ); |
| 635 | CK_DLL_CGET( BandedWG_cget_bowRate ); |
| 636 | CK_DLL_CTRL( BandedWG_ctrl_preset ); |
| 637 | CK_DLL_CGET( BandedWG_cget_preset ); |
| 638 | CK_DLL_CTRL( BandedWG_ctrl_startBowing ); |
| 639 | CK_DLL_CTRL( BandedWG_ctrl_stopBowing ); |
| 640 | CK_DLL_CTRL( BandedWG_ctrl_pluck ); |
| 641 | CK_DLL_CTRL( BandedWG_ctrl_noteOn ); |
| 642 | CK_DLL_CTRL( BandedWG_ctrl_noteOff ); |
| 643 | CK_DLL_CTRL( BandedWG_ctrl_freq ); |
| 644 | CK_DLL_CGET( BandedWG_cget_freq ); |
| 645 | CK_DLL_CTRL( BandedWG_ctrl_controlChange ); |
| 646 | /* |
| 647 | CK_DLL_CTRL( BandedWG_ctrl_aftertouch ); |
| 648 | CK_DLL_CTRL( BandedWG_ctrl_bowTarget ); |
| 649 | CK_DLL_CTRL( BandedWG_ctrl_sustain ); |
| 650 | CK_DLL_CTRL( BandedWG_ctrl_trackVelocity ); |
| 651 | CK_DLL_CTRL( BandedWG_ctrl_portamento ); |
| 652 | */ |
| 653 | |
| 654 | // BeeThree |
| 655 | CK_DLL_CTOR( BeeThree_ctor ); |
| 656 | CK_DLL_DTOR( BeeThree_dtor ); |
| 657 | CK_DLL_TICK( BeeThree_tick ); |
| 658 | CK_DLL_PMSG( BeeThree_pmsg ); |
| 659 | CK_DLL_CTRL( BeeThree_ctrl_noteOn ); |
| 660 | |
| 661 | // BlowBotl |
| 662 | CK_DLL_CTOR( BlowBotl_ctor ); |
| 663 | CK_DLL_DTOR( BlowBotl_dtor ); |
| 664 | CK_DLL_TICK( BlowBotl_tick ); |
| 665 | CK_DLL_PMSG( BlowBotl_pmsg ); |
| 666 | CK_DLL_CTRL( BlowBotl_ctrl_freq ); |
| 667 | CK_DLL_CGET( BlowBotl_cget_freq ); |
| 668 | CK_DLL_CTRL( BlowBotl_ctrl_noiseGain ); |
| 669 | CK_DLL_CGET( BlowBotl_cget_noiseGain ); |
| 670 | CK_DLL_CTRL( BlowBotl_ctrl_vibratoFreq ); |
| 671 | CK_DLL_CGET( BlowBotl_cget_vibratoFreq ); |
| 672 | CK_DLL_CTRL( BlowBotl_ctrl_vibratoGain ); |
| 673 | CK_DLL_CGET( BlowBotl_cget_vibratoGain ); |
| 674 | CK_DLL_CTRL( BlowBotl_ctrl_volume ); |
| 675 | CK_DLL_CGET( BlowBotl_cget_volume ); |
| 676 | CK_DLL_CTRL( BlowBotl_ctrl_noteOn ); |
| 677 | CK_DLL_CTRL( BlowBotl_ctrl_noteOff ); |
| 678 | CK_DLL_CTRL( BlowBotl_ctrl_controlChange ); |
| 679 | CK_DLL_CTRL( BlowBotl_ctrl_startBlowing ); |
| 680 | CK_DLL_CTRL( BlowBotl_ctrl_stopBlowing ); |
| 681 | CK_DLL_CTRL( BlowBotl_ctrl_rate ); |
| 682 | CK_DLL_CGET( BlowBotl_cget_rate ); |
| 683 | |
| 684 | // BlowHole |
| 685 | CK_DLL_CTOR( BlowHole_ctor ); |
| 686 | CK_DLL_DTOR( BlowHole_dtor ); |
| 687 | CK_DLL_TICK( BlowHole_tick ); |
| 688 | CK_DLL_PMSG( BlowHole_pmsg ); |
| 689 | CK_DLL_CTRL( BlowHole_ctrl_freq ); |
| 690 | CK_DLL_CGET( BlowHole_cget_freq ); |
| 691 | CK_DLL_CTRL( BlowHole_ctrl_reed ); |
| 692 | CK_DLL_CGET( BlowHole_cget_reed ); |
| 693 | CK_DLL_CTRL( BlowHole_ctrl_noiseGain ); |
| 694 | CK_DLL_CGET( BlowHole_cget_noiseGain ); |
| 695 | CK_DLL_CTRL( BlowHole_ctrl_tonehole ); |
| 696 | CK_DLL_CGET( BlowHole_cget_tonehole ); |
| 697 | CK_DLL_CTRL( BlowHole_ctrl_vent ); |
| 698 | CK_DLL_CGET( BlowHole_cget_vent ); |
| 699 | CK_DLL_CTRL( BlowHole_ctrl_pressure ); |
| 700 | CK_DLL_CGET( BlowHole_cget_pressure ); |
| 701 | CK_DLL_CTRL( BlowHole_ctrl_noteOn ); |
| 702 | CK_DLL_CTRL( BlowHole_ctrl_noteOff ); |
| 703 | CK_DLL_CTRL( BlowHole_ctrl_controlChange ); |
| 704 | CK_DLL_CTRL( BlowHole_ctrl_startBlowing ); |
| 705 | CK_DLL_CTRL( BlowHole_ctrl_stopBlowing ); |
| 706 | CK_DLL_CTRL( BlowHole_ctrl_rate ); |
| 707 | CK_DLL_CGET( BlowHole_cget_rate ); |
| 708 | |
| 709 | // Bowed |
| 710 | CK_DLL_CTOR( Bowed_ctor ); |
| 711 | CK_DLL_DTOR( Bowed_dtor ); |
| 712 | CK_DLL_TICK( Bowed_tick ); |
| 713 | CK_DLL_PMSG( Bowed_pmsg ); |
| 714 | CK_DLL_CTRL( Bowed_ctrl_freq ); |
| 715 | CK_DLL_CGET( Bowed_cget_freq ); |
| 716 | CK_DLL_CTRL( Bowed_ctrl_bowPressure ); |
| 717 | CK_DLL_CGET( Bowed_cget_bowPressure ); |
| 718 | CK_DLL_CTRL( Bowed_ctrl_bowPos ); |
| 719 | CK_DLL_CGET( Bowed_cget_bowPos ); |
| 720 | CK_DLL_CTRL( Bowed_ctrl_vibratoFreq ); |
| 721 | CK_DLL_CGET( Bowed_cget_vibratoFreq ); |
| 722 | CK_DLL_CTRL( Bowed_ctrl_vibratoGain ); |
| 723 | CK_DLL_CGET( Bowed_cget_vibratoGain ); |
| 724 | CK_DLL_CTRL( Bowed_ctrl_volume ); |
| 725 | CK_DLL_CGET( Bowed_cget_volume ); |
| 726 | CK_DLL_CTRL( Bowed_ctrl_noteOn ); |
| 727 | CK_DLL_CTRL( Bowed_ctrl_noteOff ); |
| 728 | CK_DLL_CTRL( Bowed_ctrl_controlChange ); |
| 729 | CK_DLL_CTRL( Bowed_ctrl_startBowing ); |
| 730 | CK_DLL_CTRL( Bowed_ctrl_stopBowing ); |
| 731 | CK_DLL_CTRL( Bowed_ctrl_rate ); |
| 732 | CK_DLL_CGET( Bowed_cget_rate ); |
| 733 | |
| 734 | // BowTabl |
| 735 | CK_DLL_CTOR( BowTabl_ctor ); |
| 736 | CK_DLL_DTOR( BowTabl_dtor ); |
| 737 | CK_DLL_TICK( BowTabl_tick ); |
| 738 | CK_DLL_PMSG( BowTabl_pmsg ); |
| 739 | CK_DLL_CTRL( BowTabl_ctrl_offset ); |
| 740 | CK_DLL_CTRL( BowTabl_ctrl_slope ); |
| 741 | |
| 742 | // Brass |
| 743 | CK_DLL_CTOR( Brass_ctor ); |
| 744 | CK_DLL_DTOR( Brass_dtor ); |
| 745 | CK_DLL_TICK( Brass_tick ); |
| 746 | CK_DLL_PMSG( Brass_pmsg ); |
| 747 | CK_DLL_CTRL( Brass_ctrl_freq ); |
| 748 | CK_DLL_CGET( Brass_cget_freq ); |
| 749 | CK_DLL_CTRL( Brass_ctrl_lip ); |
| 750 | CK_DLL_CGET( Brass_cget_lip ); |
| 751 | CK_DLL_CTRL( Brass_ctrl_slide ); |
| 752 | CK_DLL_CGET( Brass_cget_slide ); |
| 753 | CK_DLL_CTRL( Brass_ctrl_vibratoFreq ); |
| 754 | CK_DLL_CGET( Brass_cget_vibratoFreq ); |
| 755 | CK_DLL_CTRL( Brass_ctrl_vibratoGain ); |
| 756 | CK_DLL_CGET( Brass_cget_vibratoGain ); |
| 757 | CK_DLL_CTRL( Brass_ctrl_volume ); |
| 758 | CK_DLL_CGET( Brass_cget_volume ); |
| 759 | CK_DLL_CTRL( Brass_ctrl_clear ); |
| 760 | CK_DLL_CTRL( Brass_ctrl_noteOn ); |
| 761 | CK_DLL_CTRL( Brass_ctrl_noteOff ); |
| 762 | CK_DLL_CTRL( Brass_ctrl_controlChange ); |
| 763 | CK_DLL_CTRL( Brass_ctrl_startBlowing ); |
| 764 | CK_DLL_CTRL( Brass_ctrl_stopBlowing ); |
| 765 | CK_DLL_CTRL( Brass_ctrl_rate ); |
| 766 | CK_DLL_CGET( Brass_cget_rate ); |
| 767 | |
| 768 | // Clarinet |
| 769 | CK_DLL_CTOR( Clarinet_ctor ); |
| 770 | CK_DLL_DTOR( Clarinet_dtor ); |
| 771 | CK_DLL_TICK( Clarinet_tick ); |
| 772 | CK_DLL_PMSG( Clarinet_pmsg ); |
| 773 | CK_DLL_CTRL( Clarinet_ctrl_freq ); |
| 774 | CK_DLL_CGET( Clarinet_cget_freq ); |
| 775 | CK_DLL_CTRL( Clarinet_ctrl_reed ); |
| 776 | CK_DLL_CGET( Clarinet_cget_reed ); |
| 777 | CK_DLL_CTRL( Clarinet_ctrl_noiseGain ); |
| 778 | CK_DLL_CGET( Clarinet_cget_noiseGain ); |
| 779 | CK_DLL_CTRL( Clarinet_ctrl_vibratoFreq ); |
| 780 | CK_DLL_CGET( Clarinet_cget_vibratoFreq ); |
| 781 | CK_DLL_CTRL( Clarinet_ctrl_vibratoGain ); |
| 782 | CK_DLL_CGET( Clarinet_cget_vibratoGain ); |
| 783 | CK_DLL_CTRL( Clarinet_ctrl_pressure ); |
| 784 | CK_DLL_CGET( Clarinet_cget_pressure ); |
| 785 | CK_DLL_CTRL( Clarinet_ctrl_clear ); |
| 786 | CK_DLL_CTRL( Clarinet_ctrl_noteOn ); |
| 787 | CK_DLL_CTRL( Clarinet_ctrl_noteOff ); |
| 788 | CK_DLL_CTRL( Clarinet_ctrl_startBlowing ); |
| 789 | CK_DLL_CTRL( Clarinet_ctrl_stopBlowing ); |
| 790 | CK_DLL_CTRL( Clarinet_ctrl_rate ); |
| 791 | CK_DLL_CGET( Clarinet_cget_rate ); |
| 792 | CK_DLL_CTRL( Clarinet_ctrl_controlChange ); |
| 793 | |
| 794 | // Flute |
| 795 | CK_DLL_CTOR( Flute_ctor ); |
| 796 | CK_DLL_DTOR( Flute_dtor ); |
| 797 | CK_DLL_TICK( Flute_tick ); |
| 798 | CK_DLL_PMSG( Flute_pmsg ); |
| 799 | CK_DLL_CTRL( Flute_ctrl_freq ); |
| 800 | CK_DLL_CGET( Flute_cget_freq ); |
| 801 | CK_DLL_CTRL( Flute_ctrl_jetDelay ); |
| 802 | CK_DLL_CGET( Flute_cget_jetDelay ); |
| 803 | CK_DLL_CTRL( Flute_ctrl_jetReflection ); |
| 804 | CK_DLL_CGET( Flute_cget_jetReflection ); |
| 805 | CK_DLL_CTRL( Flute_ctrl_endReflection ); |
| 806 | CK_DLL_CGET( Flute_cget_endReflection ); |
| 807 | CK_DLL_CTRL( Flute_ctrl_noiseGain ); |
| 808 | CK_DLL_CGET( Flute_cget_noiseGain ); |
| 809 | CK_DLL_CTRL( Flute_ctrl_vibratoFreq ); |
| 810 | CK_DLL_CGET( Flute_cget_vibratoFreq ); |
| 811 | CK_DLL_CTRL( Flute_ctrl_vibratoGain ); |
| 812 | CK_DLL_CGET( Flute_cget_vibratoGain ); |
| 813 | CK_DLL_CTRL( Flute_ctrl_pressure ); |
| 814 | CK_DLL_CGET( Flute_cget_pressure ); |
| 815 | CK_DLL_CTRL( Flute_ctrl_clear ); |
| 816 | CK_DLL_CTRL( Flute_ctrl_noteOn ); |
| 817 | CK_DLL_CTRL( Flute_ctrl_noteOff ); |
| 818 | CK_DLL_CTRL( Flute_ctrl_controlChange ); |
| 819 | CK_DLL_CTRL( Flute_ctrl_startBlowing ); |
| 820 | CK_DLL_CTRL( Flute_ctrl_stopBlowing ); |
| 821 | CK_DLL_CTRL( Flute_ctrl_rate ); |
| 822 | CK_DLL_CGET( Flute_cget_rate ); |
| 823 | |
| 824 | // FMVoices |
| 825 | CK_DLL_CTOR( FMVoices_ctor ); |
| 826 | CK_DLL_DTOR( FMVoices_dtor ); |
| 827 | CK_DLL_TICK( FMVoices_tick ); |
| 828 | CK_DLL_PMSG( FMVoices_pmsg ); |
| 829 | CK_DLL_CTRL( FMVoices_ctrl_vowel ); |
| 830 | CK_DLL_CTRL( FMVoices_cget_vowel ); |
| 831 | CK_DLL_CTRL( FMVoices_ctrl_spectralTilt ); |
| 832 | CK_DLL_CTRL( FMVoices_cget_spectralTilt ); |
| 833 | CK_DLL_CTRL( FMVoices_ctrl_adsrTarget ); |
| 834 | CK_DLL_CTRL( FMVoices_cget_adsrTarget ); |
| 835 | |
| 836 | // HevyMetl |
| 837 | CK_DLL_CTOR( HevyMetl_ctor ); |
| 838 | CK_DLL_DTOR( HevyMetl_dtor ); |
| 839 | CK_DLL_TICK( HevyMetl_tick ); |
| 840 | CK_DLL_PMSG( HevyMetl_pmsg ); |
| 841 | |
| 842 | // HnkyTonk 1.4.1.0 (prc) REPAIRATHON2021 ADDITION, Algorithm 1 |
| 843 | CK_DLL_CTOR( HnkyTonk_ctor ); |
| 844 | CK_DLL_DTOR( HnkyTonk_dtor ); |
| 845 | CK_DLL_TICK( HnkyTonk_tick ); |
| 846 | CK_DLL_PMSG( HnkyTonk_pmsg ); |
| 847 | |
| 848 | // FrencHrn 1.4.1.0 (prc) REPAIRATHON2021 ADDITION, Algorithm 2 |
| 849 | CK_DLL_CTOR( FrencHrn_ctor ); |
| 850 | CK_DLL_DTOR( FrencHrn_dtor ); |
| 851 | CK_DLL_TICK( FrencHrn_tick ); |
| 852 | CK_DLL_PMSG( FrencHrn_pmsg ); |
| 853 | |
| 854 | // KrstlChr 1.4.1.0 (prc) REPAIRATHON2021 ADDITION, Algorithm 7 |
| 855 | CK_DLL_CTOR( KrstlChr_ctor ); |
| 856 | CK_DLL_DTOR( KrstlChr_dtor ); |
| 857 | CK_DLL_TICK( KrstlChr_tick ); |
| 858 | CK_DLL_PMSG( KrstlChr_pmsg ); |
| 859 | |
| 860 | // JetTabl |
| 861 | CK_DLL_CTOR( JetTabl_ctor ); |
| 862 | CK_DLL_DTOR( JetTabl_dtor ); |
| 863 | CK_DLL_TICK( JetTabl_tick ); |
| 864 | CK_DLL_PMSG( JetTabl_pmsg ); |
| 865 | |
| 866 | // Mandolin |
| 867 | CK_DLL_CTOR( Mandolin_ctor ); |
| 868 | CK_DLL_DTOR( Mandolin_dtor ); |
| 869 | CK_DLL_TICK( Mandolin_tick ); |
| 870 | CK_DLL_PMSG( Mandolin_pmsg ); |
| 871 | CK_DLL_CTRL( Mandolin_ctrl_freq ); |
| 872 | CK_DLL_CGET( Mandolin_cget_freq ); |
| 873 | CK_DLL_CTRL( Mandolin_ctrl_pluckPos ); |
| 874 | CK_DLL_CGET( Mandolin_cget_pluckPos ); |
| 875 | CK_DLL_CTRL( Mandolin_ctrl_bodySize ); |
| 876 | CK_DLL_CGET( Mandolin_cget_bodySize ); |
| 877 | CK_DLL_CTRL( Mandolin_ctrl_stringDamping ); |
| 878 | CK_DLL_CGET( Mandolin_cget_stringDamping ); |
| 879 | CK_DLL_CTRL( Mandolin_ctrl_stringDetune ); |
| 880 | CK_DLL_CGET( Mandolin_cget_stringDetune ); |
| 881 | CK_DLL_CTRL( Mandolin_ctrl_controlChange ); |
| 882 | CK_DLL_CTRL( Mandolin_ctrl_afterTouch ); |
| 883 | CK_DLL_CTRL( Mandolin_ctrl_pluck ); |
| 884 | CK_DLL_CTRL( Mandolin_ctrl_noteOn ); |
| 885 | CK_DLL_CTRL( Mandolin_ctrl_noteOff ); |
| 886 | CK_DLL_CTRL( Mandolin_ctrl_bodyIR ); |
| 887 | CK_DLL_CGET( Mandolin_cget_bodyIR ); |
| 888 | |
| 889 | // Modal |
| 890 | CK_DLL_CTOR( Modal_ctor ); |
| 891 | CK_DLL_DTOR( Modal_dtor ); |
| 892 | CK_DLL_TICK( Modal_tick ); |
| 893 | CK_DLL_PMSG( Modal_pmsg ); |
| 894 | CK_DLL_CTRL( Modal_ctrl_freq ); |
| 895 | CK_DLL_CTRL( Modal_ctrl_masterGain ); |
| 896 | CK_DLL_CTRL( Modal_ctrl_directGain ); |
| 897 | CK_DLL_CTRL( Modal_ctrl_mode ); |
| 898 | CK_DLL_CTRL( Modal_ctrl_modeRatio ); |
| 899 | CK_DLL_CTRL( Modal_ctrl_modeRadius ); |
| 900 | CK_DLL_CTRL( Modal_ctrl_modeGain ); |
| 901 | CK_DLL_CTRL( Modal_ctrl_strike ); |
| 902 | CK_DLL_CTRL( Modal_ctrl_damp ); |
| 903 | CK_DLL_CTRL( Modal_ctrl_noteOn ); |
| 904 | CK_DLL_CTRL( Modal_ctrl_noteOff ); |
| 905 | |
| 906 | // ModalBar |
| 907 | CK_DLL_CTOR( ModalBar_ctor ); |
| 908 | CK_DLL_DTOR( ModalBar_dtor ); |
| 909 | CK_DLL_TICK( ModalBar_tick ); |
| 910 | CK_DLL_PMSG( ModalBar_pmsg ); |
| 911 | CK_DLL_CTRL( ModalBar_ctrl_strike ); |
| 912 | CK_DLL_CTRL( ModalBar_ctrl_damp ); |
| 913 | CK_DLL_CTRL( ModalBar_ctrl_clear ); |
| 914 | CK_DLL_CTRL( ModalBar_ctrl_noteOn ); |
| 915 | CK_DLL_CTRL( ModalBar_ctrl_noteOff ); |
| 916 | CK_DLL_CTRL( ModalBar_ctrl_stickHardness ); |
| 917 | CK_DLL_CGET( ModalBar_cget_stickHardness ); |
| 918 | CK_DLL_CTRL( ModalBar_ctrl_strikePosition ); |
| 919 | CK_DLL_CGET( ModalBar_cget_strikePosition ); |
| 920 | CK_DLL_CTRL( ModalBar_ctrl_vibratoGain ); |
| 921 | CK_DLL_CGET( ModalBar_cget_vibratoGain ); |
| 922 | CK_DLL_CTRL( ModalBar_ctrl_vibratoFreq ); |
| 923 | CK_DLL_CGET( ModalBar_cget_vibratoFreq ); |
| 924 | CK_DLL_CTRL( ModalBar_ctrl_preset ); |
| 925 | CK_DLL_CGET( ModalBar_cget_preset ); |
| 926 | CK_DLL_CTRL( ModalBar_ctrl_freq ); |
| 927 | CK_DLL_CGET( ModalBar_cget_freq ); |
| 928 | CK_DLL_CTRL( ModalBar_ctrl_directGain ); |
| 929 | CK_DLL_CGET( ModalBar_cget_directGain ); |
| 930 | CK_DLL_CTRL( ModalBar_ctrl_masterGain ); |
| 931 | CK_DLL_CGET( ModalBar_cget_masterGain ); |
| 932 | CK_DLL_CTRL( ModalBar_ctrl_mode ); |
| 933 | CK_DLL_CGET( ModalBar_cget_mode ); |
| 934 | CK_DLL_CTRL( ModalBar_ctrl_modeRatio ); |
| 935 | CK_DLL_CGET( ModalBar_cget_modeRatio ); |
| 936 | CK_DLL_CTRL( ModalBar_ctrl_modeRadius ); |
| 937 | CK_DLL_CGET( ModalBar_cget_modeRadius ); |
| 938 | CK_DLL_CTRL( ModalBar_ctrl_modeGain ); |
| 939 | CK_DLL_CGET( ModalBar_cget_modeGain ); |
| 940 | CK_DLL_CTRL( ModalBar_ctrl_volume ); |
| 941 | CK_DLL_CGET( ModalBar_cget_volume ); |
| 942 | CK_DLL_CTRL( ModalBar_ctrl_controlChange ); |
| 943 | |
| 944 | |
| 945 | // Moog |
| 946 | CK_DLL_CTOR( Moog_ctor ); |
| 947 | CK_DLL_DTOR( Moog_dtor ); |
| 948 | CK_DLL_TICK( Moog_tick ); |
| 949 | CK_DLL_PMSG( Moog_pmsg ); |
| 950 | CK_DLL_CTRL( Moog_ctrl_freq ); |
| 951 | CK_DLL_CTRL( Moog_ctrl_noteOn ); |
| 952 | CK_DLL_CTRL( Moog_ctrl_modSpeed ); |
| 953 | CK_DLL_CTRL( Moog_ctrl_modDepth ); |
| 954 | CK_DLL_CTRL( Moog_ctrl_filterQ ); |
| 955 | CK_DLL_CTRL( Moog_ctrl_filterSweepRate ); |
| 956 | CK_DLL_CTRL( Moog_ctrl_filterStartFreq ); // 1.4.1.0 (prc) added |
| 957 | CK_DLL_CTRL( Moog_ctrl_afterTouch ); |
| 958 | CK_DLL_CTRL( Moog_ctrl_vibratoFreq ); |
| 959 | CK_DLL_CTRL( Moog_ctrl_vibratoGain ); |
| 960 | CK_DLL_CTRL( Moog_ctrl_volume ); |
| 961 | |
| 962 | CK_DLL_CGET( Moog_cget_freq ); |
| 963 | CK_DLL_CGET( Moog_cget_modSpeed ); |
| 964 | CK_DLL_CGET( Moog_cget_modDepth ); |
| 965 | CK_DLL_CGET( Moog_cget_filterQ ); |
| 966 | CK_DLL_CGET( Moog_cget_filterSweepRate ); |
| 967 | CK_DLL_CGET( Moog_cget_filterStartFreq ); // 1.4.1.0 (prc) added |
| 968 | CK_DLL_CGET( Moog_cget_vibratoFreq ); |
| 969 | CK_DLL_CGET( Moog_cget_vibratoGain ); |
| 970 | CK_DLL_CGET( Moog_cget_volume ); |
| 971 | |
| 972 | CK_DLL_CTRL( Moog_ctrl_controlChange ); |
| 973 | |
| 974 | // PercFlut |
| 975 | CK_DLL_CTOR( PercFlut_ctor ); |
| 976 | CK_DLL_DTOR( PercFlut_dtor ); |
| 977 | CK_DLL_TICK( PercFlut_tick ); |
| 978 | CK_DLL_PMSG( PercFlut_pmsg ); |
| 979 | CK_DLL_CTRL( PercFlut_ctrl_noteOn ); |
| 980 | CK_DLL_CTRL( PercFlut_ctrl_freq ); |
| 981 | CK_DLL_CGET( PercFlut_cget_freq ); |
| 982 | |
| 983 | // Plucked |
| 984 | CK_DLL_CTOR( Plucked_ctor ); |
| 985 | CK_DLL_DTOR( Plucked_dtor ); |
| 986 | CK_DLL_TICK( Plucked_tick ); |
| 987 | CK_DLL_PMSG( Plucked_pmsg ); |
| 988 | CK_DLL_CTRL( Plucked_ctrl_freq ); |
| 989 | CK_DLL_CTRL( Plucked_ctrl_pluck ); |
| 990 | CK_DLL_CTRL( Plucked_ctrl_noteOn ); |
| 991 | CK_DLL_CTRL( Plucked_ctrl_noteOff ); |
| 992 | |
| 993 | // PluckTwo |
| 994 | CK_DLL_CTOR( PluckTwo_ctor ); |
| 995 | CK_DLL_DTOR( PluckTwo_dtor ); |
| 996 | CK_DLL_TICK( PluckTwo_tick ); |
| 997 | CK_DLL_PMSG( PluckTwo_pmsg ); |
| 998 | CK_DLL_CTRL( PluckTwo_ctrl_detune ); |
| 999 | CK_DLL_CTRL( PluckTwo_ctrl_freq ); |
| 1000 | CK_DLL_CTRL( PluckTwo_ctrl_pluckPosition ); |
| 1001 | CK_DLL_CTRL( PluckTwo_ctrl_baseLoopGain ); |
| 1002 | CK_DLL_CTRL( PluckTwo_ctrl_pluck ); |
| 1003 | CK_DLL_CTRL( PluckTwo_ctrl_noteOn ); |
| 1004 | CK_DLL_CTRL( PluckTwo_ctrl_noteOff ); |
| 1005 | |
| 1006 | // ReedTabl |
| 1007 | CK_DLL_CTOR( ReedTabl_ctor ); |
| 1008 | CK_DLL_DTOR( ReedTabl_dtor ); |
| 1009 | CK_DLL_TICK( ReedTabl_tick ); |
| 1010 | CK_DLL_PMSG( ReedTabl_pmsg ); |
| 1011 | CK_DLL_CTRL( ReedTabl_ctrl_offset ); |
| 1012 | CK_DLL_CTRL( ReedTabl_ctrl_slope ); |
| 1013 | |
| 1014 | // Resonate |
| 1015 | CK_DLL_CTOR( Resonate_ctor ); |
| 1016 | CK_DLL_DTOR( Resonate_dtor ); |
| 1017 | CK_DLL_TICK( Resonate_tick ); |
| 1018 | CK_DLL_PMSG( Resonate_pmsg ); |
| 1019 | |
| 1020 | // Rhodey |
| 1021 | CK_DLL_CTOR( Rhodey_ctor ); |
| 1022 | CK_DLL_DTOR( Rhodey_dtor ); |
| 1023 | CK_DLL_TICK( Rhodey_tick ); |
| 1024 | CK_DLL_PMSG( Rhodey_pmsg ); |
| 1025 | CK_DLL_CTRL( Rhodey_ctrl_freq ); |
| 1026 | CK_DLL_CTRL( Rhodey_ctrl_noteOn ); |
| 1027 | CK_DLL_CTRL( Rhodey_ctrl_noteOff ); |
| 1028 | CK_DLL_CTRL( Rhodey_cget_freq ); |
| 1029 | |
| 1030 | // Saxofony |
| 1031 | CK_DLL_CTOR( Saxofony_ctor ); |
| 1032 | CK_DLL_DTOR( Saxofony_dtor ); |
| 1033 | CK_DLL_TICK( Saxofony_tick ); |
| 1034 | CK_DLL_PMSG( Saxofony_pmsg ); |
| 1035 | CK_DLL_CTRL( Saxofony_ctrl_freq ); |
| 1036 | CK_DLL_CGET( Saxofony_cget_freq ); |
| 1037 | CK_DLL_CTRL( Saxofony_ctrl_reed ); |
| 1038 | CK_DLL_CGET( Saxofony_cget_reed ); |
| 1039 | CK_DLL_CTRL( Saxofony_ctrl_aperture ); |
| 1040 | CK_DLL_CTRL( Saxofony_cget_aperture ); |
| 1041 | CK_DLL_CTRL( Saxofony_ctrl_noiseGain ); |
| 1042 | CK_DLL_CGET( Saxofony_cget_noiseGain ); |
| 1043 | CK_DLL_CTRL( Saxofony_ctrl_vibratoGain ); |
| 1044 | CK_DLL_CGET( Saxofony_cget_vibratoGain ); |
| 1045 | CK_DLL_CTRL( Saxofony_ctrl_vibratoFreq ); |
| 1046 | CK_DLL_CTRL( Saxofony_cget_vibratoFreq ); |
| 1047 | CK_DLL_CTRL( Saxofony_ctrl_blowPosition ); |
| 1048 | CK_DLL_CGET( Saxofony_cget_blowPosition ); |
| 1049 | CK_DLL_CTRL( Saxofony_ctrl_pressure ); |
| 1050 | CK_DLL_CGET( Saxofony_cget_pressure ); |
| 1051 | CK_DLL_CTRL( Saxofony_ctrl_controlChange ); |
| 1052 | CK_DLL_CTRL( Saxofony_ctrl_startBlowing ); |
| 1053 | CK_DLL_CTRL( Saxofony_ctrl_stopBlowing ); |
| 1054 | CK_DLL_CTRL( Saxofony_ctrl_clear ); |
| 1055 | CK_DLL_CTRL( Saxofony_ctrl_rate ); |
| 1056 | CK_DLL_CGET( Saxofony_cget_rate ); |
| 1057 | CK_DLL_CTRL( Saxofony_ctrl_noteOn ); |
| 1058 | CK_DLL_CTRL( Saxofony_ctrl_noteOff ); |
| 1059 | |
| 1060 | // Shakers |
| 1061 | CK_DLL_CTOR( Shakers_ctor ); |
| 1062 | CK_DLL_DTOR( Shakers_dtor ); |
| 1063 | CK_DLL_TICK( Shakers_tick ); |
| 1064 | CK_DLL_PMSG( Shakers_pmsg ); |
| 1065 | CK_DLL_CTRL( Shakers_ctrl_energy ); |
| 1066 | CK_DLL_CGET( Shakers_cget_energy ); |
| 1067 | CK_DLL_CTRL( Shakers_ctrl_decay ); |
| 1068 | CK_DLL_CGET( Shakers_cget_decay ); |
| 1069 | CK_DLL_CTRL( Shakers_ctrl_objects ); |
| 1070 | CK_DLL_CGET( Shakers_cget_objects ); |
| 1071 | CK_DLL_CTRL( Shakers_ctrl_which ); |
| 1072 | CK_DLL_CGET( Shakers_cget_which ); |
| 1073 | CK_DLL_CTRL( Shakers_ctrl_noteOn ); |
| 1074 | CK_DLL_CTRL( Shakers_ctrl_noteOff ); |
| 1075 | CK_DLL_CTRL( Shakers_ctrl_freq ); |
| 1076 | CK_DLL_CGET( Shakers_cget_freq ); |
| 1077 | CK_DLL_CTRL( Shakers_ctrl_controlChange ); |
| 1078 | |
| 1079 | // Simple |
| 1080 | CK_DLL_CTOR( Simple_ctor ); |
| 1081 | CK_DLL_DTOR( Simple_dtor ); |
| 1082 | CK_DLL_PMSG( Simple_pmsg ); |
| 1083 | CK_DLL_CTRL( Simple_ctrl_freq ); |
| 1084 | |
| 1085 | // SingWave |
| 1086 | CK_DLL_CTOR( SingWave_ctor ); |
| 1087 | CK_DLL_DTOR( SingWave_dtor ); |
| 1088 | CK_DLL_TICK( SingWave_tick ); |
| 1089 | CK_DLL_PMSG( SingWave_pmsg ); |
| 1090 | CK_DLL_CTRL( SingWave_ctrl_wavFilename ); |
| 1091 | CK_DLL_CTRL( SingWave_ctrl_rawFilename ); |
| 1092 | CK_DLL_CTRL( SingWave_ctrl_norm ); |
| 1093 | CK_DLL_CTRL( SingWave_ctrl_sweepRate ); |
| 1094 | CK_DLL_CTRL( SingWave_ctrl_freq ); |
| 1095 | CK_DLL_CTRL( SingWave_ctrl_vibratoRate ); |
| 1096 | CK_DLL_CTRL( SingWave_ctrl_vibratoGain ); |
| 1097 | CK_DLL_CTRL( SingWave_ctrl_randomGain ); |
| 1098 | CK_DLL_CTRL( SingWave_ctrl_gainTarget ); |
| 1099 | CK_DLL_CTRL( SingWave_ctrl_gainRate ); |
| 1100 | |
| 1101 | // Sitar |
| 1102 | CK_DLL_CTOR( Sitar_ctor ); |
| 1103 | CK_DLL_DTOR( Sitar_dtor ); |
| 1104 | CK_DLL_TICK( Sitar_tick ); |
| 1105 | CK_DLL_PMSG( Sitar_pmsg ); |
| 1106 | CK_DLL_CTRL( Sitar_ctrl_noteOn ); |
| 1107 | CK_DLL_CTRL( Sitar_ctrl_noteOff ); |
| 1108 | CK_DLL_CTRL( Sitar_ctrl_pluck ); |
| 1109 | CK_DLL_CTRL( Sitar_ctrl_clear ); |
| 1110 | CK_DLL_CTRL( Sitar_ctrl_freq ); |
| 1111 | CK_DLL_CTRL( Sitar_cget_freq ); |
| 1112 | |
| 1113 | // Sphere |
| 1114 | CK_DLL_CTOR( Sphere_ctor ); |
| 1115 | CK_DLL_DTOR( Sphere_dtor ); |
| 1116 | CK_DLL_TICK( Sphere_tick ); |
| 1117 | CK_DLL_PMSG( Sphere_pmsg ); |
| 1118 | CK_DLL_CTRL( Sphere_ctrl_radius ); |
| 1119 | CK_DLL_CTRL( Sphere_ctrl_mass ); |
| 1120 | |
| 1121 | // StifKarp |
| 1122 | CK_DLL_CTOR( StifKarp_ctor ); |
| 1123 | CK_DLL_DTOR( StifKarp_dtor ); |
| 1124 | CK_DLL_TICK( StifKarp_tick ); |
| 1125 | CK_DLL_PMSG( StifKarp_pmsg ); |
| 1126 | CK_DLL_CTRL( StifKarp_ctrl_pluck ); |
| 1127 | CK_DLL_CTRL( StifKarp_ctrl_clear ); |
| 1128 | CK_DLL_CTRL( StifKarp_ctrl_noteOn ); |
| 1129 | CK_DLL_CTRL( StifKarp_ctrl_noteOff ); |
| 1130 | |
| 1131 | CK_DLL_CTRL( StifKarp_ctrl_freq ); |
| 1132 | CK_DLL_CGET( StifKarp_cget_freq ); |
| 1133 | CK_DLL_CTRL( StifKarp_ctrl_pickupPosition ); |
| 1134 | CK_DLL_CGET( StifKarp_cget_pickupPosition ); |
| 1135 | CK_DLL_CTRL( StifKarp_ctrl_stretch ); |
| 1136 | CK_DLL_CGET( StifKarp_cget_stretch ); |
| 1137 | CK_DLL_CTRL( StifKarp_ctrl_sustain ); |
| 1138 | CK_DLL_CGET( StifKarp_cget_sustain ); |
| 1139 | CK_DLL_CTRL( StifKarp_ctrl_baseLoopGain ); |
| 1140 | CK_DLL_CGET( StifKarp_cget_baseLoopGain ); |
| 1141 | |
| 1142 | // TubeBell |
| 1143 | CK_DLL_CTOR( TubeBell_ctor ); |
| 1144 | CK_DLL_DTOR( TubeBell_dtor ); |
| 1145 | CK_DLL_TICK( TubeBell_tick ); |
| 1146 | CK_DLL_PMSG( TubeBell_pmsg ); |
| 1147 | CK_DLL_CTRL( TubeBell_ctrl_noteOn ); |
| 1148 | CK_DLL_CTRL( TubeBell_ctrl_freq ); |
| 1149 | CK_DLL_CGET( TubeBell_cget_freq ); |
| 1150 | |
| 1151 | // Voicer |
| 1152 | CK_DLL_CTOR( Voicer_ctor ); |
| 1153 | CK_DLL_DTOR( Voicer_dtor ); |
| 1154 | CK_DLL_TICK( Voicer_tick ); |
| 1155 | CK_DLL_PMSG( Voicer_pmsg ); |
| 1156 | |
| 1157 | // VoicForm |
| 1158 | CK_DLL_CTOR( VoicForm_ctor ); |
| 1159 | CK_DLL_DTOR( VoicForm_dtor ); |
| 1160 | CK_DLL_TICK( VoicForm_tick ); |
| 1161 | CK_DLL_PMSG( VoicForm_pmsg ); |
| 1162 | CK_DLL_CTRL( VoicForm_ctrl_voiceMix ); |
| 1163 | CK_DLL_CGET( VoicForm_cget_voiceMix ); |
| 1164 | CK_DLL_CTRL( VoicForm_ctrl_phoneme ); |
| 1165 | CK_DLL_CGET( VoicForm_cget_phoneme ); |
| 1166 | CK_DLL_CTRL( VoicForm_ctrl_vibratoFreq ); |
| 1167 | CK_DLL_CGET( VoicForm_cget_vibratoFreq ); |
| 1168 | CK_DLL_CTRL( VoicForm_ctrl_vibratoGain ); |
| 1169 | CK_DLL_CGET( VoicForm_cget_vibratoGain ); |
| 1170 | CK_DLL_CTRL( VoicForm_ctrl_loudness ); |
| 1171 | CK_DLL_CGET( VoicForm_cget_loudness ); |
| 1172 | CK_DLL_CTRL( VoicForm_ctrl_freq ); |
| 1173 | CK_DLL_CGET( VoicForm_cget_freq ); |
| 1174 | CK_DLL_CTRL( VoicForm_ctrl_noteOn ); |
| 1175 | CK_DLL_CTRL( VoicForm_ctrl_noteOff ); |
| 1176 | CK_DLL_CTRL( VoicForm_ctrl_speak ); |
| 1177 | CK_DLL_CTRL( VoicForm_ctrl_quiet ); |
| 1178 | CK_DLL_CTRL( VoicForm_ctrl_voiced ); |
| 1179 | CK_DLL_CGET( VoicForm_cget_voiced ); |
| 1180 | CK_DLL_CTRL( VoicForm_ctrl_unVoiced ); |
| 1181 | CK_DLL_CGET( VoicForm_cget_unVoiced ); |
| 1182 | CK_DLL_CTRL( VoicForm_ctrl_pitchSweepRate ); |
| 1183 | CK_DLL_CGET( VoicForm_cget_pitchSweepRate ); |
| 1184 | CK_DLL_CTRL( VoicForm_ctrl_selPhoneme ); |
| 1185 | CK_DLL_CGET( VoicForm_cget_selPhoneme ); |
| 1186 | |
| 1187 | // Whistle |
| 1188 | CK_DLL_CTOR( Whistle_ctor ); |
| 1189 | CK_DLL_DTOR( Whistle_dtor ); |
| 1190 | CK_DLL_TICK( Whistle_tick ); |
| 1191 | CK_DLL_PMSG( Whistle_pmsg ); |
| 1192 | CK_DLL_CTRL( Whistle_ctrl_freq ); |
| 1193 | CK_DLL_CTRL( Whistle_ctrl_startBlowing ); |
| 1194 | CK_DLL_CTRL( Whistle_ctrl_stopBlowing ); |
| 1195 | CK_DLL_CTRL( Whistle_ctrl_noteOn ); |
| 1196 | CK_DLL_CTRL( Whistle_ctrl_noteOff ); |
| 1197 | |
| 1198 | // Wurley |
| 1199 | CK_DLL_CTOR( Wurley_ctor ); |
| 1200 | CK_DLL_DTOR( Wurley_dtor ); |
| 1201 | CK_DLL_TICK( Wurley_tick ); |
| 1202 | CK_DLL_PMSG( Wurley_pmsg ); |
| 1203 | CK_DLL_CTRL( Wurley_ctrl_freq ); |
| 1204 | CK_DLL_CTRL( Wurley_ctrl_noteOn ); |
| 1205 | CK_DLL_CTRL( Wurley_ctrl_noteOff ); |
| 1206 | CK_DLL_CGET( Wurley_cget_freq ); |
| 1207 | |
| 1208 | |
| 1209 | |
| 1210 | // Instrmnt |
| 1211 | CK_DLL_CTOR( Instrmnt_ctor ); |
| 1212 | CK_DLL_DTOR( Instrmnt_dtor ); |
| 1213 | CK_DLL_TICK( Instrmnt_tick ); |
| 1214 | CK_DLL_PMSG( Instrmnt_pmsg ); |
| 1215 | CK_DLL_CTRL( Instrmnt_ctrl_freq ); |
| 1216 | |
| 1217 | // Mesh2D |
| 1218 | CK_DLL_CTOR( Mesh2D_ctor ); |
| 1219 | CK_DLL_DTOR( Mesh2D_dtor ); |
| 1220 | CK_DLL_TICK( Mesh2D_tick ); |
| 1221 | CK_DLL_PMSG( Mesh2D_pmsg ); |
| 1222 | //CK_DLL_CTRL( Mesh2D_ctrl_NY ); |
| 1223 | //CK_DLL_CTRL( Mesh2D_ctrl_NY ); |
| 1224 | //CK_DLL_CTRL( Mesh2D_ctrl_NY ); |
| 1225 | //CK_DLL_CTRL( Mesh2D_ctrl_NX ); |
| 1226 | //CK_DLL_CTRL( Mesh2D_ctrl_NX ); |
| 1227 | //CK_DLL_CTRL( Mesh2D_ctrl_NX ); |
| 1228 | CK_DLL_CTRL( Mesh2D_ctrl_decay ); |
| 1229 | |
| 1230 | // Reverb |
| 1231 | CK_DLL_CTOR( Reverb_ctor ); |
| 1232 | CK_DLL_DTOR( Reverb_dtor ); |
| 1233 | CK_DLL_TICK( Reverb_tick ); |
| 1234 | CK_DLL_PMSG( Reverb_pmsg ); |
| 1235 | CK_DLL_CTRL( Reverb_ctrl_effectMix ); |
| 1236 | |
| 1237 | // Socket |
| 1238 | CK_DLL_CTOR( Socket_ctor ); |
| 1239 | CK_DLL_DTOR( Socket_dtor ); |
| 1240 | CK_DLL_TICK( Socket_tick ); |
| 1241 | CK_DLL_PMSG( Socket_pmsg ); |
| 1242 | |
| 1243 | // Stk |
| 1244 | CK_DLL_CTOR( Stk_ctor ); |
| 1245 | CK_DLL_DTOR( Stk_dtor ); |
| 1246 | CK_DLL_TICK( Stk_tick ); |
| 1247 | CK_DLL_PMSG( Stk_pmsg ); |
| 1248 | CK_DLL_CTRL( Stk_ctrl_sampleRate ); |
| 1249 | CK_DLL_CTRL( Stk_ctrl_rawwavePath ); |
| 1250 | |
| 1251 | // Table |
| 1252 | CK_DLL_CTOR( Table_ctor ); |
| 1253 | CK_DLL_DTOR( Table_dtor ); |
| 1254 | CK_DLL_TICK( Table_tick ); |
| 1255 | CK_DLL_PMSG( Table_pmsg ); |
| 1256 | |
| 1257 | // TcpWvIn |
| 1258 | CK_DLL_CTOR( TcpWvIn_ctor ); |
| 1259 | CK_DLL_DTOR( TcpWvIn_dtor ); |
| 1260 | CK_DLL_TICK( TcpWvIn_tick ); |
| 1261 | CK_DLL_PMSG( TcpWvIn_pmsg ); |
| 1262 | |
| 1263 | // TcpWvOut |
| 1264 | CK_DLL_CTOR( TcpWvOut_ctor ); |
| 1265 | CK_DLL_DTOR( TcpWvOut_dtor ); |
| 1266 | CK_DLL_TICK( TcpWvOut_tick ); |
| 1267 | CK_DLL_PMSG( TcpWvOut_pmsg ); |
| 1268 | |
| 1269 | // Vector3D |
| 1270 | CK_DLL_CTOR( Vector3D_ctor ); |
| 1271 | CK_DLL_DTOR( Vector3D_dtor ); |
| 1272 | CK_DLL_TICK( Vector3D_tick ); |
| 1273 | CK_DLL_PMSG( Vector3D_pmsg ); |
| 1274 | CK_DLL_CTRL( Vector3D_ctrl_x ); |
| 1275 | CK_DLL_CTRL( Vector3D_ctrl_y ); |
| 1276 | CK_DLL_CTRL( Vector3D_ctrl_z ); |
| 1277 | |
| 1278 | // JetTable |
| 1279 | CK_DLL_CTOR( JetTabl_ctor ); |
| 1280 | CK_DLL_DTOR( JetTabl_dtor ); |
| 1281 | CK_DLL_TICK( JetTabl_tick ); |
| 1282 | CK_DLL_PMSG( JetTabl_pmsg ); |
| 1283 | |
| 1284 | // Mesh2D |
| 1285 | CK_DLL_CTOR( Mesh2D_ctor ); |
| 1286 | CK_DLL_DTOR( Mesh2D_dtor ); |
| 1287 | CK_DLL_TICK( Mesh2D_tick ); |
| 1288 | CK_DLL_PMSG( Mesh2D_pmsg ); |
| 1289 | CK_DLL_CTRL( Mesh2D_ctrl_nx ); |
| 1290 | CK_DLL_CTRL( Mesh2D_ctrl_ny ); |
| 1291 | CK_DLL_CTRL( Mesh2D_cget_nx ); |
| 1292 | CK_DLL_CTRL( Mesh2D_cget_ny ); |
| 1293 | CK_DLL_CTRL( Mesh2D_ctrl_input_position ); |
| 1294 | CK_DLL_CTRL( Mesh2D_cget_input_position ); |
| 1295 | CK_DLL_CTRL( Mesh2D_ctrl_decay ); |
| 1296 | CK_DLL_CTRL( Mesh2D_cget_decay ); |
| 1297 | CK_DLL_CTRL( Mesh2D_ctrl_note_on ); |
| 1298 | CK_DLL_CTRL( Mesh2D_ctrl_note_off ); |
| 1299 | CK_DLL_CTRL( Mesh2D_cget_energy ); |
| 1300 | CK_DLL_CTRL( Mesh2D_ctrl_control_change ); |
| 1301 | |
| 1302 | |
| 1303 | // MidiFileIn |
| 1304 | CK_DLL_CTOR( MidiFileIn_ctor ); |
| 1305 | CK_DLL_DTOR( MidiFileIn_dtor ); |
| 1306 | CK_DLL_MFUN( MidiFileIn_open ); |
| 1307 | CK_DLL_MFUN( MidiFileIn_close ); |
| 1308 | CK_DLL_MFUN( MidiFileIn_numTracks ); |
| 1309 | CK_DLL_MFUN( MidiFileIn_ticksPerQuarter ); |
| 1310 | CK_DLL_MFUN( MidiFileIn_beatsPerMinute ); |
| 1311 | CK_DLL_MFUN( MidiFileIn_read ); |
| 1312 | CK_DLL_MFUN( MidiFileIn_readTrack ); |
| 1313 | CK_DLL_MFUN( MidiFileIn_rewind ); |
| 1314 | CK_DLL_MFUN( MidiFileIn_rewindTrack ); |
| 1315 | |
| 1316 | //----------------------------------------------------------------------------- |
| 1317 | // this is called for this module to know when sample rate changes | 1.5.4.2 (ge) added |
| 1318 | //----------------------------------------------------------------------------- |
| 1319 | void stk_srate_update_cb( t_CKUINT srate, void * userdata ) { Stk::setSampleRate( srate ); } |
| 1320 | |
| 1321 | |
| 1322 | |
| 1323 | |
| 1324 | //----------------------------------------------------------------------------- |
| 1325 | // name: stk_query() |
| 1326 | // desc: ... |
| 1327 | //----------------------------------------------------------------------------- |
| 1328 | DLL_QUERY stk_query( Chuck_DL_Query * QUERY ) |
| 1329 | { |
| 1330 | Chuck_Env * env = QUERY->env(); |
| 1331 | Chuck_DL_Func * func = NULL; |
| 1332 | |
| 1333 | std::string doc; |
| 1334 | |
| 1335 | // TODO: does not work for multiple VMs running different sample rates |
| 1336 | // https://github.com/ccrma/chuck/issues/208 |
| 1337 | // set srate |
| 1338 | Stk::setSampleRate( QUERY->srate() ); |
| 1339 | // register callback to be notified if/when sample rate changes | 1.5.4.2 (ge) added |
| 1340 | QUERY->register_callback_on_srate_update( QUERY, stk_srate_update_cb, NULL ); |
| 1341 | |
| 1342 | // test for endian |
| 1343 | what w; w.x = 1; |
| 1344 | little_endian = (t_CKBOOL)w.y[0]; |
| 1345 | |
| 1346 | //! \sectionMain STK |
| 1347 | |
| 1348 | //! \section stk - instruments |
| 1349 | |
| 1350 | //------------------------------------------------------------------------ |
| 1351 | // begin StkInstrument UGen |
| 1352 | //------------------------------------------------------------------------ |
| 1353 | |
| 1354 | doc = "super-class for STK instruments."; |
| 1355 | |
| 1356 | if( !type_engine_import_ugen_begin( env, "StkInstrument", "UGen", env->global(), |
| 1357 | Instrmnt_ctor, NULL, Instrmnt_tick, Instrmnt_pmsg, |
| 1358 | doc.c_str()) ) return FALSE; |
| 1359 | // member variable |
| 1360 | Instrmnt_offset_data = type_engine_import_mvar ( env, "int", "@Instrmnt_data", FALSE ); |
| 1361 | if( Instrmnt_offset_data == CK_INVALID_OFFSET ) goto error; |
| 1362 | |
| 1363 | func = make_new_mfun( "float", "noteOn", Instrmnt_ctrl_noteOn ); //! note on |
| 1364 | func->add_arg( "float", "value" ); |
| 1365 | func->doc = "trigger note on."; |
| 1366 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1367 | |
| 1368 | func = make_new_mfun( "float", "noteOff", Instrmnt_ctrl_noteOff ); //! note off |
| 1369 | func->add_arg( "float", "value" ); |
| 1370 | func->doc = "trigger note off."; |
| 1371 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1372 | |
| 1373 | func = make_new_mfun( "float", "freq", Instrmnt_ctrl_freq ); //! frequency |
| 1374 | func->add_arg( "float", "value" ); |
| 1375 | func->doc = "set frequency."; |
| 1376 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1377 | |
| 1378 | func = make_new_mfun( "float", "freq", Instrmnt_cget_freq ); //! frequency |
| 1379 | func->doc = "get frequency."; |
| 1380 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1381 | |
| 1382 | func = make_new_mfun( "void", "controlChange", Instrmnt_ctrl_controlChange ); //! control change |
| 1383 | func->add_arg( "int", "ctrl" ); |
| 1384 | func->add_arg( "float", "value" ); |
| 1385 | func->doc = "assert control change; numbers are instrument specific; value range [0.0 - 127.0]"; |
| 1386 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1387 | |
| 1388 | // end the class import |
| 1389 | type_engine_import_class_end( env ); |
| 1390 | |
| 1391 | |
| 1392 | //------------------------------------------------------------------------ |
| 1393 | // begin BandedWG ugen |
| 1394 | //------------------------------------------------------------------------ |
| 1395 | |
| 1396 | doc = "This class uses banded waveguide techniques to model a variety of sounds, including bowed bars, glasses, and bowls. For more information, see Essl, G. and Cook, P. 'Banded Waveguides: Towards Physical Modelling of Bar Percussion Instruments', Proceedings of the 1999 International Computer Music Conference.\n\ |
| 1397 | \n\ |
| 1398 | Control Change Numbers:\n\ |
| 1399 | \n\ |
| 1400 | - Bow Pressure = 2\n\ |
| 1401 | - Bow Motion = 4\n\ |
| 1402 | - Strike Position = 8 (not implemented)\n\ |
| 1403 | - Vibrato Frequency = 11\n\ |
| 1404 | - Gain = 1\n\ |
| 1405 | - Bow Velocity = 128\n\ |
| 1406 | - Instrument Presets = 16\n\ |
| 1407 | - Uniform Bar = 0\n\ |
| 1408 | - Tuned Bar = 1\n\ |
| 1409 | - Glass Harmonica = 2\n\ |
| 1410 | - Tibetan Bowl = 3\n\ |
| 1411 | \n\ |
| 1412 | by Georg Essl, 1999 - 2002.\n\ |
| 1413 | Modified for Stk 4.0 by Gary Scavone."; |
| 1414 | |
| 1415 | if( !type_engine_import_ugen_begin( env, "BandedWG", "StkInstrument", env->global(), |
| 1416 | BandedWG_ctor, BandedWG_dtor, |
| 1417 | BandedWG_tick, BandedWG_pmsg, doc.c_str() ) ) return FALSE; |
| 1418 | |
| 1419 | type_engine_import_add_ex(env, "stk/band-o-matic.ck"); |
| 1420 | type_engine_import_add_ex(env, "stk/bandedwg.ck"); |
| 1421 | type_engine_import_add_ex(env, "stk/bandedwg2.ck"); |
| 1422 | |
| 1423 | // member variable |
| 1424 | // BandedWG_offset_data = type_engine_import_mvar ( env, "int", "@BandedWG_data", FALSE ); |
| 1425 | // if( BandedWG_offset_data == CK_INVALID_OFFSET ) goto error; |
| 1426 | |
| 1427 | func = make_new_mfun( "float", "pluck", BandedWG_ctrl_pluck ); //! pluck waveguide |
| 1428 | func->add_arg( "float", "value" ); |
| 1429 | func->doc = "pluck instrument, [0.0-1.0]."; |
| 1430 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1431 | |
| 1432 | func = make_new_mfun( "float", "startBowing", BandedWG_ctrl_startBowing ); //! startBowing |
| 1433 | func->add_arg( "float", "value" ); |
| 1434 | func->doc = "start bowing, [0.0-1.0]."; |
| 1435 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1436 | |
| 1437 | func = make_new_mfun( "float", "stopBowing", BandedWG_ctrl_stopBowing ); //! stopBowing |
| 1438 | func->add_arg( "float", "value" ); |
| 1439 | func->doc = "stop bowing, [0.0-1.0]."; |
| 1440 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1441 | |
| 1442 | func = make_new_mfun( "float", "bowRate", BandedWG_ctrl_bowRate ); //! strike bowRate |
| 1443 | func->add_arg( "float", "value" ); |
| 1444 | func->doc = "set bowing rate (seconds)."; |
| 1445 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1446 | |
| 1447 | func = make_new_mfun( "float", "bowRate", BandedWG_cget_bowRate ); //! strike bowRate |
| 1448 | func->doc = "get bowing rate (seconds)."; |
| 1449 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1450 | |
| 1451 | func = make_new_mfun( "float", "bowPressure", BandedWG_ctrl_bowPressure ); //! bowPressure |
| 1452 | func->add_arg( "float", "value" ); |
| 1453 | func->doc = "set bow pressure, [0.0-1.0]."; |
| 1454 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1455 | |
| 1456 | func = make_new_mfun( "float", "bowPressure", BandedWG_cget_bowPressure ); //! bowPressure |
| 1457 | func->doc = "get bow pressure, [0.0-1.0]."; |
| 1458 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1459 | |
| 1460 | func = make_new_mfun( "float", "bowMotion", BandedWG_ctrl_bowMotion ); //! bowMotion |
| 1461 | func->add_arg( "float", "value" ); |
| 1462 | func->doc = "set bow motion, [0.0-1.0]."; |
| 1463 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1464 | |
| 1465 | func = make_new_mfun( "float", "bowMotion", BandedWG_cget_bowMotion ); //! bowMotion |
| 1466 | func->doc = "get bow motion, [0.0-1.0]."; |
| 1467 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1468 | |
| 1469 | func = make_new_mfun( "float", "integrationConstant", BandedWG_ctrl_vibratoFreq ); //! vibratoFreq |
| 1470 | func->add_arg( "float", "value" ); |
| 1471 | func->doc = "set integration constant, vibrato frequency."; |
| 1472 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1473 | |
| 1474 | func = make_new_mfun( "float", "integrationConstant", BandedWG_cget_vibratoFreq ); //! vibratoFreq |
| 1475 | func->doc = "get integration constant, vibrato frequency."; |
| 1476 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1477 | |
| 1478 | func = make_new_mfun( "float", "modesGain", BandedWG_ctrl_modesGain ); //! modesGain |
| 1479 | func->add_arg( "float", "value" ); |
| 1480 | func->doc = "set amplitude for modes."; |
| 1481 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1482 | |
| 1483 | func = make_new_mfun( "float", "modesGain", BandedWG_cget_modesGain ); //! modesGain |
| 1484 | func->doc = "get amplitude for modes."; |
| 1485 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1486 | |
| 1487 | func = make_new_mfun( "int", "preset", BandedWG_ctrl_preset ); //! preset |
| 1488 | func->add_arg( "int", "value" ); |
| 1489 | func->doc = "set instrument preset, (0-3, see above)."; |
| 1490 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1491 | |
| 1492 | func = make_new_mfun( "int", "preset", BandedWG_cget_preset ); //! preset |
| 1493 | func->doc = "get instrument preset, (0-3, see above)."; |
| 1494 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1495 | |
| 1496 | func = make_new_mfun( "float", "strikePosition", BandedWG_ctrl_strikePosition ); //! strike Position |
| 1497 | func->add_arg( "float", "value" ); |
| 1498 | func->doc = "set strike position, [0.0-1.0]."; |
| 1499 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1500 | |
| 1501 | func = make_new_mfun( "float", "strikePosition", BandedWG_cget_strikePosition ); //! strike Position |
| 1502 | func->doc = "get strike position, [0.0-1.0]."; |
| 1503 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1504 | |
| 1505 | // end the class import |
| 1506 | type_engine_import_class_end( env ); |
| 1507 | |
| 1508 | |
| 1509 | //------------------------------------------------------------------------ |
| 1510 | // begin BlowBotl ugen |
| 1511 | //------------------------------------------------------------------------ |
| 1512 | |
| 1513 | doc = "This class implements a helmholtz resonator (biquad filter) with a polynomial jet excitation (a la Cook).\n\ |
| 1514 | \n\ |
| 1515 | Control Change Numbers:\n\ |
| 1516 | \n\ |
| 1517 | - Noise Gain = 4\n\ |
| 1518 | - Vibrato Frequency = 11\n\ |
| 1519 | - Vibrato Gain = 1\n\ |
| 1520 | - Volume = 128\n\ |
| 1521 | \n\ |
| 1522 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002"; |
| 1523 | |
| 1524 | if( !type_engine_import_ugen_begin( env, "BlowBotl", "StkInstrument", env->global(), |
| 1525 | BlowBotl_ctor, BlowBotl_dtor, |
| 1526 | BlowBotl_tick, BlowBotl_pmsg, doc.c_str() ) ) return FALSE; |
| 1527 | |
| 1528 | type_engine_import_add_ex(env, "stk/blowbotl.ck"); |
| 1529 | type_engine_import_add_ex(env, "stk/blowbotl2.ck"); |
| 1530 | |
| 1531 | // member variable |
| 1532 | // BlowBotl_offset_data = type_engine_import_mvar ( env, "int", "@BlowBotl_data", FALSE ); |
| 1533 | // if( BlowBotl_offset_data == CK_INVALID_OFFSET ) goto error; |
| 1534 | |
| 1535 | func = make_new_mfun( "float", "startBlowing", BlowBotl_ctrl_startBlowing ); //! note on |
| 1536 | func->add_arg( "float", "value" ); |
| 1537 | func->doc = "start blowing, [0.0-1.0]."; |
| 1538 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1539 | |
| 1540 | func = make_new_mfun( "float", "stopBlowing", BlowBotl_ctrl_stopBlowing ); //! note on |
| 1541 | func->add_arg( "float", "value" ); |
| 1542 | func->doc = "stop blowing, [0.0-1.0]."; |
| 1543 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1544 | |
| 1545 | func = make_new_mfun( "float", "rate", BlowBotl_ctrl_rate ); //! attack rate |
| 1546 | func->add_arg( "float", "value" ); |
| 1547 | func->doc = "set rate of attack"; |
| 1548 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1549 | |
| 1550 | func = make_new_mfun( "float", "rate", BlowBotl_cget_rate ); //! attack rate |
| 1551 | func->doc = "get rate of attack"; |
| 1552 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1553 | |
| 1554 | func = make_new_mfun( "float", "noiseGain", BlowBotl_ctrl_noiseGain ); //! noiseGain |
| 1555 | func->add_arg( "float", "value" ); |
| 1556 | func->doc = "set noise component gain, [0.0-1.0]."; |
| 1557 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1558 | |
| 1559 | func = make_new_mfun( "float", "noiseGain", BlowBotl_cget_noiseGain ); //! noiseGain |
| 1560 | func->doc = "get noise component gain, [0.0-1.0]."; |
| 1561 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1562 | |
| 1563 | func = make_new_mfun( "float", "vibratoFreq", BlowBotl_ctrl_vibratoFreq ); //! vibratoFreq |
| 1564 | func->add_arg( "float", "value" ); |
| 1565 | func->doc = "set vibrato frequency (Hz)."; |
| 1566 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1567 | |
| 1568 | func = make_new_mfun( "float", "vibratoFreq", BlowBotl_cget_vibratoFreq ); //! vibratoFreq |
| 1569 | func->doc = "get vibrato frequency (Hz)."; |
| 1570 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1571 | |
| 1572 | func = make_new_mfun( "float", "vibratoGain", BlowBotl_ctrl_vibratoGain ); //! vibratoGain |
| 1573 | func->add_arg( "float", "value" ); |
| 1574 | func->doc = "set vibrato gain, [0.0-1.0]."; |
| 1575 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1576 | |
| 1577 | func = make_new_mfun( "float", "vibratoGain", BlowBotl_cget_vibratoGain ); //! vibratoGain |
| 1578 | func->doc = "get vibrato gain, [0.0-1.0]."; |
| 1579 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1580 | |
| 1581 | func = make_new_mfun( "float", "volume", BlowBotl_ctrl_volume ); //! volume |
| 1582 | func->add_arg( "float", "value" ); |
| 1583 | func->doc = "set volume, [0.0-1.0]."; |
| 1584 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1585 | |
| 1586 | func = make_new_mfun( "float", "volume", BlowBotl_cget_volume ); //! volume |
| 1587 | func->doc = "get volume, [0.0-1.0]."; |
| 1588 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1589 | |
| 1590 | // end the class import |
| 1591 | type_engine_import_class_end( env ); |
| 1592 | |
| 1593 | |
| 1594 | //------------------------------------------------------------------------ |
| 1595 | // begin BlowHole ugen |
| 1596 | //------------------------------------------------------------------------ |
| 1597 | |
| 1598 | doc = "This class is based on the clarinet model, with the addition of a two-port register hole and a three-port dynamic tonehole implementation, as discussed by Scavone and Cook (1998).\n\ |
| 1599 | \n\ |
| 1600 | In this implementation, the distances between the reed/register hole and tonehole/bell are fixed. As a result, both the tonehole and register hole will have variable influence on the playing frequency, which is dependent on the length of the air column. In addition, the highest playing freqeuency is limited by these fixed lengths. This is a digital waveguide model, making its use possibly subject to patents held by Stanford University, Yamaha, and others.\n\ |
| 1601 | \n\ |
| 1602 | Control Change Numbers:\n\ |
| 1603 | \n\ |
| 1604 | - Reed Stiffness = 2\n\ |
| 1605 | - Noise Gain = 4\n\ |
| 1606 | - Tonehole State = 11\n\ |
| 1607 | - Register State = 1\n\ |
| 1608 | - Breath Pressure = 128\n\ |
| 1609 | \n\ |
| 1610 | Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 1611 | |
| 1612 | if( !type_engine_import_ugen_begin( env, "BlowHole", "StkInstrument", env->global(), |
| 1613 | BlowHole_ctor, BlowHole_dtor, |
| 1614 | BlowHole_tick, BlowHole_pmsg, doc.c_str() ) ) return FALSE; |
| 1615 | |
| 1616 | type_engine_import_add_ex(env, "stk/blowhole.ck"); |
| 1617 | type_engine_import_add_ex(env, "stk/blowhole2.ck"); |
| 1618 | |
| 1619 | // member variable |
| 1620 | // BlowHole_offset_data = type_engine_import_mvar ( env, "int", "@BlowHole_data", FALSE ); |
| 1621 | // if( BlowHole_offset_data == CK_INVALID_OFFSET ) goto error; |
| 1622 | |
| 1623 | func = make_new_mfun( "float", "startBlowing", BlowHole_ctrl_startBlowing ); //! note on |
| 1624 | func->add_arg( "float", "value" ); |
| 1625 | func->doc = "start blowing, [0.0-1.0]"; |
| 1626 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1627 | |
| 1628 | func = make_new_mfun( "float", "stopBlowing", BlowHole_ctrl_stopBlowing ); //! note on |
| 1629 | func->add_arg( "float", "value" ); |
| 1630 | func->doc = "stop blowing, [0.0-1.0]"; |
| 1631 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1632 | |
| 1633 | func = make_new_mfun( "float", "vent", BlowHole_ctrl_vent ); //! vent frequency |
| 1634 | func->add_arg( "float", "value" ); |
| 1635 | func->doc = "set vent frequency, [0.0-1.0]."; |
| 1636 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1637 | |
| 1638 | func = make_new_mfun( "float", "vent", BlowHole_cget_vent ); //! vent frequency |
| 1639 | func->doc = "get vent frequency, [0.0-1.0]."; |
| 1640 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1641 | |
| 1642 | func = make_new_mfun( "float", "tonehole", BlowHole_ctrl_tonehole ); //! tonehole size |
| 1643 | func->add_arg( "float", "value" ); |
| 1644 | func->doc = "set tonehole size, [0.0-1.0]."; |
| 1645 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1646 | |
| 1647 | func = make_new_mfun( "float", "tonehole", BlowHole_cget_tonehole ); //! tonehole size |
| 1648 | func->doc = "get tonehole size, [0.0-1.0]."; |
| 1649 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1650 | |
| 1651 | func = make_new_mfun( "float", "reed", BlowHole_ctrl_reed ); //! reed stiffness |
| 1652 | func->add_arg( "float", "value" ); |
| 1653 | func->doc = "set reed stiffness, [0.0-1.0]."; |
| 1654 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1655 | |
| 1656 | func = make_new_mfun( "float", "reed", BlowHole_cget_reed ); //! reed stiffness |
| 1657 | func->doc = "get reed stiffness, [0.0-1.0]."; |
| 1658 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1659 | |
| 1660 | func = make_new_mfun( "float", "rate", BlowHole_ctrl_rate ); //! attack rate |
| 1661 | func->add_arg( "float", "value" ); |
| 1662 | func->doc = "set rate of attack, [0.0-1.0]."; |
| 1663 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1664 | |
| 1665 | func = make_new_mfun( "float", "rate", BlowHole_cget_rate ); //! attack rate |
| 1666 | func->doc = "get rate of attack, [0.0-1.0]."; |
| 1667 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1668 | |
| 1669 | func = make_new_mfun( "float", "noiseGain", BlowHole_ctrl_noiseGain ); //! noise gain |
| 1670 | func->add_arg( "float", "value" ); |
| 1671 | func->doc = "set noise component gain, [0.0-1.0]."; |
| 1672 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1673 | |
| 1674 | func = make_new_mfun( "float", "noiseGain", BlowHole_cget_noiseGain ); //! noise gain |
| 1675 | func->doc = "get noise component gain, [0.0-1.0]."; |
| 1676 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1677 | |
| 1678 | func = make_new_mfun( "float", "pressure", BlowHole_ctrl_pressure ); //! breath pressure |
| 1679 | func->add_arg( "float", "value" ); |
| 1680 | func->doc = "set pressure, [0.0-1.0]."; |
| 1681 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1682 | |
| 1683 | func = make_new_mfun( "float", "pressure", BlowHole_cget_pressure ); //! breath pressure |
| 1684 | func->doc = "get pressure, [0.0-1.0]."; |
| 1685 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1686 | |
| 1687 | // end the class import |
| 1688 | type_engine_import_class_end( env ); |
| 1689 | |
| 1690 | |
| 1691 | //------------------------------------------------------------------------ |
| 1692 | // begin Bowed ugen |
| 1693 | //------------------------------------------------------------------------ |
| 1694 | |
| 1695 | doc = "This class implements a bowed string model, a la Smith (1986), after McIntyre, Schumacher, Woodhouse (1983).\n\ |
| 1696 | \n\ |
| 1697 | This is a digital waveguide model, making its use possibly subject to patents held by Stanford University, Yamaha, and others.\n\ |
| 1698 | \n\ |
| 1699 | Control Change Numbers:\n\ |
| 1700 | \n\ |
| 1701 | - Bow Pressure = 2\n\ |
| 1702 | - Bow Position = 4\n\ |
| 1703 | - Vibrato Frequency = 11\n\ |
| 1704 | - Vibrato Gain = 1\n\ |
| 1705 | - Volume = 128\n\ |
| 1706 | \n\ |
| 1707 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 1708 | |
| 1709 | if( !type_engine_import_ugen_begin( env, "Bowed", "StkInstrument", env->global(), |
| 1710 | Bowed_ctor, Bowed_dtor, |
| 1711 | Bowed_tick, Bowed_pmsg, doc.c_str() ) ) return FALSE; |
| 1712 | |
| 1713 | type_engine_import_add_ex(env, "stk/bowed.ck"); |
| 1714 | type_engine_import_add_ex(env, "stk/bowed2.ck"); |
| 1715 | |
| 1716 | // member variable |
| 1717 | // Bowed_offset_data = type_engine_import_mvar ( env, "int", "@Bowed_data", FALSE ); |
| 1718 | // if( Bowed_offset_data == CK_INVALID_OFFSET ) goto error; |
| 1719 | |
| 1720 | func = make_new_mfun( "float", "startBowing", Bowed_ctrl_startBowing ); //! begin bowing instrument |
| 1721 | func->add_arg( "float", "value" ); |
| 1722 | func->doc = "start bowing, [0.0-1.0]."; |
| 1723 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1724 | |
| 1725 | func = make_new_mfun( "float", "stopBowing", Bowed_ctrl_stopBowing ); //! stop bowing |
| 1726 | func->add_arg( "float", "value" ); |
| 1727 | func->doc = "stop bowing, [0.0-1.0]."; |
| 1728 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1729 | |
| 1730 | func = make_new_mfun( "float", "bowPressure", Bowed_ctrl_bowPressure ); //! bowPressure |
| 1731 | func->add_arg( "float", "value" ); |
| 1732 | func->doc = "set bow pressure, [0.0-1.0]"; |
| 1733 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1734 | |
| 1735 | func = make_new_mfun( "float", "bowPressure", Bowed_cget_bowPressure ); //! bowPressure |
| 1736 | func->doc = "get bow pressure, [0.0-1.0]"; |
| 1737 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1738 | |
| 1739 | func = make_new_mfun( "float", "bowPosition", Bowed_ctrl_bowPos ); //! bowPos |
| 1740 | func->add_arg( "float", "value" ); |
| 1741 | func->doc = "set bow position, [0.0-1.0]"; |
| 1742 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1743 | |
| 1744 | func = make_new_mfun( "float", "bowPosition", Bowed_cget_bowPos ); //! bowPos |
| 1745 | func->doc = "get bow position, [0.0-1.0]"; |
| 1746 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1747 | |
| 1748 | func = make_new_mfun( "float", "vibratoFreq", Bowed_ctrl_vibratoFreq ); //! vibratoFreq |
| 1749 | func->add_arg( "float", "value" ); |
| 1750 | func->doc = "set vibrato frequency (Hz)."; |
| 1751 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1752 | |
| 1753 | func = make_new_mfun( "float", "vibratoFreq", Bowed_cget_vibratoFreq ); //! vibratoFreq |
| 1754 | func->doc = "get vibrato frequency (Hz)."; |
| 1755 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1756 | |
| 1757 | func = make_new_mfun( "float", "vibratoGain", Bowed_ctrl_vibratoGain ); //! vibratoGain |
| 1758 | func->add_arg( "float", "value" ); |
| 1759 | func->doc = "set vibrato gain, [0.0-1.0]."; |
| 1760 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1761 | |
| 1762 | func = make_new_mfun( "float", "vibratoGain", Bowed_cget_vibratoGain ); //! vibratoGain |
| 1763 | func->doc = "get vibrato gain, [0.0-1.0]."; |
| 1764 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1765 | |
| 1766 | func = make_new_mfun( "float", "volume", Bowed_ctrl_volume ); //! volume |
| 1767 | func->add_arg( "float", "value" ); |
| 1768 | func->doc = "set volume, [0.0-1.0]."; |
| 1769 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1770 | |
| 1771 | func = make_new_mfun( "float", "volume", Bowed_cget_volume ); //! volume |
| 1772 | func->doc = "get volume, [0.0-1.0]."; |
| 1773 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1774 | |
| 1775 | // end the class import |
| 1776 | type_engine_import_class_end( env ); |
| 1777 | |
| 1778 | |
| 1779 | //------------------------------------------------------------------------ |
| 1780 | // begin Brass ugen |
| 1781 | //------------------------------------------------------------------------ |
| 1782 | |
| 1783 | doc = "This class implements a simple brass instrument waveguide model, a la Cook (TBone, HosePlayer).\n\ |
| 1784 | \n\ |
| 1785 | This is a digital waveguide model, making its use possibly subject to patents held by Stanford University, Yamaha, and others.\n\ |
| 1786 | \n\ |
| 1787 | Control Change Numbers:\n\ |
| 1788 | \n\ |
| 1789 | - Lip Tension = 2\n\ |
| 1790 | - Slide Length = 4\n\ |
| 1791 | - Vibrato Frequency = 11\n\ |
| 1792 | - Vibrato Gain = 1\n\ |
| 1793 | - Volume = 128\n\ |
| 1794 | \n\ |
| 1795 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 1796 | |
| 1797 | if( !type_engine_import_ugen_begin( env, "Brass", "StkInstrument", env->global(), |
| 1798 | Brass_ctor, Brass_dtor, |
| 1799 | Brass_tick, Brass_pmsg, doc.c_str() ) ) return FALSE; |
| 1800 | |
| 1801 | type_engine_import_add_ex(env, "stk/brass.ck"); |
| 1802 | type_engine_import_add_ex(env, "stk/brass2.ck"); |
| 1803 | |
| 1804 | // member variable |
| 1805 | // Brass_offset_data = type_engine_import_mvar ( env, "int", "@Brass_data", FALSE ); |
| 1806 | // if( Brass_offset_data == CK_INVALID_OFFSET ) goto error; |
| 1807 | |
| 1808 | func = make_new_mfun( "float", "clear", Brass_ctrl_clear ); //! clear instrument |
| 1809 | func->add_arg( "float", "value" ); |
| 1810 | func->doc = "clear instrument."; |
| 1811 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1812 | |
| 1813 | func = make_new_mfun( "float", "startBlowing", Brass_ctrl_startBlowing ); //! note on |
| 1814 | func->add_arg( "float", "value" ); |
| 1815 | func->doc = "start blowing, [0.0-1.0]."; |
| 1816 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1817 | |
| 1818 | func = make_new_mfun( "float", "stopBlowing", Brass_ctrl_stopBlowing ); //! note on |
| 1819 | func->add_arg( "float", "value" ); |
| 1820 | func->doc = "stop blowing, [0.0-1.0]."; |
| 1821 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1822 | |
| 1823 | func = make_new_mfun( "float", "lip", Brass_ctrl_lip ); //! lip stiffness |
| 1824 | func->add_arg( "float", "value" ); |
| 1825 | func->doc = "set lip tension, [0.0-1.0]."; |
| 1826 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1827 | |
| 1828 | func = make_new_mfun( "float", "lip", Brass_cget_lip ); //! lip stiffness |
| 1829 | func->doc = "get lip tension, [0.0-1.0]."; |
| 1830 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1831 | |
| 1832 | func = make_new_mfun( "float", "slide", Brass_ctrl_slide ); //! slide |
| 1833 | func->add_arg( "float", "value" ); |
| 1834 | func->doc = "set slide length, [0.0-1.0]."; |
| 1835 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1836 | |
| 1837 | func = make_new_mfun( "float", "slide", Brass_cget_slide ); //! slide |
| 1838 | func->doc = "get slide length, [0.0-1.0]."; |
| 1839 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1840 | |
| 1841 | func = make_new_mfun( "float", "vibratoFreq", Brass_ctrl_vibratoFreq ); //! vibratoFreq |
| 1842 | func->add_arg( "float", "value" ); |
| 1843 | func->doc = "set vibrato frequency (Hz)."; |
| 1844 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1845 | |
| 1846 | func = make_new_mfun( "float", "vibratoFreq", Brass_cget_vibratoFreq ); //! vibratoFreq |
| 1847 | func->doc = "get vibrato frequency (Hz)."; |
| 1848 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1849 | |
| 1850 | func = make_new_mfun( "float", "vibratoGain", Brass_ctrl_vibratoGain ); //! vibratoGain |
| 1851 | func->add_arg( "float", "value" ); |
| 1852 | func->doc = "set vibrato gain, [0.0-1.0]."; |
| 1853 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1854 | |
| 1855 | func = make_new_mfun( "float", "vibratoGain", Brass_cget_vibratoGain ); //! vibratoGain |
| 1856 | func->doc = "get vibrato gain, [0.0-1.0]."; |
| 1857 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1858 | |
| 1859 | func = make_new_mfun( "float", "volume", Brass_ctrl_volume ); //! volume |
| 1860 | func->add_arg( "float", "value" ); |
| 1861 | func->doc = "set volume, [0.0-1.0]."; |
| 1862 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1863 | |
| 1864 | func = make_new_mfun( "float", "volume", Brass_cget_volume ); //! volume |
| 1865 | func->doc = "get volume, [0.0-1.0]."; |
| 1866 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1867 | |
| 1868 | func = make_new_mfun( "float", "rate", Brass_ctrl_rate ); //! attack rate |
| 1869 | func->add_arg( "float", "value" ); |
| 1870 | func->doc = "set rate of attack (seconds)."; |
| 1871 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1872 | |
| 1873 | func = make_new_mfun( "float", "rate", Brass_cget_rate ); //! attack rate |
| 1874 | func->doc = "get rate of attack (seconds)."; |
| 1875 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1876 | |
| 1877 | // end the class import |
| 1878 | type_engine_import_class_end( env ); |
| 1879 | |
| 1880 | |
| 1881 | //------------------------------------------------------------------------ |
| 1882 | // begin Clarinet ugen |
| 1883 | //------------------------------------------------------------------------ |
| 1884 | |
| 1885 | doc = "This class implements a simple clarinet physical model, as discussed by Smith (1986), McIntyre, Schumacher, Woodhouse (1983), and others.\n\ |
| 1886 | \n\ |
| 1887 | This is a digital waveguide model, making its use possibly subject to patents held by Stanford University, Yamaha, and others.\n\ |
| 1888 | \n\ |
| 1889 | Control Change Numbers:\n\ |
| 1890 | \n\ |
| 1891 | - Reed Stiffness = 2\n\ |
| 1892 | - Noise Gain = 4\n\ |
| 1893 | - Vibrato Frequency = 11\n\ |
| 1894 | - Vibrato Gain = 1\n\ |
| 1895 | - Breath Pressure = 128\n\ |
| 1896 | \n\ |
| 1897 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 1898 | |
| 1899 | if( !type_engine_import_ugen_begin( env, "Clarinet", "StkInstrument", env->global(), |
| 1900 | Clarinet_ctor, Clarinet_dtor, |
| 1901 | Clarinet_tick, Clarinet_pmsg, doc.c_str() ) ) return FALSE; |
| 1902 | |
| 1903 | type_engine_import_add_ex( env, "stk/clarinet.ck" ); |
| 1904 | type_engine_import_add_ex( env, "stk/clarinet2.ck" ); |
| 1905 | type_engine_import_add_ex( env, "midi/polyfony2.ck" ); |
| 1906 | |
| 1907 | // member variable |
| 1908 | // Clarinet_offset_data = type_engine_import_mvar ( env, "int", "@Clarinet_data", FALSE ); |
| 1909 | // if( Clarinet_offset_data == CK_INVALID_OFFSET ) goto error; |
| 1910 | |
| 1911 | func = make_new_mfun( "float", "clear", Clarinet_ctrl_clear ); //! note on |
| 1912 | func->add_arg( "float", "value" ); |
| 1913 | func->doc = "clear instrument."; |
| 1914 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1915 | |
| 1916 | func = make_new_mfun( "float", "startBlowing", Clarinet_ctrl_startBlowing ); //! note on |
| 1917 | func->add_arg( "float", "value" ); |
| 1918 | func->doc = "start blowing, [0.0-1.0]."; |
| 1919 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1920 | |
| 1921 | func = make_new_mfun( "float", "stopBlowing", Clarinet_ctrl_stopBlowing ); //! note on |
| 1922 | func->add_arg( "float", "value" ); |
| 1923 | func->doc = "stop blowing, [0.0-1.0]."; |
| 1924 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1925 | |
| 1926 | func = make_new_mfun( "float", "rate", Clarinet_ctrl_rate ); //! attack rate |
| 1927 | func->add_arg( "float", "value" ); |
| 1928 | func->doc = "set rate of attack (seconds)."; |
| 1929 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1930 | |
| 1931 | func = make_new_mfun( "float", "rate", Clarinet_cget_rate ); //! attack rate |
| 1932 | func->doc = "get rate of attack (seconds)."; |
| 1933 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1934 | |
| 1935 | func = make_new_mfun( "float", "reed", Clarinet_ctrl_reed); //! reed |
| 1936 | func->add_arg( "float", "value" ); |
| 1937 | func->doc = "set reed stiffness, [0.0-1.0]."; |
| 1938 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1939 | |
| 1940 | func = make_new_mfun( "float", "reed", Clarinet_cget_reed); //! reed |
| 1941 | func->doc = "get reed stiffness, [0.0-1.0]."; |
| 1942 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1943 | |
| 1944 | func = make_new_mfun( "float", "noiseGain", Clarinet_ctrl_noiseGain ); //! noiseGain |
| 1945 | func->add_arg( "float", "value" ); |
| 1946 | func->doc = "set noise component gain, [0.0-1.0]."; |
| 1947 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1948 | |
| 1949 | func = make_new_mfun( "float", "noiseGain", Clarinet_cget_noiseGain ); //! noiseGain |
| 1950 | func->doc = "get noise component gain, [0.0-1.0]."; |
| 1951 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1952 | |
| 1953 | func = make_new_mfun( "float", "vibratoFreq", Clarinet_ctrl_vibratoFreq ); //! rvibratoFreq |
| 1954 | func->add_arg( "float", "value" ); |
| 1955 | func->doc = "set vibrato frequency (Hz)."; |
| 1956 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1957 | |
| 1958 | func = make_new_mfun( "float", "vibratoFreq", Clarinet_cget_vibratoFreq ); //! rvibratoFreq |
| 1959 | func->doc = "get vibrato frequency (Hz)."; |
| 1960 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1961 | |
| 1962 | func = make_new_mfun( "float", "vibratoGain", Clarinet_ctrl_vibratoGain ); //! vibratoGain |
| 1963 | func->add_arg( "float", "value" ); |
| 1964 | func->doc = "set vibrato gain, [0.0-1.0]."; |
| 1965 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1966 | |
| 1967 | func = make_new_mfun( "float", "vibratoGain", Clarinet_cget_vibratoGain ); //! vibratoGain |
| 1968 | func->doc = "get vibrato gain, [0.0-1.0]."; |
| 1969 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1970 | |
| 1971 | func = make_new_mfun( "float", "pressure", Clarinet_ctrl_pressure ); //! pressure |
| 1972 | func->add_arg( "float", "value" ); |
| 1973 | func->doc = "set pressure, [0.0-1.0]."; |
| 1974 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1975 | |
| 1976 | func = make_new_mfun( "float", "pressure", Clarinet_cget_pressure ); //! pressure |
| 1977 | func->doc = "get pressure, [0.0-1.0]."; |
| 1978 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 1979 | |
| 1980 | // end the class import |
| 1981 | type_engine_import_class_end( env ); |
| 1982 | |
| 1983 | |
| 1984 | //------------------------------------------------------------------------ |
| 1985 | // begin Flute ugen |
| 1986 | //------------------------------------------------------------------------ |
| 1987 | |
| 1988 | doc = "This class implements a simple flute physical model, as discussed by Karjalainen, Smith, Waryznyk, etc. The jet model uses a polynomial, a la Cook.\n\ |
| 1989 | \n\ |
| 1990 | This is a digital waveguide model, making its use possibly subject to patents held by Stanford University, Yamaha, and others.\n\ |
| 1991 | \n\ |
| 1992 | Control Change Numbers:\n\ |
| 1993 | \n\ |
| 1994 | - Jet Delay = 2\n\ |
| 1995 | - Noise Gain = 4\n\ |
| 1996 | - Vibrato Frequency = 11\n\ |
| 1997 | - Vibrato Gain = 1\n\ |
| 1998 | - Breath Pressure = 128\n\ |
| 1999 | \n\ |
| 2000 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 2001 | |
| 2002 | if( !type_engine_import_ugen_begin( env, "Flute", "StkInstrument", env->global(), |
| 2003 | Flute_ctor, Flute_dtor, |
| 2004 | Flute_tick, Flute_pmsg, doc.c_str() ) ) return FALSE; |
| 2005 | |
| 2006 | // add examples |
| 2007 | type_engine_import_add_ex( env, "stk/flute.ck"); |
| 2008 | |
| 2009 | // member variable |
| 2010 | // Flute_offset_data = type_engine_import_mvar ( env, "int", "@Flute_data", FALSE ); |
| 2011 | // if( Flute_offset_data == CK_INVALID_OFFSET ) goto error; |
| 2012 | |
| 2013 | func = make_new_mfun( "float", "clear", Flute_ctrl_clear ); //! clear |
| 2014 | func->add_arg( "float", "value" ); |
| 2015 | func->doc = "clear instrument."; |
| 2016 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2017 | |
| 2018 | func = make_new_mfun( "float", "startBlowing", Flute_ctrl_startBlowing ); //! startBlowing |
| 2019 | func->add_arg( "float", "value" ); |
| 2020 | func->doc = "start blowing, [0.0-1.0]."; |
| 2021 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2022 | |
| 2023 | func = make_new_mfun( "float", "stopBlowing", Flute_ctrl_stopBlowing ); //! stopBlowing |
| 2024 | func->add_arg( "float", "value" ); |
| 2025 | func->doc = "stop blowing, [0.0-1.0]."; |
| 2026 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2027 | |
| 2028 | func = make_new_mfun( "float", "rate", Flute_ctrl_rate ); //! attack rate |
| 2029 | func->add_arg( "float", "value" ); |
| 2030 | func->doc = "set rate of attack (seconds)."; |
| 2031 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2032 | |
| 2033 | func = make_new_mfun( "float", "rate", Flute_cget_rate ); //! attack rate |
| 2034 | func->doc = "get rate of attack (seconds)."; |
| 2035 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2036 | |
| 2037 | func = make_new_mfun( "float", "jetReflection", Flute_ctrl_jetReflection ); //! jet reflection |
| 2038 | func->add_arg( "float", "value" ); |
| 2039 | func-> doc = "set jet reflection."; |
| 2040 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2041 | |
| 2042 | func = make_new_mfun( "float", "jetReflection", Flute_cget_jetReflection ); //! jet reflection |
| 2043 | func-> doc = "get jet reflection."; |
| 2044 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2045 | |
| 2046 | func = make_new_mfun( "float", "jetDelay", Flute_ctrl_jetDelay ); //! jet delay |
| 2047 | func->add_arg( "float", "value" ); |
| 2048 | func->doc = "set jet delay."; |
| 2049 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2050 | |
| 2051 | func = make_new_mfun( "float", "jetDelay", Flute_cget_jetDelay ); //! jet delay |
| 2052 | func->doc = "get jet delay."; |
| 2053 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2054 | |
| 2055 | func = make_new_mfun( "float", "endReflection", Flute_ctrl_endReflection ); //! end reflection |
| 2056 | func->add_arg( "float", "value" ); |
| 2057 | func->doc = "set end reflection."; |
| 2058 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2059 | |
| 2060 | func = make_new_mfun( "float", "endReflection", Flute_cget_endReflection ); //! end reflection |
| 2061 | func->doc = "get end reflection."; |
| 2062 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2063 | |
| 2064 | func = make_new_mfun( "float", "noiseGain", Flute_ctrl_noiseGain ); //! noiseGain |
| 2065 | func->add_arg( "float", "value" ); |
| 2066 | func->doc = "set noise component gain, [0.0-1.0]."; |
| 2067 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2068 | |
| 2069 | func = make_new_mfun( "float", "noiseGain", Flute_cget_noiseGain ); //! noiseGain |
| 2070 | func->doc = "get noise component gain, [0.0-1.0]."; |
| 2071 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2072 | |
| 2073 | func = make_new_mfun( "float", "vibratoFreq", Flute_ctrl_vibratoFreq ); //! vibratoFreq |
| 2074 | func->add_arg( "float", "value" ); |
| 2075 | func->doc = "set vibrato frequency (Hz)."; |
| 2076 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2077 | |
| 2078 | func = make_new_mfun( "float", "vibratoFreq", Flute_cget_vibratoFreq ); //! vibratoFreq |
| 2079 | func->doc = "get vibrato frequency (Hz)."; |
| 2080 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2081 | |
| 2082 | func = make_new_mfun( "float", "vibratoGain", Flute_ctrl_vibratoGain ); //! vibratoGain |
| 2083 | func->add_arg( "float", "value" ); |
| 2084 | func->doc = "set vibrato gain, [0.0-1.0]."; |
| 2085 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2086 | |
| 2087 | func = make_new_mfun( "float", "vibratoGain", Flute_cget_vibratoGain ); //! vibratoGain |
| 2088 | func->doc = "get vibrato gain, [0.0-1.0]."; |
| 2089 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2090 | |
| 2091 | func = make_new_mfun( "float", "pressure", Flute_ctrl_pressure ); //! pressure |
| 2092 | func->add_arg( "float", "value" ); |
| 2093 | func->doc = "set pressure, [0.0-1.0]."; |
| 2094 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2095 | |
| 2096 | func = make_new_mfun( "float", "pressure", Flute_cget_pressure ); //! pressure |
| 2097 | func->doc = "get pressure, [0.0-1.0]."; |
| 2098 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2099 | |
| 2100 | // end the class import |
| 2101 | type_engine_import_class_end( env ); |
| 2102 | |
| 2103 | |
| 2104 | //------------------------------------------------------------------------ |
| 2105 | // begin Mandolin ugen |
| 2106 | //------------------------------------------------------------------------ |
| 2107 | |
| 2108 | doc = "This class inherits from PluckTwo and uses 'commuted synthesis' techniques to model a mandolin instrument.\n\ |
| 2109 | \n\ |
| 2110 | This is a digital waveguide model, making its use possibly subject to patents held by Stanford University, Yamaha, and others. Commuted Synthesis, in particular, is covered by patents, granted, pending, and/or applied-for. All are assigned to the Board of Trustees, Stanford University. For information, contact the Office of Technology Licensing, Stanford University.\n\ |
| 2111 | \n\ |
| 2112 | Control Change Numbers:\n\ |
| 2113 | \n\ |
| 2114 | - Body Size = 2\n\ |
| 2115 | - Pluck Position = 4\n\ |
| 2116 | - String Sustain = 11\n\ |
| 2117 | - String Detuning = 1\n\ |
| 2118 | - Microphone Position = 128\n\ |
| 2119 | \n\ |
| 2120 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 2121 | |
| 2122 | //! see \example mand-o-matic.ck |
| 2123 | if( !type_engine_import_ugen_begin( env, "Mandolin", "StkInstrument", env->global(), |
| 2124 | Mandolin_ctor, Mandolin_dtor, |
| 2125 | Mandolin_tick, Mandolin_pmsg, doc.c_str() ) ) return FALSE; |
| 2126 | |
| 2127 | type_engine_import_add_ex(env, "stk/mandolin.ck"); |
| 2128 | type_engine_import_add_ex(env, "stk/mand-o-matic.ck"); |
| 2129 | type_engine_import_add_ex(env, "stk/mand-o-matic-simple.ck"); |
| 2130 | |
| 2131 | // member variable |
| 2132 | // Mandolin_offset_data = type_engine_import_mvar ( env, "int", "@Mandolin_data", FALSE ); |
| 2133 | // if( Mandolin_offset_data == CK_INVALID_OFFSET ) goto error; |
| 2134 | |
| 2135 | func = make_new_mfun( "float", "pluck", Mandolin_ctrl_pluck ); //! pluck string with given amplitude |
| 2136 | func->add_arg( "float", "value" ); |
| 2137 | func->doc = "pluck instrument, [0.0-1.0]."; |
| 2138 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2139 | |
| 2140 | func = make_new_mfun( "float", "pluckPos", Mandolin_ctrl_pluckPos ); //! set pluck position ( 0-1) along string |
| 2141 | func->add_arg( "float", "value" ); |
| 2142 | func->doc = "set pluck position, [0.0-1.0]."; |
| 2143 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2144 | |
| 2145 | func = make_new_mfun( "float", "pluckPos", Mandolin_cget_pluckPos ); //! get pluck position ( 0-1) along string |
| 2146 | func->doc = "get pluck position, [0.0-1.0]."; |
| 2147 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2148 | |
| 2149 | func = make_new_mfun( "float", "bodySize", Mandolin_ctrl_bodySize ); //! modify instrument size |
| 2150 | func->add_arg( "float", "value" ); |
| 2151 | func->doc = "set body size (percentage)."; |
| 2152 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2153 | |
| 2154 | func = make_new_mfun( "float", "bodySize", Mandolin_cget_bodySize ); //! modify instrument size |
| 2155 | func->doc = "get body size (percentage)."; |
| 2156 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2157 | |
| 2158 | func = make_new_mfun( "float", "stringDamping", Mandolin_ctrl_stringDamping ); //! control string damping |
| 2159 | func->add_arg( "float", "value" ); |
| 2160 | func->doc = "set string damping, [0.0-1.0]."; |
| 2161 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2162 | |
| 2163 | func = make_new_mfun( "float", "stringDamping", Mandolin_cget_stringDamping ); //! control string damping |
| 2164 | func->doc = "get string damping, [0.0-1.0]."; |
| 2165 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2166 | |
| 2167 | func = make_new_mfun( "float", "stringDetune", Mandolin_ctrl_stringDetune ); //! control detuning of string pair |
| 2168 | func->add_arg( "float", "value" ); |
| 2169 | func->doc = "set detuning of string pair, [0.0-1.0]."; |
| 2170 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2171 | |
| 2172 | func = make_new_mfun( "float", "stringDetune", Mandolin_cget_stringDetune ); //! control detuning of string pair |
| 2173 | func->doc = "get detuning of string pair, [0.0-1.0]."; |
| 2174 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2175 | |
| 2176 | func = make_new_mfun( "float", "afterTouch", Mandolin_ctrl_afterTouch ); //! aftertouch |
| 2177 | func->add_arg( "float", "value" ); |
| 2178 | func->doc = "set aftertouch (currently unsupported)."; |
| 2179 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2180 | |
| 2181 | func = make_new_mfun( "string", "bodyIR", Mandolin_ctrl_bodyIR ); //! read body impulse response |
| 2182 | func->add_arg( "string", "path" ); |
| 2183 | func->doc = "set body impulse response."; |
| 2184 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2185 | |
| 2186 | func = make_new_mfun( "string", "bodyIR", Mandolin_cget_bodyIR ); //! get path |
| 2187 | func->doc = "get body impulse response."; |
| 2188 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2189 | |
| 2190 | // end the class import |
| 2191 | type_engine_import_class_end( env ); |
| 2192 | |
| 2193 | |
| 2194 | //------------------------------------------------------------------------ |
| 2195 | // begin ModalBar ugen |
| 2196 | //------------------------------------------------------------------------ |
| 2197 | |
| 2198 | doc = "This class implements a number of different struck bar instruments. It inherits from the Modal class.\n\ |
| 2199 | \n\ |
| 2200 | Control Change Numbers:\n\ |
| 2201 | \n\ |
| 2202 | - Stick Hardness = 2\n\ |
| 2203 | - Stick Position = 4\n\ |
| 2204 | - Vibrato Gain = 11\n\ |
| 2205 | - Vibrato Frequency = 7\n\ |
| 2206 | - Direct Stick Mix = 1\n\ |
| 2207 | - Volume = 128\n\ |
| 2208 | - Modal Presets = 16\n\ |
| 2209 | - Marimba = 0\n\ |
| 2210 | - Vibraphone = 1\n\ |
| 2211 | - Agogo = 2\n\ |
| 2212 | - Wood1 = 3\n\ |
| 2213 | - Reso = 4\n\ |
| 2214 | - Wood2 = 5\n\ |
| 2215 | - Beats = 6\n\ |
| 2216 | - Two Fixed = 7\n\ |
| 2217 | - Clump = 8\n\ |
| 2218 | \n\ |
| 2219 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 2220 | |
| 2221 | //! see \example modalbot.ck |
| 2222 | if( !type_engine_import_ugen_begin( env, "ModalBar", "StkInstrument", env->global(), |
| 2223 | ModalBar_ctor, ModalBar_dtor, |
| 2224 | ModalBar_tick, ModalBar_pmsg, doc.c_str() ) ) return FALSE; |
| 2225 | |
| 2226 | type_engine_import_add_ex(env, "stk/modalbar.ck"); |
| 2227 | type_engine_import_add_ex(env, "stk/modalbar2.ck"); |
| 2228 | type_engine_import_add_ex(env, "stk/mode-o-matic.ck"); |
| 2229 | type_engine_import_add_ex(env, "stk/mode-o-test.ck"); |
| 2230 | |
| 2231 | // member variable |
| 2232 | // ModalBar_offset_data = type_engine_import_mvar ( env, "int", "@ModalBar_data", FALSE ); |
| 2233 | // if( ModalBar_offset_data == CK_INVALID_OFFSET ) goto error; |
| 2234 | |
| 2235 | func = make_new_mfun( "float", "strike", ModalBar_ctrl_strike ); //! strike bar |
| 2236 | func->add_arg( "float", "value" ); |
| 2237 | func->doc = "Strike bar, [0.0-1.0]."; |
| 2238 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2239 | |
| 2240 | func = make_new_mfun( "float", "damp", ModalBar_ctrl_damp ); //! damp bar |
| 2241 | func->add_arg( "float", "value" ); |
| 2242 | func->doc = "Damp bar, [0.0-1.0]."; |
| 2243 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2244 | |
| 2245 | func = make_new_mfun( "float", "clear", ModalBar_ctrl_clear ); //! clear |
| 2246 | func->add_arg( "float", "value" ); |
| 2247 | func->doc = "clear instrument."; |
| 2248 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2249 | |
| 2250 | func = make_new_mfun( "int", "preset", ModalBar_ctrl_preset ); //! choose preset |
| 2251 | func->add_arg( "int", "value" ); |
| 2252 | func->doc = "set preset (see above)."; |
| 2253 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2254 | |
| 2255 | func = make_new_mfun( "int", "preset", ModalBar_cget_preset ); //! choose preset |
| 2256 | func->doc = "get preset."; |
| 2257 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2258 | |
| 2259 | func = make_new_mfun( "float", "stickHardness", ModalBar_ctrl_stickHardness ); //! set stickHardness |
| 2260 | func->add_arg( "float", "value" ); |
| 2261 | func->doc = "set stick hardness, [0.0-1.0]."; |
| 2262 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2263 | |
| 2264 | func = make_new_mfun( "float", "stickHardness", ModalBar_cget_stickHardness ); //! set stickHardness |
| 2265 | func->doc = "get stick hardness, [0.0-1.0]"; |
| 2266 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2267 | |
| 2268 | func = make_new_mfun( "float", "strikePosition", ModalBar_ctrl_strikePosition ); //! set strikePosition |
| 2269 | func->add_arg( "float", "value" ); |
| 2270 | func->doc = "set strike position, [0.0-1.0]."; |
| 2271 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2272 | |
| 2273 | func = make_new_mfun( "float", "strikePosition", ModalBar_cget_strikePosition ); //! set strikePosition |
| 2274 | func->doc = "get strike position, [0.0-1.0]."; |
| 2275 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2276 | |
| 2277 | func = make_new_mfun( "float", "vibratoGain", ModalBar_ctrl_vibratoGain ); //! set vibratoGain |
| 2278 | func->add_arg( "float", "value" ); |
| 2279 | func->doc = "set vibrato gain, [0.0-1.0]."; |
| 2280 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2281 | |
| 2282 | func = make_new_mfun( "float", "vibratoGain", ModalBar_cget_vibratoGain ); //! set vibratoGain |
| 2283 | func->doc = "get vibrato gain, [0.0-1.0]."; |
| 2284 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2285 | |
| 2286 | func = make_new_mfun( "float", "vibratoFreq", ModalBar_ctrl_vibratoFreq ); //! set vibratoFreq |
| 2287 | func->add_arg( "float", "value" ); |
| 2288 | func->doc = "set vibrato frequency (Hz)."; |
| 2289 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2290 | |
| 2291 | func = make_new_mfun( "float", "vibratoFreq", ModalBar_cget_vibratoFreq ); //! set vibratoFreq |
| 2292 | func->doc = "get vibrato frequency (Hz)."; |
| 2293 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2294 | |
| 2295 | func = make_new_mfun( "float", "directGain", ModalBar_ctrl_directGain ); //! set directGain |
| 2296 | func->add_arg( "float", "value" ); |
| 2297 | func->doc = "set direct gain, [0.0-1.0]."; |
| 2298 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2299 | |
| 2300 | func = make_new_mfun( "float", "directGain", ModalBar_cget_directGain ); //! set directGain |
| 2301 | func->doc = "get direct gain, [0.0-1.0]."; |
| 2302 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2303 | |
| 2304 | func = make_new_mfun( "float", "masterGain", ModalBar_ctrl_masterGain ); //! set masterGain |
| 2305 | func->add_arg( "float", "value" ); |
| 2306 | func->doc = "set master gain, [0.0-1.0]."; |
| 2307 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2308 | |
| 2309 | func = make_new_mfun( "float", "masterGain", ModalBar_cget_masterGain ); //! set masterGain |
| 2310 | func->doc = "get master gain, [0.0-1.0]."; |
| 2311 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2312 | |
| 2313 | func = make_new_mfun( "int", "mode", ModalBar_ctrl_mode ); //! choose mode |
| 2314 | func->add_arg( "int", "value" ); |
| 2315 | func->doc = "set mode."; |
| 2316 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2317 | |
| 2318 | func = make_new_mfun( "int", "mode", ModalBar_cget_mode ); //! choose mode |
| 2319 | func->doc = "get mode."; |
| 2320 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2321 | |
| 2322 | func = make_new_mfun( "float", "modeRatio", ModalBar_ctrl_modeRatio ); //! mode edit (modeRatio) |
| 2323 | func->add_arg( "float", "value" ); |
| 2324 | func->doc = "set ratio for selected mode."; |
| 2325 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2326 | |
| 2327 | func = make_new_mfun( "float", "modeRatio", ModalBar_cget_modeRatio ); //! mode edit (modeRatio) |
| 2328 | func->doc = "get ratio for selected mode."; |
| 2329 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2330 | |
| 2331 | func = make_new_mfun( "float", "modeRadius", ModalBar_ctrl_modeRadius ); //! mode edit (modeRadius) |
| 2332 | func->add_arg( "float", "value" ); |
| 2333 | func->doc = "set radius for selected mode, [0.0-1.0]."; |
| 2334 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2335 | |
| 2336 | func = make_new_mfun( "float", "modeRadius", ModalBar_cget_modeRadius ); //! mode edit (modeRadius) |
| 2337 | func->doc = "get radius for selected mode, [0.0-1.0]."; |
| 2338 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2339 | |
| 2340 | func = make_new_mfun( "float", "modeGain", ModalBar_ctrl_modeGain ); //! mode edit (modeGain) |
| 2341 | func->add_arg( "float", "value" ); |
| 2342 | func->doc = "set gain for selected mode, [0.0-1.0]."; |
| 2343 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2344 | |
| 2345 | func = make_new_mfun( "float", "modeGain", ModalBar_cget_modeGain ); //! mode edit (modeGain) |
| 2346 | func->doc = "get gain for selected mode, [0.0-1.0]."; |
| 2347 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2348 | |
| 2349 | func = make_new_mfun( "float", "volume", ModalBar_ctrl_volume ); //! volume |
| 2350 | func->add_arg( "float", "value" ); |
| 2351 | func->doc = "set volume, [0.0-1.0]."; |
| 2352 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2353 | |
| 2354 | func = make_new_mfun( "float", "volume", ModalBar_cget_volume ); //! volume |
| 2355 | func->doc = "get volume, [0.0-1.0]."; |
| 2356 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2357 | |
| 2358 | // end the class import |
| 2359 | type_engine_import_class_end( env ); |
| 2360 | |
| 2361 | |
| 2362 | //------------------------------------------------------------------------ |
| 2363 | // begin Moog ugen |
| 2364 | //------------------------------------------------------------------------ |
| 2365 | |
| 2366 | doc = "This instrument uses one attack wave, one looped wave, and an ADSR envelope (inherited from the Sampler class) and adds two sweepable formant (FormSwep) filters.\n\ |
| 2367 | \n\ |
| 2368 | Control Change Numbers:\n\ |
| 2369 | \n\ |
| 2370 | - Filter Q = 2\n\ |
| 2371 | - Filter Sweep Rate = 4\n\ |
| 2372 | - Vibrato Frequency = 11\n\ |
| 2373 | - Vibrato Gain = 1\n\ |
| 2374 | - Gain = 128\n\ |
| 2375 | \n\ |
| 2376 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 2377 | |
| 2378 | //! see \example moogie.ck |
| 2379 | if( !type_engine_import_ugen_begin( env, "Moog", "StkInstrument", env->global(), |
| 2380 | Moog_ctor, Moog_dtor, |
| 2381 | Moog_tick, Moog_pmsg, doc.c_str() ) ) return FALSE; |
| 2382 | |
| 2383 | type_engine_import_add_ex(env, "stk/moog.ck"); |
| 2384 | type_engine_import_add_ex(env, "stk/moog2.ck"); |
| 2385 | type_engine_import_add_ex(env, "stk/moogie.ck"); |
| 2386 | |
| 2387 | // member variable |
| 2388 | // Moog_offset_data = type_engine_import_mvar ( env, "int", "@Moog_data", FALSE ); |
| 2389 | // if( Moog_offset_data == CK_INVALID_OFFSET ) goto error; |
| 2390 | |
| 2391 | func = make_new_mfun( "float", "lfoSpeed", Moog_ctrl_modSpeed ); //! modulation speed |
| 2392 | func->add_arg( "float", "value" ); |
| 2393 | func->doc = "set LFO modulation speed."; |
| 2394 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2395 | |
| 2396 | func = make_new_mfun( "float", "lfoSpeed", Moog_cget_modSpeed ); //! modulation speed |
| 2397 | func->doc = "get LFO modulation speed."; |
| 2398 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2399 | |
| 2400 | func = make_new_mfun( "float", "lfoDepth", Moog_ctrl_modDepth ); //! modulation depth |
| 2401 | func->add_arg( "float", "value" ); |
| 2402 | func->doc = "set LFO modulation depth."; |
| 2403 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2404 | |
| 2405 | func = make_new_mfun( "float", "lfoDepth", Moog_cget_modDepth ); //! modulation depth |
| 2406 | func->doc = "get LFO modulation depth."; |
| 2407 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2408 | |
| 2409 | func = make_new_mfun( "float", "modSpeed", Moog_ctrl_modSpeed ); //! modulation speed |
| 2410 | func->add_arg( "float", "value" ); |
| 2411 | func->doc = "set modulation speed."; |
| 2412 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2413 | |
| 2414 | func = make_new_mfun( "float", "modSpeed", Moog_cget_modSpeed ); //! modulation speed |
| 2415 | func->doc = "get modulation speed."; |
| 2416 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2417 | |
| 2418 | func = make_new_mfun( "float", "modDepth", Moog_ctrl_modDepth ); //! modulation depth |
| 2419 | func->add_arg( "float", "value" ); |
| 2420 | func->doc = "set modulation depth."; |
| 2421 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2422 | |
| 2423 | func = make_new_mfun( "float", "modDepth", Moog_cget_modDepth ); //! modulation depth |
| 2424 | func->doc = "get modulation depth."; |
| 2425 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2426 | |
| 2427 | func = make_new_mfun( "float", "filterQ", Moog_ctrl_filterQ ); //! filter Q value |
| 2428 | func->add_arg( "float", "value" ); |
| 2429 | func->doc = "set filter Q value, [0.0-1.0]."; |
| 2430 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2431 | |
| 2432 | func = make_new_mfun( "float", "filterQ", Moog_cget_filterQ ); //! filter Q value |
| 2433 | func->doc = "get filter Q value, [0.0-1.0]."; |
| 2434 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2435 | |
| 2436 | func = make_new_mfun( "float", "filterSweepRate", Moog_ctrl_filterSweepRate ); //! filter sweep rate |
| 2437 | func->add_arg( "float", "value" ); |
| 2438 | func->doc = "set filter sweep rate, [0.0-1.0]."; |
| 2439 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2440 | |
| 2441 | func = make_new_mfun( "float", "filterSweepRate", Moog_cget_filterSweepRate ); //! filter sweep rate |
| 2442 | func->doc = "get filter sweep rate, [0.0-1.0]."; |
| 2443 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2444 | |
| 2445 | func = make_new_mfun( "float", "filterStartFreq", Moog_ctrl_filterStartFreq ); //! filter starting frequency |
| 2446 | func->add_arg( "float", "freq" ); |
| 2447 | func->doc = "set filter starting frequency."; |
| 2448 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2449 | |
| 2450 | func = make_new_mfun( "float", "filterStartFreq", Moog_cget_filterStartFreq ); //! filter starting frequency |
| 2451 | func->doc = "get filter starting frequency."; |
| 2452 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2453 | |
| 2454 | func = make_new_mfun( "float", "afterTouch", Moog_ctrl_afterTouch ); // aftertouch |
| 2455 | func->add_arg( "float", "value" ); |
| 2456 | func->doc = "set aftertouch, [0.0-1.0]."; |
| 2457 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2458 | |
| 2459 | func = make_new_mfun( "float", "volume", Moog_ctrl_volume ); //! volume |
| 2460 | func->add_arg( "float", "value" ); |
| 2461 | func->doc = "set volume."; |
| 2462 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2463 | |
| 2464 | func = make_new_mfun( "float", "volume", Moog_cget_volume ); //! volume |
| 2465 | func->doc = "get volume."; |
| 2466 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2467 | |
| 2468 | func = make_new_mfun( "float", "vibratoFreq", Moog_ctrl_vibratoFreq ); //! vibrato frequency |
| 2469 | func->add_arg( "float", "value" ); |
| 2470 | func->doc = "set vibrato frequency (Hz)."; |
| 2471 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2472 | |
| 2473 | func = make_new_mfun( "float", "vibratoFreq", Moog_cget_vibratoFreq ); //! vibrato frequency |
| 2474 | func->doc = "get vibrato frequency (Hz)."; |
| 2475 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2476 | |
| 2477 | func = make_new_mfun( "float", "vibratoGain", Moog_ctrl_vibratoGain ); //! vibrato gain |
| 2478 | func->add_arg( "float", "value" ); |
| 2479 | func->doc = "set vibrato gain, [0.0-1.0]."; |
| 2480 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2481 | |
| 2482 | func = make_new_mfun( "float", "vibratoGain", Moog_cget_vibratoGain ); //! vibrato gain |
| 2483 | func->doc = "get vibrato gain, [0.0-1.0]."; |
| 2484 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2485 | |
| 2486 | // end the class import |
| 2487 | type_engine_import_class_end( env ); |
| 2488 | |
| 2489 | |
| 2490 | //------------------------------------------------------------------------ |
| 2491 | // begin Saxofony ugen |
| 2492 | //------------------------------------------------------------------------ |
| 2493 | |
| 2494 | doc = "This class implements a 'hybrid' digital waveguide instrument that can generate a variety of wind-like sounds. It has also been referred to as the 'blowed string' model. The waveguide section is essentially that of a string, with one rigid and one lossy termination. The non-linear function is a reed table. The string can be 'blown' at any point between the terminations, though just as with strings, it is impossible to excite the system at either end. If the excitation is placed at the string mid-point, the sound is that of a clarinet. At points closer to the 'bridge', the sound is closer to that of a saxophone. See Scavone (2002) for more details.\n\ |
| 2495 | \n\ |
| 2496 | This is a digital waveguide model, making its use possibly subject to patents held by Stanford University, Yamaha, and others.\n\ |
| 2497 | \n\ |
| 2498 | Control Change Numbers:\n\ |
| 2499 | \n\ |
| 2500 | - Reed Stiffness = 2\n\ |
| 2501 | - Reed Aperture = 26\n\ |
| 2502 | - Noise Gain = 4\n\ |
| 2503 | - Blow Position = 11\n\ |
| 2504 | - Vibrato Frequency = 29\n\ |
| 2505 | - Vibrato Gain = 1\n\ |
| 2506 | - Breath Pressure = 128\n\ |
| 2507 | \n\ |
| 2508 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 2509 | |
| 2510 | if( !type_engine_import_ugen_begin( env, "Saxofony", "StkInstrument", env->global(), |
| 2511 | Saxofony_ctor, Saxofony_dtor, |
| 2512 | Saxofony_tick, Saxofony_pmsg, doc.c_str() ) ) return FALSE; |
| 2513 | |
| 2514 | type_engine_import_add_ex(env, "stk/saxofony.ck"); |
| 2515 | |
| 2516 | // member variable |
| 2517 | // Saxofony_offset_data = type_engine_import_mvar ( env, "int", "@Saxofony_data", FALSE ); |
| 2518 | // if( Saxofony_offset_data == CK_INVALID_OFFSET ) goto error; |
| 2519 | |
| 2520 | func = make_new_mfun( "float", "clear", Saxofony_ctrl_clear ); //! clear instrument |
| 2521 | func->add_arg( "float", "value" ); |
| 2522 | func->doc = "clear instrument."; |
| 2523 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2524 | |
| 2525 | func = make_new_mfun( "float", "startBlowing", Saxofony_ctrl_startBlowing ); //! note on |
| 2526 | func->add_arg( "float", "value" ); |
| 2527 | func->doc = "start blowing, [0.0-1.0]."; |
| 2528 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2529 | |
| 2530 | func = make_new_mfun( "float", "stopBlowing", Saxofony_ctrl_stopBlowing ); //! note on |
| 2531 | func->add_arg( "float", "value" ); |
| 2532 | func->doc = "stop blowing, [0.0-1.0]."; |
| 2533 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2534 | |
| 2535 | func = make_new_mfun( "float", "rate", Saxofony_ctrl_rate ); //! rate |
| 2536 | func->add_arg( "float", "value" ); |
| 2537 | func->doc = "set rate of attack (seconds)."; |
| 2538 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2539 | |
| 2540 | func = make_new_mfun( "float", "rate", Saxofony_cget_rate ); //! rate |
| 2541 | func->doc = "get rate of attack (seconds)."; |
| 2542 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2543 | |
| 2544 | func = make_new_mfun( "float", "stiffness", Saxofony_ctrl_reed ); //! stiffness |
| 2545 | func->add_arg( "float", "value" ); |
| 2546 | func->doc = "set reed stiffness, [0.0-1.0]."; |
| 2547 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2548 | |
| 2549 | func = make_new_mfun( "float", "stiffness", Saxofony_cget_reed ); //! stiffness |
| 2550 | func->doc = "get reed stiffness, [0.0-1.0]."; |
| 2551 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2552 | |
| 2553 | func = make_new_mfun( "float", "aperture", Saxofony_ctrl_aperture ); //! aperture |
| 2554 | func->add_arg( "float", "value" ); |
| 2555 | func->doc = "set reed aperture, [0.0-1.0]."; |
| 2556 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2557 | |
| 2558 | func = make_new_mfun( "float", "aperture", Saxofony_cget_aperture ); //! aperture |
| 2559 | func->doc = "get reed aperture, [0.0-1.0]."; |
| 2560 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2561 | |
| 2562 | func = make_new_mfun( "float", "noiseGain", Saxofony_ctrl_noiseGain ); //! noiseGain |
| 2563 | func->add_arg( "float", "value" ); |
| 2564 | func->doc = "set noise component gain, [0.0-1.0]."; |
| 2565 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2566 | |
| 2567 | func = make_new_mfun( "float", "noiseGain", Saxofony_cget_noiseGain ); //! noiseGain |
| 2568 | func->doc = "get noise component gain, [0.0-1.0]."; |
| 2569 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2570 | |
| 2571 | func = make_new_mfun( "float", "vibratoGain", Saxofony_ctrl_vibratoGain ); //! vibratoGain |
| 2572 | func->add_arg( "float", "value" ); |
| 2573 | func->doc = "set vibrato gain, [0.0-1.0]."; |
| 2574 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2575 | |
| 2576 | func = make_new_mfun( "float", "vibratoGain", Saxofony_cget_vibratoGain ); //! vibratoGain |
| 2577 | func->doc = "get vibrato gain, [0.0-1.0]."; |
| 2578 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2579 | |
| 2580 | func = make_new_mfun( "float", "vibratoFreq", Saxofony_ctrl_vibratoFreq ); //! vibratoFreq |
| 2581 | func->add_arg( "float", "value" ); |
| 2582 | func->doc = "set vibrato frequency (Hz)."; |
| 2583 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2584 | |
| 2585 | func = make_new_mfun( "float", "vibratoFreq", Saxofony_cget_vibratoFreq ); //! vibratoFreq |
| 2586 | func->doc = "get vibrato frequency (Hz)."; |
| 2587 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2588 | |
| 2589 | func = make_new_mfun( "float", "blowPosition", Saxofony_ctrl_blowPosition ); //! blowPosition |
| 2590 | func->add_arg( "float", "value" ); |
| 2591 | func->doc = "set lip stiffness, [0.0-1.0]."; |
| 2592 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2593 | |
| 2594 | func = make_new_mfun( "float", "blowPosition", Saxofony_cget_blowPosition ); //! blowPosition |
| 2595 | func->doc = "get lip stiffness, [0.0-1.0]."; |
| 2596 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2597 | |
| 2598 | func = make_new_mfun( "float", "pressure", Saxofony_ctrl_pressure ); //! pressure |
| 2599 | func->add_arg( "float", "value" ); |
| 2600 | func->doc = "set pressure, [0.0-1.0]"; |
| 2601 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2602 | |
| 2603 | func = make_new_mfun( "float", "pressure", Saxofony_cget_pressure ); //! pressure |
| 2604 | func->doc = "get pressure, [0.0-1.0]"; |
| 2605 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2606 | |
| 2607 | // end the class import |
| 2608 | type_engine_import_class_end( env ); |
| 2609 | |
| 2610 | |
| 2611 | //------------------------------------------------------------------------ |
| 2612 | // begin Shakers ugen |
| 2613 | //------------------------------------------------------------------------ |
| 2614 | |
| 2615 | doc = "PhISEM (Physically Informed Stochastic Event Modeling) is an algorithmic approach for simulating collisions of multiple independent sound producing objects. This class is a meta-model that can simulate a Maraca, Sekere, Cabasa, Bamboo Wind Chimes, Water Drops, Tambourine, Sleighbells, and a Guiro.\n\ |
| 2616 | \n\ |
| 2617 | PhOLIES (Physically-Oriented Library of Imitated Environmental Sounds) is a similar approach for the synthesis of environmental sounds. This class implements simulations of breaking sticks, crunchy snow (or not), a wrench, sandpaper, and more.\n\ |
| 2618 | \n\ |
| 2619 | Control Change Numbers:\n\ |
| 2620 | \n\ |
| 2621 | - Shake Energy = 2\n\ |
| 2622 | - System Decay = 4\n\ |
| 2623 | - Number Of Objects = 11\n\ |
| 2624 | - Resonance Frequency = 1\n\ |
| 2625 | - Shake Energy = 128\n\ |
| 2626 | - Instrument Selection = 1071\n\ |
| 2627 | - Maraca = 0\n\ |
| 2628 | - Cabasa = 1\n\ |
| 2629 | - Sekere = 2\n\ |
| 2630 | - Guiro = 3\n\ |
| 2631 | - Water Drops = 4\n\ |
| 2632 | - Bamboo Chimes = 5\n\ |
| 2633 | - Tambourine = 6\n\ |
| 2634 | - Sleigh Bells = 7\n\ |
| 2635 | - Sticks = 8\n\ |
| 2636 | - Crunch = 9\n\ |
| 2637 | - Wrench = 10\n\ |
| 2638 | - Sand Paper = 11\n\ |
| 2639 | - Coke Can = 12\n\ |
| 2640 | - Next Mug = 13\n\ |
| 2641 | - Penny + Mug = 14\n\ |
| 2642 | - Nickle + Mug = 15\n\ |
| 2643 | - Dime + Mug = 16\n\ |
| 2644 | - Quarter + Mug = 17\n\ |
| 2645 | - Franc + Mug = 18\n\ |
| 2646 | - Peso + Mug = 19\n\ |
| 2647 | - Big Rocks = 20\n\ |
| 2648 | - Little Rocks = 21\n\ |
| 2649 | - Tuned Bamboo Chimes = 22\n\ |
| 2650 | \n\ |
| 2651 | by Perry R. Cook, 1996 - 1999."; |
| 2652 | |
| 2653 | //! see \example shake-o-matic.ck |
| 2654 | if( !type_engine_import_ugen_begin( env, "Shakers", "StkInstrument", env->global(), |
| 2655 | Shakers_ctor, Shakers_dtor, |
| 2656 | Shakers_tick, Shakers_pmsg, doc.c_str() ) ) return FALSE; |
| 2657 | |
| 2658 | type_engine_import_add_ex(env, "stk/shake-cycle.ck"); |
| 2659 | type_engine_import_add_ex(env, "stk/shake-o-matic.ck"); |
| 2660 | |
| 2661 | // member variable |
| 2662 | // Shakers_offset_data = type_engine_import_mvar ( env, "int", "@Shakers_data", FALSE ); |
| 2663 | // if( Shakers_offset_data == CK_INVALID_OFFSET ) goto error; |
| 2664 | |
| 2665 | func = make_new_mfun( "int", "which", Shakers_ctrl_which ); //! select instrument |
| 2666 | func->add_arg( "int", "value" ); |
| 2667 | func->doc = "set instrument, [0-22] (see above)."; |
| 2668 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2669 | |
| 2670 | func = make_new_mfun( "int", "which", Shakers_cget_which ); //! select instrument |
| 2671 | func->doc = "get instrument, [0-22] (see above)."; |
| 2672 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2673 | |
| 2674 | func = make_new_mfun( "int", "preset", Shakers_ctrl_which ); //! select instrument |
| 2675 | func->add_arg( "int", "value" ); |
| 2676 | func->doc = "set instrument, [0-22] (see above)."; |
| 2677 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2678 | |
| 2679 | func = make_new_mfun( "int", "preset", Shakers_cget_which ); //! select instrument |
| 2680 | func->doc = "get instrument, [0-22] (see above)."; |
| 2681 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2682 | |
| 2683 | func = make_new_mfun( "float", "energy", Shakers_ctrl_energy ); //! energy |
| 2684 | func->add_arg( "float", "value" ); |
| 2685 | func->doc = "set shake energy, [0.0-1.0]."; |
| 2686 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2687 | |
| 2688 | func = make_new_mfun( "float", "energy", Shakers_cget_energy ); //! energy |
| 2689 | func->doc = "get shake energy, [0.0-1.0]."; |
| 2690 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2691 | |
| 2692 | func = make_new_mfun( "float", "decay", Shakers_ctrl_decay ); //! decay |
| 2693 | func->add_arg( "float", "value" ); |
| 2694 | func->doc = "set system decay, [0.0-1.0]."; |
| 2695 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2696 | |
| 2697 | func = make_new_mfun( "float", "decay", Shakers_cget_decay ); //! decay |
| 2698 | func->doc = "get system decay, [0.0-1.0]."; |
| 2699 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2700 | |
| 2701 | func = make_new_mfun( "float", "objects", Shakers_ctrl_objects ); //! objects |
| 2702 | func->add_arg( "float", "value" ); |
| 2703 | func->doc = "set number of objects, [0.0-128.0]."; |
| 2704 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2705 | |
| 2706 | func = make_new_mfun( "float", "objects", Shakers_cget_objects ); //! objects |
| 2707 | func->doc = "get number of objects, [0.0-128.0]."; |
| 2708 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2709 | |
| 2710 | func = make_new_mfun( "float", "freq", Shakers_ctrl_freq ); //! frequency |
| 2711 | func->add_arg( "float", "value" ); |
| 2712 | func->doc = "set frequency (Hz)."; |
| 2713 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2714 | |
| 2715 | func = make_new_mfun( "float", "freq", Shakers_cget_freq ); //! frequency |
| 2716 | func->doc = "get frequency (Hz)."; |
| 2717 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2718 | |
| 2719 | func = make_new_mfun( "float", "noteOn", Shakers_ctrl_noteOn ); //! note on |
| 2720 | func->add_arg( "float", "value" ); |
| 2721 | func->doc = "trigger note on."; |
| 2722 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2723 | |
| 2724 | func = make_new_mfun( "float", "noteOff", Shakers_ctrl_noteOff ); //! note off |
| 2725 | func->add_arg( "float", "value" ); |
| 2726 | func->doc = "trigger note off."; |
| 2727 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2728 | |
| 2729 | // end the class import |
| 2730 | type_engine_import_class_end( env ); |
| 2731 | |
| 2732 | |
| 2733 | //------------------------------------------------------------------------ |
| 2734 | // begin Sitar ugen |
| 2735 | //------------------------------------------------------------------------ |
| 2736 | |
| 2737 | doc = "This class implements a sitar plucked string physical model based on the Karplus-Strong algorithm.\n\ |
| 2738 | \n\ |
| 2739 | This is a digital waveguide model, making its use possibly subject to patents held by Stanford University, Yamaha, and others. There exist at least two patents, assigned to Stanford, bearing the names of Karplus and/or Strong.\n\ |
| 2740 | \n\ |
| 2741 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 2742 | |
| 2743 | if( !type_engine_import_ugen_begin( env, "Sitar", "StkInstrument", env->global(), |
| 2744 | Sitar_ctor, Sitar_dtor, |
| 2745 | Sitar_tick, Sitar_pmsg, doc.c_str() ) ) return FALSE; |
| 2746 | |
| 2747 | type_engine_import_add_ex(env, "stk/sitar.ck"); |
| 2748 | |
| 2749 | // member variable |
| 2750 | // Sitar_offset_data = type_engine_import_mvar ( env, "int", "@Sitar_data", FALSE ); |
| 2751 | // if( Sitar_offset_data == CK_INVALID_OFFSET ) goto error; |
| 2752 | |
| 2753 | func = make_new_mfun( "float", "pluck", Sitar_ctrl_pluck ); //! pluck |
| 2754 | func->add_arg( "float", "value" ); |
| 2755 | func->doc = "pluck string."; |
| 2756 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2757 | |
| 2758 | func = make_new_mfun( "float", "clear", Sitar_ctrl_clear ); |
| 2759 | func->add_arg( "float", "value" ); |
| 2760 | func->doc = "clear instrument."; |
| 2761 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2762 | |
| 2763 | // end the class import |
| 2764 | type_engine_import_class_end( env ); |
| 2765 | |
| 2766 | |
| 2767 | //------------------------------------------------------------------------ |
| 2768 | // begin StifKarp ugen |
| 2769 | //------------------------------------------------------------------------ |
| 2770 | |
| 2771 | doc = "This class implements a simple plucked string algorithm (Karplus Strong) with enhancements (Jaffe-Smith, Smith, and others), including string stiffness and pluck position controls. The stiffness is modeled with allpass filters.\n\ |
| 2772 | \n\ |
| 2773 | This is a digital waveguide model, making its use possibly subject to patents held by Stanford University, Yamaha, and others.\n\ |
| 2774 | \n\ |
| 2775 | Control Change Numbers:\n\ |
| 2776 | \n\ |
| 2777 | - Pickup Position = 4\n\ |
| 2778 | - String Sustain = 11\n\ |
| 2779 | - String Stretch = 1\n\ |
| 2780 | \n\ |
| 2781 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 2782 | |
| 2783 | //! see \example stifkarp.ck |
| 2784 | if( !type_engine_import_ugen_begin( env, "StifKarp", "StkInstrument", env->global(), |
| 2785 | StifKarp_ctor, StifKarp_dtor, |
| 2786 | StifKarp_tick, StifKarp_pmsg, doc.c_str() ) ) return FALSE; |
| 2787 | |
| 2788 | type_engine_import_add_ex(env, "stk/stifkarp.ck"); |
| 2789 | type_engine_import_add_ex(env, "stk/stif-o-karp.ck"); |
| 2790 | |
| 2791 | // member variable |
| 2792 | // StifKarp_offset_data = type_engine_import_mvar ( env, "int", "@StifKarp_data", FALSE ); |
| 2793 | // if( StifKarp_offset_data == CK_INVALID_OFFSET ) goto error; |
| 2794 | |
| 2795 | func = make_new_mfun( "float", "pluck", StifKarp_ctrl_pluck ); //! pluck |
| 2796 | func->add_arg( "float", "value" ); |
| 2797 | func->doc = "pluck string."; |
| 2798 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2799 | |
| 2800 | func = make_new_mfun( "float", "clear", StifKarp_ctrl_clear ); |
| 2801 | func->add_arg( "float", "value" ); |
| 2802 | func->doc = "clear instrument."; |
| 2803 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2804 | |
| 2805 | func = make_new_mfun( "float", "pickupPosition", StifKarp_ctrl_pickupPosition ); |
| 2806 | func->add_arg( "float", "value" ); |
| 2807 | func->doc = "set pickup position, [0.0-1.0]."; |
| 2808 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2809 | |
| 2810 | func = make_new_mfun( "float", "pickupPosition", StifKarp_cget_pickupPosition ); |
| 2811 | func->doc = "get pickup position, [0.0-1.0]."; |
| 2812 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2813 | |
| 2814 | func = make_new_mfun( "float", "stretch", StifKarp_ctrl_stretch ); |
| 2815 | func->add_arg( "float", "value" ); |
| 2816 | func->doc = "set string stretch, [0.0-1.0]."; |
| 2817 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2818 | |
| 2819 | func = make_new_mfun( "float", "stretch", StifKarp_cget_stretch ); |
| 2820 | func->doc = "get string stretch, [0.0-1.0]."; |
| 2821 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2822 | |
| 2823 | func = make_new_mfun( "float", "sustain", StifKarp_ctrl_sustain ); |
| 2824 | func->add_arg( "float", "value" ); |
| 2825 | func->doc = "set string sustain, [0.0-1.0]."; |
| 2826 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2827 | |
| 2828 | func = make_new_mfun( "float", "sustain", StifKarp_cget_sustain ); |
| 2829 | func->doc = "get string sustain, [0.0-1.0]."; |
| 2830 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2831 | |
| 2832 | func = make_new_mfun( "float", "baseLoopGain", StifKarp_ctrl_baseLoopGain ); |
| 2833 | func->add_arg( "float", "value" ); |
| 2834 | func->doc = "set base loop gain, [0.0-1.0]."; |
| 2835 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2836 | |
| 2837 | func = make_new_mfun( "float", "baseLoopGain", StifKarp_cget_baseLoopGain ); |
| 2838 | func->doc = "get base loop gain, [0.0-1.0]."; |
| 2839 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2840 | |
| 2841 | // end the class import |
| 2842 | type_engine_import_class_end( env ); |
| 2843 | |
| 2844 | |
| 2845 | //------------------------------------------------------------------------ |
| 2846 | // begin VoicForm ugen |
| 2847 | //------------------------------------------------------------------------ |
| 2848 | |
| 2849 | doc = "This instrument contains an excitation singing wavetable (looping wave with random and periodic vibrato, smoothing on frequency, etc.), excitation noise, and four sweepable complex resonances.\n\ |
| 2850 | \n\ |
| 2851 | Measured formant data is included, and enough data is there to support either parallel or cascade synthesis. In the floating point case cascade synthesis is the most natural so that's what you'll find here.\n\ |
| 2852 | \n\ |
| 2853 | Control Change Numbers:\n\ |
| 2854 | Voiced/Unvoiced Mix = 2\n\ |
| 2855 | Vowel/Phoneme Selection = 4\n\ |
| 2856 | Vibrato Frequency = 11\n\ |
| 2857 | Vibrato Gain = 1\n\ |
| 2858 | Loudness (Spectral Tilt) = 128\n\ |
| 2859 | \n\ |
| 2860 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002.\n\ |
| 2861 | \n\ |
| 2862 | Phoneme Names:\n\ |
| 2863 | \n\ |
| 2864 | 'eee' 'ihh' 'ehh' 'aaa'\n\ |
| 2865 | 'ahh' 'aww' 'ohh' 'uhh'\n\ |
| 2866 | 'uuu' 'ooo' 'rrr' 'lll'\n\ |
| 2867 | 'mmm' 'nnn' 'nng' 'ngg'\n\ |
| 2868 | 'fff' 'sss' 'thh' 'shh'\n\ |
| 2869 | 'xxx' 'hee' 'hoo' 'hah'\n\ |
| 2870 | 'bbb' 'ddd' 'jjj' 'ggg'\n\ |
| 2871 | 'vvv' 'zzz' 'thz' 'zhh'"; |
| 2872 | |
| 2873 | //! see \example voic-o-form.ck |
| 2874 | if( !type_engine_import_ugen_begin( env, "VoicForm", "StkInstrument", env->global(), |
| 2875 | VoicForm_ctor, VoicForm_dtor, |
| 2876 | VoicForm_tick, VoicForm_pmsg, doc.c_str() ) ) return FALSE; |
| 2877 | |
| 2878 | type_engine_import_add_ex(env, "stk/voic-o-form.ck"); |
| 2879 | |
| 2880 | // member variable |
| 2881 | // VoicForm_offset_data = type_engine_import_mvar ( env, "int", "@VoicForm_data", FALSE ); |
| 2882 | // if( VoicForm_offset_data == CK_INVALID_OFFSET ) goto error; |
| 2883 | |
| 2884 | func = make_new_mfun( "string", "phoneme", VoicForm_ctrl_phoneme ); //! select phoneme ( above ) |
| 2885 | func->add_arg( "string", "value" ); |
| 2886 | func->doc = "set phoneme (see above)."; |
| 2887 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2888 | |
| 2889 | func = make_new_mfun( "string", "phoneme", VoicForm_cget_phoneme ); //! select phoneme ( above ) |
| 2890 | func->doc = "get phoneme (see above)."; |
| 2891 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2892 | |
| 2893 | func = make_new_mfun( "float", "speak", VoicForm_ctrl_speak ); //! start singing |
| 2894 | func->add_arg( "float", "value" ); |
| 2895 | func->doc = "start singing, [0.0-1.0]."; |
| 2896 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2897 | |
| 2898 | func = make_new_mfun( "float", "quiet", VoicForm_ctrl_quiet ); //! stop singing |
| 2899 | func->add_arg( "float", "value" ); |
| 2900 | func->doc = "stop singing, [0.0-1.0]."; |
| 2901 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2902 | |
| 2903 | func = make_new_mfun( "float", "voiced", VoicForm_ctrl_voiced ); //! set mix for voiced component |
| 2904 | func->add_arg( "float", "value" ); |
| 2905 | func->doc = "set mix for voiced component, [0.0 - 1.0]."; |
| 2906 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2907 | |
| 2908 | func = make_new_mfun( "float", "voiced", VoicForm_cget_voiced ); //! set mix for voiced component |
| 2909 | func->doc = "get mix for voiced component, [0.0 - 1.0]."; |
| 2910 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2911 | |
| 2912 | func = make_new_mfun( "float", "unVoiced", VoicForm_ctrl_unVoiced ); //! set mix for unvoiced component |
| 2913 | func->add_arg( "float", "value" ); |
| 2914 | func->doc = "set mix for unvoiced component, [0.0 - 1.0]."; |
| 2915 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2916 | |
| 2917 | func = make_new_mfun( "float", "unVoiced", VoicForm_cget_unVoiced ); //! set mix for unvoiced component |
| 2918 | func->doc = "get mix for unvoiced component, [0.0 - 1.0]."; |
| 2919 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2920 | |
| 2921 | func = make_new_mfun( "float", "pitchSweepRate", VoicForm_ctrl_pitchSweepRate ); //! pitch sweep |
| 2922 | func->add_arg( "float", "value" ); |
| 2923 | func->doc = "set rate of pitch sweep, [0.0-1.0]."; |
| 2924 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2925 | |
| 2926 | func = make_new_mfun( "float", "pitchSweepRate", VoicForm_cget_pitchSweepRate ); //! pitch sweep |
| 2927 | func->doc = "get rate of pitch sweep, [0.0-1.0]."; |
| 2928 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2929 | |
| 2930 | func = make_new_mfun( "float", "voiceMix", VoicForm_ctrl_voiceMix ); //! voiced/unvoiced mix |
| 2931 | func->add_arg( "float", "value" ); |
| 2932 | func->doc = "set voiced/unvoiced mix, [0.0-1.0]."; |
| 2933 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2934 | |
| 2935 | func = make_new_mfun( "float", "voiceMix", VoicForm_cget_voiceMix ); //! voiced/unvoiced mix |
| 2936 | func->doc = "get voiced/unvoiced mix, [0.0-1.0]."; |
| 2937 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2938 | |
| 2939 | func = make_new_mfun( "int", "phonemeNum", VoicForm_ctrl_selPhoneme ); //! select phoneme by number |
| 2940 | func->add_arg( "int", "value" ); |
| 2941 | func->doc = "set phoneme by number, [0.0-128.0]."; |
| 2942 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2943 | |
| 2944 | func = make_new_mfun( "int", "phonemeNum", VoicForm_cget_selPhoneme ); //! select phoneme by number |
| 2945 | func->doc = "get phoneme by number, [0.0-128.0]."; |
| 2946 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2947 | |
| 2948 | func = make_new_mfun( "float", "vibratoFreq", VoicForm_ctrl_vibratoFreq );//! vibrato |
| 2949 | func->add_arg( "float", "value" ); |
| 2950 | func->doc = "set vibrato frequency (Hz)."; |
| 2951 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2952 | |
| 2953 | func = make_new_mfun( "float", "vibratoFreq", VoicForm_cget_vibratoFreq );//! vibrato |
| 2954 | func->doc = "get vibrato frequency (Hz)."; |
| 2955 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2956 | |
| 2957 | func = make_new_mfun( "float", "vibratoGain", VoicForm_ctrl_vibratoGain );//! vibrato depth |
| 2958 | func->doc = "set vibrato gain (Hz), [0.0-1.0]."; |
| 2959 | func->add_arg( "float", "value" ); |
| 2960 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2961 | |
| 2962 | func = make_new_mfun( "float", "vibratoGain", VoicForm_cget_vibratoGain );//! vibrato depth |
| 2963 | func->doc = "get vibrato gain (Hz), [0.0-1.0]."; |
| 2964 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2965 | |
| 2966 | func = make_new_mfun( "float", "loudness", VoicForm_ctrl_loudness ); //! 'loudness' of voicee |
| 2967 | func->add_arg( "float", "value" ); |
| 2968 | func->doc = "set 'loudness' of voice, [0.0-1.0]."; |
| 2969 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2970 | |
| 2971 | func = make_new_mfun( "float", "loudness", VoicForm_cget_loudness ); //! 'loudness' of voicee |
| 2972 | func->doc = "get 'loudness' of voice, [0.0-1.0]."; |
| 2973 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 2974 | |
| 2975 | // end the class import |
| 2976 | type_engine_import_class_end( env ); |
| 2977 | |
| 2978 | |
| 2979 | //! \section2 stk - fm synths |
| 2980 | |
| 2981 | //------------------------------------------------------------------------ |
| 2982 | // begin FM ugen |
| 2983 | //------------------------------------------------------------------------ |
| 2984 | |
| 2985 | doc = "STK FM synthesis super class. You should NOT need to use this UGen directly. Please refer to the documentation on FM subclasses instead.\n\ |
| 2986 | \n\ |
| 2987 | This class controls an arbitrary number of waves and envelopes, determined via a constructor argument.\n\ |
| 2988 | \n\ |
| 2989 | Control Change Numbers:\n\ |
| 2990 | \n\ |
| 2991 | - Control One = 2\n\ |
| 2992 | - Control Two = 4\n\ |
| 2993 | - LFO Speed = 11\n\ |
| 2994 | - LFO Depth = 1\n\ |
| 2995 | - ADSR 2 & 4 Target = 128\n\ |
| 2996 | \n\ |
| 2997 | The basic Chowning/Stanford FM patent expired in 1995, but there exist follow-on patents, mostly assigned to Yamaha. If you are of the type who should worry about this (making money) worry away.\n\ |
| 2998 | \n\ |
| 2999 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3000 | |
| 3001 | if( !type_engine_import_ugen_begin( env, "FM", "StkInstrument", env->global(), |
| 3002 | FM_ctor, FM_dtor, |
| 3003 | FM_tick, FM_pmsg, doc.c_str() ) ) return FALSE; |
| 3004 | |
| 3005 | // member variable |
| 3006 | // all subclasses of FM must use this offset, as this is where the inherited |
| 3007 | // functions will look for the object |
| 3008 | // the other option would be to keep SubClass_offset_data, but assign |
| 3009 | // the value to FM_offset_data. |
| 3010 | // FM_offset_data = type_engine_import_mvar ( env, "int", "@FM_data", FALSE ); |
| 3011 | // if( FM_offset_data == CK_INVALID_OFFSET ) goto error; |
| 3012 | FM_offset_data = Instrmnt_offset_data; |
| 3013 | |
| 3014 | func = make_new_mfun( "float", "lfoDepth", FM_ctrl_modDepth ); //!modulation Depth |
| 3015 | func->add_arg( "float", "value" ); |
| 3016 | func->doc = "set modulation depth, [0.0-1.0]."; |
| 3017 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3018 | |
| 3019 | func = make_new_mfun( "float", "lfoDepth", FM_cget_modDepth ); //!modulation Depth |
| 3020 | func->doc = "get modulation depth, [0.0-1.0]."; |
| 3021 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3022 | |
| 3023 | func = make_new_mfun( "float", "lfoSpeed", FM_ctrl_modSpeed ); //!modulation Speed |
| 3024 | func->add_arg( "float", "value" ); |
| 3025 | func->doc = "set modulation speed (Hz)."; |
| 3026 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3027 | |
| 3028 | func = make_new_mfun( "float", "lfoSpeed", FM_cget_modSpeed ); //!modulation Speed |
| 3029 | func->doc = "get modulation speed (Hz)."; |
| 3030 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3031 | |
| 3032 | func = make_new_mfun( "float", "afterTouch", FM_ctrl_afterTouch ); //!aftertouch |
| 3033 | func->add_arg( "float", "value" ); |
| 3034 | func->doc = "set aftertouch, [0.0-1.0]."; |
| 3035 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3036 | |
| 3037 | func = make_new_mfun( "float", "afterTouch", FM_cget_afterTouch ); //!aftertouch |
| 3038 | func->doc = "get aftertouch, [0.0-1.0]."; |
| 3039 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3040 | |
| 3041 | // 1.4.1.0 (prc) REPAIRATHON2021 NEW SET/GET ACCESS FUNCTIONS |
| 3042 | func = make_new_mfun( "float", "opADSR", FM_ctrl_opADSR ); //!adsr |
| 3043 | func->add_arg( "int", "opNum" ); |
| 3044 | func->add_arg( "float", "attack" ); |
| 3045 | func->add_arg( "float", "decay" ); |
| 3046 | func->add_arg( "float", "sustain" ); |
| 3047 | func->add_arg( "float", "release" ); |
| 3048 | func->doc = "set operator ADSR: attack (sec), decay (sec), sustain [0.0-1.0], release (sec)."; |
| 3049 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3050 | |
| 3051 | // for now, there is no getADSR function |
| 3052 | |
| 3053 | // 1.4.1.0 (prc) REPAIRATHON2021 NEW SET/GET ACCESS FUNCTIONS |
| 3054 | func = make_new_mfun( "float", "opGain", FM_ctrl_opGain ); //!OperatorGain |
| 3055 | func->add_arg( "int", "opNum" ); |
| 3056 | func->add_arg( "float", "value" ); |
| 3057 | func->doc = "set operator gain."; |
| 3058 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3059 | |
| 3060 | func = make_new_mfun( "float", "opGain", FM_cget_opGain ); //!OperatorGain |
| 3061 | func->add_arg( "int", "opNum" ); |
| 3062 | func->doc = "get gperator gain."; |
| 3063 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3064 | |
| 3065 | func = make_new_mfun( "float", "opAM", FM_ctrl_opAM ); // !OperatorAmplitudeModulation |
| 3066 | func->add_arg( "int", "opNum" ); |
| 3067 | func->add_arg( "float", "value" ); |
| 3068 | func->doc = "set operator amplitude modulation."; |
| 3069 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3070 | |
| 3071 | func = make_new_mfun( "float", "opAM", FM_cget_opAM ); //!OperatorAmplitudeModulation |
| 3072 | func->add_arg( "int", "opNum" ); |
| 3073 | func->doc = "get operator amplitude modulation."; |
| 3074 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3075 | |
| 3076 | func = make_new_mfun( "float", "op4Feedback", FM_ctrl_op4Feedback ); //!Operator4Feedback |
| 3077 | func->add_arg( "float", "value" ); |
| 3078 | func->doc = "set operator 4 feedback."; |
| 3079 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3080 | |
| 3081 | func = make_new_mfun( "float", "op4Feedback", FM_cget_op4Feedback ); //!Operator4Feedback |
| 3082 | func->doc = "get operator 4 feedback."; |
| 3083 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3084 | |
| 3085 | func = make_new_mfun( "float", "opWave", FM_ctrl_opWave ); //!OperatorWaveform |
| 3086 | func->add_arg( "int", "opNum" ); |
| 3087 | func->add_arg( "int", "wave" ); |
| 3088 | func->doc = "set operator waveform [1-8]."; |
| 3089 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3090 | |
| 3091 | // NOTE: setRatio was declared in original .h file, but maybe never fully implemented?? |
| 3092 | func = make_new_mfun( "float", "opRatio", FM_ctrl_opRatio ); //!Frequency Ratio (from master freq) |
| 3093 | func->add_arg( "int", "opNum" ); |
| 3094 | func->add_arg( "float", "ratio" ); |
| 3095 | func->doc = "set operator frequency ratio."; |
| 3096 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3097 | |
| 3098 | func = make_new_mfun( "float", "opRatio", FM_cget_opRatio ); //!OperatorFrequencyRatio |
| 3099 | func->add_arg( "int", "opNum" ); |
| 3100 | func->doc = "get operator frequency ratio."; |
| 3101 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3102 | |
| 3103 | func = make_new_mfun( "float", "getFMTableGain", FM_cget_getFMTableGain ); //!Gain Table Lookup (from integer 0-100) |
| 3104 | func->add_arg( "int", "index" ); |
| 3105 | func->doc = "get table gain lookup."; |
| 3106 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3107 | |
| 3108 | func = make_new_mfun( "float", "getFMTableTime", FM_cget_getFMTableTime ); //!Envelope Time Table Lookup (from integer 0-32) |
| 3109 | func->add_arg( "int", "index" ); |
| 3110 | func->doc = "get table time lookup."; |
| 3111 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3112 | |
| 3113 | func = make_new_mfun( "float", "getFMTableSusLevel", FM_cget_getFMTableSusLevel ); //!Sustain Level Table Lookup (from integer 0-16) |
| 3114 | func->add_arg( "int", "index" ); |
| 3115 | func->doc = "get sustain level lookup."; |
| 3116 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3117 | |
| 3118 | // ***** END REPAIRATHON2021 NEW SET/GET ADDITIONS***** |
| 3119 | |
| 3120 | func = make_new_mfun( "float", "controlOne", FM_ctrl_control1 ); //! FM control 1 |
| 3121 | func->add_arg( "float", "value" ); |
| 3122 | func->doc = "set control one [instrument specific]."; |
| 3123 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3124 | |
| 3125 | func = make_new_mfun( "float", "controlOne", FM_cget_control1 ); //! FM control 1 |
| 3126 | func->doc = "get control one [instrument specific]."; |
| 3127 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3128 | |
| 3129 | func = make_new_mfun( "float", "controlTwo", FM_ctrl_control2 ); //! FM control 2 |
| 3130 | func->add_arg( "float", "value" ); |
| 3131 | func->doc = "set control two [instrument specific]."; |
| 3132 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3133 | |
| 3134 | func = make_new_mfun( "float", "controlTwo", FM_cget_control2 ); //! FM control 2 |
| 3135 | func->doc = "get control two [instrument specific]."; |
| 3136 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3137 | |
| 3138 | // end the class import |
| 3139 | type_engine_import_class_end( env ); |
| 3140 | |
| 3141 | |
| 3142 | //------------------------------------------------------------------------ |
| 3143 | // begin BeeThree ugen |
| 3144 | //------------------------------------------------------------------------ |
| 3145 | |
| 3146 | doc = "STK Hammond-oid organ FM synthesis instrument.\n\ |
| 3147 | \n\ |
| 3148 | This class implements a simple 4 operator topology, also referred to as algorithm 8 of the TX81Z.\n\ |
| 3149 | \n\ |
| 3150 | Algorithm 8 is :\n\ |
| 3151 | \n\ |
| 3152 | 1 --.\n\ |
| 3153 | 2 -\\|\n\ |
| 3154 | +-> Out\n\ |
| 3155 | 3 -/|\n\ |
| 3156 | 4 --.\n\ |
| 3157 | \n\ |
| 3158 | Control Change Numbers:\n\ |
| 3159 | \n\ |
| 3160 | - Operator 4 (feedback) Gain = 2 (.controlOne)\n\ |
| 3161 | - Operator 3 Gain = 4 (.controlTwo)\n\ |
| 3162 | - LFO Speed = 11\n\ |
| 3163 | - LFO Depth = 1\n\ |
| 3164 | - ADSR 2 & 4 Target = 128\n\ |
| 3165 | \n\ |
| 3166 | The basic Chowning/Stanford FM patent expired in 1995, but there exist follow-on patents, mostly assigned to Yamaha. If you are of the type who should worry about this (making money) worry away.\n\ |
| 3167 | \n\ |
| 3168 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3169 | |
| 3170 | if( !type_engine_import_ugen_begin( env, "BeeThree", "FM", env->global(), |
| 3171 | BeeThree_ctor, BeeThree_dtor, |
| 3172 | BeeThree_tick, BeeThree_pmsg, doc.c_str() ) ) return FALSE; |
| 3173 | |
| 3174 | // add examples |
| 3175 | type_engine_import_add_ex(env, "hid/keyboard-organ.ck"); |
| 3176 | |
| 3177 | // end the class import |
| 3178 | type_engine_import_class_end( env ); |
| 3179 | |
| 3180 | |
| 3181 | //------------------------------------------------------------------------ |
| 3182 | // begin FMVoices ugen |
| 3183 | //------------------------------------------------------------------------ |
| 3184 | |
| 3185 | doc = "STK singing FM synthesis instrument.\n\ |
| 3186 | \n\ |
| 3187 | This class implements 3 carriers and a common modulator, also referred to as algorithm 6 of the TX81Z.\n\ |
| 3188 | \n\ |
| 3189 | Algorithm 6 is :\n\ |
| 3190 | \n\ |
| 3191 | ___//->1 -\\\n\ |
| 3192 | 4-||-->2 - +-> Out\n\ |
| 3193 | ___\\->3 -//\n\ |
| 3194 | \n\ |
| 3195 | Control Change Numbers:\n\ |
| 3196 | \n\ |
| 3197 | - Vowel = 2 (.controlOne)\n\ |
| 3198 | - Spectral Tilt = 4 (.controlTwo)\n\ |
| 3199 | - LFO Speed = 11\n\ |
| 3200 | - LFO Depth = 1\n\ |
| 3201 | - ADSR 2 & 4 Target = 128\n\ |
| 3202 | \n\ |
| 3203 | The basic Chowning/Stanford FM patent expired in 1995, but there exist follow-on patents, mostly assigned to Yamaha. If you are of the type who should worry about this (making money) worry away.\n\ |
| 3204 | \n\ |
| 3205 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3206 | |
| 3207 | if( !type_engine_import_ugen_begin( env, "FMVoices", "FM", env->global(), |
| 3208 | FMVoices_ctor, FMVoices_dtor, |
| 3209 | FMVoices_tick, FMVoices_pmsg, doc.c_str() ) ) return FALSE; |
| 3210 | |
| 3211 | func = make_new_mfun( "float", "vowel", FMVoices_ctrl_vowel ); //!select vowel |
| 3212 | func->add_arg( "float", "value" ); |
| 3213 | func->doc = "set vowel, [0.0-1.0]."; |
| 3214 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3215 | |
| 3216 | func = make_new_mfun( "float", "vowel", FMVoices_cget_vowel ); //!select vowel |
| 3217 | func->doc = "get vowel, [0.0-1.0]."; |
| 3218 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3219 | |
| 3220 | func = make_new_mfun( "float", "spectralTilt", FMVoices_ctrl_spectralTilt ); //! spectral tilt |
| 3221 | func->add_arg( "float", "value" ); |
| 3222 | func->doc = "set spectral tilt, [0.0-1.0]."; |
| 3223 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3224 | |
| 3225 | func = make_new_mfun( "float", "spectralTilt", FMVoices_cget_spectralTilt ); //! spectral tilt |
| 3226 | func->doc = "get spectral tilt, [0.0-1.0]."; |
| 3227 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3228 | |
| 3229 | func = make_new_mfun( "float", "adsrTarget", FMVoices_ctrl_adsrTarget ); //!adsr targets |
| 3230 | func->add_arg( "float", "value" ); |
| 3231 | func->doc = "set ADSR targets, [0.0-1.0]."; |
| 3232 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3233 | |
| 3234 | func = make_new_mfun( "float", "adsrTarget", FMVoices_cget_adsrTarget ); //!adsr targets |
| 3235 | func->doc = "get ADSR targets, [0.0-1.0]."; |
| 3236 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3237 | |
| 3238 | // end the class import |
| 3239 | type_engine_import_class_end( env ); |
| 3240 | |
| 3241 | |
| 3242 | //------------------------------------------------------------------------ |
| 3243 | // begin HevyMetl ugen |
| 3244 | //------------------------------------------------------------------------ |
| 3245 | |
| 3246 | doc = "A STK heavy metal FM synthesis instrument.\n\ |
| 3247 | \n\ |
| 3248 | This class implements 3 cascade operators with feedback modulation, also referred to as algorithm 3 of the TX81Z.\n\ |
| 3249 | \n\ |
| 3250 | Algorithm 3 is :\n\ |
| 3251 | \n\ |
| 3252 | ____4--\\\n\ |
| 3253 | 3-->2-- + -->1-->Out\n\ |
| 3254 | \n\ |
| 3255 | Control Change Numbers:\n\ |
| 3256 | \n\ |
| 3257 | - Total Modulator Index = 2 (.controlOne)\n\ |
| 3258 | - Modulator Crossfade = 4 (.controlTwo)\n\ |
| 3259 | - LFO Speed = 11\n\ |
| 3260 | - LFO Depth = 1\n\ |
| 3261 | - ADSR 2 & 4 Target = 128\n\ |
| 3262 | \n\ |
| 3263 | The basic Chowning/Stanford FM patent expired in 1995, but there exist follow-on patents, mostly assigned to Yamaha. If you are of the type who should worry about this (making money) worry away.\n\ |
| 3264 | \n\ |
| 3265 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3266 | |
| 3267 | if( !type_engine_import_ugen_begin( env, "HevyMetl", "FM", env->global(), |
| 3268 | HevyMetl_ctor, HevyMetl_dtor, |
| 3269 | HevyMetl_tick, HevyMetl_pmsg, doc.c_str() ) ) return FALSE; |
| 3270 | |
| 3271 | // add examples |
| 3272 | if( !type_engine_import_add_ex( env, "stk/hevymetl-algo3.ck" ) ) goto error; |
| 3273 | if( !type_engine_import_add_ex( env, "stk/hevymetl-dance-now.ck" ) ) goto error; |
| 3274 | if( !type_engine_import_add_ex( env, "stk/hevymetl-trumpet-algo3.ck" ) ) goto error; |
| 3275 | |
| 3276 | // end the class import |
| 3277 | type_engine_import_class_end( env ); |
| 3278 | |
| 3279 | |
| 3280 | /***** REPAIRATHON2021 NEW FM SUB CLASS/ALGORITHM ADDITIONS *****/ |
| 3281 | |
| 3282 | //------------------------------------------------------------------------ |
| 3283 | // begin HnkyTonk ugen |
| 3284 | //------------------------------------------------------------------------ |
| 3285 | |
| 3286 | doc = "STK-style Honkey Tonk Piano FM synthesis instrument.\n\ |
| 3287 | \n\ |
| 3288 | This class implements 4 cascade operators with feedback modulation, also referred to as algorithm 1 of the TX81Z.\n\ |
| 3289 | \n\ |
| 3290 | Algorithm 1 is :\n\ |
| 3291 | \n\ |
| 3292 | ____4-->3-->2-->1-->Out\n\ |
| 3293 | \n\ |
| 3294 | Control Change Numbers:\n\ |
| 3295 | \n\ |
| 3296 | - Total Modulator Index = 2 (.controlOne)\n\ |
| 3297 | - Modulator Crossfade = 4 (.controlTwo)\n\ |
| 3298 | - LFO Speed = 11\n\ |
| 3299 | - LFO Depth = 1\n\ |
| 3300 | - ADSR 2 & 4 Target = 128\n\ |
| 3301 | \n\ |
| 3302 | The basic Chowning/Stanford FM patent expired in 1995, but there exist follow-on patents, mostly assigned to Yamaha. If you are of the type who should worry about this (making money) worry away.\n\ |
| 3303 | \n\ |
| 3304 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3305 | |
| 3306 | if( !type_engine_import_ugen_begin( env, "HnkyTonk", "FM", env->global(), |
| 3307 | HnkyTonk_ctor, HnkyTonk_dtor, |
| 3308 | HnkyTonk_tick, HnkyTonk_pmsg, doc.c_str() ) ) return FALSE; |
| 3309 | |
| 3310 | // add examples |
| 3311 | if( !type_engine_import_add_ex( env, "stk/honkeytonk-algo1.ck" ) ) goto error; |
| 3312 | if( !type_engine_import_add_ex( env, "stk/nylon-guitar-algo1.ck" ) ) goto error; |
| 3313 | if( !type_engine_import_add_ex( env, "stk/jacobass-algo1.ck" ) ) goto error; |
| 3314 | |
| 3315 | // end the class import |
| 3316 | type_engine_import_class_end( env ); |
| 3317 | |
| 3318 | |
| 3319 | //------------------------------------------------------------------------ |
| 3320 | // begin FrencHrn ugen |
| 3321 | //------------------------------------------------------------------------ |
| 3322 | |
| 3323 | doc = "STK-style French Horn FM synthesis instrument.\n\ |
| 3324 | \n\ |
| 3325 | This class implements 3 cascade operators and a 4th modulator with feedback modulation, also referred to as algorithm 2 of the TX81Z.\n\ |
| 3326 | \n\ |
| 3327 | Algorithm 2 is :\n\ |
| 3328 | \n\ |
| 3329 | ____4--\\\n\ |
| 3330 | 3--+-->>2-->1-->Out\n\ |
| 3331 | \n\ |
| 3332 | Control Change Numbers:\n\ |
| 3333 | \n\ |
| 3334 | - Total Modulator Index = 2 (.controlOne)\n\ |
| 3335 | - Modulator Crossfade = 4 (.controlTwo)\n\ |
| 3336 | - LFO Speed = 11\n\ |
| 3337 | - LFO Depth = 1\n\ |
| 3338 | - ADSR 2 & 4 Target = 128\n\ |
| 3339 | \n\ |
| 3340 | The basic Chowning/Stanford FM patent expired in 1995, but there exist follow-on patents, mostly assigned to Yamaha. If you are of the type who should worry about this (making money) worry away.\n\ |
| 3341 | \n\ |
| 3342 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3343 | |
| 3344 | if( !type_engine_import_ugen_begin( env, "FrencHrn", "FM", env->global(), |
| 3345 | FrencHrn_ctor, FrencHrn_dtor, |
| 3346 | FrencHrn_tick, FrencHrn_pmsg, doc.c_str() ) ) return FALSE; |
| 3347 | |
| 3348 | // add examples |
| 3349 | if( !type_engine_import_add_ex( env, "stk/frenchrn-algo2.ck" ) ) goto error; |
| 3350 | |
| 3351 | // end the class import |
| 3352 | type_engine_import_class_end( env ); |
| 3353 | |
| 3354 | |
| 3355 | //------------------------------------------------------------------------ |
| 3356 | // begin KrstlChr ugen |
| 3357 | //------------------------------------------------------------------------ |
| 3358 | |
| 3359 | doc = "STK-style \"Crystal Choir\" FM synthesis instrument.\n\ |
| 3360 | \n\ |
| 3361 | This class implements 3 parallel operators with being modulated (feedback modulation), also referred to as algorithm 7 of the TX81Z.\n\ |
| 3362 | \n\ |
| 3363 | Algorithm 7 is :\n\ |
| 3364 | \n\ |
| 3365 | 1 -\\\n\ |
| 3366 | 2 - +-> Out \n\ |
| 3367 | 4-->3 -/ \n\ |
| 3368 | \n\ |
| 3369 | Control Change Numbers:\n\ |
| 3370 | \n\ |
| 3371 | - Total Modulator Index = 2 (.controlOne)\n\ |
| 3372 | - Modulator Crossfade = 4 (.controlTwo)\n\ |
| 3373 | - LFO Speed = 11\n\ |
| 3374 | - LFO Depth = 1\n\ |
| 3375 | - ADSR 2 & 4 Target = 128\n\ |
| 3376 | \n\ |
| 3377 | The basic Chowning/Stanford FM patent expired in 1995, but there exist follow-on patents, mostly assigned to Yamaha. If you are of the type who should worry about this (making money) worry away.\n\ |
| 3378 | \n\ |
| 3379 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3380 | |
| 3381 | if( !type_engine_import_ugen_begin( env, "KrstlChr", "FM", env->global(), |
| 3382 | KrstlChr_ctor, KrstlChr_dtor, |
| 3383 | KrstlChr_tick, KrstlChr_pmsg, doc.c_str() ) ) return FALSE; |
| 3384 | |
| 3385 | // add examples |
| 3386 | if( !type_engine_import_add_ex( env, "stk/krstlchr-algo7.ck" ) ) goto error; |
| 3387 | |
| 3388 | // end the class import |
| 3389 | type_engine_import_class_end( env ); |
| 3390 | |
| 3391 | /***** END REPAIRATHON2021 FM ALGORITHM ADDITIONS *****/ |
| 3392 | |
| 3393 | |
| 3394 | //------------------------------------------------------------------------ |
| 3395 | // begin PercFlut ugen |
| 3396 | //------------------------------------------------------------------------ |
| 3397 | |
| 3398 | doc = "STK percussive flute FM synthesis instrument.\n\ |
| 3399 | \n\ |
| 3400 | This class implements algorithm 4 of the TX81Z.\n\ |
| 3401 | \n\ |
| 3402 | Algorithm 4 is :\n\ |
| 3403 | \n\ |
| 3404 | 4->3--\\\n\ |
| 3405 | ___2-- + -->1-->Out\n\ |
| 3406 | \n\ |
| 3407 | Control Change Numbers:\n\ |
| 3408 | \n\ |
| 3409 | - Total Modulator Index = 2 (.controlOne)\n\ |
| 3410 | - Modulator Crossfade = 4 (.controlTwo)\n\ |
| 3411 | - LFO Speed = 11\n\ |
| 3412 | - LFO Depth = 1\n\ |
| 3413 | - ADSR 2 & 4 Target = 128\n\ |
| 3414 | \n\ |
| 3415 | The basic Chowning/Stanford FM patent expired in 1995, but there exist follow-on patents, mostly assigned to Yamaha. If you are of the type who should worry about this (making money) worry away.\n\ |
| 3416 | \n\ |
| 3417 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3418 | |
| 3419 | if( !type_engine_import_ugen_begin( env, "PercFlut", "FM", env->global(), |
| 3420 | PercFlut_ctor, PercFlut_dtor, |
| 3421 | PercFlut_tick, PercFlut_pmsg, doc.c_str() ) ) return FALSE; |
| 3422 | |
| 3423 | // add examples |
| 3424 | if( !type_engine_import_add_ex( env, "ctrl/ctrl_sequencer.ck" ) ) goto error; |
| 3425 | |
| 3426 | // end the class import |
| 3427 | type_engine_import_class_end( env ); |
| 3428 | |
| 3429 | |
| 3430 | //------------------------------------------------------------------------ |
| 3431 | // begin Rhodey ugen |
| 3432 | //------------------------------------------------------------------------ |
| 3433 | |
| 3434 | doc = "STK Fender Rhodes-like electric piano FM synthesis instrument.\n\ |
| 3435 | \n\ |
| 3436 | This class implements two simple FM Pairs summed together, also referred to as algorithm 5 of the TX81Z.\n\ |
| 3437 | \n\ |
| 3438 | Algorithm 5 is :\n\ |
| 3439 | \n\ |
| 3440 | 4->3--\n\ |
| 3441 | + --> Out\n\ |
| 3442 | 2->1--\n\ |
| 3443 | \n\ |
| 3444 | Control Change Numbers:\n\ |
| 3445 | \n\ |
| 3446 | - Modulator Index One = 2 (.controlOne)\n\ |
| 3447 | - Crossfade of Outputs = 4 (.controlTwo)\n\ |
| 3448 | - LFO Speed = 11\n\ |
| 3449 | - LFO Depth = 1\n\ |
| 3450 | - ADSR 2 & 4 Target = 128\n\ |
| 3451 | \n\ |
| 3452 | The basic Chowning/Stanford FM patent expired in 1995, but there exist follow-on patents, mostly assigned to Yamaha. If you are of the type who should worry about this (making money) worry away.\n\ |
| 3453 | \n\ |
| 3454 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3455 | |
| 3456 | //! see \examples rhodey.ck |
| 3457 | if( !type_engine_import_ugen_begin( env, "Rhodey", "FM", env->global(), |
| 3458 | Rhodey_ctor, Rhodey_dtor, |
| 3459 | Rhodey_tick, Rhodey_pmsg, doc.c_str() ) ) return FALSE; |
| 3460 | |
| 3461 | type_engine_import_add_ex(env, "stk/rhodey.ck"); |
| 3462 | |
| 3463 | // end the class import |
| 3464 | type_engine_import_class_end( env ); |
| 3465 | |
| 3466 | |
| 3467 | //------------------------------------------------------------------------ |
| 3468 | // begin TubeBell ugen |
| 3469 | //------------------------------------------------------------------------ |
| 3470 | |
| 3471 | doc = "STK tubular bell (orchestral chime) FM synthesis instrument.\n\ |
| 3472 | \n\ |
| 3473 | This class implements two simple FM Pairs summed together, also referred to as algorithm 5 of the TX81Z.\n\ |
| 3474 | \n\ |
| 3475 | Algorithm 5 is :\n\ |
| 3476 | \n\ |
| 3477 | 4->3--\n\ |
| 3478 | + --> Out\n\ |
| 3479 | 2->1--\n\ |
| 3480 | \n\ |
| 3481 | Control Change Numbers:\n\ |
| 3482 | \n\ |
| 3483 | - Modulator Index One = 2 (.controlOne)\n\ |
| 3484 | - Crossfade of Outputs = 4 (.controlTwo)\n\ |
| 3485 | - LFO Speed = 11\n\ |
| 3486 | - LFO Depth = 1\n\ |
| 3487 | - ADSR 2 & 4 Target = 128\n\ |
| 3488 | \n\ |
| 3489 | The basic Chowning/Stanford FM patent expired in 1995, but there exist follow-on patents, mostly assigned to Yamaha. If you are of the type who should worry about this (making money) worry away.\n\ |
| 3490 | \n\ |
| 3491 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3492 | |
| 3493 | if( !type_engine_import_ugen_begin( env, "TubeBell", "FM", env->global(), |
| 3494 | TubeBell_ctor, TubeBell_dtor, |
| 3495 | TubeBell_tick, TubeBell_pmsg, doc.c_str() ) ) return FALSE; |
| 3496 | |
| 3497 | // add example |
| 3498 | type_engine_import_add_ex( env, "stk/tubebell-algo5.ck" ); |
| 3499 | |
| 3500 | // end the class import |
| 3501 | type_engine_import_class_end( env ); |
| 3502 | |
| 3503 | |
| 3504 | //------------------------------------------------------------------------ |
| 3505 | // begin Wurley ugen |
| 3506 | //------------------------------------------------------------------------ |
| 3507 | |
| 3508 | doc = "STK Wurlitzer electric piano FM synthesis instrument.\n\ |
| 3509 | \n\ |
| 3510 | This class implements two simple FM Pairs summed together, also referred to as algorithm 5 of the TX81Z.\n\ |
| 3511 | \n\ |
| 3512 | Algorithm 5 is :\n\ |
| 3513 | \n\ |
| 3514 | 4->3--\n\ |
| 3515 | + --> Out\n\ |
| 3516 | 2->1--\n\ |
| 3517 | \n\ |
| 3518 | Control Change Numbers:\n\ |
| 3519 | \n\ |
| 3520 | - Modulator Index One = 2 (.controlOne)\n\ |
| 3521 | - Crossfade of Outputs = 4 (.controlTwo)\n\ |
| 3522 | - LFO Speed = 11\n\ |
| 3523 | - LFO Depth = 1\n\ |
| 3524 | - ADSR 2 & 4 Target = 128\n\ |
| 3525 | \n\ |
| 3526 | The basic Chowning/Stanford FM patent expired in 1995, but there exist follow-on patents, mostly assigned to Yamaha. If you are of the type who should worry about this (making money) worry away.\n\ |
| 3527 | \n\ |
| 3528 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3529 | |
| 3530 | //! see \examples wurley.ck |
| 3531 | if( !type_engine_import_ugen_begin( env, "Wurley", "FM", env->global(), |
| 3532 | Wurley_ctor, Wurley_dtor, |
| 3533 | Wurley_tick, Wurley_pmsg, doc.c_str() ) ) return FALSE; |
| 3534 | |
| 3535 | type_engine_import_add_ex(env, "stk/wurley.ck"); |
| 3536 | type_engine_import_add_ex(env, "stk/wurley2.ck"); |
| 3537 | type_engine_import_add_ex(env, "stk/wurley3.ck"); |
| 3538 | |
| 3539 | // end the class import |
| 3540 | type_engine_import_class_end( env ); |
| 3541 | |
| 3542 | //end FM |
| 3543 | |
| 3544 | //! \section stk - delay |
| 3545 | |
| 3546 | //------------------------------------------------------------------------ |
| 3547 | // begin Delay ugen |
| 3548 | //------------------------------------------------------------------------ |
| 3549 | |
| 3550 | doc = "A non-interpolating digital delay-line. A fixed maximum length of 4095 and a delay of zero is set using the default constructor. Alternatively, the delay and maximum length can be set during instantiation with an overloaded constructor.\n\ |
| 3551 | \n\ |
| 3552 | A non-interpolating delay line is typically used in fixed delay-length applications, such as for reverberation.\n\ |
| 3553 | \n\ |
| 3554 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3555 | |
| 3556 | //! see \example net_relay.ck |
| 3557 | if( !type_engine_import_ugen_begin( env, "Delay", "UGen", env->global(), |
| 3558 | Delay_ctor, Delay_dtor, |
| 3559 | Delay_tick, Delay_pmsg, doc.c_str() ) ) return FALSE; |
| 3560 | |
| 3561 | // add examples |
| 3562 | if( !type_engine_import_add_ex( env, "basic/comb.ck" ) ) goto error; |
| 3563 | if( !type_engine_import_add_ex( env, "deep/plu.ck" ) ) goto error; |
| 3564 | |
| 3565 | // member variable |
| 3566 | Delay_offset_data = type_engine_import_mvar ( env, "int", "@Delay_data", FALSE ); |
| 3567 | if( Delay_offset_data == CK_INVALID_OFFSET ) goto error; |
| 3568 | |
| 3569 | // add ctor( dur delay ) |
| 3570 | func = make_new_ctor( Delay_ctor_delay ); |
| 3571 | func->add_arg( "dur", "delay" ); |
| 3572 | func->doc = "construct a Delay with delay length and, implicitly, delay max"; |
| 3573 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3574 | |
| 3575 | func = make_new_ctor( Delay_ctor_delay_max ); |
| 3576 | func->add_arg( "dur", "delay" ); |
| 3577 | func->add_arg( "dur", "max" ); |
| 3578 | func->doc = "construct a Delay with delay length and delay max"; |
| 3579 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3580 | |
| 3581 | func = make_new_mfun( "void", "set", Delay_ctrl_set ); |
| 3582 | func->add_arg( "dur", "delay" ); |
| 3583 | func->add_arg( "dur", "max" ); |
| 3584 | func->doc = "set delay length and delay max; delay should be <= max"; |
| 3585 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3586 | |
| 3587 | func = make_new_mfun( "dur", "delay", Delay_ctrl_delay ); //! length of delay |
| 3588 | func->add_arg( "dur", "value" ); |
| 3589 | func->doc = "set length of delay."; |
| 3590 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3591 | |
| 3592 | func = make_new_mfun( "dur", "delay", Delay_cget_delay ); //! length of delay |
| 3593 | func->doc = "get length of delay."; |
| 3594 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3595 | |
| 3596 | func = make_new_mfun( "dur", "max", Delay_ctrl_max ); //! max delay (buffer size) |
| 3597 | func->add_arg( "dur", "value" ); |
| 3598 | func->doc = "set max delay (buffer size)."; |
| 3599 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3600 | |
| 3601 | func = make_new_mfun( "dur", "max", Delay_cget_max ); //! max delay (buffer size) |
| 3602 | func->doc = "get max delay (buffer size)."; |
| 3603 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3604 | |
| 3605 | func = make_new_mfun( "void", "clear", Delay_clear ); //! clear delay |
| 3606 | func->doc = "clear delay line."; |
| 3607 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3608 | |
| 3609 | // delay 'subs' not actually extending . |
| 3610 | |
| 3611 | // end the class import |
| 3612 | type_engine_import_class_end( env ); |
| 3613 | |
| 3614 | |
| 3615 | //------------------------------------------------------------------------ |
| 3616 | // begin DelayA ugen |
| 3617 | //------------------------------------------------------------------------ |
| 3618 | |
| 3619 | doc = "A fractional-length digital delay-line using a first-order allpass filter. A fixed maximum length of 4095 and a delay of 0.5 is set using the default constructor. Alternatively, the delay and maximum length can be set during instantiation with an overloaded constructor.\n\ |
| 3620 | \n\ |
| 3621 | An allpass filter has unity magnitude gain but variable phase delay properties, making it useful in achieving fractional delays without affecting a signal's frequency magnitude response. In order to achieve a maximally flat phase delay response, the minimum delay possible in this implementation is limited to a value of 0.5.\n\ |
| 3622 | \n\ |
| 3623 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3624 | |
| 3625 | if( !type_engine_import_ugen_begin( env, "DelayA", "UGen", env->global(), |
| 3626 | DelayA_ctor, DelayA_dtor, |
| 3627 | DelayA_tick, DelayA_pmsg, doc.c_str() ) ) return FALSE; |
| 3628 | // add examples |
| 3629 | if( !type_engine_import_add_ex( env, "deep/ks-chord.ck" ) ) goto error; |
| 3630 | |
| 3631 | // member variable |
| 3632 | DelayA_offset_data = type_engine_import_mvar ( env, "int", "@DelayA_data", FALSE ); |
| 3633 | if( DelayA_offset_data == CK_INVALID_OFFSET ) goto error; |
| 3634 | |
| 3635 | // add ctor( dur delay ) |
| 3636 | func = make_new_ctor( DelayA_ctor_delay ); |
| 3637 | func->add_arg( "dur", "delay" ); |
| 3638 | func->doc = "construct a DelayA with delay length and, implicitly, delay max"; |
| 3639 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3640 | |
| 3641 | func = make_new_ctor( DelayA_ctor_delay_max ); |
| 3642 | func->add_arg( "dur", "delay" ); |
| 3643 | func->add_arg( "dur", "max" ); |
| 3644 | func->doc = "construct a DelayA with delay length and delay max"; |
| 3645 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3646 | |
| 3647 | func = make_new_mfun( "void", "set", DelayA_ctrl_set ); |
| 3648 | func->add_arg( "dur", "delay" ); |
| 3649 | func->add_arg( "dur", "max" ); |
| 3650 | func->doc = "set delay length and delay max; delay should be <= max"; |
| 3651 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3652 | |
| 3653 | func = make_new_mfun( "dur", "delay", DelayA_ctrl_delay ); //! length of delay |
| 3654 | func->add_arg( "dur", "value" ); |
| 3655 | func->doc = "set length of delay."; |
| 3656 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3657 | |
| 3658 | func = make_new_mfun( "dur", "delay", DelayA_cget_delay ); //! length of delay |
| 3659 | func->doc = "get length of delay."; |
| 3660 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3661 | |
| 3662 | func = make_new_mfun( "dur", "max", DelayA_ctrl_max ); //! max delay ( buffer size ) |
| 3663 | func->add_arg( "dur", "value" ); |
| 3664 | func->doc = "set max delay (buffer size)."; |
| 3665 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3666 | |
| 3667 | func = make_new_mfun( "dur", "max", DelayA_cget_max ); //! max delay ( buffer size ) |
| 3668 | func->doc = "get max delay (buffer size)."; |
| 3669 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3670 | |
| 3671 | func = make_new_mfun( "void", "clear", DelayA_clear ); //! clear delay |
| 3672 | func->doc = "clear delay line."; |
| 3673 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3674 | |
| 3675 | // end the class import |
| 3676 | type_engine_import_class_end( env ); |
| 3677 | |
| 3678 | |
| 3679 | //------------------------------------------------------------------------ |
| 3680 | // begin DelayL ugen |
| 3681 | //------------------------------------------------------------------------ |
| 3682 | |
| 3683 | doc = "A fractional-length digital delay-line using first-order linear interpolation. A fixed maximum length of 4095 and a delay of zero is set using the default constructor. Alternatively, the delay and maximum length can be set during instantiation with an overloaded constructor.\n\ |
| 3684 | \n\ |
| 3685 | Linear interpolation is an efficient technique for achieving fractional delay lengths, though it does introduce high-frequency signal attenuation to varying degrees depending on the fractional delay setting. The use of higher order Lagrange interpolators can typically improve (minimize) this attenuation characteristic.\n\ |
| 3686 | \n\ |
| 3687 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3688 | |
| 3689 | //! see \example i-robot.ck |
| 3690 | if( !type_engine_import_ugen_begin( env, "DelayL", "UGen", env->global(), |
| 3691 | DelayL_ctor, DelayL_dtor, |
| 3692 | DelayL_tick, DelayL_pmsg, doc.c_str() ) ) return FALSE; |
| 3693 | |
| 3694 | type_engine_import_add_ex(env, "basic/delay.ck"); |
| 3695 | type_engine_import_add_ex(env, "basic/delay2.ck"); |
| 3696 | type_engine_import_add_ex(env, "basic/i-robot.ck"); |
| 3697 | type_engine_import_add_ex(env, "multi/we-robot.ck"); |
| 3698 | type_engine_import_add_ex(env, "analysis/xcorr.ck"); |
| 3699 | type_engine_import_add_ex(env, "ai/word2vec/poem-i-feel.ck"); |
| 3700 | |
| 3701 | // member variable |
| 3702 | DelayL_offset_data = type_engine_import_mvar ( env, "int", "@DelayL_data", FALSE ); |
| 3703 | if( DelayL_offset_data == CK_INVALID_OFFSET ) goto error; |
| 3704 | |
| 3705 | // add ctor( dur delay ) |
| 3706 | func = make_new_ctor( DelayL_ctor_delay ); |
| 3707 | func->add_arg( "dur", "delay" ); |
| 3708 | func->doc = "construct a DelayL with delay length and, implicitly, delay max"; |
| 3709 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3710 | |
| 3711 | func = make_new_ctor( DelayL_ctor_delay_max ); |
| 3712 | func->add_arg( "dur", "delay" ); |
| 3713 | func->add_arg( "dur", "max" ); |
| 3714 | func->doc = "construct a DelayL with delay length and delay max"; |
| 3715 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3716 | |
| 3717 | func = make_new_mfun( "void", "set", DelayL_ctrl_set ); |
| 3718 | func->add_arg( "dur", "delay" ); |
| 3719 | func->add_arg( "dur", "max" ); |
| 3720 | func->doc = "set delay length and delay max; delay should be <= max"; |
| 3721 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3722 | |
| 3723 | func = make_new_mfun( "dur", "delay", DelayL_ctrl_delay ); //! length of delay |
| 3724 | func->add_arg( "dur", "value" ); |
| 3725 | func->doc = "set length of delay."; |
| 3726 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3727 | |
| 3728 | func = make_new_mfun( "dur", "delay", DelayL_cget_delay ); //! length of delay |
| 3729 | func->doc = "get length of delay."; |
| 3730 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3731 | |
| 3732 | func = make_new_mfun( "dur", "max", DelayL_ctrl_max ); //! max delay ( buffer size ) |
| 3733 | func->add_arg( "dur", "value" ); |
| 3734 | func->doc = "set max delay (buffer size)."; |
| 3735 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3736 | |
| 3737 | func = make_new_mfun( "dur", "max", DelayL_cget_max ); //! max delay ( buffer size ) |
| 3738 | func->doc = "get max delay (buffer size)."; |
| 3739 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3740 | |
| 3741 | func = make_new_mfun( "void", "clear", DelayL_clear ); //! clear delay |
| 3742 | func->doc = "clear delay line."; |
| 3743 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3744 | |
| 3745 | // end the class import |
| 3746 | type_engine_import_class_end( env ); |
| 3747 | |
| 3748 | |
| 3749 | //------------------------------------------------------------------------ |
| 3750 | // begin Echo ugen |
| 3751 | //------------------------------------------------------------------------ |
| 3752 | |
| 3753 | doc = "An echo effect.\n\ |
| 3754 | \n\ |
| 3755 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3756 | |
| 3757 | if( !type_engine_import_ugen_begin( env, "Echo", "UGen", env->global(), |
| 3758 | Echo_ctor, Echo_dtor, |
| 3759 | Echo_tick, Echo_pmsg, doc.c_str() ) ) return FALSE; |
| 3760 | |
| 3761 | // add examples |
| 3762 | type_engine_import_add_ex(env, "basic/echo.ck"); |
| 3763 | type_engine_import_add_ex(env, "stk/rhodey.ck"); |
| 3764 | type_engine_import_add_ex(env, "stk/wurley2.ck"); |
| 3765 | |
| 3766 | //member variable |
| 3767 | Echo_offset_data = type_engine_import_mvar ( env, "int", "@Echo_data", FALSE ); |
| 3768 | if( Echo_offset_data == CK_INVALID_OFFSET ) goto error; |
| 3769 | |
| 3770 | // add ctor( dur delay ) |
| 3771 | func = make_new_ctor( Echo_ctor_delay ); |
| 3772 | func->add_arg( "dur", "delay" ); |
| 3773 | func->doc = "construct an Echo with delay length and, implicitly, delay max"; |
| 3774 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3775 | |
| 3776 | func = make_new_ctor( Echo_ctor_delay_max ); |
| 3777 | func->add_arg( "dur", "delay" ); |
| 3778 | func->add_arg( "dur", "max" ); |
| 3779 | func->doc = "construct an Echo with delay length and delay max"; |
| 3780 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3781 | |
| 3782 | func = make_new_mfun( "void", "set", Echo_ctrl_set ); |
| 3783 | func->add_arg( "dur", "delay" ); |
| 3784 | func->add_arg( "dur", "max" ); |
| 3785 | func->doc = "set delay length and delay max; delay should be <= max"; |
| 3786 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3787 | |
| 3788 | func = make_new_mfun( "dur", "delay", Echo_ctrl_delay ); //! length of echo |
| 3789 | func->add_arg( "dur", "value" ); |
| 3790 | func->doc = "set length of echo."; |
| 3791 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3792 | |
| 3793 | func = make_new_mfun( "dur", "delay", Echo_cget_delay ); //! length of echo |
| 3794 | func->doc = "get length of echo."; |
| 3795 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3796 | |
| 3797 | func = make_new_mfun( "dur", "max", Echo_ctrl_max ); //! max delay |
| 3798 | func->add_arg( "dur", "value" ); |
| 3799 | func->doc = "set max delay (buffer size)."; |
| 3800 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3801 | |
| 3802 | func = make_new_mfun( "dur", "max", Echo_cget_max ); //! max delay |
| 3803 | func->doc = "get max delay (buffer size)."; |
| 3804 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3805 | |
| 3806 | func = make_new_mfun( "float", "mix", Echo_ctrl_mix ); //! mix level ( wet/dry ) |
| 3807 | func->add_arg( "float", "value" ); |
| 3808 | func->doc = "set mix level (wet/dry)."; |
| 3809 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3810 | |
| 3811 | func = make_new_mfun( "float", "mix", Echo_cget_mix ); //! mix level ( wet/dry ) |
| 3812 | func->doc = "get mix level (wet/dry)."; |
| 3813 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3814 | |
| 3815 | // end the class import |
| 3816 | type_engine_import_class_end( env ); |
| 3817 | |
| 3818 | //! \section stk - envelopes |
| 3819 | |
| 3820 | |
| 3821 | |
| 3822 | //------------------------------------------------------------------------ |
| 3823 | // begin Envelope ugen |
| 3824 | //------------------------------------------------------------------------ |
| 3825 | doc = "This class implements a simple envelope generator which is capable of ramping to a target value by a specified rate. It also responds to simple `keyOn` and `keyOff` messages, ramping to 1.0 on `keyOn` and to 0.0 on `keyOff`.\n\ |
| 3826 | \n\ |
| 3827 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3828 | |
| 3829 | //! see \example sixty.ck |
| 3830 | if( !type_engine_import_ugen_begin( env, "Envelope", "UGen", env->global(), |
| 3831 | Envelope_ctor, Envelope_dtor, |
| 3832 | Envelope_tick, Envelope_pmsg, doc.c_str() ) ) return FALSE; |
| 3833 | |
| 3834 | type_engine_import_add_ex(env, "basic/envelope.ck"); |
| 3835 | type_engine_import_add_ex(env, "basic/envelope2.ck"); |
| 3836 | type_engine_import_add_ex(env, "basic/chirp2.ck"); |
| 3837 | type_engine_import_add_ex(env, "deep/say-chu.ck"); |
| 3838 | |
| 3839 | // member variable |
| 3840 | Envelope_offset_data = type_engine_import_mvar ( env, "int", "@Envelope_data", FALSE ); |
| 3841 | if( Envelope_offset_data == CK_INVALID_OFFSET ) goto error; |
| 3842 | |
| 3843 | // add constructor Envelope( dur durationToTarget ) | 1.5.2.5 (added) ge & eito |
| 3844 | func = make_new_ctor( Envelope_ctor_duration ); |
| 3845 | func->add_arg( "dur", "durationToTarget" ); |
| 3846 | func->doc = "construct an Envelope with duration to reach target (assumed to be 1.0); FYI this does not start the Envelope until .keyOn() is called."; |
| 3847 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3848 | |
| 3849 | // add constructor Envelope( float secondsToTarget ) | 1.5.2.5 (added) ge & eito |
| 3850 | func = make_new_ctor( Envelope_ctor_float ); |
| 3851 | func->add_arg( "float", "secondsToTarget" ); |
| 3852 | func->doc = "construct an Envelope with duration (in seconds) to reach target (assumed to be 1.0); FYI this does not start the Envelope until .keyOn() is called."; |
| 3853 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3854 | |
| 3855 | // add constructor Envelope( dur durationToTarget, float target ) | 1.5.2.5 (added) ge & eito |
| 3856 | func = make_new_ctor( Envelope_ctor_duration_target ); |
| 3857 | func->add_arg( "dur", "durationToTarget" ); |
| 3858 | func->add_arg( "float", "target" ); |
| 3859 | func->doc = "construct an Envelope with duration to reach target; FYI this does not start the Envelope until .keyOn() is called."; |
| 3860 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3861 | |
| 3862 | // add constructor Envelope( float durationToTarget, float target ) | 1.5.2.5 (added) ge & eito |
| 3863 | func = make_new_ctor( Envelope_ctor_float_target ); |
| 3864 | func->add_arg( "float", "secondsToTarget" ); |
| 3865 | func->add_arg( "float", "target" ); |
| 3866 | func->doc = "construct an Envelope with duration (in seconds) to reach target; FYI this does not start the Envelope until .keyOn() is called."; |
| 3867 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3868 | |
| 3869 | // add ramp( dur durationToTarget, float target ) | 1.5.2.5 (added) ge |
| 3870 | func = make_new_mfun( "dur", "ramp", Envelope_mfun_duration_target ); |
| 3871 | func->add_arg( "dur", "durationToTarget" ); |
| 3872 | func->add_arg( "float", "target" ); |
| 3873 | func->doc = "over the given duration, ramp toward the specified target; returns the given duration."; |
| 3874 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3875 | |
| 3876 | // add ramp( float durationToTarget, float target ) | 1.5.2.5 (added) ge |
| 3877 | func = make_new_mfun( "dur", "ramp", Envelope_mfun_float_target ); |
| 3878 | func->add_arg( "float", "secondsToTarget" ); |
| 3879 | func->add_arg( "float", "target" ); |
| 3880 | func->doc = "over the given duration (in seconds), ramp toward the specified target; returns the given duration."; |
| 3881 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3882 | |
| 3883 | func = make_new_mfun( "int", "keyOn", Envelope_ctrl_keyOn0 ); //! ramp to 1.0 |
| 3884 | func->doc = "get keyOn state."; |
| 3885 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3886 | |
| 3887 | func = make_new_mfun( "int", "keyOn", Envelope_ctrl_keyOn ); //! ramp to 1.0 |
| 3888 | func->add_arg( "int", "value" ); |
| 3889 | func->doc = "ramp to 1.0."; |
| 3890 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3891 | |
| 3892 | func = make_new_mfun( "int", "keyOff", Envelope_ctrl_keyOff0 ); //! ramp to 0.0 |
| 3893 | func->doc = "get keyOff state."; |
| 3894 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3895 | |
| 3896 | func = make_new_mfun( "int", "keyOff", Envelope_ctrl_keyOff ); //! ramp to 0.0 |
| 3897 | func->add_arg( "int", "value" ); |
| 3898 | func->doc = "ramp to 0.0."; |
| 3899 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3900 | |
| 3901 | func = make_new_mfun( "float", "target", Envelope_ctrl_target ); //! ramp to arbitrary value. |
| 3902 | func->add_arg( "float", "value" ); |
| 3903 | func->doc = "set value to ramp to."; |
| 3904 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3905 | |
| 3906 | func = make_new_mfun( "float", "target", Envelope_cget_target ); //! ramp to arbitrary value. |
| 3907 | func->doc = "get value to ramp to."; |
| 3908 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3909 | |
| 3910 | func = make_new_mfun( "float", "time", Envelope_ctrl_time ); //! time to reach target |
| 3911 | func->add_arg( "float", "value" ); |
| 3912 | func->doc = "set time to reach target (in seconds)."; |
| 3913 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3914 | |
| 3915 | func = make_new_mfun( "float", "time", Envelope_cget_time ); //! time to reach target |
| 3916 | func->doc = "get time to reach target (in seconds)."; |
| 3917 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3918 | |
| 3919 | func = make_new_mfun( "dur", "duration", Envelope_ctrl_duration ); //! time to reach target |
| 3920 | func->add_arg( "dur", "value" ); |
| 3921 | func->doc = "set duration to reach target."; |
| 3922 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3923 | |
| 3924 | func = make_new_mfun( "dur", "duration", Envelope_cget_duration ); //! time to reach target |
| 3925 | func->doc = "get duration to reach target."; |
| 3926 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3927 | |
| 3928 | func = make_new_mfun( "float", "rate", Envelope_ctrl_rate ); //! attack rate |
| 3929 | func->add_arg( "float", "value" ); |
| 3930 | func->doc = "set rate of change."; |
| 3931 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3932 | |
| 3933 | func = make_new_mfun( "float", "rate", Envelope_cget_rate ); //! attack rate |
| 3934 | func->doc = "get rate of change."; |
| 3935 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3936 | |
| 3937 | func = make_new_mfun( "float", "value", Envelope_ctrl_value ); //! set immediate value |
| 3938 | func->add_arg( "float", "value" ); |
| 3939 | func->doc = "set immediate value."; |
| 3940 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3941 | |
| 3942 | func = make_new_mfun( "float", "value", Envelope_cget_value ); //! set immediate value |
| 3943 | func->doc = "get immediate value."; |
| 3944 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3945 | |
| 3946 | |
| 3947 | // end the class import |
| 3948 | type_engine_import_class_end( env ); |
| 3949 | |
| 3950 | |
| 3951 | //------------------------------------------------------------------------ |
| 3952 | // begin ADSR ugen |
| 3953 | //------------------------------------------------------------------------ |
| 3954 | |
| 3955 | doc = "This Envelope subclass implements a traditional ADSR (Attack, Decay, Sustain, Release) envelope. It responds to simple `keyOn` and `keyOff` messages, keeping track of its state.\n\ |
| 3956 | \n\ |
| 3957 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 3958 | |
| 3959 | //! see \example adsr.ck |
| 3960 | if( !type_engine_import_ugen_begin( env, "ADSR", "Envelope", env->global(), |
| 3961 | ADSR_ctor, ADSR_dtor, |
| 3962 | ADSR_tick, ADSR_pmsg, doc.c_str() ) ) return FALSE; |
| 3963 | |
| 3964 | type_engine_import_add_ex(env, "basic/adsr.ck"); |
| 3965 | type_engine_import_add_ex(env, "basic/blit2.ck"); |
| 3966 | |
| 3967 | // add construtor ADSR( dur attack, dur decay, float sustain, dur release ) | 1.5.2.5 (added) ge & eito |
| 3968 | func = make_new_ctor( ADSR_ctor_durs ); |
| 3969 | func->add_arg( "dur", "attack" ); |
| 3970 | func->add_arg( "dur", "decay" ); |
| 3971 | func->add_arg( "float", "sustain" ); |
| 3972 | func->add_arg( "dur", "release" ); |
| 3973 | func->doc = "construct an ADSR with attack, decay, sustain, and release values. Attack, decay, and release values are durations; sustain is a float value typically between 0 and 1."; |
| 3974 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3975 | |
| 3976 | // add constructor ADSR( float attack, float decay, float sustain, float release ) | 1.5.2.5 (added) ge & eito |
| 3977 | func = make_new_ctor( ADSR_ctor_floats ); |
| 3978 | func->add_arg( "float", "attack" ); |
| 3979 | func->add_arg( "float", "decay" ); |
| 3980 | func->add_arg( "float", "sustain" ); |
| 3981 | func->add_arg( "float", "release" ); |
| 3982 | func->doc = "construct an ADSR with attack, decay, sustain, and release values. Attack, decay, and release values are in seconds; sustain is a float value typically between 0 and 1."; |
| 3983 | if( !type_engine_import_ctor( env, func ) ) goto error; |
| 3984 | |
| 3985 | func = make_new_mfun( "dur", "attackTime", ADSR_ctrl_attackTime ); //! attack time |
| 3986 | func->add_arg( "dur", "value" ); |
| 3987 | func->doc = "set attack time."; |
| 3988 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3989 | |
| 3990 | func = make_new_mfun( "dur", "attackTime", ADSR_cget_attackTime ); //! attack time |
| 3991 | func->doc = "get attack time."; |
| 3992 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3993 | |
| 3994 | func = make_new_mfun( "float", "attackRate", ADSR_ctrl_attackRate ); //! attack rate |
| 3995 | func->add_arg( "float", "value" ); |
| 3996 | func->doc = "set attack rate."; |
| 3997 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 3998 | |
| 3999 | func = make_new_mfun( "float", "attackRate", ADSR_cget_attackRate ); //! attack rate |
| 4000 | func->doc = "get attack rate."; |
| 4001 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4002 | |
| 4003 | func = make_new_mfun( "dur", "decayTime", ADSR_ctrl_decayTime ); //! decay time |
| 4004 | func->add_arg( "dur", "value" ); |
| 4005 | func->doc = "set decay time."; |
| 4006 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4007 | |
| 4008 | func = make_new_mfun( "dur", "decayTime", ADSR_cget_decayTime ); //! decay time |
| 4009 | func->doc = "get decay time."; |
| 4010 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4011 | |
| 4012 | func = make_new_mfun( "float", "decayRate", ADSR_ctrl_decayRate ); //! decay rate |
| 4013 | func->add_arg( "float", "value" ); |
| 4014 | func->doc = "set decay rate."; |
| 4015 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4016 | |
| 4017 | func = make_new_mfun( "float", "decayRate", ADSR_cget_decayRate ); //! decay rate |
| 4018 | func->doc = "get decay rate."; |
| 4019 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4020 | |
| 4021 | func = make_new_mfun( "float", "sustainLevel", ADSR_ctrl_sustainLevel ); //! sustain level |
| 4022 | func->add_arg( "float", "value" ); |
| 4023 | func->doc = "set sustain level."; |
| 4024 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4025 | |
| 4026 | func = make_new_mfun( "float", "sustainLevel", ADSR_cget_sustainLevel ); //! sustain level |
| 4027 | func->doc = "get sustain level."; |
| 4028 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4029 | |
| 4030 | func = make_new_mfun( "dur", "releaseTime", ADSR_ctrl_releaseTime ); //! release time |
| 4031 | func->add_arg( "dur", "value" ); |
| 4032 | func->doc = "set release time."; |
| 4033 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4034 | |
| 4035 | func = make_new_mfun( "dur", "releaseTime", ADSR_cget_releaseTime ); //! release time |
| 4036 | func->doc = "get release time."; |
| 4037 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4038 | |
| 4039 | func = make_new_mfun( "float", "releaseRate", ADSR_ctrl_releaseRate ); //! release rate |
| 4040 | func->add_arg( "float", "value" ); |
| 4041 | func->doc = "set release rate."; |
| 4042 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4043 | |
| 4044 | func = make_new_mfun( "float", "releaseRate", ADSR_cget_releaseRate ); //! release rate |
| 4045 | func->doc = "get release rate."; |
| 4046 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4047 | |
| 4048 | func = make_new_mfun( "void", "set", ADSR_ctrl_set ); //! set |
| 4049 | func->add_arg( "float", "attackTime" ); |
| 4050 | func->add_arg( "float", "decayTime" ); |
| 4051 | func->add_arg( "float", "sustainLevel" ); |
| 4052 | func->add_arg( "float", "releaseTime" ); |
| 4053 | func->doc = "set attack, decay, sustain, and release all at once (in seconds)."; |
| 4054 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4055 | |
| 4056 | func = make_new_mfun( "void", "set", ADSR_ctrl_set2 ); //! set |
| 4057 | func->add_arg( "dur", "attackDuration" ); |
| 4058 | func->add_arg( "dur", "decayDuration" ); |
| 4059 | func->add_arg( "float", "sustainLevel" ); |
| 4060 | func->add_arg( "dur", "releaseDuration" ); |
| 4061 | func->doc = "set attack, decay, sustain, and release all at once."; |
| 4062 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4063 | |
| 4064 | func = make_new_mfun( "int", "state", ADSR_cget_state ); //! attack=0, decay=1 , sustain=2, release=3, done=4 |
| 4065 | func->doc = "get state; attack=0, decay=1, sustain=2, release=3, done=4"; |
| 4066 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4067 | |
| 4068 | if( !type_engine_import_svar( env, "int", "ATTACK", TRUE, (t_CKUINT)&ADSR_state_ATTACK, |
| 4069 | "see state() function. Denotes that the envelope is in the attack stage") ) goto error; |
| 4070 | if( !type_engine_import_svar( env, "int", "DECAY", TRUE, (t_CKUINT)&ADSR_state_DECAY, |
| 4071 | "see state() function. Denotes that the envelope is in the decay stage") ) goto error; |
| 4072 | if( !type_engine_import_svar( env, "int", "SUSTAIN", TRUE, (t_CKUINT)&ADSR_state_SUSTAIN, |
| 4073 | "see state() function. Denotes that the envelope is in the sustain stage") ) goto error; |
| 4074 | if( !type_engine_import_svar( env, "int", "RELEASE", TRUE, (t_CKUINT)&ADSR_state_RELEASE, |
| 4075 | "see state() function. Denotes that the envelope is in the release stage") ) goto error; |
| 4076 | if( !type_engine_import_svar( env, "int", "DONE", TRUE, (t_CKUINT)&ADSR_state_DONE, |
| 4077 | "see state() function. Denotes that the envelope has completed all stages") ) goto error; |
| 4078 | |
| 4079 | // end the class import |
| 4080 | type_engine_import_class_end( env ); |
| 4081 | |
| 4082 | // uhhh we are supposed to have target and value here as well.. d'oh |
| 4083 | |
| 4084 | //! \section stk - filters |
| 4085 | |
| 4086 | |
| 4087 | |
| 4088 | |
| 4089 | /* -- using native BiQuad -- |
| 4090 | //------------------------------------------------------------------------ |
| 4091 | // begin BiQuad ugen |
| 4092 | //------------------------------------------------------------------------ |
| 4093 | |
| 4094 | if( !type_engine_import_ugen_begin( env, "BiQuadStk", "UGen", env->global(), |
| 4095 | BiQuad_ctor, BiQuad_tick, BiQuad_pmsg ) ) return FALSE; |
| 4096 | //member variable |
| 4097 | BiQuad_offset_data = type_engine_import_mvar ( env, "int", "@BiQuad_data", FALSE ); |
| 4098 | if( BiQuad_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4099 | |
| 4100 | func = make_new_mfun( "float", "b2", BiQuad_ctrl_b2 ); //! b2 coefficient |
| 4101 | func->add_arg( "float", "value" ); |
| 4102 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4103 | |
| 4104 | func = make_new_mfun( "float", "b2", BiQuad_cget_b2 ); //! b2 coefficient |
| 4105 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4106 | |
| 4107 | func = make_new_mfun( "float", "b1", BiQuad_ctrl_b1 ); //! b1 coefficient |
| 4108 | func->add_arg( "float", "value" ); |
| 4109 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4110 | |
| 4111 | func = make_new_mfun( "float", "b1", BiQuad_cget_b1 ); //! b1 coefficient |
| 4112 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4113 | |
| 4114 | func = make_new_mfun( "float", "b0", BiQuad_ctrl_b0 ); //! b0 coefficient |
| 4115 | func->add_arg( "float", "value" ); |
| 4116 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4117 | |
| 4118 | func = make_new_mfun( "float", "b0", BiQuad_cget_b0 ); //! b0 coefficient |
| 4119 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4120 | |
| 4121 | func = make_new_mfun( "float", "a2", BiQuad_ctrl_a2 ); //! a2 coefficient |
| 4122 | func->add_arg( "float", "value" ); |
| 4123 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4124 | |
| 4125 | func = make_new_mfun( "float", "a2", BiQuad_cget_a2 ); //! a2 coefficient |
| 4126 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4127 | |
| 4128 | func = make_new_mfun( "float", "a1", BiQuad_ctrl_a1 ); //! a1 coefficient |
| 4129 | func->add_arg( "float", "value" ); |
| 4130 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4131 | |
| 4132 | func = make_new_mfun( "float", "a1", BiQuad_cget_a1 ); //! a1 coefficient |
| 4133 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4134 | |
| 4135 | func = make_new_mfun( "float", "a0", BiQuad_cget_a0 ); //! a0 coefficient |
| 4136 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4137 | |
| 4138 | func = make_new_mfun( "float", "pfreq", BiQuad_ctrl_pfreq ); //! set resonance frequency (poles) |
| 4139 | func->add_arg( "float", "value" ); |
| 4140 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4141 | |
| 4142 | func = make_new_mfun( "float", "pfreq", BiQuad_cget_pfreq ); //! get resonance frequency (poles) |
| 4143 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4144 | |
| 4145 | func = make_new_mfun( "float", "prad", BiQuad_ctrl_prad ); //! pole radius (less than 1 to be stable) |
| 4146 | func->add_arg( "float", "value" ); |
| 4147 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4148 | |
| 4149 | func = make_new_mfun( "float", "prad", BiQuad_cget_prad ); //! pole radius (less than 1 to be stable) |
| 4150 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4151 | |
| 4152 | func = make_new_mfun( "float", "zfreq", BiQuad_ctrl_zfreq ); //! notch frequency |
| 4153 | func->add_arg( "float", "value" ); |
| 4154 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4155 | |
| 4156 | func = make_new_mfun( "float", "zfreq", BiQuad_cget_zfreq ); //! notch frequency |
| 4157 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4158 | |
| 4159 | func = make_new_mfun( "float", "zrad", BiQuad_ctrl_zrad ); //! zero radius |
| 4160 | func->add_arg( "float", "value" ); |
| 4161 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4162 | |
| 4163 | func = make_new_mfun( "float", "zrad", BiQuad_cget_zrad ); //! zero radius |
| 4164 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4165 | |
| 4166 | func = make_new_mfun( "float", "norm", BiQuad_ctrl_norm ); //! normalization |
| 4167 | func->add_arg( "float", "value" ); |
| 4168 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4169 | |
| 4170 | func = make_new_mfun( "float", "eqzs", BiQuad_ctrl_eqzs ); //! equal gain zeroes |
| 4171 | func->add_arg( "float", "value" ); |
| 4172 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4173 | |
| 4174 | |
| 4175 | // end the class import |
| 4176 | type_engine_import_class_end( env ); |
| 4177 | */ |
| 4178 | |
| 4179 | |
| 4180 | //------------------------------------------------------------------------ |
| 4181 | // begin FilterStk ugen (orginally Filter) |
| 4182 | //------------------------------------------------------------------------ |
| 4183 | |
| 4184 | if( !type_engine_import_ugen_begin( env, "FilterStk", "UGen", env->global(), |
| 4185 | FilterStk_ctor, FilterStk_dtor, |
| 4186 | FilterStk_tick, FilterStk_pmsg, |
| 4187 | "FilterStk is an STK Filter base class inherited by all Stk Filter UGens such as BiQuad, TwoZero, PoleZero, etc. You should NOT need to use this UGen directly. Please refer to the documentation on other filter types instead." ) ) return FALSE; |
| 4188 | // member variable |
| 4189 | FilterStk_offset_data = type_engine_import_mvar ( env, "int", "@FilterStk_data", FALSE ); |
| 4190 | if( FilterStk_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4191 | |
| 4192 | // coefs |
| 4193 | func = make_new_mfun( "string", "coefs", FilterStk_ctrl_coefs ); |
| 4194 | func->add_arg( "string", "value" ); |
| 4195 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4196 | |
| 4197 | // end the class import |
| 4198 | type_engine_import_class_end( env ); |
| 4199 | |
| 4200 | |
| 4201 | //------------------------------------------------------------------------ |
| 4202 | // begin OnePole ugen |
| 4203 | //------------------------------------------------------------------------ |
| 4204 | |
| 4205 | doc = "This Filter subclass implements a one-pole digital filter. A method is provided for setting the pole position along the real axis of the z-plane while maintaining a constant peak filter gain.\n\ |
| 4206 | \n\ |
| 4207 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4208 | |
| 4209 | if( !type_engine_import_ugen_begin( env, "OnePole", "UGen", env->global(), |
| 4210 | OnePole_ctor, OnePole_dtor, |
| 4211 | OnePole_tick, OnePole_pmsg, doc.c_str() ) ) return FALSE; |
| 4212 | |
| 4213 | // member variable |
| 4214 | OnePole_offset_data = type_engine_import_mvar ( env, "int", "@OnePole_data", FALSE ); |
| 4215 | if( OnePole_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4216 | |
| 4217 | func = make_new_mfun( "float", "a1", OnePole_ctrl_a1 ); //! filter coefficient |
| 4218 | func->add_arg( "float", "value" ); |
| 4219 | func->doc = "set filter coefficient."; |
| 4220 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4221 | |
| 4222 | func = make_new_mfun( "float", "a1", OnePole_cget_a1 ); //! filter coefficient |
| 4223 | func->doc = "get filter coefficient."; |
| 4224 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4225 | |
| 4226 | func = make_new_mfun( "float", "b0", OnePole_ctrl_b0 ); //! filter coefficient |
| 4227 | func->add_arg( "float", "value" ); |
| 4228 | func->doc = "set filter coefficient."; |
| 4229 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4230 | |
| 4231 | func = make_new_mfun( "float", "b0", OnePole_cget_b0 ); //! filter coefficient |
| 4232 | func->doc = "get filter coefficient."; |
| 4233 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4234 | |
| 4235 | func = make_new_mfun( "float", "pole", OnePole_ctrl_pole ); //! set pole position along real axis of z-plane |
| 4236 | func->add_arg( "float", "value" ); |
| 4237 | func->doc = "set pole position along real axis of z-plane."; |
| 4238 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4239 | |
| 4240 | func = make_new_mfun( "float", "pole", OnePole_cget_pole ); //! set pole position along real axis of z-plane |
| 4241 | func->doc = "get pole position along real axis of z-plane."; |
| 4242 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4243 | |
| 4244 | // add examples |
| 4245 | type_engine_import_add_ex( env, "deep/follower.ck" ); |
| 4246 | |
| 4247 | // end the class import |
| 4248 | type_engine_import_class_end( env ); |
| 4249 | |
| 4250 | |
| 4251 | //------------------------------------------------------------------------ |
| 4252 | // begin TwoPole ugen |
| 4253 | //------------------------------------------------------------------------ |
| 4254 | doc = "This Filter subclass implements a two-pole digital filter. A method is provided for creating a resonance in the frequency response while maintaining a nearly constant filter gain.\n\ |
| 4255 | \n\ |
| 4256 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4257 | |
| 4258 | if( !type_engine_import_ugen_begin( env, "TwoPole", "UGen", env->global(), |
| 4259 | TwoPole_ctor, TwoPole_dtor, |
| 4260 | TwoPole_tick, TwoPole_pmsg, doc.c_str() ) ) return FALSE; |
| 4261 | |
| 4262 | type_engine_import_add_ex(env, "shred/powerup.ck"); |
| 4263 | |
| 4264 | //member variable |
| 4265 | TwoPole_offset_data = type_engine_import_mvar ( env, "int", "@TwoPole_data", FALSE ); |
| 4266 | if( TwoPole_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4267 | func = make_new_mfun( "float", "a1", TwoPole_ctrl_a1 ); //! filter coefficient |
| 4268 | func->add_arg( "float", "value" ); |
| 4269 | func->doc = "set filter coefficient."; |
| 4270 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4271 | |
| 4272 | func = make_new_mfun( "float", "a1", TwoPole_cget_a1 ); //! filter coefficient |
| 4273 | func->doc = "get filter coefficient."; |
| 4274 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4275 | |
| 4276 | func = make_new_mfun( "float", "a2", TwoPole_ctrl_a2 ); //! filter coefficient |
| 4277 | func->add_arg( "float", "value" ); |
| 4278 | func->doc = "set filter coefficient."; |
| 4279 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4280 | |
| 4281 | func = make_new_mfun( "float", "a2", TwoPole_cget_a2 ); //! filter coefficient |
| 4282 | func->doc = "get filter coefficient."; |
| 4283 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4284 | |
| 4285 | func = make_new_mfun( "float", "b0", TwoPole_ctrl_b0 ); //! filter coefficient |
| 4286 | func->add_arg( "float", "value" ); |
| 4287 | func->doc = "set filter coefficient."; |
| 4288 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4289 | |
| 4290 | func = make_new_mfun( "float", "b0", TwoPole_cget_b0 ); //! filter coefficient |
| 4291 | func->doc = "get filter coefficient."; |
| 4292 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4293 | |
| 4294 | func = make_new_mfun( "float", "freq", TwoPole_ctrl_freq ); //! filter resonance frequency |
| 4295 | func->add_arg( "float", "value" ); |
| 4296 | func->doc = "set filter resonance frequency."; |
| 4297 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4298 | |
| 4299 | func = make_new_mfun( "float", "freq", TwoPole_cget_freq ); //! filter resonance frequency |
| 4300 | func->doc = "get filter resonance frequency."; |
| 4301 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4302 | |
| 4303 | func = make_new_mfun( "float", "radius", TwoPole_ctrl_radius ); //! filter resonance radius |
| 4304 | func->add_arg( "float", "value" ); |
| 4305 | func->doc = "set filter radius resonance."; |
| 4306 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4307 | |
| 4308 | func = make_new_mfun( "float", "radius", TwoPole_cget_radius ); //! filter resonance radius |
| 4309 | func->doc = "get filter radius resonance."; |
| 4310 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4311 | |
| 4312 | func = make_new_mfun( "int", "norm", TwoPole_ctrl_norm ); //! toggle filter normalization |
| 4313 | func->add_arg( "int", "value" ); |
| 4314 | func->doc = "set filter normalization."; |
| 4315 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4316 | |
| 4317 | func = make_new_mfun( "int", "norm", TwoPole_cget_norm ); //! toggle filter normalization |
| 4318 | func->doc = "get filter normalization."; |
| 4319 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4320 | |
| 4321 | |
| 4322 | // end the class import |
| 4323 | type_engine_import_class_end( env ); |
| 4324 | |
| 4325 | |
| 4326 | //------------------------------------------------------------------------ |
| 4327 | // begin OneZero ugen |
| 4328 | //------------------------------------------------------------------------ |
| 4329 | doc = "This Filter subclass implements a one-zero digital filter. A method is provided for setting the zero position along the real axis of the z-plane while maintaining a constant filter gain.\n\ |
| 4330 | \n\ |
| 4331 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4332 | |
| 4333 | if( !type_engine_import_ugen_begin( env, "OneZero", "UGen", env->global(), |
| 4334 | OneZero_ctor, OneZero_dtor, |
| 4335 | OneZero_tick, OneZero_pmsg, doc.c_str() ) ) return FALSE; |
| 4336 | |
| 4337 | //member variable |
| 4338 | OneZero_offset_data = type_engine_import_mvar ( env, "int", "@OneZero_data", FALSE ); |
| 4339 | if( OneZero_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4340 | func = make_new_mfun( "float", "zero", OneZero_ctrl_zero ); //! set zero position |
| 4341 | func->add_arg( "float", "value" ); |
| 4342 | func->doc = "set zero position."; |
| 4343 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4344 | |
| 4345 | func = make_new_mfun( "float", "zero", OneZero_cget_zero ); //! set zero position |
| 4346 | func->doc = "get zero position."; |
| 4347 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4348 | |
| 4349 | func = make_new_mfun( "float", "b0", OneZero_ctrl_b0 ); //! filter coefficient |
| 4350 | func->add_arg( "float", "value" ); |
| 4351 | func->doc = "set filter coefficient."; |
| 4352 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4353 | |
| 4354 | func = make_new_mfun( "float", "b0", OneZero_cget_b0 ); //! filter coefficient |
| 4355 | func->doc = "get filter coefficient."; |
| 4356 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4357 | |
| 4358 | func = make_new_mfun( "float", "b1", OneZero_ctrl_b1 ); //! filter coefficient |
| 4359 | func->add_arg( "float", "value" ); |
| 4360 | func->doc = "set filter coefficient."; |
| 4361 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4362 | |
| 4363 | func = make_new_mfun( "float", "b1", OneZero_cget_b1 ); //! filter coefficient |
| 4364 | func->doc = "get filter coefficient."; |
| 4365 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4366 | |
| 4367 | // add examples |
| 4368 | type_engine_import_add_ex( env, "deep/plu.ck" ); |
| 4369 | type_engine_import_add_ex( env, "deep/plu2.ck" ); |
| 4370 | type_engine_import_add_ex( env, "deep/plu3.ck" ); |
| 4371 | |
| 4372 | // end the class import |
| 4373 | type_engine_import_class_end( env ); |
| 4374 | |
| 4375 | |
| 4376 | //------------------------------------------------------------------------ |
| 4377 | // begin TwoZero ugen |
| 4378 | //------------------------------------------------------------------------ |
| 4379 | |
| 4380 | doc = "This Filter subclass implements a two-zero digital filter. A method is provided for creating a 'notch' in the frequency response while maintaining a constant filter gain.\n\ |
| 4381 | \n\ |
| 4382 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4383 | |
| 4384 | if( !type_engine_import_ugen_begin( env, "TwoZero", "UGen", env->global(), |
| 4385 | TwoZero_ctor, TwoZero_dtor, |
| 4386 | TwoZero_tick, TwoZero_pmsg, doc.c_str() ) ) return FALSE; |
| 4387 | |
| 4388 | //member variable |
| 4389 | TwoZero_offset_data = type_engine_import_mvar ( env, "int", "@TwoZero_data", FALSE ); |
| 4390 | if( TwoZero_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4391 | func = make_new_mfun( "float", "b0", TwoZero_ctrl_b0 ); //! filter coefficient |
| 4392 | func->add_arg( "float", "value" ); |
| 4393 | func->doc = "set filter coefficient."; |
| 4394 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4395 | |
| 4396 | func = make_new_mfun( "float", "b0", TwoZero_cget_b0 ); //! filter coefficient |
| 4397 | func->doc = "get filter coefficient."; |
| 4398 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4399 | |
| 4400 | func = make_new_mfun( "float", "b1", TwoZero_ctrl_b1 ); //! filter coefficient |
| 4401 | func->add_arg( "float", "value" ); |
| 4402 | func->doc = "set filter coefficient."; |
| 4403 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4404 | |
| 4405 | func = make_new_mfun( "float", "b1", TwoZero_cget_b1 ); //! filter coefficient |
| 4406 | func->doc = "get filter coefficient."; |
| 4407 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4408 | |
| 4409 | func = make_new_mfun( "float", "b2", TwoZero_ctrl_b2 ); //! filter coefficient |
| 4410 | func->add_arg( "float", "value" ); |
| 4411 | func->doc = "set filter coefficient."; |
| 4412 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4413 | |
| 4414 | func = make_new_mfun( "float", "b2", TwoZero_cget_b2 ); //! filter coefficient |
| 4415 | func->doc = "get filter coefficient."; |
| 4416 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4417 | |
| 4418 | func = make_new_mfun( "float", "freq", TwoZero_ctrl_freq ); //! filter notch frequency |
| 4419 | func->add_arg( "float", "value" ); |
| 4420 | func->doc = "set filter notch frequency."; |
| 4421 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4422 | |
| 4423 | func = make_new_mfun( "float", "freq", TwoZero_cget_freq ); //! filter notch frequency |
| 4424 | func->doc = "get filter notch frequency."; |
| 4425 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4426 | |
| 4427 | func = make_new_mfun( "float", "radius", TwoZero_ctrl_radius ); //! filter notch radius |
| 4428 | func->add_arg( "float", "value" ); |
| 4429 | func->doc = "set filter notch radius."; |
| 4430 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4431 | |
| 4432 | func = make_new_mfun( "float", "radius", TwoZero_cget_radius ); //! filter notch radius |
| 4433 | func->doc = "get filter notch radius."; |
| 4434 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4435 | |
| 4436 | // add examples |
| 4437 | if( !type_engine_import_add_ex( env, "deep/chant.ck" ) ) goto error; |
| 4438 | if( !type_engine_import_add_ex( env, "deep/say-chu.ck" ) ) goto error; |
| 4439 | |
| 4440 | // end the class import |
| 4441 | type_engine_import_class_end( env ); |
| 4442 | |
| 4443 | |
| 4444 | //------------------------------------------------------------------------ |
| 4445 | // begin PoleZero ugen |
| 4446 | //------------------------------------------------------------------------ |
| 4447 | |
| 4448 | doc = "a one-pole, one-zero digital filter. A method is provided for creating an allpass filter with a given coefficient. Another method is provided to create a DC blocking filter.\n\ |
| 4449 | \n\ |
| 4450 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4451 | |
| 4452 | if( !type_engine_import_ugen_begin( env, "PoleZero", "UGen", env->global(), |
| 4453 | PoleZero_ctor, PoleZero_dtor, |
| 4454 | PoleZero_tick, PoleZero_pmsg, doc.c_str() ) ) return FALSE; |
| 4455 | |
| 4456 | //member variable |
| 4457 | PoleZero_offset_data = type_engine_import_mvar ( env, "int", "@PoleZero_data", FALSE ); |
| 4458 | if( PoleZero_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4459 | func = make_new_mfun( "float", "a1", PoleZero_ctrl_a1 ); //! filter coefficient |
| 4460 | func->add_arg( "float", "value" ); |
| 4461 | func->doc = "set filter coefficient."; |
| 4462 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4463 | |
| 4464 | func = make_new_mfun( "float", "a1", PoleZero_cget_a1 ); //! filter coefficient |
| 4465 | func->doc = "get filter coefficient."; |
| 4466 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4467 | |
| 4468 | func = make_new_mfun( "float", "b0", PoleZero_ctrl_b0 ); //! filter coefficient |
| 4469 | func->add_arg( "float", "value" ); |
| 4470 | func->doc = "set filter coefficient."; |
| 4471 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4472 | |
| 4473 | func = make_new_mfun( "float", "b0", PoleZero_cget_b0 ); //! filter coefficient |
| 4474 | func->doc = "get filter coefficient."; |
| 4475 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4476 | |
| 4477 | func = make_new_mfun( "float", "b1", PoleZero_ctrl_b1 ); //! filter coefficient |
| 4478 | func->add_arg( "float", "value" ); |
| 4479 | func->doc = "set filter coefficient."; |
| 4480 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4481 | |
| 4482 | func = make_new_mfun( "float", "b1", PoleZero_cget_b1 ); //! filter coefficient |
| 4483 | func->doc = "get filter coefficient."; |
| 4484 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4485 | |
| 4486 | func = make_new_mfun( "float", "blockZero", PoleZero_ctrl_blockZero ); //! DC blocking filter with given pole position |
| 4487 | func->add_arg( "float", "value" ); |
| 4488 | func->doc = "set DC blocking filter with given pole position."; |
| 4489 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4490 | |
| 4491 | func = make_new_mfun( "float", "blockZero", PoleZero_cget_blockZero ); //! DC blocking filter with given pole position |
| 4492 | func->doc = "get DC blocking filter with given pole position."; |
| 4493 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4494 | |
| 4495 | func = make_new_mfun( "float", "allpass", PoleZero_ctrl_allpass ); //!allpass filter with given coefficient |
| 4496 | func->add_arg( "float", "value" ); |
| 4497 | func->doc = "set allpass filter with given coefficient."; |
| 4498 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4499 | |
| 4500 | func = make_new_mfun( "float", "allpass", PoleZero_cget_allpass ); //!allpass filter with given coefficient |
| 4501 | func->doc = "get allpass filter with given coefficient."; |
| 4502 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4503 | |
| 4504 | // add examples | 1.5.0.0 (ge) |
| 4505 | if( !type_engine_import_add_ex( env, "filter/dcblocker.ck" ) ) goto error; |
| 4506 | if( !type_engine_import_add_ex( env, "deep/plu2.ck" ) ) goto error; |
| 4507 | if( !type_engine_import_add_ex( env, "deep/plu3.ck" ) ) goto error; |
| 4508 | if( !type_engine_import_add_ex( env, "stk/flute.ck" ) ) goto error; |
| 4509 | if( !type_engine_import_add_ex( env, "analysis/tracking/pitch-track.ck" ) ) goto error; |
| 4510 | if( !type_engine_import_add_ex( env, "analysis/tracking/pitch-third.ck" ) ) goto error; |
| 4511 | if( !type_engine_import_add_ex( env, "analysis/tracking/pitch-fifth.ck" ) ) goto error; |
| 4512 | if( !type_engine_import_add_ex( env, "analysis/tracking/pitch-seventh.ck" ) ) goto error; |
| 4513 | if( !type_engine_import_add_ex( env, "analysis/tracking/Tracking.ck" ) ) goto error; |
| 4514 | |
| 4515 | // end the class import |
| 4516 | type_engine_import_class_end( env ); |
| 4517 | |
| 4518 | //end Filters |
| 4519 | |
| 4520 | //! \section stk-reverbs |
| 4521 | |
| 4522 | //------------------------------------------------------------------------ |
| 4523 | // begin JCRev ugen |
| 4524 | //------------------------------------------------------------------------ |
| 4525 | |
| 4526 | doc = "John Chowning's reverberator class. This class is derived from the CLM NRev function, which is based on the use of networks of simple allpass and comb delay filters. This particular arrangement consists of 6 comb filters in parallel, followed by 3 allpass filters, a lowpass filter, and another allpass in series, followed by two allpass filters in parallel with corresponding right and left outputs.\n\ |
| 4527 | \n\ |
| 4528 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4529 | |
| 4530 | if( !type_engine_import_ugen_begin( env, "JCRev", "UGen", env->global(), |
| 4531 | JCRev_ctor, JCRev_dtor, |
| 4532 | JCRev_tick, JCRev_pmsg, doc.c_str() ) ) return FALSE; |
| 4533 | |
| 4534 | //member variable |
| 4535 | JCRev_offset_data = type_engine_import_mvar ( env, "int", "@JCRev_data", FALSE ); |
| 4536 | if( JCRev_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4537 | |
| 4538 | // overload ctor( float mix ) |
| 4539 | func = make_new_ctor( JCRev_ctor_mix ); |
| 4540 | func->add_arg( "float", "mix" ); |
| 4541 | func->doc = "construct a JCRev with specified mix level."; |
| 4542 | if ( !type_engine_import_ctor( env, func ) ) goto error; |
| 4543 | |
| 4544 | func = make_new_mfun( "float", "mix", JCRev_ctrl_mix ); //! mix level |
| 4545 | func->add_arg( "float", "value" ); |
| 4546 | func->doc = "set mix level."; |
| 4547 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4548 | |
| 4549 | func = make_new_mfun( "float", "mix", JCRev_cget_mix ); //! mix level |
| 4550 | func->doc = "get mix level."; |
| 4551 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4552 | |
| 4553 | // add examples |
| 4554 | if( !type_engine_import_add_ex( env, "effects/reverb.ck" ) ) goto error; |
| 4555 | if( !type_engine_import_add_ex( env, "otf_06.ck" ) ) goto error; |
| 4556 | if( !type_engine_import_add_ex( env, "otf_07.ck" ) ) goto error; |
| 4557 | |
| 4558 | // end the class import |
| 4559 | type_engine_import_class_end( env ); |
| 4560 | |
| 4561 | |
| 4562 | //------------------------------------------------------------------------ |
| 4563 | // begin NRev ugen |
| 4564 | //------------------------------------------------------------------------ |
| 4565 | |
| 4566 | doc = "CCRMA's NRev reverberator class. This class is derived from the CLM NRev function, which is based on the use of networks of simple allpass and comb delay filters. This particular arrangement consists of 6 comb filters in parallel, followed by 3 allpass filters, a lowpass filter, and another allpass in series, followed by two allpass filters in parallel with corresponding rightand left outputs.\n\ |
| 4567 | \n\ |
| 4568 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4569 | |
| 4570 | if( !type_engine_import_ugen_begin( env, "NRev", "UGen", env->global(), |
| 4571 | NRev_ctor, NRev_dtor, |
| 4572 | NRev_tick, NRev_pmsg, doc.c_str() ) ) return FALSE; |
| 4573 | |
| 4574 | //member variable |
| 4575 | NRev_offset_data = type_engine_import_mvar ( env, "int", "@NRev_data", FALSE ); |
| 4576 | if( NRev_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4577 | |
| 4578 | // overload ctor( float mix ) |
| 4579 | func = make_new_ctor( NRev_ctor_mix ); |
| 4580 | func->add_arg( "float", "mix" ); |
| 4581 | func->doc = "construct an NRev with specified mix level."; |
| 4582 | if ( !type_engine_import_ctor( env, func ) ) goto error; |
| 4583 | |
| 4584 | func = make_new_mfun( "float", "mix", NRev_ctrl_mix ); // set effect mix |
| 4585 | func->add_arg( "float", "value" ); |
| 4586 | func->doc = "set mix level."; |
| 4587 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4588 | |
| 4589 | func = make_new_mfun( "float", "mix", NRev_cget_mix ); // set effect mix |
| 4590 | func->doc = "get mix level."; |
| 4591 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4592 | |
| 4593 | // add examples |
| 4594 | if( !type_engine_import_add_ex( env, "effects/reverb.ck" ) ) goto error; |
| 4595 | if( !type_engine_import_add_ex( env, "stk/krstlchr-algo7.ck" ) ) goto error; |
| 4596 | if( !type_engine_import_add_ex( env, "deep/thx.ck" ) ) goto error; |
| 4597 | |
| 4598 | // end the class import |
| 4599 | type_engine_import_class_end( env ); |
| 4600 | |
| 4601 | |
| 4602 | //------------------------------------------------------------------------ |
| 4603 | // begin PRCRev ugen |
| 4604 | //------------------------------------------------------------------------ |
| 4605 | |
| 4606 | doc = "Perry's simple reverberator class. This class is based on some of the famous Stanford/CCRMA reverbs (NRev, KipRev), which were based on the Chowning/Moorer/Schroeder reverberators using networks of simple allpass and comb delay filters. This class implements two series allpass units and two parallel comb filters.\n\ |
| 4607 | \n\ |
| 4608 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4609 | |
| 4610 | if( !type_engine_import_ugen_begin( env, "PRCRev", "UGen", env->global(), |
| 4611 | PRCRev_ctor, PRCRev_dtor, |
| 4612 | PRCRev_tick, PRCRev_pmsg, doc.c_str() ) ) return FALSE; |
| 4613 | |
| 4614 | //member variable |
| 4615 | PRCRev_offset_data = type_engine_import_mvar ( env, "int", "@PRCRev_data", FALSE ); |
| 4616 | if( PRCRev_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4617 | |
| 4618 | // overload ctor( float mix ) |
| 4619 | func = make_new_ctor( PRCRev_ctor_mix ); |
| 4620 | func->add_arg( "float", "mix" ); |
| 4621 | func->doc = "construct a PRCRev with specified mix level."; |
| 4622 | if ( !type_engine_import_ctor( env, func ) ) goto error; |
| 4623 | |
| 4624 | func = make_new_mfun( "float", "mix", PRCRev_ctrl_mix ); //! mix level |
| 4625 | func->add_arg( "float", "value" ); |
| 4626 | func->doc = "set mix level."; |
| 4627 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4628 | |
| 4629 | func = make_new_mfun( "float", "mix", PRCRev_cget_mix ); //! mix level |
| 4630 | func->doc = "get mix level."; |
| 4631 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4632 | |
| 4633 | // add example |
| 4634 | if( !type_engine_import_add_ex( env, "effects/reverb.ck" ) ) goto error; |
| 4635 | |
| 4636 | // end the class import |
| 4637 | type_engine_import_class_end( env ); |
| 4638 | |
| 4639 | //! \section components |
| 4640 | |
| 4641 | //------------------------------------------------------------------------ |
| 4642 | // begin Chorus ugen |
| 4643 | //------------------------------------------------------------------------ |
| 4644 | |
| 4645 | doc = "A chorus effect.\n\ |
| 4646 | \n\ |
| 4647 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4648 | |
| 4649 | if( !type_engine_import_ugen_begin( env, "Chorus", "UGen", env->global(), |
| 4650 | Chorus_ctor, Chorus_dtor, |
| 4651 | Chorus_tick, Chorus_pmsg, doc.c_str() ) ) return FALSE; |
| 4652 | |
| 4653 | //member variable |
| 4654 | Chorus_offset_data = type_engine_import_mvar ( env, "int", "@Chorus_data", FALSE ); |
| 4655 | if( Chorus_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4656 | |
| 4657 | // overload ctor( float modFreq ) |
| 4658 | func = make_new_ctor( Chorus_ctor_freq ); |
| 4659 | func->add_arg( "float", "modFreq" ); |
| 4660 | func->doc = "construct a Chorus with specified modulation frequency."; |
| 4661 | if ( !type_engine_import_ctor( env, func ) ) goto error; |
| 4662 | |
| 4663 | // overload ctor( float modFreq, float modDepth ) |
| 4664 | func = make_new_ctor( Chorus_ctor_freq_depth ); |
| 4665 | func->add_arg( "float", "modFreq" ); |
| 4666 | func->add_arg( "float", "modDepth" ); |
| 4667 | func->doc = "construct a Chorus with specified modulation frequency and modulation depth."; |
| 4668 | if ( !type_engine_import_ctor( env, func ) ) goto error; |
| 4669 | |
| 4670 | // overload ctor( float modFreq, float modDepth, float mix ) |
| 4671 | func = make_new_ctor( Chorus_ctor_freq_depth_mix ); |
| 4672 | func->add_arg( "float", "modFreq" ); |
| 4673 | func->add_arg( "float", "modDepth" ); |
| 4674 | func->add_arg( "float", "mix" ); |
| 4675 | func->doc = "construct a Chorus with specified modulation frequency, modulation depth, and effect mix."; |
| 4676 | if ( !type_engine_import_ctor( env, func ) ) goto error; |
| 4677 | |
| 4678 | func = make_new_mfun( "float", "modFreq", Chorus_ctrl_modFreq ); //! modulation frequency |
| 4679 | func->add_arg( "float", "value" ); |
| 4680 | func->doc = "set modulation frequency."; |
| 4681 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4682 | |
| 4683 | func = make_new_mfun( "float", "modFreq", Chorus_cget_modFreq ); //! modulation frequency |
| 4684 | func->doc = "get modulation frequency."; |
| 4685 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4686 | |
| 4687 | func = make_new_mfun( "float", "modDepth", Chorus_ctrl_modDepth ); //! modulation depth |
| 4688 | func->add_arg( "float", "value" ); |
| 4689 | func->doc = "set modulation depth."; |
| 4690 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4691 | |
| 4692 | func = make_new_mfun( "float", "modDepth", Chorus_cget_modDepth ); //! modulation depth |
| 4693 | func->doc = "get modulation depth."; |
| 4694 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4695 | |
| 4696 | func = make_new_mfun( "dur", "baseDelay", Chorus_ctrl_baseDelay ); //! base delay |
| 4697 | func->add_arg( "dur", "value" ); |
| 4698 | func->doc = "set base delay."; |
| 4699 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4700 | |
| 4701 | func = make_new_mfun( "dur", "baseDelay", Chorus_cget_baseDelay ); //! base delay |
| 4702 | func->doc = "get base delay."; |
| 4703 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4704 | |
| 4705 | func = make_new_mfun( "float", "mix", Chorus_ctrl_mix ); //! effect mix |
| 4706 | func->add_arg( "float", "value" ); |
| 4707 | func->doc = "set effect mix."; |
| 4708 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4709 | |
| 4710 | func = make_new_mfun( "float", "mix", Chorus_cget_mix ); //! effect mix |
| 4711 | func->doc = "get effect mix."; |
| 4712 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4713 | |
| 4714 | func = make_new_mfun( "void", "max", Chorus_ctrl_set ); |
| 4715 | func->add_arg( "dur", "baseDelay" ); |
| 4716 | func->add_arg( "float", "modDepth" ); |
| 4717 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4718 | |
| 4719 | // add examples |
| 4720 | if( !type_engine_import_add_ex( env, "effects/chorus.ck" ) ) goto error; |
| 4721 | |
| 4722 | // end the class import |
| 4723 | type_engine_import_class_end( env ); |
| 4724 | |
| 4725 | |
| 4726 | //------------------------------------------------------------------------ |
| 4727 | // begin Modulate ugen |
| 4728 | //------------------------------------------------------------------------ |
| 4729 | |
| 4730 | doc = "This class combines random and periodic modulations to give a nice, natural human modulation function.\n\ |
| 4731 | \n\ |
| 4732 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4733 | |
| 4734 | if( !type_engine_import_ugen_begin( env, "Modulate", "UGen", env->global(), |
| 4735 | Modulate_ctor, Modulate_dtor, |
| 4736 | Modulate_tick, Modulate_pmsg, doc.c_str() ) ) return FALSE; |
| 4737 | |
| 4738 | //member variable |
| 4739 | Modulate_offset_data = type_engine_import_mvar ( env, "int", "@Modulate_data", FALSE ); |
| 4740 | if( Modulate_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4741 | |
| 4742 | // overload ctor( float vibratoRate ) |
| 4743 | func = make_new_ctor( Modulate_ctor_rate ); |
| 4744 | func->add_arg( "float", "vibratoRate" ); |
| 4745 | func->doc = "construct a Modulate with specified vibrato rate."; |
| 4746 | if ( !type_engine_import_ctor( env, func ) ) goto error; |
| 4747 | |
| 4748 | // overload ctor( float vibratoRate, float vibratoGain ) |
| 4749 | func = make_new_ctor( Modulate_ctor_rate_gain ); |
| 4750 | func->add_arg( "float", "vibratoRate" ); |
| 4751 | func->add_arg( "float", "vibratoGain" ); |
| 4752 | func->doc = "construct a Modulate with specified vibrato rate and vibrato gain."; |
| 4753 | if ( !type_engine_import_ctor( env, func ) ) goto error; |
| 4754 | |
| 4755 | // overload ctor( float vibratoRate, float vibratoGain, float randomGain ) |
| 4756 | func = make_new_ctor( Modulate_ctor_rate_gain_random ); |
| 4757 | func->add_arg( "float", "vibratoRate" ); |
| 4758 | func->add_arg( "float", "vibratoGain" ); |
| 4759 | func->add_arg( "float", "randomGain" ); |
| 4760 | func->doc = "construct a Modulate with specified vibrato rate, vibrato gain, and random contribution gain."; |
| 4761 | if ( !type_engine_import_ctor( env, func ) ) goto error; |
| 4762 | |
| 4763 | func = make_new_mfun( "float", "vibratoRate", Modulate_ctrl_vibratoRate ); //! set rate of vibrato |
| 4764 | func->add_arg( "float", "value" ); |
| 4765 | func->doc = "set rate for vibrato."; |
| 4766 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4767 | |
| 4768 | func = make_new_mfun( "float", "vibratoRate", Modulate_cget_vibratoRate ); //! set rate of vibrato |
| 4769 | func->doc = "get rate for vibrato."; |
| 4770 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4771 | |
| 4772 | func = make_new_mfun( "float", "vibratoGain", Modulate_ctrl_vibratoGain ); //! gain for vibrato |
| 4773 | func->add_arg( "float", "value" ); |
| 4774 | func->doc = "set gain for vibrato."; |
| 4775 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4776 | |
| 4777 | func = make_new_mfun( "float", "vibratoGain", Modulate_cget_vibratoGain ); //! gain for vibrato |
| 4778 | func->doc = "get gain for vibrato."; |
| 4779 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4780 | |
| 4781 | func = make_new_mfun( "float", "randomGain", Modulate_ctrl_randomGain ); //! gain for random contribution |
| 4782 | func->add_arg( "float", "value" ); |
| 4783 | func->doc = "set gain for random contribution."; |
| 4784 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4785 | |
| 4786 | func = make_new_mfun( "float", "randomGain", Modulate_cget_randomGain ); //! gain for random contribution |
| 4787 | func->doc = "get gain for random contribution."; |
| 4788 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4789 | |
| 4790 | // add examples |
| 4791 | if( !type_engine_import_add_ex( env, "stk/modulate.ck" ) ) goto error; |
| 4792 | |
| 4793 | // end the class import |
| 4794 | type_engine_import_class_end( env ); |
| 4795 | |
| 4796 | |
| 4797 | //------------------------------------------------------------------------ |
| 4798 | // begin PitShift ugen |
| 4799 | //------------------------------------------------------------------------ |
| 4800 | |
| 4801 | doc = "This class implements a simple pitch shifter using delay lines.\n\ |
| 4802 | \n\ |
| 4803 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4804 | |
| 4805 | if( !type_engine_import_ugen_begin( env, "PitShift", "UGen", env->global(), |
| 4806 | PitShift_ctor, PitShift_dtor, |
| 4807 | PitShift_tick, PitShift_pmsg, doc.c_str() ) ) return FALSE; |
| 4808 | |
| 4809 | //member variable |
| 4810 | PitShift_offset_data = type_engine_import_mvar ( env, "int", "@PitShift_data", FALSE ); |
| 4811 | if( PitShift_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4812 | |
| 4813 | // overload ctor( float shift ) |
| 4814 | func = make_new_ctor( PitShift_ctor_shift ); |
| 4815 | func->add_arg( "float", "shift" ); |
| 4816 | func->doc = "construct a PitShift with specified degree of pitch shifting."; |
| 4817 | if ( !type_engine_import_ctor( env, func ) ) goto error; |
| 4818 | |
| 4819 | // overload ctor( float shift, float mix ) |
| 4820 | func = make_new_ctor( PitShift_ctor_shift_mix ); |
| 4821 | func->add_arg( "float", "shift" ); |
| 4822 | func->add_arg( "float", "mix" ); |
| 4823 | func->doc = "construct a PitShift with specified degree of pitch shifting and effect mix."; |
| 4824 | if ( !type_engine_import_ctor( env, func ) ) goto error; |
| 4825 | |
| 4826 | func = make_new_mfun( "float", "shift", PitShift_ctrl_shift ); //! degree of pitch shifting |
| 4827 | func->add_arg( "float", "value" ); |
| 4828 | func->doc = "set degree of pitch shifting"; |
| 4829 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4830 | |
| 4831 | func = make_new_mfun( "float", "shift", PitShift_cget_shift ); //! degree of pitch shifting |
| 4832 | func->doc = "get degree of pitch shifting"; |
| 4833 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4834 | |
| 4835 | func = make_new_mfun( "float", "mix", PitShift_ctrl_effectMix ); //! mix level |
| 4836 | func->add_arg( "float", "value" ); |
| 4837 | func->doc = "set mix level"; |
| 4838 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4839 | |
| 4840 | func = make_new_mfun( "float", "mix", PitShift_cget_effectMix ); //! mix level |
| 4841 | func->doc = "get mix level"; |
| 4842 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4843 | |
| 4844 | func = make_new_mfun( "float", "effectMix", PitShift_ctrl_effectMix ); //! mix level |
| 4845 | func->doc = "set effect mix level"; |
| 4846 | func->add_arg( "float", "value" ); |
| 4847 | |
| 4848 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4849 | |
| 4850 | func = make_new_mfun( "float", "effectMix", PitShift_cget_effectMix ); //! mix level |
| 4851 | func->doc = "get effect mix level"; |
| 4852 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4853 | |
| 4854 | // add examples | 1.5.0.0 (alex han) added |
| 4855 | if( !type_engine_import_add_ex( env, "effects/pitch-shift.ck" ) ) goto error; |
| 4856 | |
| 4857 | // end the class import |
| 4858 | type_engine_import_class_end( env ); |
| 4859 | |
| 4860 | |
| 4861 | //------------------------------------------------------------------------ |
| 4862 | // begin SubNoise ugen |
| 4863 | //------------------------------------------------------------------------ |
| 4864 | |
| 4865 | doc = "Generates a new random number every 'rate' ticks using the C `rand()` function. The quality of the r`and()` function varies from one OS to another.\n\ |
| 4866 | \n\ |
| 4867 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4868 | |
| 4869 | if( !type_engine_import_ugen_begin( env, "SubNoise", "UGen", env->global(), |
| 4870 | SubNoise_ctor, SubNoise_dtor, |
| 4871 | SubNoise_tick, SubNoise_pmsg, doc.c_str() ) ) return FALSE; |
| 4872 | |
| 4873 | //member variable |
| 4874 | SubNoise_offset_data = type_engine_import_mvar ( env, "int", "@SubNoise_data", FALSE ); |
| 4875 | if( SubNoise_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4876 | func = make_new_mfun( "int", "rate", SubNoise_ctrl_rate ); //! subsampling rate |
| 4877 | func->add_arg( "int", "value" ); |
| 4878 | func->doc = "set subsampling rate"; |
| 4879 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4880 | |
| 4881 | func = make_new_mfun( "int", "rate", SubNoise_cget_rate ); //! subsampling rate |
| 4882 | func->doc = "get subsampling rate"; |
| 4883 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4884 | |
| 4885 | // add examples |
| 4886 | if( !type_engine_import_add_ex( env, "stk/subnoise-control.ck" ) ) goto error; |
| 4887 | if( !type_engine_import_add_ex( env, "stk/subnoise-audio.ck" ) ) goto error; |
| 4888 | |
| 4889 | // end the class import |
| 4890 | type_engine_import_class_end( env ); |
| 4891 | |
| 4892 | //! \section stk - file i/o |
| 4893 | |
| 4894 | |
| 4895 | //------------------------------------------------------------------------ |
| 4896 | // begin WvIn ugen |
| 4897 | //------------------------------------------------------------------------ |
| 4898 | |
| 4899 | doc = "This class provides input support for various audio file formats. It also serves as a base class for 'realtime' streaming subclasses.\n\ |
| 4900 | \n\ |
| 4901 | WvIn loads the contents of an audio file for subsequent output. Linear interpolation is used for fractional 'read rates'.\n\ |
| 4902 | \n\ |
| 4903 | WvIn supports multi-channel data in interleaved format. It is important to distinguish the `tick()` methods, which return samples produced by averaging across sample frames, from the `tickFrame()` methods, which return pointers to multi-channel sample frames. For single-channel data, these methods return equivalent values. Small files are completely read into local memory during instantiation. Large files are read incrementally from disk. The file size threshold and the increment size values are defined in WvIn.h.\n\ |
| 4904 | \n\ |
| 4905 | WvIn currently supports WAV, AIFF, SND (AU), MAT-file (Matlab), and STK RAW file formats. Signed integer (8-, 16-, and 32-bit) and floating-point (32- and 64-bit) data types are supported. Uncompressed data types are not supported. If using MAT-files, data should be saved in an array with each data channel filling a matrix row.\n\ |
| 4906 | \n\ |
| 4907 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4908 | |
| 4909 | if( !type_engine_import_ugen_begin( env, "WvIn", "UGen", env->global(), |
| 4910 | WvIn_ctor, WvIn_dtor, |
| 4911 | WvIn_tick, WvIn_pmsg, doc.c_str() ) ) return FALSE; |
| 4912 | |
| 4913 | //member variable |
| 4914 | WvIn_offset_data = type_engine_import_mvar ( env, "int", "@WvIn_data", FALSE ); |
| 4915 | if( WvIn_offset_data == CK_INVALID_OFFSET ) goto error; |
| 4916 | func = make_new_mfun( "float", "rate", WvIn_ctrl_rate ); //! playback rate |
| 4917 | func->add_arg( "float", "value" ); |
| 4918 | func->doc = "set playback rate."; |
| 4919 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4920 | |
| 4921 | func = make_new_mfun( "float", "rate", WvIn_cget_rate ); //! playback rate |
| 4922 | func->doc = "get playback rate."; |
| 4923 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4924 | |
| 4925 | func = make_new_mfun( "string", "path", WvIn_ctrl_path ); //! specifies file to be played |
| 4926 | func->add_arg( "string", "value" ); |
| 4927 | func->doc = "set file to be played."; |
| 4928 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4929 | |
| 4930 | func = make_new_mfun( "string", "path", WvIn_cget_path ); //! specifies file to be played |
| 4931 | func->doc = "get file to be played."; |
| 4932 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4933 | |
| 4934 | |
| 4935 | // end the class import |
| 4936 | type_engine_import_class_end( env ); |
| 4937 | |
| 4938 | |
| 4939 | //------------------------------------------------------------------------ |
| 4940 | // begin WaveLoop ugen |
| 4941 | //------------------------------------------------------------------------ |
| 4942 | |
| 4943 | doc = "This class inherits from WvIn and provides audio file looping functionality.\n\ |
| 4944 | \n\ |
| 4945 | WaveLoop supports multi-channel data in interleaved format. It is important to distinguish the `tick()` methods, which return samples produced by averaging across sample frames, from the `tickFrame()` methods, which return pointers to multi-channel sample frames. For single-channel data, these methods return equivalent values.\n\ |
| 4946 | \n\ |
| 4947 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4948 | |
| 4949 | //! see \example dope.ck |
| 4950 | if( !type_engine_import_ugen_begin( env, "WaveLoop", "WvIn", env->global(), |
| 4951 | WaveLoop_ctor, WaveLoop_dtor, |
| 4952 | WaveLoop_tick, WaveLoop_pmsg, doc.c_str() ) ) return FALSE; |
| 4953 | |
| 4954 | func = make_new_mfun( "float", "freq", WaveLoop_ctrl_freq ); //! set frequency of playback ( loops / second ) |
| 4955 | func->add_arg( "float", "value" ); |
| 4956 | func->doc = "set frequency of playback (loops/second)."; |
| 4957 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4958 | |
| 4959 | func = make_new_mfun( "float", "freq", WaveLoop_cget_freq ); //! set frequency of playback ( loops / second ) |
| 4960 | func->doc = "get frequency of playback (loops/second)."; |
| 4961 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4962 | |
| 4963 | func = make_new_mfun( "float", "addPhase", WaveLoop_ctrl_phase ); //! offset by phase |
| 4964 | func->add_arg( "float", "value" ); |
| 4965 | func->doc = "set offset by phase."; |
| 4966 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4967 | |
| 4968 | func = make_new_mfun( "float", "addPhase", WaveLoop_cget_phase ); //! offset by phase |
| 4969 | func->doc = "get offset by phase."; |
| 4970 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4971 | |
| 4972 | func = make_new_mfun( "float", "addPhaseOffset", WaveLoop_ctrl_phaseOffset ); //! set phase offset |
| 4973 | func->add_arg( "float", "value" ); |
| 4974 | func->doc = "set phase offset."; |
| 4975 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4976 | |
| 4977 | func = make_new_mfun( "float", "addPhaseOffset", WaveLoop_cget_phaseOffset ); //! set phase offset |
| 4978 | func->doc = "get phase offset."; |
| 4979 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 4980 | |
| 4981 | // end the class import |
| 4982 | type_engine_import_class_end( env ); |
| 4983 | |
| 4984 | |
| 4985 | #ifndef __DISABLE_WVOUT__ |
| 4986 | //------------------------------------------------------------------------ |
| 4987 | // begin WvOut ugen |
| 4988 | //------------------------------------------------------------------------ |
| 4989 | |
| 4990 | doc = "This class provides output support for various audio file formats. It also serves as a base class for 'realtime' streaming subclasses.\n\ |
| 4991 | \n\ |
| 4992 | WvOut writes samples to an audio file. It supports multi-channel data in interleaved format. It is important to distinguish the `tick()` methods, which output single samples to all channels in a sample frame, from the `tickFrame()` method, which takes a pointer to multi-channel sample frame data.\n\ |
| 4993 | \n\ |
| 4994 | WvOut currently supports WAV, AIFF, AIFC, SND (AU), MAT-file (Matlab), and STK RAW file formats. Signed integer (8-, 16-, and 32-bit) and floating- point (32- and 64-bit) data types are supported. STK RAW files use 16-bit integers by definition. MAT-files will always be written as 64-bit floats. If a data type specification does not match the specified file type, the data type will automatically be modified. Uncompressed data types are not supported.\n\ |
| 4995 | \n\ |
| 4996 | Currently, WvOut is non-interpolating and the output rate is always `Stk::sampleRate()`.\n\ |
| 4997 | \n\ |
| 4998 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; |
| 4999 | |
| 5000 | if( !type_engine_import_ugen_begin( env, "WvOut", "UGen", env->global(), |
| 5001 | WvOut_ctor, WvOut_dtor, WvOut_tick, WvOut_pmsg, doc.c_str() ) ) return FALSE; |
| 5002 | |
| 5003 | //member variable |
| 5004 | WvOut_offset_data = type_engine_import_mvar ( env, "int", "@WvOut_data", FALSE ); |
| 5005 | if( WvOut_offset_data == CK_INVALID_OFFSET ) goto error; |
| 5006 | |
| 5007 | func = make_new_mfun( "string", "aifFilename", WvOut_ctrl_aifFilename ); //!open AIFF file for writing |
| 5008 | func->add_arg( "string", "value" ); |
| 5009 | func->doc = "open an AIFF file for writing (with default datatype IO.INT16)."; |
| 5010 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5011 | |
| 5012 | func = make_new_mfun( "string", "aifFilename", WvOut_ctrl_aifFilename2 ); //!open AIFF file for writing |
| 5013 | func->add_arg( "string", "value" ); |
| 5014 | func->add_arg( "int", "datatype" ); |
| 5015 | func->doc = "open an AIFF file for writing, with datatype (e.g., IO.INT16, IO.INT24, IO.INT32, IO.FLOAT32, IO.FLOAT64)."; |
| 5016 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5017 | |
| 5018 | func = make_new_mfun( "string", "matFilename", WvOut_ctrl_matFilename ); //!open matlab file for writing |
| 5019 | func->add_arg( "string", "value" ); |
| 5020 | func->doc = "open MATLAB file for writing (with default datatype IO.FLOAT64)."; |
| 5021 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5022 | |
| 5023 | func = make_new_mfun( "string", "matFilename", WvOut_ctrl_matFilename2 ); //!open matlab file for writing |
| 5024 | func->add_arg( "string", "value" ); |
| 5025 | func->add_arg( "int", "datatype" ); |
| 5026 | func->doc = "open MATLAB file for writing; datatype for MATLAB files can only be IO.FLOAT64."; |
| 5027 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5028 | |
| 5029 | func = make_new_mfun( "string", "sndFilename", WvOut_ctrl_sndFilename ); //!open snd file for writing |
| 5030 | func->add_arg( "string", "value" ); |
| 5031 | func->doc = "open SND file for writing (with default datatype IO.INT16)."; |
| 5032 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5033 | |
| 5034 | func = make_new_mfun( "string", "sndFilename", WvOut_ctrl_sndFilename2 ); //!open snd file for writing |
| 5035 | func->add_arg( "string", "value" ); |
| 5036 | func->add_arg( "int", "datatype" ); |
| 5037 | func->doc = "open SND file for writing, with datatype (e.g., IO.INT16, IO.INT24, IO.INT32, IO.FLOAT32, IO.FLOAT64)."; |
| 5038 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5039 | |
| 5040 | func = make_new_mfun( "string", "wavFilename", WvOut_ctrl_wavFilename ); //!open WAVE file for writing |
| 5041 | func->add_arg( "string", "value" ); |
| 5042 | func->doc = "open WAVE file for writing (with default datatype IO.INT16)."; |
| 5043 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5044 | |
| 5045 | func = make_new_mfun( "string", "wavFilename", WvOut_ctrl_wavFilename2 ); //!open WAVE file for writing |
| 5046 | func->add_arg( "string", "value" ); |
| 5047 | func->add_arg( "int", "datatype" ); |
| 5048 | func->doc = "open WAVE file for writing, with datatype (e.g., IO.INT16, IO.INT24, IO.INT32, IO.FLOAT32, IO.FLOAT64)."; |
| 5049 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5050 | |
| 5051 | func = make_new_mfun( "string", "rawFilename", WvOut_ctrl_rawFilename ); //!open raw file for writing |
| 5052 | func->add_arg( "string", "value" ); |
| 5053 | func->doc = "open a RAW file for writing (note: raw audio files are mono and 16-bit)."; |
| 5054 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5055 | |
| 5056 | func = make_new_mfun( "string", "rawFilename", WvOut_ctrl_rawFilename2 ); //!open raw file for writing |
| 5057 | func->add_arg( "string", "value" ); |
| 5058 | func->add_arg( "int", "datatype" ); |
| 5059 | func->doc = "open a RAW file for writing; datatype for raw files can only be IO.INT16."; |
| 5060 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5061 | |
| 5062 | func = make_new_mfun( "string", "filename", WvOut_cget_filename ); //!get filename |
| 5063 | func->doc = "get filename."; |
| 5064 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5065 | |
| 5066 | func = make_new_mfun( "int", "record", WvOut_ctrl_record ); // !start/stop output |
| 5067 | func->add_arg( "int", "value" ); |
| 5068 | func->doc = "start/stop output."; |
| 5069 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5070 | |
| 5071 | func = make_new_mfun( "int", "record", WvOut_cget_record ); // !start/stop output |
| 5072 | func->doc = "start/stop output."; |
| 5073 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5074 | |
| 5075 | func = make_new_mfun( "string", "closeFile", WvOut_ctrl_closeFile ); //! close file properly |
| 5076 | func->add_arg( "string", "value" ); |
| 5077 | func->doc = "close the file properly."; |
| 5078 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5079 | |
| 5080 | func = make_new_mfun( "string", "closeFile", WvOut_ctrl_closeFile ); //! close file properly |
| 5081 | func->doc = "close the file properly."; |
| 5082 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5083 | |
| 5084 | func = make_new_mfun( "string", "autoPrefix", WvOut_ctrl_autoPrefix ); //! set/get auto prefix string |
| 5085 | func->add_arg( "string", "value" ); |
| 5086 | func->doc = "set auto prefix string for \"special:auto\" filename generation."; |
| 5087 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5088 | |
| 5089 | func = make_new_mfun( "string", "autoPrefix", WvOut_cget_autoPrefix ); //! set/get auto prefix string |
| 5090 | func->doc = "get auto prefix string for \"special:auto\" filename generation."; |
| 5091 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5092 | |
| 5093 | func = make_new_mfun( "float", "fileGain", WvOut_ctrl_fileGain ); //! set/get auto prefix string |
| 5094 | func->add_arg( "float", "value" ); |
| 5095 | func->doc = "set file gain."; |
| 5096 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5097 | |
| 5098 | func = make_new_mfun( "float", "fileGain", WvOut_cget_fileGain ); //! set/get auto prefix string |
| 5099 | func->doc = "get file gain."; |
| 5100 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5101 | |
| 5102 | // add examples | 1.5.0.0 (ge) added |
| 5103 | if( !type_engine_import_add_ex( env, "basic/rec.ck" ) ) goto error; |
| 5104 | if( !type_engine_import_add_ex( env, "basic/rec-auto.ck" ) ) goto error; |
| 5105 | if( !type_engine_import_add_ex( env, "basic/rec-auto-stereo.ck" ) ) goto error; |
| 5106 | if( !type_engine_import_add_ex( env, "stk/wvout-24bit.ck" ) ) goto error; |
| 5107 | |
| 5108 | // end the class import |
| 5109 | type_engine_import_class_end( env ); |
| 5110 | |
| 5111 | // description |
| 5112 | doc = "WvOut2 is the stereo version of WvOut; opens and writes a 2-channel audio file; see WvOut for usage."; |
| 5113 | |
| 5114 | // start WvOut2 import |
| 5115 | if( !type_engine_import_ugen_begin( env, "WvOut2", "WvOut", env->global(), |
| 5116 | NULL, NULL, |
| 5117 | NULL, WvOut2_tickf, WvOut_pmsg, 2, 2, doc.c_str() ) ) return FALSE; |
| 5118 | |
| 5119 | // add examples | 1.5.0.0 (ge) added |
| 5120 | if( !type_engine_import_add_ex( env, "basic/rec.ck" ) ) goto error; |
| 5121 | if( !type_engine_import_add_ex( env, "basic/rec-auto.ck" ) ) goto error; |
| 5122 | if( !type_engine_import_add_ex( env, "basic/rec-auto-stereo.ck" ) ) goto error; |
| 5123 | if( !type_engine_import_add_ex( env, "stk/wvout-24bit.ck" ) ) goto error; |
| 5124 | |
| 5125 | // end the class import |
| 5126 | type_engine_import_class_end( env ); |
| 5127 | #endif //__DISABLE_WVOUT__ |
| 5128 | |
| 5129 | |
| 5130 | //------------------------------------------------------------------------ |
| 5131 | // begin BLT (BandLtd) |
| 5132 | //------------------------------------------------------------------------ |
| 5133 | |
| 5134 | doc = "super-class for band-limited oscillators."; |
| 5135 | |
| 5136 | if( !type_engine_import_ugen_begin( env, "BLT", "UGen", env->global(), |
| 5137 | BLT_ctor, BLT_dtor, |
| 5138 | BLT_tick, BLT_pmsg, doc.c_str()) ) return FALSE; |
| 5139 | |
| 5140 | // member variable |
| 5141 | // all subclasses of BLT must use this offset, as this is where the |
| 5142 | // inherited functions will look for the object |
| 5143 | // the other option would be to keep SubClass_offset_data, but assign |
| 5144 | // the value to BLT_offset_data. |
| 5145 | BLT_offset_data = type_engine_import_mvar( env, "int", "@BLT_data", FALSE ); |
| 5146 | if( BLT_offset_data == CK_INVALID_OFFSET ) goto error; |
| 5147 | |
| 5148 | func = make_new_mfun( "float", "phase", BLT_ctrl_phase ); //!set phase |
| 5149 | func->add_arg( "float", "value" ); |
| 5150 | func->doc = "set phase."; |
| 5151 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5152 | |
| 5153 | func = make_new_mfun( "float", "phase", BLT_cget_phase ); //!get phase |
| 5154 | func->doc = "get phase."; |
| 5155 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5156 | |
| 5157 | func = make_new_mfun( "float", "freq", BLT_ctrl_freq ); //!set freq |
| 5158 | func->add_arg( "float", "value" ); |
| 5159 | func->doc = "set frequency."; |
| 5160 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5161 | |
| 5162 | func = make_new_mfun( "float", "freq", BLT_cget_freq ); //!get freq |
| 5163 | func->doc = "set frequency."; |
| 5164 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5165 | |
| 5166 | func = make_new_mfun( "int", "harmonics", BLT_ctrl_harmonics ); //!set harmonics |
| 5167 | func->add_arg( "int", "value" ); |
| 5168 | func->doc = "set harmonics."; |
| 5169 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5170 | |
| 5171 | func = make_new_mfun( "int", "harmonics", BLT_cget_harmonics ); //!get harmonics |
| 5172 | func->doc = "get harmonics."; |
| 5173 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5174 | |
| 5175 | // end the class import |
| 5176 | type_engine_import_class_end( env ); |
| 5177 | |
| 5178 | |
| 5179 | //------------------------------------------------------------------------ |
| 5180 | // begin Blit |
| 5181 | //------------------------------------------------------------------------ |
| 5182 | |
| 5183 | doc = "This class generates a band-limited impulse train using a closed-form algorithm reported by Stilson and Smith in 'Alias-Free Digital Synthesis of Classic Analog Waveforms', 1996. The user can specify both the fundamental frequency of the impulse train and the number of harmonics contained in the resulting signal.\n\ |
| 5184 | \n\ |
| 5185 | The signal is normalized so that the peak value is +/-1.0.\n\ |
| 5186 | \n\ |
| 5187 | If `nHarmonics` is 0, then the signal will contain all harmonics up to half the sample rate. Note, however, that this setting may produce aliasing in the signal when the frequency is changing (no automatic modification of the number of harmonics is performed by the `setFrequency()` function).\n\ |
| 5188 | \n\ |
| 5189 | Original code by Robin Davies, 2005.\n\ |
| 5190 | Revisions by Gary Scavone for STK, 2005."; |
| 5191 | |
| 5192 | if( !type_engine_import_ugen_begin( env, "Blit", "BLT", env->global(), |
| 5193 | Blit_ctor, Blit_dtor, Blit_tick, Blit_pmsg, doc.c_str() ) ) return FALSE; |
| 5194 | |
| 5195 | type_engine_import_add_ex(env, "basic/blit.ck"); |
| 5196 | type_engine_import_add_ex(env, "basic/blit2.ck"); |
| 5197 | type_engine_import_add_ex(env, "basic/foo2.ck"); |
| 5198 | |
| 5199 | // end the class import |
| 5200 | type_engine_import_class_end( env ); |
| 5201 | |
| 5202 | |
| 5203 | //------------------------------------------------------------------------ |
| 5204 | // begin BlitSaw |
| 5205 | //------------------------------------------------------------------------ |
| 5206 | |
| 5207 | doc = "This class generates a band-limited sawtooth waveform using a closed-form algorithm reported by Stilson and Smith in 'Alias-Free Digital Synthesis of Classic Analog Waveforms', 1996. The user can specify both the fundamental frequency of the sawtooth and the number of harmonics contained in the resulting signal.\n\ |
| 5208 | \n\ |
| 5209 | If `nHarmonics` is 0, then the signal will contain all harmonics up to half the sample rate. Note, however, that this setting may produce aliasing in the signal when the frequency is changing (no automatic modification of the number of harmonics is performed by the `setFrequency()` function).\n\ |
| 5210 | \n\ |
| 5211 | Based on initial code of Robin Davies, 2005.\n\ |
| 5212 | Modified algorithm code by Gary Scavone, 2005."; |
| 5213 | |
| 5214 | if( !type_engine_import_ugen_begin( env, "BlitSaw", "BLT", env->global(), |
| 5215 | BlitSaw_ctor, BlitSaw_dtor, BlitSaw_tick, BlitSaw_pmsg, doc.c_str() ) ) return FALSE; |
| 5216 | |
| 5217 | // end the class import |
| 5218 | type_engine_import_class_end( env ); |
| 5219 | |
| 5220 | |
| 5221 | //------------------------------------------------------------------------ |
| 5222 | // begin BlitSquare |
| 5223 | //------------------------------------------------------------------------ |
| 5224 | |
| 5225 | doc = "This class generates a band-limited square wave signal. It is derived in part from the approach reported by Stilson and Smith in 'Alias-Free Digital Synthesis of Classic Analog Waveforms', 1996. The algorithm implemented in this class uses a SincM function with an even M value to achieve a bipolar bandlimited impulse train. This signal is then integrated to achieve a square waveform. The integration process has an associated DC offset but that is subtracted off the output signal.\n\ |
| 5226 | \n\ |
| 5227 | The user can specify both the fundamental frequency of the waveform and the number of harmonics contained in the resulting signal.\n\ |
| 5228 | \n\ |
| 5229 | If `nHarmonics` is 0, then the signal will contain all harmonics up to half the sample rate. Note, however, that this setting may produce aliasing in the signal when the frequency is changing (no automatic modification of the number of harmonics is performed by the `setFrequency()` function).\n\ |
| 5230 | \n\ |
| 5231 | Based on initial code of Robin Davies, 2005.\n\ |
| 5232 | Modified algorithm code by Gary Scavone, 2005."; |
| 5233 | |
| 5234 | if( !type_engine_import_ugen_begin( env, "BlitSquare", "BLT", env->global(), |
| 5235 | BlitSquare_ctor, BlitSquare_dtor, |
| 5236 | BlitSquare_tick, BlitSquare_pmsg, doc.c_str() ) ) return FALSE; |
| 5237 | |
| 5238 | // end the class import |
| 5239 | type_engine_import_class_end( env ); |
| 5240 | |
| 5241 | |
| 5242 | //------------------------------------------------------------------------ |
| 5243 | // begin JetTable |
| 5244 | //------------------------------------------------------------------------ |
| 5245 | |
| 5246 | if( !type_engine_import_ugen_begin( env, "JetTabl", "UGen", env->global(), |
| 5247 | JetTabl_ctor, JetTabl_dtor, JetTabl_tick, JetTabl_pmsg ) ) return FALSE; |
| 5248 | |
| 5249 | // member variable |
| 5250 | JetTabl_offset_data = type_engine_import_mvar( env, "int", "@JetTabl_data", FALSE ); |
| 5251 | if( JetTabl_offset_data == CK_INVALID_OFFSET ) goto error; |
| 5252 | |
| 5253 | // end the class import |
| 5254 | type_engine_import_class_end( env ); |
| 5255 | |
| 5256 | // Mesh2D |
| 5257 | // 1.5.0.0 (ge) commented out, using the chugin Mesh2D |
| 5258 | /* |
| 5259 | if( !type_engine_import_ugen_begin( env, "Mesh2D", "UGen", env->global(), |
| 5260 | Mesh2D_ctor, Mesh2D_dtor, |
| 5261 | Mesh2D_tick, Mesh2D_pmsg ) ) return FALSE; |
| 5262 | //member variable |
| 5263 | Mesh2D_offset_data = type_engine_import_mvar ( env, "int", "@Mesh2D_data", FALSE ); |
| 5264 | if( Mesh2D_offset_data == CK_INVALID_OFFSET ) goto error; |
| 5265 | |
| 5266 | func = make_new_mfun( "int", "nx", Mesh2D_ctrl_nx ); //! nx |
| 5267 | func->add_arg( "int", "value" ); |
| 5268 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5269 | |
| 5270 | func = make_new_mfun( "int", "nx", Mesh2D_cget_nx ); //! nx |
| 5271 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5272 | |
| 5273 | func = make_new_mfun( "int", "ny", Mesh2D_ctrl_ny ); //! nx |
| 5274 | func->add_arg( "int", "value" ); |
| 5275 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5276 | |
| 5277 | func = make_new_mfun( "int", "ny", Mesh2D_cget_ny ); //! nx |
| 5278 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5279 | |
| 5280 | func = make_new_mfun( "float", "inputPosition", Mesh2D_ctrl_input_position ); //! nx |
| 5281 | func->add_arg( "float", "xval" ); |
| 5282 | func->add_arg( "float", "yval" ); |
| 5283 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5284 | |
| 5285 | func = make_new_mfun( "float", "decay", Mesh2D_ctrl_decay ); //! nx |
| 5286 | func->add_arg( "float", "value" ); |
| 5287 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5288 | |
| 5289 | func = make_new_mfun( "float", "energy", Mesh2D_cget_energy ); //! nx |
| 5290 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5291 | |
| 5292 | func = make_new_mfun( "float", "noteOn", Mesh2D_ctrl_note_on ); //! start |
| 5293 | func->add_arg( "float", "note" ); |
| 5294 | func->add_arg( "float", "vel" ); |
| 5295 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5296 | |
| 5297 | func = make_new_mfun( "float", "noteOff", Mesh2D_ctrl_note_off ); //! stop |
| 5298 | func->add_arg( "float", "value" ); |
| 5299 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5300 | |
| 5301 | func = make_new_mfun( "int", "controlChange", Mesh2D_ctrl_control_change ); //! select instrument |
| 5302 | func->add_arg( "int", "ctrl" ); |
| 5303 | func->add_arg( "float", "value" ); |
| 5304 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5305 | |
| 5306 | // end the class import |
| 5307 | type_engine_import_class_end( env ); |
| 5308 | */ |
| 5309 | |
| 5310 | // MidiFileIn |
| 5311 | if(!type_engine_import_class_begin( env, "MidiFileIn", "Object", env->global(), MidiFileIn_ctor, MidiFileIn_dtor, |
| 5312 | "Class for reading data from a MIDI file." ) ) |
| 5313 | return FALSE; |
| 5314 | |
| 5315 | MidiFileIn_offset_data = type_engine_import_mvar ( env, "int", "@MidiFileIn_data", FALSE ); |
| 5316 | if( MidiFileIn_offset_data == CK_INVALID_OFFSET ) goto error; |
| 5317 | |
| 5318 | func = make_new_mfun( "int", "open", MidiFileIn_open ); |
| 5319 | func->add_arg( "string", "path" ); |
| 5320 | func->doc = "Open a MIDI file."; |
| 5321 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5322 | |
| 5323 | func = make_new_mfun( "void", "close", MidiFileIn_close ); |
| 5324 | func->doc = "Close the MIDI file."; |
| 5325 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5326 | |
| 5327 | func = make_new_mfun( "int", "read", MidiFileIn_read ); |
| 5328 | func->add_arg( "MidiMsg", "msg" ); |
| 5329 | func->doc = "Read next MIDI Event (on default track 0); return contents in 'msg'."; |
| 5330 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5331 | |
| 5332 | func = make_new_mfun( "int", "read", MidiFileIn_readTrack ); |
| 5333 | func->add_arg( "MidiMsg", "msg" ); |
| 5334 | func->add_arg( "int", "track" ); |
| 5335 | func->doc = "Read next MIDI Event on track 'track'; return contents in 'msg'."; |
| 5336 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5337 | |
| 5338 | func = make_new_mfun( "int", "numTracks", MidiFileIn_numTracks ); |
| 5339 | func->doc = "Get the number of tracks in the open MIDI file."; |
| 5340 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5341 | |
| 5342 | func = make_new_mfun( "int", "ticksPerQuarter", MidiFileIn_ticksPerQuarter ); |
| 5343 | func->doc = "Get the ticks per quarter (TPQ) value from the MIDI file header."; |
| 5344 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5345 | |
| 5346 | func = make_new_mfun( "int", "tpq", MidiFileIn_ticksPerQuarter ); |
| 5347 | func->doc = "Same as ticksPerQuarter()."; |
| 5348 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5349 | |
| 5350 | func = make_new_mfun( "float", "beatsPerMinute", MidiFileIn_beatsPerMinute ); |
| 5351 | func->doc = "Get the beats per minute (BPM) value from the MIDI file header."; |
| 5352 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5353 | |
| 5354 | func = make_new_mfun( "float", "bpm", MidiFileIn_beatsPerMinute ); |
| 5355 | func->doc = "Same as beatsPerMinute()."; |
| 5356 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5357 | |
| 5358 | func = make_new_mfun( "void", "rewind", MidiFileIn_rewind ); |
| 5359 | func->doc = "Rewind MIDI reader to beginning of default track 0."; |
| 5360 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5361 | |
| 5362 | func = make_new_mfun( "void", "rewind", MidiFileIn_rewindTrack ); |
| 5363 | func->add_arg( "int", "track" ); |
| 5364 | func->doc = "Rewind MIDI reader to beginning of track 'track'."; |
| 5365 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 5366 | |
| 5367 | // add examples | 1.5.0.0 |
| 5368 | type_engine_import_add_ex( env, "midi/midifile-play.ck" ); |
| 5369 | type_engine_import_add_ex( env, "midi/bwv772.mid" ); |
| 5370 | |
| 5371 | // end the class import |
| 5372 | type_engine_import_class_end( env ); |
| 5373 | |
| 5374 | |
| 5375 | return TRUE; |
| 5376 | |
| 5377 | //error recovery - end class and throw flag... |
| 5378 | error: |
| 5379 | |
| 5380 | // end the class import |
| 5381 | type_engine_import_class_end( env ); |
| 5382 | |
| 5383 | return FALSE; |
| 5384 | |
| 5385 | } |
| 5386 | |
| 5387 | |
| 5388 | |
| 5389 | |
| 5390 | struct SKINISpec { char messageString[32]; |
| 5391 | long type; |
| 5392 | long data2; |
| 5393 | long data3; |
| 5394 | }; |
| 5395 | |
| 5396 | /* SEE COMMENT BLOCK AT BOTTOM FOR FIELDS AND USES */ |
| 5397 | /* MessageString ,type, ch?, data2 , data3 */ |
| 5398 | |
| 5399 | struct SKINISpec skini_msgs[__SK_MaxMsgTypes_] = |
| 5400 | { |
| 5401 | {"NoteOff" , __SK_NoteOff_, SK_DBL, SK_DBL}, |
| 5402 | {"NoteOn" , __SK_NoteOn_, SK_DBL, SK_DBL}, |
| 5403 | {"PolyPressure" , __SK_PolyPressure_, SK_DBL, SK_DBL}, |
| 5404 | {"ControlChange" , __SK_ControlChange_, SK_INT, SK_DBL}, |
| 5405 | {"ProgramChange" , __SK_ProgramChange_, SK_DBL, SK_DBL}, |
| 5406 | {"AfterTouch" , __SK_AfterTouch_, SK_DBL, NOPE}, |
| 5407 | {"ChannelPressure" ,__SK_ChannelPressure_, SK_DBL, NOPE}, |
| 5408 | {"PitchWheel" , __SK_PitchWheel_, SK_DBL, NOPE}, |
| 5409 | {"PitchBend" , __SK_PitchBend_, SK_DBL, NOPE}, |
| 5410 | {"PitchChange" , __SK_PitchChange_, SK_DBL, NOPE}, |
| 5411 | |
| 5412 | {"Clock" , __SK_Clock_, NOPE, NOPE}, |
| 5413 | {"Undefined" , 249, NOPE, NOPE}, |
| 5414 | {"SongStart" , __SK_SongStart_, NOPE, NOPE}, |
| 5415 | {"Continue" , __SK_Continue_, NOPE, NOPE}, |
| 5416 | {"SongStop" , __SK_SongStop_, NOPE, NOPE}, |
| 5417 | {"Undefined" , 253, NOPE, NOPE}, |
| 5418 | {"ActiveSensing" , __SK_ActiveSensing_, NOPE, NOPE}, |
| 5419 | {"SystemReset" , __SK_SystemReset_, NOPE, NOPE}, |
| 5420 | |
| 5421 | {"Volume" , __SK_ControlChange_, __SK_Volume_ , SK_DBL}, |
| 5422 | {"ModWheel" , __SK_ControlChange_, __SK_ModWheel_ , SK_DBL}, |
| 5423 | {"Modulation" , __SK_ControlChange_, __SK_Modulation_ , SK_DBL}, |
| 5424 | {"Breath" , __SK_ControlChange_, __SK_Breath_ , SK_DBL}, |
| 5425 | {"FootControl" , __SK_ControlChange_, __SK_FootControl_ , SK_DBL}, |
| 5426 | {"Portamento" , __SK_ControlChange_, __SK_Portamento_ , SK_DBL}, |
| 5427 | {"Balance" , __SK_ControlChange_, __SK_Balance_ , SK_DBL}, |
| 5428 | {"Pan" , __SK_ControlChange_, __SK_Pan_ , SK_DBL}, |
| 5429 | {"Sustain" , __SK_ControlChange_, __SK_Sustain_ , SK_DBL}, |
| 5430 | {"Damper" , __SK_ControlChange_, __SK_Damper_ , SK_DBL}, |
| 5431 | {"Expression" , __SK_ControlChange_, __SK_Expression_ , SK_DBL}, |
| 5432 | |
| 5433 | {"NoiseLevel" , __SK_ControlChange_, __SK_NoiseLevel_ , SK_DBL}, |
| 5434 | {"PickPosition" , __SK_ControlChange_, __SK_PickPosition_ , SK_DBL}, |
| 5435 | {"StringDamping" , __SK_ControlChange_, __SK_StringDamping_ , SK_DBL}, |
| 5436 | {"StringDetune" , __SK_ControlChange_, __SK_StringDetune_ , SK_DBL}, |
| 5437 | {"BodySize" , __SK_ControlChange_, __SK_BodySize_ , SK_DBL}, |
| 5438 | {"BowPressure" , __SK_ControlChange_, __SK_BowPressure_ , SK_DBL}, |
| 5439 | {"BowPosition" , __SK_ControlChange_, __SK_BowPosition_ , SK_DBL}, |
| 5440 | {"BowBeta" , __SK_ControlChange_, __SK_BowBeta_ , SK_DBL}, |
| 5441 | |
| 5442 | {"ReedStiffness" , __SK_ControlChange_, __SK_ReedStiffness_ , SK_DBL}, |
| 5443 | {"ReedRestPos" , __SK_ControlChange_, __SK_ReedRestPos_ , SK_DBL}, |
| 5444 | {"FluteEmbouchure" , __SK_ControlChange_, __SK_FluteEmbouchure_, SK_DBL}, |
| 5445 | {"LipTension" , __SK_ControlChange_, __SK_LipTension_ , SK_DBL}, |
| 5446 | {"StrikePosition" , __SK_ControlChange_, __SK_StrikePosition_, SK_DBL}, |
| 5447 | {"StickHardness" , __SK_ControlChange_, __SK_StickHardness_ , SK_DBL}, |
| 5448 | |
| 5449 | {"TrillDepth" , __SK_ControlChange_, __SK_TrillDepth_ , SK_DBL}, |
| 5450 | {"TrillSpeed" , __SK_ControlChange_, __SK_TrillSpeed_ , SK_DBL}, |
| 5451 | |
| 5452 | {"Strumming" , __SK_ControlChange_, __SK_Strumming_ , 127 }, |
| 5453 | {"NotStrumming" , __SK_ControlChange_, __SK_Strumming_ , 0 }, |
| 5454 | |
| 5455 | {"PlayerSkill" , __SK_ControlChange_, __SK_PlayerSkill_ , SK_DBL}, |
| 5456 | |
| 5457 | {"Chord" , __SK_Chord_ , SK_DBL , SK_STR }, |
| 5458 | {"ChordOff" , __SK_ChordOff_ , SK_DBL , NOPE }, |
| 5459 | |
| 5460 | {"ShakerInst" , __SK_ControlChange_, __SK_ShakerInst_ , SK_DBL}, |
| 5461 | {"Maraca" , __SK_ControlChange_, __SK_ShakerInst_ , 0 }, |
| 5462 | {"Sekere" , __SK_ControlChange_, __SK_ShakerInst_ , 1 }, |
| 5463 | {"Cabasa" , __SK_ControlChange_, __SK_ShakerInst_ , 2 }, |
| 5464 | {"Bamboo" , __SK_ControlChange_, __SK_ShakerInst_ , 3 }, |
| 5465 | {"Waterdrp" , __SK_ControlChange_, __SK_ShakerInst_ , 4 }, |
| 5466 | {"Tambourn" , __SK_ControlChange_, __SK_ShakerInst_ , 5 }, |
| 5467 | {"Sleighbl" , __SK_ControlChange_, __SK_ShakerInst_ , 6 }, |
| 5468 | {"Guiro" , __SK_ControlChange_, __SK_ShakerInst_ , 7 }, |
| 5469 | |
| 5470 | {"OpenFile" , 256, SK_STR , NOPE}, |
| 5471 | {"SetPath" , 257, SK_STR , NOPE}, |
| 5472 | |
| 5473 | {"FilePath" , __SK_SINGER_FilePath_, SK_STR , NOPE}, |
| 5474 | {"Frequency" , __SK_SINGER_Frequency_, SK_STR , NOPE}, |
| 5475 | {"NoteName" , __SK_SINGER_NoteName_, SK_STR , NOPE}, |
| 5476 | {"VocalShape" , __SK_SINGER_Shape_ , SK_STR , NOPE}, |
| 5477 | {"Glottis" , __SK_SINGER_Glot_ , SK_STR , NOPE}, |
| 5478 | {"VoicedUnVoiced" , __SK_SINGER_VoicedUnVoiced_, SK_DBL , SK_STR}, |
| 5479 | {"Synthesize" , __SK_SINGER_Synthesize_, SK_STR , NOPE}, |
| 5480 | {"Silence" , __SK_SINGER_Silence_, SK_STR , NOPE}, |
| 5481 | {"VibratoAmt" , __SK_ControlChange_ ,__SK_SINGER_VibratoAmt_,SK_DBL}, |
| 5482 | {"RndVibAmt" , __SK_SINGER_RndVibAmt_ ,SK_STR, NOPE}, |
| 5483 | {"VibFreq" , __SK_ControlChange_ ,__SK_SINGER_VibFreq_ ,SK_DBL} |
| 5484 | }; |
| 5485 | |
| 5486 | |
| 5487 | /** FORMAT: *************************************************************/ |
| 5488 | /* */ |
| 5489 | /* MessageStr$ ,type, data2, data3, */ |
| 5490 | /* */ |
| 5491 | /* type is the message type sent back from the SKINI line parser. */ |
| 5492 | /* data<n> is either */ |
| 5493 | /* NOPE : field not used, specifically, there aren't going */ |
| 5494 | /* to be any more fields on this line. So if there */ |
| 5495 | /* is is NOPE in data2, data3 won't even be checked */ |
| 5496 | /* SK_INT : byte (actually scanned as 32 bit signed integer) */ |
| 5497 | /* If it's a MIDI data field which is required to */ |
| 5498 | /* be an integer, like a controller number, it's */ |
| 5499 | /* 0-127 otherwise get creative with SK_INTs */ |
| 5500 | /* SK_DBL : double precision floating point. SKINI uses these */ |
| 5501 | /* in the MIDI context for note numbers with micro */ |
| 5502 | /* tuning, velocities, controller values, etc. */ |
| 5503 | /* SK_STR : only valid in final field. This allows (nearly) */ |
| 5504 | /* arbitrary message types to be supported by simply */ |
| 5505 | /* scanning the string to EndOfLine and then passing */ |
| 5506 | /* it to a more intellegent handler. For example, */ |
| 5507 | /* MIDI SYSEX (system exclusive) messages of up to */ |
| 5508 | /* 256bytes can be read as space-delimited integers */ |
| 5509 | /* into the 1K SK_STR buffer. Longer bulk dumps, */ |
| 5510 | /* soundfiles, etc. should be handled as a new */ |
| 5511 | /* message type pointing to a FileName stored in the */ |
| 5512 | /* SK_STR field, or as a new type of multi-line */ |
| 5513 | /* message. */ |
| 5514 | /* */ |
| 5515 | /*************************************************************************/ |
| 5516 | |
| 5517 | |
| 5518 | /***************************************************/ |
| 5519 | /*! \class ADSR |
| 5520 | \brief STK ADSR envelope class. |
| 5521 | |
| 5522 | This Envelope subclass implements a |
| 5523 | traditional ADSR (Attack, Decay, |
| 5524 | Sustain, Release) envelope. It |
| 5525 | responds to simple keyOn and keyOff |
| 5526 | messages, keeping track of its state. |
| 5527 | The \e state = ADSR::DONE after the |
| 5528 | envelope value reaches 0.0 in the |
| 5529 | ADSR::RELEASE state. |
| 5530 | |
| 5531 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5532 | */ |
| 5533 | /***************************************************/ |
| 5534 | #include <stdio.h> |
| 5535 | #include "ugen_stk.h" |
| 5536 | |
| 5537 | ADSR :: ADSR() : Envelope() |
| 5538 | { |
| 5539 | target = (MY_FLOAT) 0.0; |
| 5540 | value = (MY_FLOAT) 0.0; |
| 5541 | attackRate = (MY_FLOAT) 0.001; |
| 5542 | decayRate = (MY_FLOAT) 0.001; |
| 5543 | sustainLevel = (MY_FLOAT) 0.5; |
| 5544 | releaseRate = (MY_FLOAT) 0.01; |
| 5545 | state = DONE; |
| 5546 | // chuck |
| 5547 | m_attackTime = (MY_FLOAT) -1.0; // 1.4.1.0 (thanks mariobuoninfante) |
| 5548 | m_decayTime = (MY_FLOAT) -1.0; |
| 5549 | m_releaseTime = (MY_FLOAT) -1.0; |
| 5550 | |
| 5551 | // initialize times to default rates | 1.4.1.0 |
| 5552 | setAttackRate( attackRate ); |
| 5553 | setDecayRate( decayRate ); |
| 5554 | setReleaseRate( releaseRate ); |
| 5555 | } |
| 5556 | |
| 5557 | ADSR :: ~ADSR() |
| 5558 | { |
| 5559 | } |
| 5560 | |
| 5561 | void ADSR :: keyOn() |
| 5562 | { |
| 5563 | target = (MY_FLOAT)1.0; |
| 5564 | rate = attackRate; |
| 5565 | state = ATTACK; |
| 5566 | } |
| 5567 | |
| 5568 | void ADSR :: keyOff() |
| 5569 | { |
| 5570 | // chuck |
| 5571 | if( m_releaseTime > 0 ) |
| 5572 | { |
| 5573 | // in case release triggered before sustain |
| 5574 | rate = value / (m_releaseTime * Stk::sampleRate()); |
| 5575 | } |
| 5576 | else |
| 5577 | { |
| 5578 | // rate was set |
| 5579 | rate = releaseRate; |
| 5580 | } |
| 5581 | |
| 5582 | target = (MY_FLOAT)0.0; |
| 5583 | state = RELEASE; |
| 5584 | } |
| 5585 | |
| 5586 | void ADSR :: setAttackRate(MY_FLOAT aRate) |
| 5587 | { |
| 5588 | // sanity check |
| 5589 | if( aRate == 0.0 ) |
| 5590 | { |
| 5591 | printf("[chuck](via ADSR): zero attack rate ... ignoring!\n"); |
| 5592 | return; |
| 5593 | } |
| 5594 | |
| 5595 | if (aRate < 0.0) { |
| 5596 | printf("[chuck](via ADSR): negative rates not allowed ... correcting!\n"); |
| 5597 | attackRate = -aRate; |
| 5598 | } |
| 5599 | else attackRate = aRate; |
| 5600 | |
| 5601 | // 1.4.1.0 (thanks mariobuoninfante) |
| 5602 | m_attackTime = 1 / (aRate * Stk::sampleRate()); |
| 5603 | } |
| 5604 | |
| 5605 | void ADSR :: setDecayRate(MY_FLOAT aRate) |
| 5606 | { |
| 5607 | // sanity check |
| 5608 | if( aRate == 0.0 ) |
| 5609 | { |
| 5610 | printf("[chuck](via ADSR): zero decay rate ... ignoring!\n"); |
| 5611 | return; |
| 5612 | } |
| 5613 | |
| 5614 | if (aRate < 0.0) { |
| 5615 | printf("[chuck](via ADSR): negative rates not allowed ... correcting!\n"); |
| 5616 | decayRate = -aRate; |
| 5617 | } |
| 5618 | else decayRate = aRate; |
| 5619 | |
| 5620 | // 1.4.1.0 changed from -1.0 (thanks mariobuoninfante) |
| 5621 | m_decayTime = 1 / (aRate * Stk::sampleRate()); |
| 5622 | } |
| 5623 | |
| 5624 | void ADSR :: setSustainLevel(MY_FLOAT aLevel) |
| 5625 | { |
| 5626 | if (aLevel < 0.0 ) { |
| 5627 | printf("[chuck](via ADSR): sustain level out of range ... correcting!\n"); |
| 5628 | sustainLevel = (MY_FLOAT) 0.0; |
| 5629 | } |
| 5630 | else { |
| 5631 | sustainLevel = aLevel; |
| 5632 | } |
| 5633 | |
| 5634 | // chuck: need to recompute decay and release rates |
| 5635 | if( m_decayTime > 0.0 ) setDecayTime( m_decayTime ); |
| 5636 | if( m_releaseTime > 0.0 ) setReleaseTime( m_releaseTime ); |
| 5637 | } |
| 5638 | |
| 5639 | void ADSR :: setReleaseRate(MY_FLOAT aRate) |
| 5640 | { |
| 5641 | // sanity check |
| 5642 | if( aRate == 0.0 ) |
| 5643 | { |
| 5644 | printf("[chuck](via ADSR): zero release rate ... ignoring!\n"); |
| 5645 | return; |
| 5646 | } |
| 5647 | |
| 5648 | if (aRate < 0.0) { |
| 5649 | printf("[chuck](via ADSR): negative rates not allowed ... correcting!\n"); |
| 5650 | releaseRate = -aRate; |
| 5651 | } |
| 5652 | else { |
| 5653 | releaseRate = aRate; |
| 5654 | } |
| 5655 | |
| 5656 | // chuck (thanks mariobuoninfante) |
| 5657 | m_releaseTime = 1 / (aRate * Stk::sampleRate()); |
| 5658 | } |
| 5659 | |
| 5660 | void ADSR :: setAttackTime(MY_FLOAT aTime) |
| 5661 | { |
| 5662 | if( aTime < 0.0 ) { |
| 5663 | printf("[chuck](via ADSR): negative rates not allowed ... correcting!\n"); |
| 5664 | attackRate = 1.0 / ( -aTime * Stk::sampleRate() ); |
| 5665 | } |
| 5666 | else { |
| 5667 | attackRate = 1.0 / ( aTime * Stk::sampleRate() ); |
| 5668 | } |
| 5669 | |
| 5670 | // added 1.4.1.0 (thanks mariobuoninfante) |
| 5671 | m_attackTime = aTime; |
| 5672 | } |
| 5673 | |
| 5674 | void ADSR :: setDecayTime(MY_FLOAT aTime) |
| 5675 | { |
| 5676 | // check for negative |
| 5677 | if (aTime < 0.0) { |
| 5678 | printf("[chuck](via ADSR): negative times not allowed ... correcting!\n"); |
| 5679 | aTime = -aTime; |
| 5680 | } |
| 5681 | |
| 5682 | // check for zero |
| 5683 | if( aTime == 0.0 ) { |
| 5684 | // printf("[chuck](via ADSR): zero decay time not allowed ... correcting!\n"); |
| 5685 | decayRate = FLT_MAX; // a big number |
| 5686 | } |
| 5687 | else { |
| 5688 | // chuck: compute rate for 1.0 to sustain |
| 5689 | decayRate = (1.0 - sustainLevel) / (aTime * Stk::sampleRate()); |
| 5690 | } |
| 5691 | |
| 5692 | // chuck |
| 5693 | m_decayTime = aTime; |
| 5694 | } |
| 5695 | |
| 5696 | void ADSR :: setReleaseTime(MY_FLOAT aTime) |
| 5697 | { |
| 5698 | // check for negative |
| 5699 | if (aTime < 0.0) { |
| 5700 | printf("[chuck](via ADSR): negative times not allowed ... correcting!\n"); |
| 5701 | aTime = -aTime; |
| 5702 | } |
| 5703 | |
| 5704 | // check for zero |
| 5705 | if( aTime == 0.0 ) { |
| 5706 | // printf("[chuck](via ADSR): zero release time not allowed ... correcting!\n"); |
| 5707 | releaseRate = FLT_MAX; // a big number |
| 5708 | } |
| 5709 | else { |
| 5710 | releaseRate = sustainLevel / ( aTime * Stk::sampleRate() ); |
| 5711 | } |
| 5712 | |
| 5713 | // chuck |
| 5714 | m_releaseTime = aTime; |
| 5715 | } |
| 5716 | |
| 5717 | // chuck | 1.4.1.0 update (thanks mariobuoninfante) |
| 5718 | MY_FLOAT ADSR :: getAttackTime() { return m_attackTime; } |
| 5719 | // { return 1.0 / (attackRate*Stk::sampleRate()); } |
| 5720 | MY_FLOAT ADSR :: getDecayTime() { return m_decayTime; } |
| 5721 | // { return (1.0 - sustainLevel) / (decayRate*Stk::sampleRate()); } |
| 5722 | MY_FLOAT ADSR :: getReleaseTime() { return m_releaseTime; } |
| 5723 | // { return sustainLevel / (releaseRate*Stk::sampleRate()); } |
| 5724 | |
| 5725 | void ADSR :: setAllTimes(MY_FLOAT aTime, MY_FLOAT dTime, MY_FLOAT sLevel, MY_FLOAT rTime) |
| 5726 | { |
| 5727 | // set this first, as decay and release rates depends on sustain level |
| 5728 | this->setSustainLevel(sLevel); |
| 5729 | // set the rest |
| 5730 | this->setAttackTime(aTime); |
| 5731 | this->setDecayTime(dTime); |
| 5732 | this->setReleaseTime(rTime); |
| 5733 | } |
| 5734 | |
| 5735 | void ADSR :: setTarget(MY_FLOAT aTarget) |
| 5736 | { |
| 5737 | target = aTarget; |
| 5738 | if (value < target) { |
| 5739 | state = ATTACK; |
| 5740 | this->setSustainLevel(target); |
| 5741 | rate = attackRate; |
| 5742 | } // 1.4.1.0 (ge): I don't understand this logic; |
| 5743 | // what if value > target but we are still in the attack? |
| 5744 | if (value > target) { |
| 5745 | this->setSustainLevel(target); |
| 5746 | state = DECAY; |
| 5747 | rate = decayRate; |
| 5748 | } |
| 5749 | } |
| 5750 | |
| 5751 | void ADSR :: setValue(MY_FLOAT aValue) |
| 5752 | { |
| 5753 | state = SUSTAIN; |
| 5754 | target = aValue; |
| 5755 | value = aValue; |
| 5756 | this->setSustainLevel(aValue); |
| 5757 | rate = (MY_FLOAT)0.0; |
| 5758 | } |
| 5759 | |
| 5760 | int ADSR :: getState(void) const |
| 5761 | { |
| 5762 | return state; |
| 5763 | } |
| 5764 | |
| 5765 | MY_FLOAT ADSR :: tick() |
| 5766 | { |
| 5767 | switch(state) |
| 5768 | { |
| 5769 | case ATTACK: |
| 5770 | value += rate; |
| 5771 | |
| 5772 | // check if we reached/overshot the goal |
| 5773 | if( m_attackTime <= 0 || value >= target ) |
| 5774 | { |
| 5775 | state = DECAY; |
| 5776 | value = target; |
| 5777 | target = sustainLevel; |
| 5778 | rate = decayRate; |
| 5779 | |
| 5780 | // 1.4.1.0 |
| 5781 | // if( m_decayTime <= 0 ) // if( decayRate >= FLT_MAX ) // big number |
| 5782 | // { |
| 5783 | // // go directly to sustain; |
| 5784 | // state = SUSTAIN; |
| 5785 | // value = sustainLevel; |
| 5786 | // rate = (MY_FLOAT)0.0; |
| 5787 | // } |
| 5788 | } |
| 5789 | break; |
| 5790 | |
| 5791 | case DECAY: |
| 5792 | value -= rate; |
| 5793 | |
| 5794 | // check if we reached/overshot the goal |
| 5795 | if( m_decayTime <= 0 || value <= sustainLevel ) |
| 5796 | { |
| 5797 | state = SUSTAIN; |
| 5798 | value = sustainLevel; |
| 5799 | rate = (MY_FLOAT)0.0; |
| 5800 | } |
| 5801 | break; |
| 5802 | |
| 5803 | case RELEASE: |
| 5804 | // chuck |
| 5805 | value -= rate; |
| 5806 | |
| 5807 | // check if we reached/overshot the goal |
| 5808 | if( m_releaseTime <= 0 || value <= 0.0 ) |
| 5809 | { |
| 5810 | state = DONE; |
| 5811 | value = (MY_FLOAT)0.0; |
| 5812 | } |
| 5813 | } |
| 5814 | |
| 5815 | return value; |
| 5816 | } |
| 5817 | |
| 5818 | MY_FLOAT * ADSR :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 5819 | { |
| 5820 | for ( t_CKUINT i= 0 ; i < vectorSize; i++ ) |
| 5821 | vec[i] = tick(); |
| 5822 | |
| 5823 | return vec; |
| 5824 | } |
| 5825 | |
| 5826 | |
| 5827 | /***************************************************/ |
| 5828 | /*! \class BandedWG |
| 5829 | \brief Banded waveguide modeling class. |
| 5830 | |
| 5831 | This class uses banded waveguide techniques to |
| 5832 | model a variety of sounds, including bowed |
| 5833 | bars, glasses, and bowls. For more |
| 5834 | information, see Essl, G. and Cook, P. "Banded |
| 5835 | Waveguides: Towards Physical Modelling of Bar |
| 5836 | Percussion Instruments", Proceedings of the |
| 5837 | 1999 International Computer Music Conference. |
| 5838 | |
| 5839 | Control Change Numbers: |
| 5840 | - Bow Pressure = 2 |
| 5841 | - Bow Motion = 4 |
| 5842 | - Strike Position = 8 (not implemented) |
| 5843 | - Vibrato Frequency = 11 |
| 5844 | - Gain = 1 |
| 5845 | - Bow Velocity = 128 |
| 5846 | - Set Striking = 64 |
| 5847 | - Instrument Presets = 16 |
| 5848 | - Uniform Bar = 0 |
| 5849 | - Tuned Bar = 1 |
| 5850 | - Glass Harmonica = 2 |
| 5851 | - Tibetan Bowl = 3 |
| 5852 | |
| 5853 | by Georg Essl, 1999 - 2002. |
| 5854 | Modified for Stk 4.0 by Gary Scavone. |
| 5855 | */ |
| 5856 | /***************************************************/ |
| 5857 | |
| 5858 | #include <math.h> |
| 5859 | |
| 5860 | BandedWG :: BandedWG() |
| 5861 | { |
| 5862 | doPluck = true; |
| 5863 | |
| 5864 | delay = new DelayL[MAX_BANDED_MODES]; |
| 5865 | bandpass = new BiQuad[MAX_BANDED_MODES]; |
| 5866 | |
| 5867 | bowTabl = new BowTabl; |
| 5868 | bowTabl->setSlope( 3.0 ); |
| 5869 | |
| 5870 | adsr = new ADSR; |
| 5871 | adsr->setAllTimes( 0.02, 0.005, 0.9, 0.01 ); |
| 5872 | |
| 5873 | freakency = 220.0; |
| 5874 | setPreset(0); |
| 5875 | |
| 5876 | bowPosition = 0; |
| 5877 | baseGain = (MY_FLOAT) 0.999; |
| 5878 | |
| 5879 | integrationConstant = 0.0; |
| 5880 | trackVelocity = false; |
| 5881 | |
| 5882 | bowVelocity = 0.0; |
| 5883 | bowTarget = 0.0; |
| 5884 | |
| 5885 | strikeAmp = 0.0; |
| 5886 | |
| 5887 | for (int i=0; i<MAX_BANDED_MODES; i++) { /***** REPAIRATHON2021 HACK, Better for Strike Position and more *****/ |
| 5888 | outGains[i] = 1.0; /***** REPAIRATHON2021 HACKS, Better for Strike Position and more *****/ |
| 5889 | } |
| 5890 | |
| 5891 | modeReson = 1.0; /***** REPAIRATHON2021 HACKS, actually allows mode resonance manipulation *****/ |
| 5892 | |
| 5893 | // chuck |
| 5894 | m_frequency = freakency; |
| 5895 | // rate |
| 5896 | m_rate = .02; |
| 5897 | // reverse: nothing (set directly from norm in controlChange) |
| 5898 | m_bowPressure = 0.0; |
| 5899 | // reverse: bowPosition |
| 5900 | m_bowMotion = bowPosition; |
| 5901 | // reverse: baseGain = 0.8999999999999999 + (0.1 * norm); |
| 5902 | m_modesGain = (baseGain - 0.8999999999999999) / .1; |
| 5903 | // reverse: nothing (set directly from preset in setPreset) |
| 5904 | m_preset = 0; |
| 5905 | // reverse: not used |
| 5906 | strikePosition = 0.0; // 1.4.1.0 (prc) added |
| 5907 | m_strikePosition = 0; |
| 5908 | } |
| 5909 | |
| 5910 | BandedWG :: ~BandedWG() |
| 5911 | { |
| 5912 | delete bowTabl; |
| 5913 | delete adsr; |
| 5914 | delete [] bandpass; |
| 5915 | delete [] delay; |
| 5916 | } |
| 5917 | |
| 5918 | void BandedWG :: clear() |
| 5919 | { |
| 5920 | for (int i=0; i<nModes; i++) { |
| 5921 | delay[i].clear(); |
| 5922 | bandpass[i].clear(); |
| 5923 | } |
| 5924 | } |
| 5925 | |
| 5926 | void BandedWG :: setPreset(int preset) |
| 5927 | { |
| 5928 | int i; |
| 5929 | m_preset = preset; |
| 5930 | switch (preset){ |
| 5931 | |
| 5932 | case 1: // Tuned Bar |
| 5933 | presetModes = 4; |
| 5934 | modes[0] = (MY_FLOAT) 1.0; |
| 5935 | modes[1] = (MY_FLOAT) 4.0198391420; |
| 5936 | modes[2] = (MY_FLOAT) 10.7184986595; |
| 5937 | modes[3] = (MY_FLOAT) 18.0697050938; |
| 5938 | |
| 5939 | for (i=0; i<presetModes; i++) { |
| 5940 | basegains[i] = (MY_FLOAT) pow(0.999,(double) i+1); |
| 5941 | excitation[i] = 1.0; |
| 5942 | } |
| 5943 | |
| 5944 | break; |
| 5945 | |
| 5946 | case 2: // Glass Harmonica |
| 5947 | presetModes = 5; |
| 5948 | modes[0] = (MY_FLOAT) 1.0; |
| 5949 | modes[1] = (MY_FLOAT) 2.32; |
| 5950 | modes[2] = (MY_FLOAT) 4.25; |
| 5951 | modes[3] = (MY_FLOAT) 6.63; |
| 5952 | modes[4] = (MY_FLOAT) 9.38; |
| 5953 | // modes[5] = (MY_FLOAT) 12.22; |
| 5954 | |
| 5955 | for (i=0; i<presetModes; i++) { |
| 5956 | basegains[i] = (MY_FLOAT) pow(0.999,(double) i+1); |
| 5957 | excitation[i] = 1.0; |
| 5958 | } |
| 5959 | /* |
| 5960 | baseGain = (MY_FLOAT) 0.99999; |
| 5961 | for (i=0; i<presetModes; i++) |
| 5962 | gains[i]= (MY_FLOAT) pow(baseGain, delay[i].getDelay()+i); |
| 5963 | */ |
| 5964 | |
| 5965 | break; |
| 5966 | |
| 5967 | case 3: // Tibetan Prayer Bowl (ICMC'02) |
| 5968 | presetModes = 12; |
| 5969 | modes[0]=0.996108344; |
| 5970 | basegains[0]=0.999925960128219; |
| 5971 | excitation[0]=11.900357/10.0; |
| 5972 | modes[1]=1.0038916562; |
| 5973 | basegains[1]=0.999925960128219; |
| 5974 | excitation[1]=11.900357/10.; |
| 5975 | modes[2]=2.979178; |
| 5976 | basegains[2]=0.999982774366897; |
| 5977 | excitation[2]=10.914886/10.; |
| 5978 | modes[3]=2.99329767; |
| 5979 | basegains[3]=0.999982774366897; |
| 5980 | excitation[3]=10.914886/10.; |
| 5981 | modes[4]=5.704452; |
| 5982 | basegains[4]=1.0; //0.999999999999999999987356406352; |
| 5983 | excitation[4]=42.995041/10.; |
| 5984 | modes[5]=5.704452; |
| 5985 | basegains[5]=1.0; //0.999999999999999999987356406352; |
| 5986 | excitation[5]=42.995041/10.; |
| 5987 | modes[6]=8.9982; |
| 5988 | basegains[6]=1.0; //0.999999999999999999996995497558225; |
| 5989 | excitation[6]=40.063034/10.; |
| 5990 | modes[7]=9.01549726; |
| 5991 | basegains[7]=1.0; //0.999999999999999999996995497558225; |
| 5992 | excitation[7]=40.063034/10.; |
| 5993 | modes[8]=12.83303; |
| 5994 | basegains[8]=0.999965497558225; |
| 5995 | excitation[8]=7.063034/10.; |
| 5996 | modes[9]=12.807382; |
| 5997 | basegains[9]=0.999965497558225; |
| 5998 | excitation[9]=7.063034/10.; |
| 5999 | modes[10]=17.2808219; |
| 6000 | basegains[10]=0.9999999999999999999965497558225; |
| 6001 | excitation[10]=57.063034/10.; |
| 6002 | modes[11]=21.97602739726; |
| 6003 | basegains[11]=0.999999999999999965497558225; |
| 6004 | excitation[11]=57.063034/10.; |
| 6005 | |
| 6006 | break; |
| 6007 | |
| 6008 | default: // Uniform Bar |
| 6009 | presetModes = 4; |
| 6010 | modes[0] = (MY_FLOAT) 1.0; |
| 6011 | modes[1] = (MY_FLOAT) 2.756; |
| 6012 | modes[2] = (MY_FLOAT) 5.404; |
| 6013 | modes[3] = (MY_FLOAT) 8.933; |
| 6014 | |
| 6015 | for (i=0; i<presetModes; i++) { |
| 6016 | basegains[i] = (MY_FLOAT) pow(0.9,(double) i+1); |
| 6017 | excitation[i] = 1.0; |
| 6018 | } |
| 6019 | |
| 6020 | break; |
| 6021 | } |
| 6022 | |
| 6023 | nModes = presetModes; |
| 6024 | setFrequency( freakency ); |
| 6025 | } |
| 6026 | |
| 6027 | void BandedWG :: setFrequency(MY_FLOAT frequency) |
| 6028 | { |
| 6029 | freakency = frequency; |
| 6030 | if ( frequency <= 0.0 ) { |
| 6031 | CK_STDCERR << "[chuck](via STK): BandedWG: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 6032 | freakency = 220.0; |
| 6033 | } |
| 6034 | if (freakency > 1568.0) freakency = 1568.0; |
| 6035 | |
| 6036 | MY_FLOAT radius; |
| 6037 | MY_FLOAT base = Stk::sampleRate() / freakency; |
| 6038 | MY_FLOAT length; |
| 6039 | for (int i=0; i<presetModes; i++) { |
| 6040 | // Calculate the delay line lengths for each mode. |
| 6041 | length = (int)(base / modes[i]); |
| 6042 | if ( length > 2.0) { |
| 6043 | delay[i].setDelay( length ); |
| 6044 | gains[i]=basegains[i]; |
| 6045 | // gains[i]=(MY_FLOAT) pow(basegains[i], 1/((MY_FLOAT)delay[i].getDelay())); |
| 6046 | // CK_STDCERR << gains[i]; |
| 6047 | } |
| 6048 | else { |
| 6049 | nModes = i; |
| 6050 | break; |
| 6051 | } |
| 6052 | // CK_STDCERR << CK_STDENDL; |
| 6053 | |
| 6054 | // set the bandpass filter resonances |
| 6055 | radius = 1.0 - CK_ONE_PI * 32 / Stk::sampleRate(); //freakency * modes[i] / Stk::sampleRate()/32; |
| 6056 | if ( radius < 0.0 ) radius = 0.0; |
| 6057 | bandpass[i].setResonance(freakency * modes[i], radius, true); |
| 6058 | |
| 6059 | delay[i].clear(); |
| 6060 | bandpass[i].clear(); |
| 6061 | } |
| 6062 | |
| 6063 | //int olen = (int)(delay[0].getDelay()); |
| 6064 | //strikePosition = (int)(strikePosition*(length/modes[0])/olen); |
| 6065 | |
| 6066 | // chuck |
| 6067 | m_frequency = freakency; |
| 6068 | } |
| 6069 | |
| 6070 | void BandedWG :: setStrikePosition(MY_FLOAT position) |
| 6071 | { |
| 6072 | // 1.4.1.0 (prc) |
| 6073 | // strikePosition = (int)(delay[0].getDelay() * position / 2.0); |
| 6074 | // m_strikePosition = position; |
| 6075 | |
| 6076 | // 1.4.1.0 (prc) |
| 6077 | strikePosition = position; /***** REPAIRATHON2021 HACK *****/ |
| 6078 | for (int i=0; i<MAX_BANDED_MODES; i++) { /***** REPAIRATHON2021 HACKS *****/ |
| 6079 | outGains[i] = fabs(sin((i+1)*CK_ONE_PI*strikePosition)); /***** REPAIRATHON2021 HACKS *****/ |
| 6080 | if (strikePosition == 0.0) outGains[i] = 1.0; // AVOID (Override) EDGE CASES |
| 6081 | if (strikePosition == 1.0) outGains[i] = 1.0; // WHERE GAINS WOULD COME OUT ZERO |
| 6082 | } |
| 6083 | m_strikePosition = position; |
| 6084 | } |
| 6085 | |
| 6086 | void BandedWG :: startBowing(MY_FLOAT amplitude, MY_FLOAT rate) |
| 6087 | { |
| 6088 | adsr->setRate(rate); |
| 6089 | adsr->keyOn(); |
| 6090 | maxVelocity = 0.03 + (0.1 * amplitude); |
| 6091 | } |
| 6092 | |
| 6093 | void BandedWG :: stopBowing(MY_FLOAT rate) |
| 6094 | { |
| 6095 | adsr->setRate(rate); |
| 6096 | adsr->keyOff(); |
| 6097 | } |
| 6098 | |
| 6099 | void BandedWG :: pluck(MY_FLOAT amplitude) |
| 6100 | { |
| 6101 | int j; |
| 6102 | MY_FLOAT min_len = delay[nModes-1].getDelay(); |
| 6103 | for (int i=0; i<nModes; i++) { |
| 6104 | for(j=0; j<(int)(delay[i].getDelay()/min_len); j++) { |
| 6105 | delay[i].tick( excitation[i]*amplitude / nModes /*/ (delay[i].getDelay()/min_len)*/); |
| 6106 | } |
| 6107 | } |
| 6108 | /* strikeAmp += amplitude;*/ |
| 6109 | } |
| 6110 | |
| 6111 | void BandedWG :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 6112 | { |
| 6113 | this->setFrequency(frequency); |
| 6114 | |
| 6115 | if ( doPluck ) |
| 6116 | this->pluck(amplitude); |
| 6117 | else |
| 6118 | this->startBowing(amplitude, amplitude * 0.001); |
| 6119 | |
| 6120 | #if defined(_STK_DEBUG_) |
| 6121 | CK_STDCERR << "[chuck](via STK): BandedWG: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 6122 | #endif |
| 6123 | } |
| 6124 | |
| 6125 | void BandedWG :: noteOff(MY_FLOAT amplitude) |
| 6126 | { |
| 6127 | if ( !doPluck ) |
| 6128 | this->stopBowing((1.0 - amplitude) * 0.005); |
| 6129 | |
| 6130 | #if defined(_STK_DEBUG_) |
| 6131 | CK_STDCERR << "[chuck](via STK): BandedWG: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 6132 | #endif |
| 6133 | } |
| 6134 | |
| 6135 | MY_FLOAT BandedWG :: tick() |
| 6136 | { |
| 6137 | int k; |
| 6138 | |
| 6139 | MY_FLOAT input = 0.0; |
| 6140 | if ( doPluck ) { |
| 6141 | input = 0.0; |
| 6142 | // input = strikeAmp/nModes; |
| 6143 | // strikeAmp = 0.0; |
| 6144 | } |
| 6145 | else { |
| 6146 | if (integrationConstant == 0.0) |
| 6147 | velocityInput = 0.0; |
| 6148 | else |
| 6149 | velocityInput = integrationConstant * velocityInput; |
| 6150 | |
| 6151 | for (k=0; k<nModes; k++) { |
| 6152 | // 1.4.1.0 REPAIRATHON2021 HACKS out with the old: |
| 6153 | // velocityInput += baseGain * delay[k].lastOut(); |
| 6154 | // 1.4.1.0 REPAIRATHON2021 HACKS in with the new: |
| 6155 | velocityInput += outGains[k]*baseGain * delay[k].lastOut(); |
| 6156 | } |
| 6157 | |
| 6158 | if ( trackVelocity ) { |
| 6159 | bowVelocity *= 0.9995; |
| 6160 | bowVelocity += bowTarget; |
| 6161 | bowTarget *= 0.995; |
| 6162 | } |
| 6163 | else |
| 6164 | bowVelocity = adsr->tick() * maxVelocity; |
| 6165 | |
| 6166 | input = bowVelocity - velocityInput; |
| 6167 | input = input * bowTabl->tick(input); |
| 6168 | input = input/(MY_FLOAT)nModes; |
| 6169 | } |
| 6170 | |
| 6171 | MY_FLOAT data = 0.0; |
| 6172 | for (k=0; k<nModes; k++) { |
| 6173 | bandpass[k].tick(input + gains[k] * delay[k].lastOut()); |
| 6174 | delay[k].tick(modeReson*bandpass[k].lastOut()); /***** REPAIRATHON2021 HACKS ADDED Mode Resonance *****/ |
| 6175 | // data += bandpass[k].lastOut(); /***** REPAIRATHON2021 HACKS *****/ |
| 6176 | data += outGains[k]*bandpass[k].lastOut(); /***** ADDED OUTGAINS FOR STRIKE/BOW POSITION *****/ |
| 6177 | } |
| 6178 | |
| 6179 | //lastOutput = data * nModes; |
| 6180 | lastOutput = data * 4; |
| 6181 | return lastOutput; |
| 6182 | } |
| 6183 | |
| 6184 | void BandedWG :: controlChange(int number, MY_FLOAT value) |
| 6185 | { |
| 6186 | MY_FLOAT norm = value * ONE_OVER_128; |
| 6187 | if ( norm < 0 ) { |
| 6188 | norm = 0.0; |
| 6189 | CK_STDCERR << "[chuck](via STK): BandedWG: Control value less than zero!" << CK_STDENDL; |
| 6190 | } |
| 6191 | else if ( norm > 1.0 ) { |
| 6192 | norm = 1.0; |
| 6193 | CK_STDCERR << "[chuck](via STK): BandedWG: Control value exceeds nominal range!" << CK_STDENDL; |
| 6194 | } |
| 6195 | |
| 6196 | if (number == __SK_BowPressure_) { // 2 |
| 6197 | m_bowPressure = norm; |
| 6198 | if ( norm == 0.0 ) |
| 6199 | doPluck = true; |
| 6200 | else { |
| 6201 | doPluck = false; |
| 6202 | bowTabl->setSlope( 10.0 - (9.0 * norm)); |
| 6203 | } |
| 6204 | } |
| 6205 | else if (number == 4) { // 4 |
| 6206 | if ( !trackVelocity ) trackVelocity = true; |
| 6207 | bowTarget += 0.005 * (norm - bowPosition); |
| 6208 | bowPosition = norm; |
| 6209 | m_bowMotion = norm; |
| 6210 | //adsr->setTarget(bowPosition); |
| 6211 | } |
| 6212 | else if (number == 8) // 8 |
| 6213 | this->setStrikePosition( norm ); |
| 6214 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 6215 | //bowTarget += 0.02 * (norm - bowPosition); |
| 6216 | //bowPosition = norm; |
| 6217 | if ( trackVelocity ) trackVelocity = false; |
| 6218 | maxVelocity = 0.13 * norm; |
| 6219 | adsr->setTarget(norm); |
| 6220 | } |
| 6221 | else if (number == __SK_ModWheel_) { // 1 |
| 6222 | // baseGain = 0.9989999999 + (0.001 * norm ); // DELETE THESE SOMEDAY |
| 6223 | // baseGain = 0.8999999999999999 + (0.1 * norm); // 1.4.1.0 REPAIRATHON2021 HACK, better modeResonance implementation |
| 6224 | if( norm > 1.0 ) { |
| 6225 | CK_STDCERR << "[chuck](via STK): BandedWG: modeResonance > 1.0!!!" << CK_STDENDL; |
| 6226 | } |
| 6227 | modeReson = norm; // 1.4.1.0 (prc) REPAIRATHON2021: NOW THIS DOES IT ALL (later in tick) |
| 6228 | // for (int i=0; i<nModes; i++) // REPAIRATHON2021 HACK, take these out |
| 6229 | // gains[i]=(MY_FLOAT) basegains[i]*baseGain; // REPAIRATHON2021 HACK, take these out |
| 6230 | // gains[i]=(MY_FLOAT) pow(baseGain, (int)((MY_FLOAT)delay[i].getDelay()+i)); |
| 6231 | m_modesGain = norm; |
| 6232 | } |
| 6233 | else if (number == __SK_ModFrequency_) // 11 |
| 6234 | integrationConstant = norm; |
| 6235 | else if (number == __SK_Sustain_) { // 64 |
| 6236 | if (value < 65) doPluck = true; |
| 6237 | else doPluck = false; |
| 6238 | } |
| 6239 | else if (number == __SK_Portamento_) { // 65 |
| 6240 | if (value < 65) trackVelocity = false; |
| 6241 | else trackVelocity = true; |
| 6242 | } |
| 6243 | else if (number == __SK_ProphesyRibbon_) // 16 |
| 6244 | this->setPreset((int) value); |
| 6245 | else |
| 6246 | CK_STDCERR << "[chuck](via STK): BandedWG: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 6247 | |
| 6248 | #if defined(_STK_DEBUG_) |
| 6249 | CK_STDCERR << "[chuck](via STK): BandedWG: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 6250 | #endif |
| 6251 | } |
| 6252 | |
| 6253 | |
| 6254 | /***************************************************/ |
| 6255 | /*! \class BeeThree |
| 6256 | \brief STK Hammond-oid organ FM synthesis instrument. |
| 6257 | |
| 6258 | This class implements a simple 4 operator |
| 6259 | topology, also referred to as algorithm 8 of |
| 6260 | the TX81Z. |
| 6261 | |
| 6262 | \code |
| 6263 | Algorithm 8 is : |
| 6264 | 1 --. |
| 6265 | 2 -\| |
| 6266 | +-> Out |
| 6267 | 3 -/| |
| 6268 | 4 -- |
| 6269 | \endcode |
| 6270 | |
| 6271 | Control Change Numbers: |
| 6272 | - Operator 4 (feedback) Gain = 2 |
| 6273 | - Operator 3 Gain = 4 |
| 6274 | - LFO Speed = 11 |
| 6275 | - LFO Depth = 1 |
| 6276 | - ADSR 2 & 4 Target = 128 |
| 6277 | |
| 6278 | The basic Chowning/Stanford FM patent expired |
| 6279 | in 1995, but there exist follow-on patents, |
| 6280 | mostly assigned to Yamaha. If you are of the |
| 6281 | type who should worry about this (making |
| 6282 | money) worry away. |
| 6283 | |
| 6284 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 6285 | */ |
| 6286 | /***************************************************/ |
| 6287 | |
| 6288 | |
| 6289 | BeeThree :: BeeThree() |
| 6290 | : FM() |
| 6291 | { |
| 6292 | // Concatenate the STK rawwave path to the rawwave files |
| 6293 | for ( int i=0; i<3; i++ ) |
| 6294 | waves[i] = new WaveLoop( (Stk::rawwavePath() + "special:sinewave").c_str(), TRUE ); |
| 6295 | waves[3] = new WaveLoop( "special:fwavblnk", TRUE ); |
| 6296 | |
| 6297 | this->setRatio(0, 0.999); |
| 6298 | this->setRatio(1, 1.997); |
| 6299 | this->setRatio(2, 3.006); |
| 6300 | this->setRatio(3, 6.009); |
| 6301 | |
| 6302 | gains[0] = __FM_gains[95]; |
| 6303 | gains[1] = __FM_gains[95]; |
| 6304 | gains[2] = __FM_gains[99]; |
| 6305 | gains[3] = __FM_gains[95]; |
| 6306 | |
| 6307 | baseGains[0] = gains[0]; // 1.4.1.0 (prc) REPARIATHON2021 ADDITION |
| 6308 | baseGains[1] = gains[1]; |
| 6309 | baseGains[2] = gains[2]; |
| 6310 | baseGains[3] = gains[3]; |
| 6311 | |
| 6312 | adsr[0]->setAllTimes( 0.005, 0.003, 1.0, 0.01); |
| 6313 | adsr[1]->setAllTimes( 0.005, 0.003, 1.0, 0.01); |
| 6314 | adsr[2]->setAllTimes( 0.005, 0.003, 1.0, 0.01); |
| 6315 | adsr[3]->setAllTimes( 0.005, 0.001, 0.4, 0.03); |
| 6316 | |
| 6317 | twozero->setGain( 0.1 ); |
| 6318 | } |
| 6319 | |
| 6320 | BeeThree :: ~BeeThree() |
| 6321 | { |
| 6322 | // note: waves array taken care of in FM destructor |
| 6323 | } |
| 6324 | |
| 6325 | void BeeThree :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 6326 | { |
| 6327 | // 1.4.1.0 (prc) updated REPAIRATHON2021 |
| 6328 | // gains[0] = amplitude * __FM_gains[95]; |
| 6329 | // gains[1] = amplitude * __FM_gains[95]; |
| 6330 | // gains[2] = amplitude * __FM_gains[99]; |
| 6331 | // gains[3] = amplitude * __FM_gains[95]; |
| 6332 | gains[0] = amplitude * baseGains[0]; |
| 6333 | gains[1] = amplitude * baseGains[1]; |
| 6334 | gains[2] = amplitude * baseGains[2]; |
| 6335 | gains[3] = amplitude * baseGains[3]; |
| 6336 | |
| 6337 | this->setFrequency(frequency); |
| 6338 | this->keyOn(); |
| 6339 | |
| 6340 | #if defined(_STK_DEBUG_) |
| 6341 | CK_STDCERR << "BeeThree: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 6342 | #endif |
| 6343 | } |
| 6344 | |
| 6345 | MY_FLOAT BeeThree :: tick() |
| 6346 | { |
| 6347 | /* register */ MY_FLOAT temp, temp2; |
| 6348 | // save for AM later |
| 6349 | // 1.4.1.0 (prc) REPAIRATHON2021 ADDITION, allow for tremelo or vibrato |
| 6350 | temp2 = vibrato->tick(); |
| 6351 | temp = temp2 * modDepth * 0.2; |
| 6352 | for (int i = 0; i < 4; i++) { |
| 6353 | if (ratios[i] > 0.0) { |
| 6354 | waves[i]->setFrequency(baseFrequency * (1.0 + temp) * ratios[i]); |
| 6355 | } |
| 6356 | } |
| 6357 | waves[3]->addPhaseOffset(twozero->lastOut()); |
| 6358 | temp = (1.0 + opAMs[3]*temp2) * control1 * 2.0 * gains[3] * adsr[3]->tick() * waves[3]->tick(); |
| 6359 | twozero->tick(temp); |
| 6360 | temp += (1.0 + opAMs[2]*temp2) * control2 * 2.0 * gains[2] * adsr[2]->tick() * waves[2]->tick(); |
| 6361 | temp += (1.0 + opAMs[1]*temp2) * gains[1] * adsr[1]->tick() * waves[1]->tick(); |
| 6362 | temp += (1.0 + opAMs[0]*temp2) * gains[0] * adsr[0]->tick() * waves[0]->tick(); |
| 6363 | |
| 6364 | lastOutput = temp * 0.125; |
| 6365 | return lastOutput; |
| 6366 | } |
| 6367 | |
| 6368 | |
| 6369 | /***************************************************/ |
| 6370 | /*! \class BiQuad |
| 6371 | \brief STK biquad (two-pole, two-zero) filter class. |
| 6372 | |
| 6373 | This protected Filter subclass implements a |
| 6374 | two-pole, two-zero digital filter. A method |
| 6375 | is provided for creating a resonance in the |
| 6376 | frequency response while maintaining a constant |
| 6377 | filter gain. |
| 6378 | |
| 6379 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 6380 | */ |
| 6381 | /***************************************************/ |
| 6382 | |
| 6383 | #include <math.h> |
| 6384 | |
| 6385 | BiQuad :: BiQuad() : FilterStk() |
| 6386 | { |
| 6387 | MY_FLOAT B[3] = {1.0, 0.0, 0.0}; |
| 6388 | MY_FLOAT A[3] = {1.0, 0.0, 0.0}; |
| 6389 | FilterStk::setCoefficients( 3, B, 3, A ); |
| 6390 | } |
| 6391 | |
| 6392 | BiQuad :: ~BiQuad() |
| 6393 | { |
| 6394 | } |
| 6395 | |
| 6396 | void BiQuad :: clear(void) |
| 6397 | { |
| 6398 | FilterStk::clear(); |
| 6399 | } |
| 6400 | |
| 6401 | void BiQuad :: setB0(MY_FLOAT b0) |
| 6402 | { |
| 6403 | b[0] = b0; |
| 6404 | } |
| 6405 | |
| 6406 | void BiQuad :: setB1(MY_FLOAT b1) |
| 6407 | { |
| 6408 | b[1] = b1; |
| 6409 | } |
| 6410 | |
| 6411 | void BiQuad :: setB2(MY_FLOAT b2) |
| 6412 | { |
| 6413 | b[2] = b2; |
| 6414 | } |
| 6415 | |
| 6416 | void BiQuad :: setA1(MY_FLOAT a1) |
| 6417 | { |
| 6418 | a[1] = a1; |
| 6419 | } |
| 6420 | |
| 6421 | void BiQuad :: setA2(MY_FLOAT a2) |
| 6422 | { |
| 6423 | a[2] = a2; |
| 6424 | } |
| 6425 | |
| 6426 | void BiQuad :: setResonance(MY_FLOAT frequency, MY_FLOAT radius, bool normalize) |
| 6427 | { |
| 6428 | a[2] = radius * radius; |
| 6429 | a[1] = -2.0 * radius * cos(CK_TWO_PI * frequency / Stk::sampleRate()); |
| 6430 | |
| 6431 | if ( normalize ) { |
| 6432 | // Use zeros at +- 1 and normalize the filter peak gain. |
| 6433 | b[0] = 0.5 - 0.5 * a[2]; |
| 6434 | b[1] = 0.0; |
| 6435 | b[2] = -b[0]; |
| 6436 | } |
| 6437 | } |
| 6438 | |
| 6439 | void BiQuad :: setNotch(MY_FLOAT frequency, MY_FLOAT radius) |
| 6440 | { |
| 6441 | // This method does not attempt to normalize the filter gain. |
| 6442 | b[2] = radius * radius; |
| 6443 | b[1] = (MY_FLOAT) -2.0 * radius * cos(CK_TWO_PI * (double) frequency / Stk::sampleRate()); |
| 6444 | } |
| 6445 | |
| 6446 | void BiQuad :: setEqualGainZeroes() |
| 6447 | { |
| 6448 | b[0] = 1.0; |
| 6449 | b[1] = 0.0; |
| 6450 | b[2] = -1.0; |
| 6451 | } |
| 6452 | |
| 6453 | void BiQuad :: setGain(MY_FLOAT theGain) |
| 6454 | { |
| 6455 | FilterStk::setGain(theGain); |
| 6456 | } |
| 6457 | |
| 6458 | MY_FLOAT BiQuad :: getGain(void) const |
| 6459 | { |
| 6460 | return FilterStk::getGain(); |
| 6461 | } |
| 6462 | |
| 6463 | MY_FLOAT BiQuad :: lastOut(void) const |
| 6464 | { |
| 6465 | return FilterStk::lastOut(); |
| 6466 | } |
| 6467 | |
| 6468 | MY_FLOAT BiQuad :: tick(MY_FLOAT sample) |
| 6469 | { |
| 6470 | inputs[0] = gain * sample; |
| 6471 | outputs[0] = b[0] * inputs[0] + b[1] * inputs[1] + b[2] * inputs[2]; |
| 6472 | outputs[0] -= a[2] * outputs[2] + a[1] * outputs[1]; |
| 6473 | inputs[2] = inputs[1]; |
| 6474 | inputs[1] = inputs[0]; |
| 6475 | outputs[2] = outputs[1]; |
| 6476 | outputs[1] = outputs[0]; |
| 6477 | |
| 6478 | // gewang: dedenormal |
| 6479 | CK_STK_DDN(outputs[1]); |
| 6480 | CK_STK_DDN(outputs[2]); |
| 6481 | |
| 6482 | return outputs[0]; |
| 6483 | } |
| 6484 | |
| 6485 | MY_FLOAT *BiQuad :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 6486 | { |
| 6487 | for (unsigned int i=0; i<vectorSize; i++) |
| 6488 | vec[i] = tick(vec[i]); |
| 6489 | |
| 6490 | return vec; |
| 6491 | } |
| 6492 | |
| 6493 | |
| 6494 | /***************************************************/ |
| 6495 | /*! \class Blit |
| 6496 | \brief STK band-limited impulse train class. |
| 6497 | |
| 6498 | This class generates a band-limited impulse train using a |
| 6499 | closed-form algorithm reported by Stilson and Smith in "Alias-Free |
| 6500 | Digital Synthesis of Classic Analog Waveforms", 1996. The user |
| 6501 | can specify both the fundamental frequency of the impulse train |
| 6502 | and the number of harmonics contained in the resulting signal. |
| 6503 | |
| 6504 | The signal is normalized so that the peak value is +/-1.0. |
| 6505 | |
| 6506 | If nHarmonics is 0, then the signal will contain all harmonics up |
| 6507 | to half the sample rate. Note, however, that this setting may |
| 6508 | produce aliasing in the signal when the frequency is changing (no |
| 6509 | automatic modification of the number of harmonics is performed by |
| 6510 | the setFrequency() function). |
| 6511 | |
| 6512 | Original code by Robin Davies, 2005. |
| 6513 | Revisions by Gary Scavone for STK, 2005. |
| 6514 | */ |
| 6515 | /***************************************************/ |
| 6516 | |
| 6517 | #include <cmath> |
| 6518 | #include <limits> |
| 6519 | |
| 6520 | Blit:: Blit( MY_FLOAT frequency ) |
| 6521 | { |
| 6522 | nHarmonics_ = 0; |
| 6523 | this->setFrequency( frequency ); |
| 6524 | this->reset(); |
| 6525 | } |
| 6526 | |
| 6527 | Blit :: ~Blit() |
| 6528 | { |
| 6529 | } |
| 6530 | |
| 6531 | void Blit :: reset() |
| 6532 | { |
| 6533 | phase_ = 0.0; |
| 6534 | // lastOutput_ = 0; |
| 6535 | } |
| 6536 | |
| 6537 | void Blit :: setFrequency( MY_FLOAT frequency ) |
| 6538 | { |
| 6539 | #if defined(_STK_DEBUG_) |
| 6540 | errorString_ << "Blit::setFrequency: frequency = " << frequency << '.'; |
| 6541 | handleError( StkError::DEBUG_WARNING ); |
| 6542 | #endif |
| 6543 | |
| 6544 | p_ = Stk::sampleRate() / frequency; |
| 6545 | rate_ = CK_ONE_PI / p_; |
| 6546 | this->updateHarmonics(); |
| 6547 | } |
| 6548 | |
| 6549 | void Blit :: setHarmonics( unsigned int nHarmonics ) |
| 6550 | { |
| 6551 | nHarmonics_ = nHarmonics; |
| 6552 | this->updateHarmonics(); |
| 6553 | } |
| 6554 | |
| 6555 | void Blit :: updateHarmonics( void ) |
| 6556 | { |
| 6557 | if ( nHarmonics_ <= 0 ) { |
| 6558 | unsigned int maxHarmonics = (unsigned int) floor( 0.5 * p_ ); |
| 6559 | m_ = 2 * maxHarmonics + 1; |
| 6560 | } |
| 6561 | else |
| 6562 | m_ = 2 * nHarmonics_ + 1; |
| 6563 | |
| 6564 | #if defined(_STK_DEBUG_) |
| 6565 | errorString_ << "Blit::updateHarmonics: nHarmonics_ = " << nHarmonics_ << ", m_ = " << m_ << '.'; |
| 6566 | handleError( StkError::DEBUG_WARNING ); |
| 6567 | #endif |
| 6568 | } |
| 6569 | |
| 6570 | MY_FLOAT Blit :: tick( void ) |
| 6571 | { |
| 6572 | // The code below implements the SincM algorithm of Stilson and |
| 6573 | // Smith with an additional scale factor of P / M applied to |
| 6574 | // normalize the output. |
| 6575 | |
| 6576 | // A fully optimized version of this code would replace the two sin |
| 6577 | // calls with a pair of fast sin oscillators, for which stable fast |
| 6578 | // two-multiply algorithms are well known. In the spirit of STK, |
| 6579 | // which favors clarity over performance, the optimization has not |
| 6580 | // been made here. |
| 6581 | |
| 6582 | MY_FLOAT output; |
| 6583 | |
| 6584 | // Avoid a divide by zero at the sinc peak, which has a limiting |
| 6585 | // value of 1.0. |
| 6586 | MY_FLOAT denominator = sin( phase_ ); |
| 6587 | if ( denominator <= std::numeric_limits<MY_FLOAT>::epsilon() ) { |
| 6588 | output = 1.0; |
| 6589 | } else { |
| 6590 | output = sin( m_ * phase_ ); |
| 6591 | output /= m_ * denominator; |
| 6592 | } |
| 6593 | |
| 6594 | phase_ += rate_; |
| 6595 | if ( phase_ >= CK_ONE_PI ) phase_ -= CK_ONE_PI; |
| 6596 | |
| 6597 | return output; |
| 6598 | } |
| 6599 | |
| 6600 | |
| 6601 | /***************************************************/ |
| 6602 | /*! \class BlitSaw |
| 6603 | \brief STK band-limited sawtooth wave class. |
| 6604 | |
| 6605 | This class generates a band-limited sawtooth waveform using a |
| 6606 | closed-form algorithm reported by Stilson and Smith in "Alias-Free |
| 6607 | Digital Synthesis of Classic Analog Waveforms", 1996. The user |
| 6608 | can specify both the fundamental frequency of the sawtooth and the |
| 6609 | number of harmonics contained in the resulting signal. |
| 6610 | |
| 6611 | If nHarmonics is 0, then the signal will contain all harmonics up |
| 6612 | to half the sample rate. Note, however, that this setting may |
| 6613 | produce aliasing in the signal when the frequency is changing (no |
| 6614 | automatic modification of the number of harmonics is performed by |
| 6615 | the setFrequency() function). |
| 6616 | |
| 6617 | Based on initial code of Robin Davies, 2005. |
| 6618 | Modified algorithm code by Gary Scavone, 2005. |
| 6619 | */ |
| 6620 | /***************************************************/ |
| 6621 | |
| 6622 | BlitSaw:: BlitSaw( MY_FLOAT frequency ) |
| 6623 | { |
| 6624 | nHarmonics_ = 0; |
| 6625 | this->reset(); |
| 6626 | this->setFrequency( frequency ); |
| 6627 | } |
| 6628 | |
| 6629 | BlitSaw :: ~BlitSaw() |
| 6630 | { |
| 6631 | } |
| 6632 | |
| 6633 | void BlitSaw :: reset() |
| 6634 | { |
| 6635 | phase_ = 0.0f; |
| 6636 | state_ = 0.0; |
| 6637 | // lastOutput_ = 0; |
| 6638 | } |
| 6639 | |
| 6640 | void BlitSaw :: setFrequency( MY_FLOAT frequency ) |
| 6641 | { |
| 6642 | #if defined(_STK_DEBUG_) |
| 6643 | errorString_ << "BlitSaw::setFrequency: frequency = " << frequency << '.'; |
| 6644 | handleError( StkError::DEBUG_WARNING ); |
| 6645 | #endif |
| 6646 | |
| 6647 | p_ = Stk::sampleRate() / frequency; |
| 6648 | C2_ = 1 / p_; |
| 6649 | rate_ = CK_ONE_PI * C2_; |
| 6650 | this->updateHarmonics(); |
| 6651 | } |
| 6652 | |
| 6653 | void BlitSaw :: setHarmonics( unsigned int nHarmonics ) |
| 6654 | { |
| 6655 | nHarmonics_ = nHarmonics; |
| 6656 | this->updateHarmonics(); |
| 6657 | |
| 6658 | // I found that the initial DC offset could be minimized with an |
| 6659 | // initial state setting as given below. This initialization should |
| 6660 | // only happen before starting the oscillator for the first time |
| 6661 | // (but after setting the frequency and number of harmonics). I |
| 6662 | // struggled a bit to decide where best to put this and finally |
| 6663 | // settled on here. In general, the user shouldn't be messing with |
| 6664 | // the number of harmonics once the oscillator is running because |
| 6665 | // this is automatically taken care of in the setFrequency() |
| 6666 | // function. (GPS - 1 October 2005) |
| 6667 | state_ = -0.5 * a_; |
| 6668 | } |
| 6669 | |
| 6670 | void BlitSaw :: updateHarmonics( void ) |
| 6671 | { |
| 6672 | if ( nHarmonics_ <= 0 ) { |
| 6673 | unsigned int maxHarmonics = (unsigned int) floor( 0.5 * p_ ); |
| 6674 | m_ = 2 * maxHarmonics + 1; |
| 6675 | } |
| 6676 | else |
| 6677 | m_ = 2 * nHarmonics_ + 1; |
| 6678 | |
| 6679 | a_ = m_ / p_; |
| 6680 | |
| 6681 | #if defined(_STK_DEBUG_) |
| 6682 | errorString_ << "BlitSaw::updateHarmonics: nHarmonics_ = " << nHarmonics_ << ", m_ = " << m_ << '.'; |
| 6683 | handleError( StkError::DEBUG_WARNING ); |
| 6684 | #endif |
| 6685 | } |
| 6686 | |
| 6687 | MY_FLOAT BlitSaw :: tick( void ) |
| 6688 | { |
| 6689 | // The code below implements the BLIT algorithm of Stilson and |
| 6690 | // Smith, followed by a summation and filtering operation to produce |
| 6691 | // a sawtooth waveform. After experimenting with various approaches |
| 6692 | // to calculate the average value of the BLIT over one period, I |
| 6693 | // found that an estimate of C2_ = 1.0 / period (in samples) worked |
| 6694 | // most consistently. A "leaky integrator" is then applied to the |
| 6695 | // difference of the BLIT output and C2_. (GPS - 1 October 2005) |
| 6696 | |
| 6697 | // A fully optimized version of this code would replace the two sin |
| 6698 | // calls with a pair of fast sin oscillators, for which stable fast |
| 6699 | // two-multiply algorithms are well known. In the spirit of STK, |
| 6700 | // which favors clarity over performance, the optimization has |
| 6701 | // not been made here. |
| 6702 | |
| 6703 | MY_FLOAT output; |
| 6704 | |
| 6705 | // Avoid a divide by zero, or use of a denormalized divisor |
| 6706 | // at the sinc peak, which has a limiting value of m_ / p_. |
| 6707 | MY_FLOAT denominator = sin( phase_ ); |
| 6708 | if ( fabs(denominator) <= std::numeric_limits<MY_FLOAT>::epsilon() ) |
| 6709 | output = a_; |
| 6710 | else { |
| 6711 | output = sin( m_ * phase_ ); |
| 6712 | output /= p_ * denominator; |
| 6713 | } |
| 6714 | |
| 6715 | output += state_ - C2_; |
| 6716 | state_ = output * 0.995; |
| 6717 | |
| 6718 | phase_ += rate_; |
| 6719 | if ( phase_ >= CK_ONE_PI ) phase_ -= CK_ONE_PI; |
| 6720 | |
| 6721 | return output; |
| 6722 | } |
| 6723 | |
| 6724 | |
| 6725 | /***************************************************/ |
| 6726 | /*! \class BlitSquare |
| 6727 | \brief STK band-limited square wave class. |
| 6728 | |
| 6729 | This class generates a band-limited square wave signal. It is |
| 6730 | derived in part from the approach reported by Stilson and Smith in |
| 6731 | "Alias-Free Digital Synthesis of Classic Analog Waveforms", 1996. |
| 6732 | The algorithm implemented in this class uses a SincM function with |
| 6733 | an even M value to achieve a bipolar bandlimited impulse train. |
| 6734 | This signal is then integrated to achieve a square waveform. The |
| 6735 | integration process has an associated DC offset but that is |
| 6736 | subtracted off the output signal. |
| 6737 | |
| 6738 | The user can specify both the fundamental frequency of the |
| 6739 | waveform and the number of harmonics contained in the resulting |
| 6740 | signal. |
| 6741 | |
| 6742 | If nHarmonics is 0, then the signal will contain all harmonics up |
| 6743 | to half the sample rate. Note, however, that this setting may |
| 6744 | produce aliasing in the signal when the frequency is changing (no |
| 6745 | automatic modification of the number of harmonics is performed by |
| 6746 | the setFrequency() function). |
| 6747 | |
| 6748 | Based on initial code of Robin Davies, 2005. |
| 6749 | Modified algorithm code by Gary Scavone, 2005. |
| 6750 | */ |
| 6751 | /***************************************************/ |
| 6752 | |
| 6753 | BlitSquare:: BlitSquare( MY_FLOAT frequency ) |
| 6754 | { |
| 6755 | nHarmonics_ = 0; |
| 6756 | this->setFrequency( frequency ); |
| 6757 | this->reset(); |
| 6758 | } |
| 6759 | |
| 6760 | BlitSquare :: ~BlitSquare() |
| 6761 | { |
| 6762 | } |
| 6763 | |
| 6764 | void BlitSquare :: reset() |
| 6765 | { |
| 6766 | phase_ = 0.0; |
| 6767 | m_output = 0; |
| 6768 | dcbState_ = 0.0; |
| 6769 | m_boutput = 0.0; |
| 6770 | } |
| 6771 | |
| 6772 | void BlitSquare :: setFrequency( MY_FLOAT frequency ) |
| 6773 | { |
| 6774 | #if defined(_STK_DEBUG_) |
| 6775 | errorString_ << "BlitSquare::setFrequency: frequency = " << frequency << '.'; |
| 6776 | handleError( StkError::DEBUG_WARNING ); |
| 6777 | #endif |
| 6778 | |
| 6779 | // By using an even value of the parameter M, we get a bipolar blit |
| 6780 | // waveform at half the blit frequency. Thus, we need to scale the |
| 6781 | // frequency value here by 0.5. (GPS, 2006). |
| 6782 | p_ = 0.5 * Stk::sampleRate() / frequency; |
| 6783 | rate_ = CK_ONE_PI / p_; |
| 6784 | this->updateHarmonics(); |
| 6785 | } |
| 6786 | |
| 6787 | void BlitSquare :: setHarmonics( unsigned int nHarmonics ) |
| 6788 | { |
| 6789 | nHarmonics_ = nHarmonics; |
| 6790 | this->updateHarmonics(); |
| 6791 | } |
| 6792 | |
| 6793 | void BlitSquare :: updateHarmonics( void ) |
| 6794 | { |
| 6795 | // Make sure we end up with an even value of the parameter M here. |
| 6796 | if ( nHarmonics_ <= 0 ) { |
| 6797 | unsigned int maxHarmonics = (unsigned int) floor( 0.5 * p_ ); |
| 6798 | m_ = 2 * ( maxHarmonics ); |
| 6799 | } |
| 6800 | else |
| 6801 | m_ = 2 * ( nHarmonics_ ); |
| 6802 | |
| 6803 | // This offset value was derived empirically. (GPS, 2005) |
| 6804 | // offset_ = 1.0 - 0.5 * m_ / p_; |
| 6805 | |
| 6806 | a_ = m_ / p_; |
| 6807 | |
| 6808 | #if defined(_STK_DEBUG_) |
| 6809 | errorString_ << "BlitSquare::updateHarmonics: nHarmonics_ = " << nHarmonics_ << ", m_ = " << m_ << '.'; |
| 6810 | handleError( StkError::DEBUG_WARNING ); |
| 6811 | #endif |
| 6812 | } |
| 6813 | |
| 6814 | MY_FLOAT BlitSquare :: tick( void ) |
| 6815 | { |
| 6816 | MY_FLOAT temp = m_boutput; |
| 6817 | |
| 6818 | // A fully optimized version of this would replace the two sin calls |
| 6819 | // with a pair of fast sin oscillators, for which stable fast |
| 6820 | // two-multiply algorithms are well known. In the spirit of STK, |
| 6821 | // which favors clarity over performance, the optimization has |
| 6822 | // not been made here. |
| 6823 | |
| 6824 | // Avoid a divide by zero, or use of a denomralized divisor |
| 6825 | // at the sinc peak, which has a limiting value of 1.0. |
| 6826 | MY_FLOAT denominator = sin( phase_ ); |
| 6827 | if ( fabs( denominator ) < std::numeric_limits<MY_FLOAT>::epsilon() ) { |
| 6828 | // Inexact comparison safely distinguishes betwen *close to zero*, and *close to PI*. |
| 6829 | if ( phase_ < 0.1f || phase_ > CK_TWO_PI - 0.1f ) |
| 6830 | m_boutput = a_; |
| 6831 | else |
| 6832 | m_boutput = -a_; |
| 6833 | } |
| 6834 | else { |
| 6835 | m_boutput = sin( m_ * phase_ ); |
| 6836 | m_boutput /= p_ * denominator; |
| 6837 | } |
| 6838 | |
| 6839 | m_boutput += temp; |
| 6840 | |
| 6841 | // Now apply DC blocker. |
| 6842 | m_output = m_boutput - dcbState_ + 0.999 * m_output; |
| 6843 | dcbState_ = m_boutput; |
| 6844 | |
| 6845 | phase_ += rate_; |
| 6846 | if ( phase_ >= CK_TWO_PI ) phase_ -= CK_TWO_PI; |
| 6847 | |
| 6848 | return m_output; |
| 6849 | } |
| 6850 | |
| 6851 | |
| 6852 | /***************************************************/ |
| 6853 | /*! \class BlowBotl |
| 6854 | \brief STK blown bottle instrument class. |
| 6855 | |
| 6856 | This class implements a helmholtz resonator |
| 6857 | (biquad filter) with a polynomial jet |
| 6858 | excitation (a la Cook). |
| 6859 | |
| 6860 | Control Change Numbers: |
| 6861 | - Noise Gain = 4 |
| 6862 | - Vibrato Frequency = 11 |
| 6863 | - Vibrato Gain = 1 |
| 6864 | - Volume = 128 |
| 6865 | |
| 6866 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 6867 | */ |
| 6868 | /***************************************************/ |
| 6869 | |
| 6870 | |
| 6871 | #define __BOTTLE_RADIUS_ 0.999 |
| 6872 | |
| 6873 | BlowBotl :: BlowBotl() |
| 6874 | { |
| 6875 | jetTable = new JetTabl(); |
| 6876 | |
| 6877 | dcBlock = new PoleZero(); |
| 6878 | dcBlock->setBlockZero(); |
| 6879 | |
| 6880 | // Concatenate the STK rawwave path to the rawwave file |
| 6881 | vibrato = new WaveLoop( "special:sinewave", TRUE ); |
| 6882 | vibrato->setFrequency( 5.925 ); |
| 6883 | vibratoGain = 0.0; |
| 6884 | |
| 6885 | resonator = new BiQuad(); |
| 6886 | resonator->setResonance(500.0, __BOTTLE_RADIUS_, true); |
| 6887 | |
| 6888 | adsr = new ADSR(); |
| 6889 | adsr->setAllTimes( 0.005, 0.01, 0.8, 0.010 ); |
| 6890 | |
| 6891 | noise = new Noise(); |
| 6892 | noiseGain = 20.0; |
| 6893 | |
| 6894 | maxPressure = (MY_FLOAT)0.0; |
| 6895 | |
| 6896 | // chuck added later |
| 6897 | outputGain = 1.0; |
| 6898 | |
| 6899 | // chuck |
| 6900 | //reverse: nothing (set from directly from setFrequency) |
| 6901 | m_frequency = 500; |
| 6902 | //reverse: nothing (set in BlowBotl_ctrl_rate only) |
| 6903 | m_rate = .02; |
| 6904 | //reverse: norm * 30.0 (from controlChange) |
| 6905 | m_noiseGain = noiseGain / 30.0; |
| 6906 | //reverse: vibratoFreq * 12.0 (from controlChange) |
| 6907 | m_vibratoFreq = vibrato->m_freq / 12.0; |
| 6908 | //reverse: vibratoGain * 0.4 (from controlChange) |
| 6909 | m_vibratoGain = vibratoGain / 0.4; |
| 6910 | //reverse: nothing (set in controlChange) |
| 6911 | m_volume = 1.0; |
| 6912 | } |
| 6913 | |
| 6914 | BlowBotl :: ~BlowBotl() |
| 6915 | { |
| 6916 | delete jetTable; |
| 6917 | delete resonator; |
| 6918 | delete dcBlock; |
| 6919 | delete noise; |
| 6920 | delete adsr; |
| 6921 | delete vibrato; |
| 6922 | } |
| 6923 | |
| 6924 | void BlowBotl :: clear() |
| 6925 | { |
| 6926 | resonator->clear(); |
| 6927 | } |
| 6928 | |
| 6929 | void BlowBotl :: setFrequency(MY_FLOAT frequency) |
| 6930 | { |
| 6931 | MY_FLOAT freakency = frequency; |
| 6932 | if ( frequency <= 0.0 ) { |
| 6933 | CK_STDCERR << "[chuck](via STK): BlowBotl: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 6934 | freakency = 220.0; |
| 6935 | } |
| 6936 | |
| 6937 | resonator->setResonance( freakency, __BOTTLE_RADIUS_, true ); |
| 6938 | |
| 6939 | // chuck |
| 6940 | m_frequency = freakency; |
| 6941 | } |
| 6942 | |
| 6943 | void BlowBotl :: startBlowing(MY_FLOAT amplitude, MY_FLOAT rate) |
| 6944 | { |
| 6945 | adsr->setAttackRate(rate); |
| 6946 | maxPressure = amplitude; |
| 6947 | adsr->keyOn(); |
| 6948 | } |
| 6949 | |
| 6950 | void BlowBotl :: stopBlowing(MY_FLOAT rate) |
| 6951 | { |
| 6952 | adsr->setReleaseRate(rate); |
| 6953 | adsr->keyOff(); |
| 6954 | } |
| 6955 | |
| 6956 | void BlowBotl :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 6957 | { |
| 6958 | setFrequency(frequency); |
| 6959 | startBlowing( 1.1 + (amplitude * 0.20), amplitude * 0.02); |
| 6960 | outputGain = amplitude + 0.001; |
| 6961 | |
| 6962 | #if defined(_STK_DEBUG_) |
| 6963 | CK_STDCERR << "[chuck](via STK): BlowBotl: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 6964 | #endif |
| 6965 | } |
| 6966 | |
| 6967 | void BlowBotl :: noteOff(MY_FLOAT amplitude) |
| 6968 | { |
| 6969 | this->stopBlowing(amplitude * 0.02); |
| 6970 | |
| 6971 | #if defined(_STK_DEBUG_) |
| 6972 | CK_STDCERR << "[chuck](via STK): BlowBotl: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 6973 | #endif |
| 6974 | } |
| 6975 | |
| 6976 | MY_FLOAT BlowBotl :: tick() |
| 6977 | { |
| 6978 | MY_FLOAT breathPressure; |
| 6979 | MY_FLOAT randPressure; |
| 6980 | MY_FLOAT pressureDiff; |
| 6981 | |
| 6982 | // Calculate the breath pressure (envelope + vibrato) |
| 6983 | breathPressure = maxPressure * adsr->tick(); |
| 6984 | breathPressure += vibratoGain * vibrato->tick(); |
| 6985 | |
| 6986 | pressureDiff = breathPressure - resonator->lastOut(); |
| 6987 | |
| 6988 | randPressure = noiseGain * noise->tick(); |
| 6989 | randPressure *= breathPressure; |
| 6990 | randPressure *= (1.0 + pressureDiff); |
| 6991 | |
| 6992 | resonator->tick( breathPressure + randPressure - ( jetTable->tick( pressureDiff ) * pressureDiff ) ); |
| 6993 | lastOutput = 0.2 * outputGain * dcBlock->tick( pressureDiff ); |
| 6994 | |
| 6995 | return lastOutput; |
| 6996 | } |
| 6997 | |
| 6998 | void BlowBotl :: controlChange(int number, MY_FLOAT value) |
| 6999 | { |
| 7000 | MY_FLOAT norm = value * ONE_OVER_128; |
| 7001 | if ( norm < 0 ) { |
| 7002 | norm = 0.0; |
| 7003 | CK_STDCERR << "[chuck](via STK): BlowBotl: Control value less than zero!" << CK_STDENDL; |
| 7004 | } |
| 7005 | else if ( norm > 1.0 ) { |
| 7006 | norm = 1.0; |
| 7007 | CK_STDCERR << "[chuck](via STK): BlowBotl: Control value exceeds nominal range!" << CK_STDENDL; |
| 7008 | } |
| 7009 | |
| 7010 | if( number == __SK_NoiseLevel_ ) { // 4 |
| 7011 | noiseGain = norm * 30.0; |
| 7012 | m_noiseGain = norm; // chuck |
| 7013 | } |
| 7014 | else if( number == __SK_ModFrequency_ ) // 11 |
| 7015 | setVibratoFreq( norm * 12.0 ); |
| 7016 | else if( number == __SK_ModWheel_ ) { // 1 |
| 7017 | vibratoGain = norm * 0.4; |
| 7018 | m_vibratoGain = norm; |
| 7019 | } |
| 7020 | else if( number == __SK_AfterTouch_Cont_ ) { // 128 |
| 7021 | adsr->setTarget( norm ); |
| 7022 | m_volume = norm; |
| 7023 | } |
| 7024 | else |
| 7025 | CK_STDCERR << "[chuck](via STK): BlowBotl: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 7026 | |
| 7027 | #if defined(_STK_DEBUG_) |
| 7028 | CK_STDCERR << "[chuck](via STK): BlowBotl: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 7029 | #endif |
| 7030 | } |
| 7031 | |
| 7032 | |
| 7033 | /***************************************************/ |
| 7034 | /*! \class BlowHole |
| 7035 | \brief STK clarinet physical model with one |
| 7036 | register hole and one tonehole. |
| 7037 | |
| 7038 | This class is based on the clarinet model, |
| 7039 | with the addition of a two-port register hole |
| 7040 | and a three-port dynamic tonehole |
| 7041 | implementation, as discussed by Scavone and |
| 7042 | Cook (1998). |
| 7043 | |
| 7044 | In this implementation, the distances between |
| 7045 | the reed/register hole and tonehole/bell are |
| 7046 | fixed. As a result, both the tonehole and |
| 7047 | register hole will have variable influence on |
| 7048 | the playing frequency, which is dependent on |
| 7049 | the length of the air column. In addition, |
| 7050 | the highest playing freqeuency is limited by |
| 7051 | these fixed lengths. |
| 7052 | This is a digital waveguide model, making its |
| 7053 | use possibly subject to patents held by Stanford |
| 7054 | University, Yamaha, and others. |
| 7055 | |
| 7056 | Control Change Numbers: |
| 7057 | - Reed Stiffness = 2 |
| 7058 | - Noise Gain = 4 |
| 7059 | - Tonehole State = 11 |
| 7060 | - Register State = 1 |
| 7061 | - Breath Pressure = 128 |
| 7062 | |
| 7063 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 7064 | */ |
| 7065 | /***************************************************/ |
| 7066 | |
| 7067 | #include <math.h> |
| 7068 | |
| 7069 | BlowHole :: BlowHole(MY_FLOAT lowestFrequency) |
| 7070 | { |
| 7071 | length = (long) (Stk::sampleRate() / lowestFrequency + 1); |
| 7072 | // delays[0] is the delay line between the reed and the register vent. |
| 7073 | delays[0] = (DelayL *) new DelayL( 5.0 * Stk::sampleRate() / 22050.0, 100 ); |
| 7074 | // delays[1] is the delay line between the register vent and the tonehole. |
| 7075 | delays[1] = (DelayL *) new DelayL( length >> 1, length ); |
| 7076 | // delays[2] is the delay line between the tonehole and the end of the bore. |
| 7077 | delays[2] = (DelayL *) new DelayL( 4.0 * Stk::sampleRate() / 22050.0, 100 ); |
| 7078 | reedTable = new ReedTabl(); |
| 7079 | reedTable->setOffset((MY_FLOAT) 0.7); |
| 7080 | reedTable->setSlope((MY_FLOAT) -0.3); |
| 7081 | filter = new OneZero; |
| 7082 | envelope = new Envelope; |
| 7083 | noise = new Noise; |
| 7084 | |
| 7085 | // Calculate the initial tonehole three-port scattering coefficient |
| 7086 | double r_b = 0.0075; // main bore radius |
| 7087 | r_th = 0.003; // tonehole radius |
| 7088 | scatter = -pow(r_th,2) / ( pow(r_th,2) + 2*pow(r_b,2) ); |
| 7089 | |
| 7090 | // Calculate tonehole coefficients |
| 7091 | MY_FLOAT te = 1.4 * r_th; // effective length of the open hole |
| 7092 | th_coeff = (te*2*Stk::sampleRate() - 347.23) / (te*2*Stk::sampleRate() + 347.23); |
| 7093 | tonehole = new PoleZero; |
| 7094 | // Start with tonehole open |
| 7095 | tonehole->setA1(-th_coeff); |
| 7096 | tonehole->setB0(th_coeff); |
| 7097 | tonehole->setB1(-1.0); |
| 7098 | |
| 7099 | // Calculate register hole filter coefficients |
| 7100 | double r_rh = 0.0015; // register vent radius |
| 7101 | te = 1.4 * r_rh; // effective length of the open hole |
| 7102 | double xi = 0.0; // series resistance term |
| 7103 | double zeta = 347.23 + 2*CK_ONE_PI*pow(r_b,2)*xi/1.1769; |
| 7104 | double psi = 2*CK_ONE_PI*pow(r_b,2)*te / (CK_ONE_PI*pow(r_rh,2)); |
| 7105 | rh_coeff = (zeta - 2 * Stk::sampleRate() * psi) / (zeta + 2 * Stk::sampleRate() * psi); |
| 7106 | rh_gain = -347.23 / (zeta + 2 * Stk::sampleRate() * psi); |
| 7107 | vent = new PoleZero; |
| 7108 | vent->setA1(rh_coeff); |
| 7109 | vent->setB0(1.0); |
| 7110 | vent->setB1(1.0); |
| 7111 | // Start with register vent closed |
| 7112 | vent->setGain(0.0); |
| 7113 | |
| 7114 | // Concatenate the STK rawwave path to the rawwave file |
| 7115 | vibrato = new WaveLoop( "special:sinewave", TRUE ); |
| 7116 | vibrato->setFrequency((MY_FLOAT) 5.735); |
| 7117 | outputGain = (MY_FLOAT) 1.0; |
| 7118 | noiseGain = (MY_FLOAT) 0.2; |
| 7119 | vibratoGain = (MY_FLOAT) 0.01; |
| 7120 | |
| 7121 | // set |
| 7122 | setFrequency( 220.0 ); |
| 7123 | |
| 7124 | // chuck data |
| 7125 | |
| 7126 | //m_reed = 0.5; // DONE: check default value <- old value |
| 7127 | //reverse: slope = -0.44 + (0.26 * norm) |
| 7128 | m_reed = (reedTable->slope + 0.44) / 0.26; |
| 7129 | //reverse: noiseGain = norm * 0.4 |
| 7130 | m_noiseGain = noiseGain / .4; |
| 7131 | //reverse: nothing |
| 7132 | m_tonehole = 1.0; |
| 7133 | //reverse: nothing |
| 7134 | m_vent = 0.0; |
| 7135 | //reverse: nothing |
| 7136 | m_pressure = 1.0; |
| 7137 | //reverse: nothing |
| 7138 | m_rate = envelope->rate; |
| 7139 | } |
| 7140 | |
| 7141 | BlowHole :: ~BlowHole() |
| 7142 | { |
| 7143 | delete delays[0]; |
| 7144 | delete delays[1]; |
| 7145 | delete delays[2]; |
| 7146 | delete reedTable; |
| 7147 | delete filter; |
| 7148 | delete tonehole; |
| 7149 | delete vent; |
| 7150 | delete envelope; |
| 7151 | delete noise; |
| 7152 | delete vibrato; |
| 7153 | } |
| 7154 | |
| 7155 | void BlowHole :: clear() |
| 7156 | { |
| 7157 | delays[0]->clear(); |
| 7158 | delays[1]->clear(); |
| 7159 | delays[2]->clear(); |
| 7160 | filter->tick((MY_FLOAT) 0.0); |
| 7161 | tonehole->tick((MY_FLOAT) 0.0); |
| 7162 | vent->tick((MY_FLOAT) 0.0); |
| 7163 | } |
| 7164 | |
| 7165 | void BlowHole :: setFrequency(MY_FLOAT frequency) |
| 7166 | { |
| 7167 | MY_FLOAT freakency = frequency; |
| 7168 | if ( frequency <= 0.0 ) { |
| 7169 | CK_STDCERR << "[chuck](via STK): BlowHole: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 7170 | freakency = 220.0; |
| 7171 | } |
| 7172 | |
| 7173 | // Delay = length - approximate filter delay. |
| 7174 | MY_FLOAT delay = (Stk::sampleRate() / freakency) * 0.5 - 3.5; |
| 7175 | delay -= delays[0]->getDelay() + delays[2]->getDelay(); |
| 7176 | |
| 7177 | if (delay <= 0.0) delay = 0.3; |
| 7178 | else if (delay > length) delay = length; |
| 7179 | delays[1]->setDelay(delay); |
| 7180 | |
| 7181 | // chuck |
| 7182 | m_frequency = freakency; |
| 7183 | } |
| 7184 | |
| 7185 | void BlowHole :: setVent(MY_FLOAT newValue) |
| 7186 | { |
| 7187 | // This method allows setting of the register vent "open-ness" at |
| 7188 | // any point between "Open" (newValue = 1) and "Closed" |
| 7189 | // (newValue = 0). |
| 7190 | |
| 7191 | MY_FLOAT gain; |
| 7192 | if (newValue <= 0.0) gain = 0.0; |
| 7193 | else if (newValue >= 1.0) gain = rh_gain; |
| 7194 | else gain = newValue * rh_gain; |
| 7195 | m_vent = newValue; |
| 7196 | vent->setGain(gain); |
| 7197 | } |
| 7198 | |
| 7199 | void BlowHole :: setTonehole(MY_FLOAT newValue) |
| 7200 | { |
| 7201 | // This method allows setting of the tonehole "open-ness" at |
| 7202 | // any point between "Open" (newValue = 1) and "Closed" |
| 7203 | // (newValue = 0). |
| 7204 | MY_FLOAT new_coeff; |
| 7205 | |
| 7206 | if (newValue <= 0.0) new_coeff = 0.9995; |
| 7207 | else if (newValue >= 1.0) new_coeff = th_coeff; |
| 7208 | else new_coeff = (newValue * (th_coeff - 0.9995)) + 0.9995; |
| 7209 | m_tonehole = newValue; |
| 7210 | tonehole->setA1(-new_coeff); |
| 7211 | tonehole->setB0(new_coeff); |
| 7212 | } |
| 7213 | |
| 7214 | void BlowHole :: startBlowing(MY_FLOAT amplitude, MY_FLOAT rate) |
| 7215 | { |
| 7216 | envelope->setRate(rate); |
| 7217 | envelope->setTarget(amplitude); |
| 7218 | } |
| 7219 | |
| 7220 | void BlowHole :: stopBlowing(MY_FLOAT rate) |
| 7221 | { |
| 7222 | envelope->setRate(rate); |
| 7223 | envelope->setTarget((MY_FLOAT) 0.0); |
| 7224 | } |
| 7225 | |
| 7226 | void BlowHole :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 7227 | { |
| 7228 | setFrequency(frequency); |
| 7229 | startBlowing((MY_FLOAT) 0.55 + (amplitude * 0.30), amplitude * 0.005); |
| 7230 | outputGain = amplitude + 0.001; |
| 7231 | |
| 7232 | #if defined(_STK_DEBUG_) |
| 7233 | CK_STDCERR << "[chuck](via STK): BlowHole: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 7234 | #endif |
| 7235 | } |
| 7236 | |
| 7237 | void BlowHole :: noteOff(MY_FLOAT amplitude) |
| 7238 | { |
| 7239 | this->stopBlowing(amplitude * 0.01); |
| 7240 | |
| 7241 | #if defined(_STK_DEBUG_) |
| 7242 | CK_STDCERR << "[chuck](via STK): BlowHole: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 7243 | #endif |
| 7244 | } |
| 7245 | |
| 7246 | MY_FLOAT BlowHole :: tick() |
| 7247 | { |
| 7248 | MY_FLOAT pressureDiff; |
| 7249 | MY_FLOAT breathPressure; |
| 7250 | MY_FLOAT temp; |
| 7251 | |
| 7252 | // Calculate the breath pressure (envelope + noise + vibrato) |
| 7253 | breathPressure = envelope->tick(); |
| 7254 | breathPressure += breathPressure * noiseGain * noise->tick(); |
| 7255 | breathPressure += breathPressure * vibratoGain * vibrato->tick(); |
| 7256 | |
| 7257 | // Calculate the differential pressure = reflected - mouthpiece pressures |
| 7258 | pressureDiff = delays[0]->lastOut() - breathPressure; |
| 7259 | |
| 7260 | // Do two-port junction scattering for register vent |
| 7261 | MY_FLOAT pa = breathPressure + pressureDiff * reedTable->tick(pressureDiff); |
| 7262 | MY_FLOAT pb = delays[1]->lastOut(); |
| 7263 | vent->tick(pa+pb); |
| 7264 | |
| 7265 | lastOutput = delays[0]->tick(vent->lastOut()+pb); |
| 7266 | lastOutput *= outputGain; |
| 7267 | |
| 7268 | // Do three-port junction scattering (under tonehole) |
| 7269 | pa += vent->lastOut(); |
| 7270 | pb = delays[2]->lastOut(); |
| 7271 | MY_FLOAT pth = tonehole->lastOut(); |
| 7272 | temp = scatter * (pa + pb - 2 * pth); |
| 7273 | |
| 7274 | delays[2]->tick(filter->tick(pa + temp) * -0.95); |
| 7275 | delays[1]->tick(pb + temp); |
| 7276 | tonehole->tick(pa + pb - pth + temp); |
| 7277 | |
| 7278 | return lastOutput; |
| 7279 | } |
| 7280 | |
| 7281 | void BlowHole :: controlChange(int number, MY_FLOAT value) |
| 7282 | { |
| 7283 | MY_FLOAT norm = value * ONE_OVER_128; |
| 7284 | if ( norm < 0 ) { |
| 7285 | norm = 0.0; |
| 7286 | CK_STDCERR << "[chuck](via STK): BlowHole: Control value less than zero!" << CK_STDENDL; |
| 7287 | } |
| 7288 | else if ( norm > 1.0 ) { |
| 7289 | norm = 1.0; |
| 7290 | CK_STDCERR << "[chuck](via STK): BlowHole: Control value exceeds nominal range!" << CK_STDENDL; |
| 7291 | } |
| 7292 | |
| 7293 | if (number == __SK_ReedStiffness_) { // 2 |
| 7294 | m_reed = norm; |
| 7295 | reedTable->setSlope( -0.44 + (0.26 * norm) ); |
| 7296 | } |
| 7297 | else if (number == __SK_NoiseLevel_) { // 4 |
| 7298 | m_noiseGain = norm; |
| 7299 | noiseGain = ( norm * 0.4 ); |
| 7300 | } |
| 7301 | else if (number == __SK_ModFrequency_) // 11 |
| 7302 | this->setTonehole( norm ); |
| 7303 | else if (number == __SK_ModWheel_) // 1 |
| 7304 | this->setVent( norm ); |
| 7305 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 7306 | m_pressure = norm; |
| 7307 | envelope->setValue( norm ); |
| 7308 | } |
| 7309 | else |
| 7310 | CK_STDCERR << "[chuck](via STK): BlowHole: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 7311 | |
| 7312 | #if defined(_STK_DEBUG_) |
| 7313 | CK_STDCERR << "[chuck](via STK): BlowHole: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 7314 | #endif |
| 7315 | } |
| 7316 | |
| 7317 | |
| 7318 | /***************************************************/ |
| 7319 | /*! \class BowTabl |
| 7320 | \brief STK bowed string table class. |
| 7321 | |
| 7322 | This class implements a simple bowed string |
| 7323 | non-linear function, as described by Smith (1986). |
| 7324 | |
| 7325 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 7326 | */ |
| 7327 | /***************************************************/ |
| 7328 | |
| 7329 | #include <math.h> |
| 7330 | |
| 7331 | BowTabl :: BowTabl() |
| 7332 | { |
| 7333 | offSet = (MY_FLOAT) 0.0; |
| 7334 | slope = (MY_FLOAT) 0.1; |
| 7335 | lastOutput = 0.0; |
| 7336 | } |
| 7337 | |
| 7338 | BowTabl :: ~BowTabl() |
| 7339 | { |
| 7340 | } |
| 7341 | |
| 7342 | void BowTabl :: setOffset(MY_FLOAT aValue) |
| 7343 | { |
| 7344 | offSet = aValue; |
| 7345 | } |
| 7346 | |
| 7347 | void BowTabl :: setSlope(MY_FLOAT aValue) |
| 7348 | { |
| 7349 | slope = aValue; |
| 7350 | } |
| 7351 | |
| 7352 | MY_FLOAT BowTabl :: lastOut() const |
| 7353 | { |
| 7354 | return lastOutput; |
| 7355 | } |
| 7356 | |
| 7357 | MY_FLOAT BowTabl :: tick(MY_FLOAT input) |
| 7358 | { |
| 7359 | // The input represents differential string vs. bow velocity. |
| 7360 | MY_FLOAT sample; |
| 7361 | sample = input + offSet; // add bias to input |
| 7362 | sample *= slope; // then scale it |
| 7363 | lastOutput = (MY_FLOAT)fabs((double) sample) + (MY_FLOAT) 0.75; |
| 7364 | lastOutput = (MY_FLOAT)pow( lastOutput,(MY_FLOAT) -4.0 ); |
| 7365 | |
| 7366 | // set minimum friction to 0.0 |
| 7367 | //if (lastOutput < 0.0 ) lastOutput = 0.0; |
| 7368 | // set maximum friction to 1.0. |
| 7369 | if (lastOutput > 1.0 ) lastOutput = (MY_FLOAT) 1.0; |
| 7370 | |
| 7371 | return lastOutput; |
| 7372 | } |
| 7373 | |
| 7374 | MY_FLOAT *BowTabl :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 7375 | { |
| 7376 | for (unsigned int i=0; i<vectorSize; i++) |
| 7377 | vec[i] = tick(vec[i]); |
| 7378 | |
| 7379 | return vec; |
| 7380 | } |
| 7381 | |
| 7382 | |
| 7383 | /***************************************************/ |
| 7384 | /*! \class Bowed |
| 7385 | \brief STK bowed string instrument class. |
| 7386 | |
| 7387 | This class implements a bowed string model, a |
| 7388 | la Smith (1986), after McIntyre, Schumacher, |
| 7389 | Woodhouse (1983). |
| 7390 | |
| 7391 | This is a digital waveguide model, making its |
| 7392 | use possibly subject to patents held by |
| 7393 | Stanford University, Yamaha, and others. |
| 7394 | |
| 7395 | Control Change Numbers: |
| 7396 | - Bow Pressure = 2 |
| 7397 | - Bow Position = 4 |
| 7398 | - Vibrato Frequency = 11 |
| 7399 | - Vibrato Gain = 1 |
| 7400 | - Volume = 128 |
| 7401 | |
| 7402 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 7403 | */ |
| 7404 | /***************************************************/ |
| 7405 | |
| 7406 | |
| 7407 | Bowed :: Bowed(MY_FLOAT lowestFrequency) |
| 7408 | { |
| 7409 | long length; |
| 7410 | length = (long) (Stk::sampleRate() / lowestFrequency + 1); |
| 7411 | neckDelay = new DelayL(100.0, length); |
| 7412 | length >>= 1; |
| 7413 | bridgeDelay = new DelayL(29.0, length); |
| 7414 | |
| 7415 | bowTable = new BowTabl; |
| 7416 | bowTable->setSlope((MY_FLOAT) 3.0); |
| 7417 | |
| 7418 | // Concatenate the STK rawwave path to the rawwave file |
| 7419 | vibrato = new WaveLoop( "special:sinewave", TRUE ); |
| 7420 | vibrato->setFrequency((MY_FLOAT) 6.12723); |
| 7421 | vibratoGain = (MY_FLOAT) 0.0; |
| 7422 | |
| 7423 | stringFilter = new OnePole; |
| 7424 | stringFilter->setPole((MY_FLOAT) (0.6 - (0.1 * 22050.0 / Stk::sampleRate() ) ) ); |
| 7425 | stringFilter->setGain((MY_FLOAT) 0.95); |
| 7426 | |
| 7427 | bodyFilter = new BiQuad; |
| 7428 | bodyFilter->setResonance( 500.0, 0.85, TRUE ); |
| 7429 | bodyFilter->setGain((MY_FLOAT) 0.2); |
| 7430 | |
| 7431 | adsr = new ADSR; |
| 7432 | adsr->setAllTimes((MY_FLOAT) 0.02,(MY_FLOAT) 0.005,(MY_FLOAT) 0.9,(MY_FLOAT) 0.01); |
| 7433 | |
| 7434 | betaRatio = (MY_FLOAT)0.127236; |
| 7435 | |
| 7436 | // Necessary to initialize internal variables. |
| 7437 | setFrequency( 220.0 ); |
| 7438 | |
| 7439 | // CHUCK |
| 7440 | //reverse: bowTable->setSlope( 5.0 - (4.0 * norm) ); |
| 7441 | m_bowPressure = (bowTable->slope - 5.0) / -4.0; |
| 7442 | //reverse: betaRatio = 0.027236 + (0.2 * norm); |
| 7443 | m_bowPosition = (betaRatio - .027236) / .2; |
| 7444 | //reverse: setVibratoFreq( norm * 12.0 ); |
| 7445 | m_vibratoFreq = vibrato->m_freq / 12.0; |
| 7446 | //reverse: vibratoGain = ( norm * 0.4 ); |
| 7447 | m_vibratoGain = 0.0; // vibratoGain / 0.4 |
| 7448 | //reverse: nothing |
| 7449 | m_volume = 1.0; |
| 7450 | } |
| 7451 | |
| 7452 | Bowed :: ~Bowed() |
| 7453 | { |
| 7454 | delete neckDelay; |
| 7455 | delete bridgeDelay; |
| 7456 | delete bowTable; |
| 7457 | delete stringFilter; |
| 7458 | delete bodyFilter; |
| 7459 | delete vibrato; |
| 7460 | delete adsr; |
| 7461 | } |
| 7462 | |
| 7463 | void Bowed :: clear() |
| 7464 | { |
| 7465 | neckDelay->clear(); |
| 7466 | bridgeDelay->clear(); |
| 7467 | } |
| 7468 | |
| 7469 | void Bowed :: setFrequency(MY_FLOAT frequency) |
| 7470 | { |
| 7471 | MY_FLOAT freakency = frequency; |
| 7472 | if ( frequency <= 0.0 ) { |
| 7473 | CK_STDCERR << "[chuck](via STK): Bowed: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 7474 | freakency = 220.0; |
| 7475 | } |
| 7476 | |
| 7477 | // Delay = length - approximate filter delay. |
| 7478 | baseDelay = Stk::sampleRate() / freakency - (MY_FLOAT) 4.0; |
| 7479 | if ( baseDelay <= 0.0 ) baseDelay = 0.3; |
| 7480 | bridgeDelay->setDelay(baseDelay * betaRatio); // bow to bridge length |
| 7481 | neckDelay->setDelay(baseDelay * ((MY_FLOAT) 1.0 - betaRatio)); // bow to nut (finger) length |
| 7482 | |
| 7483 | // chuck |
| 7484 | m_frequency = freakency; |
| 7485 | } |
| 7486 | |
| 7487 | void Bowed :: startBowing(MY_FLOAT amplitude, MY_FLOAT rate) |
| 7488 | { |
| 7489 | adsr->setRate(rate); |
| 7490 | adsr->keyOn(); |
| 7491 | maxVelocity = (MY_FLOAT) 0.03 + ((MY_FLOAT) 0.2 * amplitude); |
| 7492 | } |
| 7493 | |
| 7494 | void Bowed :: stopBowing(MY_FLOAT rate) |
| 7495 | { |
| 7496 | adsr->setRate(rate); |
| 7497 | adsr->keyOff(); |
| 7498 | } |
| 7499 | |
| 7500 | void Bowed :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 7501 | { |
| 7502 | this->startBowing(amplitude, amplitude * 0.001); |
| 7503 | this->setFrequency(frequency); |
| 7504 | |
| 7505 | #if defined(_STK_DEBUG_) |
| 7506 | CK_STDCERR << "[chuck](via STK): Bowed: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 7507 | #endif |
| 7508 | } |
| 7509 | |
| 7510 | void Bowed :: noteOff(MY_FLOAT amplitude) |
| 7511 | { |
| 7512 | this->stopBowing(((MY_FLOAT) 1.0 - amplitude) * (MY_FLOAT) 0.005); |
| 7513 | |
| 7514 | #if defined(_STK_DEBUG_) |
| 7515 | CK_STDCERR << "[chuck](via STK): Bowed: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 7516 | #endif |
| 7517 | } |
| 7518 | |
| 7519 | void Bowed :: setVibrato(MY_FLOAT gain) |
| 7520 | { |
| 7521 | vibratoGain = gain; |
| 7522 | } |
| 7523 | |
| 7524 | MY_FLOAT Bowed :: tick() |
| 7525 | { |
| 7526 | MY_FLOAT bowVelocity; |
| 7527 | MY_FLOAT bridgeRefl; |
| 7528 | MY_FLOAT nutRefl; |
| 7529 | MY_FLOAT newVel; |
| 7530 | MY_FLOAT velDiff; |
| 7531 | MY_FLOAT stringVel; |
| 7532 | |
| 7533 | bowVelocity = maxVelocity * adsr->tick(); |
| 7534 | |
| 7535 | bridgeRefl = -stringFilter->tick( bridgeDelay->lastOut() ); |
| 7536 | nutRefl = -neckDelay->lastOut(); |
| 7537 | stringVel = bridgeRefl + nutRefl; // Sum is String Velocity |
| 7538 | velDiff = bowVelocity - stringVel; // Differential Velocity |
| 7539 | newVel = velDiff * bowTable->tick( velDiff ); // Non-Linear Bow Function |
| 7540 | neckDelay->tick(bridgeRefl + newVel); // Do string propagations |
| 7541 | bridgeDelay->tick(nutRefl + newVel); |
| 7542 | |
| 7543 | if (vibratoGain > 0.0) { |
| 7544 | neckDelay->setDelay((baseDelay * ((MY_FLOAT) 1.0 - betaRatio)) + |
| 7545 | (baseDelay * vibratoGain * vibrato->tick())); |
| 7546 | } |
| 7547 | |
| 7548 | lastOutput = bodyFilter->tick(bridgeDelay->lastOut()); |
| 7549 | |
| 7550 | return lastOutput; |
| 7551 | } |
| 7552 | |
| 7553 | void Bowed :: controlChange(int number, MY_FLOAT value) |
| 7554 | { |
| 7555 | MY_FLOAT norm = value * ONE_OVER_128; |
| 7556 | if ( norm < 0 ) { |
| 7557 | norm = 0.0; |
| 7558 | CK_STDCERR << "[chuck](via STK): Bowed: Control value less than zero!" << CK_STDENDL; |
| 7559 | } |
| 7560 | else if ( norm > 1.0 ) { |
| 7561 | norm = 1.0; |
| 7562 | CK_STDCERR << "[chuck](via STK): Bowed: Control value exceeds nominal range!" << CK_STDENDL; |
| 7563 | } |
| 7564 | |
| 7565 | if (number == __SK_BowPressure_) { // 2 |
| 7566 | m_bowPressure = norm; |
| 7567 | bowTable->setSlope( 5.0 - (4.0 * norm) ); |
| 7568 | } |
| 7569 | else if (number == __SK_BowPosition_) { // 4 |
| 7570 | m_bowPosition = norm; |
| 7571 | betaRatio = 0.027236 + (0.2 * norm); |
| 7572 | bridgeDelay->setDelay(baseDelay * betaRatio); |
| 7573 | neckDelay->setDelay(baseDelay * ((MY_FLOAT) 1.0 - betaRatio)); |
| 7574 | } |
| 7575 | else if (number == __SK_ModFrequency_) { // 11 |
| 7576 | setVibratoFreq( norm * 12.0 ); |
| 7577 | m_vibratoFreq = norm; |
| 7578 | } |
| 7579 | else if (number == __SK_ModWheel_) { // 1 |
| 7580 | m_vibratoGain = norm; |
| 7581 | vibratoGain = ( norm * 0.4 ); |
| 7582 | } |
| 7583 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 7584 | m_volume = norm; |
| 7585 | adsr->setTarget(norm); |
| 7586 | } |
| 7587 | else |
| 7588 | CK_STDCERR << "[chuck](via STK): Bowed: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 7589 | |
| 7590 | #if defined(_STK_DEBUG_) |
| 7591 | CK_STDCERR << "[chuck](via STK): Bowed: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 7592 | #endif |
| 7593 | } |
| 7594 | |
| 7595 | |
| 7596 | /***************************************************/ |
| 7597 | /*! \class Brass |
| 7598 | \brief STK simple brass instrument class. |
| 7599 | |
| 7600 | This class implements a simple brass instrument |
| 7601 | waveguide model, a la Cook (TBone, HosePlayer). |
| 7602 | |
| 7603 | This is a digital waveguide model, making its |
| 7604 | use possibly subject to patents held by |
| 7605 | Stanford University, Yamaha, and others. |
| 7606 | |
| 7607 | Control Change Numbers: |
| 7608 | - Lip Tension = 2 |
| 7609 | - Slide Length = 4 |
| 7610 | - Vibrato Frequency = 11 |
| 7611 | - Vibrato Gain = 1 |
| 7612 | - Volume = 128 |
| 7613 | |
| 7614 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 7615 | */ |
| 7616 | /***************************************************/ |
| 7617 | |
| 7618 | #include <math.h> |
| 7619 | |
| 7620 | Brass :: Brass(MY_FLOAT lowestFrequency) |
| 7621 | { |
| 7622 | length = (long) (Stk::sampleRate() / lowestFrequency + 1); |
| 7623 | delayLine = new DelayA( 0.5 * length, length ); |
| 7624 | |
| 7625 | lipFilter = new BiQuad(); |
| 7626 | lipFilter->setGain( 0.03 ); |
| 7627 | dcBlock = new PoleZero(); |
| 7628 | dcBlock->setBlockZero(); |
| 7629 | |
| 7630 | adsr = new ADSR; |
| 7631 | adsr->setAllTimes( 0.005, 0.001, 1.0, 0.010); |
| 7632 | |
| 7633 | // Concatenate the STK rawwave path to the rawwave file |
| 7634 | vibrato = new WaveLoop( "special:sinewave", TRUE ); |
| 7635 | vibrato->setFrequency( 6.137 ); |
| 7636 | vibratoGain = 0.0; |
| 7637 | |
| 7638 | this->clear(); |
| 7639 | maxPressure = (MY_FLOAT) 0.0; |
| 7640 | lipTarget = 0.0; |
| 7641 | // initialize to something | 1.4.1.0 |
| 7642 | slideTarget = (Stk::sampleRate() / 220 * 2.0) + 3.0; |
| 7643 | |
| 7644 | // Necessary to initialize variables. |
| 7645 | setFrequency( 220.0 ); |
| 7646 | |
| 7647 | // CHUCK |
| 7648 | //reverse: nothing |
| 7649 | m_rate = .005; |
| 7650 | //reverse: I give up! |
| 7651 | m_lip = 0.1; |
| 7652 | //reverse: this is a special variable... we'll just leave this be for now |
| 7653 | m_slide = length; |
| 7654 | //reverse: setVibratoFreq( norm * 12.0 ); |
| 7655 | m_vibratoFreq = vibrato->m_freq / 12.0; |
| 7656 | //reverse: setVibratoGain(norm * 0.4) |
| 7657 | m_vibratoGain = 0.0; |
| 7658 | //reverse: nothing |
| 7659 | m_volume = 1.0; |
| 7660 | } |
| 7661 | |
| 7662 | Brass :: ~Brass() |
| 7663 | { |
| 7664 | delete delayLine; |
| 7665 | delete lipFilter; |
| 7666 | delete dcBlock; |
| 7667 | delete adsr; |
| 7668 | delete vibrato; |
| 7669 | } |
| 7670 | |
| 7671 | void Brass :: clear() |
| 7672 | { |
| 7673 | delayLine->clear(); |
| 7674 | lipFilter->clear(); |
| 7675 | dcBlock->clear(); |
| 7676 | } |
| 7677 | |
| 7678 | void Brass :: setFrequency(MY_FLOAT frequency) |
| 7679 | { |
| 7680 | MY_FLOAT freakency = frequency; |
| 7681 | if ( frequency <= 0.0 ) { |
| 7682 | CK_STDCERR << "[chuck](via STK): Brass: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 7683 | freakency = 220.0; |
| 7684 | } |
| 7685 | |
| 7686 | // Fudge correction for filter delays. |
| 7687 | slideTarget = (Stk::sampleRate() / freakency * 2.0) + 3.0; |
| 7688 | delayLine->setDelay(slideTarget); // play a harmonic |
| 7689 | |
| 7690 | lipTarget = freakency; |
| 7691 | lipFilter->setResonance( freakency, 0.997 ); |
| 7692 | |
| 7693 | // chuck |
| 7694 | m_frequency = freakency; |
| 7695 | } |
| 7696 | |
| 7697 | void Brass :: setLip(MY_FLOAT frequency) |
| 7698 | { |
| 7699 | MY_FLOAT freakency = frequency; |
| 7700 | if ( frequency <= 0.0 ) { |
| 7701 | CK_STDCERR << "[chuck](via STK): Brass: setLip parameter is less than or equal to zero!" << CK_STDENDL; |
| 7702 | freakency = 220.0; |
| 7703 | } |
| 7704 | |
| 7705 | lipFilter->setResonance( freakency, 0.997 ); |
| 7706 | } |
| 7707 | |
| 7708 | void Brass :: startBlowing(MY_FLOAT amplitude, MY_FLOAT rate) |
| 7709 | { |
| 7710 | adsr->setAttackRate(rate); |
| 7711 | maxPressure = amplitude; |
| 7712 | adsr->keyOn(); |
| 7713 | } |
| 7714 | |
| 7715 | void Brass :: stopBlowing(MY_FLOAT rate) |
| 7716 | { |
| 7717 | adsr->setReleaseRate(rate); |
| 7718 | adsr->keyOff(); |
| 7719 | } |
| 7720 | |
| 7721 | void Brass :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 7722 | { |
| 7723 | setFrequency(frequency); |
| 7724 | this->startBlowing(amplitude, amplitude * 0.001); |
| 7725 | |
| 7726 | #if defined(_STK_DEBUG_) |
| 7727 | CK_STDCERR << "[chuck](via STK): Brass: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 7728 | #endif |
| 7729 | } |
| 7730 | |
| 7731 | void Brass :: noteOff(MY_FLOAT amplitude) |
| 7732 | { |
| 7733 | this->stopBlowing(amplitude * 0.005); |
| 7734 | |
| 7735 | #if defined(_STK_DEBUG_) |
| 7736 | CK_STDCERR << "[chuck](via STK): Brass: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 7737 | #endif |
| 7738 | } |
| 7739 | |
| 7740 | MY_FLOAT Brass :: tick() |
| 7741 | { |
| 7742 | MY_FLOAT breathPressure = maxPressure * adsr->tick(); |
| 7743 | breathPressure += vibratoGain * vibrato->tick(); |
| 7744 | |
| 7745 | MY_FLOAT mouthPressure = 0.3 * breathPressure; |
| 7746 | MY_FLOAT borePressure = 0.85 * delayLine->lastOut(); |
| 7747 | MY_FLOAT deltaPressure = mouthPressure - borePressure; // Differential pressure. |
| 7748 | deltaPressure = lipFilter->tick( deltaPressure ); // Force - > position. |
| 7749 | deltaPressure *= deltaPressure; // Basic position to area mapping. |
| 7750 | if ( deltaPressure > 1.0 ) deltaPressure = 1.0; // Non-linear saturation. |
| 7751 | // The following input scattering assumes the mouthPressure = area. |
| 7752 | lastOutput = deltaPressure * mouthPressure + ( 1.0 - deltaPressure) * borePressure; |
| 7753 | lastOutput = delayLine->tick( dcBlock->tick( lastOutput ) ); |
| 7754 | |
| 7755 | return lastOutput; |
| 7756 | } |
| 7757 | |
| 7758 | void Brass :: controlChange(int number, MY_FLOAT value) |
| 7759 | { |
| 7760 | MY_FLOAT norm = value * ONE_OVER_128; |
| 7761 | if ( norm < 0 ) { |
| 7762 | norm = 0.0; |
| 7763 | CK_STDCERR << "[chuck](via STK): Brass: Control value less than zero!" << CK_STDENDL; |
| 7764 | } |
| 7765 | else if ( norm > 1.0 ) { |
| 7766 | norm = 1.0; |
| 7767 | CK_STDCERR << "[chuck](via STK): Brass: Control value exceeds nominal range!" << CK_STDENDL; |
| 7768 | } |
| 7769 | |
| 7770 | if (number == __SK_LipTension_) { // 2 |
| 7771 | MY_FLOAT temp = lipTarget * pow( 4.0, (2.0 * norm) - 1.0 ); |
| 7772 | m_lip = norm; |
| 7773 | this->setLip(temp); |
| 7774 | } |
| 7775 | else if (number == __SK_SlideLength_) { // 4 |
| 7776 | m_slide = norm; |
| 7777 | delayLine->setDelay( slideTarget * (0.5 + norm) ); |
| 7778 | } |
| 7779 | else if (number == __SK_ModFrequency_) // 11 |
| 7780 | setVibratoFreq( norm * 12.0 ); |
| 7781 | else if (number == __SK_ModWheel_ ) { // 1 |
| 7782 | m_vibratoGain = norm; |
| 7783 | vibratoGain = norm * 0.4; |
| 7784 | } |
| 7785 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 7786 | m_volume = norm; |
| 7787 | adsr->setTarget( norm ); |
| 7788 | } |
| 7789 | else |
| 7790 | CK_STDCERR << "[chuck](via STK): Brass: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 7791 | |
| 7792 | #if defined(_STK_DEBUG_) |
| 7793 | CK_STDCERR << "[chuck](via STK): Brass: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 7794 | #endif |
| 7795 | } |
| 7796 | |
| 7797 | /***************************************************/ |
| 7798 | /*! \class Chorus |
| 7799 | \brief STK chorus effect class. |
| 7800 | |
| 7801 | This class implements a chorus effect. |
| 7802 | |
| 7803 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 7804 | */ |
| 7805 | /***************************************************/ |
| 7806 | |
| 7807 | #include <iostream> |
| 7808 | |
| 7809 | Chorus :: Chorus(MY_FLOAT baseDelay) |
| 7810 | { |
| 7811 | delayLine[0] = delayLine[1] = NULL; |
| 7812 | mods[0] = new WaveLoop( "special:sinewave", TRUE ); |
| 7813 | mods[1] = NULL; |
| 7814 | set(baseDelay, 4); |
| 7815 | setDelay( baseDelay ); |
| 7816 | setModDepth( .5 ); |
| 7817 | setModFrequency( .25 ); |
| 7818 | |
| 7819 | // Concatenate the STK rawwave path to the rawwave file |
| 7820 | // mods[0] = new WaveLoop( "special:sinewave", TRUE ); |
| 7821 | // mods[1] = new WaveLoop( "special:sinewave", TRUE ); |
| 7822 | // mods[0]->setFrequency(0.2); |
| 7823 | // mods[1]->setFrequency(0.222222); |
| 7824 | effectMix = 0.5; |
| 7825 | } |
| 7826 | |
| 7827 | Chorus :: ~Chorus() |
| 7828 | { |
| 7829 | CK_SAFE_DELETE( delayLine[0] ); |
| 7830 | CK_SAFE_DELETE( delayLine[1] ); |
| 7831 | CK_SAFE_DELETE( mods[0] ); |
| 7832 | CK_SAFE_DELETE( mods[1] ); |
| 7833 | } |
| 7834 | |
| 7835 | // chuck |
| 7836 | void Chorus :: set(MY_FLOAT baseDelay, MY_FLOAT depth) |
| 7837 | { |
| 7838 | CK_SAFE_DELETE( delayLine[0] ); |
| 7839 | CK_SAFE_DELETE( delayLine[1] ); |
| 7840 | |
| 7841 | delayLine[0] = new DelayL((long) baseDelay, (long) (baseDelay + baseDelay * depth) + 2); |
| 7842 | // delayLine[0] = new DelayL((long) baseDelay, (long) (baseDelay + baseDelay * 1.414 * depth) + 2); |
| 7843 | // delayLine[1] = new DelayL((long) baseDelay, (long) (baseDelay + baseDelay * depth) + 2); |
| 7844 | |
| 7845 | this->clear(); |
| 7846 | } |
| 7847 | |
| 7848 | void Chorus :: clear() |
| 7849 | { |
| 7850 | delayLine[0]->clear(); |
| 7851 | // delayLine[1]->clear(); |
| 7852 | lastOutput[0] = 0.0; |
| 7853 | lastOutput[1] = 0.0; |
| 7854 | } |
| 7855 | |
| 7856 | void Chorus :: setEffectMix(MY_FLOAT mix) |
| 7857 | { |
| 7858 | effectMix = mix; |
| 7859 | if ( mix < 0.0 ) { |
| 7860 | CK_STDCERR << "[chuck](via STK): Chorus: setEffectMix parameter (" << mix << ") is less than zero!" << CK_STDENDL; |
| 7861 | effectMix = 0.0; |
| 7862 | } |
| 7863 | else if ( mix > 1.0 ) { |
| 7864 | CK_STDCERR << "[chuck](via STK): Chorus: setEffectMix parameter (" << mix << ") is greater than 1.0!" << CK_STDENDL; |
| 7865 | effectMix = 1.0; |
| 7866 | } |
| 7867 | } |
| 7868 | |
| 7869 | void Chorus :: setModDepth(MY_FLOAT depth) |
| 7870 | { |
| 7871 | modDepth = depth; |
| 7872 | } |
| 7873 | |
| 7874 | void Chorus :: setDelay(MY_FLOAT baseDelay) |
| 7875 | { |
| 7876 | baseLength = baseDelay; |
| 7877 | } |
| 7878 | |
| 7879 | void Chorus :: setModFrequency(MY_FLOAT frequency) |
| 7880 | { |
| 7881 | mods[0]->setFrequency(frequency); |
| 7882 | // mods[1]->setFrequency(frequency * 1.1111); |
| 7883 | } |
| 7884 | |
| 7885 | MY_FLOAT Chorus :: lastOut() const |
| 7886 | { |
| 7887 | // return (lastOutput[0] + lastOutput[1]) * (MY_FLOAT) 0.5; |
| 7888 | return lastOutput[0]; |
| 7889 | } |
| 7890 | |
| 7891 | MY_FLOAT Chorus :: lastOutLeft() const |
| 7892 | { |
| 7893 | return lastOutput[0]; |
| 7894 | } |
| 7895 | |
| 7896 | MY_FLOAT Chorus :: lastOutRight() const |
| 7897 | { |
| 7898 | return lastOutput[1]; |
| 7899 | } |
| 7900 | |
| 7901 | MY_FLOAT Chorus :: tick(MY_FLOAT input) |
| 7902 | { |
| 7903 | delayLine[0]->setDelay(baseLength * modDepth * .5 * (1.0 + mods[0]->tick())); |
| 7904 | // delayLine[0]->setDelay(baseLength * 0.707 * modDepth * (1.0 + mods[0]->tick())); |
| 7905 | // delayLine[1]->setDelay(baseLength * 0.5 * modDepth * (1.0 + mods[1]->tick())); |
| 7906 | lastOutput[0] = input * (1.0 - effectMix); |
| 7907 | lastOutput[0] += effectMix * delayLine[0]->tick(input); |
| 7908 | // lastOutput[1] = input * (1.0 - effectMix); |
| 7909 | // lastOutput[1] += effectMix * delayLine[1]->tick(input); |
| 7910 | // return (lastOutput[0] + lastOutput[1]) * (MY_FLOAT) 0.5; |
| 7911 | return lastOutput[0]; |
| 7912 | } |
| 7913 | |
| 7914 | MY_FLOAT *Chorus :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 7915 | { |
| 7916 | for (unsigned int i=0; i<vectorSize; i++) |
| 7917 | vec[i] = tick(vec[i]); |
| 7918 | |
| 7919 | return vec; |
| 7920 | } |
| 7921 | /***************************************************/ |
| 7922 | /*! \class Clarinet |
| 7923 | \brief STK clarinet physical model class. |
| 7924 | |
| 7925 | This class implements a simple clarinet |
| 7926 | physical model, as discussed by Smith (1986), |
| 7927 | McIntyre, Schumacher, Woodhouse (1983), and |
| 7928 | others. |
| 7929 | |
| 7930 | This is a digital waveguide model, making its |
| 7931 | use possibly subject to patents held by Stanford |
| 7932 | University, Yamaha, and others. |
| 7933 | |
| 7934 | Control Change Numbers: |
| 7935 | - Reed Stiffness = 2 |
| 7936 | - Noise Gain = 4 |
| 7937 | - Vibrato Frequency = 11 |
| 7938 | - Vibrato Gain = 1 |
| 7939 | - Breath Pressure = 128 |
| 7940 | |
| 7941 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 7942 | */ |
| 7943 | /***************************************************/ |
| 7944 | |
| 7945 | |
| 7946 | Clarinet :: Clarinet(MY_FLOAT lowestFrequency) |
| 7947 | { |
| 7948 | length = (long) (Stk::sampleRate() / lowestFrequency + 1); |
| 7949 | delayLine = new DelayL( (MY_FLOAT)(length / 2.0), length); |
| 7950 | reedTable = new ReedTabl(); |
| 7951 | reedTable->setOffset((MY_FLOAT) 0.7); |
| 7952 | reedTable->setSlope((MY_FLOAT) -0.3); |
| 7953 | filter = new OneZero; |
| 7954 | envelope = new Envelope; |
| 7955 | noise = new Noise; |
| 7956 | |
| 7957 | // Concatenate the STK rawwave path to the rawwave file |
| 7958 | vibrato = new WaveLoop( "special:sinewave", TRUE ); |
| 7959 | vibrato->setFrequency((MY_FLOAT) 5.735); |
| 7960 | outputGain = (MY_FLOAT) 1.0; |
| 7961 | noiseGain = (MY_FLOAT) 0.2; |
| 7962 | vibratoGain = (MY_FLOAT) 0.1; |
| 7963 | |
| 7964 | // set |
| 7965 | setFrequency( 220.0 ); |
| 7966 | |
| 7967 | // CHUCK |
| 7968 | //reverse: reedTable->setSlope((MY_FLOAT) -0.44 + ( (MY_FLOAT) 0.26 * norm )) |
| 7969 | m_reed = (reedTable->slope + 0.44) / 0.26; |
| 7970 | //reverse: noiseGain = (norm * (MY_FLOAT) 0.4); |
| 7971 | m_noiseGain = noiseGain / .4; |
| 7972 | //reverse: setVibratoFreq( norm * 12.0 ); |
| 7973 | m_vibratoFreq = vibrato->m_freq / 12.0; |
| 7974 | //reverse: vibratoGain = (norm * (MY_FLOAT) 0.5); |
| 7975 | m_vibratoGain = .1 / 0.5; |
| 7976 | //reverse: nothing |
| 7977 | m_volume = 1.0; |
| 7978 | //reverse: nothing |
| 7979 | m_rate = .005; |
| 7980 | } |
| 7981 | |
| 7982 | Clarinet :: ~Clarinet() |
| 7983 | { |
| 7984 | delete delayLine; |
| 7985 | delete reedTable; |
| 7986 | delete filter; |
| 7987 | delete envelope; |
| 7988 | delete noise; |
| 7989 | delete vibrato; |
| 7990 | } |
| 7991 | |
| 7992 | void Clarinet :: clear() |
| 7993 | { |
| 7994 | delayLine->clear(); |
| 7995 | filter->tick((MY_FLOAT) 0.0); |
| 7996 | } |
| 7997 | |
| 7998 | void Clarinet :: setFrequency(MY_FLOAT frequency) |
| 7999 | { |
| 8000 | MY_FLOAT freakency = frequency; |
| 8001 | if ( frequency <= 0.0 ) { |
| 8002 | CK_STDCERR << "[chuck](via STK): Clarinet: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 8003 | freakency = 220.0; |
| 8004 | } |
| 8005 | |
| 8006 | // Delay = length - approximate filter delay. |
| 8007 | MY_FLOAT delay = (Stk::sampleRate() / freakency) * 0.5 - 1.5; |
| 8008 | if (delay <= 0.0) delay = 0.3; |
| 8009 | else if (delay > length) delay = length; |
| 8010 | delayLine->setDelay(delay); |
| 8011 | |
| 8012 | // chuck |
| 8013 | m_frequency = freakency; |
| 8014 | } |
| 8015 | |
| 8016 | void Clarinet :: startBlowing(MY_FLOAT amplitude, MY_FLOAT rate) |
| 8017 | { |
| 8018 | envelope->setRate(rate); |
| 8019 | envelope->setTarget(amplitude); |
| 8020 | } |
| 8021 | |
| 8022 | void Clarinet :: stopBlowing(MY_FLOAT rate) |
| 8023 | { |
| 8024 | envelope->setRate(rate); |
| 8025 | envelope->setTarget((MY_FLOAT) 0.0); |
| 8026 | } |
| 8027 | |
| 8028 | void Clarinet :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 8029 | { |
| 8030 | this->setFrequency(frequency); |
| 8031 | this->startBlowing((MY_FLOAT) 0.55 + (amplitude * (MY_FLOAT) 0.30), amplitude * (MY_FLOAT) 0.005); |
| 8032 | outputGain = amplitude + (MY_FLOAT) 0.001; |
| 8033 | |
| 8034 | #if defined(_STK_DEBUG_) |
| 8035 | CK_STDCERR << "[chuck](via STK): Clarinet: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 8036 | #endif |
| 8037 | } |
| 8038 | |
| 8039 | void Clarinet :: noteOff(MY_FLOAT amplitude) |
| 8040 | { |
| 8041 | this->stopBlowing(amplitude * (MY_FLOAT) 0.01); |
| 8042 | |
| 8043 | #if defined(_STK_DEBUG_) |
| 8044 | CK_STDCERR << "[chuck](via STK): Clarinet: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 8045 | #endif |
| 8046 | } |
| 8047 | |
| 8048 | MY_FLOAT Clarinet :: tick() |
| 8049 | { |
| 8050 | MY_FLOAT pressureDiff; |
| 8051 | MY_FLOAT breathPressure; |
| 8052 | |
| 8053 | // Calculate the breath pressure (envelope + noise + vibrato) |
| 8054 | breathPressure = envelope->tick(); |
| 8055 | breathPressure += breathPressure * noiseGain * noise->tick(); |
| 8056 | breathPressure += breathPressure * vibratoGain * vibrato->tick(); |
| 8057 | |
| 8058 | // Perform commuted loss filtering. |
| 8059 | pressureDiff = -0.95 * filter->tick(delayLine->lastOut()); |
| 8060 | |
| 8061 | // Calculate pressure difference of reflected and mouthpiece pressures. |
| 8062 | pressureDiff = pressureDiff - breathPressure; |
| 8063 | |
| 8064 | // Perform non-linear scattering using pressure difference in reed function. |
| 8065 | lastOutput = delayLine->tick(breathPressure + pressureDiff * reedTable->tick(pressureDiff)); |
| 8066 | |
| 8067 | // Apply output gain. |
| 8068 | lastOutput *= outputGain; |
| 8069 | |
| 8070 | return lastOutput; |
| 8071 | } |
| 8072 | |
| 8073 | void Clarinet :: controlChange(int number, MY_FLOAT value) |
| 8074 | { |
| 8075 | MY_FLOAT norm = value * ONE_OVER_128; |
| 8076 | if ( norm < 0 ) { |
| 8077 | norm = 0.0; |
| 8078 | CK_STDCERR << "[chuck](via STK): Clarinet: Control value less than zero!" << CK_STDENDL; |
| 8079 | } |
| 8080 | else if ( norm > 1.0 ) { |
| 8081 | norm = 1.0; |
| 8082 | CK_STDCERR << "[chuck](via STK): Clarinet: Control value exceeds nominal range!" << CK_STDENDL; |
| 8083 | } |
| 8084 | |
| 8085 | if (number == __SK_ReedStiffness_) { // 2 |
| 8086 | m_reed = norm; |
| 8087 | reedTable->setSlope((MY_FLOAT) -0.44 + ( (MY_FLOAT) 0.26 * norm )); |
| 8088 | } |
| 8089 | else if (number == __SK_NoiseLevel_) { // 4 |
| 8090 | m_noiseGain = norm; |
| 8091 | noiseGain = (norm * (MY_FLOAT) 0.4); |
| 8092 | } |
| 8093 | else if (number == __SK_ModFrequency_) { // 11 |
| 8094 | m_vibratoFreq = norm; |
| 8095 | setVibratoFreq( norm * 12.0 ); |
| 8096 | } |
| 8097 | else if (number == __SK_ModWheel_) { // 1 |
| 8098 | m_vibratoGain = norm; |
| 8099 | vibratoGain = (norm * (MY_FLOAT) 0.5); |
| 8100 | } |
| 8101 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 8102 | m_volume = norm; |
| 8103 | envelope->setValue(norm); |
| 8104 | } |
| 8105 | else |
| 8106 | CK_STDCERR << "[chuck](via STK): Clarinet: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 8107 | |
| 8108 | #if defined(_STK_DEBUG_) |
| 8109 | CK_STDCERR << "[chuck](via STK): Clarinet: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 8110 | #endif |
| 8111 | } |
| 8112 | |
| 8113 | |
| 8114 | /***************************************************/ |
| 8115 | /*! \class DelayBase |
| 8116 | \brief STK non-interpolating delay line class. |
| 8117 | |
| 8118 | This protected Filter subclass implements |
| 8119 | a non-interpolating digital delay-line. |
| 8120 | A fixed maximum length of 4095 and a delay |
| 8121 | of zero is set using the default constructor. |
| 8122 | Alternatively, the delay and maximum length |
| 8123 | can be set during instantiation with an |
| 8124 | overloaded constructor. |
| 8125 | |
| 8126 | A non-interpolating delay line is typically |
| 8127 | used in fixed delay-length applications, such |
| 8128 | as for reverberation. |
| 8129 | |
| 8130 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 8131 | */ |
| 8132 | /***************************************************/ |
| 8133 | |
| 8134 | #include <iostream> |
| 8135 | |
| 8136 | DelayBase :: DelayBase() |
| 8137 | { |
| 8138 | this->set( 0, 4096 ); |
| 8139 | } |
| 8140 | |
| 8141 | DelayBase :: DelayBase(long theDelay, long maxDelay) |
| 8142 | { |
| 8143 | this->set( theDelay, maxDelay ); |
| 8144 | } |
| 8145 | |
| 8146 | void DelayBase :: set( long theDelay, long max ) |
| 8147 | { |
| 8148 | // Writing before reading allows delays from 0 to length-1. |
| 8149 | // If we want to allow a delay of maxDelay, we need a |
| 8150 | // delay-line of length = maxDelay+1. |
| 8151 | length = max+1; |
| 8152 | |
| 8153 | // We need to delete the previously allocated inputs. |
| 8154 | if( inputs ) delete [] inputs; |
| 8155 | inputs = new MY_FLOAT[length]; |
| 8156 | this->clear(); |
| 8157 | |
| 8158 | inPoint = 0; |
| 8159 | this->setDelay(theDelay); |
| 8160 | } |
| 8161 | |
| 8162 | DelayBase :: ~DelayBase() |
| 8163 | { |
| 8164 | } |
| 8165 | |
| 8166 | void DelayBase :: clear(void) |
| 8167 | { |
| 8168 | long i; |
| 8169 | for (i=0;i<length;i++) inputs[i] = 0.0; |
| 8170 | outputs[0] = 0.0; |
| 8171 | } |
| 8172 | |
| 8173 | void DelayBase :: setDelay(long theDelay) |
| 8174 | { |
| 8175 | if (theDelay > length-1) { // The value is too big. |
| 8176 | CK_STDCERR << "[chuck](via STK): Delay: setDelay(" << theDelay << ") too big!" << CK_STDENDL; |
| 8177 | // Force delay to maxLength. |
| 8178 | outPoint = inPoint + 1; |
| 8179 | delay = length - 1; |
| 8180 | } |
| 8181 | else if (theDelay < 0 ) { |
| 8182 | CK_STDCERR << "[chuck](via STK): Delay: setDelay(" << theDelay << ") less than zero!" << CK_STDENDL; |
| 8183 | outPoint = inPoint; |
| 8184 | delay = 0; |
| 8185 | } |
| 8186 | else { |
| 8187 | outPoint = inPoint - (long) theDelay; // read chases write |
| 8188 | delay = theDelay; |
| 8189 | } |
| 8190 | |
| 8191 | while (outPoint < 0) outPoint += length; // modulo maximum length |
| 8192 | } |
| 8193 | |
| 8194 | MY_FLOAT DelayBase :: getDelay(void) const |
| 8195 | { |
| 8196 | return delay; |
| 8197 | } |
| 8198 | |
| 8199 | MY_FLOAT DelayBase :: energy(void) const |
| 8200 | { |
| 8201 | long i; |
| 8202 | /* register */ MY_FLOAT e = 0; |
| 8203 | if (inPoint >= outPoint) { |
| 8204 | for (i=outPoint; i<inPoint; i++) { |
| 8205 | /* register */ MY_FLOAT t = inputs[i]; |
| 8206 | e += t*t; |
| 8207 | } |
| 8208 | } else { |
| 8209 | for (i=outPoint; i<length; i++) { |
| 8210 | /* register */ MY_FLOAT t = inputs[i]; |
| 8211 | e += t*t; |
| 8212 | } |
| 8213 | for (i=0; i<inPoint; i++) { |
| 8214 | /* register */ MY_FLOAT t = inputs[i]; |
| 8215 | e += t*t; |
| 8216 | } |
| 8217 | } |
| 8218 | return e; |
| 8219 | } |
| 8220 | |
| 8221 | MY_FLOAT DelayBase :: contentsAt(unsigned long tapDelay) const |
| 8222 | { |
| 8223 | long i = tapDelay; |
| 8224 | if (i < 1) { |
| 8225 | CK_STDCERR << "[chuck](via STK): Delay: contentsAt(" << tapDelay << ") too small!" << CK_STDENDL; |
| 8226 | i = 1; |
| 8227 | } |
| 8228 | else if (i > delay) { |
| 8229 | CK_STDCERR << "[chuck](via STK): Delay: contentsAt(" << tapDelay << ") too big!" << CK_STDENDL; |
| 8230 | i = (long) delay; |
| 8231 | } |
| 8232 | |
| 8233 | long tap = inPoint - i; |
| 8234 | if (tap < 0) // Check for wraparound. |
| 8235 | tap += length; |
| 8236 | |
| 8237 | return inputs[tap]; |
| 8238 | } |
| 8239 | |
| 8240 | MY_FLOAT DelayBase :: lastOut(void) const |
| 8241 | { |
| 8242 | return FilterStk::lastOut(); |
| 8243 | } |
| 8244 | |
| 8245 | MY_FLOAT DelayBase :: nextOut(void) |
| 8246 | { |
| 8247 | return inputs[outPoint]; |
| 8248 | } |
| 8249 | |
| 8250 | MY_FLOAT DelayBase :: tick(MY_FLOAT sample) |
| 8251 | { |
| 8252 | inputs[inPoint++] = sample; |
| 8253 | |
| 8254 | // Check for end condition |
| 8255 | if (inPoint == length) |
| 8256 | inPoint -= length; |
| 8257 | |
| 8258 | // Read out next value |
| 8259 | outputs[0] = inputs[outPoint++]; |
| 8260 | |
| 8261 | if (outPoint>=length) |
| 8262 | outPoint -= length; |
| 8263 | |
| 8264 | return outputs[0]; |
| 8265 | } |
| 8266 | |
| 8267 | MY_FLOAT *DelayBase :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 8268 | { |
| 8269 | for (unsigned int i=0; i<vectorSize; i++) |
| 8270 | vec[i] = tick(vec[i]); |
| 8271 | |
| 8272 | return vec; |
| 8273 | } |
| 8274 | /***************************************************/ |
| 8275 | /*! \class DelayA |
| 8276 | \brief STK allpass interpolating delay line class. |
| 8277 | |
| 8278 | This Delay subclass implements a fractional- |
| 8279 | length digital delay-line using a first-order |
| 8280 | allpass filter. A fixed maximum length |
| 8281 | of 4095 and a delay of 0.5 is set using the |
| 8282 | default constructor. Alternatively, the |
| 8283 | delay and maximum length can be set during |
| 8284 | instantiation with an overloaded constructor. |
| 8285 | |
| 8286 | An allpass filter has unity magnitude gain but |
| 8287 | variable phase delay properties, making it useful |
| 8288 | in achieving fractional delays without affecting |
| 8289 | a signal's frequency magnitude response. In |
| 8290 | order to achieve a maximally flat phase delay |
| 8291 | response, the minimum delay possible in this |
| 8292 | implementation is limited to a value of 0.5. |
| 8293 | |
| 8294 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 8295 | */ |
| 8296 | /***************************************************/ |
| 8297 | |
| 8298 | #include <iostream> |
| 8299 | |
| 8300 | DelayA :: DelayA() |
| 8301 | { |
| 8302 | this->setDelay( 0.5 ); |
| 8303 | apInput = 0.0; |
| 8304 | doNextOut = true; |
| 8305 | } |
| 8306 | |
| 8307 | DelayA :: DelayA(MY_FLOAT theDelay, long maxDelay) |
| 8308 | { |
| 8309 | // Writing before reading allows delays from 0 to length-1. |
| 8310 | length = maxDelay+1; |
| 8311 | |
| 8312 | if ( length > 4096 ) { |
| 8313 | // We need to delete the previously allocated inputs. |
| 8314 | delete [] inputs; |
| 8315 | inputs = new MY_FLOAT[length]; |
| 8316 | this->clear(); |
| 8317 | } |
| 8318 | |
| 8319 | inPoint = 0; |
| 8320 | this->setDelay(theDelay); |
| 8321 | apInput = 0.0; |
| 8322 | doNextOut = true; |
| 8323 | } |
| 8324 | |
| 8325 | void DelayA :: set( MY_FLOAT theDelay, long max ) |
| 8326 | { |
| 8327 | // Writing before reading allows delays from 0 to length-1. |
| 8328 | // If we want to allow a delay of maxDelay, we need a |
| 8329 | // delay-line of length = maxDelay+1. |
| 8330 | length = max+1; |
| 8331 | |
| 8332 | // We need to delete the previously allocated inputs. |
| 8333 | if( inputs ) delete [] inputs; |
| 8334 | inputs = new MY_FLOAT[length]; |
| 8335 | this->clear(); |
| 8336 | |
| 8337 | inPoint = 0; |
| 8338 | this->setDelay(theDelay); |
| 8339 | apInput = 0.0; |
| 8340 | doNextOut = true; |
| 8341 | } |
| 8342 | |
| 8343 | DelayA :: ~DelayA() |
| 8344 | { |
| 8345 | } |
| 8346 | |
| 8347 | void DelayA :: clear() |
| 8348 | { |
| 8349 | DelayBase::clear(); |
| 8350 | apInput = 0.0; |
| 8351 | } |
| 8352 | |
| 8353 | void DelayA :: setDelay(MY_FLOAT theDelay) |
| 8354 | { |
| 8355 | MY_FLOAT outPointer; |
| 8356 | |
| 8357 | if (theDelay > length-1) { |
| 8358 | CK_STDCERR << "[chuck](via STK): DelayA: setDelay(" << theDelay << ") too big!" << CK_STDENDL; |
| 8359 | // Force delay to maxLength |
| 8360 | outPointer = inPoint + 1.0; |
| 8361 | delay = length - 1; |
| 8362 | } |
| 8363 | else if (theDelay < 0.5) { |
| 8364 | CK_STDCERR << "[chuck](via STK): DelayA: setDelay(" << theDelay << ") less than 0.5 not possible!" << CK_STDENDL; |
| 8365 | outPointer = inPoint + 0.4999999999; |
| 8366 | delay = 0.5; |
| 8367 | } |
| 8368 | else { |
| 8369 | outPointer = inPoint - theDelay + 1.0; // outPoint chases inpoint |
| 8370 | delay = theDelay; |
| 8371 | } |
| 8372 | |
| 8373 | if (outPointer < 0) |
| 8374 | outPointer += length; // modulo maximum length |
| 8375 | |
| 8376 | outPoint = (long) outPointer; // integer part |
| 8377 | alpha = 1.0 + outPoint - outPointer; // fractional part |
| 8378 | |
| 8379 | if (alpha < 0.5) { |
| 8380 | // The optimal range for alpha is about 0.5 - 1.5 in order to |
| 8381 | // achieve the flattest phase delay response. |
| 8382 | outPoint += 1; |
| 8383 | if (outPoint >= length) outPoint -= length; |
| 8384 | alpha += (MY_FLOAT) 1.0; |
| 8385 | } |
| 8386 | |
| 8387 | coeff = ((MY_FLOAT) 1.0 - alpha) / |
| 8388 | ((MY_FLOAT) 1.0 + alpha); // coefficient for all pass |
| 8389 | } |
| 8390 | |
| 8391 | MY_FLOAT DelayA :: nextOut(void) |
| 8392 | { |
| 8393 | if ( doNextOut ) { |
| 8394 | // Do allpass interpolation delay. |
| 8395 | nextOutput = -coeff * outputs[0]; |
| 8396 | nextOutput += apInput + (coeff * inputs[outPoint]); |
| 8397 | doNextOut = false; |
| 8398 | } |
| 8399 | |
| 8400 | return nextOutput; |
| 8401 | } |
| 8402 | |
| 8403 | MY_FLOAT DelayA :: tick(MY_FLOAT sample) |
| 8404 | { |
| 8405 | inputs[inPoint++] = sample; |
| 8406 | |
| 8407 | // Increment input pointer modulo length. |
| 8408 | if (inPoint == length) |
| 8409 | inPoint -= length; |
| 8410 | |
| 8411 | outputs[0] = nextOut(); |
| 8412 | doNextOut = true; |
| 8413 | |
| 8414 | // Save the allpass input and increment modulo length. |
| 8415 | apInput = inputs[outPoint++]; |
| 8416 | if (outPoint == length) |
| 8417 | outPoint -= length; |
| 8418 | |
| 8419 | return outputs[0]; |
| 8420 | } |
| 8421 | |
| 8422 | |
| 8423 | /***************************************************/ |
| 8424 | /*! \class DelayL |
| 8425 | \brief STK linear interpolating delay line class. |
| 8426 | |
| 8427 | This Delay subclass implements a fractional- |
| 8428 | length digital delay-line using first-order |
| 8429 | linear interpolation. A fixed maximum length |
| 8430 | of 4095 and a delay of zero is set using the |
| 8431 | default constructor. Alternatively, the |
| 8432 | delay and maximum length can be set during |
| 8433 | instantiation with an overloaded constructor. |
| 8434 | |
| 8435 | Linear interpolation is an efficient technique |
| 8436 | for achieving fractional delay lengths, though |
| 8437 | it does introduce high-frequency signal |
| 8438 | attenuation to varying degrees depending on the |
| 8439 | fractional delay setting. The use of higher |
| 8440 | order Lagrange interpolators can typically |
| 8441 | improve (minimize) this attenuation characteristic. |
| 8442 | |
| 8443 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 8444 | */ |
| 8445 | /***************************************************/ |
| 8446 | |
| 8447 | #include <iostream> |
| 8448 | |
| 8449 | DelayL :: DelayL() |
| 8450 | { |
| 8451 | doNextOut = true; |
| 8452 | nextOutput = 0; |
| 8453 | alpha = 0; // added 1.5.0.0 |
| 8454 | omAlpha = 0; // added 1.5.0.0 |
| 8455 | } |
| 8456 | |
| 8457 | DelayL :: DelayL(MY_FLOAT theDelay, long maxDelay) |
| 8458 | { |
| 8459 | // Writing before reading allows delays from 0 to length-1. |
| 8460 | length = maxDelay+1; |
| 8461 | nextOutput = 0; // added 1.5.0.0 |
| 8462 | |
| 8463 | if ( length > 4096 ) { |
| 8464 | // We need to delete the previously allocated inputs. |
| 8465 | delete [] inputs; |
| 8466 | inputs = new MY_FLOAT[length]; |
| 8467 | this->clear(); |
| 8468 | } |
| 8469 | |
| 8470 | inPoint = 0; |
| 8471 | this->setDelay(theDelay); |
| 8472 | doNextOut = true; |
| 8473 | } |
| 8474 | |
| 8475 | DelayL :: ~DelayL() |
| 8476 | { |
| 8477 | } |
| 8478 | |
| 8479 | void DelayL :: set( MY_FLOAT theDelay, long max ) |
| 8480 | { |
| 8481 | // Writing before reading allows delays from 0 to length-1. |
| 8482 | // If we want to allow a delay of maxDelay, we need a |
| 8483 | // delay-line of length = maxDelay+1. |
| 8484 | length = max+1; |
| 8485 | |
| 8486 | // We need to delete the previously allocated inputs. |
| 8487 | if( inputs ) delete [] inputs; |
| 8488 | inputs = new MY_FLOAT[length]; |
| 8489 | this->clear(); |
| 8490 | |
| 8491 | inPoint = 0; |
| 8492 | this->setDelay(theDelay); |
| 8493 | doNextOut = true; |
| 8494 | } |
| 8495 | |
| 8496 | void DelayL :: setDelay(MY_FLOAT theDelay) |
| 8497 | { |
| 8498 | MY_FLOAT outPointer; |
| 8499 | |
| 8500 | if (theDelay > length-1) { |
| 8501 | CK_STDCERR << "[chuck](via STK): DelayL: setDelay(" << theDelay << ") too big!" << CK_STDENDL; |
| 8502 | // Force delay to maxLength |
| 8503 | outPointer = inPoint + 1.0; |
| 8504 | delay = length - 1; |
| 8505 | } |
| 8506 | else if (theDelay < 0 ) { |
| 8507 | CK_STDCERR << "[chuck](via STK): DelayL: setDelay(" << theDelay << ") less than zero!" << CK_STDENDL; |
| 8508 | outPointer = inPoint; |
| 8509 | delay = 0; |
| 8510 | } |
| 8511 | else { |
| 8512 | outPointer = inPoint - theDelay; // read chases write |
| 8513 | delay = theDelay; |
| 8514 | } |
| 8515 | |
| 8516 | while (outPointer < 0) |
| 8517 | outPointer += length; // modulo maximum length |
| 8518 | |
| 8519 | outPoint = (long) outPointer; // integer part |
| 8520 | alpha = outPointer - outPoint; // fractional part |
| 8521 | omAlpha = (MY_FLOAT) 1.0 - alpha; |
| 8522 | } |
| 8523 | |
| 8524 | MY_FLOAT DelayL :: nextOut(void) |
| 8525 | { |
| 8526 | if ( doNextOut ) { |
| 8527 | // First 1/2 of interpolation |
| 8528 | nextOutput = inputs[outPoint] * omAlpha; |
| 8529 | // Second 1/2 of interpolation |
| 8530 | if (outPoint+1 < length) |
| 8531 | nextOutput += inputs[outPoint+1] * alpha; |
| 8532 | else |
| 8533 | nextOutput += inputs[0] * alpha; |
| 8534 | doNextOut = false; |
| 8535 | } |
| 8536 | |
| 8537 | return nextOutput; |
| 8538 | } |
| 8539 | |
| 8540 | MY_FLOAT DelayL :: tick(MY_FLOAT sample) |
| 8541 | { |
| 8542 | inputs[inPoint++] = sample; |
| 8543 | |
| 8544 | // Increment input pointer modulo length. |
| 8545 | if (inPoint == length) |
| 8546 | inPoint -= length; |
| 8547 | |
| 8548 | outputs[0] = nextOut(); |
| 8549 | doNextOut = true; |
| 8550 | |
| 8551 | // Increment output pointer modulo length. |
| 8552 | if (++outPoint >= length) |
| 8553 | outPoint -= length; |
| 8554 | |
| 8555 | return outputs[0]; |
| 8556 | } |
| 8557 | /***************************************************/ |
| 8558 | /*! \class Drummer |
| 8559 | \brief STK drum sample player class. |
| 8560 | |
| 8561 | This class implements a drum sampling |
| 8562 | synthesizer using WvIn objects and one-pole |
| 8563 | filters. The drum rawwave files are sampled |
| 8564 | at 22050 Hz, but will be appropriately |
| 8565 | interpolated for other sample rates. You can |
| 8566 | specify the maximum polyphony (maximum number |
| 8567 | of simultaneous voices) via a #define in the |
| 8568 | Drummer.h. |
| 8569 | |
| 8570 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 8571 | */ |
| 8572 | /***************************************************/ |
| 8573 | |
| 8574 | #include <math.h> |
| 8575 | |
| 8576 | // Not really General MIDI yet. Coming soon. |
| 8577 | unsigned char genMIDIMap[128] = |
| 8578 | { 0,0,0,0,0,0,0,0, // 0-7 |
| 8579 | 0,0,0,0,0,0,0,0, // 8-15 |
| 8580 | 0,0,0,0,0,0,0,0, // 16-23 |
| 8581 | 0,0,0,0,0,0,0,0, // 24-31 |
| 8582 | 0,0,0,0,1,0,2,0, // 32-39 |
| 8583 | 2,3,6,3,6,4,7,4, // 40-47 |
| 8584 | 5,8,5,0,0,0,10,0, // 48-55 |
| 8585 | 9,0,0,0,0,0,0,0, // 56-63 |
| 8586 | 0,0,0,0,0,0,0,0, // 64-71 |
| 8587 | 0,0,0,0,0,0,0,0, // 72-79 |
| 8588 | 0,0,0,0,0,0,0,0, // 80-87 |
| 8589 | 0,0,0,0,0,0,0,0, // 88-95 |
| 8590 | 0,0,0,0,0,0,0,0, // 96-103 |
| 8591 | 0,0,0,0,0,0,0,0, // 104-111 |
| 8592 | 0,0,0,0,0,0,0,0, // 112-119 |
| 8593 | 0,0,0,0,0,0,0,0 // 120-127 |
| 8594 | }; |
| 8595 | |
| 8596 | //XXX changed this from 16 to 32 for the 'special' convention..also, we do not have these linked |
| 8597 | //in the headers |
| 8598 | char waveNames[DRUM_NUMWAVES][32] = |
| 8599 | { |
| 8600 | "special:dope", |
| 8601 | "special:bassdrum", |
| 8602 | "special:snardrum", |
| 8603 | "special:tomlowdr", |
| 8604 | "special:tommiddr", |
| 8605 | "special:tomhidrm", |
| 8606 | "special:hihatcym", |
| 8607 | "special:ridecymb", |
| 8608 | "special:crashcym", |
| 8609 | "special:cowbell1", |
| 8610 | "special:tambourn" |
| 8611 | }; |
| 8612 | |
| 8613 | Drummer :: Drummer() : Instrmnt() |
| 8614 | { |
| 8615 | for (int i=0; i<DRUM_POLYPHONY; i++) { |
| 8616 | filters[i] = new OnePole; |
| 8617 | sounding[i] = -1; |
| 8618 | |
| 8619 | // this will crash if Drummer is used (currently doesn't seem to be) |
| 8620 | // but better than trashing memory |
| 8621 | waves[i] = NULL; // 1.5.0.4 (ge) added |
| 8622 | } |
| 8623 | |
| 8624 | // This counts the number of sounding voices. |
| 8625 | nSounding = 0; |
| 8626 | } |
| 8627 | |
| 8628 | Drummer :: ~Drummer() |
| 8629 | { |
| 8630 | int i; |
| 8631 | for ( i=0; i<nSounding-1; i++ ) delete waves[i]; |
| 8632 | for ( i=0; i<DRUM_POLYPHONY; i++ ) delete filters[i]; |
| 8633 | } |
| 8634 | |
| 8635 | void Drummer :: noteOn(MY_FLOAT instrument, MY_FLOAT amplitude) |
| 8636 | { |
| 8637 | #if defined(_STK_DEBUG_) |
| 8638 | CK_STDCERR << "[chuck](via STK): Drummer: NoteOn instrument = " << instrument << ", amplitude = " << amplitude << CK_STDENDL; |
| 8639 | #endif |
| 8640 | |
| 8641 | MY_FLOAT gain = amplitude; |
| 8642 | if ( amplitude > 1.0 ) { |
| 8643 | CK_STDCERR << "[chuck](via STK): Drummer: noteOn amplitude parameter is greater than 1.0!" << CK_STDENDL; |
| 8644 | gain = 1.0; |
| 8645 | } |
| 8646 | else if ( amplitude < 0.0 ) { |
| 8647 | CK_STDCERR << "[chuck](via STK): Drummer: noteOn amplitude parameter is less than 0.0!" << CK_STDENDL; |
| 8648 | return; |
| 8649 | } |
| 8650 | |
| 8651 | // Yes, this is tres kludgey. |
| 8652 | int noteNum = (int) ((12*log(instrument/220.0)/log(2.0)) + 57.01); |
| 8653 | |
| 8654 | // Check first to see if there's already one like this sounding. |
| 8655 | int i, waveIndex = -1; |
| 8656 | for (i=0; i<DRUM_POLYPHONY; i++) { |
| 8657 | if (sounding[i] == noteNum) waveIndex = i; |
| 8658 | } |
| 8659 | |
| 8660 | if ( waveIndex >= 0 ) { |
| 8661 | // Reset this sound. |
| 8662 | waves[waveIndex]->reset(); |
| 8663 | filters[waveIndex]->setPole((MY_FLOAT) 0.999 - (gain * 0.6)); |
| 8664 | filters[waveIndex]->setGain(gain); |
| 8665 | } |
| 8666 | else { |
| 8667 | if (nSounding == DRUM_POLYPHONY) { |
| 8668 | // If we're already at maximum polyphony, then preempt the oldest voice. |
| 8669 | delete waves[0]; |
| 8670 | filters[0]->clear(); |
| 8671 | WvIn *tempWv = waves[0]; |
| 8672 | OnePole *tempFilt = filters[0]; |
| 8673 | // Re-order the list. |
| 8674 | for (i=0; i<DRUM_POLYPHONY-1; i++) { |
| 8675 | waves[i] = waves[i+1]; |
| 8676 | filters[i] = filters[i+1]; |
| 8677 | } |
| 8678 | waves[DRUM_POLYPHONY-1] = tempWv; |
| 8679 | filters[DRUM_POLYPHONY-1] = tempFilt; |
| 8680 | } |
| 8681 | else |
| 8682 | nSounding += 1; |
| 8683 | |
| 8684 | sounding[nSounding-1] = noteNum; |
| 8685 | // Concatenate the STK rawwave path to the rawwave file |
| 8686 | waves[nSounding-1] = new WvIn( (Stk::rawwavePath() + waveNames[genMIDIMap[noteNum]]).c_str(), TRUE ); |
| 8687 | if (Stk::sampleRate() != 22050.0) |
| 8688 | waves[nSounding-1]->setRate( 22050.0 / Stk::sampleRate() ); |
| 8689 | filters[nSounding-1]->setPole((MY_FLOAT) 0.999 - (gain * 0.6) ); |
| 8690 | filters[nSounding-1]->setGain( gain ); |
| 8691 | } |
| 8692 | |
| 8693 | #if defined(_STK_DEBUG_) |
| 8694 | CK_STDCERR << "[chuck](via STK): Number Sounding = " << nSounding << CK_STDENDL; |
| 8695 | for (i=0; i<nSounding; i++) CK_STDCERR << sounding[i] << " "; |
| 8696 | CK_STDCERR << "[chuck](via STK): \n"; |
| 8697 | #endif |
| 8698 | } |
| 8699 | |
| 8700 | void Drummer :: noteOff(MY_FLOAT amplitude) |
| 8701 | { |
| 8702 | // Set all sounding wave filter gains low. |
| 8703 | int i = 0; |
| 8704 | while(i < nSounding) { |
| 8705 | filters[i++]->setGain( amplitude * 0.01 ); |
| 8706 | } |
| 8707 | } |
| 8708 | |
| 8709 | MY_FLOAT Drummer :: tick() |
| 8710 | { |
| 8711 | MY_FLOAT output = 0.0; |
| 8712 | OnePole *tempFilt; |
| 8713 | |
| 8714 | int j, i = 0; |
| 8715 | while (i < nSounding) { |
| 8716 | if ( waves[i]->isFinished() ) { |
| 8717 | delete waves[i]; |
| 8718 | tempFilt = filters[i]; |
| 8719 | // Re-order the list. |
| 8720 | for (j=i; j<nSounding-1; j++) { |
| 8721 | sounding[j] = sounding[j+1]; |
| 8722 | waves[j] = waves[j+1]; |
| 8723 | filters[j] = filters[j+1]; |
| 8724 | } |
| 8725 | filters[j] = tempFilt; |
| 8726 | filters[j]->clear(); |
| 8727 | sounding[j] = -1; |
| 8728 | nSounding -= 1; |
| 8729 | i -= 1; |
| 8730 | } |
| 8731 | else |
| 8732 | output += filters[i]->tick( waves[i]->tick() ); |
| 8733 | i++; |
| 8734 | } |
| 8735 | |
| 8736 | return output; |
| 8737 | } |
| 8738 | /***************************************************/ |
| 8739 | /*! \class Echo |
| 8740 | \brief STK echo effect class. |
| 8741 | |
| 8742 | This class implements a echo effect. |
| 8743 | |
| 8744 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 8745 | */ |
| 8746 | /***************************************************/ |
| 8747 | |
| 8748 | #include <iostream> |
| 8749 | |
| 8750 | Echo :: Echo(MY_FLOAT longestDelay) |
| 8751 | { |
| 8752 | delayLine = NULL; |
| 8753 | this->set( longestDelay ); |
| 8754 | effectMix = 0.5; |
| 8755 | } |
| 8756 | |
| 8757 | Echo :: ~Echo() |
| 8758 | { |
| 8759 | delete delayLine; |
| 8760 | } |
| 8761 | |
| 8762 | void Echo :: set( MY_FLOAT max ) |
| 8763 | { |
| 8764 | length = (long)max + 2; |
| 8765 | MY_FLOAT delay = delayLine ? delayLine->getDelay() : length>>1; |
| 8766 | if( delayLine ) delete delayLine; |
| 8767 | if( delay >= max ) delay = max; |
| 8768 | delayLine = new DelayBase(length>>1, length); |
| 8769 | this->clear(); |
| 8770 | this->setDelay(delay+.5); |
| 8771 | } |
| 8772 | |
| 8773 | MY_FLOAT Echo :: getDelay() |
| 8774 | { |
| 8775 | return delayLine->getDelay(); |
| 8776 | } |
| 8777 | |
| 8778 | void Echo :: clear() |
| 8779 | { |
| 8780 | delayLine->clear(); |
| 8781 | lastOutput = 0.0; |
| 8782 | } |
| 8783 | |
| 8784 | void Echo :: setDelay(MY_FLOAT delay) |
| 8785 | { |
| 8786 | MY_FLOAT size = delay; |
| 8787 | if ( delay < 0.0 ) { |
| 8788 | CK_STDCERR << "[chuck](via STK): Echo: setDelay parameter is less than zero!" << CK_STDENDL; |
| 8789 | size = 0.0; |
| 8790 | } |
| 8791 | else if ( delay > length ) { |
| 8792 | CK_STDCERR << "[chuck](via STK): Echo: setDelay parameter is greater than delay length!" << CK_STDENDL; |
| 8793 | size = length; |
| 8794 | } |
| 8795 | |
| 8796 | delayLine->setDelay((long)size); |
| 8797 | } |
| 8798 | |
| 8799 | void Echo :: setEffectMix(MY_FLOAT mix) |
| 8800 | { |
| 8801 | effectMix = mix; |
| 8802 | if ( mix < 0.0 ) { |
| 8803 | CK_STDCERR << "[chuck](via STK): Echo: setEffectMix parameter (" << mix << ") is less than zero!" << CK_STDENDL; |
| 8804 | effectMix = 0.0; |
| 8805 | } |
| 8806 | else if ( mix > 1.0 ) { |
| 8807 | CK_STDCERR << "[chuck](via STK): Echo: setEffectMix parameter (" << mix << ") is greater than 1.0!" << CK_STDENDL; |
| 8808 | effectMix = 1.0; |
| 8809 | } |
| 8810 | } |
| 8811 | |
| 8812 | MY_FLOAT Echo :: lastOut() const |
| 8813 | { |
| 8814 | return lastOutput; |
| 8815 | } |
| 8816 | |
| 8817 | MY_FLOAT Echo :: tick(MY_FLOAT input) |
| 8818 | { |
| 8819 | lastOutput = effectMix * delayLine->tick(input); |
| 8820 | lastOutput += input * (1.0 - effectMix); |
| 8821 | return lastOutput; |
| 8822 | } |
| 8823 | |
| 8824 | MY_FLOAT *Echo :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 8825 | { |
| 8826 | for (unsigned int i=0; i<vectorSize; i++) |
| 8827 | vec[i] = tick(vec[i]); |
| 8828 | |
| 8829 | return vec; |
| 8830 | } |
| 8831 | /***************************************************/ |
| 8832 | /*! \class Envelope |
| 8833 | \brief STK envelope base class. |
| 8834 | |
| 8835 | This class implements a simple envelope |
| 8836 | generator which is capable of ramping to |
| 8837 | a target value by a specified \e rate. |
| 8838 | It also responds to simple \e keyOn and |
| 8839 | \e keyOff messages, ramping to 1.0 on |
| 8840 | keyOn and to 0.0 on keyOff. |
| 8841 | |
| 8842 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 8843 | */ |
| 8844 | /***************************************************/ |
| 8845 | |
| 8846 | #include <stdio.h> |
| 8847 | |
| 8848 | Envelope :: Envelope(void) : Stk() |
| 8849 | { |
| 8850 | target = (MY_FLOAT) 0.0; |
| 8851 | value = (MY_FLOAT) 0.0; |
| 8852 | rate = (MY_FLOAT) 0.001; |
| 8853 | m_target = 1.0; |
| 8854 | m_time = m_target / (rate * Stk::sampleRate()); |
| 8855 | state = 0; |
| 8856 | } |
| 8857 | |
| 8858 | Envelope :: ~Envelope(void) |
| 8859 | { |
| 8860 | } |
| 8861 | |
| 8862 | void Envelope :: keyOn(void) |
| 8863 | { |
| 8864 | target = (MY_FLOAT) m_target; |
| 8865 | if (value != target) state = 1; |
| 8866 | setTime( m_time ); |
| 8867 | } |
| 8868 | |
| 8869 | void Envelope :: keyOff(void) |
| 8870 | { |
| 8871 | target = (MY_FLOAT) 0.0; |
| 8872 | if (value != target) state = 1; |
| 8873 | setTime( m_time ); |
| 8874 | } |
| 8875 | |
| 8876 | void Envelope :: setRate(MY_FLOAT aRate) |
| 8877 | { |
| 8878 | if (aRate < 0.0) { |
| 8879 | printf("[chuck](via Envelope): negative rates not allowed ... correcting!\n"); |
| 8880 | rate = -aRate; |
| 8881 | } |
| 8882 | else |
| 8883 | rate = aRate; |
| 8884 | |
| 8885 | m_time = (target - value) / (rate * Stk::sampleRate()); |
| 8886 | if( m_time < 0.0 ) m_time = -m_time; |
| 8887 | } |
| 8888 | |
| 8889 | void Envelope :: setTime(MY_FLOAT aTime) |
| 8890 | { |
| 8891 | if (aTime < 0.0) { |
| 8892 | printf("[chuck](via Envelope): negative times not allowed ... correcting!\n"); |
| 8893 | aTime = -aTime; |
| 8894 | } |
| 8895 | |
| 8896 | if( aTime == 0.0 ) |
| 8897 | rate = FLT_MAX; |
| 8898 | else |
| 8899 | rate = (target - value) / (aTime * Stk::sampleRate()); |
| 8900 | |
| 8901 | // rate |
| 8902 | if( rate < 0 ) rate = -rate; |
| 8903 | |
| 8904 | // should >= 0 |
| 8905 | m_time = aTime; |
| 8906 | } |
| 8907 | |
| 8908 | void Envelope :: setTarget(MY_FLOAT aTarget) |
| 8909 | { |
| 8910 | target = m_target = aTarget; |
| 8911 | if (value != target) state = 1; |
| 8912 | |
| 8913 | // set time |
| 8914 | setTime( m_time ); |
| 8915 | } |
| 8916 | |
| 8917 | void Envelope :: setValue(MY_FLOAT aValue) |
| 8918 | { |
| 8919 | state = 0; |
| 8920 | target = aValue; |
| 8921 | value = aValue; |
| 8922 | } |
| 8923 | |
| 8924 | int Envelope :: getState(void) const |
| 8925 | { |
| 8926 | return state; |
| 8927 | } |
| 8928 | |
| 8929 | void Envelope :: prepTarget(MY_FLOAT aTarget) |
| 8930 | { |
| 8931 | m_target = aTarget; |
| 8932 | } |
| 8933 | |
| 8934 | void Envelope :: prepTime(MY_FLOAT aTime) |
| 8935 | { |
| 8936 | if (aTime < 0.0) { |
| 8937 | printf("[chuck](via Envelope): negative times not allowed ... correcting!\n"); |
| 8938 | aTime = -aTime; |
| 8939 | } |
| 8940 | |
| 8941 | // should >= 0 |
| 8942 | m_time = aTime; |
| 8943 | } |
| 8944 | |
| 8945 | MY_FLOAT Envelope :: tick(void) |
| 8946 | { |
| 8947 | if (state) { |
| 8948 | if (target > value) { |
| 8949 | value += rate; |
| 8950 | if (value >= target) { |
| 8951 | value = target; |
| 8952 | state = 0; |
| 8953 | } |
| 8954 | } |
| 8955 | else { |
| 8956 | value -= rate; |
| 8957 | if (value <= target) { |
| 8958 | value = target; |
| 8959 | state = 0; |
| 8960 | } |
| 8961 | } |
| 8962 | } |
| 8963 | return value; |
| 8964 | } |
| 8965 | |
| 8966 | MY_FLOAT *Envelope :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 8967 | { |
| 8968 | for (unsigned int i=0; i<vectorSize; i++) |
| 8969 | vec[i] = tick(); |
| 8970 | |
| 8971 | return vec; |
| 8972 | } |
| 8973 | |
| 8974 | MY_FLOAT Envelope :: lastOut(void) const |
| 8975 | { |
| 8976 | return value; |
| 8977 | } |
| 8978 | |
| 8979 | /***************************************************/ |
| 8980 | /*! \class FM |
| 8981 | \brief STK abstract FM synthesis base class. |
| 8982 | |
| 8983 | This class controls an arbitrary number of |
| 8984 | waves and envelopes, determined via a |
| 8985 | constructor argument. |
| 8986 | |
| 8987 | Control Change Numbers: |
| 8988 | - Control One = 2 |
| 8989 | - Control Two = 4 |
| 8990 | - LFO Speed = 11 |
| 8991 | - LFO Depth = 1 |
| 8992 | - ADSR 2 & 4 Target = 128 |
| 8993 | |
| 8994 | The basic Chowning/Stanford FM patent expired |
| 8995 | in 1995, but there exist follow-on patents, |
| 8996 | mostly assigned to Yamaha. If you are of the |
| 8997 | type who should worry about this (making |
| 8998 | money) worry away. |
| 8999 | |
| 9000 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 9001 | */ |
| 9002 | /***************************************************/ |
| 9003 | |
| 9004 | #include <stdlib.h> |
| 9005 | |
| 9006 | FM :: FM(int operators) |
| 9007 | : nOperators(operators) |
| 9008 | { |
| 9009 | if ( nOperators <= 0 ) { |
| 9010 | char msg[STK_MSG_BUF_LENGTH]; |
| 9011 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via FM): Invalid number of operators (%d) argument to constructor!", operators); |
| 9012 | handleError(msg, StkError::FUNCTION_ARGUMENT); |
| 9013 | } |
| 9014 | |
| 9015 | twozero = new TwoZero(); |
| 9016 | twozero->setB2( -1.0 ); |
| 9017 | twozero->setGain( 0.0 ); |
| 9018 | |
| 9019 | // Concatenate the STK rawwave path to the rawwave file |
| 9020 | vibrato = new WaveLoop( "special:sinewave", TRUE ); |
| 9021 | vibrato->setFrequency(6.0); |
| 9022 | |
| 9023 | int i; |
| 9024 | ratios = (MY_FLOAT *) new MY_FLOAT[nOperators]; |
| 9025 | gains = (MY_FLOAT *) new MY_FLOAT[nOperators]; |
| 9026 | baseGains = (MY_FLOAT *) new MY_FLOAT[nOperators]; /* 1.4.1.0 REPAIRATHON2021 ADDITION */ |
| 9027 | opAMs = (MY_FLOAT *) new MY_FLOAT[nOperators]; /* 1.4.1.0 REPAIRATHON2021 ADDITION */ |
| 9028 | adsr = (ADSR **) calloc( nOperators, sizeof(ADSR *) ); |
| 9029 | waves = (WaveLoop **) calloc( nOperators, sizeof(WaveLoop *) ); |
| 9030 | for (i=0; i<nOperators; i++ ) { |
| 9031 | ratios[i] = 1.0; |
| 9032 | gains[i] = 1.0; |
| 9033 | baseGains[i] = 1.0; // 1.4.1.0 |
| 9034 | opAMs[i] = 0.0; // 1.4.1.0 |
| 9035 | adsr[i] = new ADSR(); |
| 9036 | } |
| 9037 | |
| 9038 | modDepth = (MY_FLOAT) 0.0; |
| 9039 | control1 = (MY_FLOAT) 1.0; |
| 9040 | control2 = (MY_FLOAT) 1.0; |
| 9041 | baseFrequency = (MY_FLOAT) 440.0; |
| 9042 | |
| 9043 | // chuck |
| 9044 | m_frequency = baseFrequency; |
| 9045 | |
| 9046 | MY_FLOAT temp = 1.0; |
| 9047 | for (i=99; i>=0; i--) { |
| 9048 | __FM_gains[i] = temp; |
| 9049 | temp *= 0.933033; |
| 9050 | } |
| 9051 | |
| 9052 | temp = 1.0; |
| 9053 | for (i=15; i>=0; i--) { |
| 9054 | __FM_susLevels[i] = temp; |
| 9055 | temp *= 0.707101; |
| 9056 | } |
| 9057 | |
| 9058 | temp = 8.498186; |
| 9059 | for (i=0; i<32; i++) { |
| 9060 | __FM_attTimes[i] = temp; |
| 9061 | temp *= 0.707101; |
| 9062 | } |
| 9063 | |
| 9064 | // 1.4.1.0 REPAIRATHON2021 COMPATIBILITY HACK |
| 9065 | // (for Wurley, Rhodey, TubeBell AM vs. Vibrato) |
| 9066 | bCompatible = 1; |
| 9067 | } |
| 9068 | |
| 9069 | FM :: ~FM() |
| 9070 | { |
| 9071 | delete vibrato; |
| 9072 | delete twozero; |
| 9073 | delete [] ratios; |
| 9074 | delete [] gains; |
| 9075 | delete [] baseGains; // 1.4.1.0 |
| 9076 | delete [] opAMs; // 1.4.1.0 |
| 9077 | for (int i=0; i<nOperators; i++ ) { |
| 9078 | delete adsr[i]; |
| 9079 | delete waves[i]; |
| 9080 | } |
| 9081 | |
| 9082 | free(adsr); |
| 9083 | free(waves); |
| 9084 | } |
| 9085 | |
| 9086 | void FM :: loadWaves(const char **filenames ) |
| 9087 | { |
| 9088 | for (int i=0; i<nOperators; i++ ) |
| 9089 | waves[i] = new WaveLoop( filenames[i], TRUE ); |
| 9090 | } |
| 9091 | |
| 9092 | // 1.4.1.0 (prc) ***** REPAIRATHON2021 NEW SET/GET ACCESSING FUNCTIONS ***** |
| 9093 | |
| 9094 | void FM :: setADSR(int opNum, MY_FLOAT attack, MY_FLOAT decay, MY_FLOAT sustain, MY_FLOAT release) |
| 9095 | { |
| 9096 | adsr[opNum]->setAllTimes( attack, decay, sustain, release); |
| 9097 | bCompatible = 0; /***** REPAIRATHON2021 COMPATILITY HACK *****/ |
| 9098 | } |
| 9099 | |
| 9100 | void FM :: setOpGain(int opNum, MY_FLOAT gain) |
| 9101 | { |
| 9102 | gains[opNum] = gain; |
| 9103 | baseGains[opNum] = gain ; /***** REPAIRATHON2021 ADDITION */ |
| 9104 | bCompatible = 0; /***** REPAIRATHON2021 COMPATILITY HACK *****/ |
| 9105 | } |
| 9106 | |
| 9107 | MY_FLOAT FM :: getOpGain(int opNum) |
| 9108 | { |
| 9109 | return baseGains[opNum]; |
| 9110 | } |
| 9111 | |
| 9112 | void FM :: setOpAM(int opNum, MY_FLOAT gain) /***** REPAIRATHON2021 ADDITION NEW SET/GET ACCESSING FUNCTION */ |
| 9113 | { |
| 9114 | opAMs[opNum] = gain; |
| 9115 | bCompatible = 0; /***** REPAIRATHON2021 COMPATILITY HACK *****/ |
| 9116 | } |
| 9117 | |
| 9118 | MY_FLOAT FM :: getOpAM(int opNum) |
| 9119 | { |
| 9120 | return opAMs[opNum] ; |
| 9121 | } |
| 9122 | |
| 9123 | void FM :: setOpWave(int opNum, int wave) |
| 9124 | { |
| 9125 | delete waves[opNum]; |
| 9126 | if (wave == 1) { |
| 9127 | waves[opNum] = new WaveLoop( "special:sinewave", TRUE ); |
| 9128 | } |
| 9129 | else if (wave == 2) { |
| 9130 | waves[opNum] = new WaveLoop( "special:twopeaks", TRUE ); |
| 9131 | } |
| 9132 | else if (wave == 3) { |
| 9133 | waves[opNum] = new WaveLoop( "special:halfwave", TRUE ); |
| 9134 | } |
| 9135 | else if (wave == 4) { |
| 9136 | waves[opNum] = new WaveLoop( "special:snglpeak", TRUE ); |
| 9137 | } |
| 9138 | else if (wave == 5) { |
| 9139 | waves[opNum] = new WaveLoop( "special:sineblnk", TRUE ); |
| 9140 | } |
| 9141 | else if (wave == 6) { |
| 9142 | waves[opNum] = new WaveLoop( "special:peksblnk", TRUE ); |
| 9143 | } |
| 9144 | else if (wave == 7) { |
| 9145 | waves[opNum] = new WaveLoop( "special:fwavblnk", TRUE ); |
| 9146 | } |
| 9147 | else if (wave == 8) { |
| 9148 | waves[opNum] = new WaveLoop( "special:ppksblnk", TRUE ); |
| 9149 | } |
| 9150 | else { |
| 9151 | printf("Wave# out of range!! Setting to sine wave\n"); |
| 9152 | waves[opNum] = new WaveLoop( "special:sinewave", TRUE ); |
| 9153 | } |
| 9154 | |
| 9155 | bCompatible = 0; /***** REPAIRATHON2021 COMPATILITY HACK (primarily for Rhodey/Wurley/TubeBell AM vs. Vibrato *****/ |
| 9156 | } |
| 9157 | |
| 9158 | MY_FLOAT FM :: getFMTableGain(int index) /* TX81Z integer to float table lookup */ |
| 9159 | { |
| 9160 | MY_FLOAT gain = 1.0; |
| 9161 | if (index < 0 || index > 100) printf("FM gain table index must be 0-99!!\n Returning 1.0\n"); |
| 9162 | else gain = __FM_gains[index]; |
| 9163 | return gain; |
| 9164 | } |
| 9165 | |
| 9166 | MY_FLOAT FM :: getFMTableSusLevel(int index) /* TX81Z integer to float table lookup */ |
| 9167 | { |
| 9168 | MY_FLOAT gain = 1.0; |
| 9169 | if (index < 0 || index > 15) printf("FM sustain table index must be 0-15!!\n Returning 1.0\n"); |
| 9170 | else gain = __FM_susLevels[index]; |
| 9171 | return gain; |
| 9172 | } |
| 9173 | |
| 9174 | MY_FLOAT FM :: getFMTableTime(int index) /* TX81Z integer to float table lookup */ |
| 9175 | { |
| 9176 | MY_FLOAT gain = 1.0; |
| 9177 | if (index < 0 || index > 31) printf("FM envelope time table index must be 0-31!!\n Returning 1.0\n"); |
| 9178 | else gain = __FM_attTimes[index]; |
| 9179 | return gain; |
| 9180 | } |
| 9181 | |
| 9182 | // 1.4.1.0 (prc) ***** END REPARIATHON2021 BLOCK |
| 9183 | |
| 9184 | void FM :: setFrequency(MY_FLOAT frequency) |
| 9185 | { |
| 9186 | baseFrequency = frequency; |
| 9187 | |
| 9188 | for (int i=0; i<nOperators; i++ ) |
| 9189 | waves[i]->setFrequency( baseFrequency * ratios[i] ); |
| 9190 | |
| 9191 | // chuck |
| 9192 | m_frequency = baseFrequency; |
| 9193 | } |
| 9194 | |
| 9195 | void FM :: setRatio(int waveIndex, MY_FLOAT ratio) |
| 9196 | { |
| 9197 | if ( waveIndex < 0 ) { |
| 9198 | CK_STDCERR << "[chuck](via STK): FM: setRatio waveIndex parameter is less than zero!" << CK_STDENDL; |
| 9199 | return; |
| 9200 | } |
| 9201 | else if ( waveIndex >= nOperators ) { |
| 9202 | CK_STDCERR << "[chuck](via STK): FM: setRatio waveIndex parameter is greater than the number of operators!" << CK_STDENDL; |
| 9203 | return; |
| 9204 | } |
| 9205 | |
| 9206 | ratios[waveIndex] = ratio; |
| 9207 | if (ratio > 0.0) |
| 9208 | waves[waveIndex]->setFrequency(baseFrequency * ratio); |
| 9209 | else |
| 9210 | waves[waveIndex]->setFrequency(ratio); |
| 9211 | } |
| 9212 | |
| 9213 | MY_FLOAT FM :: getRatio(int waveIndex) |
| 9214 | { |
| 9215 | if ( waveIndex >= nOperators ) { |
| 9216 | CK_STDCERR << "[chuck](via STK): FM: getRatio waveIndex parameter is greater than the number of operators!" << CK_STDENDL; |
| 9217 | } |
| 9218 | |
| 9219 | return ratios[waveIndex]; |
| 9220 | } |
| 9221 | |
| 9222 | void FM :: setGain(int waveIndex, MY_FLOAT gain) |
| 9223 | { |
| 9224 | if ( waveIndex < 0 ) { |
| 9225 | CK_STDCERR << "[chuck](via STK): FM: setGain waveIndex parameter is less than zero!" << CK_STDENDL; |
| 9226 | return; |
| 9227 | } |
| 9228 | else if ( waveIndex >= nOperators ) { |
| 9229 | CK_STDCERR << "[chuck](via STK): FM: setGain waveIndex parameter is greater than the number of operators!" << CK_STDENDL; |
| 9230 | return; |
| 9231 | } |
| 9232 | |
| 9233 | gains[waveIndex] = gain; |
| 9234 | } |
| 9235 | |
| 9236 | void FM :: setModulationSpeed(MY_FLOAT mSpeed) |
| 9237 | { |
| 9238 | vibrato->setFrequency(mSpeed); |
| 9239 | } |
| 9240 | |
| 9241 | void FM :: setModulationDepth(MY_FLOAT mDepth) |
| 9242 | { |
| 9243 | modDepth = mDepth; |
| 9244 | } |
| 9245 | |
| 9246 | void FM :: setControl1(MY_FLOAT cVal) |
| 9247 | { |
| 9248 | control1 = cVal * (MY_FLOAT) 2.0; |
| 9249 | } |
| 9250 | |
| 9251 | void FM :: setControl2(MY_FLOAT cVal) |
| 9252 | { |
| 9253 | control2 = cVal * (MY_FLOAT) 2.0; |
| 9254 | } |
| 9255 | |
| 9256 | // 1.4.1.0 ***** REPAIRATHON2021 NEW PARAMETER ACCESS ***** |
| 9257 | |
| 9258 | void FM :: setOp4Feedback(MY_FLOAT fbVal) |
| 9259 | { |
| 9260 | op4Feedback = fbVal; |
| 9261 | twozero->gain = fbVal; |
| 9262 | } |
| 9263 | |
| 9264 | MY_FLOAT FM :: getOp4Feedback() |
| 9265 | { |
| 9266 | return op4Feedback; |
| 9267 | } |
| 9268 | |
| 9269 | // 1.4.1.0 ***** END REPAIRATHON2021 NEW PARAMETER ACCESS ***** |
| 9270 | |
| 9271 | void FM :: keyOn() |
| 9272 | { |
| 9273 | for (int i=0; i<nOperators; i++ ) |
| 9274 | adsr[i]->keyOn(); |
| 9275 | } |
| 9276 | |
| 9277 | void FM :: keyOff() |
| 9278 | { |
| 9279 | for (int i=0; i<nOperators; i++ ) |
| 9280 | adsr[i]->keyOff(); |
| 9281 | } |
| 9282 | |
| 9283 | void FM :: noteOff(MY_FLOAT amplitude) |
| 9284 | { |
| 9285 | keyOff(); |
| 9286 | |
| 9287 | #if defined(_STK_DEBUG_) |
| 9288 | CK_STDCERR << "[chuck](via STK): FM: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 9289 | #endif |
| 9290 | } |
| 9291 | |
| 9292 | void FM :: controlChange(int number, MY_FLOAT value) |
| 9293 | { |
| 9294 | MY_FLOAT norm = value * ONE_OVER_128; |
| 9295 | if ( norm < 0 ) { |
| 9296 | norm = 0.0; |
| 9297 | CK_STDCERR << "[chuck](via STK): FM: Control value less than zero!" << CK_STDENDL; |
| 9298 | } |
| 9299 | else if ( norm > 1.0 ) { |
| 9300 | norm = 1.0; |
| 9301 | CK_STDCERR << "[chuck](via STK): FM: Control value exceeds nominal range!" << CK_STDENDL; |
| 9302 | } |
| 9303 | |
| 9304 | if (number == __SK_Breath_) // 2 |
| 9305 | setControl1( norm ); |
| 9306 | else if (number == __SK_FootControl_) // 4 |
| 9307 | setControl2( norm ); |
| 9308 | else if (number == __SK_ModFrequency_) // 11 |
| 9309 | setModulationSpeed( norm * 12.0); |
| 9310 | else if (number == __SK_ModWheel_) // 1 |
| 9311 | setModulationDepth( norm ); |
| 9312 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 9313 | //adsr[0]->setTarget( norm ); |
| 9314 | adsr[1]->setTarget( norm ); |
| 9315 | //adsr[2]->setTarget( norm ); |
| 9316 | adsr[3]->setTarget( norm ); |
| 9317 | } |
| 9318 | else |
| 9319 | CK_STDCERR << "[chuck](via STK): FM: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 9320 | |
| 9321 | #if defined(_STK_DEBUG_) |
| 9322 | CK_STDCERR << "[chuck](via STK): FM: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 9323 | #endif |
| 9324 | } |
| 9325 | |
| 9326 | /***************************************************/ |
| 9327 | /*! \class FMVoices |
| 9328 | \brief STK singing FM synthesis instrument. |
| 9329 | |
| 9330 | This class implements 3 carriers and a common |
| 9331 | modulator, also referred to as algorithm 6 of |
| 9332 | the TX81Z. |
| 9333 | |
| 9334 | \code |
| 9335 | Algorithm 6 is : |
| 9336 | /->1 -\ |
| 9337 | 4-|-->2 - +-> Out |
| 9338 | \->3 -/ |
| 9339 | \endcode |
| 9340 | |
| 9341 | Control Change Numbers: |
| 9342 | - Vowel = 2 |
| 9343 | - Spectral Tilt = 4 |
| 9344 | - LFO Speed = 11 |
| 9345 | - LFO Depth = 1 |
| 9346 | - ADSR 2 & 4 Target = 128 |
| 9347 | |
| 9348 | The basic Chowning/Stanford FM patent expired |
| 9349 | in 1995, but there exist follow-on patents, |
| 9350 | mostly assigned to Yamaha. If you are of the |
| 9351 | type who should worry about this (making |
| 9352 | money) worry away. |
| 9353 | |
| 9354 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 9355 | */ |
| 9356 | /***************************************************/ |
| 9357 | |
| 9358 | |
| 9359 | FMVoices :: FMVoices() |
| 9360 | : FM() |
| 9361 | { |
| 9362 | // Concatenate the STK rawwave path to the rawwave files |
| 9363 | for ( int i=0; i<3; i++ ) |
| 9364 | waves[i] = new WaveLoop( "special:sinewave", TRUE ); |
| 9365 | waves[3] = new WaveLoop( "special:fwavblnk", TRUE ); |
| 9366 | |
| 9367 | this->setRatio(0, 2.00); |
| 9368 | this->setRatio(1, 4.00); |
| 9369 | this->setRatio(2, 12.0); |
| 9370 | this->setRatio(3, 1.00); |
| 9371 | |
| 9372 | gains[3] = __FM_gains[80]; |
| 9373 | |
| 9374 | baseGains[0] = gains[0]; // 1.4.1.0 ***** REPAIRATHON2021 ADDITIONS ***** |
| 9375 | baseGains[1] = gains[1]; |
| 9376 | baseGains[2] = gains[2]; |
| 9377 | baseGains[3] = gains[3]; |
| 9378 | |
| 9379 | adsr[0]->setAllTimes( 0.05, 0.05, __FM_susLevels[15], 0.05); |
| 9380 | adsr[1]->setAllTimes( 0.05, 0.05, __FM_susLevels[15], 0.05); |
| 9381 | adsr[2]->setAllTimes( 0.05, 0.05, __FM_susLevels[15], 0.05); |
| 9382 | adsr[3]->setAllTimes( 0.01, 0.01, __FM_susLevels[15], 0.5); |
| 9383 | |
| 9384 | twozero->setGain( 0.0 ); |
| 9385 | op4Feedback = 0.0; // 1.4.1.0 addedd |
| 9386 | modDepth = (MY_FLOAT) 0.005; |
| 9387 | currentVowel = 0; |
| 9388 | tilt[0] = 1.0; |
| 9389 | tilt[1] = 0.5; |
| 9390 | tilt[2] = 0.2; |
| 9391 | mods[0] = 1.0; |
| 9392 | mods[1] = 1.1; |
| 9393 | mods[2] = 1.1; |
| 9394 | baseFrequency = 110.0; |
| 9395 | setFrequency( 110.0 ); |
| 9396 | } |
| 9397 | |
| 9398 | FMVoices :: ~FMVoices() |
| 9399 | { |
| 9400 | // note: waves array taken care of in FM destructor |
| 9401 | } |
| 9402 | |
| 9403 | void FMVoices :: setFrequency(MY_FLOAT frequency) |
| 9404 | { |
| 9405 | MY_FLOAT temp, temp2 = 0.0; |
| 9406 | int tempi = 0; |
| 9407 | unsigned int i = 0; |
| 9408 | |
| 9409 | if (currentVowel < 32) { |
| 9410 | i = currentVowel; |
| 9411 | temp2 = (MY_FLOAT) 0.9; |
| 9412 | } |
| 9413 | else if (currentVowel < 64) { |
| 9414 | i = currentVowel - 32; |
| 9415 | temp2 = (MY_FLOAT) 1.0; |
| 9416 | } |
| 9417 | else if (currentVowel < 96) { |
| 9418 | i = currentVowel - 64; |
| 9419 | temp2 = (MY_FLOAT) 1.1; |
| 9420 | } |
| 9421 | else if (currentVowel <= 128) { |
| 9422 | i = currentVowel - 96; |
| 9423 | temp2 = (MY_FLOAT) 1.2; |
| 9424 | } |
| 9425 | |
| 9426 | baseFrequency = frequency; |
| 9427 | temp = (temp2 * Phonemes::formantFrequency(i, 0) / baseFrequency) + 0.5; |
| 9428 | tempi = (int) temp; |
| 9429 | this->setRatio(0,(MY_FLOAT) tempi); |
| 9430 | temp = (temp2 * Phonemes::formantFrequency(i, 1) / baseFrequency) + 0.5; |
| 9431 | tempi = (int) temp; |
| 9432 | this->setRatio(1,(MY_FLOAT) tempi); |
| 9433 | temp = (temp2 * Phonemes::formantFrequency(i, 2) / baseFrequency) + 0.5; |
| 9434 | tempi = (int) temp; |
| 9435 | this->setRatio(2, (MY_FLOAT) tempi); |
| 9436 | |
| 9437 | gains[0] = baseGains[0]; // 1.4.1.0 updated; was = 1.0; |
| 9438 | gains[1] = baseGains[1]; // 1.4.1.0 updated; was = 1.0; |
| 9439 | gains[2] = baseGains[2]; // 1.4.1.0 updated; was = 1.0; |
| 9440 | |
| 9441 | // chuck |
| 9442 | m_frequency = baseFrequency; |
| 9443 | } |
| 9444 | |
| 9445 | void FMVoices :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 9446 | { |
| 9447 | this->setFrequency(frequency); |
| 9448 | tilt[0] = amplitude; |
| 9449 | tilt[1] = amplitude * amplitude; |
| 9450 | tilt[2] = tilt[1] * amplitude; |
| 9451 | this->keyOn(); |
| 9452 | |
| 9453 | #if defined(_STK_DEBUG_) |
| 9454 | CK_STDCERR << "[chuck](via STK): FMVoices: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 9455 | #endif |
| 9456 | } |
| 9457 | |
| 9458 | MY_FLOAT FMVoices :: tick() // 1.4.1.0 updated (prc) |
| 9459 | { |
| 9460 | /* register */ MY_FLOAT temp, temp2; |
| 9461 | |
| 9462 | temp2 = vibrato->tick() * modDepth * (MY_FLOAT) 0.1; |
| 9463 | for (int i = 0; i < 4; i++) { |
| 9464 | if (ratios[i] > 0.0) { |
| 9465 | waves[i]->setFrequency(baseFrequency * (1.0 + temp2) * ratios[i]); |
| 9466 | } |
| 9467 | } |
| 9468 | |
| 9469 | temp2 = vibrato->lastOut(); // save pure lfo for AM later /***** REPAIRATHON2021 ADDITION *****/ |
| 9470 | temp = (1.0 + opAMs[3]*temp2) * gains[3] * adsr[3]->tick() * waves[3]->tick(); |
| 9471 | twozero->tick(temp); |
| 9472 | |
| 9473 | waves[0]->addPhaseOffset(control1*temp * mods[0]); |
| 9474 | waves[1]->addPhaseOffset(control1*temp * mods[1]); |
| 9475 | waves[2]->addPhaseOffset(control1*temp * mods[2]); |
| 9476 | waves[3]->addPhaseOffset(control2*twozero->lastOut()); // Doesn't do anything for Voice, but... |
| 9477 | |
| 9478 | temp = (1.0 + opAMs[0]*temp2) * gains[0] * tilt[0] * adsr[0]->tick() * waves[0]->tick(); |
| 9479 | temp += (1.0 + opAMs[1]*temp2) * gains[1] * tilt[1] * adsr[1]->tick() * waves[1]->tick(); |
| 9480 | temp += (1.0 + opAMs[2]*temp2) * gains[2] * tilt[2] * adsr[2]->tick() * waves[2]->tick(); |
| 9481 | |
| 9482 | return temp * 0.33; |
| 9483 | } |
| 9484 | |
| 9485 | void FMVoices :: controlChange(int number, MY_FLOAT value) |
| 9486 | { |
| 9487 | MY_FLOAT norm = value * ONE_OVER_128; |
| 9488 | if ( norm < 0 ) { |
| 9489 | norm = 0.0; |
| 9490 | CK_STDCERR << "[chuck](via STK): FMVoices: Control value less than zero!" << CK_STDENDL; |
| 9491 | } |
| 9492 | else if ( norm > 1.0 ) { |
| 9493 | norm = 1.0; |
| 9494 | CK_STDCERR << "[chuck](via STK): FMVoices: Control value exceeds nominal range!" << CK_STDENDL; |
| 9495 | } |
| 9496 | |
| 9497 | |
| 9498 | if (number == __SK_Breath_) // 2 |
| 9499 | gains[3] = __FM_gains[(int) ( norm * 99.9 )]; |
| 9500 | else if (number == __SK_FootControl_) { // 4 |
| 9501 | currentVowel = (int) (norm * 128.0); |
| 9502 | this->setFrequency(baseFrequency); |
| 9503 | } |
| 9504 | else if (number == __SK_ModFrequency_) // 11 |
| 9505 | this->setModulationSpeed( norm * 12.0); |
| 9506 | else if (number == __SK_ModWheel_) // 1 |
| 9507 | this->setModulationDepth( norm ); |
| 9508 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 9509 | tilt[0] = norm; |
| 9510 | tilt[1] = norm * norm; |
| 9511 | tilt[2] = tilt[1] * norm; |
| 9512 | } |
| 9513 | else |
| 9514 | CK_STDCERR << "[chuck](via STK): FMVoices: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 9515 | |
| 9516 | #if defined(_STK_DEBUG_) |
| 9517 | CK_STDCERR << "[chuck](via STK): FMVoices: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 9518 | #endif |
| 9519 | } |
| 9520 | |
| 9521 | |
| 9522 | /***************************************************/ |
| 9523 | /*! \class Filter |
| 9524 | \brief STK filter class. |
| 9525 | |
| 9526 | This class implements a generic structure which |
| 9527 | can be used to create a wide range of filters. |
| 9528 | It can function independently or be subclassed |
| 9529 | to provide more specific controls based on a |
| 9530 | particular filter type. |
| 9531 | |
| 9532 | In particular, this class implements the standard |
| 9533 | difference equation: |
| 9534 | |
| 9535 | a[0]*y[n] = b[0]*x[n] + ... + b[nb]*x[n-nb] - |
| 9536 | a[1]*y[n-1] - ... - a[na]*y[n-na] |
| 9537 | |
| 9538 | If a[0] is not equal to 1, the filter coeffcients |
| 9539 | are normalized by a[0]. |
| 9540 | |
| 9541 | The \e gain parameter is applied at the filter |
| 9542 | input and does not affect the coefficient values. |
| 9543 | The default gain value is 1.0. This structure |
| 9544 | results in one extra multiply per computed sample, |
| 9545 | but allows easy control of the overall filter gain. |
| 9546 | |
| 9547 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 9548 | */ |
| 9549 | /***************************************************/ |
| 9550 | |
| 9551 | #include <stdio.h> |
| 9552 | |
| 9553 | FilterStk :: FilterStk() |
| 9554 | { |
| 9555 | // The default constructor should setup for pass-through. |
| 9556 | gain = 1.0; |
| 9557 | nB = 1; |
| 9558 | nA = 1; |
| 9559 | b = new MY_FLOAT[nB]; |
| 9560 | b[0] = 1.0; |
| 9561 | a = new MY_FLOAT[nA]; |
| 9562 | a[0] = 1.0; |
| 9563 | |
| 9564 | inputs = new MY_FLOAT[nB]; |
| 9565 | outputs = new MY_FLOAT[nA]; |
| 9566 | this->clear(); |
| 9567 | } |
| 9568 | |
| 9569 | FilterStk :: FilterStk(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients) |
| 9570 | { |
| 9571 | char message[STK_MSG_BUF_LENGTH]; |
| 9572 | |
| 9573 | // Check the arguments. |
| 9574 | if ( nb < 1 || na < 1 ) { |
| 9575 | snprintf(message, STK_MSG_BUF_LENGTH, "[chuck](via Filter): nb (%d) and na (%d) must be >= 1!", nb, na); |
| 9576 | handleError( message, StkError::FUNCTION_ARGUMENT ); |
| 9577 | } |
| 9578 | |
| 9579 | if ( aCoefficients[0] == 0.0 ) { |
| 9580 | snprintf(message, STK_MSG_BUF_LENGTH, "[chuck](via Filter): a[0] coefficient cannot == 0!"); |
| 9581 | handleError( message, StkError::FUNCTION_ARGUMENT ); |
| 9582 | } |
| 9583 | |
| 9584 | gain = 1.0; |
| 9585 | nB = nb; |
| 9586 | nA = na; |
| 9587 | b = new MY_FLOAT[nB]; |
| 9588 | a = new MY_FLOAT[nA]; |
| 9589 | |
| 9590 | inputs = new MY_FLOAT[nB]; |
| 9591 | outputs = new MY_FLOAT[nA]; |
| 9592 | this->clear(); |
| 9593 | |
| 9594 | this->setCoefficients(nB, bCoefficients, nA, aCoefficients); |
| 9595 | } |
| 9596 | |
| 9597 | FilterStk :: ~FilterStk() |
| 9598 | { |
| 9599 | delete [] b; |
| 9600 | delete [] a; |
| 9601 | delete [] inputs; |
| 9602 | delete [] outputs; |
| 9603 | } |
| 9604 | |
| 9605 | void FilterStk :: clear(void) |
| 9606 | { |
| 9607 | int i; |
| 9608 | for (i=0; i<nB; i++) |
| 9609 | inputs[i] = 0.0; |
| 9610 | for (i=0; i<nA; i++) |
| 9611 | outputs[i] = 0.0; |
| 9612 | } |
| 9613 | |
| 9614 | void FilterStk :: setCoefficients(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients) |
| 9615 | { |
| 9616 | int i; |
| 9617 | char message[STK_MSG_BUF_LENGTH]; |
| 9618 | |
| 9619 | // Check the arguments. |
| 9620 | if ( nb < 1 || na < 1 ) { |
| 9621 | snprintf(message, STK_MSG_BUF_LENGTH, "[chuck](via Filter): nb (%d) and na (%d) must be >= 1!", nb, na); |
| 9622 | handleError( message, StkError::FUNCTION_ARGUMENT ); |
| 9623 | } |
| 9624 | |
| 9625 | if ( aCoefficients[0] == 0.0 ) { |
| 9626 | snprintf(message, STK_MSG_BUF_LENGTH, "[chuck](via Filter): a[0] coefficient cannot == 0!"); |
| 9627 | handleError( message, StkError::FUNCTION_ARGUMENT ); |
| 9628 | } |
| 9629 | |
| 9630 | if (nb != nB) { |
| 9631 | delete [] b; |
| 9632 | delete [] inputs; |
| 9633 | nB = nb; |
| 9634 | b = new MY_FLOAT[nB]; |
| 9635 | inputs = new MY_FLOAT[nB]; |
| 9636 | for (i=0; i<nB; i++) inputs[i] = 0.0; |
| 9637 | } |
| 9638 | |
| 9639 | if (na != nA) { |
| 9640 | delete [] a; |
| 9641 | delete [] outputs; |
| 9642 | nA = na; |
| 9643 | a = new MY_FLOAT[nA]; |
| 9644 | outputs = new MY_FLOAT[nA]; |
| 9645 | for (i=0; i<nA; i++) outputs[i] = 0.0; |
| 9646 | } |
| 9647 | |
| 9648 | for (i=0; i<nB; i++) |
| 9649 | b[i] = bCoefficients[i]; |
| 9650 | for (i=0; i<nA; i++) |
| 9651 | a[i] = aCoefficients[i]; |
| 9652 | |
| 9653 | // scale coefficients by a[0] if necessary |
| 9654 | if (a[0] != 1.0) { |
| 9655 | for (i=0; i<nB; i++) |
| 9656 | b[i] /= a[0]; |
| 9657 | for (i=0; i<nA; i++) |
| 9658 | a[i] /= a[0]; |
| 9659 | } |
| 9660 | } |
| 9661 | |
| 9662 | void FilterStk :: setNumerator(int nb, MY_FLOAT *bCoefficients) |
| 9663 | { |
| 9664 | int i; |
| 9665 | char message[STK_MSG_BUF_LENGTH]; |
| 9666 | |
| 9667 | // Check the arguments. |
| 9668 | if ( nb < 1 ) { |
| 9669 | snprintf(message, STK_MSG_BUF_LENGTH, "[chuck](via Filter): nb (%d) must be >= 1!", nb); |
| 9670 | handleError( message, StkError::FUNCTION_ARGUMENT ); |
| 9671 | } |
| 9672 | |
| 9673 | if (nb != nB) { |
| 9674 | delete [] b; |
| 9675 | delete [] inputs; |
| 9676 | nB = nb; |
| 9677 | b = new MY_FLOAT[nB]; |
| 9678 | inputs = new MY_FLOAT[nB]; |
| 9679 | for (i=0; i<nB; i++) inputs[i] = 0.0; |
| 9680 | } |
| 9681 | |
| 9682 | for (i=0; i<nB; i++) |
| 9683 | b[i] = bCoefficients[i]; |
| 9684 | } |
| 9685 | |
| 9686 | void FilterStk :: setDenominator(int na, MY_FLOAT *aCoefficients) |
| 9687 | { |
| 9688 | int i; |
| 9689 | char message[STK_MSG_BUF_LENGTH]; |
| 9690 | |
| 9691 | // Check the arguments. |
| 9692 | if ( na < 1 ) { |
| 9693 | snprintf(message, STK_MSG_BUF_LENGTH, "[chuck](via Filter): na (%d) must be >= 1!", na); |
| 9694 | handleError( message, StkError::FUNCTION_ARGUMENT ); |
| 9695 | } |
| 9696 | |
| 9697 | if ( aCoefficients[0] == 0.0 ) { |
| 9698 | snprintf(message, STK_MSG_BUF_LENGTH, "[chuck](via Filter): a[0] coefficient cannot == 0!"); |
| 9699 | handleError( message, StkError::FUNCTION_ARGUMENT ); |
| 9700 | } |
| 9701 | |
| 9702 | if (na != nA) { |
| 9703 | delete [] a; |
| 9704 | delete [] outputs; |
| 9705 | nA = na; |
| 9706 | a = new MY_FLOAT[nA]; |
| 9707 | outputs = new MY_FLOAT[nA]; |
| 9708 | for (i=0; i<nA; i++) outputs[i] = 0.0; |
| 9709 | } |
| 9710 | |
| 9711 | for (i=0; i<nA; i++) |
| 9712 | a[i] = aCoefficients[i]; |
| 9713 | |
| 9714 | // scale coefficients by a[0] if necessary |
| 9715 | |
| 9716 | if (a[0] != 1.0) { |
| 9717 | for (i=0; i<nB; i++) |
| 9718 | b[i] /= a[0]; |
| 9719 | for (i=0; i<nA; i++) |
| 9720 | a[i] /= a[0]; |
| 9721 | } |
| 9722 | } |
| 9723 | |
| 9724 | void FilterStk :: setGain(MY_FLOAT theGain) |
| 9725 | { |
| 9726 | gain = theGain; |
| 9727 | } |
| 9728 | |
| 9729 | MY_FLOAT FilterStk :: getGain(void) const |
| 9730 | { |
| 9731 | return gain; |
| 9732 | } |
| 9733 | |
| 9734 | MY_FLOAT FilterStk :: lastOut(void) const |
| 9735 | { |
| 9736 | return outputs[0]; |
| 9737 | } |
| 9738 | |
| 9739 | MY_FLOAT FilterStk :: tick(MY_FLOAT sample) |
| 9740 | { |
| 9741 | int i; |
| 9742 | |
| 9743 | outputs[0] = 0.0; |
| 9744 | inputs[0] = gain * sample; |
| 9745 | for (i=nB-1; i>0; i--) { |
| 9746 | outputs[0] += b[i] * inputs[i]; |
| 9747 | inputs[i] = inputs[i-1]; |
| 9748 | } |
| 9749 | outputs[0] += b[0] * inputs[0]; |
| 9750 | |
| 9751 | for (i=nA-1; i>0; i--) { |
| 9752 | outputs[0] += -a[i] * outputs[i]; |
| 9753 | outputs[i] = outputs[i-1]; |
| 9754 | } |
| 9755 | |
| 9756 | return outputs[0]; |
| 9757 | } |
| 9758 | |
| 9759 | MY_FLOAT *FilterStk :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 9760 | { |
| 9761 | for (unsigned int i=0; i<vectorSize; i++) |
| 9762 | vec[i] = tick(vec[i]); |
| 9763 | |
| 9764 | return vec; |
| 9765 | } |
| 9766 | |
| 9767 | |
| 9768 | /***************************************************/ |
| 9769 | /*! \class Flute |
| 9770 | \brief STK flute physical model class. |
| 9771 | |
| 9772 | This class implements a simple flute |
| 9773 | physical model, as discussed by Karjalainen, |
| 9774 | Smith, Waryznyk, etc. The jet model uses |
| 9775 | a polynomial, a la Cook. |
| 9776 | |
| 9777 | This is a digital waveguide model, making its |
| 9778 | use possibly subject to patents held by Stanford |
| 9779 | University, Yamaha, and others. |
| 9780 | |
| 9781 | Control Change Numbers: |
| 9782 | - Jet Delay = 2 |
| 9783 | - Noise Gain = 4 |
| 9784 | - Vibrato Frequency = 11 |
| 9785 | - Vibrato Gain = 1 |
| 9786 | - Breath Pressure = 128 |
| 9787 | |
| 9788 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 9789 | */ |
| 9790 | /***************************************************/ |
| 9791 | |
| 9792 | |
| 9793 | Flute :: Flute(MY_FLOAT lowestFrequency) |
| 9794 | { |
| 9795 | length = (long) (Stk::sampleRate() / lowestFrequency + 1); |
| 9796 | boreDelay = new DelayL( 100.0, length ); |
| 9797 | length >>= 1; |
| 9798 | jetDelay = new DelayL( 49.0, length ); |
| 9799 | jetTable = new JetTabl(); |
| 9800 | filter = new OnePole(); |
| 9801 | dcBlock = new PoleZero(); |
| 9802 | dcBlock->setBlockZero(); |
| 9803 | noise = new Noise(); |
| 9804 | adsr = new ADSR(); |
| 9805 | |
| 9806 | // Concatenate the STK rawwave path to the rawwave file |
| 9807 | vibrato = new WaveLoop( "special:sinewave", TRUE ); |
| 9808 | vibrato->setFrequency( 5.925 ); |
| 9809 | |
| 9810 | this->clear(); |
| 9811 | |
| 9812 | filter->setPole( 0.7 - ((MY_FLOAT) 0.1 * 22050.0 / Stk::sampleRate() ) ); |
| 9813 | filter->setGain( -1.0 ); |
| 9814 | adsr->setAllTimes( 0.005, 0.01, 0.8, 0.010); |
| 9815 | endReflection = (MY_FLOAT) 0.5; |
| 9816 | jetReflection = (MY_FLOAT) 0.5; |
| 9817 | noiseGain = 0.15; // Breath pressure random component. |
| 9818 | vibratoGain = (MY_FLOAT) 0.05; // Breath periodic vibrato component. |
| 9819 | jetRatio = (MY_FLOAT) 0.32; |
| 9820 | |
| 9821 | maxPressure = (MY_FLOAT) 0.0; |
| 9822 | lastFrequency = 220.0; |
| 9823 | |
| 9824 | // CHUCK |
| 9825 | //reverse: nothing |
| 9826 | m_frequency = lastFrequency; |
| 9827 | //reverse: nothing (see setJetDelay) |
| 9828 | m_jetDelay = jetRatio; |
| 9829 | //reverse: nothing |
| 9830 | m_jetReflection = jetReflection; |
| 9831 | //reverse: nothing |
| 9832 | m_endReflection = endReflection; |
| 9833 | //reverse: noiseGain = norm * 0.4 |
| 9834 | m_noiseGain = noiseGain / .4; |
| 9835 | //reverse: same * 12.0 |
| 9836 | m_vibratoFreq = vibrato->m_freq / 12.0; |
| 9837 | //reverse: same * 0.4 |
| 9838 | m_vibratoGain = .15 / 0.4; |
| 9839 | //reverse: nothing |
| 9840 | m_pressure = 1.0; |
| 9841 | //reverse: nothing |
| 9842 | m_rate = .005; |
| 9843 | } |
| 9844 | |
| 9845 | Flute :: ~Flute() |
| 9846 | { |
| 9847 | delete jetDelay; |
| 9848 | delete boreDelay; |
| 9849 | delete jetTable; |
| 9850 | delete filter; |
| 9851 | delete dcBlock; |
| 9852 | delete noise; |
| 9853 | delete adsr; |
| 9854 | delete vibrato; |
| 9855 | } |
| 9856 | |
| 9857 | void Flute :: clear() |
| 9858 | { |
| 9859 | jetDelay->clear(); |
| 9860 | boreDelay->clear(); |
| 9861 | filter->clear(); |
| 9862 | dcBlock->clear(); |
| 9863 | } |
| 9864 | |
| 9865 | void Flute :: setFrequency(MY_FLOAT frequency) |
| 9866 | { |
| 9867 | lastFrequency = frequency; |
| 9868 | if ( frequency <= 0.0 ) { |
| 9869 | CK_STDCERR << "[chuck](via STK): Flute: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 9870 | lastFrequency = 220.0; |
| 9871 | } |
| 9872 | |
| 9873 | // We're overblowing here. |
| 9874 | lastFrequency *= 0.66666; |
| 9875 | // Delay = length - approximate filter delay. |
| 9876 | MY_FLOAT delay = Stk::sampleRate() / lastFrequency - (MY_FLOAT) 2.0; |
| 9877 | if (delay <= 0.0) delay = 0.3; |
| 9878 | else if (delay > length) delay = length; |
| 9879 | |
| 9880 | boreDelay->setDelay(delay); |
| 9881 | jetDelay->setDelay(delay * jetRatio); |
| 9882 | |
| 9883 | // chuck |
| 9884 | m_frequency = frequency; |
| 9885 | } |
| 9886 | |
| 9887 | void Flute :: startBlowing(MY_FLOAT amplitude, MY_FLOAT rate) |
| 9888 | { |
| 9889 | #if defined(_STK_DEBUG_) |
| 9890 | CK_STDCERR << "[chuck](via STK): Flute: startblowing " << amplitude << " " << rate << CK_STDENDL; |
| 9891 | #endif |
| 9892 | adsr->setAttackRate(rate); |
| 9893 | maxPressure = amplitude / (MY_FLOAT) 0.8; |
| 9894 | adsr->keyOn(); |
| 9895 | } |
| 9896 | |
| 9897 | void Flute :: stopBlowing(MY_FLOAT rate) |
| 9898 | { |
| 9899 | adsr->setReleaseRate(rate); |
| 9900 | adsr->keyOff(); |
| 9901 | } |
| 9902 | |
| 9903 | void Flute :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 9904 | { |
| 9905 | setFrequency(frequency); |
| 9906 | startBlowing( 1.1 + (amplitude * 0.20), amplitude * 0.02); |
| 9907 | outputGain = amplitude + 0.001; |
| 9908 | |
| 9909 | #if defined(_STK_DEBUG_) |
| 9910 | CK_STDCERR << "[chuck](via STK): Flute: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 9911 | #endif |
| 9912 | } |
| 9913 | |
| 9914 | void Flute :: noteOff(MY_FLOAT amplitude) |
| 9915 | { |
| 9916 | this->stopBlowing(amplitude * 0.02); |
| 9917 | |
| 9918 | #if defined(_STK_DEBUG_) |
| 9919 | CK_STDCERR << "[chuck](via STK): Flute: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 9920 | #endif |
| 9921 | } |
| 9922 | |
| 9923 | void Flute :: setJetReflection(MY_FLOAT coefficient) |
| 9924 | { |
| 9925 | jetReflection = coefficient; |
| 9926 | m_jetReflection = coefficient; |
| 9927 | } |
| 9928 | |
| 9929 | void Flute :: setEndReflection(MY_FLOAT coefficient) |
| 9930 | { |
| 9931 | endReflection = coefficient; |
| 9932 | m_endReflection = coefficient; |
| 9933 | } |
| 9934 | |
| 9935 | void Flute :: setJetDelay(MY_FLOAT aRatio) |
| 9936 | { |
| 9937 | // Delay = length - approximate filter delay. |
| 9938 | MY_FLOAT temp = Stk::sampleRate() / lastFrequency - (MY_FLOAT) 2.0; |
| 9939 | jetRatio = aRatio; |
| 9940 | jetDelay->setDelay(temp * aRatio); // Scaled by ratio. |
| 9941 | m_jetDelay = aRatio; |
| 9942 | } |
| 9943 | |
| 9944 | MY_FLOAT Flute :: tick() |
| 9945 | { |
| 9946 | MY_FLOAT pressureDiff; |
| 9947 | MY_FLOAT breathPressure; |
| 9948 | |
| 9949 | // Calculate the breath pressure (envelope + noise + vibrato) |
| 9950 | breathPressure = maxPressure * adsr->tick(); |
| 9951 | breathPressure += breathPressure * noiseGain * noise->tick(); |
| 9952 | breathPressure += breathPressure * vibratoGain * vibrato->tick(); |
| 9953 | |
| 9954 | MY_FLOAT temp = filter->tick( boreDelay->lastOut() ); |
| 9955 | temp = dcBlock->tick(temp); // Block DC on reflection. |
| 9956 | |
| 9957 | pressureDiff = breathPressure - (jetReflection * temp); |
| 9958 | pressureDiff = jetDelay->tick( pressureDiff ); |
| 9959 | pressureDiff = jetTable->tick( pressureDiff ) + (endReflection * temp); |
| 9960 | lastOutput = (MY_FLOAT) 0.3 * boreDelay->tick( pressureDiff ); |
| 9961 | |
| 9962 | lastOutput *= outputGain; |
| 9963 | return lastOutput; |
| 9964 | } |
| 9965 | |
| 9966 | void Flute :: controlChange(int number, MY_FLOAT value) |
| 9967 | { |
| 9968 | MY_FLOAT norm = value * ONE_OVER_128; |
| 9969 | if ( norm < 0 ) { |
| 9970 | norm = 0.0; |
| 9971 | CK_STDCERR << "[chuck](via STK): Flute: Control value less than zero!" << CK_STDENDL; |
| 9972 | } |
| 9973 | else if ( norm > 1.0 ) { |
| 9974 | norm = 1.0; |
| 9975 | CK_STDCERR << "[chuck](via STK): Flute: Control value exceeds nominal range!" << CK_STDENDL; |
| 9976 | } |
| 9977 | |
| 9978 | if (number == __SK_JetDelay_) // 2 |
| 9979 | this->setJetDelay( (MY_FLOAT) (0.08 + (0.48 * norm)) ); |
| 9980 | else if (number == __SK_NoiseLevel_) { // 4 |
| 9981 | m_noiseGain = norm; |
| 9982 | noiseGain = ( norm * 0.4); |
| 9983 | } |
| 9984 | else if (number == __SK_ModFrequency_) // 11 |
| 9985 | setVibratoFreq( norm * 12.0 ); |
| 9986 | else if (number == __SK_ModWheel_) { // 1 |
| 9987 | m_vibratoGain = norm; |
| 9988 | vibratoGain = ( norm * 0.4 ); |
| 9989 | } |
| 9990 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 9991 | m_pressure = norm; |
| 9992 | adsr->setTarget( norm ); |
| 9993 | } |
| 9994 | else |
| 9995 | CK_STDCERR << "[chuck](via STK): Flute: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 9996 | |
| 9997 | #if defined(_STK_DEBUG_) |
| 9998 | CK_STDCERR << "[chuck](via STK): Flute: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 9999 | #endif |
| 10000 | } |
| 10001 | |
| 10002 | |
| 10003 | /***************************************************/ |
| 10004 | /*! \class FormSwep |
| 10005 | \brief STK sweepable formant filter class. |
| 10006 | |
| 10007 | This public BiQuad filter subclass implements |
| 10008 | a formant (resonance) which can be "swept" |
| 10009 | over time from one frequency setting to another. |
| 10010 | It provides methods for controlling the sweep |
| 10011 | rate and target frequency. |
| 10012 | |
| 10013 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 10014 | */ |
| 10015 | /***************************************************/ |
| 10016 | |
| 10017 | |
| 10018 | FormSwep :: FormSwep() : BiQuad() |
| 10019 | { |
| 10020 | frequency = (MY_FLOAT) 0.0; |
| 10021 | radius = (MY_FLOAT) 0.0; |
| 10022 | targetGain = (MY_FLOAT) 1.0; |
| 10023 | targetFrequency = (MY_FLOAT) 0.0; |
| 10024 | targetRadius = (MY_FLOAT) 0.0; |
| 10025 | deltaGain = (MY_FLOAT) 0.0; |
| 10026 | deltaFrequency = (MY_FLOAT) 0.0; |
| 10027 | deltaRadius = (MY_FLOAT) 0.0; |
| 10028 | sweepState = (MY_FLOAT) 0.0; |
| 10029 | sweepRate = (MY_FLOAT) 0.002; |
| 10030 | startFrequency = (MY_FLOAT) 0.0; // 1.5.0.4 (ge) added |
| 10031 | startGain = (MY_FLOAT)0.0; // 1.5.0.4 (ge) added |
| 10032 | startRadius = (MY_FLOAT)0.0; // 1.5.0.4 (ge) added |
| 10033 | dirty = false; |
| 10034 | this->clear(); |
| 10035 | } |
| 10036 | |
| 10037 | FormSwep :: ~FormSwep() |
| 10038 | { |
| 10039 | } |
| 10040 | |
| 10041 | void FormSwep :: setResonance(MY_FLOAT aFrequency, MY_FLOAT aRadius) |
| 10042 | { |
| 10043 | dirty = false; |
| 10044 | radius = aRadius; |
| 10045 | frequency = aFrequency; |
| 10046 | |
| 10047 | BiQuad::setResonance( frequency, radius, true ); |
| 10048 | } |
| 10049 | |
| 10050 | void FormSwep :: setStates(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain) |
| 10051 | { |
| 10052 | dirty = false; |
| 10053 | |
| 10054 | if ( frequency != aFrequency || radius != aRadius ) |
| 10055 | BiQuad::setResonance( aFrequency, aRadius, true ); |
| 10056 | |
| 10057 | frequency = aFrequency; |
| 10058 | radius = aRadius; |
| 10059 | gain = aGain; |
| 10060 | targetFrequency = aFrequency; |
| 10061 | targetRadius = aRadius; |
| 10062 | targetGain = aGain; |
| 10063 | } |
| 10064 | |
| 10065 | void FormSwep :: setTargets(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain) |
| 10066 | { |
| 10067 | dirty = true; |
| 10068 | startFrequency = frequency; |
| 10069 | startRadius = radius; |
| 10070 | startGain = gain; |
| 10071 | targetFrequency = aFrequency; |
| 10072 | targetRadius = aRadius; |
| 10073 | targetGain = aGain; |
| 10074 | deltaFrequency = aFrequency - frequency; |
| 10075 | deltaRadius = aRadius - radius; |
| 10076 | deltaGain = aGain - gain; |
| 10077 | sweepState = (MY_FLOAT) 0.0; |
| 10078 | } |
| 10079 | |
| 10080 | void FormSwep :: setSweepRate(MY_FLOAT aRate) |
| 10081 | { |
| 10082 | sweepRate = aRate; |
| 10083 | if ( sweepRate > 1.0 ) sweepRate = 1.0; |
| 10084 | if ( sweepRate < 0.0 ) sweepRate = 0.0; |
| 10085 | } |
| 10086 | |
| 10087 | void FormSwep :: setSweepTime(MY_FLOAT aTime) |
| 10088 | { |
| 10089 | sweepRate = 1.0 / ( aTime * Stk::sampleRate() ); |
| 10090 | if ( sweepRate > 1.0 ) sweepRate = 1.0; |
| 10091 | if ( sweepRate < 0.0 ) sweepRate = 0.0; |
| 10092 | } |
| 10093 | |
| 10094 | MY_FLOAT FormSwep :: tick(MY_FLOAT sample) |
| 10095 | { |
| 10096 | if (dirty) { |
| 10097 | sweepState += sweepRate; |
| 10098 | if ( sweepState >= 1.0 ) { |
| 10099 | sweepState = (MY_FLOAT) 1.0; |
| 10100 | dirty = false; |
| 10101 | radius = targetRadius; |
| 10102 | frequency = targetFrequency; |
| 10103 | gain = targetGain; |
| 10104 | } |
| 10105 | else { |
| 10106 | radius = startRadius + (deltaRadius * sweepState); |
| 10107 | frequency = startFrequency + (deltaFrequency * sweepState); |
| 10108 | gain = startGain + (deltaGain * sweepState); |
| 10109 | } |
| 10110 | BiQuad::setResonance( frequency, radius, true ); |
| 10111 | } |
| 10112 | |
| 10113 | return BiQuad::tick( sample ); |
| 10114 | } |
| 10115 | |
| 10116 | MY_FLOAT *FormSwep :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 10117 | { |
| 10118 | for (unsigned int i=0; i<vectorSize; i++) |
| 10119 | vec[i] = tick(vec[i]); |
| 10120 | |
| 10121 | return vec; |
| 10122 | } |
| 10123 | /***************************************************/ |
| 10124 | /*! \class HevyMetl |
| 10125 | \brief STK heavy metal FM synthesis instrument. |
| 10126 | |
| 10127 | This class implements 3 cascade operators with |
| 10128 | feedback modulation, also referred to as |
| 10129 | algorithm 3 of the TX81Z. |
| 10130 | |
| 10131 | Algorithm 3 is : 4--\ |
| 10132 | 3-->2-- + -->1-->Out |
| 10133 | |
| 10134 | Control Change Numbers: |
| 10135 | - Total Modulator Index = 2 |
| 10136 | - Modulator Crossfade = 4 |
| 10137 | - LFO Speed = 11 |
| 10138 | - LFO Depth = 1 |
| 10139 | - ADSR 2 & 4 Target = 128 |
| 10140 | |
| 10141 | The basic Chowning/Stanford FM patent expired |
| 10142 | in 1995, but there exist follow-on patents, |
| 10143 | mostly assigned to Yamaha. If you are of the |
| 10144 | type who should worry about this (making |
| 10145 | money) worry away. |
| 10146 | |
| 10147 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 10148 | */ |
| 10149 | /***************************************************/ |
| 10150 | |
| 10151 | |
| 10152 | HevyMetl :: HevyMetl() |
| 10153 | : FM() |
| 10154 | { |
| 10155 | // Concatenate the STK rawwave path to the rawwave files |
| 10156 | for ( int i=0; i<3; i++ ) |
| 10157 | waves[i] = new WaveLoop( "special:sinewave", TRUE ); |
| 10158 | waves[3] = new WaveLoop( "special:fwavblnk", TRUE ); |
| 10159 | |
| 10160 | this->setRatio(0, 1.0 * 1.000); |
| 10161 | this->setRatio(1, 4.0 * 0.999); |
| 10162 | this->setRatio(2, 3.0 * 1.001); |
| 10163 | this->setRatio(3, 0.5 * 1.002); |
| 10164 | |
| 10165 | gains[0] = __FM_gains[92]; |
| 10166 | gains[1] = __FM_gains[76]; |
| 10167 | gains[2] = __FM_gains[91]; |
| 10168 | gains[3] = __FM_gains[68]; |
| 10169 | |
| 10170 | baseGains[0] = gains[0]; // 1.4.1.0 ***** REPAIRATHON2021 ADDITIONS ***** |
| 10171 | baseGains[1] = gains[0]; |
| 10172 | baseGains[2] = gains[0]; |
| 10173 | baseGains[3] = gains[0]; |
| 10174 | |
| 10175 | adsr[0]->setAllTimes( 0.001, 0.001, 1.0, 0.01); |
| 10176 | adsr[1]->setAllTimes( 0.001, 0.010, 1.0, 0.50); |
| 10177 | adsr[2]->setAllTimes( 0.010, 0.005, 1.0, 0.20); |
| 10178 | adsr[3]->setAllTimes( 0.030, 0.010, 0.2, 0.20); |
| 10179 | |
| 10180 | twozero->setGain( 2.0 ); |
| 10181 | op4Feedback = 2.0; // 1.4.1.0 |
| 10182 | vibrato->setFrequency( 5.5 ); |
| 10183 | modDepth = 0.0; |
| 10184 | } |
| 10185 | |
| 10186 | HevyMetl :: ~HevyMetl() |
| 10187 | { |
| 10188 | // note: waves array taken care of in FM destructor |
| 10189 | } |
| 10190 | |
| 10191 | void HevyMetl :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 10192 | { |
| 10193 | // 1.4.1.0 (prc) commented out |
| 10194 | // gains[0] = amplitude * __FM_gains[92]; // OLD WAY OF DOING IT |
| 10195 | // gains[1] = amplitude * __FM_gains[76]; // ... DELETE THESE SOMEDAY |
| 10196 | // gains[2] = amplitude * __FM_gains[91]; |
| 10197 | // gains[3] = amplitude * __FM_gains[68]; |
| 10198 | |
| 10199 | // 1.4.1.0 ***** REPAIRATHON2021 CHANGESS ***** |
| 10200 | gains[0] = amplitude * baseGains[0]; |
| 10201 | gains[1] = amplitude * baseGains[1]; |
| 10202 | gains[2] = amplitude * baseGains[2]; |
| 10203 | gains[3] = amplitude * baseGains[3]; |
| 10204 | |
| 10205 | this->setFrequency(frequency); |
| 10206 | this->keyOn(); |
| 10207 | |
| 10208 | #if defined(_STK_DEBUG_) |
| 10209 | CK_STDCERR << "HevyMetl: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 10210 | #endif |
| 10211 | } |
| 10212 | |
| 10213 | MY_FLOAT HevyMetl :: tick() // 1.4.1.0 (prc) REPAIRATHON2021 updated |
| 10214 | { |
| 10215 | /* register */ MY_FLOAT temp, temp2; |
| 10216 | |
| 10217 | temp2 = vibrato->tick(); // save for AM later /*****2021 REPAIRATHON ADDITION *****/ |
| 10218 | temp = temp2 * modDepth * 0.2; |
| 10219 | for (int i = 0; i < 4; i++) { |
| 10220 | if (ratios[i] > 0.0) { |
| 10221 | waves[i]->setFrequency(baseFrequency * (1.0 + temp) * ratios[i]); |
| 10222 | } |
| 10223 | } |
| 10224 | |
| 10225 | // waves[0]->setFrequency(baseFrequency * (1.0 + temp) * ratios[0]); |
| 10226 | // waves[1]->setFrequency(baseFrequency * (1.0 + temp) * ratios[1]); |
| 10227 | // waves[2]->setFrequency(baseFrequency * (1.0 + temp) * ratios[2]); |
| 10228 | // waves[3]->setFrequency(baseFrequency * (1.0 + temp) * ratios[3]); |
| 10229 | |
| 10230 | /***** REPAIRATHON2021 NOTE!!!! THIS ALGORITHM MIGHT HAVE BEEN WRONG ALL ALONG!!! *****/ |
| 10231 | temp = (1.0 + opAMs[2]*temp2) * gains[2] * adsr[2]->tick() * waves[2]->tick(); // Op3 |
| 10232 | waves[1]->addPhaseOffset(temp); |
| 10233 | |
| 10234 | waves[3]->addPhaseOffset(twozero->lastOut()); // Op4 |
| 10235 | temp = (1.0 + opAMs[3]*temp2 - (control2 * 0.5)) * gains[3] * adsr[3]->tick() * waves[3]->tick(); // Op4 |
| 10236 | twozero->tick(temp); |
| 10237 | |
| 10238 | temp += (1.0 + opAMs[1]*temp2) * control2 * (MY_FLOAT) 0.5 * gains[1] * adsr[1]->tick() * waves[1]->tick(); // Op2 |
| 10239 | temp = temp * control1; |
| 10240 | |
| 10241 | waves[0]->addPhaseOffset(temp); |
| 10242 | temp = (1.0 + opAMs[0]*temp2) * gains[0] * adsr[0]->tick() * waves[0]->tick(); // Added AM // Op1 |
| 10243 | |
| 10244 | lastOutput = temp * 0.5; |
| 10245 | return lastOutput; |
| 10246 | } |
| 10247 | |
| 10248 | |
| 10249 | |
| 10250 | |
| 10251 | |
| 10252 | //----------------------------------------------------------------------------- |
| 10253 | // 1.4.1.0 ***** REPAIRATHON2021 BRAND NEW FM ALGORITHMS!!! ***** |
| 10254 | //----------------------------------------------------------------------------- |
| 10255 | /***** REPAIRATHON2021 BRAND NEW FM ALGORITHMS!!! *****/ |
| 10256 | /***************************************************/ |
| 10257 | /*! \class HnkyTonk |
| 10258 | \brief New STK-style Honkey Tonk Piano FM synthesis instrument. |
| 10259 | |
| 10260 | This class implements 4 cascade operators with |
| 10261 | feedback modulation on the master modulator, |
| 10262 | also referred to as algorithm 1 of the TX81Z. |
| 10263 | |
| 10264 | Algorithm 1 is : |
| 10265 | 4-->3-->2-->1-->Out |
| 10266 | |
| 10267 | Control Change Numbers: |
| 10268 | - Total Modulator Index = 2 |
| 10269 | - Modulator Crossfade = 4 |
| 10270 | - LFO Speed = 11 |
| 10271 | - LFO Depth = 1 |
| 10272 | - ADSR 2 & 4 Target = 128 |
| 10273 | |
| 10274 | The basic Chowning/Stanford FM patent expired |
| 10275 | in 1995, but there exist follow-on patents, |
| 10276 | mostly assigned to Yamaha. If you are of the |
| 10277 | type who should worry about this (making |
| 10278 | money) worry away. |
| 10279 | |
| 10280 | by Perry R. Cook, 2021. |
| 10281 | */ |
| 10282 | /***************************************************/ |
| 10283 | |
| 10284 | HnkyTonk :: HnkyTonk() |
| 10285 | : FM() |
| 10286 | { |
| 10287 | // Concatenate the STK rawwave path to the rawwave files |
| 10288 | for ( int i=0; i<3; i++ ) |
| 10289 | waves[i] = new WaveLoop( "special:sinewave", TRUE ); |
| 10290 | waves[3] = new WaveLoop( "special:sineblnk", TRUE ); |
| 10291 | |
| 10292 | this->setRatio(0, 1.51); // 1.51 |
| 10293 | this->setRatio(1, 1.49); // 1.49 |
| 10294 | this->setRatio(2, 10.49); // 10.49 |
| 10295 | this->setRatio(3, 7.22); |
| 10296 | |
| 10297 | gains[0] = __FM_gains[99]; |
| 10298 | gains[1] = __FM_gains[78]; // 78 |
| 10299 | gains[2] = __FM_gains[61]; // 61 |
| 10300 | gains[3] = __FM_gains[48]; // 48 |
| 10301 | |
| 10302 | baseGains[0] = gains[0]; /***** REPAIRATHON2021 CHANGES *****/ |
| 10303 | baseGains[1] = gains[1]; |
| 10304 | baseGains[2] = gains[2]; |
| 10305 | baseGains[3] = gains[3]; |
| 10306 | |
| 10307 | adsr[0]->setAllTimes( __FM_attTimes[20], __FM_attTimes[8], __FM_susLevels[12], __FM_attTimes[5]); // 6 |
| 10308 | adsr[1]->setAllTimes( __FM_attTimes[22], __FM_attTimes[3], __FM_susLevels[12], __FM_attTimes[4]); |
| 10309 | adsr[2]->setAllTimes( __FM_attTimes[24], __FM_attTimes[27], __FM_susLevels[13], __FM_attTimes[3]); |
| 10310 | adsr[3]->setAllTimes( __FM_attTimes[24], __FM_attTimes[1], __FM_susLevels[0], __FM_attTimes[3]); |
| 10311 | |
| 10312 | twozero->setGain( 0.8 ); |
| 10313 | op4Feedback = 0.8; |
| 10314 | vibrato->setFrequency( 6.0 ); |
| 10315 | modDepth = 0.05; |
| 10316 | } |
| 10317 | |
| 10318 | HnkyTonk :: ~HnkyTonk() |
| 10319 | { |
| 10320 | // note: waves array taken care of in FM destructor |
| 10321 | } |
| 10322 | |
| 10323 | void HnkyTonk :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 10324 | { |
| 10325 | // gains[0] = amplitude * __FM_gains[92]; // OLD WAY OF DOING IT |
| 10326 | // gains[1] = amplitude * __FM_gains[76]; // DELETE THESE SOMEDAY |
| 10327 | // gains[2] = amplitude * __FM_gains[91]; |
| 10328 | // gains[3] = amplitude * __FM_gains[68]; |
| 10329 | |
| 10330 | gains[0] = amplitude * baseGains[0]; /***** REPAIRATHON2021 CHANGES *****/ |
| 10331 | gains[1] = amplitude * baseGains[1]; |
| 10332 | gains[2] = amplitude * baseGains[2]; |
| 10333 | gains[3] = amplitude * baseGains[3]; |
| 10334 | |
| 10335 | this->setFrequency(frequency); |
| 10336 | this->keyOn(); |
| 10337 | |
| 10338 | #if defined(_STK_DEBUG_) |
| 10339 | CK_STDCERR << "HevyMetl: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 10340 | #endif |
| 10341 | } |
| 10342 | |
| 10343 | MY_FLOAT HnkyTonk :: tick() /***** REPAIRATHON2021 NEED TO FIX THIS!!! */ |
| 10344 | { |
| 10345 | /* register */ MY_FLOAT temp, temp2; |
| 10346 | |
| 10347 | temp2 = vibrato->tick(); |
| 10348 | |
| 10349 | temp = temp2 * modDepth * 0.2; |
| 10350 | for (int i = 0; i < 4; i++) { |
| 10351 | if (ratios[i] > 0.0) { |
| 10352 | waves[i]->setFrequency(baseFrequency * (1.0 + temp) * ratios[i]); |
| 10353 | } |
| 10354 | } |
| 10355 | |
| 10356 | waves[3]->addPhaseOffset(twozero->lastOut()); |
| 10357 | temp = (1.0 + opAMs[3]*temp2) * control1 * gains[3] * adsr[3]->tick() * waves[3]->tick(); |
| 10358 | twozero->tick(temp); |
| 10359 | |
| 10360 | waves[2]->addPhaseOffset(temp); |
| 10361 | temp = (1.0 + opAMs[2]*temp2) * gains[2] * adsr[2]->tick() * waves[2]->tick(); |
| 10362 | |
| 10363 | waves[1]->addPhaseOffset(temp); |
| 10364 | temp = (1.0 + opAMs[1]*temp2) * control1 * gains[1] * adsr[1]->tick() * waves[1]->tick(); |
| 10365 | |
| 10366 | waves[0]->addPhaseOffset(temp); |
| 10367 | temp = (1.0 + opAMs[0]*temp2) * gains[0] * adsr[0]->tick() * waves[0]->tick(); |
| 10368 | |
| 10369 | lastOutput = temp; |
| 10370 | return lastOutput; |
| 10371 | } |
| 10372 | |
| 10373 | |
| 10374 | |
| 10375 | |
| 10376 | /***************************************************/ |
| 10377 | /*! \class FrencHrn |
| 10378 | \brief NEW STK-style French Horn FM synthesis instrument. |
| 10379 | |
| 10380 | This class implements 3 cascade operators with |
| 10381 | feedback modulation, also referred to as |
| 10382 | algorithm 3 of the TX81Z. |
| 10383 | |
| 10384 | Algorithm 3 is: 4--\ |
| 10385 | 3-->2-- + -->1-->Out |
| 10386 | |
| 10387 | Control Change Numbers: |
| 10388 | - Total Modulator Index = 2 |
| 10389 | - Modulator Crossfade = 4 |
| 10390 | - LFO Speed = 11 |
| 10391 | - LFO Depth = 1 |
| 10392 | - ADSR 2 & 4 Target = 128 |
| 10393 | |
| 10394 | The basic Chowning/Stanford FM patent expired |
| 10395 | in 1995, but there exist follow-on patents, |
| 10396 | mostly assigned to Yamaha. If you are of the |
| 10397 | type who should worry about this (making |
| 10398 | money) worry away. |
| 10399 | |
| 10400 | by Perry R. Cook, 2021. |
| 10401 | */ |
| 10402 | /***************************************************/ |
| 10403 | |
| 10404 | FrencHrn :: FrencHrn() |
| 10405 | : FM() |
| 10406 | { |
| 10407 | // Concatenate the STK rawwave path to the rawwave files |
| 10408 | for( int i=0; i<4; i++ ) |
| 10409 | waves[i] = new WaveLoop( "special:sinewave", TRUE ); |
| 10410 | |
| 10411 | this->setRatio(0, 1.0); |
| 10412 | this->setRatio(1, 0.99); |
| 10413 | this->setRatio(2, 3.14); |
| 10414 | this->setRatio(3, 0.99); |
| 10415 | |
| 10416 | gains[0] = __FM_gains[97]; /***** REPAIRATHON2021: French Horn!!! *****/ |
| 10417 | gains[1] = __FM_gains[77]; // Factory Bank 1759 says 67, adjust for controls |
| 10418 | gains[2] = __FM_gains[59]; |
| 10419 | gains[3] = __FM_gains[71]; |
| 10420 | |
| 10421 | baseGains[0] = gains[0]; |
| 10422 | baseGains[1] = gains[1]; |
| 10423 | baseGains[2] = gains[2]; |
| 10424 | baseGains[3] = gains[3]; |
| 10425 | |
| 10426 | adsr[0]->setAllTimes( __FM_attTimes[12], __FM_attTimes[31], __FM_susLevels[15], __FM_attTimes[16]); // 6 |
| 10427 | adsr[1]->setAllTimes( __FM_attTimes[14], __FM_attTimes[31], __FM_susLevels[15], __FM_attTimes[16]); |
| 10428 | adsr[2]->setAllTimes( __FM_attTimes[31], __FM_attTimes[14], __FM_susLevels[0], __FM_attTimes[16]); |
| 10429 | adsr[3]->setAllTimes( __FM_attTimes[8], __FM_attTimes[5], __FM_susLevels[0], __FM_attTimes[16]); |
| 10430 | |
| 10431 | twozero->setGain( 1.0 ); // 2.0 ); |
| 10432 | op4Feedback = 1.0; |
| 10433 | vibrato->setFrequency( 6.0 ); |
| 10434 | modDepth = 0.0; |
| 10435 | control1 = 1.0; |
| 10436 | control2 = 1.0; |
| 10437 | // control1 = 1.3; |
| 10438 | // control2 = 1.3; |
| 10439 | } |
| 10440 | |
| 10441 | FrencHrn :: ~FrencHrn() |
| 10442 | { |
| 10443 | // note: waves array taken care of in FM destructor |
| 10444 | } |
| 10445 | |
| 10446 | void FrencHrn :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 10447 | { |
| 10448 | gains[0] = amplitude * baseGains[0]; |
| 10449 | gains[1] = amplitude * baseGains[1]; |
| 10450 | gains[2] = amplitude * baseGains[2]; |
| 10451 | gains[3] = amplitude * baseGains[3]; |
| 10452 | |
| 10453 | this->setFrequency(frequency); |
| 10454 | this->keyOn(); |
| 10455 | |
| 10456 | #if defined(_STK_DEBUG_) |
| 10457 | CK_STDCERR << "HevyMetl: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 10458 | #endif |
| 10459 | } |
| 10460 | |
| 10461 | MY_FLOAT FrencHrn :: tick() |
| 10462 | { |
| 10463 | /* register */ MY_FLOAT temp, temp2; |
| 10464 | |
| 10465 | temp2 = vibrato->tick(); // save for AM /***** REPAIRATHON2021 HACK *****/ |
| 10466 | |
| 10467 | temp = temp2 * modDepth * 0.2; |
| 10468 | for (int i = 0; i < 4; i++) { |
| 10469 | if (ratios[i] > 0.0) { |
| 10470 | waves[i]->setFrequency(baseFrequency * (1.0 + temp) * ratios[i]); |
| 10471 | } |
| 10472 | } |
| 10473 | |
| 10474 | waves[3]->addPhaseOffset(twozero->lastOut()); // Operator 4 |
| 10475 | // temp = (1.0 - (control2 * 0.5)) * gains[3] * adsr[3]->tick() * waves[3]->tick(); |
| 10476 | temp = (1.0 + opAMs[3]*temp2) * control2 * 0.5 * gains[3] * adsr[3]->tick() * waves[3]->tick(); // ADDED AM |
| 10477 | twozero->tick(temp); |
| 10478 | temp = temp * control2; |
| 10479 | |
| 10480 | temp += (1.0 + opAMs[2]*temp2) * control1 * 0.5 * gains[2] * adsr[2]->tick() * waves[2]->tick(); // Operator 3 // ADDED AM too |
| 10481 | |
| 10482 | waves[1]->addPhaseOffset(temp); // Operator 2 |
| 10483 | temp = (1.0 + opAMs[1]*temp2) * gains[1] * adsr[1]->tick() * waves[1]->tick(); // ADDED AM |
| 10484 | temp = temp * 0.5 * (control1 + control2); |
| 10485 | // temp = temp * control1; |
| 10486 | |
| 10487 | waves[0]->addPhaseOffset(temp); // Operator 1 |
| 10488 | temp = (1.0 + opAMs[0]*temp2) * gains[0] * adsr[0]->tick() * waves[0]->tick(); // ADDED AM |
| 10489 | |
| 10490 | lastOutput = temp; |
| 10491 | return lastOutput; |
| 10492 | } |
| 10493 | |
| 10494 | //----------------------------------------------------------------------------- |
| 10495 | // 1.4.1.0 ***** REPAIRATHON2021 BRAND NEW FM ALGORITHMS!!! ***** |
| 10496 | //----------------------------------------------------------------------------- |
| 10497 | |
| 10498 | /***************************************************/ |
| 10499 | /*! \class KrstlChr |
| 10500 | \brief New STK-style "Crystal Choir" FM synthesis instrument. |
| 10501 | |
| 10502 | This class implements 3 parallel operators with |
| 10503 | one modulated, by one with feedback modulation, |
| 10504 | also referred to as algorithm 7 of the TX81Z. |
| 10505 | |
| 10506 | Algorithm 3 is: 4-->3-->\ |
| 10507 | 2--> + -->Out |
| 10508 | 1-->/ |
| 10509 | |
| 10510 | Control Change Numbers: |
| 10511 | - Total Modulator Index = 2 |
| 10512 | - Modulator Crossfade = 4 |
| 10513 | - LFO Speed = 11 |
| 10514 | - LFO Depth = 1 |
| 10515 | - ADSR 2 & 4 Target = 128 |
| 10516 | |
| 10517 | The basic Chowning/Stanford FM patent expired |
| 10518 | in 1995, but there exist follow-on patents, |
| 10519 | mostly assigned to Yamaha. If you are of the |
| 10520 | type who should worry about this (making |
| 10521 | money) worry away. |
| 10522 | |
| 10523 | by Perry R. Cook, 2021. |
| 10524 | */ |
| 10525 | /***************************************************/ |
| 10526 | |
| 10527 | KrstlChr :: KrstlChr() |
| 10528 | : FM() |
| 10529 | { |
| 10530 | // Concatenate the STK rawwave path to the rawwave files |
| 10531 | waves[0] = new WaveLoop( "special:sineblnk", TRUE ); |
| 10532 | waves[1] = new WaveLoop( "special:snglpeak", TRUE ); |
| 10533 | waves[2] = new WaveLoop( "special:sinewave", TRUE ); |
| 10534 | waves[3] = new WaveLoop( "special:snglpeak", TRUE ); |
| 10535 | |
| 10536 | // this->setRatio(0, 1.50); // This is what PatchBase editor says |
| 10537 | // this->setRatio(1, 1.51); // Factory bank 1761 is |
| 10538 | // this->setRatio(2, 1.49); // but I think that's shit |
| 10539 | // this->setRatio(3, 8.63); |
| 10540 | |
| 10541 | this->setRatio(0, 1.00); |
| 10542 | this->setRatio(1, 0.99); |
| 10543 | this->setRatio(2, 1.01); |
| 10544 | this->setRatio(3, 8.63); |
| 10545 | |
| 10546 | gains[0] = __FM_gains[99]; |
| 10547 | gains[1] = __FM_gains[99]; |
| 10548 | gains[2] = __FM_gains[89]; |
| 10549 | gains[3] = __FM_gains[77]; // Factory Bank 1761 says 67 |
| 10550 | |
| 10551 | baseGains[0] = gains[0]; |
| 10552 | baseGains[1] = gains[1]; |
| 10553 | baseGains[2] = gains[2]; |
| 10554 | baseGains[3] = gains[3]; |
| 10555 | |
| 10556 | adsr[0]->setAllTimes( __FM_attTimes[14], __FM_attTimes[8], 1.0, __FM_attTimes[5]); |
| 10557 | adsr[1]->setAllTimes( __FM_attTimes[11], __FM_attTimes[8], 1.0, __FM_attTimes[7]); |
| 10558 | adsr[2]->setAllTimes( __FM_attTimes[15], __FM_attTimes[7], 1.0, __FM_attTimes[7]); |
| 10559 | adsr[3]->setAllTimes( __FM_attTimes[31], __FM_attTimes[0], 1.0, __FM_attTimes[4]); |
| 10560 | |
| 10561 | twozero->setGain( 2.0 ); // Op4 Feedback |
| 10562 | op4Feedback = 2.0; |
| 10563 | vibrato->setFrequency( 3.5 ); |
| 10564 | modDepth = 0.02; |
| 10565 | } |
| 10566 | |
| 10567 | KrstlChr :: ~KrstlChr() |
| 10568 | { |
| 10569 | // note: waves array taken care of in FM destructor |
| 10570 | } |
| 10571 | |
| 10572 | void KrstlChr :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 10573 | { |
| 10574 | gains[0] = amplitude * baseGains[0]; /***** REPAIRATHON2021 *****/ |
| 10575 | gains[1] = amplitude * baseGains[1]; |
| 10576 | gains[2] = amplitude * baseGains[2]; |
| 10577 | gains[3] = amplitude * baseGains[3]; |
| 10578 | |
| 10579 | this->setFrequency(frequency); |
| 10580 | this->keyOn(); |
| 10581 | |
| 10582 | #if defined(_STK_DEBUG_) |
| 10583 | CK_STDCERR << "HevyMetl: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 10584 | #endif |
| 10585 | } |
| 10586 | |
| 10587 | MY_FLOAT KrstlChr :: tick() |
| 10588 | { |
| 10589 | /* register */ MY_FLOAT temp, temp2; |
| 10590 | |
| 10591 | temp2 = vibrato->tick() * modDepth * 0.2; // Save for AM |
| 10592 | |
| 10593 | temp = vibrato->tick() * modDepth * 0.2; |
| 10594 | for (int i = 0; i < 4; i++) { |
| 10595 | if (ratios[i] > 0.0) { |
| 10596 | waves[i]->setFrequency(baseFrequency * (1.0 + temp) * ratios[i]); |
| 10597 | } |
| 10598 | } |
| 10599 | |
| 10600 | waves[3]->addPhaseOffset(twozero->lastOut()); |
| 10601 | twozero->tick(temp); |
| 10602 | temp = (1.0 + opAMs[3]*temp2) * gains[3] * adsr[3]->tick() * waves[3]->tick(); // Add AM |
| 10603 | |
| 10604 | waves[2]->addPhaseOffset(temp); |
| 10605 | |
| 10606 | temp = (1.0 + opAMs[2]*temp2 - (control2 * 0.5)) * gains[2] * adsr[2]->tick() * waves[2]->tick(); // Add AM |
| 10607 | |
| 10608 | temp += (1.0 + opAMs[1]*temp2) * control2 * (MY_FLOAT) 0.5 * gains[1] * adsr[1]->tick() * waves[1]->tick(); // Add AM |
| 10609 | temp = temp * control1; |
| 10610 | |
| 10611 | temp += (1.0 + opAMs[0]*temp2) * gains[0] * adsr[0]->tick() * waves[0]->tick(); // Add AM |
| 10612 | |
| 10613 | lastOutput = temp * 0.5; |
| 10614 | return lastOutput; |
| 10615 | } |
| 10616 | |
| 10617 | //----------------------------------------------------------------------------- |
| 10618 | // 1.4.1.0 ***** END REPAIRATHON2021 ADDITIONS of NEW FM ALGORITHMS ***** |
| 10619 | //----------------------------------------------------------------------------- |
| 10620 | |
| 10621 | |
| 10622 | |
| 10623 | //----------------------------------------------------------------------------- |
| 10624 | // name: stk_verify_baseclass() |
| 10625 | // desc: check base class pointer, if NULL throw exception (which also halts the shred) |
| 10626 | //----------------------------------------------------------------------------- |
| 10627 | t_CKBOOL stk_verify_baseclass( void * ptr, const std::string & typeName, Chuck_VM_Shred * shred ) |
| 10628 | { |
| 10629 | if( ptr == NULL ) |
| 10630 | { |
| 10631 | // we have a problem |
| 10632 | EM_exception( "MethodCalledByAbstractClass: '%s' is an abstract class\n" |
| 10633 | "...(hint: call the method using a non-abstract subclass) shred[id=%lu:%s]", |
| 10634 | typeName.c_str(), shred->xid, shred->name.c_str() ); |
| 10635 | // halt the shred |
| 10636 | shred->is_running = FALSE; |
| 10637 | shred->is_done = TRUE; |
| 10638 | // return false |
| 10639 | return FALSE; |
| 10640 | } |
| 10641 | |
| 10642 | return TRUE; |
| 10643 | } |
| 10644 | |
| 10645 | |
| 10646 | |
| 10647 | |
| 10648 | /***************************************************/ |
| 10649 | /*! \class Instrmnt |
| 10650 | \brief STK instrument abstract base class. |
| 10651 | |
| 10652 | This class provides a common interface for |
| 10653 | all STK instruments. |
| 10654 | |
| 10655 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 10656 | */ |
| 10657 | /***************************************************/ |
| 10658 | |
| 10659 | |
| 10660 | Instrmnt :: Instrmnt() |
| 10661 | { |
| 10662 | lastOutput = 0; |
| 10663 | m_frequency = 0; |
| 10664 | } |
| 10665 | |
| 10666 | Instrmnt :: ~Instrmnt() |
| 10667 | { |
| 10668 | } |
| 10669 | |
| 10670 | void Instrmnt :: setFrequency(MY_FLOAT frequency) |
| 10671 | { |
| 10672 | CK_STDCERR << "[chuck](via STK): StkInstrument is abstract and cannot be used directly!" << CK_STDENDL; |
| 10673 | // m_frequency = frequency; |
| 10674 | } |
| 10675 | |
| 10676 | MY_FLOAT Instrmnt :: lastOut() const |
| 10677 | { |
| 10678 | return lastOutput; |
| 10679 | } |
| 10680 | |
| 10681 | // Support for stereo output: |
| 10682 | MY_FLOAT Instrmnt :: lastOutLeft(void) const |
| 10683 | { |
| 10684 | return 0.5 * lastOutput; |
| 10685 | } |
| 10686 | |
| 10687 | MY_FLOAT Instrmnt :: lastOutRight(void) const |
| 10688 | { |
| 10689 | return 0.5 * lastOutput; |
| 10690 | } |
| 10691 | |
| 10692 | MY_FLOAT *Instrmnt :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 10693 | { |
| 10694 | for (unsigned int i=0; i<vectorSize; i++) |
| 10695 | vec[i] = tick(); |
| 10696 | |
| 10697 | return vec; |
| 10698 | } |
| 10699 | |
| 10700 | /* |
| 10701 | TODO : let's add this as two function in Chuck. |
| 10702 | : one version is a ( int , float ) for the midi messages |
| 10703 | : the second is a ( string, float ) that does a quick binary search |
| 10704 | : into the skini table for the __SK_ value, and dispatches the proper function |
| 10705 | : hoohoo! |
| 10706 | |
| 10707 | - and then everyone can inherit from Instrmnt like the good Lord intended. |
| 10708 | - pld |
| 10709 | */ |
| 10710 | |
| 10711 | void Instrmnt :: controlChange(int number, MY_FLOAT value) |
| 10712 | { |
| 10713 | } |
| 10714 | |
| 10715 | /***************************************************/ |
| 10716 | /*! \class JCRev |
| 10717 | \brief John Chowning's reverberator class. |
| 10718 | |
| 10719 | This class is derived from the CLM JCRev |
| 10720 | function, which is based on the use of |
| 10721 | networks of simple allpass and comb delay |
| 10722 | filters. This class implements three series |
| 10723 | allpass units, followed by four parallel comb |
| 10724 | filters, and two decorrelation delay lines in |
| 10725 | parallel at the output. |
| 10726 | |
| 10727 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 10728 | */ |
| 10729 | /***************************************************/ |
| 10730 | |
| 10731 | #include <math.h> |
| 10732 | |
| 10733 | JCRev :: JCRev(MY_FLOAT T60) |
| 10734 | { |
| 10735 | // Delay lengths for 44100 Hz sample rate. |
| 10736 | int lengths[9] = {1777, 1847, 1993, 2137, 389, 127, 43, 211, 179}; |
| 10737 | double scaler = Stk::sampleRate() / 44100.0; |
| 10738 | |
| 10739 | int delay, i; |
| 10740 | if ( scaler != 1.0 ) { |
| 10741 | for (i=0; i<9; i++) { |
| 10742 | delay = (int) floor(scaler * lengths[i]); |
| 10743 | if ( (delay & 1) == 0) delay++; |
| 10744 | while ( !this->isPrime(delay) ) delay += 2; |
| 10745 | lengths[i] = delay; |
| 10746 | } |
| 10747 | } |
| 10748 | |
| 10749 | for (i=0; i<3; i++) |
| 10750 | allpassDelays[i] = new DelayBase(lengths[i+4], lengths[i+4]); |
| 10751 | |
| 10752 | for (i=0; i<4; i++) { |
| 10753 | combDelays[i] = new DelayBase(lengths[i], lengths[i]); |
| 10754 | combCoefficient[i] = pow(10.0,(-3 * lengths[i] / (T60 * Stk::sampleRate()))); |
| 10755 | } |
| 10756 | |
| 10757 | outLeftDelay = new DelayBase(lengths[7], lengths[7]); |
| 10758 | outRightDelay = new DelayBase(lengths[8], lengths[8]); |
| 10759 | allpassCoefficient = 0.7; |
| 10760 | effectMix = 0.3; |
| 10761 | this->clear(); |
| 10762 | } |
| 10763 | |
| 10764 | JCRev :: ~JCRev() |
| 10765 | { |
| 10766 | delete allpassDelays[0]; |
| 10767 | delete allpassDelays[1]; |
| 10768 | delete allpassDelays[2]; |
| 10769 | delete combDelays[0]; |
| 10770 | delete combDelays[1]; |
| 10771 | delete combDelays[2]; |
| 10772 | delete combDelays[3]; |
| 10773 | delete outLeftDelay; |
| 10774 | delete outRightDelay; |
| 10775 | } |
| 10776 | |
| 10777 | void JCRev :: clear() |
| 10778 | { |
| 10779 | allpassDelays[0]->clear(); |
| 10780 | allpassDelays[1]->clear(); |
| 10781 | allpassDelays[2]->clear(); |
| 10782 | combDelays[0]->clear(); |
| 10783 | combDelays[1]->clear(); |
| 10784 | combDelays[2]->clear(); |
| 10785 | combDelays[3]->clear(); |
| 10786 | outRightDelay->clear(); |
| 10787 | outLeftDelay->clear(); |
| 10788 | lastOutput[0] = 0.0; |
| 10789 | lastOutput[1] = 0.0; |
| 10790 | } |
| 10791 | |
| 10792 | MY_FLOAT JCRev :: tick(MY_FLOAT input) |
| 10793 | { |
| 10794 | MY_FLOAT temp, temp0, temp1, temp2, temp3, temp4, temp5, temp6; |
| 10795 | MY_FLOAT filtout; |
| 10796 | |
| 10797 | // gewang: dedenormal |
| 10798 | CK_STK_DDN(input); |
| 10799 | |
| 10800 | temp = allpassDelays[0]->lastOut(); |
| 10801 | temp0 = allpassCoefficient * temp; |
| 10802 | temp0 += input; |
| 10803 | // gewang: dedenormal |
| 10804 | CK_STK_DDN(temp0); |
| 10805 | allpassDelays[0]->tick(temp0); |
| 10806 | temp0 = -(allpassCoefficient * temp0) + temp; |
| 10807 | |
| 10808 | temp = allpassDelays[1]->lastOut(); |
| 10809 | temp1 = allpassCoefficient * temp; |
| 10810 | temp1 += temp0; |
| 10811 | // gewang: dedenormal |
| 10812 | CK_STK_DDN(temp1); |
| 10813 | allpassDelays[1]->tick(temp1); |
| 10814 | temp1 = -(allpassCoefficient * temp1) + temp; |
| 10815 | |
| 10816 | temp = allpassDelays[2]->lastOut(); |
| 10817 | temp2 = allpassCoefficient * temp; |
| 10818 | temp2 += temp1; |
| 10819 | // gewang: dedenormal |
| 10820 | CK_STK_DDN(temp2); |
| 10821 | allpassDelays[2]->tick(temp2); |
| 10822 | temp2 = -(allpassCoefficient * temp2) + temp; |
| 10823 | |
| 10824 | temp3 = temp2 + (combCoefficient[0] * combDelays[0]->lastOut()); |
| 10825 | temp4 = temp2 + (combCoefficient[1] * combDelays[1]->lastOut()); |
| 10826 | temp5 = temp2 + (combCoefficient[2] * combDelays[2]->lastOut()); |
| 10827 | temp6 = temp2 + (combCoefficient[3] * combDelays[3]->lastOut()); |
| 10828 | |
| 10829 | // gewang: dedenormal |
| 10830 | CK_STK_DDN(temp3); |
| 10831 | CK_STK_DDN(temp4); |
| 10832 | CK_STK_DDN(temp5); |
| 10833 | CK_STK_DDN(temp6); |
| 10834 | |
| 10835 | combDelays[0]->tick(temp3); |
| 10836 | combDelays[1]->tick(temp4); |
| 10837 | combDelays[2]->tick(temp5); |
| 10838 | combDelays[3]->tick(temp6); |
| 10839 | |
| 10840 | filtout = temp3 + temp4 + temp5 + temp6; |
| 10841 | |
| 10842 | // gewang: dedenormal |
| 10843 | CK_STK_DDN(filtout); |
| 10844 | |
| 10845 | lastOutput[0] = effectMix * (outLeftDelay->tick(filtout)); |
| 10846 | lastOutput[1] = effectMix * (outRightDelay->tick(filtout)); |
| 10847 | temp = (1.0 - effectMix) * input; |
| 10848 | lastOutput[0] += temp; |
| 10849 | lastOutput[1] += temp; |
| 10850 | |
| 10851 | return (lastOutput[0] + lastOutput[1]) * 0.5; |
| 10852 | } |
| 10853 | |
| 10854 | |
| 10855 | /***************************************************/ |
| 10856 | /*! \class JetTabl |
| 10857 | \brief STK jet table class. |
| 10858 | |
| 10859 | This class implements a flue jet non-linear |
| 10860 | function, computed by a polynomial calculation. |
| 10861 | Contrary to the name, this is not a "table". |
| 10862 | |
| 10863 | Consult Fletcher and Rossing, Karjalainen, |
| 10864 | Cook, and others for more information. |
| 10865 | |
| 10866 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 10867 | */ |
| 10868 | /***************************************************/ |
| 10869 | |
| 10870 | |
| 10871 | JetTabl :: JetTabl() |
| 10872 | { |
| 10873 | lastOutput = (MY_FLOAT) 0.0; |
| 10874 | } |
| 10875 | |
| 10876 | JetTabl :: ~JetTabl() |
| 10877 | { |
| 10878 | } |
| 10879 | |
| 10880 | MY_FLOAT JetTabl :: lastOut() const |
| 10881 | { |
| 10882 | return lastOutput; |
| 10883 | } |
| 10884 | |
| 10885 | MY_FLOAT JetTabl :: tick( MY_FLOAT input ) |
| 10886 | { |
| 10887 | // Perform "table lookup" using a polynomial |
| 10888 | // calculation (x^3 - x), which approximates |
| 10889 | // the jet sigmoid behavior. |
| 10890 | lastOutput = input * (input * input - (MY_FLOAT)1.0); |
| 10891 | |
| 10892 | // Saturate at +/- 1.0. |
| 10893 | if (lastOutput > 1.0) |
| 10894 | lastOutput = (MY_FLOAT) 1.0; |
| 10895 | if (lastOutput < -1.0) |
| 10896 | lastOutput = (MY_FLOAT) -1.0; |
| 10897 | return lastOutput; |
| 10898 | } |
| 10899 | |
| 10900 | MY_FLOAT *JetTabl :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 10901 | { |
| 10902 | for (unsigned int i=0; i<vectorSize; i++) |
| 10903 | vec[i] = tick(vec[i]); |
| 10904 | |
| 10905 | return vec; |
| 10906 | } |
| 10907 | |
| 10908 | /***************************************************/ |
| 10909 | /*! \class Mandolin |
| 10910 | \brief STK mandolin instrument model class. |
| 10911 | |
| 10912 | This class inherits from PluckTwo and uses |
| 10913 | "commuted synthesis" techniques to model a |
| 10914 | mandolin instrument. |
| 10915 | |
| 10916 | This is a digital waveguide model, making its |
| 10917 | use possibly subject to patents held by |
| 10918 | Stanford University, Yamaha, and others. |
| 10919 | Commuted Synthesis, in particular, is covered |
| 10920 | by patents, granted, pending, and/or |
| 10921 | applied-for. All are assigned to the Board of |
| 10922 | Trustees, Stanford University. For |
| 10923 | information, contact the Office of Technology |
| 10924 | Licensing, Stanford University. |
| 10925 | |
| 10926 | Control Change Numbers: |
| 10927 | - Body Size = 2 |
| 10928 | - Pluck Position = 4 |
| 10929 | - String Sustain = 11 |
| 10930 | - String Detuning = 1 |
| 10931 | - Microphone Position = 128 |
| 10932 | |
| 10933 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 10934 | */ |
| 10935 | /***************************************************/ |
| 10936 | |
| 10937 | |
| 10938 | Mandolin :: Mandolin(MY_FLOAT lowestFrequency) |
| 10939 | : PluckTwo(lowestFrequency) |
| 10940 | { |
| 10941 | // Concatenate the STK rawwave path to the rawwave files |
| 10942 | soundfile[0] = new WvIn( "special:mand1", TRUE ); |
| 10943 | /* |
| 10944 | soundfile[1] = new WvIn( "special:mand1", TRUE ); |
| 10945 | soundfile[2] = new WvIn( "special:mand1", TRUE ); |
| 10946 | soundfile[3] = new WvIn( "special:mand1", TRUE ); |
| 10947 | soundfile[4] = new WvIn( "special:mand1", TRUE ); |
| 10948 | soundfile[5] = new WvIn( "special:mand1", TRUE ); |
| 10949 | soundfile[6] = new WvIn( "special:mand1", TRUE ); |
| 10950 | soundfile[7] = new WvIn( "special:mand1", TRUE ); |
| 10951 | soundfile[8] = new WvIn( "special:mand1", TRUE ); |
| 10952 | soundfile[9] = new WvIn( "special:mand1", TRUE ); |
| 10953 | soundfile[10] = new WvIn( "special:mand1", TRUE ); |
| 10954 | soundfile[11] = new WvIn( "special:mand1", TRUE ); |
| 10955 | */ |
| 10956 | for( int i = 1; i <= 11; i ++ ) |
| 10957 | soundfile[i] = soundfile[0]; |
| 10958 | |
| 10959 | directBody = 1.0; |
| 10960 | mic = 0; |
| 10961 | dampTime = 0; |
| 10962 | // chuck: don't play |
| 10963 | waveDone = true; |
| 10964 | //waveDone = soundfile[mic]->isFinished(); |
| 10965 | //reverse: nothing |
| 10966 | m_bodySize = 1.0; |
| 10967 | } |
| 10968 | |
| 10969 | bool Mandolin :: setBodyIR( const char * path, bool isRaw ) |
| 10970 | { |
| 10971 | soundfile[0]->openFile( path, isRaw ); |
| 10972 | return true; |
| 10973 | } |
| 10974 | |
| 10975 | Mandolin :: ~Mandolin() |
| 10976 | { |
| 10977 | // for( int i=0; i<12; i++ ) |
| 10978 | // CK_SAFE_DELETE( soundfile[i] ); |
| 10979 | |
| 10980 | // chuck: all the soundfiles are the same object, only delete one of them |
| 10981 | CK_SAFE_DELETE(soundfile[0]); |
| 10982 | for( int i=1; i<12; i++ ) |
| 10983 | soundfile[i] = NULL; |
| 10984 | } |
| 10985 | |
| 10986 | void Mandolin :: pluck(MY_FLOAT amplitude) |
| 10987 | { |
| 10988 | // This function gets interesting, because pluck |
| 10989 | // may be longer than string length, so we just |
| 10990 | // reset the soundfile and add in the pluck in |
| 10991 | // the tick method. |
| 10992 | soundfile[mic]->reset(); |
| 10993 | waveDone = false; |
| 10994 | pluckAmplitude = amplitude; |
| 10995 | if ( amplitude < 0.0 ) { |
| 10996 | CK_STDCERR << "[chuck](via STK): Mandolin: pluck amplitude parameter less than zero!" << CK_STDENDL; |
| 10997 | pluckAmplitude = 0.0; |
| 10998 | } |
| 10999 | else if ( amplitude > 1.0 ) { |
| 11000 | CK_STDCERR << "[chuck](via STK): Mandolin: pluck amplitude parameter greater than 1.0!" << CK_STDENDL; |
| 11001 | pluckAmplitude = 1.0; |
| 11002 | } |
| 11003 | |
| 11004 | // Set the pick position, which puts zeroes at position * length. |
| 11005 | combDelay->setDelay((MY_FLOAT) 0.5 * pluckPosition * lastLength); |
| 11006 | dampTime = (long) lastLength; // See tick method below. |
| 11007 | } |
| 11008 | |
| 11009 | void Mandolin :: pluck(MY_FLOAT amplitude, MY_FLOAT position) |
| 11010 | { |
| 11011 | // Pluck position puts zeroes at position * length. |
| 11012 | pluckPosition = position; |
| 11013 | if ( position < 0.0 ) { |
| 11014 | CK_STDCERR << "[chuck](via STK): Mandolin: pluck position parameter less than zero!" << CK_STDENDL; |
| 11015 | pluckPosition = 0.0; |
| 11016 | } |
| 11017 | else if ( position > 1.0 ) { |
| 11018 | CK_STDCERR << "[chuck](via STK): Mandolin: pluck position parameter greater than 1.0!" << CK_STDENDL; |
| 11019 | pluckPosition = 1.0; |
| 11020 | } |
| 11021 | |
| 11022 | this->pluck(amplitude); |
| 11023 | } |
| 11024 | |
| 11025 | void Mandolin :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 11026 | { |
| 11027 | this->setFrequency(frequency); |
| 11028 | this->pluck(amplitude); |
| 11029 | |
| 11030 | #if defined(_STK_DEBUG_) |
| 11031 | CK_STDCERR << "[chuck](via STK): Mandolin: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 11032 | #endif |
| 11033 | } |
| 11034 | |
| 11035 | void Mandolin :: setBodySize(MY_FLOAT size) |
| 11036 | { |
| 11037 | m_bodySize = size; |
| 11038 | // Scale the commuted body response by its sample rate (22050). |
| 11039 | MY_FLOAT rate = size * soundfile[mic]->sampleRate() / Stk::sampleRate(); |
| 11040 | for ( int i=0; i<12; i++ ) |
| 11041 | soundfile[i]->setRate(rate); |
| 11042 | } |
| 11043 | |
| 11044 | MY_FLOAT Mandolin :: tick() |
| 11045 | { |
| 11046 | MY_FLOAT temp = 0.0; |
| 11047 | if ( !waveDone ) { |
| 11048 | // Scale the pluck excitation with comb |
| 11049 | // filtering for the duration of the file. |
| 11050 | temp = soundfile[mic]->tick() * pluckAmplitude; |
| 11051 | temp = temp - combDelay->tick(temp); |
| 11052 | waveDone = soundfile[mic]->isFinished(); |
| 11053 | } |
| 11054 | |
| 11055 | // Damping hack to help avoid overflow on re-plucking. |
| 11056 | if ( dampTime >=0 ) { |
| 11057 | dampTime -= 1; |
| 11058 | // Calculate 1st delay filtered reflection plus pluck excitation. |
| 11059 | lastOutput = delayLine->tick( filter->tick( temp + (delayLine->lastOut() * (MY_FLOAT) 0.7) ) ); |
| 11060 | // Calculate 2nd delay just like the 1st. |
| 11061 | lastOutput += delayLine2->tick( filter2->tick( temp + (delayLine2->lastOut() * (MY_FLOAT) 0.7) ) ); |
| 11062 | } |
| 11063 | else { // No damping hack after 1 period. |
| 11064 | // Calculate 1st delay filtered reflection plus pluck excitation. |
| 11065 | lastOutput = delayLine->tick( filter->tick( temp + (delayLine->lastOut() * loopGain) ) ); |
| 11066 | // Calculate 2nd delay just like the 1st. |
| 11067 | lastOutput += delayLine2->tick( filter2->tick( temp + (delayLine2->lastOut() * loopGain) ) ); |
| 11068 | } |
| 11069 | |
| 11070 | lastOutput *= (MY_FLOAT) 0.3; |
| 11071 | return lastOutput; |
| 11072 | } |
| 11073 | |
| 11074 | void Mandolin :: controlChange(int number, MY_FLOAT value) |
| 11075 | { |
| 11076 | MY_FLOAT norm = value * ONE_OVER_128; |
| 11077 | if ( norm < 0 ) { |
| 11078 | norm = 0.0; |
| 11079 | CK_STDCERR << "[chuck](via STK): Mandolin: Control value less than zero!" << CK_STDENDL; |
| 11080 | } |
| 11081 | else if ( norm > 1.0 ) { |
| 11082 | norm = 1.0; |
| 11083 | CK_STDCERR << "[chuck](via STK): Mandolin: Control value exceeds nominal range!" << CK_STDENDL; |
| 11084 | } |
| 11085 | |
| 11086 | if (number == __SK_BodySize_) // 2 |
| 11087 | this->setBodySize( norm * 2.0 ); |
| 11088 | else if (number == __SK_PickPosition_) // 4 |
| 11089 | this->setPluckPosition( norm ); |
| 11090 | else if (number == __SK_StringDamping_) // 11 |
| 11091 | this->setBaseLoopGain((MY_FLOAT) 0.97 + (norm * (MY_FLOAT) 0.03)); |
| 11092 | else if (number == __SK_StringDetune_) // 1 |
| 11093 | this->setDetune((MY_FLOAT) 1.0 - (norm * (MY_FLOAT) 0.1)); |
| 11094 | else if (number == __SK_AfterTouch_Cont_) // 128 |
| 11095 | mic = (int) (norm * 11.0); |
| 11096 | else |
| 11097 | CK_STDCERR << "[chuck](via STK): Mandolin: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 11098 | |
| 11099 | #if defined(_STK_DEBUG_) |
| 11100 | CK_STDCERR << "[chuck](via STK): Mandolin: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 11101 | #endif |
| 11102 | } |
| 11103 | |
| 11104 | |
| 11105 | /***************************************************/ |
| 11106 | /*! \class Mesh2D |
| 11107 | \brief Two-dimensional rectilinear waveguide mesh class. |
| 11108 | |
| 11109 | This class implements a rectilinear, |
| 11110 | two-dimensional digital waveguide mesh |
| 11111 | structure. For details, see Van Duyne and |
| 11112 | Smith, "Physical Modeling with the 2-D Digital |
| 11113 | Waveguide Mesh", Proceedings of the 1993 |
| 11114 | International Computer Music Conference. |
| 11115 | |
| 11116 | This is a digital waveguide model, making its |
| 11117 | use possibly subject to patents held by Stanford |
| 11118 | University, Yamaha, and others. |
| 11119 | |
| 11120 | Control Change Numbers: |
| 11121 | - X Dimension = 2 |
| 11122 | - Y Dimension = 4 |
| 11123 | - Mesh Decay = 11 |
| 11124 | - X-Y Input Position = 1 |
| 11125 | |
| 11126 | by Julius Smith, 2000 - 2002. |
| 11127 | Revised by Gary Scavone for STK, 2002. |
| 11128 | */ |
| 11129 | /***************************************************/ |
| 11130 | |
| 11131 | #include <stdlib.h> |
| 11132 | |
| 11133 | Mesh2D :: Mesh2D(short nX, short nY) |
| 11134 | { |
| 11135 | this->setNX(nX); |
| 11136 | this->setNY(nY); |
| 11137 | |
| 11138 | MY_FLOAT pole = 0.05; |
| 11139 | |
| 11140 | short i; |
| 11141 | for (i=0; i<NYMAX; i++) { |
| 11142 | filterY[i] = new OnePole(pole); |
| 11143 | filterY[i]->setGain(0.99); |
| 11144 | } |
| 11145 | |
| 11146 | for (i=0; i<NXMAX; i++) { |
| 11147 | filterX[i] = new OnePole(pole); |
| 11148 | filterX[i]->setGain(0.99); |
| 11149 | } |
| 11150 | |
| 11151 | this->clearMesh(); |
| 11152 | |
| 11153 | counter=0; |
| 11154 | xInput = 0; |
| 11155 | yInput = 0; |
| 11156 | } |
| 11157 | |
| 11158 | Mesh2D :: ~Mesh2D() |
| 11159 | { |
| 11160 | short i; |
| 11161 | for (i=0; i<NYMAX; i++) |
| 11162 | delete filterY[i]; |
| 11163 | |
| 11164 | for (i=0; i<NXMAX; i++) |
| 11165 | delete filterX[i]; |
| 11166 | } |
| 11167 | |
| 11168 | void Mesh2D :: clear() |
| 11169 | { |
| 11170 | this->clearMesh(); |
| 11171 | |
| 11172 | short i; |
| 11173 | for (i=0; i<NY; i++) |
| 11174 | filterY[i]->clear(); |
| 11175 | |
| 11176 | for (i=0; i<NX; i++) |
| 11177 | filterX[i]->clear(); |
| 11178 | |
| 11179 | counter=0; |
| 11180 | } |
| 11181 | |
| 11182 | void Mesh2D :: clearMesh() |
| 11183 | { |
| 11184 | int x, y; |
| 11185 | for (x=0; x<NXMAX-1; x++) { |
| 11186 | for (y=0; y<NYMAX-1; y++) { |
| 11187 | v[x][y] = 0; |
| 11188 | } |
| 11189 | } |
| 11190 | for (x=0; x<NXMAX; x++) { |
| 11191 | for (y=0; y<NYMAX; y++) { |
| 11192 | |
| 11193 | vxp[x][y] = 0; |
| 11194 | vxm[x][y] = 0; |
| 11195 | vyp[x][y] = 0; |
| 11196 | vym[x][y] = 0; |
| 11197 | |
| 11198 | vxp1[x][y] = 0; |
| 11199 | vxm1[x][y] = 0; |
| 11200 | vyp1[x][y] = 0; |
| 11201 | vym1[x][y] = 0; |
| 11202 | } |
| 11203 | } |
| 11204 | } |
| 11205 | |
| 11206 | MY_FLOAT Mesh2D :: energy() |
| 11207 | { |
| 11208 | // Return total energy contained in wave variables Note that some |
| 11209 | // energy is also contained in any filter delay elements. |
| 11210 | |
| 11211 | int x, y; |
| 11212 | MY_FLOAT t; |
| 11213 | MY_FLOAT e = 0; |
| 11214 | if ( counter & 1 ) { // Ready for Mesh2D::tick1() to be called. |
| 11215 | for (x=0; x<NX; x++) { |
| 11216 | for (y=0; y<NY; y++) { |
| 11217 | t = vxp1[x][y]; |
| 11218 | e += t*t; |
| 11219 | t = vxm1[x][y]; |
| 11220 | e += t*t; |
| 11221 | t = vyp1[x][y]; |
| 11222 | e += t*t; |
| 11223 | t = vym1[x][y]; |
| 11224 | e += t*t; |
| 11225 | } |
| 11226 | } |
| 11227 | } |
| 11228 | else { // Ready for Mesh2D::tick0() to be called. |
| 11229 | for (x=0; x<NX; x++) { |
| 11230 | for (y=0; y<NY; y++) { |
| 11231 | t = vxp[x][y]; |
| 11232 | e += t*t; |
| 11233 | t = vxm[x][y]; |
| 11234 | e += t*t; |
| 11235 | t = vyp[x][y]; |
| 11236 | e += t*t; |
| 11237 | t = vym[x][y]; |
| 11238 | e += t*t; |
| 11239 | } |
| 11240 | } |
| 11241 | } |
| 11242 | |
| 11243 | return(e); |
| 11244 | } |
| 11245 | |
| 11246 | void Mesh2D :: setNX(short lenX) |
| 11247 | { |
| 11248 | NX = lenX; |
| 11249 | if ( lenX < 2 ) { |
| 11250 | CK_STDCERR << "[chuck](via STK): Mesh2D::setNX(" << lenX << "): Minimum length is 2!" << CK_STDENDL; |
| 11251 | NX = 2; |
| 11252 | } |
| 11253 | else if ( lenX > NXMAX ) { |
| 11254 | CK_STDCERR << "[chuck](via STK): Mesh2D::setNX(" << lenX << "): Maximum length is " << NXMAX << "!" << CK_STDENDL; |
| 11255 | NX = NXMAX; |
| 11256 | } |
| 11257 | } |
| 11258 | |
| 11259 | void Mesh2D :: setNY(short lenY) |
| 11260 | { |
| 11261 | NY = lenY; |
| 11262 | if ( lenY < 2 ) { |
| 11263 | CK_STDCERR << "[chuck](via STK): Mesh2D::setNY(" << lenY << "): Minimum length is 2!" << CK_STDENDL; |
| 11264 | NY = 2; |
| 11265 | } |
| 11266 | else if ( lenY > NYMAX ) { |
| 11267 | CK_STDCERR << "[chuck](via STK): Mesh2D::setNY(" << lenY << "): Maximum length is " << NYMAX << "!" << CK_STDENDL; |
| 11268 | NY = NYMAX; |
| 11269 | } |
| 11270 | } |
| 11271 | |
| 11272 | void Mesh2D :: setDecay(MY_FLOAT decayFactor) |
| 11273 | { |
| 11274 | MY_FLOAT gain = decayFactor; |
| 11275 | if ( decayFactor < 0.0 ) { |
| 11276 | CK_STDCERR << "[chuck](via STK): Mesh2D::setDecay decayFactor value is less than 0.0!" << CK_STDENDL; |
| 11277 | gain = 0.0; |
| 11278 | } |
| 11279 | else if ( decayFactor > 1.0 ) { |
| 11280 | CK_STDCERR << "[chuck](via STK): Mesh2D::setDecay decayFactor value is greater than 1.0!" << CK_STDENDL; |
| 11281 | gain = 1.0; |
| 11282 | } |
| 11283 | |
| 11284 | int i; |
| 11285 | for (i=0; i<NYMAX; i++) |
| 11286 | filterY[i]->setGain(gain); |
| 11287 | |
| 11288 | for (i=0; i<NXMAX; i++) |
| 11289 | filterX[i]->setGain(gain); |
| 11290 | } |
| 11291 | |
| 11292 | void Mesh2D :: setInputPosition(MY_FLOAT xFactor, MY_FLOAT yFactor) |
| 11293 | { |
| 11294 | if ( xFactor < 0.0 ) { |
| 11295 | CK_STDCERR << "[chuck](via STK): Mesh2D::setInputPosition xFactor value is less than 0.0!" << CK_STDENDL; |
| 11296 | xInput = 0; |
| 11297 | } |
| 11298 | else if ( xFactor > 1.0 ) { |
| 11299 | CK_STDCERR << "[chuck](via STK): Mesh2D::setInputPosition xFactor value is greater than 1.0!" << CK_STDENDL; |
| 11300 | xInput = NX - 1; |
| 11301 | } |
| 11302 | else |
| 11303 | xInput = (short) (xFactor * (NX - 1)); |
| 11304 | |
| 11305 | if ( yFactor < 0.0 ) { |
| 11306 | CK_STDCERR << "[chuck](via STK): Mesh2D::setInputPosition yFactor value is less than 0.0!" << CK_STDENDL; |
| 11307 | yInput = 0; |
| 11308 | } |
| 11309 | else if ( yFactor > 1.0 ) { |
| 11310 | CK_STDCERR << "[chuck](via STK): Mesh2D::setInputPosition yFactor value is greater than 1.0!" << CK_STDENDL; |
| 11311 | yInput = NY - 1; |
| 11312 | } |
| 11313 | else |
| 11314 | yInput = (short) (yFactor * (NY - 1)); |
| 11315 | } |
| 11316 | |
| 11317 | void Mesh2D :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 11318 | { |
| 11319 | // Input at corner. |
| 11320 | if ( counter & 1 ) { |
| 11321 | vxp1[xInput][yInput] += amplitude; |
| 11322 | vyp1[xInput][yInput] += amplitude; |
| 11323 | } |
| 11324 | else { |
| 11325 | vxp[xInput][yInput] += amplitude; |
| 11326 | vyp[xInput][yInput] += amplitude; |
| 11327 | } |
| 11328 | |
| 11329 | #if defined(_STK_DEBUG_) |
| 11330 | CK_STDCERR << "[chuck](via STK): Mesh2D: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 11331 | #endif |
| 11332 | } |
| 11333 | |
| 11334 | void Mesh2D :: noteOff(MY_FLOAT amplitude) |
| 11335 | { |
| 11336 | #if defined(_STK_DEBUG_) |
| 11337 | CK_STDCERR << "[chuck](via STK): Mesh2D: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 11338 | #endif |
| 11339 | } |
| 11340 | |
| 11341 | MY_FLOAT Mesh2D :: tick(MY_FLOAT input) |
| 11342 | { |
| 11343 | if ( counter & 1 ) { |
| 11344 | vxp1[xInput][yInput] += input; |
| 11345 | vyp1[xInput][yInput] += input; |
| 11346 | lastOutput = tick1(); |
| 11347 | } |
| 11348 | else { |
| 11349 | vxp[xInput][yInput] += input; |
| 11350 | vyp[xInput][yInput] += input; |
| 11351 | lastOutput = tick0(); |
| 11352 | } |
| 11353 | |
| 11354 | counter++; |
| 11355 | return lastOutput; |
| 11356 | } |
| 11357 | |
| 11358 | MY_FLOAT Mesh2D :: tick() |
| 11359 | { |
| 11360 | lastOutput = ((counter & 1) ? this->tick1() : this->tick0()); |
| 11361 | counter++; |
| 11362 | return lastOutput; |
| 11363 | } |
| 11364 | |
| 11365 | #define VSCALE ((MY_FLOAT) (0.5)) |
| 11366 | |
| 11367 | MY_FLOAT Mesh2D :: tick0() |
| 11368 | { |
| 11369 | int x, y; |
| 11370 | MY_FLOAT outsamp = 0; |
| 11371 | |
| 11372 | // Update junction velocities. |
| 11373 | for (x=0; x<NX-1; x++) { |
| 11374 | for (y=0; y<NY-1; y++) { |
| 11375 | v[x][y] = ( vxp[x][y] + vxm[x+1][y] + |
| 11376 | vyp[x][y] + vym[x][y+1] ) * VSCALE; |
| 11377 | } |
| 11378 | } |
| 11379 | |
| 11380 | // Update junction outgoing waves, using alternate wave-variable buffers. |
| 11381 | for (x=0; x<NX-1; x++) { |
| 11382 | for (y=0; y<NY-1; y++) { |
| 11383 | MY_FLOAT vxy = v[x][y]; |
| 11384 | // Update positive-going waves. |
| 11385 | vxp1[x+1][y] = vxy - vxm[x+1][y]; |
| 11386 | vyp1[x][y+1] = vxy - vym[x][y+1]; |
| 11387 | // Update minus-going waves. |
| 11388 | vxm1[x][y] = vxy - vxp[x][y]; |
| 11389 | vym1[x][y] = vxy - vyp[x][y]; |
| 11390 | } |
| 11391 | } |
| 11392 | |
| 11393 | // Loop over velocity-junction boundary faces, update edge |
| 11394 | // reflections, with filtering. We're only filtering on one x and y |
| 11395 | // edge here and even this could be made much sparser. |
| 11396 | for (y=0; y<NY-1; y++) { |
| 11397 | vxp1[0][y] = filterY[y]->tick(vxm[0][y]); |
| 11398 | vxm1[NX-1][y] = vxp[NX-1][y]; |
| 11399 | } |
| 11400 | for (x=0; x<NX-1; x++) { |
| 11401 | vyp1[x][0] = filterX[x]->tick(vym[x][0]); |
| 11402 | vym1[x][NY-1] = vyp[x][NY-1]; |
| 11403 | } |
| 11404 | |
| 11405 | // Output = sum of outgoing waves at far corner. Note that the last |
| 11406 | // index in each coordinate direction is used only with the other |
| 11407 | // coordinate indices at their next-to-last values. This is because |
| 11408 | // the "unit strings" attached to each velocity node to terminate |
| 11409 | // the mesh are not themselves connected together. |
| 11410 | outsamp = vxp[NX-1][NY-2] + vyp[NX-2][NY-1]; |
| 11411 | |
| 11412 | return outsamp; |
| 11413 | } |
| 11414 | |
| 11415 | MY_FLOAT Mesh2D :: tick1() |
| 11416 | { |
| 11417 | int x, y; |
| 11418 | MY_FLOAT outsamp = 0; |
| 11419 | |
| 11420 | // Update junction velocities. |
| 11421 | for (x=0; x<NX-1; x++) { |
| 11422 | for (y=0; y<NY-1; y++) { |
| 11423 | v[x][y] = ( vxp1[x][y] + vxm1[x+1][y] + |
| 11424 | vyp1[x][y] + vym1[x][y+1] ) * VSCALE; |
| 11425 | } |
| 11426 | } |
| 11427 | |
| 11428 | // Update junction outgoing waves, |
| 11429 | // using alternate wave-variable buffers. |
| 11430 | for (x=0; x<NX-1; x++) { |
| 11431 | for (y=0; y<NY-1; y++) { |
| 11432 | MY_FLOAT vxy = v[x][y]; |
| 11433 | |
| 11434 | // Update positive-going waves. |
| 11435 | vxp[x+1][y] = vxy - vxm1[x+1][y]; |
| 11436 | vyp[x][y+1] = vxy - vym1[x][y+1]; |
| 11437 | |
| 11438 | // Update minus-going waves. |
| 11439 | vxm[x][y] = vxy - vxp1[x][y]; |
| 11440 | vym[x][y] = vxy - vyp1[x][y]; |
| 11441 | } |
| 11442 | } |
| 11443 | |
| 11444 | // Loop over velocity-junction boundary faces, update edge |
| 11445 | // reflections, with filtering. We're only filtering on one x and y |
| 11446 | // edge here and even this could be made much sparser. |
| 11447 | for (y=0; y<NY-1; y++) { |
| 11448 | vxp[0][y] = filterY[y]->tick(vxm1[0][y]); |
| 11449 | vxm[NX-1][y] = vxp1[NX-1][y]; |
| 11450 | } |
| 11451 | for (x=0; x<NX-1; x++) { |
| 11452 | vyp[x][0] = filterX[x]->tick(vym1[x][0]); |
| 11453 | vym[x][NY-1] = vyp1[x][NY-1]; |
| 11454 | } |
| 11455 | |
| 11456 | // Output = sum of outgoing waves at far corner. |
| 11457 | outsamp = vxp1[NX-1][NY-2] + vyp1[NX-2][NY-1]; |
| 11458 | |
| 11459 | return outsamp; |
| 11460 | } |
| 11461 | |
| 11462 | void Mesh2D :: controlChange(int number, MY_FLOAT value) |
| 11463 | { |
| 11464 | MY_FLOAT norm = value * ONE_OVER_128; |
| 11465 | if ( norm < 0 ) { |
| 11466 | norm = 0.0; |
| 11467 | CK_STDCERR << "[chuck](via STK): Mesh2D: Control value less than zero!" << CK_STDENDL; |
| 11468 | } |
| 11469 | else if ( norm > 1.0 ) { |
| 11470 | norm = 1.0; |
| 11471 | CK_STDCERR << "[chuck](via STK): Mesh2D: Control value exceeds nominal range!" << CK_STDENDL; |
| 11472 | } |
| 11473 | |
| 11474 | if (number == 2) // 2 |
| 11475 | setNX( (short) (norm * (NXMAX-2) + 2) ); |
| 11476 | else if (number == 4) // 4 |
| 11477 | setNY( (short) (norm * (NYMAX-2) + 2) ); |
| 11478 | else if (number == 11) // 11 |
| 11479 | setDecay( 0.9 + (norm * 0.1) ); |
| 11480 | else if (number == __SK_ModWheel_) // 1 |
| 11481 | setInputPosition(norm, norm); |
| 11482 | else if (number == __SK_AfterTouch_Cont_) // 128 |
| 11483 | ; |
| 11484 | else |
| 11485 | CK_STDCERR << "[chuck](via STK): Mesh2D: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 11486 | |
| 11487 | #if defined(_STK_DEBUG_) |
| 11488 | CK_STDCERR << "[chuck](via STK): Mesh2D: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 11489 | #endif |
| 11490 | } |
| 11491 | /***************************************************/ |
| 11492 | /*! \class Modal |
| 11493 | \brief STK resonance model instrument. |
| 11494 | |
| 11495 | This class contains an excitation wavetable, |
| 11496 | an envelope, an oscillator, and N resonances |
| 11497 | (non-sweeping BiQuad filters), where N is set |
| 11498 | during instantiation. |
| 11499 | |
| 11500 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 11501 | */ |
| 11502 | /***************************************************/ |
| 11503 | |
| 11504 | #include <stdlib.h> |
| 11505 | |
| 11506 | Modal :: Modal(int modes) |
| 11507 | : nModes(modes) |
| 11508 | { |
| 11509 | if ( nModes <= 0 ) { |
| 11510 | char msg[STK_MSG_BUF_LENGTH]; |
| 11511 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via Modal): Invalid number of modes (%d) argument to constructor!", modes); |
| 11512 | handleError(msg, StkError::FUNCTION_ARGUMENT); |
| 11513 | } |
| 11514 | |
| 11515 | // We don't make the excitation wave here yet, because we don't know |
| 11516 | // what it's going to be. |
| 11517 | |
| 11518 | ratios = (MY_FLOAT *) new MY_FLOAT[nModes]; |
| 11519 | radii = (MY_FLOAT *) new MY_FLOAT[nModes]; |
| 11520 | filters = (BiQuad **) calloc( nModes, sizeof(BiQuad *) ); |
| 11521 | for (int i=0; i<nModes; i++ ) { |
| 11522 | filters[i] = new BiQuad; |
| 11523 | filters[i]->setEqualGainZeroes(); |
| 11524 | } |
| 11525 | |
| 11526 | envelope = new Envelope; |
| 11527 | onepole = new OnePole; |
| 11528 | |
| 11529 | // Concatenate the STK rawwave path to the rawwave file |
| 11530 | vibrato = new WaveLoop( "special:sinewave", TRUE ); |
| 11531 | |
| 11532 | // Set some default values. |
| 11533 | vibrato->setFrequency( 6.0 ); |
| 11534 | vibratoGain = 0.0; |
| 11535 | directGain = 0.0; |
| 11536 | masterGain = 1.0; |
| 11537 | baseFrequency = 440.0; |
| 11538 | |
| 11539 | this->clear(); |
| 11540 | |
| 11541 | stickHardness = 0.5; |
| 11542 | strikePosition = 0.561; |
| 11543 | |
| 11544 | // chuck |
| 11545 | m_frequency = baseFrequency; |
| 11546 | m_vibratoGain = vibratoGain; |
| 11547 | m_vibratoFreq = vibrato->m_freq; |
| 11548 | m_volume = 1.0; |
| 11549 | } |
| 11550 | |
| 11551 | Modal :: ~Modal() |
| 11552 | { |
| 11553 | delete envelope; |
| 11554 | delete onepole; |
| 11555 | delete vibrato; |
| 11556 | |
| 11557 | delete [] ratios; |
| 11558 | delete [] radii; |
| 11559 | for (int i=0; i<nModes; i++ ) { |
| 11560 | delete filters[i]; |
| 11561 | } |
| 11562 | free(filters); |
| 11563 | } |
| 11564 | |
| 11565 | void Modal :: clear() |
| 11566 | { |
| 11567 | onepole->clear(); |
| 11568 | for (int i=0; i<nModes; i++ ) |
| 11569 | filters[i]->clear(); |
| 11570 | } |
| 11571 | |
| 11572 | void Modal :: setFrequency(MY_FLOAT frequency) |
| 11573 | { |
| 11574 | baseFrequency = frequency; |
| 11575 | for (int i=0; i<nModes; i++ ) |
| 11576 | this->setRatioAndRadius(i, ratios[i], radii[i]); |
| 11577 | |
| 11578 | // chuck |
| 11579 | m_frequency = baseFrequency; |
| 11580 | } |
| 11581 | |
| 11582 | void Modal :: setRatioAndRadius(int modeIndex, MY_FLOAT ratio, MY_FLOAT radius) |
| 11583 | { |
| 11584 | if ( modeIndex < 0 ) { |
| 11585 | CK_STDCERR << "[chuck](via STK): Modal: setRatioAndRadius modeIndex parameter is less than zero!" << CK_STDENDL; |
| 11586 | return; |
| 11587 | } |
| 11588 | else if ( modeIndex >= nModes ) { |
| 11589 | CK_STDCERR << "[chuck](via STK): Modal: setRatioAndRadius modeIndex parameter is greater than the number of operators!" << CK_STDENDL; |
| 11590 | return; |
| 11591 | } |
| 11592 | |
| 11593 | MY_FLOAT nyquist = Stk::sampleRate() / 2.0; |
| 11594 | MY_FLOAT temp; |
| 11595 | |
| 11596 | if (ratio * baseFrequency < nyquist) { |
| 11597 | ratios[modeIndex] = ratio; |
| 11598 | } |
| 11599 | else { |
| 11600 | temp = ratio; |
| 11601 | while (temp * baseFrequency > nyquist) temp *= (MY_FLOAT) 0.5; |
| 11602 | ratios[modeIndex] = temp; |
| 11603 | #if defined(_STK_DEBUG_) |
| 11604 | CK_STDCERR << "[chuck](via STK): Modal : Aliasing would occur here ... correcting." << CK_STDENDL; |
| 11605 | #endif |
| 11606 | } |
| 11607 | radii[modeIndex] = radius; |
| 11608 | if (ratio < 0) |
| 11609 | temp = -ratio; |
| 11610 | else |
| 11611 | temp = ratio*baseFrequency; |
| 11612 | |
| 11613 | filters[modeIndex]->setResonance(temp, radius); |
| 11614 | } |
| 11615 | |
| 11616 | void Modal :: setMasterGain(MY_FLOAT aGain) |
| 11617 | { |
| 11618 | masterGain = aGain; |
| 11619 | } |
| 11620 | |
| 11621 | void Modal :: setDirectGain(MY_FLOAT aGain) |
| 11622 | { |
| 11623 | directGain = aGain; |
| 11624 | } |
| 11625 | |
| 11626 | void Modal :: setModeGain(int modeIndex, MY_FLOAT gain) |
| 11627 | { |
| 11628 | if ( modeIndex < 0 ) { |
| 11629 | CK_STDCERR << "[chuck](via STK): Modal: setModeGain modeIndex parameter is less than zero!" << CK_STDENDL; |
| 11630 | return; |
| 11631 | } |
| 11632 | else if ( modeIndex >= nModes ) { |
| 11633 | CK_STDCERR << "[chuck](via STK): Modal: setModeGain modeIndex parameter is greater than the number of operators!" << CK_STDENDL; |
| 11634 | return; |
| 11635 | } |
| 11636 | |
| 11637 | filters[modeIndex]->setGain(gain); |
| 11638 | } |
| 11639 | |
| 11640 | void Modal :: strike(MY_FLOAT amplitude) |
| 11641 | { |
| 11642 | MY_FLOAT gain = amplitude; |
| 11643 | if ( amplitude < 0.0 ) { |
| 11644 | CK_STDCERR << "[chuck](via STK): Modal: strike amplitude is less than zero!" << CK_STDENDL; |
| 11645 | gain = 0.0; |
| 11646 | } |
| 11647 | else if ( amplitude > 1.0 ) { |
| 11648 | CK_STDCERR << "[chuck](via STK): Modal: strike amplitude is greater than 1.0!" << CK_STDENDL; |
| 11649 | gain = 1.0; |
| 11650 | } |
| 11651 | |
| 11652 | envelope->setRate(1.0); |
| 11653 | envelope->setTarget(gain); |
| 11654 | onepole->setPole(1.0 - gain); |
| 11655 | envelope->tick(); |
| 11656 | wave->reset(); |
| 11657 | |
| 11658 | MY_FLOAT temp; |
| 11659 | for (int i=0; i<nModes; i++) { |
| 11660 | if (ratios[i] < 0) |
| 11661 | temp = -ratios[i]; |
| 11662 | else |
| 11663 | temp = ratios[i] * baseFrequency; |
| 11664 | filters[i]->setResonance(temp, radii[i]); |
| 11665 | } |
| 11666 | } |
| 11667 | |
| 11668 | void Modal :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 11669 | { |
| 11670 | this->setFrequency(frequency); |
| 11671 | this->strike(amplitude); |
| 11672 | |
| 11673 | #if defined(_STK_DEBUG_) |
| 11674 | CK_STDCERR << "[chuck](via STK): Modal: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 11675 | #endif |
| 11676 | } |
| 11677 | |
| 11678 | void Modal :: noteOff(MY_FLOAT amplitude) |
| 11679 | { |
| 11680 | // This calls damp, but inverts the meaning of amplitude (high |
| 11681 | // amplitude means fast damping). |
| 11682 | this->damp(1.0 - (amplitude * 0.03)); |
| 11683 | |
| 11684 | #if defined(_STK_DEBUG_) |
| 11685 | CK_STDCERR << "[chuck](via STK): Modal: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 11686 | #endif |
| 11687 | } |
| 11688 | |
| 11689 | void Modal :: damp(MY_FLOAT amplitude) |
| 11690 | { |
| 11691 | MY_FLOAT temp; |
| 11692 | for (int i=0; i<nModes; i++) { |
| 11693 | if (ratios[i] < 0) |
| 11694 | temp = -ratios[i]; |
| 11695 | else |
| 11696 | temp = ratios[i] * baseFrequency; |
| 11697 | filters[i]->setResonance(temp, radii[i]*amplitude); |
| 11698 | } |
| 11699 | } |
| 11700 | |
| 11701 | MY_FLOAT Modal :: tick() |
| 11702 | { |
| 11703 | MY_FLOAT temp = masterGain * onepole->tick(wave->tick() * envelope->tick()); |
| 11704 | |
| 11705 | MY_FLOAT temp2 = 0.0; |
| 11706 | for (int i=0; i<nModes; i++) |
| 11707 | temp2 += filters[i]->tick(temp); |
| 11708 | |
| 11709 | temp2 -= temp2 * directGain; |
| 11710 | temp2 += directGain * temp; |
| 11711 | |
| 11712 | if (vibratoGain != 0.0) { |
| 11713 | // Calculate AM and apply to master out |
| 11714 | temp = 1.0 + (vibrato->tick() * vibratoGain); |
| 11715 | temp2 = temp * temp2; |
| 11716 | } |
| 11717 | |
| 11718 | lastOutput = temp2; |
| 11719 | return lastOutput; |
| 11720 | } |
| 11721 | |
| 11722 | |
| 11723 | /***************************************************/ |
| 11724 | /*! \class ModalBar |
| 11725 | \brief STK resonant bar instrument class. |
| 11726 | |
| 11727 | This class implements a number of different |
| 11728 | struck bar instruments. It inherits from the |
| 11729 | Modal class. |
| 11730 | |
| 11731 | Control Change Numbers: |
| 11732 | - Stick Hardness = 2 |
| 11733 | - Stick Position = 4 |
| 11734 | - Vibrato Gain = 11 |
| 11735 | - Vibrato Frequency = 7 |
| 11736 | - Direct Stick Mix = 1 |
| 11737 | - Volume = 128 |
| 11738 | - Modal Presets = 16 |
| 11739 | - Marimba = 0 |
| 11740 | - Vibraphone = 1 |
| 11741 | - Agogo = 2 |
| 11742 | - Wood1 = 3 |
| 11743 | - Reso = 4 |
| 11744 | - Wood2 = 5 |
| 11745 | - Beats = 6 |
| 11746 | - Two Fixed = 7 |
| 11747 | - Clump = 8 |
| 11748 | |
| 11749 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 11750 | */ |
| 11751 | /***************************************************/ |
| 11752 | |
| 11753 | #include <math.h> |
| 11754 | |
| 11755 | ModalBar :: ModalBar() |
| 11756 | : Modal() |
| 11757 | { |
| 11758 | // Concatenate the STK rawwave path to the rawwave file |
| 11759 | wave = new WvIn( "special:marmstk1", TRUE ); |
| 11760 | wave->setRate((MY_FLOAT) 0.5 * 22050.0 / Stk::sampleRate() ); |
| 11761 | |
| 11762 | // Set the resonances for preset 0 (marimba). |
| 11763 | setPreset( 0 ); |
| 11764 | |
| 11765 | // chuck |
| 11766 | m_frequency = baseFrequency; |
| 11767 | //reverse: same as before |
| 11768 | m_vibratoGain = vibratoGain / 0.3; |
| 11769 | //reverse: same as before |
| 11770 | m_vibratoFreq = vibrato->m_freq / 12.0; |
| 11771 | m_volume = 1.0; |
| 11772 | |
| 11773 | } |
| 11774 | |
| 11775 | ModalBar :: ~ModalBar() |
| 11776 | { |
| 11777 | delete wave; |
| 11778 | } |
| 11779 | |
| 11780 | void ModalBar :: setStickHardness(MY_FLOAT hardness) |
| 11781 | { |
| 11782 | stickHardness = hardness; |
| 11783 | if ( hardness < 0.0 ) { |
| 11784 | CK_STDCERR << "[chuck](via STK): ModalBar: setStickHardness parameter is less than zero!" << CK_STDENDL; |
| 11785 | stickHardness = 0.0; |
| 11786 | } |
| 11787 | else if ( hardness > 1.0 ) { |
| 11788 | CK_STDCERR << "[chuck](via STK): ModalBar: setStickHarness parameter is greater than 1.0!" << CK_STDENDL; |
| 11789 | stickHardness = 1.0; |
| 11790 | } |
| 11791 | |
| 11792 | wave->setRate( (0.25 * (MY_FLOAT)pow(4.0, stickHardness)) ); |
| 11793 | masterGain = 0.1 + (1.8 * stickHardness); |
| 11794 | } |
| 11795 | |
| 11796 | void ModalBar :: setStrikePosition(MY_FLOAT position) |
| 11797 | { |
| 11798 | strikePosition = position; |
| 11799 | if ( position < 0.0 ) { |
| 11800 | CK_STDCERR << "[chuck](via STK): ModalBar: setStrikePositions parameter is less than zero!" << CK_STDENDL; |
| 11801 | strikePosition = 0.0; |
| 11802 | } |
| 11803 | else if ( position > 1.0 ) { |
| 11804 | CK_STDCERR << "[chuck](via STK): ModalBar: setStrikePosition parameter is greater than 1.0!" << CK_STDENDL; |
| 11805 | strikePosition = 1.0; |
| 11806 | } |
| 11807 | |
| 11808 | // Hack only first three modes. |
| 11809 | MY_FLOAT temp2 = position * CK_ONE_PI; |
| 11810 | MY_FLOAT temp = sin(temp2); |
| 11811 | this->setModeGain(0, 0.12 * temp); |
| 11812 | |
| 11813 | temp = sin(0.05 + (3.9 * temp2)); |
| 11814 | this->setModeGain(1, (MY_FLOAT)-0.03 * temp); |
| 11815 | |
| 11816 | temp = (MY_FLOAT)sin(-0.05 + (11 * temp2)); |
| 11817 | this->setModeGain(2,(MY_FLOAT) 0.11 * temp); |
| 11818 | } |
| 11819 | |
| 11820 | void ModalBar :: setPreset(int preset) |
| 11821 | { |
| 11822 | // Presets: |
| 11823 | // First line: relative modal frequencies (negative number is |
| 11824 | // a fixed mode that doesn't scale with frequency |
| 11825 | // Second line: resonances of the modes |
| 11826 | // Third line: mode volumes |
| 11827 | // Fourth line: stickHardness, strikePosition, and direct stick |
| 11828 | // gain (mixed directly into the output |
| 11829 | static MY_FLOAT presets[9][4][4] = { |
| 11830 | {{1.0, 3.99, 10.65, -2443}, // Marimba |
| 11831 | {0.9996, 0.9994, 0.9994, 0.999}, |
| 11832 | {0.04, 0.01, 0.01, 0.008}, |
| 11833 | {0.429688, 0.445312, 0.093750}}, |
| 11834 | {{1.0, 2.01, 3.9, 14.37}, // Vibraphone |
| 11835 | {0.99995, 0.99991, 0.99992, 0.9999}, |
| 11836 | {0.025, 0.015, 0.015, 0.015 }, |
| 11837 | {0.390625,0.570312,0.078125}}, |
| 11838 | {{1.0, 4.08, 6.669, -3725.0}, // Agogo |
| 11839 | {0.999, 0.999, 0.999, 0.999}, |
| 11840 | {0.06, 0.05, 0.03, 0.02}, |
| 11841 | {0.609375,0.359375,0.140625}}, |
| 11842 | {{1.0, 2.777, 7.378, 15.377}, // Wood1 |
| 11843 | {0.996, 0.994, 0.994, 0.99}, |
| 11844 | {0.04, 0.01, 0.01, 0.008}, |
| 11845 | {0.460938,0.375000,0.046875}}, |
| 11846 | {{1.0, 2.777, 7.378, 15.377}, // Reso |
| 11847 | {0.99996, 0.99994, 0.99994, 0.9999}, |
| 11848 | {0.02, 0.005, 0.005, 0.004}, |
| 11849 | {0.453125,0.250000,0.101562}}, |
| 11850 | {{1.0, 1.777, 2.378, 3.377}, // Wood2 |
| 11851 | {0.996, 0.994, 0.994, 0.99}, |
| 11852 | {0.04, 0.01, 0.01, 0.008}, |
| 11853 | {0.312500,0.445312,0.109375}}, |
| 11854 | {{1.0, 1.004, 1.013, 2.377}, // Beats |
| 11855 | {0.9999, 0.9999, 0.9999, 0.999}, |
| 11856 | {0.02, 0.005, 0.005, 0.004}, |
| 11857 | {0.398438,0.296875,0.070312}}, |
| 11858 | {{1.0, 4.0, -1320.0, -3960.0}, // 2Fix |
| 11859 | {0.9996, 0.999, 0.9994, 0.999}, |
| 11860 | {0.04, 0.01, 0.01, 0.008}, |
| 11861 | {0.453125,0.453125,0.070312}}, |
| 11862 | {{1.0, 1.217, 1.475, 1.729}, // Clump |
| 11863 | {0.999, 0.999, 0.999, 0.999}, |
| 11864 | {0.03, 0.03, 0.03, 0.03 }, |
| 11865 | {0.390625,0.570312,0.078125}}, |
| 11866 | }; |
| 11867 | |
| 11868 | int temp = (preset % 9); |
| 11869 | for (int i=0; i<nModes; i++) { |
| 11870 | this->setRatioAndRadius(i, presets[temp][0][i], presets[temp][1][i]); |
| 11871 | this->setModeGain(i, presets[temp][2][i]); |
| 11872 | } |
| 11873 | |
| 11874 | this->setStickHardness(presets[temp][3][0]); |
| 11875 | this->setStrikePosition(presets[temp][3][1]); |
| 11876 | directGain = presets[temp][3][2]; |
| 11877 | |
| 11878 | if (temp == 1) // vibraphone |
| 11879 | vibratoGain = 0.2; |
| 11880 | else |
| 11881 | vibratoGain = 0.0; |
| 11882 | } |
| 11883 | |
| 11884 | void ModalBar :: controlChange(int number, MY_FLOAT value) |
| 11885 | { |
| 11886 | MY_FLOAT norm = value * ONE_OVER_128; |
| 11887 | if ( norm < 0 ) { |
| 11888 | norm = 0.0; |
| 11889 | CK_STDCERR << "[chuck](via STK): ModalBar: Control value less than zero!" << CK_STDENDL; |
| 11890 | } |
| 11891 | else if ( norm > 1.0 ) { |
| 11892 | norm = 1.0; |
| 11893 | CK_STDCERR << "[chuck](via STK): ModalBar: Control value exceeds nominal range!" << CK_STDENDL; |
| 11894 | } |
| 11895 | |
| 11896 | if (number == __SK_StickHardness_) // 2 |
| 11897 | this->setStickHardness( norm ); |
| 11898 | else if (number == __SK_StrikePosition_) // 4 |
| 11899 | this->setStrikePosition( norm ); |
| 11900 | else if (number == __SK_ProphesyRibbon_) // 16 |
| 11901 | this->setPreset((int) value); |
| 11902 | else if (number == __SK_ModWheel_) // 1 |
| 11903 | directGain = norm; |
| 11904 | else if (number == 11) { // 11 |
| 11905 | vibratoGain = norm * 0.3; |
| 11906 | m_vibratoGain = norm; |
| 11907 | } |
| 11908 | else if (number == 7) { // 7 |
| 11909 | vibrato->setFrequency( norm * 12.0 ); |
| 11910 | m_vibratoFreq = vibrato->m_freq; |
| 11911 | } |
| 11912 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 11913 | envelope->setTarget( norm ); |
| 11914 | m_volume = norm; |
| 11915 | } else |
| 11916 | CK_STDCERR << "[chuck](via STK): ModalBar: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 11917 | |
| 11918 | #if defined(_STK_DEBUG_) |
| 11919 | CK_STDCERR << "[chuck](via STK): ModalBar: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 11920 | #endif |
| 11921 | } |
| 11922 | |
| 11923 | /***************************************************/ |
| 11924 | /*! \class Modulate |
| 11925 | \brief STK periodic/random modulator. |
| 11926 | |
| 11927 | This class combines random and periodic |
| 11928 | modulations to give a nice, natural human |
| 11929 | modulation function. |
| 11930 | |
| 11931 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 11932 | */ |
| 11933 | /***************************************************/ |
| 11934 | |
| 11935 | |
| 11936 | Modulate :: Modulate() |
| 11937 | { |
| 11938 | // Concatenate the STK rawwave path to the rawwave file |
| 11939 | vibrato = new WaveLoop( "special:sinewave", TRUE ); |
| 11940 | vibrato->setFrequency( 6.0 ); |
| 11941 | vibratoGain = 0.04; |
| 11942 | |
| 11943 | noise = new SubNoise(330); |
| 11944 | randomGain = 0.05; |
| 11945 | |
| 11946 | filter = new OnePole( 0.999 ); |
| 11947 | filter->setGain( randomGain ); |
| 11948 | |
| 11949 | // initialize | 1.5.0.4 (ge) added |
| 11950 | lastOutput = 0; |
| 11951 | } |
| 11952 | |
| 11953 | Modulate :: ~Modulate() |
| 11954 | { |
| 11955 | delete vibrato; |
| 11956 | delete noise; |
| 11957 | delete filter; |
| 11958 | } |
| 11959 | |
| 11960 | void Modulate :: reset() |
| 11961 | { |
| 11962 | lastOutput = (MY_FLOAT)0.0; |
| 11963 | } |
| 11964 | |
| 11965 | void Modulate :: setVibratoRate(MY_FLOAT aRate) |
| 11966 | { |
| 11967 | vibrato->setFrequency( aRate ); |
| 11968 | } |
| 11969 | |
| 11970 | void Modulate :: setVibratoGain(MY_FLOAT aGain) |
| 11971 | { |
| 11972 | vibratoGain = aGain; |
| 11973 | } |
| 11974 | |
| 11975 | void Modulate :: setRandomGain(MY_FLOAT aGain) |
| 11976 | { |
| 11977 | randomGain = aGain; |
| 11978 | filter->setGain( randomGain ); |
| 11979 | } |
| 11980 | |
| 11981 | MY_FLOAT Modulate :: tick() |
| 11982 | { |
| 11983 | // Compute periodic and random modulations. |
| 11984 | lastOutput = vibratoGain * vibrato->tick(); |
| 11985 | lastOutput += filter->tick( noise->tick() ); |
| 11986 | return lastOutput; |
| 11987 | } |
| 11988 | |
| 11989 | MY_FLOAT *Modulate :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 11990 | { |
| 11991 | for (unsigned int i=0; i<vectorSize; i++) |
| 11992 | vec[i] = tick(); |
| 11993 | |
| 11994 | return vec; |
| 11995 | } |
| 11996 | |
| 11997 | MY_FLOAT Modulate :: lastOut() const |
| 11998 | { |
| 11999 | return lastOutput; |
| 12000 | } |
| 12001 | |
| 12002 | |
| 12003 | /***************************************************/ |
| 12004 | /*! \class Moog |
| 12005 | \brief STK moog-like swept filter sampling synthesis class. |
| 12006 | |
| 12007 | This instrument uses one attack wave, one |
| 12008 | looped wave, and an ADSR envelope (inherited |
| 12009 | from the Sampler class) and adds two sweepable |
| 12010 | formant (FormSwep) filters. |
| 12011 | |
| 12012 | Control Change Numbers: |
| 12013 | - Filter Q = 2 |
| 12014 | - Filter Sweep Rate = 4 |
| 12015 | - Vibrato Frequency = 11 |
| 12016 | - Vibrato Gain = 1 |
| 12017 | - Gain = 128 |
| 12018 | |
| 12019 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 12020 | */ |
| 12021 | /***************************************************/ |
| 12022 | |
| 12023 | |
| 12024 | Moog :: Moog() |
| 12025 | { |
| 12026 | // Concatenate the STK rawwave path to the rawwave file |
| 12027 | attacks[0] = new WvIn( "special:mandpluk", TRUE ); |
| 12028 | loops[0] = new WaveLoop( "special:impuls20", TRUE ); |
| 12029 | loops[1] = new WaveLoop( "special:sinewave", TRUE ); // vibrato |
| 12030 | loops[1]->setFrequency((MY_FLOAT) 6.122); |
| 12031 | |
| 12032 | filters[0] = new FormSwep(); |
| 12033 | filters[0]->setTargets( 0.0, 0.7 ); |
| 12034 | |
| 12035 | filters[1] = new FormSwep(); |
| 12036 | filters[1]->setTargets( 0.0, 0.7 ); |
| 12037 | |
| 12038 | adsr->setAllTimes((MY_FLOAT) 0.001,(MY_FLOAT) 1.5,(MY_FLOAT) 0.6,(MY_FLOAT) 0.250); |
| 12039 | filterQ = (MY_FLOAT) 0.85; |
| 12040 | filterRate = (MY_FLOAT) 0.0001; |
| 12041 | filterStartFreq = (MY_FLOAT) 2000.0; // 1.5.2.5 (prc) updated to 2000.0; was 0.0; |
| 12042 | modDepth = (MY_FLOAT) 0.0; |
| 12043 | |
| 12044 | // chuck |
| 12045 | //reverse: loops[1]->setFrequency(mSpeed); |
| 12046 | m_vibratoFreq = loops[1]->m_freq; |
| 12047 | //reverse: modDepth = mDepth * (MY_FLOAT) 0.5; |
| 12048 | m_vibratoGain = modDepth / 0.5; |
| 12049 | //reverse: nothing |
| 12050 | m_volume = 1.0; |
| 12051 | } |
| 12052 | |
| 12053 | Moog :: ~Moog() |
| 12054 | { |
| 12055 | delete attacks[0]; |
| 12056 | delete loops[0]; |
| 12057 | delete loops[1]; |
| 12058 | delete filters[0]; |
| 12059 | delete filters[1]; |
| 12060 | } |
| 12061 | |
| 12062 | void Moog :: setFrequency(MY_FLOAT frequency) |
| 12063 | { |
| 12064 | baseFrequency = frequency; |
| 12065 | if ( frequency <= 0.0 ) { |
| 12066 | CK_STDCERR << "[chuck](via STK): Moog: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 12067 | baseFrequency = 220.0; |
| 12068 | } |
| 12069 | |
| 12070 | MY_FLOAT rate = attacks[0]->getSize() * 0.01 * baseFrequency / sampleRate(); |
| 12071 | attacks[0]->setRate( rate ); |
| 12072 | loops[0]->setFrequency(baseFrequency); |
| 12073 | |
| 12074 | // chuck |
| 12075 | m_frequency = baseFrequency; |
| 12076 | } |
| 12077 | |
| 12078 | //CHUCK wrapper |
| 12079 | void Moog :: noteOn(MY_FLOAT amplitude ) { |
| 12080 | noteOn ( baseFrequency, amplitude ); |
| 12081 | } |
| 12082 | |
| 12083 | void Moog :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 12084 | { |
| 12085 | MY_FLOAT temp; |
| 12086 | |
| 12087 | this->setFrequency( frequency ); |
| 12088 | this->keyOn(); |
| 12089 | attackGain = amplitude * (MY_FLOAT) 0.5; |
| 12090 | loopGain = amplitude; |
| 12091 | |
| 12092 | temp = filterQ + (MY_FLOAT) 0.05; |
| 12093 | // 1.4.1.0 (prc) updated; was 2000.0, temp ); |
| 12094 | filters[0]->setStates( filterStartFreq, temp ); |
| 12095 | // 1.4.1.0 (prc) updated; was 2000.0, temp ); |
| 12096 | filters[1]->setStates( filterStartFreq, temp ); |
| 12097 | |
| 12098 | temp = filterQ + (MY_FLOAT) 0.099; |
| 12099 | filters[0]->setTargets( frequency, temp ); |
| 12100 | filters[1]->setTargets( frequency, temp ); |
| 12101 | |
| 12102 | filters[0]->setSweepRate( filterRate * 22050.0 / Stk::sampleRate() ); |
| 12103 | filters[1]->setSweepRate( filterRate * 22050.0 / Stk::sampleRate() ); |
| 12104 | |
| 12105 | // 1.4.1.0 |
| 12106 | // printf("FilterRate: %f\n",filterRate); |
| 12107 | |
| 12108 | #if defined(_STK_DEBUG_) |
| 12109 | CK_STDCERR << "[chuck](via STK): Moog: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 12110 | #endif |
| 12111 | } |
| 12112 | |
| 12113 | void Moog :: setModulationSpeed(MY_FLOAT mSpeed) |
| 12114 | { |
| 12115 | loops[1]->setFrequency(mSpeed); |
| 12116 | m_vibratoFreq = loops[1]->m_freq; |
| 12117 | } |
| 12118 | |
| 12119 | void Moog :: setModulationDepth(MY_FLOAT mDepth) |
| 12120 | { |
| 12121 | modDepth = mDepth * (MY_FLOAT) 0.5; |
| 12122 | m_vibratoGain = mDepth; |
| 12123 | } |
| 12124 | |
| 12125 | MY_FLOAT Moog :: tick() |
| 12126 | { |
| 12127 | MY_FLOAT temp; |
| 12128 | |
| 12129 | if ( modDepth != 0.0 ) { |
| 12130 | temp = loops[1]->tick() * modDepth; |
| 12131 | loops[0]->setFrequency( baseFrequency * (1.0 + temp) ); |
| 12132 | } |
| 12133 | |
| 12134 | temp = Sampler::tick(); |
| 12135 | temp = filters[0]->tick( temp ); |
| 12136 | lastOutput = filters[1]->tick( temp ); |
| 12137 | return lastOutput * 3.0; |
| 12138 | } |
| 12139 | |
| 12140 | void Moog :: controlChange(int number, MY_FLOAT value) |
| 12141 | { |
| 12142 | MY_FLOAT norm = value * ONE_OVER_128; |
| 12143 | if ( norm < 0 ) { |
| 12144 | norm = 0.0; |
| 12145 | CK_STDCERR << "[chuck](via STK): Moog: Control value less than zero!" << CK_STDENDL; |
| 12146 | } |
| 12147 | else if ( norm > 1.0 ) { |
| 12148 | norm = 1.0; |
| 12149 | CK_STDCERR << "[chuck](via STK): Moog: Control value exceeds nominal range!" << CK_STDENDL; |
| 12150 | } |
| 12151 | |
| 12152 | if (number == __SK_FilterQ_) // 2 |
| 12153 | filterQ = 0.80 + ( 0.1 * norm ); |
| 12154 | else if (number == __SK_FilterSweepRate_) // 4 |
| 12155 | filterRate = norm * 0.0002; // 1.5.2.5 (prc) was .002 // 1.4.1.0 (prc) was .0002 |
| 12156 | else if (number == __SK_ModFrequency_) { // 11 |
| 12157 | this->setModulationSpeed( norm * 12.0 ); |
| 12158 | } |
| 12159 | else if (number == __SK_ModWheel_) { // 1 |
| 12160 | this->setModulationDepth( norm ); |
| 12161 | } |
| 12162 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 12163 | adsr->setTarget( norm ); |
| 12164 | m_volume = norm; |
| 12165 | } |
| 12166 | else |
| 12167 | CK_STDCERR << "[chuck](via STK): Moog: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 12168 | |
| 12169 | #if defined(_STK_DEBUG_) |
| 12170 | CK_STDCERR << "[chuck](via STK): Moog: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 12171 | #endif |
| 12172 | } |
| 12173 | |
| 12174 | |
| 12175 | |
| 12176 | /***************************************************/ |
| 12177 | /*! \class NRev |
| 12178 | \brief CCRMA's NRev reverberator class. |
| 12179 | |
| 12180 | This class is derived from the CLM NRev |
| 12181 | function, which is based on the use of |
| 12182 | networks of simple allpass and comb delay |
| 12183 | filters. This particular arrangement consists |
| 12184 | of 6 comb filters in parallel, followed by 3 |
| 12185 | allpass filters, a lowpass filter, and another |
| 12186 | allpass in series, followed by two allpass |
| 12187 | filters in parallel with corresponding right |
| 12188 | and left outputs. |
| 12189 | |
| 12190 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 12191 | */ |
| 12192 | /***************************************************/ |
| 12193 | |
| 12194 | #include <math.h> |
| 12195 | |
| 12196 | NRev :: NRev(MY_FLOAT T60) |
| 12197 | { |
| 12198 | int lengths[15] = {1433, 1601, 1867, 2053, 2251, 2399, 347, 113, 37, 59, 53, 43, 37, 29, 19}; |
| 12199 | double scaler = Stk::sampleRate() / 25641.0; |
| 12200 | |
| 12201 | int delay, i; |
| 12202 | for (i=0; i<15; i++) { |
| 12203 | delay = (int) floor(scaler * lengths[i]); |
| 12204 | if ( (delay & 1) == 0) delay++; |
| 12205 | while ( !this->isPrime(delay) ) delay += 2; |
| 12206 | lengths[i] = delay; |
| 12207 | } |
| 12208 | |
| 12209 | for (i=0; i<6; i++) { |
| 12210 | combDelays[i] = new DelayBase( lengths[i], lengths[i]); |
| 12211 | combCoefficient[i] = pow(10.0, (-3 * lengths[i] / (T60 * Stk::sampleRate()))); |
| 12212 | } |
| 12213 | |
| 12214 | for (i=0; i<8; i++) |
| 12215 | allpassDelays[i] = new DelayBase(lengths[i+6], lengths[i+6]); |
| 12216 | |
| 12217 | allpassCoefficient = 0.7; |
| 12218 | effectMix = 0.3; |
| 12219 | this->clear(); |
| 12220 | } |
| 12221 | |
| 12222 | NRev :: ~NRev() |
| 12223 | { |
| 12224 | int i; |
| 12225 | for (i=0; i<6; i++) delete combDelays[i]; |
| 12226 | for (i=0; i<8; i++) delete allpassDelays[i]; |
| 12227 | } |
| 12228 | |
| 12229 | void NRev :: clear() |
| 12230 | { |
| 12231 | int i; |
| 12232 | for (i=0; i<6; i++) combDelays[i]->clear(); |
| 12233 | for (i=0; i<8; i++) allpassDelays[i]->clear(); |
| 12234 | lastOutput[0] = 0.0; |
| 12235 | lastOutput[1] = 0.0; |
| 12236 | lowpassState = 0.0; |
| 12237 | } |
| 12238 | |
| 12239 | MY_FLOAT NRev :: tick(MY_FLOAT input) |
| 12240 | { |
| 12241 | MY_FLOAT temp, temp0, temp1, temp2, temp3; |
| 12242 | int i; |
| 12243 | |
| 12244 | // gewang: dedenormal |
| 12245 | CK_STK_DDN(input); |
| 12246 | |
| 12247 | temp0 = 0.0; |
| 12248 | for (i=0; i<6; i++) { |
| 12249 | temp = input + (combCoefficient[i] * combDelays[i]->lastOut()); |
| 12250 | // gewang: dedenormal |
| 12251 | CK_STK_DDN(temp); |
| 12252 | temp0 += combDelays[i]->tick(temp); |
| 12253 | } |
| 12254 | |
| 12255 | for (i=0; i<3; i++) { |
| 12256 | temp = allpassDelays[i]->lastOut(); |
| 12257 | temp1 = allpassCoefficient * temp; |
| 12258 | temp1 += temp0; |
| 12259 | // gewang: dedenormal |
| 12260 | CK_STK_DDN(temp1); |
| 12261 | allpassDelays[i]->tick(temp1); |
| 12262 | temp0 = -(allpassCoefficient * temp1) + temp; |
| 12263 | } |
| 12264 | |
| 12265 | // One-pole lowpass filter. |
| 12266 | lowpassState = 0.7*lowpassState + 0.3*temp0; |
| 12267 | // gewang: dedenormal |
| 12268 | CK_STK_DDN(lowpassState); |
| 12269 | temp = allpassDelays[3]->lastOut(); |
| 12270 | temp1 = allpassCoefficient * temp; |
| 12271 | temp1 += lowpassState; |
| 12272 | // gewang: dedenormal |
| 12273 | CK_STK_DDN(temp1); |
| 12274 | allpassDelays[3]->tick(temp1); |
| 12275 | temp1 = -(allpassCoefficient * temp1) + temp; |
| 12276 | |
| 12277 | temp = allpassDelays[4]->lastOut(); |
| 12278 | temp2 = allpassCoefficient * temp; |
| 12279 | temp2 += temp1; |
| 12280 | // gewang: dedenormal |
| 12281 | CK_STK_DDN(temp2); |
| 12282 | allpassDelays[4]->tick(temp2); |
| 12283 | lastOutput[0] = effectMix*(-(allpassCoefficient * temp2) + temp); |
| 12284 | |
| 12285 | temp = allpassDelays[5]->lastOut(); |
| 12286 | temp3 = allpassCoefficient * temp; |
| 12287 | temp3 += temp1; |
| 12288 | // gewang: dedenormal |
| 12289 | CK_STK_DDN(temp3); |
| 12290 | allpassDelays[5]->tick(temp3); |
| 12291 | lastOutput[1] = effectMix*(-(allpassCoefficient * temp3) + temp); |
| 12292 | |
| 12293 | temp = (1.0 - effectMix) * input; |
| 12294 | lastOutput[0] += temp; |
| 12295 | lastOutput[1] += temp; |
| 12296 | |
| 12297 | return (lastOutput[0] + lastOutput[1]) * 0.5; |
| 12298 | } |
| 12299 | |
| 12300 | |
| 12301 | /***************************************************/ |
| 12302 | /*! \class Noise |
| 12303 | \brief STK noise generator. |
| 12304 | |
| 12305 | Generic random number generation using the |
| 12306 | C rand() function. The quality of the rand() |
| 12307 | function varies from one OS to another. |
| 12308 | |
| 12309 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 12310 | */ |
| 12311 | /***************************************************/ |
| 12312 | |
| 12313 | #include <stdlib.h> |
| 12314 | #include <time.h> |
| 12315 | |
| 12316 | Noise :: Noise() : Stk() |
| 12317 | { |
| 12318 | // Seed the random number generator with system time. |
| 12319 | // this->setSeed( time(NULL) ); // 1.5.0.1 (ge) changed from 0 to time(NULL) |
| 12320 | lastOutput = (MY_FLOAT) 0.0; |
| 12321 | } |
| 12322 | |
| 12323 | Noise :: Noise( unsigned int seed ) : Stk() |
| 12324 | { |
| 12325 | // Seed the random number generator |
| 12326 | this->setSeed( seed ); |
| 12327 | lastOutput = (MY_FLOAT) 0.0; |
| 12328 | } |
| 12329 | |
| 12330 | Noise :: ~Noise() |
| 12331 | { |
| 12332 | } |
| 12333 | |
| 12334 | void Noise :: setSeed( unsigned int seed ) |
| 12335 | { |
| 12336 | if ( seed == 0 ) |
| 12337 | srand( (unsigned int) time(NULL) ); |
| 12338 | else |
| 12339 | srand( seed ); |
| 12340 | } |
| 12341 | |
| 12342 | MY_FLOAT Noise :: tick() |
| 12343 | { |
| 12344 | lastOutput = (MY_FLOAT) (2.0 * rand() / (RAND_MAX + 1.0) ); |
| 12345 | lastOutput -= 1.0; |
| 12346 | return lastOutput; |
| 12347 | } |
| 12348 | |
| 12349 | MY_FLOAT *Noise :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 12350 | { |
| 12351 | for (unsigned int i=0; i<vectorSize; i++) |
| 12352 | vec[i] = tick(); |
| 12353 | |
| 12354 | return vec; |
| 12355 | } |
| 12356 | |
| 12357 | MY_FLOAT Noise :: lastOut() const |
| 12358 | { |
| 12359 | return lastOutput; |
| 12360 | } |
| 12361 | |
| 12362 | /***************************************************/ |
| 12363 | /*! \class OnePole |
| 12364 | \brief STK one-pole filter class. |
| 12365 | |
| 12366 | This protected Filter subclass implements |
| 12367 | a one-pole digital filter. A method is |
| 12368 | provided for setting the pole position along |
| 12369 | the real axis of the z-plane while maintaining |
| 12370 | a constant peak filter gain. |
| 12371 | |
| 12372 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 12373 | */ |
| 12374 | /***************************************************/ |
| 12375 | |
| 12376 | |
| 12377 | OnePole :: OnePole() : FilterStk() |
| 12378 | { |
| 12379 | MY_FLOAT B = 0.1; |
| 12380 | MY_FLOAT A[2] = {1.0, -0.9}; |
| 12381 | FilterStk::setCoefficients( 1, &B, 2, A ); |
| 12382 | } |
| 12383 | |
| 12384 | OnePole :: OnePole(MY_FLOAT thePole) : FilterStk() |
| 12385 | { |
| 12386 | MY_FLOAT B; |
| 12387 | MY_FLOAT A[2] = {1.0, -0.9}; |
| 12388 | |
| 12389 | // Normalize coefficients for peak unity gain. |
| 12390 | if (thePole > 0.0) |
| 12391 | B = (MY_FLOAT) (1.0 - thePole); |
| 12392 | else |
| 12393 | B = (MY_FLOAT) (1.0 + thePole); |
| 12394 | |
| 12395 | A[1] = -thePole; |
| 12396 | FilterStk::setCoefficients( 1, &B, 2, A ); |
| 12397 | } |
| 12398 | |
| 12399 | OnePole :: ~OnePole() |
| 12400 | { |
| 12401 | } |
| 12402 | |
| 12403 | void OnePole :: clear(void) |
| 12404 | { |
| 12405 | FilterStk::clear(); |
| 12406 | } |
| 12407 | |
| 12408 | void OnePole :: setB0(MY_FLOAT b0) |
| 12409 | { |
| 12410 | b[0] = b0; |
| 12411 | } |
| 12412 | |
| 12413 | void OnePole :: setA1(MY_FLOAT a1) |
| 12414 | { |
| 12415 | a[1] = a1; |
| 12416 | } |
| 12417 | |
| 12418 | void OnePole :: setPole(MY_FLOAT thePole) |
| 12419 | { |
| 12420 | // Normalize coefficients for peak unity gain. |
| 12421 | if (thePole > 0.0) |
| 12422 | b[0] = (MY_FLOAT) (1.0 - thePole); |
| 12423 | else |
| 12424 | b[0] = (MY_FLOAT) (1.0 + thePole); |
| 12425 | |
| 12426 | a[1] = -thePole; |
| 12427 | } |
| 12428 | |
| 12429 | void OnePole :: setGain(MY_FLOAT theGain) |
| 12430 | { |
| 12431 | FilterStk::setGain(theGain); |
| 12432 | } |
| 12433 | |
| 12434 | MY_FLOAT OnePole :: getGain(void) const |
| 12435 | { |
| 12436 | return FilterStk::getGain(); |
| 12437 | } |
| 12438 | |
| 12439 | MY_FLOAT OnePole :: lastOut(void) const |
| 12440 | { |
| 12441 | return FilterStk::lastOut(); |
| 12442 | } |
| 12443 | |
| 12444 | MY_FLOAT OnePole :: tick(MY_FLOAT sample) |
| 12445 | { |
| 12446 | inputs[0] = gain * sample; |
| 12447 | outputs[0] = b[0] * inputs[0] - a[1] * outputs[1]; |
| 12448 | outputs[1] = outputs[0]; |
| 12449 | |
| 12450 | // gewang: dedenormal |
| 12451 | CK_STK_DDN(outputs[1]); |
| 12452 | |
| 12453 | return outputs[0]; |
| 12454 | } |
| 12455 | |
| 12456 | MY_FLOAT *OnePole :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 12457 | { |
| 12458 | for (unsigned int i=0; i<vectorSize; i++) |
| 12459 | vec[i] = tick(vec[i]); |
| 12460 | |
| 12461 | return vec; |
| 12462 | } |
| 12463 | /***************************************************/ |
| 12464 | /*! \class OneZero |
| 12465 | \brief STK one-zero filter class. |
| 12466 | |
| 12467 | This protected Filter subclass implements |
| 12468 | a one-zero digital filter. A method is |
| 12469 | provided for setting the zero position |
| 12470 | along the real axis of the z-plane while |
| 12471 | maintaining a constant filter gain. |
| 12472 | |
| 12473 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 12474 | */ |
| 12475 | /***************************************************/ |
| 12476 | |
| 12477 | |
| 12478 | OneZero :: OneZero() : FilterStk() |
| 12479 | { |
| 12480 | MY_FLOAT B[2] = {0.5, 0.5}; |
| 12481 | MY_FLOAT A = 1.0; |
| 12482 | FilterStk::setCoefficients( 2, B, 1, &A ); |
| 12483 | } |
| 12484 | |
| 12485 | OneZero :: OneZero(MY_FLOAT theZero) : FilterStk() |
| 12486 | { |
| 12487 | MY_FLOAT B[2]; |
| 12488 | MY_FLOAT A = 1.0; |
| 12489 | |
| 12490 | // Normalize coefficients for unity gain. |
| 12491 | if (theZero > 0.0) |
| 12492 | B[0] = 1.0 / ((MY_FLOAT) 1.0 + theZero); |
| 12493 | else |
| 12494 | B[0] = 1.0 / ((MY_FLOAT) 1.0 - theZero); |
| 12495 | |
| 12496 | B[1] = -theZero * B[0]; |
| 12497 | FilterStk::setCoefficients( 2, B, 1, &A ); |
| 12498 | } |
| 12499 | |
| 12500 | OneZero :: ~OneZero(void) |
| 12501 | { |
| 12502 | } |
| 12503 | |
| 12504 | void OneZero :: clear(void) |
| 12505 | { |
| 12506 | FilterStk::clear(); |
| 12507 | } |
| 12508 | |
| 12509 | void OneZero :: setB0(MY_FLOAT b0) |
| 12510 | { |
| 12511 | b[0] = b0; |
| 12512 | } |
| 12513 | |
| 12514 | void OneZero :: setB1(MY_FLOAT b1) |
| 12515 | { |
| 12516 | b[1] = b1; |
| 12517 | } |
| 12518 | |
| 12519 | void OneZero :: setZero(MY_FLOAT theZero) |
| 12520 | { |
| 12521 | // Normalize coefficients for unity gain. |
| 12522 | if (theZero > 0.0) |
| 12523 | b[0] = 1.0 / ((MY_FLOAT) 1.0 + theZero); |
| 12524 | else |
| 12525 | b[0] = 1.0 / ((MY_FLOAT) 1.0 - theZero); |
| 12526 | |
| 12527 | b[1] = -theZero * b[0]; |
| 12528 | } |
| 12529 | |
| 12530 | void OneZero :: setGain(MY_FLOAT theGain) |
| 12531 | { |
| 12532 | FilterStk::setGain(theGain); |
| 12533 | } |
| 12534 | |
| 12535 | MY_FLOAT OneZero :: getGain(void) const |
| 12536 | { |
| 12537 | return FilterStk::getGain(); |
| 12538 | } |
| 12539 | |
| 12540 | MY_FLOAT OneZero :: lastOut(void) const |
| 12541 | { |
| 12542 | return FilterStk::lastOut(); |
| 12543 | } |
| 12544 | |
| 12545 | MY_FLOAT OneZero :: tick(MY_FLOAT sample) |
| 12546 | { |
| 12547 | inputs[0] = gain * sample; |
| 12548 | outputs[0] = b[1] * inputs[1] + b[0] * inputs[0]; |
| 12549 | inputs[1] = inputs[0]; |
| 12550 | |
| 12551 | return outputs[0]; |
| 12552 | } |
| 12553 | |
| 12554 | MY_FLOAT *OneZero :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 12555 | { |
| 12556 | for (unsigned int i=0; i<vectorSize; i++) |
| 12557 | vec[i] = tick(vec[i]); |
| 12558 | |
| 12559 | return vec; |
| 12560 | } |
| 12561 | /***************************************************/ |
| 12562 | /*! \class PRCRev |
| 12563 | \brief Perry's simple reverberator class. |
| 12564 | |
| 12565 | This class is based on some of the famous |
| 12566 | Stanford/CCRMA reverbs (NRev, KipRev), which |
| 12567 | were based on the Chowning/Moorer/Schroeder |
| 12568 | reverberators using networks of simple allpass |
| 12569 | and comb delay filters. This class implements |
| 12570 | two series allpass units and two parallel comb |
| 12571 | filters. |
| 12572 | |
| 12573 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 12574 | */ |
| 12575 | /***************************************************/ |
| 12576 | |
| 12577 | #include <math.h> |
| 12578 | |
| 12579 | PRCRev :: PRCRev(MY_FLOAT T60) |
| 12580 | { |
| 12581 | // Delay lengths for 44100 Hz sample rate. |
| 12582 | int lengths[4]= {353, 1097, 1777, 2137}; |
| 12583 | double scaler = Stk::sampleRate() / 44100.0; |
| 12584 | |
| 12585 | // Scale the delay lengths if necessary. |
| 12586 | int delay, i; |
| 12587 | if ( scaler != 1.0 ) { |
| 12588 | for (i=0; i<4; i++) { |
| 12589 | delay = (int) floor(scaler * lengths[i]); |
| 12590 | if ( (delay & 1) == 0) delay++; |
| 12591 | while ( !this->isPrime(delay) ) delay += 2; |
| 12592 | lengths[i] = delay; |
| 12593 | } |
| 12594 | } |
| 12595 | |
| 12596 | for (i=0; i<2; i++) { |
| 12597 | allpassDelays[i] = new DelayBase( lengths[i], lengths[i] ); |
| 12598 | combDelays[i] = new DelayBase( lengths[i+2], lengths[i+2] ); |
| 12599 | combCoefficient[i] = pow(10.0,(-3 * lengths[i+2] / (T60 * Stk::sampleRate()))); |
| 12600 | } |
| 12601 | |
| 12602 | allpassCoefficient = 0.7; |
| 12603 | effectMix = 0.5; |
| 12604 | this->clear(); |
| 12605 | } |
| 12606 | |
| 12607 | PRCRev :: ~PRCRev() |
| 12608 | { |
| 12609 | delete allpassDelays[0]; |
| 12610 | delete allpassDelays[1]; |
| 12611 | delete combDelays[0]; |
| 12612 | delete combDelays[1]; |
| 12613 | } |
| 12614 | |
| 12615 | void PRCRev :: clear() |
| 12616 | { |
| 12617 | allpassDelays[0]->clear(); |
| 12618 | allpassDelays[1]->clear(); |
| 12619 | combDelays[0]->clear(); |
| 12620 | combDelays[1]->clear(); |
| 12621 | lastOutput[0] = 0.0; |
| 12622 | lastOutput[1] = 0.0; |
| 12623 | } |
| 12624 | |
| 12625 | MY_FLOAT PRCRev :: tick(MY_FLOAT input) |
| 12626 | { |
| 12627 | MY_FLOAT temp, temp0, temp1, temp2, temp3; |
| 12628 | |
| 12629 | // gewang: dedenormal |
| 12630 | CK_STK_DDN(input); |
| 12631 | |
| 12632 | temp = allpassDelays[0]->lastOut(); |
| 12633 | temp0 = allpassCoefficient * temp; |
| 12634 | temp0 += input; |
| 12635 | // gewang: dedenormal |
| 12636 | CK_STK_DDN(temp0); |
| 12637 | allpassDelays[0]->tick(temp0); |
| 12638 | temp0 = -(allpassCoefficient * temp0) + temp; |
| 12639 | |
| 12640 | temp = allpassDelays[1]->lastOut(); |
| 12641 | temp1 = allpassCoefficient * temp; |
| 12642 | temp1 += temp0; |
| 12643 | // gewang: dedenormal |
| 12644 | CK_STK_DDN(temp1); |
| 12645 | allpassDelays[1]->tick(temp1); |
| 12646 | temp1 = -(allpassCoefficient * temp1) + temp; |
| 12647 | |
| 12648 | temp2 = temp1 + (combCoefficient[0] * combDelays[0]->lastOut()); |
| 12649 | temp3 = temp1 + (combCoefficient[1] * combDelays[1]->lastOut()); |
| 12650 | |
| 12651 | // gewang: dedenormal |
| 12652 | CK_STK_DDN(temp2); |
| 12653 | CK_STK_DDN(temp3); |
| 12654 | |
| 12655 | lastOutput[0] = effectMix * (combDelays[0]->tick(temp2)); |
| 12656 | lastOutput[1] = effectMix * (combDelays[1]->tick(temp3)); |
| 12657 | temp = (MY_FLOAT) (1.0 - effectMix) * input; |
| 12658 | lastOutput[0] += temp; |
| 12659 | lastOutput[1] += temp; |
| 12660 | |
| 12661 | return (lastOutput[0] + lastOutput[1]) * (MY_FLOAT) 0.5; |
| 12662 | } |
| 12663 | |
| 12664 | |
| 12665 | /***************************************************/ |
| 12666 | /*! \class PercFlut |
| 12667 | \brief STK percussive flute FM synthesis instrument. |
| 12668 | |
| 12669 | This class implements algorithm 4 of the TX81Z. |
| 12670 | |
| 12671 | \code |
| 12672 | Algorithm 4 is : 4->3--\ |
| 12673 | 2-- + -->1-->Out |
| 12674 | \endcode |
| 12675 | |
| 12676 | Control Change Numbers: |
| 12677 | - Total Modulator Index = 2 |
| 12678 | - Modulator Crossfade = 4 |
| 12679 | - LFO Speed = 11 |
| 12680 | - LFO Depth = 1 |
| 12681 | - ADSR 2 & 4 Target = 128 |
| 12682 | |
| 12683 | The basic Chowning/Stanford FM patent expired |
| 12684 | in 1995, but there exist follow-on patents, |
| 12685 | mostly assigned to Yamaha. If you are of the |
| 12686 | type who should worry about this (making |
| 12687 | money) worry away. |
| 12688 | |
| 12689 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 12690 | */ |
| 12691 | /***************************************************/ |
| 12692 | |
| 12693 | |
| 12694 | PercFlut :: PercFlut() |
| 12695 | : FM() |
| 12696 | { |
| 12697 | // Concatenate the STK rawwave path to the rawwave files |
| 12698 | for ( int i=0; i<3; i++ ) |
| 12699 | waves[i] = new WaveLoop( "special:sinewave", TRUE ); |
| 12700 | waves[3] = new WaveLoop( "special:fwavblnk", TRUE ); |
| 12701 | |
| 12702 | this->setRatio(0, 1.50 * 1.000); |
| 12703 | this->setRatio(1, 3.00 * 0.995); |
| 12704 | this->setRatio(2, 2.99 * 1.005); |
| 12705 | this->setRatio(3, 6.00 * 0.997); |
| 12706 | |
| 12707 | gains[0] = __FM_gains[99]; |
| 12708 | gains[1] = __FM_gains[71]; |
| 12709 | gains[2] = __FM_gains[93]; |
| 12710 | gains[3] = __FM_gains[85]; |
| 12711 | |
| 12712 | // 1.4.1.0 (prc) added |
| 12713 | baseGains[0] = gains[0]; |
| 12714 | baseGains[1] = gains[1]; |
| 12715 | baseGains[2] = gains[2]; |
| 12716 | baseGains[3] = gains[3]; |
| 12717 | |
| 12718 | adsr[0]->setAllTimes( 0.05, 0.05, __FM_susLevels[14], 0.05); |
| 12719 | adsr[1]->setAllTimes( 0.02, 0.50, __FM_susLevels[13], 0.5); |
| 12720 | adsr[2]->setAllTimes( 0.02, 0.30, __FM_susLevels[11], 0.05); |
| 12721 | adsr[3]->setAllTimes( 0.02, 0.05, __FM_susLevels[13], 0.01); |
| 12722 | |
| 12723 | twozero->setGain( 0.0 ); |
| 12724 | op4Feedback = 0.0; // 1.4.1.0 (prc) |
| 12725 | modDepth = 0.005; |
| 12726 | } |
| 12727 | |
| 12728 | PercFlut :: ~PercFlut() |
| 12729 | { |
| 12730 | // note: waves array taken care of in FM destructor |
| 12731 | } |
| 12732 | |
| 12733 | void PercFlut :: setFrequency(MY_FLOAT frequency) |
| 12734 | { |
| 12735 | baseFrequency = frequency; |
| 12736 | |
| 12737 | // chuck |
| 12738 | m_frequency = baseFrequency; |
| 12739 | } |
| 12740 | |
| 12741 | void PercFlut :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 12742 | { |
| 12743 | // 1.4.1.0 (prc) commented out |
| 12744 | // gains[0] = amplitude * __FM_gains[99] * 0.5; // OLD WAY OF DOING IT |
| 12745 | // gains[1] = amplitude * __FM_gains[71] * 0.5; // DELETE THESE SOMEDAY |
| 12746 | // gains[2] = amplitude * __FM_gains[93] * 0.5; |
| 12747 | // gains[3] = amplitude * __FM_gains[85] * 0.5; |
| 12748 | |
| 12749 | // 1.4.1.0 (prc) ***** REPAIRATHON2021 ADDITIONS ***** |
| 12750 | gains[0] = amplitude * baseGains[0] * 0.5; |
| 12751 | gains[1] = amplitude * baseGains[1] * 0.5; |
| 12752 | gains[2] = amplitude * baseGains[2] * 0.5; |
| 12753 | gains[3] = amplitude * baseGains[3] * 0.5; |
| 12754 | |
| 12755 | this->setFrequency(frequency); |
| 12756 | this->keyOn(); |
| 12757 | |
| 12758 | #if defined(_STK_DEBUG_) |
| 12759 | CK_STDCERR << "PercFlut: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 12760 | #endif |
| 12761 | } |
| 12762 | |
| 12763 | MY_FLOAT PercFlut :: tick() // 1.4.1.0 (prc) REPAIRATHON2021 updated |
| 12764 | { |
| 12765 | /* register */ MY_FLOAT temp, temp2; |
| 12766 | |
| 12767 | // save for AM later /***** REPAIRATHON2021 ADDITION *****/ |
| 12768 | temp2 = vibrato->tick(); |
| 12769 | |
| 12770 | temp = temp2 * modDepth * 0.2; |
| 12771 | for (int i = 0; i < 4; i++) { |
| 12772 | if (ratios[i] > 0.0) { |
| 12773 | waves[i]->setFrequency(baseFrequency * (1.0 + temp) * ratios[i]); |
| 12774 | } |
| 12775 | } |
| 12776 | |
| 12777 | waves[3]->addPhaseOffset(twozero->lastOut()); |
| 12778 | temp = (1.0 + opAMs[3]*temp2) * gains[3] * adsr[3]->tick() * waves[3]->tick(); // ADD AM |
| 12779 | |
| 12780 | twozero->tick(temp); |
| 12781 | waves[2]->addPhaseOffset(temp); |
| 12782 | temp = (1.0 + opAMs[2]*temp2 - (control2 * 0.5)) * gains[2] * adsr[2]->tick() * waves[2]->tick(); // ADD AM |
| 12783 | |
| 12784 | temp += (1.0 + opAMs[1]*temp2) * control2 * 0.5 * gains[1] * adsr[1]->tick() * waves[1]->tick(); // ADD AM |
| 12785 | temp = temp * control1; |
| 12786 | |
| 12787 | waves[0]->addPhaseOffset(temp); |
| 12788 | temp = (1.0 + opAMs[0]*temp2) * gains[0] * adsr[0]->tick() * waves[0]->tick(); // ADD AM |
| 12789 | |
| 12790 | lastOutput = temp * (MY_FLOAT) 0.5; |
| 12791 | |
| 12792 | return lastOutput; |
| 12793 | } |
| 12794 | |
| 12795 | /***************************************************/ |
| 12796 | /*! \class Phonemes |
| 12797 | \brief STK phonemes table. |
| 12798 | |
| 12799 | This class does nothing other than declare a |
| 12800 | set of 32 static phoneme formant parameters |
| 12801 | and provide access to those values. |
| 12802 | |
| 12803 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 12804 | */ |
| 12805 | /***************************************************/ |
| 12806 | |
| 12807 | #include <iostream> |
| 12808 | |
| 12809 | const char Phonemes :: phonemeNames[32][4] = |
| 12810 | {"eee", "ihh", "ehh", "aaa", |
| 12811 | "ahh", "aww", "ohh", "uhh", |
| 12812 | "uuu", "ooo", "rrr", "lll", |
| 12813 | "mmm", "nnn", "nng", "ngg", |
| 12814 | "fff", "sss", "thh", "shh", |
| 12815 | "xxx", "hee", "hoo", "hah", |
| 12816 | "bbb", "ddd", "jjj", "ggg", |
| 12817 | "vvv", "zzz", "thz", "zhh" |
| 12818 | }; |
| 12819 | |
| 12820 | const MY_FLOAT Phonemes :: phonemeGains[32][2] = |
| 12821 | {{1.0, 0.0}, // eee |
| 12822 | {1.0, 0.0}, // ihh |
| 12823 | {1.0, 0.0}, // ehh |
| 12824 | {1.0, 0.0}, // aaa |
| 12825 | |
| 12826 | {1.0, 0.0}, // ahh |
| 12827 | {1.0, 0.0}, // aww |
| 12828 | {1.0, 0.0}, // ohh |
| 12829 | {1.0, 0.0}, // uhh |
| 12830 | |
| 12831 | {1.0, 0.0}, // uuu |
| 12832 | {1.0, 0.0}, // ooo |
| 12833 | {1.0, 0.0}, // rrr |
| 12834 | {1.0, 0.0}, // lll |
| 12835 | |
| 12836 | {1.0, 0.0}, // mmm |
| 12837 | {1.0, 0.0}, // nnn |
| 12838 | {1.0, 0.0}, // nng |
| 12839 | {1.0, 0.0}, // ngg |
| 12840 | |
| 12841 | {0.0, 0.7}, // fff |
| 12842 | {0.0, 0.7}, // sss |
| 12843 | {0.0, 0.7}, // thh |
| 12844 | {0.0, 0.7}, // shh |
| 12845 | |
| 12846 | {0.0, 0.7}, // xxx |
| 12847 | {0.0, 0.1}, // hee |
| 12848 | {0.0, 0.1}, // hoo |
| 12849 | {0.0, 0.1}, // hah |
| 12850 | |
| 12851 | {1.0, 0.1}, // bbb |
| 12852 | {1.0, 0.1}, // ddd |
| 12853 | {1.0, 0.1}, // jjj |
| 12854 | {1.0, 0.1}, // ggg |
| 12855 | |
| 12856 | {1.0, 1.0}, // vvv |
| 12857 | {1.0, 1.0}, // zzz |
| 12858 | {1.0, 1.0}, // thz |
| 12859 | {1.0, 1.0} // zhh |
| 12860 | }; |
| 12861 | |
| 12862 | const MY_FLOAT Phonemes :: phonemeParameters[32][4][3] = |
| 12863 | {{ { 273, 0.996, 10}, // eee (beet) |
| 12864 | {2086, 0.945, -16}, |
| 12865 | {2754, 0.979, -12}, |
| 12866 | {3270, 0.440, -17}}, |
| 12867 | { { 385, 0.987, 10}, // ihh (bit) |
| 12868 | {2056, 0.930, -20}, |
| 12869 | {2587, 0.890, -20}, |
| 12870 | {3150, 0.400, -20}}, |
| 12871 | { { 515, 0.977, 10}, // ehh (bet) |
| 12872 | {1805, 0.810, -10}, |
| 12873 | {2526, 0.875, -10}, |
| 12874 | {3103, 0.400, -13}}, |
| 12875 | { { 773, 0.950, 10}, // aaa (bat) |
| 12876 | {1676, 0.830, -6}, |
| 12877 | {2380, 0.880, -20}, |
| 12878 | {3027, 0.600, -20}}, |
| 12879 | |
| 12880 | { { 770, 0.950, 0}, // ahh (father) |
| 12881 | {1153, 0.970, -9}, |
| 12882 | {2450, 0.780, -29}, |
| 12883 | {3140, 0.800, -39}}, |
| 12884 | { { 637, 0.910, 0}, // aww (bought) |
| 12885 | { 895, 0.900, -3}, |
| 12886 | {2556, 0.950, -17}, |
| 12887 | {3070, 0.910, -20}}, |
| 12888 | { { 637, 0.910, 0}, // ohh (bone) NOTE: same as aww (bought) |
| 12889 | { 895, 0.900, -3}, |
| 12890 | {2556, 0.950, -17}, |
| 12891 | {3070, 0.910, -20}}, |
| 12892 | { { 561, 0.965, 0}, // uhh (but) |
| 12893 | {1084, 0.930, -10}, |
| 12894 | {2541, 0.930, -15}, |
| 12895 | {3345, 0.900, -20}}, |
| 12896 | |
| 12897 | { { 515, 0.976, 0}, // uuu (foot) |
| 12898 | {1031, 0.950, -3}, |
| 12899 | {2572, 0.960, -11}, |
| 12900 | {3345, 0.960, -20}}, |
| 12901 | { { 349, 0.986, -10}, // ooo (boot) |
| 12902 | { 918, 0.940, -20}, |
| 12903 | {2350, 0.960, -27}, |
| 12904 | {2731, 0.950, -33}}, |
| 12905 | { { 394, 0.959, -10}, // rrr (bird) |
| 12906 | {1297, 0.780, -16}, |
| 12907 | {1441, 0.980, -16}, |
| 12908 | {2754, 0.950, -40}}, |
| 12909 | { { 462, 0.990, +5}, // lll (lull) |
| 12910 | {1200, 0.640, -10}, |
| 12911 | {2500, 0.200, -20}, |
| 12912 | {3000, 0.100, -30}}, |
| 12913 | |
| 12914 | { { 265, 0.987, -10}, // mmm (mom) |
| 12915 | {1176, 0.940, -22}, |
| 12916 | {2352, 0.970, -20}, |
| 12917 | {3277, 0.940, -31}}, |
| 12918 | { { 204, 0.980, -10}, // nnn (nun) |
| 12919 | {1570, 0.940, -15}, |
| 12920 | {2481, 0.980, -12}, |
| 12921 | {3133, 0.800, -30}}, |
| 12922 | { { 204, 0.980, -10}, // nng (sang) NOTE:: same as nnn |
| 12923 | {1570, 0.940, -15}, |
| 12924 | {2481, 0.980, -12}, |
| 12925 | {3133, 0.800, -30}}, |
| 12926 | { { 204, 0.980, -10}, // ngg (bong) NOTE:: same as nnn |
| 12927 | {1570, 0.940, -15}, |
| 12928 | {2481, 0.980, -12}, |
| 12929 | {3133, 0.800, -30}}, |
| 12930 | |
| 12931 | { {1000, 0.300, 0}, // fff |
| 12932 | {2800, 0.860, -10}, |
| 12933 | {7425, 0.740, 0}, |
| 12934 | {8140, 0.860, 0}}, |
| 12935 | { {0, 0.000, 0}, // sss |
| 12936 | {2000, 0.700, -15}, |
| 12937 | {5257, 0.750, -3}, |
| 12938 | {7171, 0.840, 0}}, |
| 12939 | { { 100, 0.900, 0}, // thh |
| 12940 | {4000, 0.500, -20}, |
| 12941 | {5500, 0.500, -15}, |
| 12942 | {8000, 0.400, -20}}, |
| 12943 | { {2693, 0.940, 0}, // shh |
| 12944 | {4000, 0.720, -10}, |
| 12945 | {6123, 0.870, -10}, |
| 12946 | {7755, 0.750, -18}}, |
| 12947 | |
| 12948 | { {1000, 0.300, -10}, // xxx NOTE:: Not Really Done Yet |
| 12949 | {2800, 0.860, -10}, |
| 12950 | {7425, 0.740, 0}, |
| 12951 | {8140, 0.860, 0}}, |
| 12952 | { { 273, 0.996, -40}, // hee (beet) (noisy eee) |
| 12953 | {2086, 0.945, -16}, |
| 12954 | {2754, 0.979, -12}, |
| 12955 | {3270, 0.440, -17}}, |
| 12956 | { { 349, 0.986, -40}, // hoo (boot) (noisy ooo) |
| 12957 | { 918, 0.940, -10}, |
| 12958 | {2350, 0.960, -17}, |
| 12959 | {2731, 0.950, -23}}, |
| 12960 | { { 770, 0.950, -40}, // hah (father) (noisy ahh) |
| 12961 | {1153, 0.970, -3}, |
| 12962 | {2450, 0.780, -20}, |
| 12963 | {3140, 0.800, -32}}, |
| 12964 | |
| 12965 | { {2000, 0.700, -20}, // bbb NOTE:: Not Really Done Yet |
| 12966 | {5257, 0.750, -15}, |
| 12967 | {7171, 0.840, -3}, |
| 12968 | {9000, 0.900, 0}}, |
| 12969 | { { 100, 0.900, 0}, // ddd NOTE:: Not Really Done Yet |
| 12970 | {4000, 0.500, -20}, |
| 12971 | {5500, 0.500, -15}, |
| 12972 | {8000, 0.400, -20}}, |
| 12973 | { {2693, 0.940, 0}, // jjj NOTE:: Not Really Done Yet |
| 12974 | {4000, 0.720, -10}, |
| 12975 | {6123, 0.870, -10}, |
| 12976 | {7755, 0.750, -18}}, |
| 12977 | { {2693, 0.940, 0}, // ggg NOTE:: Not Really Done Yet |
| 12978 | {4000, 0.720, -10}, |
| 12979 | {6123, 0.870, -10}, |
| 12980 | {7755, 0.750, -18}}, |
| 12981 | |
| 12982 | { {2000, 0.700, -20}, // vvv NOTE:: Not Really Done Yet |
| 12983 | {5257, 0.750, -15}, |
| 12984 | {7171, 0.840, -3}, |
| 12985 | {9000, 0.900, 0}}, |
| 12986 | { { 100, 0.900, 0}, // zzz NOTE:: Not Really Done Yet |
| 12987 | {4000, 0.500, -20}, |
| 12988 | {5500, 0.500, -15}, |
| 12989 | {8000, 0.400, -20}}, |
| 12990 | { {2693, 0.940, 0}, // thz NOTE:: Not Really Done Yet |
| 12991 | {4000, 0.720, -10}, |
| 12992 | {6123, 0.870, -10}, |
| 12993 | {7755, 0.750, -18}}, |
| 12994 | { {2693, 0.940, 0}, // zhh NOTE:: Not Really Done Yet |
| 12995 | {4000, 0.720, -10}, |
| 12996 | {6123, 0.870, -10}, |
| 12997 | {7755, 0.750, -18}} |
| 12998 | }; |
| 12999 | |
| 13000 | Phonemes :: Phonemes(void) |
| 13001 | { |
| 13002 | } |
| 13003 | |
| 13004 | Phonemes :: ~Phonemes(void) |
| 13005 | { |
| 13006 | } |
| 13007 | |
| 13008 | const char *Phonemes :: name( unsigned int index ) |
| 13009 | { |
| 13010 | if ( index > 31 ) { |
| 13011 | CK_STDCERR << "[chuck](via STK): Phonemes: name index is greater than 31!" << CK_STDENDL; |
| 13012 | return 0; |
| 13013 | } |
| 13014 | return phonemeNames[index]; |
| 13015 | } |
| 13016 | |
| 13017 | MY_FLOAT Phonemes :: voiceGain( unsigned int index ) |
| 13018 | { |
| 13019 | if ( index > 31 ) { |
| 13020 | CK_STDCERR << "[chuck](via STK): Phonemes: voiceGain index is greater than 31!" << CK_STDENDL; |
| 13021 | return 0.0; |
| 13022 | } |
| 13023 | return phonemeGains[index][0]; |
| 13024 | } |
| 13025 | |
| 13026 | MY_FLOAT Phonemes :: noiseGain( unsigned int index ) |
| 13027 | { |
| 13028 | if ( index > 31 ) { |
| 13029 | CK_STDCERR << "[chuck](via STK): Phonemes: noiseGain index is greater than 31!" << CK_STDENDL; |
| 13030 | return 0.0; |
| 13031 | } |
| 13032 | return phonemeGains[index][1]; |
| 13033 | } |
| 13034 | |
| 13035 | MY_FLOAT Phonemes :: formantFrequency( unsigned int index, unsigned int partial ) |
| 13036 | { |
| 13037 | if ( index > 31 ) { |
| 13038 | CK_STDCERR << "[chuck](via STK): Phonemes: formantFrequency index is greater than 31!" << CK_STDENDL; |
| 13039 | return 0.0; |
| 13040 | } |
| 13041 | if ( partial > 3 ) { |
| 13042 | CK_STDCERR << "[chuck](via STK): Phonemes: formantFrequency partial is greater than 3!" << CK_STDENDL; |
| 13043 | return 0.0; |
| 13044 | } |
| 13045 | return phonemeParameters[index][partial][0]; |
| 13046 | } |
| 13047 | |
| 13048 | MY_FLOAT Phonemes :: formantRadius( unsigned int index, unsigned int partial ) |
| 13049 | { |
| 13050 | if ( index > 31 ) { |
| 13051 | CK_STDCERR << "[chuck](via STK): Phonemes: formantRadius index is greater than 31!" << CK_STDENDL; |
| 13052 | return 0.0; |
| 13053 | } |
| 13054 | if ( partial > 3 ) { |
| 13055 | CK_STDCERR << "[chuck](via STK): Phonemes: formantRadius partial is greater than 3!" << CK_STDENDL; |
| 13056 | return 0.0; |
| 13057 | } |
| 13058 | return phonemeParameters[index][partial][1]; |
| 13059 | } |
| 13060 | |
| 13061 | MY_FLOAT Phonemes :: formantGain( unsigned int index, unsigned int partial ) |
| 13062 | { |
| 13063 | if ( index > 31 ) { |
| 13064 | CK_STDCERR << "[chuck](via STK): Phonemes: formantGain index is greater than 31!" << CK_STDENDL; |
| 13065 | return 0.0; |
| 13066 | } |
| 13067 | if ( partial > 3 ) { |
| 13068 | CK_STDCERR << "[chuck](via STK): Phonemes: formantGain partial is greater than 3!" << CK_STDENDL; |
| 13069 | return 0.0; |
| 13070 | } |
| 13071 | return phonemeParameters[index][partial][2]; |
| 13072 | } |
| 13073 | /***************************************************/ |
| 13074 | /*! \class PitShift |
| 13075 | \brief STK simple pitch shifter effect class. |
| 13076 | |
| 13077 | This class implements a simple pitch shifter |
| 13078 | using delay lines. |
| 13079 | |
| 13080 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 13081 | */ |
| 13082 | /***************************************************/ |
| 13083 | |
| 13084 | #include <iostream> |
| 13085 | #include <math.h> |
| 13086 | |
| 13087 | PitShift :: PitShift() |
| 13088 | { |
| 13089 | delay[0] = 12; |
| 13090 | delay[1] = 512; |
| 13091 | delayLine[0] = new DelayL(delay[0], (long) 1024); |
| 13092 | delayLine[1] = new DelayL(delay[1], (long) 1024); |
| 13093 | effectMix = (MY_FLOAT) 0.5; |
| 13094 | rate = 1.0; |
| 13095 | |
| 13096 | // 1.5.0.4 (ge) added initialization |
| 13097 | lastOutput = 0; |
| 13098 | m_vibratoFreq = 0; |
| 13099 | m_vibratoGain = 0; |
| 13100 | m_volume = 0; |
| 13101 | } |
| 13102 | |
| 13103 | PitShift :: ~PitShift() |
| 13104 | { |
| 13105 | delete delayLine[0]; |
| 13106 | delete delayLine[1]; |
| 13107 | } |
| 13108 | |
| 13109 | void PitShift :: clear() |
| 13110 | { |
| 13111 | delayLine[0]->clear(); |
| 13112 | delayLine[1]->clear(); |
| 13113 | lastOutput = 0.0; |
| 13114 | } |
| 13115 | |
| 13116 | void PitShift :: setEffectMix(MY_FLOAT mix) |
| 13117 | { |
| 13118 | effectMix = mix; |
| 13119 | if ( mix < 0.0 ) { |
| 13120 | CK_STDCERR << "[chuck](via STK): PitShift: setEffectMix parameter (" << mix << ") is less than zero!" << CK_STDENDL; |
| 13121 | effectMix = 0.0; |
| 13122 | } |
| 13123 | else if ( mix > 1.0 ) { |
| 13124 | CK_STDCERR << "[chuck](via STK): PitShift: setEffectMix parameter (" << mix << ") is greater than 1.0!" << CK_STDENDL; |
| 13125 | effectMix = 1.0; |
| 13126 | } |
| 13127 | } |
| 13128 | |
| 13129 | void PitShift :: setShift(MY_FLOAT shift) |
| 13130 | { |
| 13131 | if (shift < 1.0) { |
| 13132 | rate = 1.0 - shift; |
| 13133 | } |
| 13134 | else if (shift > 1.0) { |
| 13135 | rate = 1.0 - shift; |
| 13136 | } |
| 13137 | else { |
| 13138 | rate = 0.0; |
| 13139 | delay[0] = 512; |
| 13140 | } |
| 13141 | } |
| 13142 | |
| 13143 | MY_FLOAT PitShift :: lastOut() const |
| 13144 | { |
| 13145 | return lastOutput; |
| 13146 | } |
| 13147 | |
| 13148 | MY_FLOAT PitShift :: tick(MY_FLOAT input) |
| 13149 | { |
| 13150 | delay[0] = delay[0] + rate; |
| 13151 | while (delay[0] > 1012) delay[0] -= 1000; |
| 13152 | while (delay[0] < 12) delay[0] += 1000; |
| 13153 | delay[1] = delay[0] + 500; |
| 13154 | while (delay[1] > 1012) delay[1] -= 1000; |
| 13155 | while (delay[1] < 12) delay[1] += 1000; |
| 13156 | delayLine[0]->setDelay((long)delay[0]); |
| 13157 | delayLine[1]->setDelay((long)delay[1]); |
| 13158 | env[1] = fabs(delay[0] - 512) * 0.002; |
| 13159 | env[0] = 1.0 - env[1]; |
| 13160 | lastOutput = env[0] * delayLine[0]->tick(input); |
| 13161 | lastOutput += env[1] * delayLine[1]->tick(input); |
| 13162 | lastOutput *= effectMix; |
| 13163 | lastOutput += (1.0 - effectMix) * input; |
| 13164 | return lastOutput; |
| 13165 | } |
| 13166 | |
| 13167 | MY_FLOAT *PitShift :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 13168 | { |
| 13169 | for (unsigned int i=0; i<vectorSize; i++) |
| 13170 | vec[i] = tick(vec[i]); |
| 13171 | |
| 13172 | return vec; |
| 13173 | } |
| 13174 | |
| 13175 | /***************************************************/ |
| 13176 | /*! \class PluckTwo |
| 13177 | \brief STK enhanced plucked string model class. |
| 13178 | |
| 13179 | This class implements an enhanced two-string, |
| 13180 | plucked physical model, a la Jaffe-Smith, |
| 13181 | Smith, and others. |
| 13182 | |
| 13183 | PluckTwo is an abstract class, with no excitation |
| 13184 | specified. Therefore, it can't be directly |
| 13185 | instantiated. |
| 13186 | |
| 13187 | This is a digital waveguide model, making its |
| 13188 | use possibly subject to patents held by |
| 13189 | Stanford University, Yamaha, and others. |
| 13190 | |
| 13191 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 13192 | */ |
| 13193 | /***************************************************/ |
| 13194 | |
| 13195 | |
| 13196 | PluckTwo :: PluckTwo(MY_FLOAT lowestFrequency) |
| 13197 | { |
| 13198 | length = (long) (Stk::sampleRate() / lowestFrequency + 1); |
| 13199 | baseLoopGain = (MY_FLOAT) 0.995; |
| 13200 | loopGain = (MY_FLOAT) 0.999; |
| 13201 | delayLine = new DelayA((MY_FLOAT)(length / 2.0), length); |
| 13202 | delayLine2 = new DelayA((MY_FLOAT)(length / 2.0), length); |
| 13203 | combDelay = new DelayL((MY_FLOAT)(length / 2.0), length); |
| 13204 | filter = new OneZero; |
| 13205 | filter2 = new OneZero; |
| 13206 | pluckAmplitude = (MY_FLOAT) 0.3; |
| 13207 | pluckPosition = (MY_FLOAT) 0.4; |
| 13208 | detuning = (MY_FLOAT) 0.995; |
| 13209 | lastFrequency = lowestFrequency * (MY_FLOAT) 2.0; |
| 13210 | lastLength = length * (MY_FLOAT) 0.5; |
| 13211 | |
| 13212 | // chuck |
| 13213 | m_frequency = lastFrequency; |
| 13214 | } |
| 13215 | |
| 13216 | PluckTwo :: ~PluckTwo() |
| 13217 | { |
| 13218 | delete delayLine; |
| 13219 | delete delayLine2; |
| 13220 | delete combDelay; |
| 13221 | delete filter; |
| 13222 | delete filter2; |
| 13223 | } |
| 13224 | |
| 13225 | void PluckTwo :: clear() |
| 13226 | { |
| 13227 | delayLine->clear(); |
| 13228 | delayLine2->clear(); |
| 13229 | combDelay->clear(); |
| 13230 | filter->clear(); |
| 13231 | filter2->clear(); |
| 13232 | } |
| 13233 | |
| 13234 | void PluckTwo :: setFrequency(MY_FLOAT frequency) |
| 13235 | { |
| 13236 | lastFrequency = frequency; |
| 13237 | if ( lastFrequency <= 0.0 ) { |
| 13238 | CK_STDCERR << "[chuck](via STK): PluckTwo: setFrequency parameter less than or equal to zero!" << CK_STDENDL; |
| 13239 | lastFrequency = 220.0; |
| 13240 | } |
| 13241 | |
| 13242 | // Delay = length - approximate filter delay. |
| 13243 | // 1.4.1.0 (prc) REPAIRATHON2021 BUG FIX (minus 1) |
| 13244 | lastLength = ( Stk::sampleRate() / lastFrequency) - 1; |
| 13245 | MY_FLOAT delay = (lastLength / detuning) - (MY_FLOAT) 0.5; |
| 13246 | if ( delay <= 0.0 ) delay = 0.3; |
| 13247 | else if ( delay > length ) delay = length; |
| 13248 | delayLine->setDelay( delay ); |
| 13249 | |
| 13250 | delay = (lastLength * detuning) - (MY_FLOAT) 0.5; |
| 13251 | if ( delay <= 0.0 ) delay = 0.3; |
| 13252 | else if ( delay > length ) delay = length; |
| 13253 | delayLine2->setDelay( delay ); |
| 13254 | |
| 13255 | loopGain = baseLoopGain + (frequency * (MY_FLOAT) 0.000005); |
| 13256 | if ( loopGain > 1.0 ) loopGain = (MY_FLOAT) 0.99999; |
| 13257 | |
| 13258 | // chuck |
| 13259 | m_frequency = lastFrequency; |
| 13260 | } |
| 13261 | |
| 13262 | void PluckTwo :: setDetune(MY_FLOAT detune) |
| 13263 | { |
| 13264 | detuning = detune; |
| 13265 | if ( detuning <= 0.0 ) { |
| 13266 | CK_STDCERR << "[chuck](via STK): PluckTwo: setDetune parameter less than or equal to zero!" << CK_STDENDL; |
| 13267 | detuning = 0.1; |
| 13268 | } |
| 13269 | delayLine->setDelay(( lastLength / detuning) - (MY_FLOAT) 0.5); |
| 13270 | delayLine2->setDelay( (lastLength * detuning) - (MY_FLOAT) 0.5); |
| 13271 | } |
| 13272 | |
| 13273 | void PluckTwo :: setFreqAndDetune(MY_FLOAT frequency, MY_FLOAT detune) |
| 13274 | { |
| 13275 | detuning = detune; |
| 13276 | this->setFrequency(frequency); |
| 13277 | } |
| 13278 | |
| 13279 | void PluckTwo :: setPluckPosition(MY_FLOAT position) |
| 13280 | { |
| 13281 | pluckPosition = position; |
| 13282 | if ( position < 0.0 ) { |
| 13283 | CK_STDCERR << "[chuck](via STK): PluckTwo: setPluckPosition parameter is less than zero!" << CK_STDENDL; |
| 13284 | pluckPosition = 0.0; |
| 13285 | } |
| 13286 | else if ( position > 1.0 ) { |
| 13287 | CK_STDCERR << "[chuck](via STK): PluckTwo: setPluckPosition parameter is greater than 1.0!" << CK_STDENDL; |
| 13288 | pluckPosition = 1.0; |
| 13289 | } |
| 13290 | } |
| 13291 | |
| 13292 | void PluckTwo :: setBaseLoopGain(MY_FLOAT aGain) |
| 13293 | { |
| 13294 | baseLoopGain = aGain; |
| 13295 | loopGain = baseLoopGain + (lastFrequency * (MY_FLOAT) 0.000005); |
| 13296 | if ( loopGain > 0.99999 ) loopGain = (MY_FLOAT) 0.99999; |
| 13297 | } |
| 13298 | |
| 13299 | void PluckTwo :: noteOff(MY_FLOAT amplitude) |
| 13300 | { |
| 13301 | loopGain = ((MY_FLOAT) 1.0 - amplitude) * (MY_FLOAT) 0.5; |
| 13302 | |
| 13303 | #if defined(_STK_DEBUG_) |
| 13304 | CK_STDCERR << "[chuck](via STK): PluckTwo: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 13305 | #endif |
| 13306 | } |
| 13307 | |
| 13308 | /***************************************************/ |
| 13309 | /*! \class Plucked |
| 13310 | \brief STK plucked string model class. |
| 13311 | |
| 13312 | This class implements a simple plucked string |
| 13313 | physical model based on the Karplus-Strong |
| 13314 | algorithm. |
| 13315 | |
| 13316 | This is a digital waveguide model, making its |
| 13317 | use possibly subject to patents held by |
| 13318 | Stanford University, Yamaha, and others. |
| 13319 | There exist at least two patents, assigned to |
| 13320 | Stanford, bearing the names of Karplus and/or |
| 13321 | Strong. |
| 13322 | |
| 13323 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 13324 | */ |
| 13325 | /***************************************************/ |
| 13326 | |
| 13327 | |
| 13328 | Plucked :: Plucked(MY_FLOAT lowestFrequency) |
| 13329 | { |
| 13330 | length = (long) (Stk::sampleRate() / lowestFrequency + 1); |
| 13331 | loopGain = (MY_FLOAT) 0.999; |
| 13332 | delayLine = new DelayA( (MY_FLOAT)(length / 2.0), length ); |
| 13333 | loopFilter = new OneZero; |
| 13334 | pickFilter = new OnePole; |
| 13335 | noise = new Noise; |
| 13336 | this->clear(); |
| 13337 | } |
| 13338 | |
| 13339 | Plucked :: ~Plucked() |
| 13340 | { |
| 13341 | delete delayLine; |
| 13342 | delete loopFilter; |
| 13343 | delete pickFilter; |
| 13344 | delete noise; |
| 13345 | } |
| 13346 | |
| 13347 | void Plucked :: clear() |
| 13348 | { |
| 13349 | delayLine->clear(); |
| 13350 | loopFilter->clear(); |
| 13351 | pickFilter->clear(); |
| 13352 | } |
| 13353 | |
| 13354 | void Plucked :: setFrequency(MY_FLOAT frequency) |
| 13355 | { |
| 13356 | MY_FLOAT freakency = frequency; |
| 13357 | if ( frequency <= 0.0 ) { |
| 13358 | CK_STDCERR << "[chuck](via STK): Plucked: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 13359 | freakency = 220.0; |
| 13360 | } |
| 13361 | |
| 13362 | // Delay = length - approximate filter delay. |
| 13363 | MY_FLOAT delay = (Stk::sampleRate() / freakency) - (MY_FLOAT) 0.5; |
| 13364 | if (delay <= 0.0) delay = 0.3; |
| 13365 | else if (delay > length) delay = length; |
| 13366 | delayLine->setDelay(delay); |
| 13367 | loopGain = 0.995 + (freakency * 0.000005); |
| 13368 | if ( loopGain >= 1.0 ) loopGain = (MY_FLOAT) 0.99999; |
| 13369 | |
| 13370 | // chuck |
| 13371 | m_frequency = freakency; |
| 13372 | } |
| 13373 | |
| 13374 | void Plucked :: pluck(MY_FLOAT amplitude) |
| 13375 | { |
| 13376 | MY_FLOAT gain = amplitude; |
| 13377 | if ( gain > 1.0 ) { |
| 13378 | CK_STDCERR << "[chuck](via STK): Plucked: pluck amplitude greater than 1.0!" << CK_STDENDL; |
| 13379 | gain = 1.0; |
| 13380 | } |
| 13381 | else if ( gain < 0.0 ) { |
| 13382 | CK_STDCERR << "[chuck](via STK): Plucked: pluck amplitude less than zero!" << CK_STDENDL; |
| 13383 | gain = 0.0; |
| 13384 | } |
| 13385 | |
| 13386 | pickFilter->setPole((MY_FLOAT) 0.999 - (gain * (MY_FLOAT) 0.15)); |
| 13387 | pickFilter->setGain(gain * (MY_FLOAT) 0.5); |
| 13388 | for (long i=0; i<length; i++) |
| 13389 | // Fill delay with noise additively with current contents. |
| 13390 | delayLine->tick( 0.6 * delayLine->lastOut() + pickFilter->tick( noise->tick() ) ); |
| 13391 | } |
| 13392 | |
| 13393 | void Plucked :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 13394 | { |
| 13395 | this->setFrequency(frequency); |
| 13396 | this->pluck(amplitude); |
| 13397 | |
| 13398 | #if defined(_STK_DEBUG_) |
| 13399 | CK_STDCERR << "[chuck](via STK): Plucked: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 13400 | #endif |
| 13401 | } |
| 13402 | |
| 13403 | void Plucked :: noteOff(MY_FLOAT amplitude) |
| 13404 | { |
| 13405 | loopGain = (MY_FLOAT) 1.0 - amplitude; |
| 13406 | if ( loopGain < 0.0 ) { |
| 13407 | CK_STDCERR << "[chuck](via STK): Plucked: noteOff amplitude greater than 1.0!" << CK_STDENDL; |
| 13408 | loopGain = 0.0; |
| 13409 | } |
| 13410 | else if ( loopGain > 1.0 ) { |
| 13411 | CK_STDCERR << "[chuck](via STK): Plucked: noteOff amplitude less than or zero!" << CK_STDENDL; |
| 13412 | loopGain = (MY_FLOAT) 0.99999; |
| 13413 | } |
| 13414 | |
| 13415 | #if defined(_STK_DEBUG_) |
| 13416 | CK_STDCERR << "[chuck](via STK): Plucked: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 13417 | #endif |
| 13418 | } |
| 13419 | |
| 13420 | MY_FLOAT Plucked :: tick() |
| 13421 | { |
| 13422 | // Here's the whole inner loop of the instrument!! |
| 13423 | lastOutput = delayLine->tick( loopFilter->tick( delayLine->lastOut() * loopGain ) ); |
| 13424 | lastOutput *= (MY_FLOAT) 3.0; |
| 13425 | return lastOutput; |
| 13426 | } |
| 13427 | /***************************************************/ |
| 13428 | /*! \class PoleZero |
| 13429 | \brief STK one-pole, one-zero filter class. |
| 13430 | |
| 13431 | This protected Filter subclass implements |
| 13432 | a one-pole, one-zero digital filter. A |
| 13433 | method is provided for creating an allpass |
| 13434 | filter with a given coefficient. Another |
| 13435 | method is provided to create a DC blocking filter. |
| 13436 | |
| 13437 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 13438 | */ |
| 13439 | /***************************************************/ |
| 13440 | |
| 13441 | |
| 13442 | PoleZero :: PoleZero() : FilterStk() |
| 13443 | { |
| 13444 | // Default setting for pass-through. |
| 13445 | MY_FLOAT B[2] = {1.0, 0.0}; |
| 13446 | MY_FLOAT A[2] = {1.0, 0.0}; |
| 13447 | FilterStk::setCoefficients( 2, B, 2, A ); |
| 13448 | } |
| 13449 | |
| 13450 | PoleZero :: ~PoleZero() |
| 13451 | { |
| 13452 | } |
| 13453 | |
| 13454 | void PoleZero :: clear(void) |
| 13455 | { |
| 13456 | FilterStk::clear(); |
| 13457 | } |
| 13458 | |
| 13459 | void PoleZero :: setB0(MY_FLOAT b0) |
| 13460 | { |
| 13461 | b[0] = b0; |
| 13462 | } |
| 13463 | |
| 13464 | void PoleZero :: setB1(MY_FLOAT b1) |
| 13465 | { |
| 13466 | b[1] = b1; |
| 13467 | } |
| 13468 | |
| 13469 | void PoleZero :: setA1(MY_FLOAT a1) |
| 13470 | { |
| 13471 | a[1] = a1; |
| 13472 | } |
| 13473 | |
| 13474 | void PoleZero :: setAllpass(MY_FLOAT coefficient) |
| 13475 | { |
| 13476 | b[0] = coefficient; |
| 13477 | b[1] = 1.0; |
| 13478 | a[0] = 1.0; // just in case |
| 13479 | a[1] = coefficient; |
| 13480 | } |
| 13481 | |
| 13482 | void PoleZero :: setBlockZero(MY_FLOAT thePole) |
| 13483 | { |
| 13484 | b[0] = 1.0; |
| 13485 | b[1] = -1.0; |
| 13486 | a[0] = 1.0; // just in case |
| 13487 | a[1] = -thePole; |
| 13488 | } |
| 13489 | |
| 13490 | void PoleZero :: setGain(MY_FLOAT theGain) |
| 13491 | { |
| 13492 | FilterStk::setGain(theGain); |
| 13493 | } |
| 13494 | |
| 13495 | MY_FLOAT PoleZero :: getGain(void) const |
| 13496 | { |
| 13497 | return FilterStk::getGain(); |
| 13498 | } |
| 13499 | |
| 13500 | MY_FLOAT PoleZero :: lastOut(void) const |
| 13501 | { |
| 13502 | return FilterStk::lastOut(); |
| 13503 | } |
| 13504 | |
| 13505 | MY_FLOAT PoleZero :: tick(MY_FLOAT sample) |
| 13506 | { |
| 13507 | inputs[0] = gain * sample; |
| 13508 | outputs[0] = b[0] * inputs[0] + b[1] * inputs[1] - a[1] * outputs[1]; |
| 13509 | inputs[1] = inputs[0]; |
| 13510 | outputs[1] = outputs[0]; |
| 13511 | |
| 13512 | // gewang: dedenormal |
| 13513 | CK_STK_DDN(outputs[1]); |
| 13514 | |
| 13515 | return outputs[0]; |
| 13516 | } |
| 13517 | |
| 13518 | MY_FLOAT *PoleZero :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 13519 | { |
| 13520 | for (unsigned int i=0; i<vectorSize; i++) |
| 13521 | vec[i] = tick(vec[i]); |
| 13522 | |
| 13523 | return vec; |
| 13524 | } |
| 13525 | |
| 13526 | /***************************************************/ |
| 13527 | /*! \class ReedTabl |
| 13528 | \brief STK reed table class. |
| 13529 | |
| 13530 | This class implements a simple one breakpoint, |
| 13531 | non-linear reed function, as described by |
| 13532 | Smith (1986). This function is based on a |
| 13533 | memoryless non-linear spring model of the reed |
| 13534 | (the reed mass is ignored) which saturates when |
| 13535 | the reed collides with the mouthpiece facing. |
| 13536 | |
| 13537 | See McIntyre, Schumacher, & Woodhouse (1983), |
| 13538 | Smith (1986), Hirschman, Cook, Scavone, and |
| 13539 | others for more information. |
| 13540 | |
| 13541 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 13542 | */ |
| 13543 | /***************************************************/ |
| 13544 | |
| 13545 | |
| 13546 | ReedTabl :: ReedTabl() |
| 13547 | { |
| 13548 | offSet = (MY_FLOAT) 0.6; // Offset is a bias, related to reed rest position. |
| 13549 | slope = (MY_FLOAT) -0.8; // Slope corresponds loosely to reed stiffness. |
| 13550 | lastOutput = (MY_FLOAT) 0.0; |
| 13551 | } |
| 13552 | |
| 13553 | ReedTabl :: ~ReedTabl() |
| 13554 | { |
| 13555 | |
| 13556 | } |
| 13557 | |
| 13558 | void ReedTabl :: setOffset(MY_FLOAT aValue) |
| 13559 | { |
| 13560 | offSet = aValue; |
| 13561 | } |
| 13562 | |
| 13563 | void ReedTabl :: setSlope(MY_FLOAT aValue) |
| 13564 | { |
| 13565 | slope = aValue; |
| 13566 | } |
| 13567 | |
| 13568 | MY_FLOAT ReedTabl :: lastOut() const |
| 13569 | { |
| 13570 | return lastOutput; |
| 13571 | } |
| 13572 | |
| 13573 | MY_FLOAT ReedTabl :: tick(MY_FLOAT input) |
| 13574 | { |
| 13575 | // The input is differential pressure across the reed. |
| 13576 | lastOutput = offSet + (slope * input); |
| 13577 | |
| 13578 | // If output is > 1, the reed has slammed shut and the |
| 13579 | // reflection function value saturates at 1.0. |
| 13580 | if (lastOutput > 1.0) lastOutput = (MY_FLOAT) 1.0; |
| 13581 | |
| 13582 | // This is nearly impossible in a physical system, but |
| 13583 | // a reflection function value of -1.0 corresponds to |
| 13584 | // an open end (and no discontinuity in bore profile). |
| 13585 | if (lastOutput < -1.0) lastOutput = (MY_FLOAT) -1.0; |
| 13586 | return lastOutput; |
| 13587 | } |
| 13588 | |
| 13589 | MY_FLOAT *ReedTabl :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 13590 | { |
| 13591 | for (unsigned int i=0; i<vectorSize; i++) |
| 13592 | vec[i] = tick(vec[i]); |
| 13593 | |
| 13594 | return vec; |
| 13595 | } |
| 13596 | |
| 13597 | /***************************************************/ |
| 13598 | /*! \class Resonate |
| 13599 | \brief STK noise driven formant filter. |
| 13600 | |
| 13601 | This instrument contains a noise source, which |
| 13602 | excites a biquad resonance filter, with volume |
| 13603 | controlled by an ADSR. |
| 13604 | |
| 13605 | Control Change Numbers: |
| 13606 | - Resonance Frequency (0-Nyquist) = 2 |
| 13607 | - Pole Radii = 4 |
| 13608 | - Notch Frequency (0-Nyquist) = 11 |
| 13609 | - Zero Radii = 1 |
| 13610 | - Envelope Gain = 128 |
| 13611 | |
| 13612 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 13613 | */ |
| 13614 | /***************************************************/ |
| 13615 | |
| 13616 | |
| 13617 | Resonate :: Resonate() |
| 13618 | { |
| 13619 | adsr = new ADSR; |
| 13620 | noise = new Noise; |
| 13621 | |
| 13622 | filter = new BiQuad; |
| 13623 | poleFrequency = 4000.0; |
| 13624 | poleRadius = 0.95; |
| 13625 | // Set the filter parameters. |
| 13626 | filter->setResonance( poleFrequency, poleRadius, TRUE ); |
| 13627 | zeroFrequency = 0.0; |
| 13628 | zeroRadius = 0.0; |
| 13629 | } |
| 13630 | |
| 13631 | Resonate :: ~Resonate() |
| 13632 | { |
| 13633 | delete adsr; |
| 13634 | delete filter; |
| 13635 | delete noise; |
| 13636 | } |
| 13637 | |
| 13638 | void Resonate :: keyOn() |
| 13639 | { |
| 13640 | adsr->keyOn(); |
| 13641 | } |
| 13642 | |
| 13643 | void Resonate :: keyOff() |
| 13644 | { |
| 13645 | adsr->keyOff(); |
| 13646 | } |
| 13647 | |
| 13648 | void Resonate :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 13649 | { |
| 13650 | adsr->setTarget( amplitude ); |
| 13651 | this->keyOn(); |
| 13652 | this->setResonance(frequency, poleRadius); |
| 13653 | |
| 13654 | #if defined(_STK_DEBUG_) |
| 13655 | CK_STDCERR << "[chuck](via STK): Resonate: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 13656 | #endif |
| 13657 | } |
| 13658 | void Resonate :: noteOff(MY_FLOAT amplitude) |
| 13659 | { |
| 13660 | this->keyOff(); |
| 13661 | |
| 13662 | #if defined(_STK_DEBUG_) |
| 13663 | CK_STDCERR << "[chuck](via STK): Resonate: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 13664 | #endif |
| 13665 | } |
| 13666 | |
| 13667 | void Resonate :: setResonance(MY_FLOAT frequency, MY_FLOAT radius) |
| 13668 | { |
| 13669 | poleFrequency = frequency; |
| 13670 | if ( frequency < 0.0 ) { |
| 13671 | CK_STDCERR << "[chuck](via STK): Resonate: setResonance frequency parameter is less than zero!" << CK_STDENDL; |
| 13672 | poleFrequency = 0.0; |
| 13673 | } |
| 13674 | |
| 13675 | poleRadius = radius; |
| 13676 | if ( radius < 0.0 ) { |
| 13677 | CK_STDCERR << "[chuck](via STK): Resonate: setResonance radius parameter is less than 0.0!" << CK_STDENDL; |
| 13678 | poleRadius = 0.0; |
| 13679 | } |
| 13680 | else if ( radius >= 1.0 ) { |
| 13681 | CK_STDCERR << "[chuck](via STK): Resonate: setResonance radius parameter is greater than or equal to 1.0, which is unstable!" << CK_STDENDL; |
| 13682 | poleRadius = 0.9999; |
| 13683 | } |
| 13684 | filter->setResonance( poleFrequency, poleRadius, TRUE ); |
| 13685 | } |
| 13686 | |
| 13687 | void Resonate :: setNotch(MY_FLOAT frequency, MY_FLOAT radius) |
| 13688 | { |
| 13689 | zeroFrequency = frequency; |
| 13690 | if ( frequency < 0.0 ) { |
| 13691 | CK_STDCERR << "[chuck](via STK): Resonate: setNotch frequency parameter is less than zero!" << CK_STDENDL; |
| 13692 | zeroFrequency = 0.0; |
| 13693 | } |
| 13694 | |
| 13695 | zeroRadius = radius; |
| 13696 | if ( radius < 0.0 ) { |
| 13697 | CK_STDCERR << "[chuck](via STK): Resonate: setNotch radius parameter is less than 0.0!" << CK_STDENDL; |
| 13698 | zeroRadius = 0.0; |
| 13699 | } |
| 13700 | |
| 13701 | filter->setNotch( zeroFrequency, zeroRadius ); |
| 13702 | } |
| 13703 | |
| 13704 | void Resonate :: setEqualGainZeroes() |
| 13705 | { |
| 13706 | filter->setEqualGainZeroes(); |
| 13707 | } |
| 13708 | |
| 13709 | MY_FLOAT Resonate :: tick() |
| 13710 | { |
| 13711 | lastOutput = filter->tick(noise->tick()); |
| 13712 | lastOutput *= adsr->tick(); |
| 13713 | return lastOutput; |
| 13714 | } |
| 13715 | |
| 13716 | void Resonate :: controlChange(int number, MY_FLOAT value) |
| 13717 | { |
| 13718 | MY_FLOAT norm = value * ONE_OVER_128; |
| 13719 | if ( norm < 0 ) { |
| 13720 | norm = 0.0; |
| 13721 | CK_STDCERR << "[chuck](via STK): Resonate: Control value less than zero!" << CK_STDENDL; |
| 13722 | } |
| 13723 | else if ( norm > 1.0 ) { |
| 13724 | norm = 1.0; |
| 13725 | CK_STDCERR << "[chuck](via STK): Resonate: Control value exceeds nominal range!" << CK_STDENDL; |
| 13726 | } |
| 13727 | |
| 13728 | if (number == 2) // 2 |
| 13729 | setResonance( norm * Stk::sampleRate() * 0.5, poleRadius ); |
| 13730 | else if (number == 4) // 4 |
| 13731 | setResonance( poleFrequency, norm*0.9999 ); |
| 13732 | else if (number == 11) // 11 |
| 13733 | this->setNotch( norm * Stk::sampleRate() * 0.5, zeroRadius ); |
| 13734 | else if (number == 1) |
| 13735 | this->setNotch( zeroFrequency, norm ); |
| 13736 | else if (number == __SK_AfterTouch_Cont_) // 128 |
| 13737 | adsr->setTarget( norm ); |
| 13738 | else |
| 13739 | CK_STDCERR << "[chuck](via STK): Resonate: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 13740 | |
| 13741 | #if defined(_STK_DEBUG_) |
| 13742 | CK_STDCERR << "[chuck](via STK): Resonate: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 13743 | #endif |
| 13744 | } |
| 13745 | /***************************************************/ |
| 13746 | /*! \class Reverb |
| 13747 | \brief STK abstract reverberator parent class. |
| 13748 | |
| 13749 | This class provides common functionality for |
| 13750 | STK reverberator subclasses. |
| 13751 | |
| 13752 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 13753 | */ |
| 13754 | /***************************************************/ |
| 13755 | |
| 13756 | #include <math.h> |
| 13757 | |
| 13758 | Reverb :: Reverb() |
| 13759 | { |
| 13760 | // 1.5.0.4 (ge) add initialization |
| 13761 | effectMix = 0; |
| 13762 | lastOutput[0] = lastOutput[1] = 0; |
| 13763 | } |
| 13764 | |
| 13765 | Reverb :: ~Reverb() |
| 13766 | { |
| 13767 | } |
| 13768 | |
| 13769 | void Reverb :: setEffectMix(MY_FLOAT mix) |
| 13770 | { |
| 13771 | effectMix = mix; |
| 13772 | } |
| 13773 | |
| 13774 | MY_FLOAT Reverb :: lastOut() const |
| 13775 | { |
| 13776 | return (lastOutput[0] + lastOutput[1]) * 0.5; |
| 13777 | } |
| 13778 | |
| 13779 | MY_FLOAT Reverb :: lastOutLeft() const |
| 13780 | { |
| 13781 | return lastOutput[0]; |
| 13782 | } |
| 13783 | |
| 13784 | MY_FLOAT Reverb :: lastOutRight() const |
| 13785 | { |
| 13786 | return lastOutput[1]; |
| 13787 | } |
| 13788 | |
| 13789 | MY_FLOAT *Reverb :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 13790 | { |
| 13791 | for (unsigned int i=0; i<vectorSize; i++) |
| 13792 | vec[i] = tick(vec[i]); |
| 13793 | |
| 13794 | return vec; |
| 13795 | } |
| 13796 | |
| 13797 | bool Reverb :: isPrime(int number) |
| 13798 | { |
| 13799 | if (number == 2) return true; |
| 13800 | if (number & 1) { |
| 13801 | for (int i=3; i<(int)sqrt((double)number)+1; i+=2) |
| 13802 | if ( (number % i) == 0) return false; |
| 13803 | return true; /* prime */ |
| 13804 | } |
| 13805 | else return false; /* even */ |
| 13806 | } |
| 13807 | /***************************************************/ |
| 13808 | /*! \class Rhodey |
| 13809 | \brief STK Fender Rhodes-like electric piano FM |
| 13810 | synthesis instrument. |
| 13811 | |
| 13812 | This class implements two simple FM Pairs |
| 13813 | summed together, also referred to as algorithm |
| 13814 | 5 of the TX81Z. |
| 13815 | |
| 13816 | \code |
| 13817 | Algorithm 5 is : 4->3--\ |
| 13818 | + --> Out |
| 13819 | 2->1--/ |
| 13820 | \endcode |
| 13821 | |
| 13822 | Control Change Numbers: |
| 13823 | - Modulator Index One = 2 |
| 13824 | - Crossfade of Outputs = 4 |
| 13825 | - LFO Speed = 11 |
| 13826 | - LFO Depth = 1 |
| 13827 | - ADSR 2 & 4 Target = 128 |
| 13828 | |
| 13829 | The basic Chowning/Stanford FM patent expired |
| 13830 | in 1995, but there exist follow-on patents, |
| 13831 | mostly assigned to Yamaha. If you are of the |
| 13832 | type who should worry about this (making |
| 13833 | money) worry away. |
| 13834 | |
| 13835 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 13836 | */ |
| 13837 | /***************************************************/ |
| 13838 | |
| 13839 | |
| 13840 | Rhodey :: Rhodey() |
| 13841 | : FM() |
| 13842 | { |
| 13843 | // Concatenate the STK rawwave path to the rawwave files |
| 13844 | for ( int i=0; i<3; i++ ) |
| 13845 | waves[i] = new WaveLoop( "special:sinewave", TRUE ); |
| 13846 | waves[3] = new WaveLoop( "special:fwavblnk", TRUE ); |
| 13847 | |
| 13848 | this->setRatio(0, 1.0); |
| 13849 | this->setRatio(1, 0.5); |
| 13850 | this->setRatio(2, 1.0); |
| 13851 | this->setRatio(3, 15.0); |
| 13852 | |
| 13853 | gains[0] = __FM_gains[99]; |
| 13854 | gains[1] = __FM_gains[90]; |
| 13855 | gains[2] = __FM_gains[99]; |
| 13856 | gains[3] = __FM_gains[67]; |
| 13857 | |
| 13858 | baseGains[0] = gains[0]; // 1.4.1.0 (prc) REPARIATHON2021 ADDITION |
| 13859 | baseGains[1] = gains[1]; |
| 13860 | baseGains[2] = gains[2]; |
| 13861 | baseGains[3] = gains[3]; |
| 13862 | |
| 13863 | adsr[0]->setAllTimes( 0.001, 1.50, 0.0, 0.04); |
| 13864 | adsr[1]->setAllTimes( 0.001, 1.50, 0.0, 0.04); |
| 13865 | adsr[2]->setAllTimes( 0.001, 1.00, 0.0, 0.04); |
| 13866 | adsr[3]->setAllTimes( 0.001, 0.25, 0.0, 0.04); |
| 13867 | |
| 13868 | twozero->setGain((MY_FLOAT) 1.0); |
| 13869 | op4Feedback = 1.0; |
| 13870 | |
| 13871 | bCompatible = 1; // 1.4.1.0 (prc) REPAIRATHON2021 HACK: When created, I'm a Rhodey, that can change.... *****/ |
| 13872 | } |
| 13873 | |
| 13874 | Rhodey :: ~Rhodey() |
| 13875 | { |
| 13876 | // note: waves array taken care of in FM destructor |
| 13877 | } |
| 13878 | |
| 13879 | void Rhodey :: setFrequency(MY_FLOAT frequency) |
| 13880 | { |
| 13881 | baseFrequency = frequency * (MY_FLOAT) 2.0; |
| 13882 | |
| 13883 | for (int i=0; i<nOperators; i++ ) |
| 13884 | waves[i]->setFrequency( baseFrequency * ratios[i] ); |
| 13885 | |
| 13886 | // chuck |
| 13887 | m_frequency = baseFrequency * .5; |
| 13888 | } |
| 13889 | |
| 13890 | void Rhodey :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 13891 | { |
| 13892 | // 1.4.1.0 (prc) REPAIRATHON2021 commented out |
| 13893 | // gains[0] = amplitude * __FM_gains[99]; // OLD WAY OF DOING IT |
| 13894 | // gains[1] = amplitude * __FM_gains[90]; // DELETE THESE SOMEDAY |
| 13895 | // gains[2] = amplitude * __FM_gains[99]; |
| 13896 | // gains[3] = amplitude * __FM_gains[67]; |
| 13897 | |
| 13898 | // 1.4.1.0 (prc) REPAIRATHON2021 added |
| 13899 | gains[0] = amplitude * baseGains[0]; |
| 13900 | gains[1] = amplitude * baseGains[1]; |
| 13901 | gains[2] = amplitude * baseGains[2]; |
| 13902 | gains[3] = amplitude * baseGains[3]; |
| 13903 | |
| 13904 | this->setFrequency(frequency); |
| 13905 | this->keyOn(); |
| 13906 | |
| 13907 | #if defined(_STK_DEBUG_) |
| 13908 | CK_STDCERR << "Rhodey: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 13909 | #endif |
| 13910 | } |
| 13911 | |
| 13912 | MY_FLOAT Rhodey :: tick() // 1.4.1.0 (prc) REPAIRATHON2021 |
| 13913 | { |
| 13914 | MY_FLOAT temp, temp2; |
| 13915 | |
| 13916 | temp2 = vibrato->tick(); |
| 13917 | |
| 13918 | if (bCompatible) { // 1.4.1.0 (prc) REPAIRATHON2021 COMPATIBILITY, "I'm still a Rhodey" |
| 13919 | temp = gains[1] * adsr[1]->tick() * waves[1]->tick(); |
| 13920 | temp = temp * control1; |
| 13921 | |
| 13922 | waves[0]->addPhaseOffset(temp); |
| 13923 | waves[3]->addPhaseOffset(twozero->lastOut()); |
| 13924 | temp = gains[3] * adsr[3]->tick() * waves[3]->tick(); |
| 13925 | twozero->tick(temp); |
| 13926 | |
| 13927 | waves[2]->addPhaseOffset(temp); |
| 13928 | temp = ( 1.0 - (control2 * 0.5)) * gains[0] * adsr[0]->tick() * waves[0]->tick(); |
| 13929 | temp += control2 * 0.5 * gains[2] * adsr[2]->tick() * waves[2]->tick(); |
| 13930 | |
| 13931 | // Calculate amplitude modulation and apply it to output. |
| 13932 | temp2 *= modDepth; |
| 13933 | temp = temp * (1.0 + temp2); |
| 13934 | } else { // 1.4.1.0 (prc) REPAIRATHON NEW FUNCTIONs, modDepth = vibrato, opAMs[n] = AM |
| 13935 | temp = temp2 * modDepth * 0.2; |
| 13936 | for (int i = 0; i < 4; i++) { |
| 13937 | if (ratios[i] > 0.0) { |
| 13938 | waves[i]->setFrequency(baseFrequency * (1.0 + temp) * ratios[i]); |
| 13939 | } |
| 13940 | } |
| 13941 | |
| 13942 | temp = (1.0 + opAMs[1] * temp2) * gains[1] * adsr[1]->tick() * waves[1]->tick(); |
| 13943 | temp = temp * control1; |
| 13944 | |
| 13945 | waves[0]->addPhaseOffset(temp); |
| 13946 | waves[3]->addPhaseOffset(twozero->lastOut()); |
| 13947 | temp = (1.0 + opAMs[3] * temp2) * gains[3] * adsr[3]->tick() * waves[3]->tick(); |
| 13948 | twozero->tick(temp); |
| 13949 | |
| 13950 | waves[2]->addPhaseOffset(temp); |
| 13951 | temp = ( 1.0 - (control2 * 0.5) + (opAMs[0] * temp2)) * gains[0] * adsr[0]->tick() * waves[0]->tick(); |
| 13952 | temp += (1.0 + opAMs[2] * temp2) * control2 * 0.5 * gains[2] * adsr[2]->tick() * waves[2]->tick(); |
| 13953 | } |
| 13954 | |
| 13955 | lastOutput = temp * 0.5; |
| 13956 | return lastOutput; |
| 13957 | } |
| 13958 | |
| 13959 | /***************************************************/ |
| 13960 | /*! \class SKINI |
| 13961 | \brief STK SKINI parsing class |
| 13962 | |
| 13963 | This class parses SKINI formatted text |
| 13964 | messages. It can be used to parse individual |
| 13965 | messages or it can be passed an entire file. |
| 13966 | The file specification is Perry's and his |
| 13967 | alone, but it's all text so it shouldn't be to |
| 13968 | hard to figure out. |
| 13969 | |
| 13970 | SKINI (Synthesis toolKit Instrument Network |
| 13971 | Interface) is like MIDI, but allows for |
| 13972 | floating-point control changes, note numbers, |
| 13973 | etc. The following example causes a sharp |
| 13974 | middle C to be played with a velocity of 111.132: |
| 13975 | |
| 13976 | noteOn 60.01 111.13 |
| 13977 | |
| 13978 | See also SKINI.txt. |
| 13979 | |
| 13980 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 13981 | */ |
| 13982 | /***************************************************/ |
| 13983 | |
| 13984 | #include <string.h> |
| 13985 | #include <stdlib.h> |
| 13986 | |
| 13987 | // Constructor for use when parsing SKINI strings (coming over socket |
| 13988 | // for example. Use parseThis() method with string pointer. |
| 13989 | SKINI :: SKINI() |
| 13990 | { |
| 13991 | } |
| 13992 | |
| 13993 | // Constructor for reading SKINI files ... use nextMessage() method. |
| 13994 | SKINI :: SKINI(char *fileName) |
| 13995 | { |
| 13996 | char msg[STK_MSG_BUF_LENGTH]; |
| 13997 | |
| 13998 | myFile = fopen(fileName,"r"); |
| 13999 | if( myFile == NULL ) { // 1.4.1.1 (ge) changed from myFile < 0, which isn't consistent with fopen return semantics |
| 14000 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via SKINI): Could not open or find file (%s).", fileName); |
| 14001 | handleError(msg, StkError::FILE_NOT_FOUND); |
| 14002 | } |
| 14003 | |
| 14004 | this->nextMessage(); |
| 14005 | } |
| 14006 | |
| 14007 | SKINI :: ~SKINI() |
| 14008 | { |
| 14009 | } |
| 14010 | |
| 14011 | /***************** SOME HANDY ROUTINES *******************/ |
| 14012 | |
| 14013 | |
| 14014 | #define __SK_MAX_FIELDS_ 5 |
| 14015 | #define __SK_MAX_SIZE_ 32 |
| 14016 | |
| 14017 | short ignoreThis(char aChar) |
| 14018 | { |
| 14019 | short ignoreIt = 0; |
| 14020 | if (aChar == 0) ignoreIt = 1; // Null String Termination |
| 14021 | if (aChar == '\n') ignoreIt = 1; // Carraige Return??? |
| 14022 | if (aChar == '/') ignoreIt = 2; // Comment Line |
| 14023 | return ignoreIt; |
| 14024 | } |
| 14025 | |
| 14026 | short delimit(char aChar) |
| 14027 | { |
| 14028 | if (aChar == ' ' || // Space |
| 14029 | aChar == ',' || // Or Comma |
| 14030 | aChar == '\t') // Or Tab |
| 14031 | return 1; |
| 14032 | else |
| 14033 | return 0; |
| 14034 | } |
| 14035 | |
| 14036 | short nextChar(char* aString) |
| 14037 | { |
| 14038 | int i; |
| 14039 | |
| 14040 | for (i=0;i<__SK_MAX_SIZE_;i++) { |
| 14041 | if ( aString[i] != ' ' && // Space |
| 14042 | aString[i] != ',' && // Or Comma |
| 14043 | aString[i] != '\t' ) // Or Tab |
| 14044 | return i; |
| 14045 | } |
| 14046 | return 1024; |
| 14047 | } |
| 14048 | |
| 14049 | int subStrings(char *aString, |
| 14050 | char someStrings[__SK_MAX_FIELDS_][__SK_MAX_SIZE_], |
| 14051 | int somePointrs[__SK_MAX_FIELDS_], |
| 14052 | char *remainderString) |
| 14053 | { |
| 14054 | int notDone,howMany,point,temp; |
| 14055 | notDone = 1; |
| 14056 | howMany = 0; |
| 14057 | point = 0; |
| 14058 | temp = nextChar(aString); |
| 14059 | if (temp >= __SK_MAX_SIZE_) { |
| 14060 | notDone = 0; |
| 14061 | // printf("Confusion here: Ignoring this line\n"); |
| 14062 | // printf("%s\n",aString); |
| 14063 | return howMany; |
| 14064 | } |
| 14065 | point = temp; |
| 14066 | somePointrs[howMany] = point; |
| 14067 | temp = 0; |
| 14068 | while (notDone) { |
| 14069 | if (aString[point] == '\n') { |
| 14070 | notDone = 0; |
| 14071 | } |
| 14072 | else { |
| 14073 | someStrings[howMany][temp++] = aString[point++]; |
| 14074 | if (temp >= __SK_MAX_SIZE_) { |
| 14075 | howMany = 0; |
| 14076 | return howMany; |
| 14077 | } |
| 14078 | if (delimit(aString[point]) || aString[point] == '\n') { |
| 14079 | someStrings[howMany][temp] = 0; |
| 14080 | howMany += 1; |
| 14081 | if (howMany < __SK_MAX_FIELDS_) { |
| 14082 | temp = nextChar(&aString[point]); |
| 14083 | point += temp; |
| 14084 | somePointrs[howMany-1] = point; |
| 14085 | temp = 0; |
| 14086 | } |
| 14087 | else { |
| 14088 | temp = 0; |
| 14089 | somePointrs[howMany-1] = point; |
| 14090 | while(aString[point] != '\n') |
| 14091 | remainderString[temp++] = aString[point++]; |
| 14092 | remainderString[temp] = aString[point]; |
| 14093 | } |
| 14094 | } |
| 14095 | } |
| 14096 | } |
| 14097 | // printf("Got: %i Strings:\n",howMany); |
| 14098 | // for (temp=0;temp<howMany;temp++) |
| 14099 | // printf("%s\n",someStrings[temp]); |
| 14100 | return howMany; |
| 14101 | |
| 14102 | } |
| 14103 | |
| 14104 | /**************** THE ENCHILLADA !!!! **********************/ |
| 14105 | /*** This function parses a single string (if it can) ****/ |
| 14106 | /*** of SKINI message, setting the appropriate variables ***/ |
| 14107 | /*************************************************************/ |
| 14108 | |
| 14109 | long SKINI :: parseThis(char* aString) |
| 14110 | { |
| 14111 | int which,aField; |
| 14112 | int temp,temp2; |
| 14113 | char someStrings[__SK_MAX_FIELDS_][__SK_MAX_SIZE_]; |
| 14114 | int somePointrs[__SK_MAX_FIELDS_]; |
| 14115 | |
| 14116 | temp = nextChar(aString); |
| 14117 | which = ignoreThis(aString[temp]); |
| 14118 | if ( which ) { |
| 14119 | if (which == 2) printf("// CommentLine: %s\n",aString); |
| 14120 | messageType = 0; |
| 14121 | return messageType; |
| 14122 | } |
| 14123 | else { |
| 14124 | temp = subStrings(aString,someStrings,somePointrs,remainderString); |
| 14125 | if (temp > 0) |
| 14126 | which = 0; |
| 14127 | aField = 0; |
| 14128 | strcpy(msgTypeString,someStrings[aField]); |
| 14129 | while ((which < __SK_MaxMsgTypes_) && |
| 14130 | (strcmp(msgTypeString, |
| 14131 | skini_msgs[which].messageString))) { |
| 14132 | which += 1; |
| 14133 | } |
| 14134 | if (which >= __SK_MaxMsgTypes_) { |
| 14135 | messageType = 0; |
| 14136 | printf("Couldn't parse this message field: =%s\n %s\n", |
| 14137 | msgTypeString,aString); |
| 14138 | return messageType; |
| 14139 | } |
| 14140 | else { |
| 14141 | messageType = skini_msgs[which].type; |
| 14142 | // printf("Message Token = %s type = %i\n", msgTypeString,messageType); |
| 14143 | } |
| 14144 | aField += 1; |
| 14145 | |
| 14146 | if (someStrings[aField][0] == '=') { |
| 14147 | deltaTime = (MY_FLOAT) atof(&someStrings[aField][1]); |
| 14148 | deltaTime = -deltaTime; |
| 14149 | } |
| 14150 | else { |
| 14151 | deltaTime = (MY_FLOAT) atof(someStrings[aField]); |
| 14152 | } |
| 14153 | // printf("DeltaTime = %f\n",deltaTime); |
| 14154 | aField += 1; |
| 14155 | |
| 14156 | channel = atoi(someStrings[aField]); |
| 14157 | // printf("Channel = %i\n",channel); |
| 14158 | aField += 1; |
| 14159 | |
| 14160 | if (skini_msgs[which].data2 != NOPE) { |
| 14161 | if (skini_msgs[which].data2 == SK_INT) { |
| 14162 | byteTwoInt = atoi(someStrings[aField]); |
| 14163 | byteTwo = (MY_FLOAT) byteTwoInt; |
| 14164 | } |
| 14165 | else if (skini_msgs[which].data2 == SK_DBL) { |
| 14166 | byteTwo = (MY_FLOAT) atof(someStrings[aField]); |
| 14167 | byteTwoInt = (long) byteTwo; |
| 14168 | } |
| 14169 | else if (skini_msgs[which].data2 == SK_STR) { |
| 14170 | temp = somePointrs[aField-1]; /* Hack Danger Here, Why -1??? */ |
| 14171 | temp2 = 0; |
| 14172 | while (aString[temp] != '\n') { |
| 14173 | remainderString[temp2++] = aString[temp++]; |
| 14174 | } |
| 14175 | remainderString[temp2] = 0; |
| 14176 | } |
| 14177 | else { |
| 14178 | byteTwoInt = skini_msgs[which].data2; |
| 14179 | byteTwo = (MY_FLOAT) byteTwoInt; |
| 14180 | aField -= 1; |
| 14181 | } |
| 14182 | |
| 14183 | aField += 1; |
| 14184 | if (skini_msgs[which].data3 != NOPE) { |
| 14185 | if (skini_msgs[which].data3 == SK_INT) { |
| 14186 | byteThreeInt = atoi(someStrings[aField]); |
| 14187 | byteThree = (MY_FLOAT) byteThreeInt; |
| 14188 | } |
| 14189 | else if (skini_msgs[which].data3 == SK_DBL) { |
| 14190 | byteThree = (MY_FLOAT) atof(someStrings[aField]); |
| 14191 | byteThreeInt = (long) byteThree; |
| 14192 | } |
| 14193 | else if (skini_msgs[which].data3 == SK_STR) { |
| 14194 | temp = somePointrs[aField-1]; /* Hack Danger Here, Why -1??? */ |
| 14195 | temp2 = 0; |
| 14196 | while (aString[temp] != '\n') { |
| 14197 | remainderString[temp2++] = aString[temp++]; |
| 14198 | } |
| 14199 | remainderString[temp2] = 0; |
| 14200 | } |
| 14201 | else { |
| 14202 | byteThreeInt = skini_msgs[which].data3; |
| 14203 | byteThree = (MY_FLOAT) byteThreeInt; |
| 14204 | } |
| 14205 | } |
| 14206 | else { |
| 14207 | byteThreeInt = byteTwoInt; |
| 14208 | byteThree = byteTwo; |
| 14209 | } |
| 14210 | } |
| 14211 | } |
| 14212 | return messageType; |
| 14213 | } |
| 14214 | |
| 14215 | long SKINI :: nextMessage() |
| 14216 | { |
| 14217 | int notDone; |
| 14218 | char inputString[1024]; |
| 14219 | |
| 14220 | notDone = 1; |
| 14221 | while (notDone) { |
| 14222 | notDone = 0; |
| 14223 | if (!fgets(inputString,1024,myFile)) { |
| 14224 | printf("// End of Score. Thanks for using SKINI!!\n"); |
| 14225 | messageType = -1; |
| 14226 | return messageType; |
| 14227 | } |
| 14228 | else if (parseThis(inputString) == 0) { |
| 14229 | notDone = 1; |
| 14230 | } |
| 14231 | } |
| 14232 | return messageType; |
| 14233 | } |
| 14234 | |
| 14235 | long SKINI :: getType() const |
| 14236 | { |
| 14237 | return messageType; |
| 14238 | } |
| 14239 | |
| 14240 | long SKINI :: getChannel() const |
| 14241 | { |
| 14242 | return channel; |
| 14243 | } |
| 14244 | |
| 14245 | MY_FLOAT SKINI :: getDelta() const |
| 14246 | { |
| 14247 | return deltaTime; |
| 14248 | } |
| 14249 | |
| 14250 | MY_FLOAT SKINI :: getByteTwo() const |
| 14251 | { |
| 14252 | return byteTwo; |
| 14253 | } |
| 14254 | |
| 14255 | long SKINI :: getByteTwoInt() const |
| 14256 | { |
| 14257 | return byteTwoInt; |
| 14258 | } |
| 14259 | |
| 14260 | MY_FLOAT SKINI :: getByteThree() const |
| 14261 | { |
| 14262 | return byteThree; |
| 14263 | } |
| 14264 | |
| 14265 | long SKINI :: getByteThreeInt() const |
| 14266 | { |
| 14267 | return byteThreeInt; |
| 14268 | } |
| 14269 | |
| 14270 | const char* SKINI :: getRemainderString() |
| 14271 | { |
| 14272 | return remainderString; |
| 14273 | } |
| 14274 | |
| 14275 | const char* SKINI :: getMessageTypeString() |
| 14276 | { |
| 14277 | return msgTypeString; |
| 14278 | } |
| 14279 | |
| 14280 | const char* SKINI :: whatsThisType(long type) |
| 14281 | { |
| 14282 | int i = 0; |
| 14283 | whatString[0] = 0; |
| 14284 | for ( i=0; i<__SK_MaxMsgTypes_; i++ ) { |
| 14285 | if ( type == skini_msgs[i].type ) { |
| 14286 | strcat(whatString, skini_msgs[i].messageString); |
| 14287 | strcat(whatString, ","); |
| 14288 | } |
| 14289 | } |
| 14290 | return whatString; |
| 14291 | } |
| 14292 | |
| 14293 | const char* SKINI :: whatsThisController(long contNum) |
| 14294 | { |
| 14295 | int i = 0; |
| 14296 | whatString[0] = 0; |
| 14297 | for ( i=0; i<__SK_MaxMsgTypes_; i++) { |
| 14298 | if ( skini_msgs[i].type == __SK_ControlChange_ |
| 14299 | && contNum == skini_msgs[i].data2) { |
| 14300 | strcat(whatString, skini_msgs[i].messageString); |
| 14301 | strcat(whatString, ","); |
| 14302 | } |
| 14303 | } |
| 14304 | return whatString; |
| 14305 | } |
| 14306 | |
| 14307 | |
| 14308 | /***************************************************/ |
| 14309 | /*! \class Sampler |
| 14310 | \brief STK sampling synthesis abstract base class. |
| 14311 | |
| 14312 | This instrument contains up to 5 attack waves, |
| 14313 | 5 looped waves, and an ADSR envelope. |
| 14314 | |
| 14315 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 14316 | */ |
| 14317 | /***************************************************/ |
| 14318 | |
| 14319 | |
| 14320 | Sampler :: Sampler() |
| 14321 | { |
| 14322 | // We don't make the waves here yet, because |
| 14323 | // we don't know what they will be. |
| 14324 | adsr = new ADSR; |
| 14325 | baseFrequency = 440.0; |
| 14326 | filter = new OnePole; |
| 14327 | attackGain = 0.25; |
| 14328 | loopGain = 0.25; |
| 14329 | whichOne = 0; |
| 14330 | |
| 14331 | // chuck |
| 14332 | m_frequency = baseFrequency; |
| 14333 | } |
| 14334 | |
| 14335 | Sampler :: ~Sampler() |
| 14336 | { |
| 14337 | delete adsr; |
| 14338 | delete filter; |
| 14339 | } |
| 14340 | |
| 14341 | void Sampler :: keyOn() |
| 14342 | { |
| 14343 | adsr->keyOn(); |
| 14344 | attacks[0]->reset(); |
| 14345 | } |
| 14346 | |
| 14347 | void Sampler :: keyOff() |
| 14348 | { |
| 14349 | adsr->keyOff(); |
| 14350 | } |
| 14351 | |
| 14352 | void Sampler :: noteOff(MY_FLOAT amplitude) |
| 14353 | { |
| 14354 | this->keyOff(); |
| 14355 | |
| 14356 | #if defined(_STK_DEBUG_) |
| 14357 | CK_STDCERR << "Sampler: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 14358 | #endif |
| 14359 | } |
| 14360 | |
| 14361 | MY_FLOAT Sampler :: tick() |
| 14362 | { |
| 14363 | lastOutput = attackGain * attacks[whichOne]->tick(); |
| 14364 | lastOutput += loopGain * loops[whichOne]->tick(); |
| 14365 | lastOutput = filter->tick(lastOutput); |
| 14366 | lastOutput *= adsr->tick(); |
| 14367 | return lastOutput; |
| 14368 | } |
| 14369 | /***************************************************/ |
| 14370 | /*! \class Saxofony |
| 14371 | \brief STK faux conical bore reed instrument class. |
| 14372 | |
| 14373 | This class implements a "hybrid" digital |
| 14374 | waveguide instrument that can generate a |
| 14375 | variety of wind-like sounds. It has also been |
| 14376 | referred to as the "blowed string" model. The |
| 14377 | waveguide section is essentially that of a |
| 14378 | string, with one rigid and one lossy |
| 14379 | termination. The non-linear function is a |
| 14380 | reed table. The string can be "blown" at any |
| 14381 | point between the terminations, though just as |
| 14382 | with strings, it is impossible to excite the |
| 14383 | system at either end. If the excitation is |
| 14384 | placed at the string mid-point, the sound is |
| 14385 | that of a clarinet. At points closer to the |
| 14386 | "bridge", the sound is closer to that of a |
| 14387 | saxophone. See Scavone (2002) for more details. |
| 14388 | |
| 14389 | This is a digital waveguide model, making its |
| 14390 | use possibly subject to patents held by Stanford |
| 14391 | University, Yamaha, and others. |
| 14392 | |
| 14393 | Control Change Numbers: |
| 14394 | - Reed Stiffness = 2 |
| 14395 | - Reed Aperture = 26 |
| 14396 | - Noise Gain = 4 |
| 14397 | - Blow Position = 11 |
| 14398 | - Vibrato Frequency = 29 |
| 14399 | - Vibrato Gain = 1 |
| 14400 | - Breath Pressure = 128 |
| 14401 | |
| 14402 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 14403 | */ |
| 14404 | /***************************************************/ |
| 14405 | |
| 14406 | |
| 14407 | Saxofony :: Saxofony(MY_FLOAT lowestFrequency) |
| 14408 | { |
| 14409 | length = (long) (Stk::sampleRate() / lowestFrequency + 1); |
| 14410 | // Initialize blowing position to 0.2 of length / 2. |
| 14411 | position = 0.2; |
| 14412 | delays[0] = (DelayL *) new DelayL( (1.0-position) * (length >> 1), length ); |
| 14413 | delays[1] = (DelayL *) new DelayL( position * (length >> 1), length ); |
| 14414 | |
| 14415 | reedTable = new ReedTabl; |
| 14416 | reedTable->setOffset((MY_FLOAT) 0.7); |
| 14417 | reedTable->setSlope((MY_FLOAT) 0.3); |
| 14418 | filter = new OneZero; |
| 14419 | envelope = new Envelope; |
| 14420 | noise = new Noise; |
| 14421 | |
| 14422 | // Concatenate the STK rawwave path to the rawwave file |
| 14423 | vibrato = new WaveLoop( "special:sinewave", TRUE ); |
| 14424 | vibrato->setFrequency((MY_FLOAT) 5.735); |
| 14425 | |
| 14426 | outputGain = (MY_FLOAT) 0.3; |
| 14427 | noiseGain = (MY_FLOAT) 0.2; |
| 14428 | vibratoGain = (MY_FLOAT) 0.1; |
| 14429 | |
| 14430 | // TODO: what is default? |
| 14431 | m_frequency = length >> 1; |
| 14432 | // assuming 1.0 velocity |
| 14433 | m_rate = .005; |
| 14434 | // reverse: reedTable->setSlope( 0.1 + (0.4 * norm) ) |
| 14435 | m_stiffness = (reedTable->slope - .1) / .4; |
| 14436 | // reverse: reedTable->setOffset(0.4 + ( norm * 0.6)); |
| 14437 | m_aperture = (reedTable->offSet - .4) / .6; |
| 14438 | // reverse: noiseGain = ( norm * 0.4 ); |
| 14439 | m_noiseGain = noiseGain / .4; |
| 14440 | // reverse: vibratoGain = ( norm * 0.5 ); |
| 14441 | m_vibratoGain = vibratoGain / .5; |
| 14442 | // pressure from envelope |
| 14443 | m_pressure = envelope->value; |
| 14444 | } |
| 14445 | |
| 14446 | Saxofony :: ~Saxofony() |
| 14447 | { |
| 14448 | delete delays[0]; |
| 14449 | delete delays[1]; |
| 14450 | delete reedTable; |
| 14451 | delete filter; |
| 14452 | delete envelope; |
| 14453 | delete noise; |
| 14454 | delete vibrato; |
| 14455 | } |
| 14456 | |
| 14457 | void Saxofony :: clear() |
| 14458 | { |
| 14459 | delays[0]->clear(); |
| 14460 | delays[1]->clear(); |
| 14461 | filter->tick((MY_FLOAT) 0.0); |
| 14462 | } |
| 14463 | |
| 14464 | void Saxofony :: setFrequency(MY_FLOAT frequency) |
| 14465 | { |
| 14466 | MY_FLOAT freakency = frequency; |
| 14467 | if ( frequency <= 0.0 ) { |
| 14468 | CK_STDCERR << "[chuck](via STK): Saxofony: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 14469 | freakency = 220.0; |
| 14470 | } |
| 14471 | |
| 14472 | // chuck |
| 14473 | m_frequency = freakency; |
| 14474 | |
| 14475 | MY_FLOAT delay = (Stk::sampleRate() / freakency) - (MY_FLOAT) 3.0; |
| 14476 | if (delay <= 0.0) delay = 0.3; |
| 14477 | else if (delay > length) delay = length; |
| 14478 | |
| 14479 | delays[0]->setDelay((1.0-position) * delay); |
| 14480 | delays[1]->setDelay(position * delay); |
| 14481 | } |
| 14482 | |
| 14483 | void Saxofony :: setBlowPosition(MY_FLOAT aPosition) |
| 14484 | { |
| 14485 | if (position == aPosition) return; |
| 14486 | |
| 14487 | if (aPosition < 0.0) position = 0.0; |
| 14488 | else if (aPosition > 1.0) position = 1.0; |
| 14489 | else position = aPosition; |
| 14490 | |
| 14491 | MY_FLOAT total_delay = delays[0]->getDelay(); |
| 14492 | total_delay += delays[1]->getDelay(); |
| 14493 | |
| 14494 | delays[0]->setDelay((1.0-position) * total_delay); |
| 14495 | delays[1]->setDelay(position * total_delay); |
| 14496 | } |
| 14497 | |
| 14498 | void Saxofony :: startBlowing(MY_FLOAT amplitude, MY_FLOAT rate) |
| 14499 | { |
| 14500 | envelope->setRate(rate); |
| 14501 | envelope->setTarget(amplitude); |
| 14502 | } |
| 14503 | |
| 14504 | void Saxofony :: stopBlowing(MY_FLOAT rate) |
| 14505 | { |
| 14506 | envelope->setRate(rate); |
| 14507 | envelope->setTarget((MY_FLOAT) 0.0); |
| 14508 | } |
| 14509 | |
| 14510 | void Saxofony :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 14511 | { |
| 14512 | setFrequency(frequency); |
| 14513 | startBlowing((MY_FLOAT) 0.55 + (amplitude * 0.30), amplitude * 0.005); |
| 14514 | outputGain = amplitude + 0.001; |
| 14515 | |
| 14516 | #if defined(_STK_DEBUG_) |
| 14517 | CK_STDCERR << "[chuck](via STK): Saxofony: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 14518 | #endif |
| 14519 | } |
| 14520 | |
| 14521 | void Saxofony :: noteOff(MY_FLOAT amplitude) |
| 14522 | { |
| 14523 | this->stopBlowing(amplitude * 0.01); |
| 14524 | |
| 14525 | #if defined(_STK_DEBUG_) |
| 14526 | CK_STDCERR << "[chuck](via STK): Saxofony: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 14527 | #endif |
| 14528 | } |
| 14529 | |
| 14530 | MY_FLOAT Saxofony :: tick() |
| 14531 | { |
| 14532 | MY_FLOAT pressureDiff; |
| 14533 | MY_FLOAT breathPressure; |
| 14534 | MY_FLOAT temp; |
| 14535 | |
| 14536 | // Calculate the breath pressure (envelope + noise + vibrato) |
| 14537 | breathPressure = envelope->tick(); |
| 14538 | breathPressure += breathPressure * noiseGain * noise->tick(); |
| 14539 | breathPressure += breathPressure * vibratoGain * vibrato->tick(); |
| 14540 | |
| 14541 | temp = -0.95 * filter->tick( delays[0]->lastOut() ); |
| 14542 | lastOutput = temp - delays[1]->lastOut(); |
| 14543 | pressureDiff = breathPressure - lastOutput; |
| 14544 | delays[1]->tick(temp); |
| 14545 | delays[0]->tick(breathPressure - (pressureDiff * reedTable->tick(pressureDiff)) - temp); |
| 14546 | |
| 14547 | lastOutput *= outputGain; |
| 14548 | return lastOutput; |
| 14549 | } |
| 14550 | |
| 14551 | void Saxofony :: controlChange(int number, MY_FLOAT value) |
| 14552 | { |
| 14553 | MY_FLOAT norm = value * ONE_OVER_128; |
| 14554 | if ( norm < 0 ) { |
| 14555 | norm = 0.0; |
| 14556 | CK_STDCERR << "[chuck](via STK): Saxofony: Control value less than zero!" << CK_STDENDL; |
| 14557 | } |
| 14558 | else if ( norm > 1.0 ) { |
| 14559 | norm = 1.0; |
| 14560 | CK_STDCERR << "[chuck](via STK): Saxofony: Control value exceeds nominal range!" << CK_STDENDL; |
| 14561 | } |
| 14562 | |
| 14563 | if (number == __SK_ReedStiffness_) { // 2 |
| 14564 | reedTable->setSlope( 0.1 + (0.4 * norm) ); |
| 14565 | m_stiffness = norm; |
| 14566 | } |
| 14567 | else if (number == __SK_NoiseLevel_) { // 4 |
| 14568 | noiseGain = ( norm * 0.4 ); |
| 14569 | m_noiseGain = norm; |
| 14570 | } |
| 14571 | else if (number == 29) // 29 |
| 14572 | vibrato->setFrequency( norm * 12.0 ); |
| 14573 | else if (number == __SK_ModWheel_) { // 1 |
| 14574 | vibratoGain = ( norm * 0.5 ); |
| 14575 | m_vibratoGain = norm; |
| 14576 | } |
| 14577 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 14578 | envelope->setValue( norm ); |
| 14579 | m_pressure = norm; |
| 14580 | } |
| 14581 | else if (number == 11) // 11 |
| 14582 | this->setBlowPosition( norm ); |
| 14583 | else if (number == 26) { // reed table offset |
| 14584 | reedTable->setOffset(0.4 + ( norm * 0.6)); |
| 14585 | m_aperture = norm; |
| 14586 | } |
| 14587 | else |
| 14588 | CK_STDCERR << "[chuck](via STK): Saxofony: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 14589 | |
| 14590 | #if defined(_STK_DEBUG_) |
| 14591 | CK_STDCERR << "[chuck](via STK): Saxofony: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 14592 | #endif |
| 14593 | |
| 14594 | } |
| 14595 | |
| 14596 | |
| 14597 | /***************************************************/ |
| 14598 | /*! \class Shakers |
| 14599 | \brief PhISEM and PhOLIES class. |
| 14600 | |
| 14601 | PhISEM (Physically Informed Stochastic Event |
| 14602 | Modeling) is an algorithmic approach for |
| 14603 | simulating collisions of multiple independent |
| 14604 | sound producing objects. This class is a |
| 14605 | meta-model that can simulate a Maraca, Sekere, |
| 14606 | Cabasa, Bamboo Wind Chimes, Water Drops, |
| 14607 | Tambourine, Sleighbells, and a Guiro. |
| 14608 | |
| 14609 | PhOLIES (Physically-Oriented Library of |
| 14610 | Imitated Environmental Sounds) is a similar |
| 14611 | approach for the synthesis of environmental |
| 14612 | sounds. This class implements simulations of |
| 14613 | breaking sticks, crunchy snow (or not), a |
| 14614 | wrench, sandpaper, and more. |
| 14615 | |
| 14616 | Control Change Numbers: |
| 14617 | - Shake Energy = 2 |
| 14618 | - System Decay = 4 |
| 14619 | - Number Of Objects = 11 |
| 14620 | - Resonance Frequency = 1 |
| 14621 | - Shake Energy = 128 |
| 14622 | - Instrument Selection = 1071 |
| 14623 | - Maraca = 0 |
| 14624 | - Cabasa = 1 |
| 14625 | - Sekere = 2 |
| 14626 | - Guiro = 3 |
| 14627 | - Water Drops = 4 |
| 14628 | - Bamboo Chimes = 5 |
| 14629 | - Tambourine = 6 |
| 14630 | - Sleigh Bells = 7 |
| 14631 | - Sticks = 8 |
| 14632 | - Crunch = 9 |
| 14633 | - Wrench = 10 |
| 14634 | - Sand Paper = 11 |
| 14635 | - Coke Can = 12 |
| 14636 | - Next Mug = 13 |
| 14637 | - Penny + Mug = 14 |
| 14638 | - Nickle + Mug = 15 |
| 14639 | - Dime + Mug = 16 |
| 14640 | - Quarter + Mug = 17 |
| 14641 | - Franc + Mug = 18 |
| 14642 | - Peso + Mug = 19 |
| 14643 | - Big Rocks = 20 |
| 14644 | - Little Rocks = 21 |
| 14645 | - Tuned Bamboo Chimes = 22 |
| 14646 | |
| 14647 | by Perry R. Cook, 1996 - 1999. |
| 14648 | */ |
| 14649 | /***************************************************/ |
| 14650 | |
| 14651 | #include <stdlib.h> |
| 14652 | #include <string.h> |
| 14653 | #include <math.h> |
| 14654 | |
| 14655 | int my_random(int max) // Return Random Int Between 0 and max |
| 14656 | { |
| 14657 | int temp = (int) ((float)max * rand() / (RAND_MAX + 1.0) ); |
| 14658 | return temp; |
| 14659 | } |
| 14660 | |
| 14661 | MY_FLOAT float_random(MY_FLOAT max) // Return random float between 0.0 and max |
| 14662 | { |
| 14663 | MY_FLOAT temp = (MY_FLOAT) (max * rand() / (RAND_MAX + 1.0) ); |
| 14664 | return temp; |
| 14665 | } |
| 14666 | |
| 14667 | MY_FLOAT noise_tick() // Return random MY_FLOAT float between -1.0 and 1.0 |
| 14668 | { |
| 14669 | MY_FLOAT temp = (MY_FLOAT) (2.0 * rand() / (RAND_MAX + 1.0) ); |
| 14670 | temp -= 1.0; |
| 14671 | return temp; |
| 14672 | } |
| 14673 | |
| 14674 | // Maraca |
| 14675 | #define MARA_SOUND_DECAY 0.95 |
| 14676 | #define MARA_SYSTEM_DECAY 0.999 |
| 14677 | #define MARA_GAIN 20.0 |
| 14678 | #define MARA_NUM_BEANS 25 |
| 14679 | #define MARA_CENTER_FREQ 3200.0 |
| 14680 | #define MARA_RESON 0.96 |
| 14681 | |
| 14682 | // Sekere |
| 14683 | #define SEKE_SOUND_DECAY 0.96 |
| 14684 | #define SEKE_SYSTEM_DECAY 0.999 |
| 14685 | #define SEKE_GAIN 20.0 |
| 14686 | #define SEKE_NUM_BEANS 64 |
| 14687 | #define SEKE_CENTER_FREQ 5500.0 |
| 14688 | #define SEKE_RESON 0.6 |
| 14689 | |
| 14690 | // Sandpaper |
| 14691 | #define SANDPAPR_SOUND_DECAY 0.999 |
| 14692 | #define SANDPAPR_SYSTEM_DECAY 0.999 |
| 14693 | #define SANDPAPR_GAIN 0.5 |
| 14694 | #define SANDPAPR_NUM_GRAINS 128 |
| 14695 | #define SANDPAPR_CENTER_FREQ 4500.0 |
| 14696 | #define SANDPAPR_RESON 0.6 |
| 14697 | |
| 14698 | // Cabasa |
| 14699 | #define CABA_SOUND_DECAY 0.96 |
| 14700 | #define CABA_SYSTEM_DECAY 0.997 |
| 14701 | #define CABA_GAIN 40.0 |
| 14702 | #define CABA_NUM_BEADS 512 |
| 14703 | #define CABA_CENTER_FREQ 3000.0 |
| 14704 | #define CABA_RESON 0.7 |
| 14705 | |
| 14706 | // Bamboo Wind Chimes |
| 14707 | #define BAMB_SOUND_DECAY 0.95 |
| 14708 | #define BAMB_SYSTEM_DECAY 0.9999 |
| 14709 | #define BAMB_GAIN 2.0 |
| 14710 | #define BAMB_NUM_TUBES 1.25 |
| 14711 | #define BAMB_CENTER_FREQ0 2800.0 |
| 14712 | #define BAMB_CENTER_FREQ1 0.8 * 2800.0 |
| 14713 | #define BAMB_CENTER_FREQ2 1.2 * 2800.0 |
| 14714 | #define BAMB_RESON 0.995 |
| 14715 | |
| 14716 | // Tuned Bamboo Wind Chimes (Anklung) |
| 14717 | #define TBAMB_SOUND_DECAY 0.95 |
| 14718 | #define TBAMB_SYSTEM_DECAY 0.9999 |
| 14719 | #define TBAMB_GAIN 1.0 |
| 14720 | #define TBAMB_NUM_TUBES 1.25 |
| 14721 | #define TBAMB_CENTER_FREQ0 1046.6 |
| 14722 | #define TBAMB_CENTER_FREQ1 1174.8 |
| 14723 | #define TBAMB_CENTER_FREQ2 1397.0 |
| 14724 | #define TBAMB_CENTER_FREQ3 1568.0 |
| 14725 | #define TBAMB_CENTER_FREQ4 1760.0 |
| 14726 | #define TBAMB_CENTER_FREQ5 2093.3 |
| 14727 | #define TBAMB_CENTER_FREQ6 2350.0 |
| 14728 | #define TBAMB_RESON 0.996 |
| 14729 | |
| 14730 | // Water Drops |
| 14731 | #define WUTR_SOUND_DECAY 0.95 |
| 14732 | #define WUTR_SYSTEM_DECAY 0.996 |
| 14733 | #define WUTR_GAIN 1.0 |
| 14734 | #define WUTR_NUM_SOURCES 10 |
| 14735 | #define WUTR_CENTER_FREQ0 450.0 |
| 14736 | #define WUTR_CENTER_FREQ1 600.0 |
| 14737 | #define WUTR_CENTER_FREQ2 750.0 |
| 14738 | #define WUTR_RESON 0.9985 |
| 14739 | #define WUTR_FREQ_SWEEP 1.0001 |
| 14740 | |
| 14741 | // Tambourine |
| 14742 | #define TAMB_SOUND_DECAY 0.95 |
| 14743 | #define TAMB_SYSTEM_DECAY 0.9985 |
| 14744 | #define TAMB_GAIN 5.0 |
| 14745 | #define TAMB_NUM_TIMBRELS 32 |
| 14746 | #define TAMB_SHELL_FREQ 2300 |
| 14747 | #define TAMB_SHELL_GAIN 0.1 |
| 14748 | #define TAMB_SHELL_RESON 0.96 |
| 14749 | #define TAMB_CYMB_FREQ1 5600 |
| 14750 | #define TAMB_CYMB_FREQ2 8100 |
| 14751 | #define TAMB_CYMB_RESON 0.99 |
| 14752 | |
| 14753 | // Sleighbells |
| 14754 | #define SLEI_SOUND_DECAY 0.97 |
| 14755 | #define SLEI_SYSTEM_DECAY 0.9994 |
| 14756 | #define SLEI_GAIN 1.0 |
| 14757 | #define SLEI_NUM_BELLS 32 |
| 14758 | #define SLEI_CYMB_FREQ0 2500 |
| 14759 | #define SLEI_CYMB_FREQ1 5300 |
| 14760 | #define SLEI_CYMB_FREQ2 6500 |
| 14761 | #define SLEI_CYMB_FREQ3 8300 |
| 14762 | #define SLEI_CYMB_FREQ4 9800 |
| 14763 | #define SLEI_CYMB_RESON 0.99 |
| 14764 | |
| 14765 | // Guiro |
| 14766 | #define GUIR_SOUND_DECAY 0.95 |
| 14767 | #define GUIR_GAIN 10.0 |
| 14768 | #define GUIR_NUM_PARTS 128 |
| 14769 | #define GUIR_GOURD_FREQ 2500.0 |
| 14770 | #define GUIR_GOURD_RESON 0.97 |
| 14771 | #define GUIR_GOURD_FREQ2 4000.0 |
| 14772 | #define GUIR_GOURD_RESON2 0.97 |
| 14773 | |
| 14774 | // Wrench |
| 14775 | #define WRENCH_SOUND_DECAY 0.95 |
| 14776 | #define WRENCH_GAIN 5 |
| 14777 | #define WRENCH_NUM_PARTS 128 |
| 14778 | #define WRENCH_FREQ 3200.0 |
| 14779 | #define WRENCH_RESON 0.99 |
| 14780 | #define WRENCH_FREQ2 8000.0 |
| 14781 | #define WRENCH_RESON2 0.992 |
| 14782 | |
| 14783 | // Cokecan |
| 14784 | #define COKECAN_SOUND_DECAY 0.97 |
| 14785 | #define COKECAN_SYSTEM_DECAY 0.999 |
| 14786 | #define COKECAN_GAIN 0.8 |
| 14787 | #define COKECAN_NUM_PARTS 48 |
| 14788 | #define COKECAN_HELMFREQ 370 |
| 14789 | #define COKECAN_HELM_RES 0.99 |
| 14790 | #define COKECAN_METLFREQ0 1025 |
| 14791 | #define COKECAN_METLFREQ1 1424 |
| 14792 | #define COKECAN_METLFREQ2 2149 |
| 14793 | #define COKECAN_METLFREQ3 3596 |
| 14794 | #define COKECAN_METL_RES 0.992 |
| 14795 | |
| 14796 | // PhOLIES (Physically-Oriented Library of Imitated Environmental |
| 14797 | // Sounds), Perry Cook, 1997-8 |
| 14798 | |
| 14799 | // Stix1 |
| 14800 | #define STIX1_SOUND_DECAY 0.96 |
| 14801 | #define STIX1_SYSTEM_DECAY 0.998 |
| 14802 | #define STIX1_GAIN 30.0 |
| 14803 | #define STIX1_NUM_BEANS 2 |
| 14804 | #define STIX1_CENTER_FREQ 5500.0 |
| 14805 | #define STIX1_RESON 0.6 |
| 14806 | |
| 14807 | // Crunch1 |
| 14808 | #define CRUNCH1_SOUND_DECAY 0.95 |
| 14809 | #define CRUNCH1_SYSTEM_DECAY 0.99806 |
| 14810 | #define CRUNCH1_GAIN 20.0 |
| 14811 | #define CRUNCH1_NUM_BEADS 7 |
| 14812 | #define CRUNCH1_CENTER_FREQ 800.0 |
| 14813 | #define CRUNCH1_RESON 0.95 |
| 14814 | |
| 14815 | // Nextmug |
| 14816 | #define NEXTMUG_SOUND_DECAY 0.97 |
| 14817 | #define NEXTMUG_SYSTEM_DECAY 0.9995 |
| 14818 | #define NEXTMUG_GAIN 0.8 |
| 14819 | #define NEXTMUG_NUM_PARTS 3 |
| 14820 | #define NEXTMUG_FREQ0 2123 |
| 14821 | #define NEXTMUG_FREQ1 4518 |
| 14822 | #define NEXTMUG_FREQ2 8856 |
| 14823 | #define NEXTMUG_FREQ3 10753 |
| 14824 | #define NEXTMUG_RES 0.997 |
| 14825 | |
| 14826 | #define PENNY_FREQ0 11000 |
| 14827 | #define PENNY_FREQ1 5200 |
| 14828 | #define PENNY_FREQ2 3835 |
| 14829 | #define PENNY_RES 0.999 |
| 14830 | |
| 14831 | #define NICKEL_FREQ0 5583 |
| 14832 | #define NICKEL_FREQ1 9255 |
| 14833 | #define NICKEL_FREQ2 9805 |
| 14834 | #define NICKEL_RES 0.9992 |
| 14835 | |
| 14836 | #define DIME_FREQ0 4450 |
| 14837 | #define DIME_FREQ1 4974 |
| 14838 | #define DIME_FREQ2 9945 |
| 14839 | #define DIME_RES 0.9993 |
| 14840 | |
| 14841 | #define QUARTER_FREQ0 1708 |
| 14842 | #define QUARTER_FREQ1 8863 |
| 14843 | #define QUARTER_FREQ2 9045 |
| 14844 | #define QUARTER_RES 0.9995 |
| 14845 | |
| 14846 | #define FRANC_FREQ0 5583 |
| 14847 | #define FRANC_FREQ1 11010 |
| 14848 | #define FRANC_FREQ2 1917 |
| 14849 | #define FRANC_RES 0.9995 |
| 14850 | |
| 14851 | #define PESO_FREQ0 7250 |
| 14852 | #define PESO_FREQ1 8150 |
| 14853 | #define PESO_FREQ2 10060 |
| 14854 | #define PESO_RES 0.9996 |
| 14855 | |
| 14856 | // Big Gravel |
| 14857 | #define BIGROCKS_SOUND_DECAY 0.98 |
| 14858 | #define BIGROCKS_SYSTEM_DECAY 0.9965 |
| 14859 | #define BIGROCKS_GAIN 20.0 |
| 14860 | #define BIGROCKS_NUM_PARTS 23 |
| 14861 | #define BIGROCKS_FREQ 6460 |
| 14862 | #define BIGROCKS_RES 0.932 |
| 14863 | |
| 14864 | // Little Gravel |
| 14865 | #define LITLROCKS_SOUND_DECAY 0.98 |
| 14866 | #define LITLROCKS_SYSTEM_DECAY 0.99586 |
| 14867 | #define LITLROCKS_GAIN 20.0 |
| 14868 | #define LITLROCKS_NUM_PARTS 1600 |
| 14869 | #define LITLROCKS_FREQ 9000 |
| 14870 | #define LITLROCKS_RES 0.843 |
| 14871 | |
| 14872 | // Finally ... the class code! |
| 14873 | |
| 14874 | |
| 14875 | Shakers :: Shakers() |
| 14876 | { |
| 14877 | int i; |
| 14878 | |
| 14879 | instType = 0; |
| 14880 | shakeEnergy = 0.0; |
| 14881 | nFreqs = 0; |
| 14882 | sndLevel = 0.0; |
| 14883 | |
| 14884 | for ( i=0; i<MAX_FREQS; i++ ) { |
| 14885 | inputs[i] = 0.0; |
| 14886 | outputs[i][0] = 0.0; |
| 14887 | outputs[i][1] = 0.0; |
| 14888 | coeffs[i][0] = 0.0; |
| 14889 | coeffs[i][1] = 0.0; |
| 14890 | gains[i] = 0.0; |
| 14891 | center_freqs[i] = 0.0; |
| 14892 | resons[i] = 0.0; |
| 14893 | freq_rand[i] = 0.0; |
| 14894 | freqalloc[i] = 0; |
| 14895 | } |
| 14896 | |
| 14897 | soundDecay = 0.0; |
| 14898 | systemDecay = 0.0; |
| 14899 | nObjects = 0.0; |
| 14900 | collLikely = 0.0; |
| 14901 | totalEnergy = 0.0; |
| 14902 | ratchet = 0.0; |
| 14903 | ratchetDelta = 0.0005; |
| 14904 | lastRatchetPos = 0; |
| 14905 | finalZ[0] = 0.0; |
| 14906 | finalZ[1] = 0.0; |
| 14907 | finalZ[2] = 0.0; |
| 14908 | finalZCoeffs[0] = 1.0; |
| 14909 | finalZCoeffs[1] = 0.0; |
| 14910 | finalZCoeffs[2] = 0.0; |
| 14911 | freq = 220.0; |
| 14912 | |
| 14913 | this->setupNum(instType); |
| 14914 | |
| 14915 | // chuck |
| 14916 | m_energy = totalEnergy; |
| 14917 | m_decay = systemDecay; |
| 14918 | m_objects = nObjects; |
| 14919 | } |
| 14920 | |
| 14921 | Shakers :: ~Shakers() |
| 14922 | { |
| 14923 | } |
| 14924 | |
| 14925 | #define MAX_SHAKE 2000.0 |
| 14926 | |
| 14927 | char instrs[NUM_INSTR][10] = { |
| 14928 | "Maraca", "Cabasa", "Sekere", "Guiro", |
| 14929 | "Waterdrp", "Bamboo", "Tambourn", "Sleighbl", |
| 14930 | "Stix1", "Crunch1", "Wrench", "SandPapr", |
| 14931 | "CokeCan", "NextMug", "PennyMug", "NicklMug", |
| 14932 | "DimeMug", "QuartMug", "FrancMug", "PesoMug", |
| 14933 | "BigRocks", "LitlRoks", "TBamboo" |
| 14934 | }; |
| 14935 | |
| 14936 | int Shakers :: setupName(char* instr) |
| 14937 | { |
| 14938 | int which = 0; |
| 14939 | |
| 14940 | for (int i=0;i<NUM_INSTR;i++) { |
| 14941 | if ( !strcmp(instr,instrs[i]) ) |
| 14942 | which = i; |
| 14943 | } |
| 14944 | |
| 14945 | #if defined(_STK_DEBUG_) |
| 14946 | CK_STDCERR << "[chuck](via STK): Shakers: Setting instrument to " << instrs[which] << CK_STDENDL; |
| 14947 | #endif |
| 14948 | |
| 14949 | return this->setupNum(which); |
| 14950 | } |
| 14951 | |
| 14952 | void Shakers :: setFinalZs(MY_FLOAT z0, MY_FLOAT z1, MY_FLOAT z2) { |
| 14953 | finalZCoeffs[0] = z0; |
| 14954 | finalZCoeffs[1] = z1; |
| 14955 | finalZCoeffs[2] = z2; |
| 14956 | } |
| 14957 | |
| 14958 | void Shakers :: setDecays(MY_FLOAT sndDecay, MY_FLOAT sysDecay) { |
| 14959 | soundDecay = sndDecay; |
| 14960 | systemDecay = sysDecay; |
| 14961 | } |
| 14962 | |
| 14963 | int Shakers :: setFreqAndReson(int which, MY_FLOAT theFreq, MY_FLOAT reson) { |
| 14964 | if (which < MAX_FREQS) { |
| 14965 | resons[which] = reson; |
| 14966 | center_freqs[which] = theFreq; |
| 14967 | t_center_freqs[which] = theFreq; |
| 14968 | coeffs[which][1] = reson * reson; |
| 14969 | coeffs[which][0] = -reson * 2.0 * cos(theFreq * CK_TWO_PI / Stk::sampleRate()); |
| 14970 | return 1; |
| 14971 | } |
| 14972 | else return 0; |
| 14973 | } |
| 14974 | |
| 14975 | int Shakers :: setupNum(int inst) |
| 14976 | { |
| 14977 | int i, rv = 0; |
| 14978 | MY_FLOAT temp; |
| 14979 | |
| 14980 | inst %= 23; // chuck hack |
| 14981 | if (inst == 1) { // Cabasa |
| 14982 | rv = inst; |
| 14983 | nObjects = CABA_NUM_BEADS; |
| 14984 | defObjs[inst] = CABA_NUM_BEADS; |
| 14985 | setDecays(CABA_SOUND_DECAY, CABA_SYSTEM_DECAY); |
| 14986 | defDecays[inst] = CABA_SYSTEM_DECAY; |
| 14987 | decayScale[inst] = 0.97; |
| 14988 | nFreqs = 1; |
| 14989 | baseGain = CABA_GAIN; |
| 14990 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 14991 | gains[0] = temp; |
| 14992 | freqalloc[0] = 0; |
| 14993 | setFreqAndReson(0,CABA_CENTER_FREQ,CABA_RESON); |
| 14994 | setFinalZs(1.0,-1.0,0.0); |
| 14995 | } |
| 14996 | else if (inst == 2) { // Sekere |
| 14997 | rv = inst; |
| 14998 | nObjects = SEKE_NUM_BEANS; |
| 14999 | defObjs[inst] = SEKE_NUM_BEANS; |
| 15000 | this->setDecays(SEKE_SOUND_DECAY,SEKE_SYSTEM_DECAY); |
| 15001 | defDecays[inst] = SEKE_SYSTEM_DECAY; |
| 15002 | decayScale[inst] = 0.94; |
| 15003 | nFreqs = 1; |
| 15004 | baseGain = SEKE_GAIN; |
| 15005 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15006 | gains[0] = temp; |
| 15007 | freqalloc[0] = 0; |
| 15008 | this->setFreqAndReson(0,SEKE_CENTER_FREQ,SEKE_RESON); |
| 15009 | this->setFinalZs(1.0, 0.0, -1.0); |
| 15010 | } |
| 15011 | else if (inst == 3) { // Guiro |
| 15012 | rv = inst; |
| 15013 | nObjects = GUIR_NUM_PARTS; |
| 15014 | defObjs[inst] = GUIR_NUM_PARTS; |
| 15015 | setDecays(GUIR_SOUND_DECAY,1.0); |
| 15016 | defDecays[inst] = 0.9999; |
| 15017 | decayScale[inst] = 1.0; |
| 15018 | nFreqs = 2; |
| 15019 | baseGain = GUIR_GAIN; |
| 15020 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15021 | gains[0]=temp; |
| 15022 | gains[1]=temp; |
| 15023 | freqalloc[0] = 0; |
| 15024 | freqalloc[1] = 0; |
| 15025 | freq_rand[0] = 0.0; |
| 15026 | freq_rand[1] = 0.0; |
| 15027 | setFreqAndReson(0,GUIR_GOURD_FREQ,GUIR_GOURD_RESON); |
| 15028 | setFreqAndReson(1,GUIR_GOURD_FREQ2,GUIR_GOURD_RESON2); |
| 15029 | ratchet = 0; |
| 15030 | ratchetPos = 10; |
| 15031 | } |
| 15032 | else if (inst == 4) { // Water Drops |
| 15033 | rv = inst; |
| 15034 | nObjects = WUTR_NUM_SOURCES; |
| 15035 | defObjs[inst] = WUTR_NUM_SOURCES; |
| 15036 | setDecays(WUTR_SOUND_DECAY,WUTR_SYSTEM_DECAY); |
| 15037 | defDecays[inst] = WUTR_SYSTEM_DECAY; |
| 15038 | decayScale[inst] = 0.8; |
| 15039 | nFreqs = 3; |
| 15040 | baseGain = WUTR_GAIN; |
| 15041 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15042 | gains[0]=temp; |
| 15043 | gains[1]=temp; |
| 15044 | gains[2]=temp; |
| 15045 | freqalloc[0] = 1; |
| 15046 | freqalloc[1] = 1; |
| 15047 | freqalloc[2] = 1; |
| 15048 | freq_rand[0] = 0.2; |
| 15049 | freq_rand[1] = 0.2; |
| 15050 | freq_rand[2] = 0.2; |
| 15051 | setFreqAndReson(0,WUTR_CENTER_FREQ0,WUTR_RESON); |
| 15052 | setFreqAndReson(1,WUTR_CENTER_FREQ0,WUTR_RESON); |
| 15053 | setFreqAndReson(2,WUTR_CENTER_FREQ0,WUTR_RESON); |
| 15054 | setFinalZs(1.0,0.0,0.0); |
| 15055 | } |
| 15056 | else if (inst == 5) { // Bamboo |
| 15057 | rv = inst; |
| 15058 | nObjects = BAMB_NUM_TUBES; |
| 15059 | defObjs[inst] = BAMB_NUM_TUBES; |
| 15060 | setDecays(BAMB_SOUND_DECAY, BAMB_SYSTEM_DECAY); |
| 15061 | defDecays[inst] = BAMB_SYSTEM_DECAY; |
| 15062 | decayScale[inst] = 0.7; |
| 15063 | nFreqs = 3; |
| 15064 | baseGain = BAMB_GAIN; |
| 15065 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15066 | gains[0]=temp; |
| 15067 | gains[1]=temp; |
| 15068 | gains[2]=temp; |
| 15069 | freqalloc[0] = 1; |
| 15070 | freqalloc[1] = 1; |
| 15071 | freqalloc[2] = 1; |
| 15072 | freq_rand[0] = 0.2; |
| 15073 | freq_rand[1] = 0.2; |
| 15074 | freq_rand[2] = 0.2; |
| 15075 | setFreqAndReson(0,BAMB_CENTER_FREQ0,BAMB_RESON); |
| 15076 | setFreqAndReson(1,BAMB_CENTER_FREQ1,BAMB_RESON); |
| 15077 | setFreqAndReson(2,BAMB_CENTER_FREQ2,BAMB_RESON); |
| 15078 | setFinalZs(1.0,0.0,0.0); |
| 15079 | } |
| 15080 | else if (inst == 6) { // Tambourine |
| 15081 | rv = inst; |
| 15082 | nObjects = TAMB_NUM_TIMBRELS; |
| 15083 | defObjs[inst] = TAMB_NUM_TIMBRELS; |
| 15084 | setDecays(TAMB_SOUND_DECAY,TAMB_SYSTEM_DECAY); |
| 15085 | defDecays[inst] = TAMB_SYSTEM_DECAY; |
| 15086 | decayScale[inst] = 0.95; |
| 15087 | nFreqs = 3; |
| 15088 | baseGain = TAMB_GAIN; |
| 15089 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15090 | gains[0]=temp*TAMB_SHELL_GAIN; |
| 15091 | gains[1]=temp*0.8; |
| 15092 | gains[2]=temp; |
| 15093 | freqalloc[0] = 0; |
| 15094 | freqalloc[1] = 1; |
| 15095 | freqalloc[2] = 1; |
| 15096 | freq_rand[0] = 0.0; |
| 15097 | freq_rand[1] = 0.05; |
| 15098 | freq_rand[2] = 0.05; |
| 15099 | setFreqAndReson(0,TAMB_SHELL_FREQ,TAMB_SHELL_RESON); |
| 15100 | setFreqAndReson(1,TAMB_CYMB_FREQ1,TAMB_CYMB_RESON); |
| 15101 | setFreqAndReson(2,TAMB_CYMB_FREQ2,TAMB_CYMB_RESON); |
| 15102 | setFinalZs(1.0,0.0,-1.0); |
| 15103 | } |
| 15104 | else if (inst == 7) { // Sleighbell |
| 15105 | rv = inst; |
| 15106 | nObjects = SLEI_NUM_BELLS; |
| 15107 | defObjs[inst] = SLEI_NUM_BELLS; |
| 15108 | setDecays(SLEI_SOUND_DECAY,SLEI_SYSTEM_DECAY); |
| 15109 | defDecays[inst] = SLEI_SYSTEM_DECAY; |
| 15110 | decayScale[inst] = 0.9; |
| 15111 | nFreqs = 5; |
| 15112 | baseGain = SLEI_GAIN; |
| 15113 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15114 | gains[0]=temp; |
| 15115 | gains[1]=temp; |
| 15116 | gains[2]=temp; |
| 15117 | gains[3]=temp*0.5; |
| 15118 | gains[4]=temp*0.3; |
| 15119 | for (i=0;i<nFreqs;i++) { |
| 15120 | freqalloc[i] = 1; |
| 15121 | freq_rand[i] = 0.03; |
| 15122 | } |
| 15123 | setFreqAndReson(0,SLEI_CYMB_FREQ0,SLEI_CYMB_RESON); |
| 15124 | setFreqAndReson(1,SLEI_CYMB_FREQ1,SLEI_CYMB_RESON); |
| 15125 | setFreqAndReson(2,SLEI_CYMB_FREQ2,SLEI_CYMB_RESON); |
| 15126 | setFreqAndReson(3,SLEI_CYMB_FREQ3,SLEI_CYMB_RESON); |
| 15127 | setFreqAndReson(4,SLEI_CYMB_FREQ4,SLEI_CYMB_RESON); |
| 15128 | setFinalZs(1.0,0.0,-1.0); |
| 15129 | } |
| 15130 | else if (inst == 8) { // Stix1 |
| 15131 | rv = inst; |
| 15132 | nObjects = STIX1_NUM_BEANS; |
| 15133 | defObjs[inst] = STIX1_NUM_BEANS; |
| 15134 | setDecays(STIX1_SOUND_DECAY,STIX1_SYSTEM_DECAY); |
| 15135 | defDecays[inst] = STIX1_SYSTEM_DECAY; |
| 15136 | |
| 15137 | decayScale[inst] = 0.96; |
| 15138 | nFreqs = 1; |
| 15139 | baseGain = STIX1_GAIN; |
| 15140 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15141 | gains[0]=temp; |
| 15142 | freqalloc[0] = 0; |
| 15143 | setFreqAndReson(0,STIX1_CENTER_FREQ,STIX1_RESON); |
| 15144 | setFinalZs(1.0,0.0,-1.0); |
| 15145 | } |
| 15146 | else if (inst == 9) { // Crunch1 |
| 15147 | rv = inst; |
| 15148 | nObjects = CRUNCH1_NUM_BEADS; |
| 15149 | defObjs[inst] = CRUNCH1_NUM_BEADS; |
| 15150 | setDecays(CRUNCH1_SOUND_DECAY,CRUNCH1_SYSTEM_DECAY); |
| 15151 | defDecays[inst] = CRUNCH1_SYSTEM_DECAY; |
| 15152 | decayScale[inst] = 0.96; |
| 15153 | nFreqs = 1; |
| 15154 | baseGain = CRUNCH1_GAIN; |
| 15155 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15156 | gains[0]=temp; |
| 15157 | freqalloc[0] = 0; |
| 15158 | setFreqAndReson(0,CRUNCH1_CENTER_FREQ,CRUNCH1_RESON); |
| 15159 | setFinalZs(1.0,-1.0,0.0); |
| 15160 | } |
| 15161 | else if (inst == 10) { // Wrench |
| 15162 | rv = inst; |
| 15163 | nObjects = WRENCH_NUM_PARTS; |
| 15164 | defObjs[inst] = WRENCH_NUM_PARTS; |
| 15165 | setDecays(WRENCH_SOUND_DECAY,1.0); |
| 15166 | defDecays[inst] = 0.9999; |
| 15167 | decayScale[inst] = 0.98; |
| 15168 | nFreqs = 2; |
| 15169 | baseGain = WRENCH_GAIN; |
| 15170 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15171 | gains[0]=temp; |
| 15172 | gains[1]=temp; |
| 15173 | freqalloc[0] = 0; |
| 15174 | freqalloc[1] = 0; |
| 15175 | freq_rand[0] = 0.0; |
| 15176 | freq_rand[1] = 0.0; |
| 15177 | setFreqAndReson(0,WRENCH_FREQ,WRENCH_RESON); |
| 15178 | setFreqAndReson(1,WRENCH_FREQ2,WRENCH_RESON2); |
| 15179 | ratchet = 0; |
| 15180 | ratchetPos = 10; |
| 15181 | } |
| 15182 | else if (inst == 11) { // Sandpapr |
| 15183 | rv = inst; |
| 15184 | nObjects = SANDPAPR_NUM_GRAINS; |
| 15185 | defObjs[inst] = SANDPAPR_NUM_GRAINS; |
| 15186 | this->setDecays(SANDPAPR_SOUND_DECAY,SANDPAPR_SYSTEM_DECAY); |
| 15187 | defDecays[inst] = SANDPAPR_SYSTEM_DECAY; |
| 15188 | decayScale[inst] = 0.97; |
| 15189 | nFreqs = 1; |
| 15190 | baseGain = SANDPAPR_GAIN; |
| 15191 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15192 | gains[0] = temp; |
| 15193 | freqalloc[0] = 0; |
| 15194 | this->setFreqAndReson(0,SANDPAPR_CENTER_FREQ,SANDPAPR_RESON); |
| 15195 | this->setFinalZs(1.0, 0.0, -1.0); |
| 15196 | } |
| 15197 | else if (inst == 12) { // Cokecan |
| 15198 | rv = inst; |
| 15199 | nObjects = COKECAN_NUM_PARTS; |
| 15200 | defObjs[inst] = COKECAN_NUM_PARTS; |
| 15201 | setDecays(COKECAN_SOUND_DECAY,COKECAN_SYSTEM_DECAY); |
| 15202 | defDecays[inst] = COKECAN_SYSTEM_DECAY; |
| 15203 | decayScale[inst] = 0.95; |
| 15204 | nFreqs = 5; |
| 15205 | baseGain = COKECAN_GAIN; |
| 15206 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15207 | gains[0]=temp; |
| 15208 | gains[1]=temp*1.8; |
| 15209 | gains[2]=temp*1.8; |
| 15210 | gains[3]=temp*1.8; |
| 15211 | gains[4]=temp*1.8; |
| 15212 | freqalloc[0] = 0; |
| 15213 | freqalloc[1] = 0; |
| 15214 | freqalloc[2] = 0; |
| 15215 | freqalloc[3] = 0; |
| 15216 | freqalloc[4] = 0; |
| 15217 | setFreqAndReson(0,COKECAN_HELMFREQ,COKECAN_HELM_RES); |
| 15218 | setFreqAndReson(1,COKECAN_METLFREQ0,COKECAN_METL_RES); |
| 15219 | setFreqAndReson(2,COKECAN_METLFREQ1,COKECAN_METL_RES); |
| 15220 | setFreqAndReson(3,COKECAN_METLFREQ2,COKECAN_METL_RES); |
| 15221 | setFreqAndReson(4,COKECAN_METLFREQ3,COKECAN_METL_RES); |
| 15222 | setFinalZs(1.0,0.0,-1.0); |
| 15223 | } |
| 15224 | else if (inst>12 && inst<20) { // Nextmug |
| 15225 | rv = inst; |
| 15226 | nObjects = NEXTMUG_NUM_PARTS; |
| 15227 | defObjs[inst] = NEXTMUG_NUM_PARTS; |
| 15228 | setDecays(NEXTMUG_SOUND_DECAY,NEXTMUG_SYSTEM_DECAY); |
| 15229 | defDecays[inst] = NEXTMUG_SYSTEM_DECAY; |
| 15230 | decayScale[inst] = 0.95; |
| 15231 | nFreqs = 4; |
| 15232 | baseGain = NEXTMUG_GAIN; |
| 15233 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15234 | gains[0]=temp; |
| 15235 | gains[1]=temp*0.8; |
| 15236 | gains[2]=temp*0.6; |
| 15237 | gains[3]=temp*0.4; |
| 15238 | freqalloc[0] = 0; |
| 15239 | freqalloc[1] = 0; |
| 15240 | freqalloc[2] = 0; |
| 15241 | freqalloc[3] = 0; |
| 15242 | freqalloc[4] = 0; |
| 15243 | freqalloc[5] = 0; |
| 15244 | setFreqAndReson(0,NEXTMUG_FREQ0,NEXTMUG_RES); |
| 15245 | setFreqAndReson(1,NEXTMUG_FREQ1,NEXTMUG_RES); |
| 15246 | setFreqAndReson(2,NEXTMUG_FREQ2,NEXTMUG_RES); |
| 15247 | setFreqAndReson(3,NEXTMUG_FREQ3,NEXTMUG_RES); |
| 15248 | setFinalZs(1.0,0.0,-1.0); |
| 15249 | |
| 15250 | if (inst == 14) { // Mug + Penny |
| 15251 | nFreqs = 7; |
| 15252 | gains[4] = temp; |
| 15253 | gains[5] = temp*0.8; |
| 15254 | gains[6] = temp*0.5; |
| 15255 | setFreqAndReson(4,PENNY_FREQ0,PENNY_RES); |
| 15256 | setFreqAndReson(5,PENNY_FREQ1,PENNY_RES); |
| 15257 | setFreqAndReson(6,PENNY_FREQ2,PENNY_RES); |
| 15258 | } |
| 15259 | else if (inst == 15) { // Mug + Nickel |
| 15260 | nFreqs = 6; |
| 15261 | gains[4] = temp; |
| 15262 | gains[5] = temp*0.8; |
| 15263 | gains[6] = temp*0.5; |
| 15264 | setFreqAndReson(4,NICKEL_FREQ0,NICKEL_RES); |
| 15265 | setFreqAndReson(5,NICKEL_FREQ1,NICKEL_RES); |
| 15266 | setFreqAndReson(6,NICKEL_FREQ2,NICKEL_RES); |
| 15267 | } |
| 15268 | else if (inst == 16) { // Mug + Dime |
| 15269 | nFreqs = 6; |
| 15270 | gains[4] = temp; |
| 15271 | gains[5] = temp*0.8; |
| 15272 | gains[6] = temp*0.5; |
| 15273 | setFreqAndReson(4,DIME_FREQ0,DIME_RES); |
| 15274 | setFreqAndReson(5,DIME_FREQ1,DIME_RES); |
| 15275 | setFreqAndReson(6,DIME_FREQ2,DIME_RES); |
| 15276 | } |
| 15277 | else if (inst == 17) { // Mug + Quarter |
| 15278 | nFreqs = 6; |
| 15279 | gains[4] = temp*1.3; |
| 15280 | gains[5] = temp*1.0; |
| 15281 | gains[6] = temp*0.8; |
| 15282 | setFreqAndReson(4,QUARTER_FREQ0,QUARTER_RES); |
| 15283 | setFreqAndReson(5,QUARTER_FREQ1,QUARTER_RES); |
| 15284 | setFreqAndReson(6,QUARTER_FREQ2,QUARTER_RES); |
| 15285 | } |
| 15286 | else if (inst == 18) { // Mug + Franc |
| 15287 | nFreqs = 6; |
| 15288 | gains[4] = temp*0.7; |
| 15289 | gains[5] = temp*0.4; |
| 15290 | gains[6] = temp*0.3; |
| 15291 | setFreqAndReson(4,FRANC_FREQ0,FRANC_RES); |
| 15292 | setFreqAndReson(5,FRANC_FREQ1,FRANC_RES); |
| 15293 | setFreqAndReson(6,FRANC_FREQ2,FRANC_RES); |
| 15294 | } |
| 15295 | else if (inst == 19) { // Mug + Peso |
| 15296 | nFreqs = 6; |
| 15297 | gains[4] = temp; |
| 15298 | gains[5] = temp*1.2; |
| 15299 | gains[6] = temp*0.7; |
| 15300 | setFreqAndReson(4,PESO_FREQ0,PESO_RES); |
| 15301 | setFreqAndReson(5,PESO_FREQ1,PESO_RES); |
| 15302 | setFreqAndReson(6,PESO_FREQ2,PESO_RES); |
| 15303 | } |
| 15304 | } |
| 15305 | else if (inst == 20) { // Big Rocks |
| 15306 | nFreqs = 1; |
| 15307 | rv = inst; |
| 15308 | nObjects = BIGROCKS_NUM_PARTS; |
| 15309 | defObjs[inst] = BIGROCKS_NUM_PARTS; |
| 15310 | setDecays(BIGROCKS_SOUND_DECAY,BIGROCKS_SYSTEM_DECAY); |
| 15311 | defDecays[inst] = BIGROCKS_SYSTEM_DECAY; |
| 15312 | decayScale[inst] = 0.95; |
| 15313 | baseGain = BIGROCKS_GAIN; |
| 15314 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15315 | gains[0]=temp; |
| 15316 | freqalloc[0] = 1; |
| 15317 | freq_rand[0] = 0.11; |
| 15318 | setFreqAndReson(0,BIGROCKS_FREQ,BIGROCKS_RES); |
| 15319 | setFinalZs(1.0,0.0,-1.0); |
| 15320 | } |
| 15321 | else if (inst == 21) { // Little Rocks |
| 15322 | nFreqs = 1; |
| 15323 | rv = inst; |
| 15324 | nObjects = LITLROCKS_NUM_PARTS; |
| 15325 | defObjs[inst] = LITLROCKS_NUM_PARTS; |
| 15326 | setDecays(LITLROCKS_SOUND_DECAY,LITLROCKS_SYSTEM_DECAY); |
| 15327 | defDecays[inst] = LITLROCKS_SYSTEM_DECAY; |
| 15328 | decayScale[inst] = 0.95; |
| 15329 | baseGain = LITLROCKS_GAIN; |
| 15330 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15331 | gains[0]=temp; |
| 15332 | freqalloc[0] = 1; |
| 15333 | freq_rand[0] = 0.18; |
| 15334 | setFreqAndReson(0,LITLROCKS_FREQ,LITLROCKS_RES); |
| 15335 | setFinalZs(1.0,0.0,-1.0); |
| 15336 | } |
| 15337 | else if (inst == 22) { // Tuned Bamboo |
| 15338 | rv = inst; |
| 15339 | nObjects = TBAMB_NUM_TUBES; |
| 15340 | defObjs[inst] = TBAMB_NUM_TUBES; |
| 15341 | setDecays(TBAMB_SOUND_DECAY, TBAMB_SYSTEM_DECAY); |
| 15342 | defDecays[inst] = TBAMB_SYSTEM_DECAY; |
| 15343 | decayScale[inst] = 0.7; |
| 15344 | nFreqs = 7; |
| 15345 | baseGain = TBAMB_GAIN; |
| 15346 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15347 | gains[0]=temp; |
| 15348 | gains[1]=temp; |
| 15349 | gains[2]=temp; |
| 15350 | gains[3]=temp; |
| 15351 | gains[4]=temp; |
| 15352 | gains[5]=temp; |
| 15353 | gains[6]=temp; |
| 15354 | freqalloc[0] = 0; |
| 15355 | freqalloc[1] = 0; |
| 15356 | freqalloc[2] = 0; |
| 15357 | freqalloc[3] = 0; |
| 15358 | freqalloc[4] = 0; |
| 15359 | freqalloc[5] = 0; |
| 15360 | freqalloc[6] = 0; |
| 15361 | freq_rand[0] = 0.0; |
| 15362 | freq_rand[1] = 0.0; |
| 15363 | freq_rand[2] = 0.0; |
| 15364 | freq_rand[3] = 0.0; |
| 15365 | freq_rand[4] = 0.0; |
| 15366 | freq_rand[5] = 0.0; |
| 15367 | freq_rand[6] = 0.0; |
| 15368 | setFreqAndReson(0,TBAMB_CENTER_FREQ0,TBAMB_RESON); |
| 15369 | setFreqAndReson(1,TBAMB_CENTER_FREQ1,TBAMB_RESON); |
| 15370 | setFreqAndReson(2,TBAMB_CENTER_FREQ2,TBAMB_RESON); |
| 15371 | setFreqAndReson(3,TBAMB_CENTER_FREQ3,TBAMB_RESON); |
| 15372 | setFreqAndReson(4,TBAMB_CENTER_FREQ4,TBAMB_RESON); |
| 15373 | setFreqAndReson(5,TBAMB_CENTER_FREQ5,TBAMB_RESON); |
| 15374 | setFreqAndReson(6,TBAMB_CENTER_FREQ6,TBAMB_RESON); |
| 15375 | setFinalZs(1.0,0.0,-1.0); |
| 15376 | } |
| 15377 | else { // Maraca (inst == 0) or default |
| 15378 | rv = 0; |
| 15379 | nObjects = MARA_NUM_BEANS; |
| 15380 | defObjs[0] = MARA_NUM_BEANS; |
| 15381 | setDecays(MARA_SOUND_DECAY,MARA_SYSTEM_DECAY); |
| 15382 | defDecays[0] = MARA_SYSTEM_DECAY; |
| 15383 | decayScale[inst] = 0.9; |
| 15384 | nFreqs = 1; |
| 15385 | baseGain = MARA_GAIN; |
| 15386 | temp = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15387 | gains[0]=temp; |
| 15388 | freqalloc[0] = 0; |
| 15389 | setFreqAndReson(0,MARA_CENTER_FREQ,MARA_RESON); |
| 15390 | setFinalZs(1.0,-1.0,0.0); |
| 15391 | } |
| 15392 | |
| 15393 | // chuck |
| 15394 | m_noteNum = inst; |
| 15395 | m_energy = totalEnergy; |
| 15396 | m_decay = systemDecay; |
| 15397 | m_objects = nObjects; |
| 15398 | |
| 15399 | return rv; |
| 15400 | } |
| 15401 | |
| 15402 | // chuck function! |
| 15403 | |
| 15404 | void Shakers :: ck_noteOn(MY_FLOAT amplitude ) { |
| 15405 | if (instType != m_noteNum) instType = this->setupNum(m_noteNum); |
| 15406 | shakeEnergy += amplitude * MAX_SHAKE * 0.1; |
| 15407 | if (shakeEnergy > MAX_SHAKE) shakeEnergy = MAX_SHAKE; |
| 15408 | if (instType==10 || instType==3) ratchetPos += 1; |
| 15409 | } |
| 15410 | |
| 15411 | void Shakers :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 15412 | { |
| 15413 | // Yep ... pretty kludgey, but it works! |
| 15414 | int noteNum = (int) ((12*log(frequency/220.0)/log(2.0)) + 57.01) % 32; |
| 15415 | m_noteNum = noteNum; |
| 15416 | if (instType != noteNum) instType = this->setupNum(noteNum); |
| 15417 | shakeEnergy += amplitude * MAX_SHAKE * 0.1; |
| 15418 | if (shakeEnergy > MAX_SHAKE) shakeEnergy = MAX_SHAKE; |
| 15419 | if (instType==10 || instType==3) ratchetPos += 1; |
| 15420 | |
| 15421 | #if defined(_STK_DEBUG_) |
| 15422 | CK_STDCERR << "[chuck](via STK): Shakers: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 15423 | #endif |
| 15424 | } |
| 15425 | |
| 15426 | void Shakers :: noteOff(MY_FLOAT amplitude) |
| 15427 | { |
| 15428 | shakeEnergy = 0.0; |
| 15429 | if (instType==10 || instType==3) ratchetPos = 0; |
| 15430 | } |
| 15431 | |
| 15432 | #define MIN_ENERGY 0.3 |
| 15433 | |
| 15434 | MY_FLOAT Shakers :: tick() |
| 15435 | { |
| 15436 | MY_FLOAT data; |
| 15437 | MY_FLOAT temp_rand; |
| 15438 | int i; |
| 15439 | |
| 15440 | if (instType == 4) { |
| 15441 | if (shakeEnergy > MIN_ENERGY) { |
| 15442 | lastOutput = wuter_tick(); |
| 15443 | lastOutput *= 0.0001; |
| 15444 | } |
| 15445 | else { |
| 15446 | lastOutput = 0.0; |
| 15447 | } |
| 15448 | } |
| 15449 | else if (instType == 22) { |
| 15450 | lastOutput = tbamb_tick(); |
| 15451 | } |
| 15452 | else if (instType == 10 || instType == 3) { |
| 15453 | if (ratchetPos > 0) { |
| 15454 | ratchet -= (ratchetDelta + (0.002*totalEnergy)); |
| 15455 | if (ratchet < 0.0) { |
| 15456 | ratchet = 1.0; |
| 15457 | ratchetPos -= 1; |
| 15458 | } |
| 15459 | totalEnergy = ratchet; |
| 15460 | lastOutput = ratchet_tick(); |
| 15461 | lastOutput *= 0.0001; |
| 15462 | } |
| 15463 | else lastOutput = 0.0; |
| 15464 | } |
| 15465 | else { |
| 15466 | // MY_FLOAT generic_tick() { |
| 15467 | if (shakeEnergy > MIN_ENERGY) { |
| 15468 | shakeEnergy *= systemDecay; // Exponential system decay |
| 15469 | if (float_random(1024.0) < nObjects) { |
| 15470 | sndLevel += shakeEnergy; |
| 15471 | for (i=0;i<nFreqs;i++) { |
| 15472 | if (freqalloc[i]) { |
| 15473 | temp_rand = t_center_freqs[i] * (1.0 + (freq_rand[i] * noise_tick())); |
| 15474 | coeffs[i][0] = -resons[i] * 2.0 * cos(temp_rand * CK_TWO_PI / Stk::sampleRate()); |
| 15475 | } |
| 15476 | } |
| 15477 | } |
| 15478 | inputs[0] = sndLevel * noise_tick(); // Actual Sound is Random |
| 15479 | for (i=1; i<nFreqs; i++) { |
| 15480 | inputs[i] = inputs[0]; |
| 15481 | } |
| 15482 | sndLevel *= soundDecay; // Exponential Sound decay |
| 15483 | finalZ[2] = finalZ[1]; |
| 15484 | finalZ[1] = finalZ[0]; |
| 15485 | finalZ[0] = 0; |
| 15486 | for (i=0;i<nFreqs;i++) { |
| 15487 | inputs[i] -= outputs[i][0]*coeffs[i][0]; // Do |
| 15488 | inputs[i] -= outputs[i][1]*coeffs[i][1]; // resonant |
| 15489 | outputs[i][1] = outputs[i][0]; // filter |
| 15490 | outputs[i][0] = inputs[i]; // calculations |
| 15491 | finalZ[0] += gains[i] * outputs[i][1]; |
| 15492 | } |
| 15493 | data = finalZCoeffs[0] * finalZ[0]; // Extra zero(s) for shape |
| 15494 | data += finalZCoeffs[1] * finalZ[1]; // Extra zero(s) for shape |
| 15495 | data += finalZCoeffs[2] * finalZ[2]; // Extra zero(s) for shape |
| 15496 | if (data > 10000.0) data = 10000.0; |
| 15497 | if (data < -10000.0) data = -10000.0; |
| 15498 | lastOutput = data * 0.0001; |
| 15499 | } |
| 15500 | else lastOutput = 0.0; |
| 15501 | } |
| 15502 | |
| 15503 | return lastOutput; |
| 15504 | } |
| 15505 | |
| 15506 | void Shakers :: controlChange(int number, MY_FLOAT value) |
| 15507 | { |
| 15508 | MY_FLOAT norm = value * ONE_OVER_128; |
| 15509 | if ( norm < 0 ) { |
| 15510 | norm = 0.0; |
| 15511 | CK_STDCERR << "[chuck](via STK): Shakers: Control value less than zero!" << CK_STDENDL; |
| 15512 | } |
| 15513 | else if ( norm > 1.0 ) { |
| 15514 | norm = 1.0; |
| 15515 | CK_STDCERR << "[chuck](via STK): Shakers: Control value exceeds nominal range!" << CK_STDENDL; |
| 15516 | } |
| 15517 | |
| 15518 | MY_FLOAT temp; |
| 15519 | int i; |
| 15520 | |
| 15521 | if (number == __SK_Breath_) { // 2 ... energy |
| 15522 | shakeEnergy += norm * MAX_SHAKE * 0.1; |
| 15523 | if (shakeEnergy > MAX_SHAKE) shakeEnergy = MAX_SHAKE; |
| 15524 | if (instType==10 || instType==3) { |
| 15525 | ratchetPos = (int) fabs(value - lastRatchetPos); |
| 15526 | ratchetDelta = 0.0002 * ratchetPos; |
| 15527 | lastRatchetPos = (int) value; |
| 15528 | } |
| 15529 | } |
| 15530 | // else if (number == __SK_ModFrequency_) { // 4 ... decay |
| 15531 | // CHUCK HACK: (actually this fixes things?) |
| 15532 | else if (number == __SK_FootControl_) { // 4 ... decay |
| 15533 | if (instType != 3 && instType != 10) { |
| 15534 | systemDecay = defDecays[instType] + ((value - 64.0) * |
| 15535 | decayScale[instType] * |
| 15536 | (1.0 - defDecays[instType]) / 64.0 ); |
| 15537 | gains[0] = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15538 | for (i=1;i<nFreqs;i++) gains[i] = gains[0]; |
| 15539 | if (instType == 6) { // tambourine |
| 15540 | gains[0] *= TAMB_SHELL_GAIN; |
| 15541 | gains[1] *= 0.8; |
| 15542 | } |
| 15543 | else if (instType == 7) { // sleighbell |
| 15544 | gains[3] *= 0.5; |
| 15545 | gains[4] *= 0.3; |
| 15546 | } |
| 15547 | else if (instType == 12) { // cokecan |
| 15548 | for (i=1;i<nFreqs;i++) gains[i] *= 1.8; |
| 15549 | } |
| 15550 | for (i=0;i<nFreqs;i++) gains[i] *= ((128-value)/100.0 + 0.36); |
| 15551 | } |
| 15552 | } |
| 15553 | // else if (number == __SK_FootControl_) { // 11 ... number of objects |
| 15554 | // CHUCK HACK: (actually this fixes things?) |
| 15555 | else if (number == __SK_Expression_) { // 11 ... number of objects |
| 15556 | if (instType == 5) // bamboo |
| 15557 | nObjects = (MY_FLOAT) (value * defObjs[instType] / 64.0) + 0.3; |
| 15558 | else |
| 15559 | nObjects = (MY_FLOAT) (value * defObjs[instType] / 64.0) + 1.1; |
| 15560 | gains[0] = log(nObjects) * baseGain / (MY_FLOAT) nObjects; |
| 15561 | for (i=1;i<nFreqs;i++) gains[i] = gains[0]; |
| 15562 | if (instType == 6) { // tambourine |
| 15563 | gains[0] *= TAMB_SHELL_GAIN; |
| 15564 | gains[1] *= 0.8; |
| 15565 | } |
| 15566 | else if (instType == 7) { // sleighbell |
| 15567 | gains[3] *= 0.5; |
| 15568 | gains[4] *= 0.3; |
| 15569 | } |
| 15570 | else if (instType == 12) { // cokecan |
| 15571 | for (i=1;i<nFreqs;i++) gains[i] *= 1.8; |
| 15572 | } |
| 15573 | if (instType != 3 && instType != 10) { |
| 15574 | // reverse calculate decay setting |
| 15575 | double temp2 = (double) (64.0 * (systemDecay-defDecays[instType])/(decayScale[instType]*(1-defDecays[instType])) + 64.0); |
| 15576 | // scale gains by decay setting |
| 15577 | for (i=0;i<nFreqs;i++) gains[i] *= ((128- temp2)/100.0 + 0.36); |
| 15578 | } |
| 15579 | } |
| 15580 | else if (number == __SK_ModWheel_) { // 1 ... resonance frequency |
| 15581 | for (i=0; i<nFreqs; i++) { |
| 15582 | if (instType == 6 || instType == 2 || instType == 7) // limit range a bit for tambourine |
| 15583 | temp = center_freqs[i] * pow (1.008,value-64); |
| 15584 | else |
| 15585 | temp = center_freqs[i] * pow (1.015,value-64); |
| 15586 | t_center_freqs[i] = temp; |
| 15587 | |
| 15588 | coeffs[i][0] = -resons[i] * 2.0 * cos(temp * CK_TWO_PI / Stk::sampleRate()); |
| 15589 | coeffs[i][1] = resons[i]*resons[i]; |
| 15590 | } |
| 15591 | } |
| 15592 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 15593 | shakeEnergy += norm * MAX_SHAKE * 0.1; |
| 15594 | if (shakeEnergy > MAX_SHAKE) shakeEnergy = MAX_SHAKE; |
| 15595 | if (instType==10 || instType==3) { |
| 15596 | ratchetPos = (int) fabs(value - lastRatchetPos); |
| 15597 | ratchetDelta = 0.0002 * ratchetPos; |
| 15598 | lastRatchetPos = (int) value; |
| 15599 | } |
| 15600 | } |
| 15601 | else if (number == __SK_ShakerInst_) { // 1071 |
| 15602 | instType = (int) (value + 0.5); // Just to be safe |
| 15603 | this->setupNum(instType); |
| 15604 | } |
| 15605 | else |
| 15606 | CK_STDCERR << "[chuck](via STK): Shakers: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 15607 | |
| 15608 | #if defined(_STK_DEBUG_) |
| 15609 | CK_STDCERR << "[chuck](via STK): Shakers: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 15610 | #endif |
| 15611 | } |
| 15612 | |
| 15613 | // KLUDGE-O-MATIC-O-RAMA |
| 15614 | |
| 15615 | MY_FLOAT Shakers :: wuter_tick() { |
| 15616 | MY_FLOAT data; |
| 15617 | int j; |
| 15618 | shakeEnergy *= systemDecay; // Exponential system decay |
| 15619 | if (my_random(32767) < nObjects) { |
| 15620 | sndLevel = shakeEnergy; |
| 15621 | j = my_random(3); |
| 15622 | if (j == 0) { |
| 15623 | center_freqs[0] = WUTR_CENTER_FREQ1 * (0.75 + (0.25 * noise_tick())); |
| 15624 | gains[0] = fabs(noise_tick()); |
| 15625 | } |
| 15626 | else if (j == 1) { |
| 15627 | center_freqs[1] = WUTR_CENTER_FREQ1 * (1.0 + (0.25 * noise_tick())); |
| 15628 | gains[1] = fabs(noise_tick()); |
| 15629 | } |
| 15630 | else { |
| 15631 | center_freqs[2] = WUTR_CENTER_FREQ1 * (1.25 + (0.25 * noise_tick())); |
| 15632 | gains[2] = fabs(noise_tick()); |
| 15633 | } |
| 15634 | } |
| 15635 | |
| 15636 | gains[0] *= resons[0]; |
| 15637 | if (gains[0] > 0.001) { |
| 15638 | center_freqs[0] *= WUTR_FREQ_SWEEP; |
| 15639 | coeffs[0][0] = -resons[0] * 2.0 * |
| 15640 | cos(center_freqs[0] * CK_TWO_PI / Stk::sampleRate()); |
| 15641 | } |
| 15642 | gains[1] *= resons[1]; |
| 15643 | if (gains[1] > 0.001) { |
| 15644 | center_freqs[1] *= WUTR_FREQ_SWEEP; |
| 15645 | coeffs[1][0] = -resons[1] * 2.0 * |
| 15646 | cos(center_freqs[1] * CK_TWO_PI / Stk::sampleRate()); |
| 15647 | } |
| 15648 | gains[2] *= resons[2]; |
| 15649 | if (gains[2] > 0.001) { |
| 15650 | center_freqs[2] *= WUTR_FREQ_SWEEP; |
| 15651 | coeffs[2][0] = -resons[2] * 2.0 * |
| 15652 | cos(center_freqs[2] * CK_TWO_PI / Stk::sampleRate()); |
| 15653 | } |
| 15654 | |
| 15655 | sndLevel *= soundDecay; // Each (all) event(s) |
| 15656 | // decay(s) exponentially |
| 15657 | inputs[0] = sndLevel; |
| 15658 | inputs[0] *= noise_tick(); // Actual Sound is Random |
| 15659 | inputs[1] = inputs[0] * gains[1]; |
| 15660 | inputs[2] = inputs[0] * gains[2]; |
| 15661 | inputs[0] *= gains[0]; |
| 15662 | inputs[0] -= outputs[0][0]*coeffs[0][0]; |
| 15663 | inputs[0] -= outputs[0][1]*coeffs[0][1]; |
| 15664 | outputs[0][1] = outputs[0][0]; |
| 15665 | outputs[0][0] = inputs[0]; |
| 15666 | data = gains[0]*outputs[0][0]; |
| 15667 | inputs[1] -= outputs[1][0]*coeffs[1][0]; |
| 15668 | inputs[1] -= outputs[1][1]*coeffs[1][1]; |
| 15669 | outputs[1][1] = outputs[1][0]; |
| 15670 | outputs[1][0] = inputs[1]; |
| 15671 | data += gains[1]*outputs[1][0]; |
| 15672 | inputs[2] -= outputs[2][0]*coeffs[2][0]; |
| 15673 | inputs[2] -= outputs[2][1]*coeffs[2][1]; |
| 15674 | outputs[2][1] = outputs[2][0]; |
| 15675 | outputs[2][0] = inputs[2]; |
| 15676 | data += gains[2]*outputs[2][0]; |
| 15677 | |
| 15678 | finalZ[2] = finalZ[1]; |
| 15679 | finalZ[1] = finalZ[0]; |
| 15680 | finalZ[0] = data * 4; |
| 15681 | |
| 15682 | data = finalZ[2] - finalZ[0]; |
| 15683 | return data; |
| 15684 | } |
| 15685 | |
| 15686 | MY_FLOAT Shakers :: ratchet_tick() { |
| 15687 | MY_FLOAT data; |
| 15688 | if (my_random(1024) < nObjects) { |
| 15689 | sndLevel += 512 * ratchet * totalEnergy; |
| 15690 | } |
| 15691 | inputs[0] = sndLevel; |
| 15692 | inputs[0] *= noise_tick() * ratchet; |
| 15693 | sndLevel *= soundDecay; |
| 15694 | |
| 15695 | inputs[1] = inputs[0]; |
| 15696 | inputs[0] -= outputs[0][0]*coeffs[0][0]; |
| 15697 | inputs[0] -= outputs[0][1]*coeffs[0][1]; |
| 15698 | outputs[0][1] = outputs[0][0]; |
| 15699 | outputs[0][0] = inputs[0]; |
| 15700 | inputs[1] -= outputs[1][0]*coeffs[1][0]; |
| 15701 | inputs[1] -= outputs[1][1]*coeffs[1][1]; |
| 15702 | outputs[1][1] = outputs[1][0]; |
| 15703 | outputs[1][0] = inputs[1]; |
| 15704 | |
| 15705 | finalZ[2] = finalZ[1]; |
| 15706 | finalZ[1] = finalZ[0]; |
| 15707 | finalZ[0] = gains[0]*outputs[0][1] + gains[1]*outputs[1][1]; |
| 15708 | data = finalZ[0] - finalZ[2]; |
| 15709 | return data; |
| 15710 | } |
| 15711 | |
| 15712 | MY_FLOAT Shakers :: tbamb_tick() { |
| 15713 | MY_FLOAT data, temp; |
| 15714 | static int which = 0; |
| 15715 | int i; |
| 15716 | |
| 15717 | if (shakeEnergy > MIN_ENERGY) { |
| 15718 | shakeEnergy *= systemDecay; // Exponential system decay |
| 15719 | if (float_random(1024.0) < nObjects) { |
| 15720 | sndLevel += shakeEnergy; |
| 15721 | which = my_random(7); |
| 15722 | } |
| 15723 | temp = sndLevel * noise_tick(); // Actual Sound is Random |
| 15724 | for (i=0;i<nFreqs;i++) inputs[i] = 0; |
| 15725 | inputs[which] = temp; |
| 15726 | sndLevel *= soundDecay; // Exponential Sound decay |
| 15727 | finalZ[2] = finalZ[1]; |
| 15728 | finalZ[1] = finalZ[0]; |
| 15729 | finalZ[0] = 0; |
| 15730 | for (i=0;i<nFreqs;i++) { |
| 15731 | inputs[i] -= outputs[i][0]*coeffs[i][0]; // Do |
| 15732 | inputs[i] -= outputs[i][1]*coeffs[i][1]; // resonant |
| 15733 | outputs[i][1] = outputs[i][0]; // filter |
| 15734 | outputs[i][0] = inputs[i]; // calculations |
| 15735 | finalZ[0] += gains[i] * outputs[i][1]; |
| 15736 | } |
| 15737 | data = finalZCoeffs[0] * finalZ[0]; // Extra zero(s) for shape |
| 15738 | data += finalZCoeffs[1] * finalZ[1]; // Extra zero(s) for shape |
| 15739 | data += finalZCoeffs[2] * finalZ[2]; // Extra zero(s) for shape |
| 15740 | if (data > 10000.0) data = 10000.0; |
| 15741 | if (data < -10000.0) data = -10000.0; |
| 15742 | data = data * 0.0001; |
| 15743 | } |
| 15744 | else data = 0.0; |
| 15745 | return data; |
| 15746 | } |
| 15747 | /***************************************************/ |
| 15748 | /*! \class Simple |
| 15749 | \brief STK wavetable/noise instrument. |
| 15750 | |
| 15751 | This class combines a looped wave, a |
| 15752 | noise source, a biquad resonance filter, |
| 15753 | a one-pole filter, and an ADSR envelope |
| 15754 | to create some interesting sounds. |
| 15755 | |
| 15756 | Control Change Numbers: |
| 15757 | - Filter Pole Position = 2 |
| 15758 | - Noise/Pitched Cross-Fade = 4 |
| 15759 | - Envelope Rate = 11 |
| 15760 | - Gain = 128 |
| 15761 | |
| 15762 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 15763 | */ |
| 15764 | /***************************************************/ |
| 15765 | |
| 15766 | |
| 15767 | Simple :: Simple() |
| 15768 | { |
| 15769 | adsr = new ADSR; |
| 15770 | baseFrequency = (MY_FLOAT) 440.0; |
| 15771 | |
| 15772 | // Concatenate the STK rawwave path to the rawwave file |
| 15773 | loop = new WaveLoop( "special:impuls10", TRUE ); |
| 15774 | |
| 15775 | filter = new OnePole(0.5); |
| 15776 | noise = new Noise; |
| 15777 | biquad = new BiQuad(); |
| 15778 | |
| 15779 | setFrequency(baseFrequency); |
| 15780 | loopGain = 0.5; |
| 15781 | } |
| 15782 | |
| 15783 | Simple :: ~Simple() |
| 15784 | { |
| 15785 | delete adsr; |
| 15786 | delete loop; |
| 15787 | delete filter; |
| 15788 | delete biquad; |
| 15789 | } |
| 15790 | |
| 15791 | void Simple :: keyOn() |
| 15792 | { |
| 15793 | adsr->keyOn(); |
| 15794 | } |
| 15795 | |
| 15796 | void Simple :: keyOff() |
| 15797 | { |
| 15798 | adsr->keyOff(); |
| 15799 | } |
| 15800 | |
| 15801 | void Simple :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 15802 | { |
| 15803 | keyOn(); |
| 15804 | setFrequency(frequency); |
| 15805 | filter->setGain(amplitude); |
| 15806 | |
| 15807 | #if defined(_STK_DEBUG_) |
| 15808 | CK_STDCERR << "[chuck](via STK): Simple: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 15809 | #endif |
| 15810 | } |
| 15811 | void Simple :: noteOff(MY_FLOAT amplitude) |
| 15812 | { |
| 15813 | keyOff(); |
| 15814 | |
| 15815 | #if defined(_STK_DEBUG_) |
| 15816 | CK_STDCERR << "[chuck](via STK): Simple: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 15817 | #endif |
| 15818 | } |
| 15819 | |
| 15820 | void Simple :: setFrequency(MY_FLOAT frequency) |
| 15821 | { |
| 15822 | biquad->setResonance( frequency, 0.98, true ); |
| 15823 | loop->setFrequency(frequency); |
| 15824 | |
| 15825 | // chuck |
| 15826 | m_frequency = frequency; |
| 15827 | } |
| 15828 | |
| 15829 | MY_FLOAT Simple :: tick() |
| 15830 | { |
| 15831 | lastOutput = loopGain * loop->tick(); |
| 15832 | biquad->tick( noise->tick() ); |
| 15833 | lastOutput += (1.0 - loopGain) * biquad->lastOut(); |
| 15834 | lastOutput = filter->tick( lastOutput ); |
| 15835 | lastOutput *= adsr->tick(); |
| 15836 | return lastOutput; |
| 15837 | } |
| 15838 | |
| 15839 | void Simple :: controlChange(int number, MY_FLOAT value) |
| 15840 | { |
| 15841 | MY_FLOAT norm = value * ONE_OVER_128; |
| 15842 | if ( norm < 0 ) { |
| 15843 | norm = 0.0; |
| 15844 | CK_STDCERR << "[chuck](via STK): Clarinet: Control value less than zero!" << CK_STDENDL; |
| 15845 | } |
| 15846 | else if ( norm > 1.0 ) { |
| 15847 | norm = 1.0; |
| 15848 | CK_STDCERR << "[chuck](via STK): Clarinet: Control value exceeds nominal range!" << CK_STDENDL; |
| 15849 | } |
| 15850 | |
| 15851 | if (number == __SK_Breath_) // 2 |
| 15852 | filter->setPole( 0.99 * (1.0 - (norm * 2.0)) ); |
| 15853 | else if (number == __SK_NoiseLevel_) // 4 |
| 15854 | loopGain = norm; |
| 15855 | else if (number == __SK_ModFrequency_) { // 11 |
| 15856 | norm /= 0.2 * Stk::sampleRate(); |
| 15857 | adsr->setAttackRate( norm ); |
| 15858 | adsr->setDecayRate( norm ); |
| 15859 | adsr->setReleaseRate( norm ); |
| 15860 | } |
| 15861 | else if (number == __SK_AfterTouch_Cont_) // 128 |
| 15862 | adsr->setTarget( norm ); |
| 15863 | else |
| 15864 | CK_STDCERR << "[chuck](via STK): Simple: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 15865 | |
| 15866 | #if defined(_STK_DEBUG_) |
| 15867 | CK_STDCERR << "[chuck](via STK): Simple: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 15868 | #endif |
| 15869 | } |
| 15870 | |
| 15871 | |
| 15872 | /***************************************************/ |
| 15873 | /*! \class SingWave |
| 15874 | \brief STK "singing" looped soundfile class. |
| 15875 | |
| 15876 | This class contains all that is needed to make |
| 15877 | a pitched musical sound, like a simple voice |
| 15878 | or violin. In general, it will not be used |
| 15879 | alone because of munchkinification effects |
| 15880 | from pitch shifting. It will be used as an |
| 15881 | excitation source for other instruments. |
| 15882 | |
| 15883 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 15884 | */ |
| 15885 | /***************************************************/ |
| 15886 | |
| 15887 | |
| 15888 | SingWave :: SingWave(const char *fileName, bool raw) |
| 15889 | { |
| 15890 | // An exception could be thrown here. |
| 15891 | wave = new WaveLoop( fileName, raw ); |
| 15892 | |
| 15893 | rate = 1.0; |
| 15894 | sweepRate = 0.001; |
| 15895 | modulator = new Modulate(); |
| 15896 | modulator->setVibratoRate( 6.0 ); |
| 15897 | modulator->setVibratoGain( 0.04 ); |
| 15898 | modulator->setRandomGain( 0.005 ); |
| 15899 | envelope = new Envelope; |
| 15900 | pitchEnvelope = new Envelope; |
| 15901 | setFrequency( 75.0 ); |
| 15902 | pitchEnvelope->setRate( 1.0 ); |
| 15903 | this->tick(); |
| 15904 | this->tick(); |
| 15905 | pitchEnvelope->setRate( sweepRate * rate ); |
| 15906 | } |
| 15907 | |
| 15908 | SingWave :: ~SingWave() |
| 15909 | { |
| 15910 | delete wave; |
| 15911 | delete modulator; |
| 15912 | delete envelope; |
| 15913 | delete pitchEnvelope; |
| 15914 | } |
| 15915 | |
| 15916 | void SingWave :: reset() |
| 15917 | { |
| 15918 | wave->reset(); |
| 15919 | lastOutput = 0.0; |
| 15920 | } |
| 15921 | |
| 15922 | void SingWave :: normalize() |
| 15923 | { |
| 15924 | wave->normalize(); |
| 15925 | } |
| 15926 | |
| 15927 | void SingWave :: normalize(MY_FLOAT newPeak) |
| 15928 | { |
| 15929 | wave->normalize( newPeak ); |
| 15930 | } |
| 15931 | |
| 15932 | void SingWave :: setFrequency(MY_FLOAT frequency) |
| 15933 | { |
| 15934 | m_freq = frequency; |
| 15935 | MY_FLOAT temp = rate; |
| 15936 | rate = wave->getSize() * frequency / Stk::sampleRate(); |
| 15937 | temp -= rate; |
| 15938 | if ( temp < 0) temp = -temp; |
| 15939 | pitchEnvelope->setTarget( rate ); |
| 15940 | pitchEnvelope->setRate( sweepRate * temp ); |
| 15941 | } |
| 15942 | |
| 15943 | void SingWave :: setVibratoRate(MY_FLOAT aRate) |
| 15944 | { |
| 15945 | modulator->setVibratoRate( aRate ); |
| 15946 | } |
| 15947 | |
| 15948 | void SingWave :: setVibratoGain(MY_FLOAT gain) |
| 15949 | { |
| 15950 | modulator->setVibratoGain(gain); |
| 15951 | } |
| 15952 | |
| 15953 | void SingWave :: setRandomGain(MY_FLOAT gain) |
| 15954 | { |
| 15955 | modulator->setRandomGain(gain); |
| 15956 | } |
| 15957 | |
| 15958 | void SingWave :: setSweepRate(MY_FLOAT aRate) |
| 15959 | { |
| 15960 | sweepRate = aRate; |
| 15961 | } |
| 15962 | |
| 15963 | void SingWave :: setGainRate(MY_FLOAT aRate) |
| 15964 | { |
| 15965 | envelope->setRate(aRate); |
| 15966 | } |
| 15967 | |
| 15968 | void SingWave :: setGainTarget(MY_FLOAT target) |
| 15969 | { |
| 15970 | envelope->setTarget(target); |
| 15971 | } |
| 15972 | |
| 15973 | void SingWave :: noteOn() |
| 15974 | { |
| 15975 | envelope->keyOn(); |
| 15976 | } |
| 15977 | |
| 15978 | void SingWave :: noteOff() |
| 15979 | { |
| 15980 | envelope->keyOff(); |
| 15981 | } |
| 15982 | |
| 15983 | MY_FLOAT SingWave :: tick() |
| 15984 | { |
| 15985 | // Set the wave rate. |
| 15986 | MY_FLOAT newRate = pitchEnvelope->tick(); |
| 15987 | newRate += newRate * modulator->tick(); |
| 15988 | wave->setRate( newRate ); |
| 15989 | |
| 15990 | lastOutput = wave->tick(); |
| 15991 | lastOutput *= envelope->tick(); |
| 15992 | |
| 15993 | return lastOutput; |
| 15994 | } |
| 15995 | |
| 15996 | MY_FLOAT SingWave :: lastOut() |
| 15997 | { |
| 15998 | return lastOutput; |
| 15999 | } |
| 16000 | /***************************************************/ |
| 16001 | /*! \class Sitar |
| 16002 | \brief STK sitar string model class. |
| 16003 | |
| 16004 | This class implements a sitar plucked string |
| 16005 | physical model based on the Karplus-Strong |
| 16006 | algorithm. |
| 16007 | |
| 16008 | This is a digital waveguide model, making its |
| 16009 | use possibly subject to patents held by |
| 16010 | Stanford University, Yamaha, and others. |
| 16011 | There exist at least two patents, assigned to |
| 16012 | Stanford, bearing the names of Karplus and/or |
| 16013 | Strong. |
| 16014 | |
| 16015 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 16016 | */ |
| 16017 | /***************************************************/ |
| 16018 | |
| 16019 | #include <math.h> |
| 16020 | |
| 16021 | Sitar :: Sitar(MY_FLOAT lowestFrequency) |
| 16022 | { |
| 16023 | length = (long) (Stk::sampleRate() / lowestFrequency + 1); |
| 16024 | loopGain = (MY_FLOAT) 0.999; |
| 16025 | delayLine = new DelayA( (MY_FLOAT)(length / 2.0), length ); |
| 16026 | delay = length / 2.0; |
| 16027 | targetDelay = delay; |
| 16028 | |
| 16029 | loopFilter = new OneZero; |
| 16030 | loopFilter->setZero(0.01); |
| 16031 | |
| 16032 | envelope = new ADSR(); |
| 16033 | envelope->setAllTimes(0.001, 0.04, 0.0, 0.5); |
| 16034 | |
| 16035 | noise = new Noise; |
| 16036 | this->clear(); |
| 16037 | } |
| 16038 | |
| 16039 | Sitar :: ~Sitar() |
| 16040 | { |
| 16041 | delete delayLine; |
| 16042 | delete loopFilter; |
| 16043 | delete noise; |
| 16044 | delete envelope; |
| 16045 | } |
| 16046 | |
| 16047 | void Sitar :: clear() |
| 16048 | { |
| 16049 | delayLine->clear(); |
| 16050 | loopFilter->clear(); |
| 16051 | } |
| 16052 | |
| 16053 | void Sitar :: setFrequency(MY_FLOAT frequency) |
| 16054 | { |
| 16055 | MY_FLOAT freakency = frequency; |
| 16056 | if ( frequency <= 0.0 ) { |
| 16057 | CK_STDCERR << "[chuck](via STK): Sitar: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 16058 | freakency = 220.0; |
| 16059 | } |
| 16060 | |
| 16061 | targetDelay = (Stk::sampleRate() / freakency); |
| 16062 | delay = targetDelay * (1.0 + (0.05 * noise->tick())); |
| 16063 | delayLine->setDelay(delay); |
| 16064 | loopGain = 0.995 + (freakency * 0.0000005); |
| 16065 | if (loopGain > 0.9995) loopGain = 0.9995; |
| 16066 | |
| 16067 | // chuck |
| 16068 | m_frequency = freakency; |
| 16069 | } |
| 16070 | |
| 16071 | void Sitar :: pluck(MY_FLOAT amplitude) |
| 16072 | { |
| 16073 | envelope->keyOn(); |
| 16074 | } |
| 16075 | |
| 16076 | void Sitar :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 16077 | { |
| 16078 | setFrequency(frequency); |
| 16079 | pluck(amplitude); |
| 16080 | amGain = 0.1 * amplitude; |
| 16081 | |
| 16082 | #if defined(_STK_DEBUG_) |
| 16083 | CK_STDCERR << "[chuck](via STK): Sitar: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 16084 | #endif |
| 16085 | } |
| 16086 | |
| 16087 | void Sitar :: noteOff(MY_FLOAT amplitude) |
| 16088 | { |
| 16089 | loopGain = (MY_FLOAT) 1.0 - amplitude; |
| 16090 | if ( loopGain < 0.0 ) { |
| 16091 | CK_STDCERR << "[chuck](via STK): Plucked: noteOff amplitude greater than 1.0!" << CK_STDENDL; |
| 16092 | loopGain = 0.0; |
| 16093 | } |
| 16094 | else if ( loopGain > 1.0 ) { |
| 16095 | CK_STDCERR << "[chuck](via STK): Plucked: noteOff amplitude less than or zero!" << CK_STDENDL; |
| 16096 | loopGain = (MY_FLOAT) 0.99999; |
| 16097 | } |
| 16098 | |
| 16099 | #if defined(_STK_DEBUG_) |
| 16100 | CK_STDCERR << "[chuck](via STK): Plucked: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 16101 | #endif |
| 16102 | } |
| 16103 | |
| 16104 | MY_FLOAT Sitar :: tick() |
| 16105 | { |
| 16106 | if ( fabs(targetDelay - delay) > 0.001 ) { |
| 16107 | if (targetDelay < delay) |
| 16108 | delay *= 0.99999; |
| 16109 | else |
| 16110 | delay *= 1.00001; |
| 16111 | delayLine->setDelay(delay); |
| 16112 | } |
| 16113 | |
| 16114 | lastOutput = delayLine->tick( loopFilter->tick( delayLine->lastOut() * loopGain ) + |
| 16115 | (amGain * envelope->tick() * noise->tick())); |
| 16116 | |
| 16117 | return lastOutput; |
| 16118 | } |
| 16119 | /***************************************************/ |
| 16120 | /*! \class Sphere |
| 16121 | \brief STK sphere class. |
| 16122 | |
| 16123 | This class implements a spherical ball with |
| 16124 | radius, mass, position, and velocity parameters. |
| 16125 | |
| 16126 | by Perry R. Cook, 1995 - 2002. |
| 16127 | */ |
| 16128 | /***************************************************/ |
| 16129 | |
| 16130 | #include <stdio.h> |
| 16131 | #include <math.h> |
| 16132 | |
| 16133 | Sphere::Sphere(double initRadius) |
| 16134 | { |
| 16135 | myRadius = initRadius; |
| 16136 | myMass = 1.0; |
| 16137 | myPosition = new Vector3D(0, 0, 0); |
| 16138 | myVelocity = new Vector3D(0, 0, 0); |
| 16139 | }; |
| 16140 | |
| 16141 | Sphere::~Sphere() |
| 16142 | { |
| 16143 | delete myPosition; |
| 16144 | delete myVelocity; |
| 16145 | } |
| 16146 | |
| 16147 | void Sphere::setPosition(double anX, double aY, double aZ) |
| 16148 | { |
| 16149 | myPosition->setXYZ(anX, aY, aZ); |
| 16150 | }; |
| 16151 | |
| 16152 | void Sphere::setVelocity(double anX, double aY, double aZ) |
| 16153 | { |
| 16154 | myVelocity->setXYZ(anX, aY, aZ); |
| 16155 | }; |
| 16156 | |
| 16157 | void Sphere::setRadius(double aRadius) |
| 16158 | { |
| 16159 | myRadius = aRadius; |
| 16160 | }; |
| 16161 | |
| 16162 | void Sphere::setMass(double aMass) |
| 16163 | { |
| 16164 | myMass = aMass; |
| 16165 | }; |
| 16166 | |
| 16167 | Vector3D* Sphere::getPosition() |
| 16168 | { |
| 16169 | return myPosition; |
| 16170 | }; |
| 16171 | |
| 16172 | Vector3D* Sphere::getRelativePosition(Vector3D* aPosition) |
| 16173 | { |
| 16174 | workingVector.setXYZ(aPosition->getX() - myPosition->getX(), |
| 16175 | aPosition->getY() - myPosition->getY(), |
| 16176 | aPosition->getZ() - myPosition->getZ()); |
| 16177 | return &workingVector; |
| 16178 | }; |
| 16179 | |
| 16180 | double Sphere::getVelocity(Vector3D* aVelocity) |
| 16181 | { |
| 16182 | aVelocity->setXYZ(myVelocity->getX(), myVelocity->getY(), myVelocity->getZ()); |
| 16183 | return myVelocity->getLength(); |
| 16184 | }; |
| 16185 | |
| 16186 | double Sphere::isInside(Vector3D *aPosition) |
| 16187 | { |
| 16188 | // Return directed distance from aPosition to spherical boundary ( < |
| 16189 | // 0 if inside). |
| 16190 | double distance; |
| 16191 | Vector3D *tempVector; |
| 16192 | |
| 16193 | tempVector = this->getRelativePosition(aPosition); |
| 16194 | distance = tempVector->getLength(); |
| 16195 | return distance - myRadius; |
| 16196 | }; |
| 16197 | |
| 16198 | double Sphere::getRadius() |
| 16199 | { |
| 16200 | return myRadius; |
| 16201 | }; |
| 16202 | |
| 16203 | double Sphere::getMass() |
| 16204 | { |
| 16205 | return myMass; |
| 16206 | }; |
| 16207 | |
| 16208 | void Sphere::addVelocity(double anX, double aY, double aZ) |
| 16209 | { |
| 16210 | myVelocity->setX(myVelocity->getX() + anX); |
| 16211 | myVelocity->setY(myVelocity->getY() + aY); |
| 16212 | myVelocity->setZ(myVelocity->getZ() + aZ); |
| 16213 | } |
| 16214 | |
| 16215 | void Sphere::tick(double timeIncrement) |
| 16216 | { |
| 16217 | myPosition->setX(myPosition->getX() + (timeIncrement * myVelocity->getX())); |
| 16218 | myPosition->setY(myPosition->getY() + (timeIncrement * myVelocity->getY())); |
| 16219 | myPosition->setZ(myPosition->getZ() + (timeIncrement * myVelocity->getZ())); |
| 16220 | }; |
| 16221 | |
| 16222 | /***************************************************/ |
| 16223 | /*! \class StifKarp |
| 16224 | \brief STK plucked stiff string instrument. |
| 16225 | |
| 16226 | This class implements a simple plucked string |
| 16227 | algorithm (Karplus Strong) with enhancements |
| 16228 | (Jaffe-Smith, Smith, and others), including |
| 16229 | string stiffness and pluck position controls. |
| 16230 | The stiffness is modeled with allpass filters. |
| 16231 | |
| 16232 | This is a digital waveguide model, making its |
| 16233 | use possibly subject to patents held by |
| 16234 | Stanford University, Yamaha, and others. |
| 16235 | |
| 16236 | Control Change Numbers: |
| 16237 | - Pickup Position = 4 |
| 16238 | - String Sustain = 11 |
| 16239 | - String Stretch = 1 |
| 16240 | |
| 16241 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 16242 | */ |
| 16243 | /***************************************************/ |
| 16244 | |
| 16245 | #include <string.h> |
| 16246 | #include <math.h> |
| 16247 | |
| 16248 | StifKarp :: StifKarp(MY_FLOAT lowestFrequency) |
| 16249 | { |
| 16250 | length = (long) (Stk::sampleRate() / lowestFrequency + 1); |
| 16251 | delayLine = new DelayA(0.5 * length, length); |
| 16252 | combDelay = new DelayL( 0.2 * length, length); |
| 16253 | |
| 16254 | filter = new OneZero(); |
| 16255 | noise = new Noise(); |
| 16256 | biQuad[0] = new BiQuad(); |
| 16257 | biQuad[1] = new BiQuad(); |
| 16258 | biQuad[2] = new BiQuad(); |
| 16259 | biQuad[3] = new BiQuad(); |
| 16260 | |
| 16261 | pluckAmplitude = 0.3; |
| 16262 | pickupPosition = (MY_FLOAT) 0.4; |
| 16263 | lastFrequency = lowestFrequency * 2.0; |
| 16264 | lastLength = length * 0.5; |
| 16265 | stretching = 0.9999; |
| 16266 | baseLoopGain = 0.995; |
| 16267 | loopGain = 0.999; |
| 16268 | |
| 16269 | clear(); |
| 16270 | } |
| 16271 | |
| 16272 | StifKarp :: ~StifKarp() |
| 16273 | { |
| 16274 | delete delayLine; |
| 16275 | delete combDelay; |
| 16276 | delete filter; |
| 16277 | delete noise; |
| 16278 | delete biQuad[0]; |
| 16279 | delete biQuad[1]; |
| 16280 | delete biQuad[2]; |
| 16281 | delete biQuad[3]; |
| 16282 | } |
| 16283 | |
| 16284 | void StifKarp :: clear() |
| 16285 | { |
| 16286 | delayLine->clear(); |
| 16287 | combDelay->clear(); |
| 16288 | filter->clear(); |
| 16289 | } |
| 16290 | |
| 16291 | void StifKarp :: setFrequency(MY_FLOAT frequency) |
| 16292 | { |
| 16293 | lastFrequency = frequency; |
| 16294 | if ( frequency <= 0.0 ) { |
| 16295 | CK_STDCERR << "[chuck](via STK): StifKarp: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 16296 | lastFrequency = 220.0; |
| 16297 | } |
| 16298 | |
| 16299 | lastLength = Stk::sampleRate() / lastFrequency; |
| 16300 | MY_FLOAT delay = lastLength - 0.5; |
| 16301 | if (delay <= 0.0) delay = 0.3; |
| 16302 | else if (delay > length) delay = length; |
| 16303 | delayLine->setDelay( delay ); |
| 16304 | |
| 16305 | loopGain = baseLoopGain + (frequency * (MY_FLOAT) 0.000005); |
| 16306 | if (loopGain >= 1.0) loopGain = (MY_FLOAT) 0.99999; |
| 16307 | |
| 16308 | setStretch(stretching); |
| 16309 | |
| 16310 | combDelay->setDelay((MY_FLOAT) 0.5 * pickupPosition * lastLength); |
| 16311 | |
| 16312 | // chuck |
| 16313 | m_frequency = lastFrequency; |
| 16314 | } |
| 16315 | |
| 16316 | void StifKarp :: setStretch(MY_FLOAT stretch) |
| 16317 | { |
| 16318 | stretching = stretch; |
| 16319 | MY_FLOAT coefficient; |
| 16320 | MY_FLOAT freq = lastFrequency * 2.0; |
| 16321 | MY_FLOAT dFreq = ( (0.5 * Stk::sampleRate()) - freq ) * 0.25; |
| 16322 | MY_FLOAT temp = 0.5 + (stretch * 0.5); |
| 16323 | if (temp > 0.9999) temp = 0.9999; |
| 16324 | for (int i=0; i<4; i++) { |
| 16325 | coefficient = temp * temp; |
| 16326 | biQuad[i]->setA2( coefficient ); |
| 16327 | biQuad[i]->setB0( coefficient ); |
| 16328 | biQuad[i]->setB2( 1.0 ); |
| 16329 | |
| 16330 | coefficient = -2.0 * temp * cos(CK_TWO_PI * freq / Stk::sampleRate()); |
| 16331 | biQuad[i]->setA1( coefficient ); |
| 16332 | biQuad[i]->setB1( coefficient ); |
| 16333 | |
| 16334 | freq += dFreq; |
| 16335 | } |
| 16336 | } |
| 16337 | |
| 16338 | void StifKarp :: setPickupPosition(MY_FLOAT position) { |
| 16339 | pickupPosition = position; |
| 16340 | if ( position < 0.0 ) { |
| 16341 | CK_STDCERR << "[chuck](via STK): StifKarp: setPickupPosition parameter is less than zero!" << CK_STDENDL; |
| 16342 | pickupPosition = 0.0; |
| 16343 | } |
| 16344 | else if ( position > 1.0 ) { |
| 16345 | CK_STDCERR << "[chuck](via STK): StifKarp: setPickupPosition parameter is greater than 1.0!" << CK_STDENDL; |
| 16346 | pickupPosition = 1.0; |
| 16347 | } |
| 16348 | |
| 16349 | // Set the pick position, which puts zeroes at position * length. |
| 16350 | combDelay->setDelay(0.5 * pickupPosition * lastLength); |
| 16351 | } |
| 16352 | |
| 16353 | void StifKarp :: setBaseLoopGain(MY_FLOAT aGain) |
| 16354 | { |
| 16355 | baseLoopGain = aGain; |
| 16356 | loopGain = baseLoopGain + (lastFrequency * 0.000005); |
| 16357 | if ( loopGain > 0.99999 ) loopGain = (MY_FLOAT) 0.99999; |
| 16358 | } |
| 16359 | |
| 16360 | void StifKarp :: pluck(MY_FLOAT amplitude) |
| 16361 | { |
| 16362 | MY_FLOAT gain = amplitude; |
| 16363 | if ( gain > 1.0 ) { |
| 16364 | CK_STDCERR << "[chuck](via STK): StifKarp: pluck amplitude greater than 1.0!" << CK_STDENDL; |
| 16365 | gain = 1.0; |
| 16366 | } |
| 16367 | else if ( gain < 0.0 ) { |
| 16368 | CK_STDCERR << "[chuck](via STK): StifKarp: pluck amplitude less than zero!" << CK_STDENDL; |
| 16369 | gain = 0.0; |
| 16370 | } |
| 16371 | |
| 16372 | pluckAmplitude = amplitude; |
| 16373 | for (long i=0; i<length; i++) { |
| 16374 | // Fill delay with noise additively with current contents. |
| 16375 | delayLine->tick((delayLine->lastOut() * 0.6) + 0.4 * noise->tick() * pluckAmplitude); |
| 16376 | //delayLine->tick( combDelay->tick((delayLine->lastOut() * 0.6) + 0.4 * noise->tick() * pluckAmplitude)); |
| 16377 | } |
| 16378 | } |
| 16379 | |
| 16380 | void StifKarp :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 16381 | { |
| 16382 | this->setFrequency(frequency); |
| 16383 | this->pluck(amplitude); |
| 16384 | |
| 16385 | #if defined(_STK_DEBUG_) |
| 16386 | CK_STDCERR << "[chuck](via STK): StifKarp: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 16387 | #endif |
| 16388 | } |
| 16389 | |
| 16390 | void StifKarp :: noteOff(MY_FLOAT amplitude) |
| 16391 | { |
| 16392 | MY_FLOAT gain = amplitude; |
| 16393 | if ( gain > 1.0 ) { |
| 16394 | CK_STDCERR << "[chuck](via STK): StifKarp: noteOff amplitude greater than 1.0!" << CK_STDENDL; |
| 16395 | gain = 1.0; |
| 16396 | } |
| 16397 | else if ( gain < 0.0 ) { |
| 16398 | CK_STDCERR << "[chuck](via STK): StifKarp: noteOff amplitude less than zero!" << CK_STDENDL; |
| 16399 | gain = 0.0; |
| 16400 | } |
| 16401 | loopGain = (1.0 - gain) * 0.5; |
| 16402 | |
| 16403 | #if defined(_STK_DEBUG_) |
| 16404 | CK_STDCERR << "[chuck](via STK): StifPluck: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 16405 | #endif |
| 16406 | } |
| 16407 | |
| 16408 | MY_FLOAT StifKarp :: tick() |
| 16409 | { |
| 16410 | MY_FLOAT temp = delayLine->lastOut() * loopGain; |
| 16411 | |
| 16412 | // Calculate allpass stretching. |
| 16413 | for (int i=0; i<4; i++) |
| 16414 | temp = biQuad[i]->tick(temp); |
| 16415 | |
| 16416 | // Moving average filter. |
| 16417 | temp = filter->tick(temp); |
| 16418 | |
| 16419 | lastOutput = delayLine->tick(temp); |
| 16420 | lastOutput = lastOutput - combDelay->tick(lastOutput); |
| 16421 | return lastOutput; |
| 16422 | } |
| 16423 | |
| 16424 | void StifKarp :: controlChange(int number, MY_FLOAT value) |
| 16425 | { |
| 16426 | MY_FLOAT norm = value * ONE_OVER_128; |
| 16427 | if ( norm < 0 ) { |
| 16428 | norm = 0.0; |
| 16429 | CK_STDCERR << "[chuck](via STK): StifKarp: Control value less than zero!" << CK_STDENDL; |
| 16430 | } |
| 16431 | else if ( norm > 1.0 ) { |
| 16432 | norm = 1.0; |
| 16433 | CK_STDCERR << "[chuck](via STK): StifKarp: Control value exceeds nominal range!" << CK_STDENDL; |
| 16434 | } |
| 16435 | |
| 16436 | if (number == __SK_PickPosition_) // 4 |
| 16437 | setPickupPosition( norm ); |
| 16438 | else if (number == __SK_StringDamping_) { // 11 |
| 16439 | setBaseLoopGain( 0.97 + (norm * 0.03) ); |
| 16440 | m_sustain = norm; |
| 16441 | } |
| 16442 | else if (number == __SK_StringDetune_) // 1 |
| 16443 | setStretch( 0.9 + (0.1 * (1.0 - norm)) ); |
| 16444 | else |
| 16445 | CK_STDCERR << "[chuck](via STK): StifKarp: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 16446 | |
| 16447 | #if defined(_STK_DEBUG_) |
| 16448 | CK_STDCERR << "[chuck](via STK): StifKarp: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 16449 | #endif |
| 16450 | } |
| 16451 | |
| 16452 | /***************************************************/ |
| 16453 | /*! \class Stk |
| 16454 | \brief STK base class |
| 16455 | |
| 16456 | Nearly all STK classes inherit from this class. |
| 16457 | The global sample rate can be queried and |
| 16458 | modified via Stk. In addition, this class |
| 16459 | provides error handling and byte-swapping |
| 16460 | functions. |
| 16461 | |
| 16462 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 16463 | */ |
| 16464 | /***************************************************/ |
| 16465 | |
| 16466 | #include <stdio.h> |
| 16467 | #include <string.h> |
| 16468 | |
| 16469 | MY_FLOAT Stk :: srate = (MY_FLOAT) SRATE; |
| 16470 | std::string Stk :: rawwavepath = RAWWAVE_PATH; |
| 16471 | const Stk::STK_FORMAT Stk :: STK_SINT8 = 1; |
| 16472 | const Stk::STK_FORMAT Stk :: STK_SINT16 = 2; |
| 16473 | const Stk::STK_FORMAT Stk :: STK_SINT24 = 4; // 1.5.0.1 (ge) added |
| 16474 | const Stk::STK_FORMAT Stk :: STK_SINT32 = 8; |
| 16475 | const Stk::STK_FORMAT Stk :: MY_FLOAT32 = 16; |
| 16476 | const Stk::STK_FORMAT Stk :: MY_FLOAT64 = 32; |
| 16477 | |
| 16478 | Stk :: Stk(void) |
| 16479 | { |
| 16480 | } |
| 16481 | |
| 16482 | Stk :: ~Stk(void) |
| 16483 | { |
| 16484 | } |
| 16485 | |
| 16486 | MY_FLOAT Stk :: sampleRate(void) |
| 16487 | { |
| 16488 | return srate; |
| 16489 | } |
| 16490 | |
| 16491 | void Stk :: setSampleRate(MY_FLOAT newRate) |
| 16492 | { |
| 16493 | if (newRate > 0) |
| 16494 | srate = newRate; |
| 16495 | } |
| 16496 | |
| 16497 | std::string Stk :: rawwavePath(void) |
| 16498 | { |
| 16499 | return rawwavepath; |
| 16500 | } |
| 16501 | |
| 16502 | void Stk :: setRawwavePath(std::string newPath) |
| 16503 | { |
| 16504 | if ( !newPath.empty() ) |
| 16505 | rawwavepath = newPath; |
| 16506 | |
| 16507 | // Make sure the path includes a "/" |
| 16508 | if ( rawwavepath[rawwavepath.length()-1] != '/' ) |
| 16509 | rawwavepath += "/"; |
| 16510 | } |
| 16511 | |
| 16512 | void Stk :: swap16(unsigned char *ptr) |
| 16513 | { |
| 16514 | /* register */ unsigned char val; |
| 16515 | |
| 16516 | // Swap 1st and 2nd bytes |
| 16517 | val = *(ptr); |
| 16518 | *(ptr) = *(ptr+1); |
| 16519 | *(ptr+1) = val; |
| 16520 | } |
| 16521 | |
| 16522 | void Stk :: swap32(unsigned char *ptr) |
| 16523 | { |
| 16524 | /* register */ unsigned char val; |
| 16525 | |
| 16526 | // Swap 1st and 4th bytes |
| 16527 | val = *(ptr); |
| 16528 | *(ptr) = *(ptr+3); |
| 16529 | *(ptr+3) = val; |
| 16530 | |
| 16531 | //Swap 2nd and 3rd bytes |
| 16532 | ptr += 1; |
| 16533 | val = *(ptr); |
| 16534 | *(ptr) = *(ptr+1); |
| 16535 | *(ptr+1) = val; |
| 16536 | } |
| 16537 | |
| 16538 | void Stk :: swap64(unsigned char *ptr) |
| 16539 | { |
| 16540 | /* register */ unsigned char val; |
| 16541 | |
| 16542 | // Swap 1st and 8th bytes |
| 16543 | val = *(ptr); |
| 16544 | *(ptr) = *(ptr+7); |
| 16545 | *(ptr+7) = val; |
| 16546 | |
| 16547 | // Swap 2nd and 7th bytes |
| 16548 | ptr += 1; |
| 16549 | val = *(ptr); |
| 16550 | *(ptr) = *(ptr+5); |
| 16551 | *(ptr+5) = val; |
| 16552 | |
| 16553 | // Swap 3rd and 6th bytes |
| 16554 | ptr += 1; |
| 16555 | val = *(ptr); |
| 16556 | *(ptr) = *(ptr+3); |
| 16557 | *(ptr+3) = val; |
| 16558 | |
| 16559 | // Swap 4th and 5th bytes |
| 16560 | ptr += 1; |
| 16561 | val = *(ptr); |
| 16562 | *(ptr) = *(ptr+1); |
| 16563 | *(ptr+1) = val; |
| 16564 | } |
| 16565 | |
| 16566 | #if (defined(__OS_WINDOWS__) || defined(__PLATFORM_WINDOWS__)) |
| 16567 | #ifndef __CHUNREAL_ENGINE__ |
| 16568 | #include <windows.h> // for win32_tmpfile() |
| 16569 | #else |
| 16570 | // 1.5.0.0 (ge) | #chunreal |
| 16571 | // unreal engine on windows disallows including windows.h |
| 16572 | #include "Windows/MinWindows.h" |
| 16573 | #endif // #ifndef __CHUNREAL_ENGINE__ |
| 16574 | #else |
| 16575 | #include <unistd.h> |
| 16576 | #endif // #if (defined(__OS_WINDOWS__) || defined(__PLATFORM_WINDOWS__)) |
| 16577 | |
| 16578 | void Stk :: sleep(unsigned long milliseconds) |
| 16579 | { |
| 16580 | // 1.4.2.0 (ge) | changed cast to unsigned int to clear a warning |
| 16581 | // 1.5.0.5 (ge and eito) call ck_usleep resolved elsewhere |
| 16582 | ck_usleep( (unsigned int)(milliseconds * 1000.0) ); |
| 16583 | } |
| 16584 | |
| 16585 | void Stk :: handleError( const char *message, StkError::TYPE type ) |
| 16586 | { |
| 16587 | if (type == StkError::WARNING) |
| 16588 | { |
| 16589 | if (strlen(message) > 0) { CK_FPRINTF_STDERR("[chuck](STK): %s\n", message); } |
| 16590 | } |
| 16591 | else if (type == StkError::DEBUG_WARNING) |
| 16592 | { |
| 16593 | #if defined(_STK_DEBUG_) |
| 16594 | if (strlen(message) > 0) { CK_FPRINTF_STDERR("[chuck](STK): %s\n", message); } |
| 16595 | #endif |
| 16596 | } |
| 16597 | else |
| 16598 | { |
| 16599 | // print error message before throwing. |
| 16600 | if (strlen(message) > 0) { CK_FPRINTF_STDERR("[chuck](STK): %s\n", message); } |
| 16601 | throw StkError(message, type); |
| 16602 | } |
| 16603 | } |
| 16604 | |
| 16605 | StkError :: StkError(const char *p, TYPE tipe) |
| 16606 | : type(tipe) |
| 16607 | { |
| 16608 | strncpy(message, p, STK_MSG_BUF_LENGTH); |
| 16609 | } |
| 16610 | |
| 16611 | StkError :: ~StkError(void) |
| 16612 | { |
| 16613 | } |
| 16614 | |
| 16615 | void StkError :: printMessage(void) |
| 16616 | { |
| 16617 | printf("%s\n", message); |
| 16618 | } |
| 16619 | /***************************************************/ |
| 16620 | /*! \class SubNoise |
| 16621 | \brief STK sub-sampled noise generator. |
| 16622 | |
| 16623 | Generates a new random number every "rate" ticks |
| 16624 | using the C rand() function. The quality of the |
| 16625 | rand() function varies from one OS to another. |
| 16626 | |
| 16627 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 16628 | */ |
| 16629 | /***************************************************/ |
| 16630 | |
| 16631 | |
| 16632 | SubNoise :: SubNoise(int subRate) : Noise() |
| 16633 | { |
| 16634 | rate = subRate; |
| 16635 | counter = rate; |
| 16636 | } |
| 16637 | SubNoise :: ~SubNoise() |
| 16638 | { |
| 16639 | } |
| 16640 | |
| 16641 | int SubNoise :: subRate(void) const |
| 16642 | { |
| 16643 | return rate; |
| 16644 | } |
| 16645 | |
| 16646 | void SubNoise :: setRate(int subRate) |
| 16647 | { |
| 16648 | if (subRate > 0) |
| 16649 | rate = subRate; |
| 16650 | } |
| 16651 | |
| 16652 | MY_FLOAT SubNoise :: tick() |
| 16653 | { |
| 16654 | if ( ++counter > rate ) { |
| 16655 | Noise::tick(); |
| 16656 | counter = 1; |
| 16657 | } |
| 16658 | |
| 16659 | return lastOutput; |
| 16660 | } |
| 16661 | /***************************************************/ |
| 16662 | /*! \class Table |
| 16663 | \brief STK table lookup class. |
| 16664 | |
| 16665 | This class loads a table of floating-point |
| 16666 | doubles, which are assumed to be in big-endian |
| 16667 | format. Linear interpolation is performed for |
| 16668 | fractional lookup indexes. |
| 16669 | |
| 16670 | An StkError will be thrown if the table file |
| 16671 | is not found. |
| 16672 | |
| 16673 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 16674 | */ |
| 16675 | /***************************************************/ |
| 16676 | |
| 16677 | #include <stdio.h> |
| 16678 | #include <sys/stat.h> |
| 16679 | #include <sys/types.h> |
| 16680 | #include <iostream> |
| 16681 | |
| 16682 | Table :: Table(char *fileName) |
| 16683 | { |
| 16684 | char message[STK_MSG_BUF_LENGTH]; |
| 16685 | |
| 16686 | // Use the system call "stat" to determine the file length |
| 16687 | struct stat filestat; |
| 16688 | if ( stat(fileName, &filestat) == -1 ) { |
| 16689 | snprintf(message, STK_MSG_BUF_LENGTH, "[chuck](via Table): Couldn't stat or find file (%s).", fileName); |
| 16690 | handleError( message, StkError::FILE_NOT_FOUND ); |
| 16691 | } |
| 16692 | length = (long) filestat.st_size / 8; // length in 8-byte samples |
| 16693 | |
| 16694 | // Open the file and read samples into data[] |
| 16695 | FILE *fd; |
| 16696 | fd = fopen(fileName,"rb"); |
| 16697 | if (!fd) { |
| 16698 | snprintf(message, STK_MSG_BUF_LENGTH, "[chuck](via Table): Couldn't open or find file (%s).", fileName); |
| 16699 | handleError( message, StkError::FILE_NOT_FOUND ); |
| 16700 | } |
| 16701 | |
| 16702 | data = (MY_FLOAT *) new MY_FLOAT[length]; |
| 16703 | |
| 16704 | // Read samples into data[] |
| 16705 | long i = 0; |
| 16706 | double temp; |
| 16707 | while ( fread(&temp, 8, 1, fd) ) { |
| 16708 | if( little_endian ) |
| 16709 | swap64((unsigned char *)&temp); |
| 16710 | |
| 16711 | data[i++] = (MY_FLOAT) temp; |
| 16712 | } |
| 16713 | fclose(fd); |
| 16714 | |
| 16715 | lastOutput = 0.0; |
| 16716 | } |
| 16717 | |
| 16718 | Table :: ~Table() |
| 16719 | { |
| 16720 | delete [ ] data; |
| 16721 | } |
| 16722 | |
| 16723 | long Table :: getLength() const |
| 16724 | { |
| 16725 | return length; |
| 16726 | } |
| 16727 | |
| 16728 | MY_FLOAT Table :: lastOut() const |
| 16729 | { |
| 16730 | return lastOutput; |
| 16731 | } |
| 16732 | |
| 16733 | MY_FLOAT Table :: tick(MY_FLOAT index) |
| 16734 | { |
| 16735 | MY_FLOAT alpha; |
| 16736 | long temp; |
| 16737 | |
| 16738 | if (index > length-1) { |
| 16739 | CK_STDCERR << "[chuck](via STK): Table: Index (" << index << ") exceeds table length ... sticking at end!" << CK_STDENDL; |
| 16740 | index = length-1; |
| 16741 | } |
| 16742 | else if (index < 0.0) { |
| 16743 | CK_STDCERR << "[chuck](via STK): Table: Index (" << index << ") is less than zero ... setting to zero!" << CK_STDENDL; |
| 16744 | index = 0.0; |
| 16745 | } |
| 16746 | |
| 16747 | // Index in range 0 to length-1 |
| 16748 | temp = (long) index; // Integer part of index |
| 16749 | alpha = index - (MY_FLOAT) temp; // Fractional part of index |
| 16750 | if (alpha > 0.0) { // Do linear interpolation |
| 16751 | lastOutput = data[temp]; |
| 16752 | lastOutput += (alpha*(data[temp+1] - lastOutput)); |
| 16753 | } |
| 16754 | else lastOutput = data[temp]; |
| 16755 | |
| 16756 | return lastOutput; |
| 16757 | } |
| 16758 | |
| 16759 | MY_FLOAT *Table :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 16760 | { |
| 16761 | for (unsigned int i=0; i<vectorSize; i++) |
| 16762 | vec[i] = tick(vec[i]); |
| 16763 | |
| 16764 | return vec; |
| 16765 | } |
| 16766 | /***************************************************/ |
| 16767 | /*! \class TubeBell |
| 16768 | \brief STK tubular bell (orchestral chime) FM |
| 16769 | synthesis instrument. |
| 16770 | |
| 16771 | This class implements two simple FM Pairs |
| 16772 | summed together, also referred to as algorithm |
| 16773 | 5 of the TX81Z. |
| 16774 | |
| 16775 | \code |
| 16776 | Algorithm 5 is : 4->3--\ |
| 16777 | + --> Out |
| 16778 | 2->1--/ |
| 16779 | \endcode |
| 16780 | |
| 16781 | Control Change Numbers: |
| 16782 | - Modulator Index One = 2 |
| 16783 | - Crossfade of Outputs = 4 |
| 16784 | - LFO Speed = 11 |
| 16785 | - LFO Depth = 1 |
| 16786 | - ADSR 2 & 4 Target = 128 |
| 16787 | |
| 16788 | The basic Chowning/Stanford FM patent expired |
| 16789 | in 1995, but there exist follow-on patents, |
| 16790 | mostly assigned to Yamaha. If you are of the |
| 16791 | type who should worry about this (making |
| 16792 | money) worry away. |
| 16793 | |
| 16794 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 16795 | */ |
| 16796 | /***************************************************/ |
| 16797 | |
| 16798 | |
| 16799 | TubeBell :: TubeBell() |
| 16800 | : FM() |
| 16801 | { |
| 16802 | // Concatenate the STK rawwave path to the rawwave files |
| 16803 | for ( int i=0; i<3; i++ ) |
| 16804 | waves[i] = new WaveLoop( "special:sinewave", TRUE ); |
| 16805 | waves[3] = new WaveLoop( "special:fwavblnk", TRUE ); |
| 16806 | |
| 16807 | this->setRatio(0, 1.0 * 0.995); |
| 16808 | this->setRatio(1, 1.414 * 0.995); |
| 16809 | this->setRatio(2, 1.0 * 1.005); |
| 16810 | this->setRatio(3, 1.414 * 1.000); |
| 16811 | |
| 16812 | gains[0] = __FM_gains[94]; |
| 16813 | gains[1] = __FM_gains[76]; |
| 16814 | gains[2] = __FM_gains[99]; |
| 16815 | gains[3] = __FM_gains[71]; |
| 16816 | |
| 16817 | // 1.4.1.0 (prc) REPARIATHON2021 ADDITION |
| 16818 | baseGains[0] = gains[0]; |
| 16819 | baseGains[1] = gains[1]; |
| 16820 | baseGains[2] = gains[2]; |
| 16821 | baseGains[3] = gains[3]; |
| 16822 | |
| 16823 | adsr[0]->setAllTimes( 0.005, 4.0, 0.0, 0.04); |
| 16824 | adsr[1]->setAllTimes( 0.005, 4.0, 0.0, 0.04); |
| 16825 | adsr[2]->setAllTimes( 0.001, 2.0, 0.0, 0.04); |
| 16826 | adsr[3]->setAllTimes( 0.004, 4.0, 0.0, 0.04); |
| 16827 | |
| 16828 | twozero->setGain( 0.5 ); |
| 16829 | op4Feedback = 0.5; // 1.4.1.0 |
| 16830 | vibrato->setFrequency( 2.0 ); |
| 16831 | |
| 16832 | bCompatible = 1; // 1.4.1.0 (prc) REPAIRATHON2021 HACK: When created, I'm a TubeBell, that can change.... |
| 16833 | } |
| 16834 | |
| 16835 | TubeBell :: ~TubeBell() |
| 16836 | { |
| 16837 | // note: waves array taken care of in FM destructor |
| 16838 | } |
| 16839 | |
| 16840 | void TubeBell :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 16841 | { |
| 16842 | // 1.4.1.0 (prc) REPAIRATHON2021 commented out |
| 16843 | // gains[0] = amplitude * __FM_gains[94]; // OLD WAY OF DOING IT |
| 16844 | // gains[1] = amplitude * __FM_gains[76]; // DELETE SOMEDAY |
| 16845 | // gains[2] = amplitude * __FM_gains[99]; |
| 16846 | // gains[3] = amplitude * __FM_gains[71]; |
| 16847 | |
| 16848 | // 1.4.1.0 (prc) REPAIRATHON2021 added |
| 16849 | gains[0] = amplitude * baseGains[0]; |
| 16850 | gains[1] = amplitude * baseGains[1]; |
| 16851 | gains[2] = amplitude * baseGains[2]; |
| 16852 | gains[3] = amplitude * baseGains[3]; |
| 16853 | |
| 16854 | this->setFrequency(frequency); |
| 16855 | this->keyOn(); |
| 16856 | |
| 16857 | #if defined(_STK_DEBUG_) |
| 16858 | CK_STDCERR << "TubeBell: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 16859 | #endif |
| 16860 | } |
| 16861 | |
| 16862 | MY_FLOAT TubeBell :: tick() // 1.4.1.0 (prc) REPAIRATHON2021 updated |
| 16863 | { |
| 16864 | MY_FLOAT temp, temp2; |
| 16865 | |
| 16866 | temp2 = vibrato->tick(); |
| 16867 | |
| 16868 | if (bCompatible) { // 1.4.1.0 (prc) REPAIRATHON COMPATIBILITY, "I'm still a TubeBell" |
| 16869 | temp = gains[1] * adsr[1]->tick() * waves[1]->tick(); |
| 16870 | temp = temp * control1; |
| 16871 | |
| 16872 | waves[0]->addPhaseOffset(temp); |
| 16873 | waves[3]->addPhaseOffset(twozero->lastOut()); |
| 16874 | temp = gains[3] * adsr[3]->tick() * waves[3]->tick(); |
| 16875 | twozero->tick(temp); |
| 16876 | |
| 16877 | waves[2]->addPhaseOffset(temp); |
| 16878 | temp = ( 1.0 - (control2 * 0.5)) * gains[0] * adsr[0]->tick() * waves[0]->tick(); |
| 16879 | temp += control2 * 0.5 * gains[2] * adsr[2]->tick() * waves[2]->tick(); |
| 16880 | |
| 16881 | // Calculate amplitude modulation and apply it to output. |
| 16882 | temp2 *= modDepth; |
| 16883 | temp = temp * (1.0 + temp2); |
| 16884 | } else { |
| 16885 | temp = temp2 * modDepth * 0.2; |
| 16886 | for (int i = 0; i < 4; i++) { |
| 16887 | if (ratios[i] > 0.0) { |
| 16888 | waves[i]->setFrequency(baseFrequency * (1.0 + temp) * ratios[i]); |
| 16889 | } |
| 16890 | } |
| 16891 | |
| 16892 | temp = (1.0 + opAMs[1]*temp2) * gains[1] * adsr[1]->tick() * waves[1]->tick(); |
| 16893 | temp = temp * control1; |
| 16894 | |
| 16895 | waves[0]->addPhaseOffset(temp); |
| 16896 | waves[3]->addPhaseOffset(twozero->lastOut()); |
| 16897 | temp = (1.0 + opAMs[3]*temp2) * gains[3] * adsr[3]->tick() * waves[3]->tick(); |
| 16898 | twozero->tick(temp); |
| 16899 | |
| 16900 | waves[2]->addPhaseOffset(temp); |
| 16901 | temp = ( 1.0 - (control2 * 0.5) + opAMs[0]*temp2) * gains[0] * adsr[0]->tick() * waves[0]->tick(); |
| 16902 | temp += (1.0 + opAMs[2]*temp2) * control2 * 0.5 * gains[2] * adsr[2]->tick() * waves[2]->tick(); |
| 16903 | } |
| 16904 | |
| 16905 | lastOutput = temp * 0.5; |
| 16906 | return lastOutput; |
| 16907 | } |
| 16908 | |
| 16909 | |
| 16910 | /***************************************************/ |
| 16911 | /*! \class TwoPole |
| 16912 | \brief STK two-pole filter class. |
| 16913 | |
| 16914 | This protected Filter subclass implements |
| 16915 | a two-pole digital filter. A method is |
| 16916 | provided for creating a resonance in the |
| 16917 | frequency response while maintaining a nearly |
| 16918 | constant filter gain. |
| 16919 | |
| 16920 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 16921 | */ |
| 16922 | /***************************************************/ |
| 16923 | |
| 16924 | #include <math.h> |
| 16925 | |
| 16926 | TwoPole :: TwoPole() : FilterStk() |
| 16927 | { |
| 16928 | MY_FLOAT B = 1.0; |
| 16929 | MY_FLOAT A[3] = {1.0, 0.0, 0.0}; |
| 16930 | m_resFreq = 440.0; |
| 16931 | m_resRad = 0.0; |
| 16932 | m_resNorm = false; |
| 16933 | FilterStk::setCoefficients( 1, &B, 3, A ); |
| 16934 | } |
| 16935 | |
| 16936 | TwoPole :: ~TwoPole() |
| 16937 | { |
| 16938 | } |
| 16939 | |
| 16940 | void TwoPole :: clear(void) |
| 16941 | { |
| 16942 | FilterStk::clear(); |
| 16943 | } |
| 16944 | |
| 16945 | void TwoPole :: setB0(MY_FLOAT b0) |
| 16946 | { |
| 16947 | b[0] = b0; |
| 16948 | } |
| 16949 | |
| 16950 | void TwoPole :: setA1(MY_FLOAT a1) |
| 16951 | { |
| 16952 | a[1] = a1; |
| 16953 | } |
| 16954 | |
| 16955 | void TwoPole :: setA2(MY_FLOAT a2) |
| 16956 | { |
| 16957 | a[2] = a2; |
| 16958 | } |
| 16959 | |
| 16960 | void TwoPole :: setResonance(MY_FLOAT frequency, MY_FLOAT radius, bool normalize) |
| 16961 | { |
| 16962 | a[2] = radius * radius; |
| 16963 | a[1] = (MY_FLOAT) -2.0 * radius * cos(CK_TWO_PI * frequency / Stk::sampleRate()); |
| 16964 | |
| 16965 | if ( normalize ) { |
| 16966 | // Normalize the filter gain ... not terribly efficient. |
| 16967 | MY_FLOAT real = 1 - radius + (a[2] - radius) * cos(CK_TWO_PI * 2 * frequency / Stk::sampleRate()); |
| 16968 | MY_FLOAT imag = (a[2] - radius) * sin(CK_TWO_PI * 2 * frequency / Stk::sampleRate()); |
| 16969 | b[0] = sqrt( pow(real, 2) + pow(imag, 2) ); |
| 16970 | } |
| 16971 | } |
| 16972 | |
| 16973 | void TwoPole :: setGain(MY_FLOAT theGain) |
| 16974 | { |
| 16975 | FilterStk::setGain(theGain); |
| 16976 | } |
| 16977 | |
| 16978 | MY_FLOAT TwoPole :: getGain(void) const |
| 16979 | { |
| 16980 | return FilterStk::getGain(); |
| 16981 | } |
| 16982 | |
| 16983 | MY_FLOAT TwoPole :: lastOut(void) const |
| 16984 | { |
| 16985 | return FilterStk::lastOut(); |
| 16986 | } |
| 16987 | |
| 16988 | MY_FLOAT TwoPole :: tick(MY_FLOAT sample) |
| 16989 | { |
| 16990 | inputs[0] = gain * sample; |
| 16991 | outputs[0] = b[0] * inputs[0] - a[2] * outputs[2] - a[1] * outputs[1]; |
| 16992 | outputs[2] = outputs[1]; |
| 16993 | outputs[1] = outputs[0]; |
| 16994 | |
| 16995 | // gewang: dedenormal |
| 16996 | CK_STK_DDN(outputs[1]); |
| 16997 | CK_STK_DDN(outputs[2]); |
| 16998 | |
| 16999 | return outputs[0]; |
| 17000 | } |
| 17001 | |
| 17002 | MY_FLOAT *TwoPole :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 17003 | { |
| 17004 | for (unsigned int i=0; i<vectorSize; i++) |
| 17005 | vec[i] = tick(vec[i]); |
| 17006 | |
| 17007 | return vec; |
| 17008 | } |
| 17009 | /***************************************************/ |
| 17010 | /*! \class TwoZero |
| 17011 | \brief STK two-zero filter class. |
| 17012 | |
| 17013 | This protected Filter subclass implements |
| 17014 | a two-zero digital filter. A method is |
| 17015 | provided for creating a "notch" in the |
| 17016 | frequency response while maintaining a |
| 17017 | constant filter gain. |
| 17018 | |
| 17019 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 17020 | */ |
| 17021 | /***************************************************/ |
| 17022 | |
| 17023 | #include <math.h> |
| 17024 | |
| 17025 | TwoZero :: TwoZero() : FilterStk() |
| 17026 | { |
| 17027 | MY_FLOAT B[3] = {1.0, 0.0, 0.0}; |
| 17028 | MY_FLOAT A = 1.0; |
| 17029 | m_notchFreq = 440.0; |
| 17030 | m_notchRad = 0.0; |
| 17031 | FilterStk::setCoefficients( 3, B, 1, &A ); |
| 17032 | } |
| 17033 | |
| 17034 | TwoZero :: ~TwoZero() |
| 17035 | { |
| 17036 | } |
| 17037 | |
| 17038 | void TwoZero :: clear(void) |
| 17039 | { |
| 17040 | FilterStk::clear(); |
| 17041 | } |
| 17042 | |
| 17043 | void TwoZero :: setB0(MY_FLOAT b0) |
| 17044 | { |
| 17045 | b[0] = b0; |
| 17046 | } |
| 17047 | |
| 17048 | void TwoZero :: setB1(MY_FLOAT b1) |
| 17049 | { |
| 17050 | b[1] = b1; |
| 17051 | } |
| 17052 | |
| 17053 | void TwoZero :: setB2(MY_FLOAT b2) |
| 17054 | { |
| 17055 | b[2] = b2; |
| 17056 | } |
| 17057 | |
| 17058 | void TwoZero :: setNotch(MY_FLOAT frequency, MY_FLOAT radius) |
| 17059 | { |
| 17060 | b[2] = radius * radius; |
| 17061 | b[1] = (MY_FLOAT) -2.0 * radius * cos(CK_TWO_PI * (double) frequency / Stk::sampleRate()); |
| 17062 | |
| 17063 | // Normalize the filter gain. |
| 17064 | if (b[1] > 0.0) // Maximum at z = 0. |
| 17065 | b[0] = 1.0 / (1.0+b[1]+b[2]); |
| 17066 | else // Maximum at z = -1. |
| 17067 | b[0] = 1.0 / (1.0-b[1]+b[2]); |
| 17068 | b[1] *= b[0]; |
| 17069 | b[2] *= b[0]; |
| 17070 | } |
| 17071 | |
| 17072 | void TwoZero :: setGain(MY_FLOAT theGain) |
| 17073 | { |
| 17074 | FilterStk::setGain(theGain); |
| 17075 | } |
| 17076 | |
| 17077 | MY_FLOAT TwoZero :: getGain(void) const |
| 17078 | { |
| 17079 | return FilterStk::getGain(); |
| 17080 | } |
| 17081 | |
| 17082 | MY_FLOAT TwoZero :: lastOut(void) const |
| 17083 | { |
| 17084 | return FilterStk::lastOut(); |
| 17085 | } |
| 17086 | |
| 17087 | MY_FLOAT TwoZero :: tick(MY_FLOAT sample) |
| 17088 | { |
| 17089 | inputs[0] = gain * sample; |
| 17090 | outputs[0] = b[2] * inputs[2] + b[1] * inputs[1] + b[0] * inputs[0]; |
| 17091 | inputs[2] = inputs[1]; |
| 17092 | inputs[1] = inputs[0]; |
| 17093 | |
| 17094 | return outputs[0]; |
| 17095 | } |
| 17096 | |
| 17097 | MY_FLOAT *TwoZero :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 17098 | { |
| 17099 | for (unsigned int i=0; i<vectorSize; i++) |
| 17100 | vec[i] = tick(vec[i]); |
| 17101 | |
| 17102 | return vec; |
| 17103 | } |
| 17104 | /***************************************************/ |
| 17105 | /*! \class Vector3D |
| 17106 | \brief STK 3D vector class. |
| 17107 | |
| 17108 | This class implements a three-dimensional vector. |
| 17109 | |
| 17110 | by Perry R. Cook, 1995 - 2002. |
| 17111 | */ |
| 17112 | /***************************************************/ |
| 17113 | |
| 17114 | #include <math.h> |
| 17115 | |
| 17116 | Vector3D :: Vector3D(double initX, double initY, double initZ) |
| 17117 | { |
| 17118 | myX = initX; |
| 17119 | myY = initY; |
| 17120 | myZ = initZ; |
| 17121 | } |
| 17122 | |
| 17123 | Vector3D :: ~Vector3D() |
| 17124 | { |
| 17125 | } |
| 17126 | |
| 17127 | double Vector3D :: getX() |
| 17128 | { |
| 17129 | return myX; |
| 17130 | } |
| 17131 | |
| 17132 | double Vector3D :: getY() |
| 17133 | { |
| 17134 | return myY; |
| 17135 | } |
| 17136 | |
| 17137 | double Vector3D :: getZ() |
| 17138 | { |
| 17139 | return myZ; |
| 17140 | } |
| 17141 | |
| 17142 | double Vector3D :: getLength() |
| 17143 | { |
| 17144 | double temp; |
| 17145 | temp = myX * myX; |
| 17146 | temp += myY * myY; |
| 17147 | temp += myZ * myZ; |
| 17148 | temp = sqrt(temp); |
| 17149 | return temp; |
| 17150 | } |
| 17151 | |
| 17152 | void Vector3D :: setXYZ(double anX, double aY, double aZ) |
| 17153 | { |
| 17154 | myX = anX; |
| 17155 | myY = aY; |
| 17156 | myZ = aZ; |
| 17157 | }; |
| 17158 | |
| 17159 | void Vector3D :: setX(double aval) |
| 17160 | { |
| 17161 | myX = aval; |
| 17162 | } |
| 17163 | |
| 17164 | void Vector3D :: setY(double aval) |
| 17165 | { |
| 17166 | myY = aval; |
| 17167 | } |
| 17168 | |
| 17169 | void Vector3D :: setZ(double aval) |
| 17170 | { |
| 17171 | myZ = aval; |
| 17172 | } |
| 17173 | |
| 17174 | |
| 17175 | /***************************************************/ |
| 17176 | /*! \class VoicForm |
| 17177 | \brief Four formant synthesis instrument. |
| 17178 | |
| 17179 | This instrument contains an excitation singing |
| 17180 | wavetable (looping wave with random and |
| 17181 | periodic vibrato, smoothing on frequency, |
| 17182 | etc.), excitation noise, and four sweepable |
| 17183 | complex resonances. |
| 17184 | |
| 17185 | Measured formant data is included, and enough |
| 17186 | data is there to support either parallel or |
| 17187 | cascade synthesis. In the floating point case |
| 17188 | cascade synthesis is the most natural so |
| 17189 | that's what you'll find here. |
| 17190 | |
| 17191 | Control Change Numbers: |
| 17192 | - Voiced/Unvoiced Mix = 2 |
| 17193 | - Vowel/Phoneme Selection = 4 |
| 17194 | - Vibrato Frequency = 11 |
| 17195 | - Vibrato Gain = 1 |
| 17196 | - Loudness (Spectral Tilt) = 128 |
| 17197 | |
| 17198 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 17199 | */ |
| 17200 | /***************************************************/ |
| 17201 | |
| 17202 | |
| 17203 | #include <math.h> |
| 17204 | |
| 17205 | VoicForm :: VoicForm() : Instrmnt() |
| 17206 | { |
| 17207 | // Concatenate the STK rawwave path to the rawwave file |
| 17208 | voiced = new SingWave( "special:impuls20", TRUE ); |
| 17209 | voiced->setGainRate( 0.001 ); |
| 17210 | voiced->setGainTarget( 0.0 ); |
| 17211 | noise = new Noise; |
| 17212 | |
| 17213 | for ( int i=0; i<4; i++ ) { |
| 17214 | filters[i] = new FormSwep; |
| 17215 | filters[i]->setSweepRate( 0.001 ); |
| 17216 | } |
| 17217 | |
| 17218 | onezero = new OneZero; |
| 17219 | onezero->setZero( -0.9 ); |
| 17220 | onepole = new OnePole; |
| 17221 | onepole->setPole( 0.9 ); |
| 17222 | |
| 17223 | noiseEnv = new Envelope; |
| 17224 | noiseEnv->setRate( 0.001 ); |
| 17225 | noiseEnv->setTarget( 0.0 ); |
| 17226 | |
| 17227 | m_phonemeNum = 0; |
| 17228 | this->setPhoneme( "eee" ); |
| 17229 | this->clear(); |
| 17230 | |
| 17231 | // chuck |
| 17232 | setFrequency( 440 ); |
| 17233 | } |
| 17234 | |
| 17235 | VoicForm :: ~VoicForm() |
| 17236 | { |
| 17237 | delete voiced; |
| 17238 | delete noise; |
| 17239 | delete onezero; |
| 17240 | delete onepole; |
| 17241 | delete noiseEnv; |
| 17242 | for( int i=0; i<4; i++ ) { |
| 17243 | delete filters[i]; |
| 17244 | } |
| 17245 | } |
| 17246 | |
| 17247 | void VoicForm :: clear() |
| 17248 | { |
| 17249 | onezero->clear(); |
| 17250 | onepole->clear(); |
| 17251 | for ( int i=0; i<4; i++ ) { |
| 17252 | filters[i]->clear(); |
| 17253 | } |
| 17254 | } |
| 17255 | |
| 17256 | void VoicForm :: setFrequency(MY_FLOAT frequency) |
| 17257 | { |
| 17258 | MY_FLOAT freakency = frequency; |
| 17259 | if ( frequency <= 0.0 ) { |
| 17260 | CK_STDCERR << "[chuck](via STK): VoicForm: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 17261 | freakency = 220.0; |
| 17262 | } |
| 17263 | |
| 17264 | voiced->setFrequency( freakency ); |
| 17265 | |
| 17266 | // chuck |
| 17267 | m_frequency = freakency; |
| 17268 | } |
| 17269 | |
| 17270 | bool VoicForm :: setPhoneme( const char *phoneme ) |
| 17271 | { |
| 17272 | bool found = false; |
| 17273 | unsigned int i = 0; |
| 17274 | while( i < 32 && !found ) |
| 17275 | { |
| 17276 | if( !strcmp( Phonemes::name(i), phoneme ) ) |
| 17277 | { |
| 17278 | found = true; |
| 17279 | filters[0]->setTargets( Phonemes::formantFrequency(i, 0), Phonemes::formantRadius(i, 0), pow(10.0, Phonemes::formantGain(i, 0 ) / 20.0) ); |
| 17280 | filters[1]->setTargets( Phonemes::formantFrequency(i, 1), Phonemes::formantRadius(i, 1), pow(10.0, Phonemes::formantGain(i, 1 ) / 20.0) ); |
| 17281 | filters[2]->setTargets( Phonemes::formantFrequency(i, 2), Phonemes::formantRadius(i, 2), pow(10.0, Phonemes::formantGain(i, 2 ) / 20.0) ); |
| 17282 | filters[3]->setTargets( Phonemes::formantFrequency(i, 3), Phonemes::formantRadius(i, 3), pow(10.0, Phonemes::formantGain(i, 3 ) / 20.0) ); |
| 17283 | setVoiced( Phonemes::voiceGain( i ) ); |
| 17284 | setUnVoiced( Phonemes::noiseGain( i ) ); |
| 17285 | m_phonemeNum = i; |
| 17286 | #if defined(_STK_DEBUG_) |
| 17287 | CK_STDCERR << "[chuck](via STK): VoicForm: found formant " << phoneme << " (number " << i << ")" << CK_STDENDL; |
| 17288 | #endif |
| 17289 | } |
| 17290 | i++; |
| 17291 | } |
| 17292 | |
| 17293 | if( !found ) |
| 17294 | CK_STDCERR << "[chuck](via STK): VoicForm: phoneme " << phoneme << " not found!" << CK_STDENDL; |
| 17295 | else |
| 17296 | str_phoneme = Phonemes::name( m_phonemeNum ); |
| 17297 | |
| 17298 | return found; |
| 17299 | } |
| 17300 | |
| 17301 | void VoicForm :: setVoiced(MY_FLOAT vGain) |
| 17302 | { |
| 17303 | voiced->setGainTarget(vGain); |
| 17304 | } |
| 17305 | |
| 17306 | void VoicForm :: setUnVoiced(MY_FLOAT nGain) |
| 17307 | { |
| 17308 | noiseEnv->setTarget(nGain * 0.01); |
| 17309 | } |
| 17310 | |
| 17311 | void VoicForm :: setFilterSweepRate(int whichOne, MY_FLOAT rate) |
| 17312 | { |
| 17313 | if ( whichOne < 0 || whichOne > 3 ) { |
| 17314 | CK_STDCERR << "[chuck](via STK): VoicForm: setFilterSweepRate filter argument outside range 0-3!" << CK_STDENDL; |
| 17315 | return; |
| 17316 | } |
| 17317 | |
| 17318 | filters[whichOne]->setSweepRate(rate); |
| 17319 | } |
| 17320 | |
| 17321 | void VoicForm :: setPitchSweepRate(MY_FLOAT rate) |
| 17322 | { |
| 17323 | voiced->setSweepRate(rate); |
| 17324 | } |
| 17325 | |
| 17326 | void VoicForm :: speak() |
| 17327 | { |
| 17328 | voiced->noteOn(); |
| 17329 | } |
| 17330 | |
| 17331 | void VoicForm :: quiet() |
| 17332 | { |
| 17333 | voiced->noteOff(); |
| 17334 | noiseEnv->setTarget( 0.0 ); |
| 17335 | } |
| 17336 | |
| 17337 | void VoicForm :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 17338 | { |
| 17339 | // chuck |
| 17340 | if( frequency != m_frequency ) |
| 17341 | setFrequency(frequency); |
| 17342 | |
| 17343 | voiced->setGainTarget(amplitude); |
| 17344 | onepole->setPole( 0.97 - (amplitude * 0.2) ); |
| 17345 | } |
| 17346 | |
| 17347 | void VoicForm :: noteOn( MY_FLOAT amplitude ) |
| 17348 | { |
| 17349 | voiced->setGainTarget(amplitude); |
| 17350 | onepole->setPole( 0.97 - (amplitude * 0.2) ); |
| 17351 | } |
| 17352 | |
| 17353 | void VoicForm :: noteOff(MY_FLOAT amplitude) |
| 17354 | { |
| 17355 | this->quiet(); |
| 17356 | } |
| 17357 | |
| 17358 | MY_FLOAT VoicForm :: tick() |
| 17359 | { |
| 17360 | MY_FLOAT temp; |
| 17361 | temp = onepole->tick( onezero->tick( voiced->tick() ) ); |
| 17362 | temp += noiseEnv->tick() * noise->tick(); |
| 17363 | lastOutput = filters[0]->tick(temp); |
| 17364 | lastOutput += filters[1]->tick(temp); |
| 17365 | lastOutput += filters[2]->tick(temp); |
| 17366 | lastOutput += filters[3]->tick(temp); |
| 17367 | /* |
| 17368 | temp += noiseEnv->tick() * noise->tick(); |
| 17369 | lastOutput = filters[0]->tick(temp); |
| 17370 | lastOutput = filters[1]->tick(lastOutput); |
| 17371 | lastOutput = filters[2]->tick(lastOutput); |
| 17372 | lastOutput = filters[3]->tick(lastOutput); |
| 17373 | */ |
| 17374 | return lastOutput; |
| 17375 | } |
| 17376 | |
| 17377 | void VoicForm :: controlChange(int number, MY_FLOAT value) |
| 17378 | { |
| 17379 | MY_FLOAT norm = value * ONE_OVER_128; |
| 17380 | if ( norm < 0 ) { |
| 17381 | norm = 0.0; |
| 17382 | CK_STDCERR << "[chuck](via STK): VoicForm: Control value less than zero!" << CK_STDENDL; |
| 17383 | } |
| 17384 | else if ( norm > 1.0 ) { |
| 17385 | norm = 1.0; |
| 17386 | CK_STDCERR << "[chuck](via STK): VoicForm: Control value exceeds nominal range!" << CK_STDENDL; |
| 17387 | } |
| 17388 | |
| 17389 | if (number == __SK_Breath_) { // 2 |
| 17390 | this->setVoiced( 1.0 - norm ); |
| 17391 | this->setUnVoiced( norm ); |
| 17392 | } |
| 17393 | else if (number == __SK_FootControl_) { // 4 |
| 17394 | MY_FLOAT temp = 0.0; |
| 17395 | unsigned int i = (int) value; |
| 17396 | if (i < 32) { |
| 17397 | temp = 0.9; |
| 17398 | } |
| 17399 | else if (i < 64) { |
| 17400 | i -= 32; |
| 17401 | temp = 1.0; |
| 17402 | } |
| 17403 | else if (i < 96) { |
| 17404 | i -= 64; |
| 17405 | temp = 1.1; |
| 17406 | } |
| 17407 | else if (i < 128) { |
| 17408 | i -= 96; |
| 17409 | temp = 1.2; |
| 17410 | } |
| 17411 | else if (i == 128) { |
| 17412 | i = 0; |
| 17413 | temp = 1.4; |
| 17414 | } |
| 17415 | filters[0]->setTargets( temp * Phonemes::formantFrequency(i, 0), Phonemes::formantRadius(i, 0), pow(10.0, Phonemes::formantGain(i, 0 ) / 20.0) ); |
| 17416 | filters[1]->setTargets( temp * Phonemes::formantFrequency(i, 1), Phonemes::formantRadius(i, 1), pow(10.0, Phonemes::formantGain(i, 1 ) / 20.0) ); |
| 17417 | filters[2]->setTargets( temp * Phonemes::formantFrequency(i, 2), Phonemes::formantRadius(i, 2), pow(10.0, Phonemes::formantGain(i, 2 ) / 20.0) ); |
| 17418 | filters[3]->setTargets( temp * Phonemes::formantFrequency(i, 3), Phonemes::formantRadius(i, 3), pow(10.0, Phonemes::formantGain(i, 3 ) / 20.0) ); |
| 17419 | setVoiced( Phonemes::voiceGain( i ) ); |
| 17420 | setUnVoiced( Phonemes::noiseGain( i ) ); |
| 17421 | } |
| 17422 | else if (number == __SK_ModFrequency_) // 11 |
| 17423 | voiced->setVibratoRate( norm * 12.0); // 0 to 12 Hz |
| 17424 | else if (number == __SK_ModWheel_) // 1 |
| 17425 | voiced->setVibratoGain( norm * 0.2); |
| 17426 | else if (number == __SK_AfterTouch_Cont_) { // 128 |
| 17427 | setVoiced( norm ); |
| 17428 | onepole->setPole( 0.97 - ( norm * 0.2) ); |
| 17429 | } |
| 17430 | else |
| 17431 | CK_STDCERR << "[chuck](via STK): VoicForm: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 17432 | |
| 17433 | #if defined(_STK_DEBUG_) |
| 17434 | CK_STDCERR << "[chuck](via STK): VoicForm: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 17435 | #endif |
| 17436 | } |
| 17437 | |
| 17438 | /***************************************************/ |
| 17439 | /*! \class Voicer |
| 17440 | \brief STK voice manager class. |
| 17441 | |
| 17442 | This class can be used to manage a group of |
| 17443 | STK instrument classes. Individual voices can |
| 17444 | be controlled via unique note tags. |
| 17445 | Instrument groups can be controlled by channel |
| 17446 | number. |
| 17447 | |
| 17448 | A previously constructed STK instrument class |
| 17449 | is linked with a voice manager using the |
| 17450 | addInstrument() function. An optional channel |
| 17451 | number argument can be specified to the |
| 17452 | addInstrument() function as well (default |
| 17453 | channel = 0). The voice manager does not |
| 17454 | delete any instrument instances ... it is the |
| 17455 | responsibility of the user to allocate and |
| 17456 | deallocate all instruments. |
| 17457 | |
| 17458 | The tick() function returns the mix of all |
| 17459 | sounding voices. Each noteOn returns a unique |
| 17460 | tag (credits to the NeXT MusicKit), so you can |
| 17461 | send control changes to specific voices within |
| 17462 | an ensemble. Alternately, control changes can |
| 17463 | be sent to all voices on a given channel. |
| 17464 | |
| 17465 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 17466 | */ |
| 17467 | /***************************************************/ |
| 17468 | |
| 17469 | #include <stdlib.h> |
| 17470 | #include <math.h> |
| 17471 | |
| 17472 | Voicer :: Voicer( int maxInstruments, MY_FLOAT decayTime ) |
| 17473 | { |
| 17474 | nVoices = 0; |
| 17475 | maxVoices = maxInstruments; |
| 17476 | voices = (Voice *) new Voice[maxVoices]; |
| 17477 | tags = 23456; |
| 17478 | muteTime = (int) ( decayTime * Stk::sampleRate() ); |
| 17479 | } |
| 17480 | |
| 17481 | Voicer :: ~Voicer() |
| 17482 | { |
| 17483 | delete [] voices; |
| 17484 | } |
| 17485 | |
| 17486 | void Voicer :: addInstrument( Instrmnt *instrument, int channel ) |
| 17487 | { |
| 17488 | //voices = (Voice *) realloc( (void *) voices, nVoices+1 * sizeof( Voice ) ); |
| 17489 | if ( nVoices == maxVoices ) { |
| 17490 | CK_STDCERR << "[chuck](via STK): Voicer: Maximum number of voices already added!!" << CK_STDENDL; |
| 17491 | return; |
| 17492 | } |
| 17493 | |
| 17494 | voices[nVoices].instrument = instrument; |
| 17495 | voices[nVoices].tag = 0; |
| 17496 | voices[nVoices].channel = channel; |
| 17497 | voices[nVoices].noteNumber = -1; |
| 17498 | voices[nVoices].frequency = 0.0; |
| 17499 | voices[nVoices].sounding = 0; |
| 17500 | nVoices++; |
| 17501 | } |
| 17502 | |
| 17503 | void Voicer :: removeInstrument( Instrmnt *instrument ) |
| 17504 | { |
| 17505 | bool found = false; |
| 17506 | for ( int i=0; i<nVoices; i++ ) { |
| 17507 | if ( voices[i].instrument == instrument ) found = true; |
| 17508 | if ( found && i+1 < nVoices ) { |
| 17509 | voices[i].instrument = voices[i+1].instrument; |
| 17510 | voices[i].tag = voices[i+1].tag; |
| 17511 | voices[i].noteNumber = voices[i+1].noteNumber; |
| 17512 | voices[i].frequency = voices[i+1].frequency; |
| 17513 | voices[i].sounding = voices[i+1].sounding; |
| 17514 | voices[i].channel = voices[i+1].channel; |
| 17515 | } |
| 17516 | } |
| 17517 | |
| 17518 | if ( found ) |
| 17519 | nVoices--; |
| 17520 | //voices = (Voice *) realloc( voices, --nVoices * sizeof( Voice ) ); |
| 17521 | |
| 17522 | } |
| 17523 | |
| 17524 | long Voicer :: noteOn(MY_FLOAT noteNumber, MY_FLOAT amplitude, int channel ) |
| 17525 | { |
| 17526 | int i; |
| 17527 | MY_FLOAT frequency = (MY_FLOAT) 220.0 * pow( 2.0, (noteNumber - 57.0) / 12.0 ); |
| 17528 | for ( i=0; i<nVoices; i++ ) { |
| 17529 | if (voices[i].noteNumber < 0 && voices[i].channel == channel) { |
| 17530 | voices[i].tag = tags++; |
| 17531 | voices[i].channel = channel; |
| 17532 | voices[i].noteNumber = noteNumber; |
| 17533 | voices[i].frequency = frequency; |
| 17534 | voices[i].instrument->noteOn( frequency, amplitude * ONE_OVER_128 ); |
| 17535 | voices[i].sounding = 1; |
| 17536 | return voices[i].tag; |
| 17537 | } |
| 17538 | } |
| 17539 | |
| 17540 | // All voices are sounding, so interrupt the oldest voice. |
| 17541 | int voice = -1; |
| 17542 | for ( i=0; i<nVoices; i++ ) { |
| 17543 | if ( voices[i].channel == channel ) { |
| 17544 | if ( voice == -1 ) voice = i; |
| 17545 | else if ( voices[i].tag < voices[voice].tag ) voice = i; |
| 17546 | } |
| 17547 | } |
| 17548 | |
| 17549 | if ( voice >= 0 ) { |
| 17550 | voices[voice].tag = tags++; |
| 17551 | voices[voice].channel = channel; |
| 17552 | voices[voice].noteNumber = noteNumber; |
| 17553 | voices[voice].frequency = frequency; |
| 17554 | voices[voice].instrument->noteOn( frequency, amplitude * ONE_OVER_128 ); |
| 17555 | voices[voice].sounding = 1; |
| 17556 | return voices[voice].tag; |
| 17557 | } |
| 17558 | |
| 17559 | return -1; |
| 17560 | } |
| 17561 | |
| 17562 | void Voicer :: noteOff( MY_FLOAT noteNumber, MY_FLOAT amplitude, int channel ) |
| 17563 | { |
| 17564 | for ( int i=0; i<nVoices; i++ ) { |
| 17565 | if ( voices[i].noteNumber == noteNumber && voices[i].channel == channel ) { |
| 17566 | voices[i].instrument->noteOff( amplitude * ONE_OVER_128 ); |
| 17567 | voices[i].sounding = -muteTime; |
| 17568 | } |
| 17569 | } |
| 17570 | } |
| 17571 | |
| 17572 | void Voicer :: noteOff( long tag, MY_FLOAT amplitude ) |
| 17573 | { |
| 17574 | for ( int i=0; i<nVoices; i++ ) { |
| 17575 | if ( voices[i].tag == tag ) { |
| 17576 | voices[i].instrument->noteOff( amplitude * ONE_OVER_128 ); |
| 17577 | voices[i].sounding = -muteTime; |
| 17578 | break; |
| 17579 | } |
| 17580 | } |
| 17581 | } |
| 17582 | |
| 17583 | void Voicer :: setFrequency( MY_FLOAT noteNumber, int channel ) |
| 17584 | { |
| 17585 | MY_FLOAT frequency = (MY_FLOAT) 220.0 * pow( 2.0, (noteNumber - 57.0) / 12.0 ); |
| 17586 | for ( int i=0; i<nVoices; i++ ) { |
| 17587 | if ( voices[i].channel == channel ) { |
| 17588 | voices[i].noteNumber = noteNumber; |
| 17589 | voices[i].frequency = frequency; |
| 17590 | voices[i].instrument->setFrequency( frequency ); |
| 17591 | } |
| 17592 | } |
| 17593 | } |
| 17594 | |
| 17595 | void Voicer :: setFrequency( long tag, MY_FLOAT noteNumber ) |
| 17596 | { |
| 17597 | MY_FLOAT frequency = (MY_FLOAT) 220.0 * pow( 2.0, (noteNumber - 57.0) / 12.0 ); |
| 17598 | for ( int i=0; i<nVoices; i++ ) { |
| 17599 | if ( voices[i].tag == tag ) { |
| 17600 | voices[i].noteNumber = noteNumber; |
| 17601 | voices[i].frequency = frequency; |
| 17602 | voices[i].instrument->setFrequency( frequency ); |
| 17603 | break; |
| 17604 | } |
| 17605 | } |
| 17606 | } |
| 17607 | |
| 17608 | void Voicer :: pitchBend( MY_FLOAT value, int channel ) |
| 17609 | { |
| 17610 | MY_FLOAT pitchScaler; |
| 17611 | if ( value < 64.0 ) |
| 17612 | pitchScaler = pow(0.5, (64.0-value)/64.0); |
| 17613 | else |
| 17614 | pitchScaler = pow(2.0, (value-64.0)/64.0); |
| 17615 | for ( int i=0; i<nVoices; i++ ) { |
| 17616 | if ( voices[i].channel == channel ) |
| 17617 | voices[i].instrument->setFrequency( (MY_FLOAT) (voices[i].frequency * pitchScaler) ); |
| 17618 | } |
| 17619 | } |
| 17620 | |
| 17621 | void Voicer :: pitchBend( long tag, MY_FLOAT value ) |
| 17622 | { |
| 17623 | MY_FLOAT pitchScaler; |
| 17624 | if ( value < 64.0 ) |
| 17625 | pitchScaler = pow(0.5, (64.0-value)/64.0); |
| 17626 | else |
| 17627 | pitchScaler = pow(2.0, (value-64.0)/64.0); |
| 17628 | for ( int i=0; i<nVoices; i++ ) { |
| 17629 | if ( voices[i].tag == tag ) { |
| 17630 | voices[i].instrument->setFrequency( (MY_FLOAT) (voices[i].frequency * pitchScaler) ); |
| 17631 | break; |
| 17632 | } |
| 17633 | } |
| 17634 | } |
| 17635 | |
| 17636 | void Voicer :: controlChange( int number, MY_FLOAT value, int channel ) |
| 17637 | { |
| 17638 | for ( int i=0; i<nVoices; i++ ) { |
| 17639 | if ( voices[i].channel == channel ) |
| 17640 | voices[i].instrument->controlChange( number, value ); |
| 17641 | } |
| 17642 | } |
| 17643 | |
| 17644 | void Voicer :: controlChange( long tag, int number, MY_FLOAT value ) |
| 17645 | { |
| 17646 | for ( int i=0; i<nVoices; i++ ) { |
| 17647 | if ( voices[i].tag == tag ) { |
| 17648 | voices[i].instrument->controlChange( number, value ); |
| 17649 | break; |
| 17650 | } |
| 17651 | } |
| 17652 | } |
| 17653 | |
| 17654 | void Voicer :: silence( void ) |
| 17655 | { |
| 17656 | for ( int i=0; i<nVoices; i++ ) { |
| 17657 | if ( voices[i].sounding > 0 ) |
| 17658 | voices[i].instrument->noteOff( 0.5 ); |
| 17659 | } |
| 17660 | } |
| 17661 | |
| 17662 | MY_FLOAT Voicer :: tick() |
| 17663 | { |
| 17664 | lastOutput = lastOutputLeft = lastOutputRight = 0.0; |
| 17665 | for ( int i=0; i<nVoices; i++ ) { |
| 17666 | if ( voices[i].sounding != 0 ) { |
| 17667 | lastOutput += voices[i].instrument->tick(); |
| 17668 | lastOutputLeft += voices[i].instrument->lastOutLeft(); |
| 17669 | lastOutputRight += voices[i].instrument->lastOutRight(); |
| 17670 | } |
| 17671 | if ( voices[i].sounding < 0 ) { |
| 17672 | voices[i].sounding++; |
| 17673 | if ( voices[i].sounding == 0 ) |
| 17674 | voices[i].noteNumber = -1; |
| 17675 | } |
| 17676 | } |
| 17677 | return lastOutput / nVoices; |
| 17678 | } |
| 17679 | |
| 17680 | MY_FLOAT *Voicer :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 17681 | { |
| 17682 | for (unsigned int i=0; i<vectorSize; i++) |
| 17683 | vec[i] = tick(); |
| 17684 | |
| 17685 | return vec; |
| 17686 | } |
| 17687 | |
| 17688 | MY_FLOAT Voicer :: lastOut() const |
| 17689 | { |
| 17690 | return lastOutput; |
| 17691 | } |
| 17692 | |
| 17693 | MY_FLOAT Voicer :: lastOutLeft() const |
| 17694 | { |
| 17695 | return lastOutputLeft; |
| 17696 | } |
| 17697 | |
| 17698 | MY_FLOAT Voicer :: lastOutRight() const |
| 17699 | { |
| 17700 | return lastOutputRight; |
| 17701 | } |
| 17702 | |
| 17703 | /***************************************************/ |
| 17704 | /*! \class WaveLoop |
| 17705 | \brief STK waveform oscillator class. |
| 17706 | |
| 17707 | This class inherits from WvIn and provides |
| 17708 | audio file looping functionality. |
| 17709 | |
| 17710 | WaveLoop supports multi-channel data in |
| 17711 | interleaved format. It is important to |
| 17712 | distinguish the tick() methods, which return |
| 17713 | samples produced by averaging across sample |
| 17714 | frames, from the tickFrame() methods, which |
| 17715 | return pointers to multi-channel sample frames. |
| 17716 | For single-channel data, these methods return |
| 17717 | equivalent values. |
| 17718 | |
| 17719 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 17720 | */ |
| 17721 | /***************************************************/ |
| 17722 | |
| 17723 | #include <math.h> |
| 17724 | |
| 17725 | WaveLoop :: WaveLoop( const char *fileName, bool raw, bool generate ) |
| 17726 | : WvIn( fileName, raw ), phaseOffset(0.0) |
| 17727 | { |
| 17728 | m_freq = 0; |
| 17729 | // If at end of file, redo extra sample frame for looping. |
| 17730 | if (chunkPointer+bufferSize == fileSize) { |
| 17731 | for (unsigned int j=0; j<channels; j++) |
| 17732 | data[bufferSize*channels+j] = data[j]; |
| 17733 | } |
| 17734 | |
| 17735 | } |
| 17736 | |
| 17737 | WaveLoop :: WaveLoop( ) |
| 17738 | : WvIn( ), phaseOffset(0.0) |
| 17739 | { m_freq = 0; } |
| 17740 | |
| 17741 | void |
| 17742 | WaveLoop :: openFile( const char * fileName, bool raw, bool norm ) |
| 17743 | { |
| 17744 | m_loaded = FALSE; |
| 17745 | WvIn::openFile( fileName, raw, norm ); |
| 17746 | // If at end of file, redo extra sample frame for looping. |
| 17747 | if (chunkPointer+bufferSize == fileSize) { |
| 17748 | for (unsigned int j=0; j<channels; j++) |
| 17749 | data[bufferSize*channels+j] = data[j]; |
| 17750 | } |
| 17751 | m_loaded = TRUE; |
| 17752 | } |
| 17753 | |
| 17754 | WaveLoop :: ~WaveLoop() |
| 17755 | { |
| 17756 | m_loaded = FALSE; |
| 17757 | } |
| 17758 | |
| 17759 | void WaveLoop :: readData( unsigned long index ) |
| 17760 | { |
| 17761 | WvIn::readData( index ); |
| 17762 | |
| 17763 | // If at end of file, redo extra sample frame for looping. |
| 17764 | if (chunkPointer+bufferSize == fileSize) { |
| 17765 | for (unsigned int j=0; j<channels; j++) |
| 17766 | data[bufferSize*channels+j] = data[j]; |
| 17767 | } |
| 17768 | } |
| 17769 | |
| 17770 | void WaveLoop :: setFrequency(MY_FLOAT aFrequency) |
| 17771 | { |
| 17772 | // This is a looping frequency. |
| 17773 | m_freq = aFrequency; // chuck data |
| 17774 | |
| 17775 | rate = fileSize * aFrequency / sampleRate(); |
| 17776 | } |
| 17777 | |
| 17778 | void WaveLoop :: addTime(MY_FLOAT aTime) |
| 17779 | { |
| 17780 | // Add an absolute time in samples |
| 17781 | time += aTime; |
| 17782 | |
| 17783 | while (time < 0.0) |
| 17784 | time += fileSize; |
| 17785 | while (time >= fileSize) |
| 17786 | time -= fileSize; |
| 17787 | } |
| 17788 | |
| 17789 | void WaveLoop :: addPhase(MY_FLOAT anAngle) |
| 17790 | { |
| 17791 | // Add a time in cycles (one cycle = fileSize). |
| 17792 | time += fileSize * anAngle; |
| 17793 | |
| 17794 | while (time < 0.0) |
| 17795 | time += fileSize; |
| 17796 | while (time >= fileSize) |
| 17797 | time -= fileSize; |
| 17798 | } |
| 17799 | |
| 17800 | void WaveLoop :: addPhaseOffset(MY_FLOAT anAngle) |
| 17801 | { |
| 17802 | // Add a phase offset in cycles, where 1.0 = fileSize. |
| 17803 | phaseOffset = fileSize * anAngle; |
| 17804 | } |
| 17805 | |
| 17806 | const MY_FLOAT * WaveLoop :: tickFrame(void) |
| 17807 | { |
| 17808 | /* register */ MY_FLOAT tyme, alpha; |
| 17809 | /* register */ unsigned long i, index; |
| 17810 | |
| 17811 | // Check limits of time address ... if necessary, recalculate modulo fileSize. |
| 17812 | while (time < 0.0) |
| 17813 | time += fileSize; |
| 17814 | while (time >= fileSize) |
| 17815 | time -= fileSize; |
| 17816 | |
| 17817 | if (phaseOffset) { |
| 17818 | tyme = time + phaseOffset; |
| 17819 | while (tyme < 0.0) |
| 17820 | tyme += fileSize; |
| 17821 | while (tyme >= fileSize) |
| 17822 | tyme -= fileSize; |
| 17823 | } |
| 17824 | else { |
| 17825 | tyme = time; |
| 17826 | } |
| 17827 | |
| 17828 | if (chunking) { |
| 17829 | // Check the time address vs. our current buffer limits. |
| 17830 | if ( (tyme < chunkPointer) || (tyme >= chunkPointer+bufferSize) ) |
| 17831 | this->readData((long) tyme); |
| 17832 | // Adjust index for the current buffer. |
| 17833 | tyme -= chunkPointer; |
| 17834 | } |
| 17835 | |
| 17836 | // Always do linear interpolation here ... integer part of time address. |
| 17837 | index = (unsigned long) tyme; |
| 17838 | |
| 17839 | // Fractional part of time address. |
| 17840 | alpha = tyme - (MY_FLOAT) index; |
| 17841 | index *= channels; |
| 17842 | for (i=0; i<channels; i++) { |
| 17843 | lastOutput[i] = data[index]; |
| 17844 | lastOutput[i] += (alpha * (data[index+channels] - lastOutput[i])); |
| 17845 | index++; |
| 17846 | // 1.5.0.0 (ge) | scaleToOne |
| 17847 | lastOutput[i] *= scaleToOne; |
| 17848 | } |
| 17849 | |
| 17850 | // if reading in chunks |
| 17851 | if(chunking) { |
| 17852 | // Scale outputs by gain. |
| 17853 | for (i=0; i<channels; i++) lastOutput[i] *= gain; |
| 17854 | } |
| 17855 | |
| 17856 | // Increment time, which can be negative. |
| 17857 | time += rate; |
| 17858 | |
| 17859 | return lastOutput; |
| 17860 | } |
| 17861 | |
| 17862 | /***************************************************/ |
| 17863 | /*! \class Whistle |
| 17864 | \brief STK police/referee whistle instrument class. |
| 17865 | |
| 17866 | This class implements a hybrid physical/spectral |
| 17867 | model of a police whistle (a la Cook). |
| 17868 | |
| 17869 | Control Change Numbers: |
| 17870 | - Noise Gain = 4 |
| 17871 | - Fipple Modulation Frequency = 11 |
| 17872 | - Fipple Modulation Gain = 1 |
| 17873 | - Blowing Frequency Modulation = 2 |
| 17874 | - Volume = 128 |
| 17875 | |
| 17876 | by Perry R. Cook 1996 - 2002. |
| 17877 | */ |
| 17878 | /***************************************************/ |
| 17879 | |
| 17880 | #include <stdlib.h> |
| 17881 | #include <math.h> |
| 17882 | |
| 17883 | #define CAN_RADIUS 100 |
| 17884 | #define PEA_RADIUS 30 |
| 17885 | #define BUMP_RADIUS 5 |
| 17886 | |
| 17887 | #define NORM_CAN_LOSS 0.97 |
| 17888 | #define SLOW_CAN_LOSS 0.90 |
| 17889 | #define GRAVITY 20.0 |
| 17890 | // GRAVITY WAS 6.0 |
| 17891 | |
| 17892 | #define NORM_TICK_SIZE 0.004 |
| 17893 | #define SLOW_TICK_SIZE 0.0001 |
| 17894 | |
| 17895 | #define ENV_RATE 0.001 |
| 17896 | |
| 17897 | Whistle :: Whistle() |
| 17898 | { |
| 17899 | tempVector = new Vector3D(0,0,0); |
| 17900 | can = new Sphere(CAN_RADIUS); |
| 17901 | pea = new Sphere(PEA_RADIUS); |
| 17902 | bumper = new Sphere(BUMP_RADIUS); |
| 17903 | |
| 17904 | // Concatenate the STK rawwave path to the rawwave file |
| 17905 | sine = new WaveLoop( "special:sinewave", TRUE ); |
| 17906 | sine->setFrequency(2800.0); |
| 17907 | |
| 17908 | can->setPosition(0, 0, 0); // set can location |
| 17909 | can->setVelocity(0, 0, 0); // and the velocity |
| 17910 | |
| 17911 | onepole.setPole(0.95); // 0.99 |
| 17912 | |
| 17913 | bumper->setPosition(0.0, CAN_RADIUS-BUMP_RADIUS, 0); |
| 17914 | bumper->setPosition(0.0, CAN_RADIUS-BUMP_RADIUS, 0); |
| 17915 | pea->setPosition(0, CAN_RADIUS/2, 0); |
| 17916 | pea->setVelocity(35, 15, 0); |
| 17917 | |
| 17918 | envelope.setRate(ENV_RATE); |
| 17919 | envelope.keyOn(); |
| 17920 | |
| 17921 | fippleFreqMod = 0.5; |
| 17922 | fippleGainMod = 0.5; |
| 17923 | blowFreqMod = 0.25; |
| 17924 | noiseGain = 0.125; |
| 17925 | maxPressure = (MY_FLOAT) 0.0; |
| 17926 | baseFrequency = 2000; |
| 17927 | |
| 17928 | tickSize = NORM_TICK_SIZE; |
| 17929 | canLoss = NORM_CAN_LOSS; |
| 17930 | |
| 17931 | subSample = 1; |
| 17932 | subSampCount = subSample; |
| 17933 | } |
| 17934 | |
| 17935 | Whistle :: ~Whistle() |
| 17936 | { |
| 17937 | delete tempVector; |
| 17938 | delete can; |
| 17939 | delete pea; |
| 17940 | delete bumper; |
| 17941 | delete sine; |
| 17942 | } |
| 17943 | |
| 17944 | void Whistle :: clear() |
| 17945 | { |
| 17946 | } |
| 17947 | |
| 17948 | void Whistle :: setFrequency(MY_FLOAT frequency) |
| 17949 | { |
| 17950 | MY_FLOAT freakency = frequency * 4; // the whistle is a transposing instrument |
| 17951 | if ( frequency <= 0.0 ) { |
| 17952 | CK_STDCERR << "[chuck](via STK): Whistle: setFrequency parameter is less than or equal to zero!" << CK_STDENDL; |
| 17953 | freakency = 220.0; |
| 17954 | } |
| 17955 | |
| 17956 | baseFrequency = freakency; |
| 17957 | } |
| 17958 | |
| 17959 | void Whistle :: startBlowing(MY_FLOAT amplitude, MY_FLOAT rate) |
| 17960 | { |
| 17961 | envelope.setRate(ENV_RATE); |
| 17962 | envelope.setTarget(amplitude); |
| 17963 | } |
| 17964 | |
| 17965 | void Whistle :: stopBlowing(MY_FLOAT rate) |
| 17966 | { |
| 17967 | envelope.setRate(rate); |
| 17968 | envelope.keyOff(); |
| 17969 | } |
| 17970 | |
| 17971 | void Whistle :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 17972 | { |
| 17973 | setFrequency(frequency); |
| 17974 | startBlowing(amplitude*2.0 ,amplitude * 0.2); |
| 17975 | #if defined(_STK_DEBUG_) |
| 17976 | CK_STDCERR << "[chuck](via STK): Whistle: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 17977 | #endif |
| 17978 | } |
| 17979 | |
| 17980 | void Whistle :: noteOff(MY_FLOAT amplitude) |
| 17981 | { |
| 17982 | this->stopBlowing(amplitude * 0.02); |
| 17983 | |
| 17984 | #if defined(_STK_DEBUG_) |
| 17985 | CK_STDCERR << "[chuck](via STK): Whistle: NoteOff amplitude = " << amplitude << CK_STDENDL; |
| 17986 | #endif |
| 17987 | } |
| 17988 | |
| 17989 | int frameCount = 0; |
| 17990 | |
| 17991 | MY_FLOAT Whistle :: tick() |
| 17992 | { |
| 17993 | MY_FLOAT soundMix, tempFreq; |
| 17994 | double envOut = 0, temp, temp1, temp2, tempX, tempY; |
| 17995 | double phi, cosphi, sinphi; |
| 17996 | double gain = 0.5, mod = 0.0; |
| 17997 | |
| 17998 | if (--subSampCount <= 0) { |
| 17999 | tempVectorP = pea->getPosition(); |
| 18000 | subSampCount = subSample; |
| 18001 | temp = bumper->isInside(tempVectorP); |
| 18002 | #ifdef WHISTLE_ANIMATION |
| 18003 | frameCount += 1; |
| 18004 | if (frameCount >= (1470 / subSample)) { |
| 18005 | frameCount = 0; |
| 18006 | // printf("%f %f %f\n",tempVectorP->getX(),tempVectorP->getY(),envOut); |
| 18007 | CK_FFLUSH_STDOUT(); |
| 18008 | } |
| 18009 | #endif |
| 18010 | envOut = envelope.tick(); |
| 18011 | |
| 18012 | if (temp < (BUMP_RADIUS + PEA_RADIUS)) { |
| 18013 | tempX = envOut * tickSize * 2000 * noise.tick(); |
| 18014 | tempY = -envOut * tickSize * 1000 * (1.0 + noise.tick()); |
| 18015 | pea->addVelocity(tempX,tempY,0); |
| 18016 | pea->tick(tickSize); |
| 18017 | } |
| 18018 | |
| 18019 | mod = exp(-temp * 0.01); // exp. distance falloff of fipple/pea effect |
| 18020 | temp = onepole.tick(mod); // smooth it a little |
| 18021 | gain = (1.0 - (fippleGainMod*0.5)) + (2.0 * fippleGainMod * temp); |
| 18022 | gain *= gain; // squared distance/gain |
| 18023 | // tempFreq = 1.0 // Normalized Base Freq |
| 18024 | // + (fippleFreqMod * 0.25) - (fippleFreqMod * temp) // fippleModulation |
| 18025 | // - (blowFreqMod) + (blowFreqMod * envOut); // blowingModulation |
| 18026 | // short form of above |
| 18027 | tempFreq = 1.0 + fippleFreqMod*(0.25-temp) + blowFreqMod*(envOut-1.0); |
| 18028 | tempFreq *= baseFrequency; |
| 18029 | |
| 18030 | sine->setFrequency(tempFreq); |
| 18031 | |
| 18032 | tempVectorP = pea->getPosition(); |
| 18033 | temp = can->isInside(tempVectorP); |
| 18034 | temp = -temp; // We know (hope) it's inside, just how much?? |
| 18035 | if (temp < (PEA_RADIUS * 1.25)) { |
| 18036 | pea->getVelocity(tempVector); // This is the can/pea collision |
| 18037 | tempX = tempVectorP->getX(); // calculation. Could probably |
| 18038 | tempY = tempVectorP->getY(); // simplify using tables, etc. |
| 18039 | phi = -atan2(tempY,tempX); |
| 18040 | cosphi = cos(phi); |
| 18041 | sinphi = sin(phi); |
| 18042 | temp1 = (cosphi*tempVector->getX()) - (sinphi*tempVector->getY()); |
| 18043 | temp2 = (sinphi*tempVector->getX()) + (cosphi*tempVector->getY()); |
| 18044 | temp1 = -temp1; |
| 18045 | tempX = (cosphi*temp1) + (sinphi*temp2); |
| 18046 | tempY = (-sinphi*temp1) + (cosphi*temp2); |
| 18047 | pea->setVelocity(tempX, tempY, 0); |
| 18048 | pea->tick(tickSize); |
| 18049 | pea->setVelocity(tempX*canLoss, tempY*canLoss, 0); |
| 18050 | pea->tick(tickSize); |
| 18051 | } |
| 18052 | |
| 18053 | temp = tempVectorP->getLength(); |
| 18054 | if (temp > 0.01) { |
| 18055 | tempX = tempVectorP->getX(); |
| 18056 | tempY = tempVectorP->getY(); |
| 18057 | phi = atan2(tempY,tempX); |
| 18058 | phi += 0.3 * temp / CAN_RADIUS; |
| 18059 | cosphi = cos(phi); |
| 18060 | sinphi = sin(phi); |
| 18061 | tempX = 3.0 * temp * cosphi; |
| 18062 | tempY = 3.0 * temp * sinphi; |
| 18063 | } |
| 18064 | else { |
| 18065 | tempX = 0.0; |
| 18066 | tempY = 0.0; |
| 18067 | } |
| 18068 | |
| 18069 | temp = (0.9 + 0.1*subSample*noise.tick()) * envOut * 0.6 * tickSize; |
| 18070 | pea->addVelocity(temp * tempX, |
| 18071 | (temp*tempY) - (GRAVITY*tickSize),0); |
| 18072 | pea->tick(tickSize); |
| 18073 | |
| 18074 | // bumper->tick(0.0); |
| 18075 | } |
| 18076 | |
| 18077 | temp = envOut * envOut * gain / 2; |
| 18078 | soundMix = temp * (sine->tick() + (noiseGain*noise.tick())); |
| 18079 | lastOutput = 0.25 * soundMix; // should probably do one-zero filter here |
| 18080 | |
| 18081 | return lastOutput; |
| 18082 | } |
| 18083 | |
| 18084 | void Whistle :: controlChange(int number, MY_FLOAT value) |
| 18085 | { |
| 18086 | MY_FLOAT norm = value * ONE_OVER_128; |
| 18087 | if ( norm < 0 ) { |
| 18088 | norm = 0.0; |
| 18089 | CK_STDCERR << "[chuck](via STK): Whistle: Control value less than zero!" << CK_STDENDL; |
| 18090 | } |
| 18091 | else if ( norm > 1.0 ) { |
| 18092 | norm = 1.0; |
| 18093 | CK_STDCERR << "[chuck](via STK): Whistle: Control value exceeds nominal range!" << CK_STDENDL; |
| 18094 | } |
| 18095 | |
| 18096 | if (number == __SK_NoiseLevel_) // 4 |
| 18097 | noiseGain = 0.25 * norm; |
| 18098 | else if (number == __SK_ModFrequency_) // 11 |
| 18099 | fippleFreqMod = norm; |
| 18100 | else if (number == __SK_ModWheel_) // 1 |
| 18101 | fippleGainMod = norm; |
| 18102 | else if (number == __SK_AfterTouch_Cont_) // 128 |
| 18103 | envelope.setTarget( norm * 2.0 ); |
| 18104 | else if (number == __SK_Breath_) // 2 |
| 18105 | blowFreqMod = norm * 0.5; |
| 18106 | else if (number == __SK_Sustain_) // 64 |
| 18107 | { if (value < 1.0) subSample = 1; } |
| 18108 | else |
| 18109 | CK_STDCERR << "[chuck](via STK): Whistle: Undefined Control Number (" << number << ")!!" << CK_STDENDL; |
| 18110 | |
| 18111 | #if defined(_STK_DEBUG_) |
| 18112 | CK_STDCERR << "[chuck](via STK): Whistle: controlChange number = " << number << ", value = " << value << CK_STDENDL; |
| 18113 | #endif |
| 18114 | } |
| 18115 | |
| 18116 | /***************************************************/ |
| 18117 | /*! \class Wurley |
| 18118 | \brief STK Wurlitzer electric piano FM |
| 18119 | synthesis instrument. |
| 18120 | |
| 18121 | This class implements two simple FM Pairs |
| 18122 | summed together, also referred to as algorithm |
| 18123 | 5 of the TX81Z. |
| 18124 | |
| 18125 | \code |
| 18126 | Algorithm 5 is : 4->3--\ |
| 18127 | + --> Out |
| 18128 | 2->1--/ |
| 18129 | \endcode |
| 18130 | |
| 18131 | Control Change Numbers: |
| 18132 | - Modulator Index One = 2 |
| 18133 | - Crossfade of Outputs = 4 |
| 18134 | - LFO Speed = 11 |
| 18135 | - LFO Depth = 1 |
| 18136 | - ADSR 2 & 4 Target = 128 |
| 18137 | |
| 18138 | The basic Chowning/Stanford FM patent expired |
| 18139 | in 1995, but there exist follow-on patents, |
| 18140 | mostly assigned to Yamaha. If you are of the |
| 18141 | type who should worry about this (making |
| 18142 | money) worry away. |
| 18143 | |
| 18144 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 18145 | */ |
| 18146 | /***************************************************/ |
| 18147 | |
| 18148 | |
| 18149 | Wurley :: Wurley() |
| 18150 | : FM() |
| 18151 | { |
| 18152 | // Concatenate the STK rawwave path to the rawwave files |
| 18153 | for ( int i=0; i<3; i++ ) waves[i] = new WaveLoop( "special:sinewave", TRUE ); |
| 18154 | waves[3] = new WaveLoop( "special:fwavblnk", TRUE ); |
| 18155 | |
| 18156 | this->setRatio(0, 1.0); |
| 18157 | this->setRatio(1, 4.0); |
| 18158 | this->setRatio(2, -510.0); |
| 18159 | this->setRatio(3, -510.0); |
| 18160 | |
| 18161 | gains[0] = __FM_gains[99]; |
| 18162 | gains[1] = __FM_gains[82]; |
| 18163 | gains[2] = __FM_gains[92]; |
| 18164 | gains[3] = __FM_gains[68]; |
| 18165 | |
| 18166 | // 1.4.1.0 (prc) REPARIATHON2021 ADDITION |
| 18167 | baseGains[0] = gains[0]; |
| 18168 | baseGains[1] = gains[1]; |
| 18169 | baseGains[2] = gains[2]; |
| 18170 | baseGains[3] = gains[3]; |
| 18171 | |
| 18172 | adsr[0]->setAllTimes( 0.001, 1.50, 0.0, 0.04); |
| 18173 | adsr[1]->setAllTimes( 0.001, 1.50, 0.0, 0.04); |
| 18174 | adsr[2]->setAllTimes( 0.001, 0.25, 0.0, 0.04); |
| 18175 | adsr[3]->setAllTimes( 0.001, 0.15, 0.0, 0.04); |
| 18176 | |
| 18177 | twozero->setGain( 2.0 ); |
| 18178 | op4Feedback = 2.0; // 1.4.1.0 |
| 18179 | vibrato->setFrequency( 8.0 ); |
| 18180 | |
| 18181 | bCompatible = 1; // 1.4.1.0 (prc) REPAIRATHON2021 HACK: When created, I'm a Wurley, that can change... |
| 18182 | } |
| 18183 | |
| 18184 | Wurley :: ~Wurley() |
| 18185 | { |
| 18186 | // note: waves array taken care of in FM destructor |
| 18187 | } |
| 18188 | |
| 18189 | void Wurley :: setFrequency(MY_FLOAT frequency) |
| 18190 | { |
| 18191 | baseFrequency = frequency; |
| 18192 | waves[0]->setFrequency(baseFrequency * ratios[0]); |
| 18193 | waves[1]->setFrequency(baseFrequency * ratios[1]); |
| 18194 | waves[2]->setFrequency(ratios[2]); // Note here a 'fixed resonance'. |
| 18195 | waves[3]->setFrequency(ratios[3]); |
| 18196 | |
| 18197 | // chuck |
| 18198 | m_frequency = baseFrequency; |
| 18199 | } |
| 18200 | |
| 18201 | void Wurley :: noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) |
| 18202 | { |
| 18203 | // 1.4.1.0 (prc) REPAIRATHON2021 commented out |
| 18204 | // gains[0] = amplitude * __FM_gains[99]; // OLD WAY OF DOING IT |
| 18205 | // gains[1] = amplitude * __FM_gains[82]; // DELETE THESE SOMEDAY |
| 18206 | // gains[2] = amplitude * __FM_gains[82]; |
| 18207 | // gains[3] = amplitude * __FM_gains[68]; |
| 18208 | |
| 18209 | // 1.4.1.0 (prc) REPAIRATHON2021 added |
| 18210 | gains[0] = amplitude * baseGains[0]; |
| 18211 | gains[1] = amplitude * baseGains[1]; |
| 18212 | gains[2] = amplitude * baseGains[2]; |
| 18213 | gains[3] = amplitude * baseGains[3]; |
| 18214 | |
| 18215 | this->setFrequency(frequency); |
| 18216 | this->keyOn(); |
| 18217 | |
| 18218 | #if defined(_STK_DEBUG_) |
| 18219 | CK_STDCERR << "Wurley: NoteOn frequency = " << frequency << ", amplitude = " << amplitude << CK_STDENDL; |
| 18220 | #endif |
| 18221 | } |
| 18222 | |
| 18223 | MY_FLOAT Wurley :: tick() // 1.4.1.0 (prc) REPAIRATHON2021 updated |
| 18224 | { |
| 18225 | MY_FLOAT temp, temp2; |
| 18226 | |
| 18227 | temp2 = vibrato->tick(); |
| 18228 | |
| 18229 | if (bCompatible) { // 1.4.1.0 (prc) REPAIRATHON COMPATIBILITY, "I'm still a Wurley" |
| 18230 | temp = gains[1] * adsr[1]->tick() * waves[1]->tick(); |
| 18231 | temp = temp * control1; |
| 18232 | |
| 18233 | waves[0]->addPhaseOffset(temp); |
| 18234 | waves[3]->addPhaseOffset(twozero->lastOut()); |
| 18235 | temp = gains[3] * adsr[3]->tick() * waves[3]->tick(); |
| 18236 | twozero->tick(temp); |
| 18237 | |
| 18238 | waves[2]->addPhaseOffset(temp); |
| 18239 | temp = ( 1.0 - (control2 * 0.5)) * gains[0] * adsr[0]->tick() * waves[0]->tick(); |
| 18240 | temp += control2 * 0.5 * gains[2] * adsr[2]->tick() * waves[2]->tick(); |
| 18241 | |
| 18242 | // Calculate amplitude modulation and apply it to output. |
| 18243 | temp2 *= modDepth; |
| 18244 | temp = temp * (1.0 + temp2); |
| 18245 | } else { // 1.4.1.0 (prc) REPAIRATHON NEW FUNCTIONs, modDepth = vibrato, opAMs[n] = AM |
| 18246 | temp = temp2 * modDepth * 0.2; |
| 18247 | for (int i = 0; i < 4; i++) { |
| 18248 | if (ratios[i] > 0.0) { |
| 18249 | waves[i]->setFrequency(baseFrequency * (1.0 + temp) * ratios[i]); |
| 18250 | } |
| 18251 | } |
| 18252 | temp = (1.0 + opAMs[1] * temp2) * gains[1] * adsr[1]->tick() * waves[1]->tick(); |
| 18253 | temp = temp * control1; |
| 18254 | |
| 18255 | waves[0]->addPhaseOffset(temp); |
| 18256 | waves[3]->addPhaseOffset(twozero->lastOut()); |
| 18257 | temp = (1.0 + opAMs[3] * temp2) * gains[3] * adsr[3]->tick() * waves[3]->tick(); |
| 18258 | twozero->tick(temp); |
| 18259 | |
| 18260 | waves[2]->addPhaseOffset(temp); |
| 18261 | temp = ( 1.0 - (control2 * 0.5) + (opAMs[0] * temp2)) * gains[0] * adsr[0]->tick() * waves[0]->tick(); |
| 18262 | temp += (1.0 + opAMs[2] * temp2) * control2 * 0.5 * gains[2] * adsr[2]->tick() * waves[2]->tick(); |
| 18263 | } |
| 18264 | |
| 18265 | lastOutput = temp * 0.5; |
| 18266 | return lastOutput; |
| 18267 | } |
| 18268 | |
| 18269 | // CHUCK HACK: |
| 18270 | void Wurley :: controlChange( int which, MY_FLOAT value ) |
| 18271 | { |
| 18272 | if( which == 3 ) |
| 18273 | { |
| 18274 | adsr[0]->setAllTimes( 0.001, 1.50 * value, 0.0, 0.04); |
| 18275 | adsr[1]->setAllTimes( 0.001, 1.50 * value, 0.0, 0.04); |
| 18276 | adsr[2]->setAllTimes( 0.001, 0.25 * value, 0.0, 0.04); |
| 18277 | adsr[3]->setAllTimes( 0.001, 0.15 * value, 0.0, 0.04); |
| 18278 | } |
| 18279 | else |
| 18280 | { |
| 18281 | // call parent |
| 18282 | FM::controlChange( which, value ); |
| 18283 | } |
| 18284 | } |
| 18285 | |
| 18286 | |
| 18287 | /***************************************************/ |
| 18288 | /*! \class WvIn |
| 18289 | \brief STK audio data input base class. |
| 18290 | |
| 18291 | This class provides input support for various |
| 18292 | audio file formats. It also serves as a base |
| 18293 | class for "realtime" streaming subclasses. |
| 18294 | |
| 18295 | WvIn loads the contents of an audio file for |
| 18296 | subsequent output. Linear interpolation is |
| 18297 | used for fractional "read rates". |
| 18298 | |
| 18299 | WvIn supports multi-channel data in interleaved |
| 18300 | format. It is important to distinguish the |
| 18301 | tick() methods, which return samples produced |
| 18302 | by averaging across sample frames, from the |
| 18303 | tickFrame() methods, which return pointers to |
| 18304 | multi-channel sample frames. For single-channel |
| 18305 | data, these methods return equivalent values. |
| 18306 | |
| 18307 | Small files are completely read into local memory |
| 18308 | during instantiation. Large files are read |
| 18309 | incrementally from disk. The file size threshold |
| 18310 | and the increment size values are defined in |
| 18311 | WvIn.h. |
| 18312 | |
| 18313 | WvIn currently supports WAV, AIFF, SND (AU), |
| 18314 | MAT-file (Matlab), and STK RAW file formats. |
| 18315 | Signed integer (8-, 16-, and 32-bit) and floating- |
| 18316 | point (32- and 64-bit) data types are supported. |
| 18317 | Uncompressed data types are not supported. If |
| 18318 | using MAT-files, data should be saved in an array |
| 18319 | with each data channel filling a matrix row. |
| 18320 | |
| 18321 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 18322 | */ |
| 18323 | /***************************************************/ |
| 18324 | |
| 18325 | #include <sys/stat.h> |
| 18326 | #include <sys/types.h> |
| 18327 | #include <math.h> |
| 18328 | #include <string.h> |
| 18329 | |
| 18330 | #include <iostream> |
| 18331 | |
| 18332 | #include "util_raw.h" |
| 18333 | |
| 18334 | WvIn :: WvIn() |
| 18335 | { |
| 18336 | init(); |
| 18337 | } |
| 18338 | |
| 18339 | WvIn :: WvIn( const char *fileName, bool raw, bool doNormalize, bool generate ) |
| 18340 | { |
| 18341 | init(); |
| 18342 | openFile( fileName, raw, doNormalize, generate ); |
| 18343 | } |
| 18344 | |
| 18345 | WvIn :: ~WvIn() |
| 18346 | { |
| 18347 | if (fd) |
| 18348 | fclose(fd); |
| 18349 | |
| 18350 | if (data) |
| 18351 | delete [] data; |
| 18352 | |
| 18353 | if (lastOutput) |
| 18354 | delete [] lastOutput; |
| 18355 | |
| 18356 | m_loaded = false; |
| 18357 | } |
| 18358 | |
| 18359 | void WvIn :: init( void ) |
| 18360 | { |
| 18361 | fd = 0; |
| 18362 | data = 0; |
| 18363 | lastOutput = 0; |
| 18364 | m_loaded = false; |
| 18365 | chunking = false; |
| 18366 | finished = true; |
| 18367 | interpolate = false; |
| 18368 | bufferSize = 0; |
| 18369 | channels = 0; |
| 18370 | time = 0.0; |
| 18371 | |
| 18372 | // 1.5.0.0 (ge) added initialization |
| 18373 | byteswap = false; |
| 18374 | fileSize = 0; |
| 18375 | dataOffset = 0; |
| 18376 | chunkPointer = 0; |
| 18377 | fileRate = 0; |
| 18378 | gain = 1; |
| 18379 | rate = 1; |
| 18380 | scaleToOne = 1; |
| 18381 | memset( msg, 0, sizeof(msg) ); |
| 18382 | } |
| 18383 | |
| 18384 | void WvIn :: closeFile( void ) |
| 18385 | { |
| 18386 | if ( fd ) fclose( fd ); |
| 18387 | finished = true; |
| 18388 | str_filename = ""; |
| 18389 | } |
| 18390 | |
| 18391 | void WvIn :: openFile( const char *fileName, bool raw, bool doNormalize, bool generate ) |
| 18392 | { |
| 18393 | unsigned long lastChannels = channels; |
| 18394 | unsigned long samples, lastSamples = (bufferSize+1)*channels; |
| 18395 | str_filename = fileName; |
| 18396 | //strncpy ( m_filename, fileName, 255 ); |
| 18397 | //m_filename[255] = '\0'; |
| 18398 | if(!generate || !strstr(fileName, "special:")) |
| 18399 | { |
| 18400 | closeFile(); |
| 18401 | |
| 18402 | // Try to open the file. |
| 18403 | fd = fopen(fileName, "rb"); |
| 18404 | if (!fd) { |
| 18405 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): Could not open or find file (%s).", fileName); |
| 18406 | handleError(msg, StkError::FILE_NOT_FOUND); |
| 18407 | } |
| 18408 | |
| 18409 | bool result = false; |
| 18410 | if ( raw ) |
| 18411 | result = getRawInfo( fileName ); |
| 18412 | else { |
| 18413 | char header[12]; |
| 18414 | if ( fread(&header, 4, 3, fd) != 3 ) goto error; |
| 18415 | if ( !strncmp(header, "RIFF", 4) && |
| 18416 | !strncmp(&header[8], "WAVE", 4) ) |
| 18417 | result = getWavInfo( fileName ); |
| 18418 | else if ( !strncmp(header, ".snd", 4) ) |
| 18419 | result = getSndInfo( fileName ); |
| 18420 | else if ( !strncmp(header, "FORM", 4) && |
| 18421 | (!strncmp(&header[8], "AIFF", 4) || !strncmp(&header[8], "AIFC", 4) ) ) |
| 18422 | result = getAifInfo( fileName ); |
| 18423 | else { |
| 18424 | if ( fseek(fd, 126, SEEK_SET) == -1 ) goto error; |
| 18425 | if ( fread(&header, 2, 1, fd) != 1 ) goto error; |
| 18426 | if (!strncmp(header, "MI", 2) || |
| 18427 | !strncmp(header, "IM", 2) ) |
| 18428 | result = getMatInfo( fileName ); |
| 18429 | else { |
| 18430 | raw = TRUE; |
| 18431 | result = getRawInfo( fileName ); |
| 18432 | // snprintf(msg, STK_MSG_BUF_LENGTH, "WvIn: File (%s) format unknown.", fileName); |
| 18433 | // handleError(msg, StkError::FILE_UNKNOWN_FORMAT); |
| 18434 | } |
| 18435 | } |
| 18436 | } |
| 18437 | |
| 18438 | if ( result == false ) |
| 18439 | handleError(msg, StkError::FILE_ERROR); |
| 18440 | |
| 18441 | if ( fileSize == 0 ) { |
| 18442 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): File (%s) data size is zero!", fileName); |
| 18443 | handleError(msg, StkError::FILE_ERROR); |
| 18444 | } |
| 18445 | } |
| 18446 | else |
| 18447 | { |
| 18448 | bufferSize = 1024; |
| 18449 | channels = 1; |
| 18450 | } |
| 18451 | |
| 18452 | // Allocate new memory if necessary. |
| 18453 | samples = (bufferSize+1)*channels; |
| 18454 | if ( lastSamples < samples ) { |
| 18455 | if ( data ) delete [] data; |
| 18456 | data = (MY_FLOAT *) new MY_FLOAT[samples]; |
| 18457 | } |
| 18458 | if ( lastChannels < channels ) { |
| 18459 | if ( lastOutput ) delete [] lastOutput; |
| 18460 | lastOutput = (MY_FLOAT *) new MY_FLOAT[channels]; |
| 18461 | } |
| 18462 | |
| 18463 | if ( fmod(rate, 1.0) != 0.0 ) interpolate = true; |
| 18464 | chunkPointer = 0; |
| 18465 | |
| 18466 | reset(); |
| 18467 | if(generate && strstr(fileName, "special:")) |
| 18468 | { |
| 18469 | // STK rawwave files have no header and are assumed to contain a |
| 18470 | // monophonic stream of 16-bit signed integers in big-endian byte |
| 18471 | // order with a sample rate of 22050 Hz. |
| 18472 | fileSize = bufferSize; |
| 18473 | dataOffset = 0; |
| 18474 | interpolate = true; |
| 18475 | chunking = false; |
| 18476 | dataType = STK_SINT16; |
| 18477 | byteswap = false; |
| 18478 | fileRate = 22050.0; |
| 18479 | rate = (MY_FLOAT)fileRate / Stk::sampleRate(); |
| 18480 | |
| 18481 | // which |
| 18482 | if( strstr(fileName, "special:sinewave") ) |
| 18483 | { |
| 18484 | for (unsigned int j=0; j<bufferSize; j++) |
| 18485 | data[j] = (SHRT_MAX) * sin(2*CK_ONE_PI*j/bufferSize); |
| 18486 | } |
| 18487 | else |
| 18488 | { |
| 18489 | SAMPLE * rawdata = NULL; |
| 18490 | t_CKUINT rawsize = 0; |
| 18491 | |
| 18492 | if( strstr(fileName, "special:aaa") || |
| 18493 | strstr(fileName, "special:aah") || |
| 18494 | strstr(fileName, "special:ahh") ) { |
| 18495 | rawsize = ahh_size; rawdata = ahh_data; |
| 18496 | } |
| 18497 | else if( strstr(fileName, "special:britestk") ) { |
| 18498 | rawsize = britestk_size; rawdata = britestk_data; |
| 18499 | } |
| 18500 | else if( strstr(fileName, "special:doh") || strstr(fileName, "special:dope") ) { |
| 18501 | rawsize = dope_size; rawdata = dope_data; |
| 18502 | } |
| 18503 | else if( strstr(fileName, "special:eee") ) { |
| 18504 | rawsize = eee_size; rawdata = eee_data; |
| 18505 | } |
| 18506 | else if( strstr(fileName, "special:fwavblnk") ) { |
| 18507 | rawsize = fwavblnk_size; rawdata = fwavblnk_data; |
| 18508 | } |
| 18509 | else if( strstr(fileName, "special:halfwave") ) { |
| 18510 | rawsize = halfwave_size; rawdata = halfwave_data; |
| 18511 | } |
| 18512 | else if( strstr(fileName, "special:impuls10") ) { |
| 18513 | rawsize = impuls10_size; rawdata = impuls10_data; |
| 18514 | } |
| 18515 | else if( strstr(fileName, "special:impuls20") ) { |
| 18516 | rawsize = impuls20_size; rawdata = impuls20_data; |
| 18517 | } |
| 18518 | else if( strstr(fileName, "special:impuls40") ) { |
| 18519 | rawsize = impuls40_size; rawdata = impuls40_data; |
| 18520 | } |
| 18521 | else if( strstr(fileName, "special:mand1") ) { |
| 18522 | rawsize = mand1_size; rawdata = mand1_data; |
| 18523 | } |
| 18524 | else if( strstr(fileName, "special:mandpluk") ) { |
| 18525 | rawsize = mandpluk_size; rawdata = mandpluk_data; |
| 18526 | } |
| 18527 | else if( strstr(fileName, "special:marmstk1") ) { |
| 18528 | rawsize = marmstk1_size; rawdata = marmstk1_data; |
| 18529 | } |
| 18530 | else if( strstr(fileName, "special:ooo") ) { |
| 18531 | rawsize = ooo_size; rawdata = ooo_data; |
| 18532 | } |
| 18533 | else if( strstr(fileName, "special:peksblnk") ) { |
| 18534 | rawsize = peksblnk_size; rawdata = peksblnk_data; |
| 18535 | } |
| 18536 | else if( strstr(fileName, "special:ppksblnk") ) { |
| 18537 | rawsize = ppksblnk_size; rawdata = ppksblnk_data; |
| 18538 | } |
| 18539 | else if( strstr(fileName, "special:silence") ) { |
| 18540 | rawsize = silence_size; rawdata = silence_data; |
| 18541 | } |
| 18542 | else if( strstr(fileName, "special:sineblnk") ) { |
| 18543 | rawsize = sineblnk_size; rawdata = sineblnk_data; |
| 18544 | } |
| 18545 | else if( strstr(fileName, "special:sinewave") ) { |
| 18546 | rawsize = sinewave_size; rawdata = sinewave_data; |
| 18547 | } |
| 18548 | else if( strstr(fileName, "special:snglpeak") ) { |
| 18549 | rawsize = snglpeak_size; rawdata = snglpeak_data; |
| 18550 | } |
| 18551 | else if( strstr(fileName, "special:twopeaks") ) { |
| 18552 | rawsize = twopeaks_size; rawdata = twopeaks_data; |
| 18553 | } |
| 18554 | else if( strstr(fileName, "special:glot_pop") ) { |
| 18555 | rawsize = glot_pop_size; rawdata = glot_pop_data; |
| 18556 | fileRate = 44100.0; rate = (MY_FLOAT)44100.0 / Stk::sampleRate(); |
| 18557 | } |
| 18558 | else if( strstr(fileName, "special:glot_ahh") ) { |
| 18559 | rawsize = glot_ahh_size; rawdata = glot_ahh_data; |
| 18560 | fileRate = 44100.0; rate = (MY_FLOAT)44100.0 / Stk::sampleRate(); |
| 18561 | } |
| 18562 | else if( strstr(fileName, "special:glot_eee" ) ) { |
| 18563 | rawsize = glot_eee_size; rawdata = glot_eee_data; |
| 18564 | fileRate = 44100.0; rate = (MY_FLOAT)44100.0 / Stk::sampleRate(); |
| 18565 | } |
| 18566 | else if( strstr(fileName, "special:glot_ooo" ) ) { |
| 18567 | rawsize = glot_ooo_size; rawdata = glot_ooo_data; |
| 18568 | fileRate = 44100.0; rate = (MY_FLOAT)44100.0 / Stk::sampleRate(); |
| 18569 | } |
| 18570 | |
| 18571 | if ( rawdata ) { |
| 18572 | if ( data ) delete [] data; |
| 18573 | data = (MY_FLOAT *) new MY_FLOAT[rawsize+1]; |
| 18574 | bufferSize = rawsize; |
| 18575 | fileSize = bufferSize; |
| 18576 | for ( int j=0; j < rawsize; j++ ) { |
| 18577 | data[j] = (MY_FLOAT) rawdata[j]; |
| 18578 | } |
| 18579 | } |
| 18580 | else |
| 18581 | goto error; |
| 18582 | } |
| 18583 | data[bufferSize] = data[0]; |
| 18584 | } |
| 18585 | else readData( 0 ); // Load file data. |
| 18586 | |
| 18587 | // check normalize |
| 18588 | if( doNormalize ) { |
| 18589 | normalize(); |
| 18590 | } else { |
| 18591 | // 1.5.0.0 (ge) | added scaling to range [-1,1] |
| 18592 | if ( dataType == STK_SINT8 ) scaleToOne = 1.0 / 128.0; |
| 18593 | else if ( dataType == STK_SINT16 ) scaleToOne = 1.0 / 32768.0; |
| 18594 | else if ( dataType == STK_SINT24 ) scaleToOne = 1.0 / 8388608.0; |
| 18595 | else if ( dataType == STK_SINT32 ) scaleToOne = 1.0 / 2147483648.0; |
| 18596 | else if ( dataType == MY_FLOAT32 || dataType == MY_FLOAT64 ) scaleToOne = 1.0; |
| 18597 | else scaleToOne = 1.0; |
| 18598 | } |
| 18599 | m_loaded = true; |
| 18600 | finished = false; |
| 18601 | interpolate = ( fmod( rate, 1.0 ) != 0.0 ); |
| 18602 | return; |
| 18603 | |
| 18604 | error: |
| 18605 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): Error reading file (%s).", fileName); |
| 18606 | handleError(msg, StkError::FILE_ERROR); |
| 18607 | } |
| 18608 | |
| 18609 | bool WvIn :: getRawInfo( const char *fileName ) |
| 18610 | { |
| 18611 | // Use the system call "stat" to determine the file length. |
| 18612 | struct stat filestat; |
| 18613 | if ( stat(fileName, &filestat) == -1 ) { |
| 18614 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): Could not stat RAW file (%s).", fileName); |
| 18615 | return false; |
| 18616 | } |
| 18617 | |
| 18618 | fileSize = (long) filestat.st_size / 2; // length in 2-byte samples |
| 18619 | bufferSize = fileSize; |
| 18620 | if (fileSize > CHUNK_THRESHOLD) { |
| 18621 | chunking = true; |
| 18622 | bufferSize = CHUNK_SIZE; |
| 18623 | gain = 1.0 / 32768.0; |
| 18624 | } |
| 18625 | |
| 18626 | // STK rawwave files have no header and are assumed to contain a |
| 18627 | // monophonic stream of 16-bit signed integers in big-endian byte |
| 18628 | // order with a sample rate of 22050 Hz. |
| 18629 | channels = 1; |
| 18630 | dataOffset = 0; |
| 18631 | rate = (MY_FLOAT) 22050.0 / Stk::sampleRate(); |
| 18632 | fileRate = 22050.0; |
| 18633 | interpolate = false; |
| 18634 | dataType = STK_SINT16; |
| 18635 | byteswap = false; |
| 18636 | if( little_endian ) |
| 18637 | byteswap = true; |
| 18638 | |
| 18639 | return true; |
| 18640 | } |
| 18641 | |
| 18642 | bool WvIn :: getWavInfo( const char *fileName ) |
| 18643 | { |
| 18644 | // Find "format" chunk ... it must come before the "data" chunk. |
| 18645 | char id[4]; |
| 18646 | SINT32 chunkSize; |
| 18647 | if ( fread(&id, 4, 1, fd) != 1 ) goto error; |
| 18648 | while ( strncmp(id, "fmt ", 4) ) { |
| 18649 | if ( fread(&chunkSize, 4, 1, fd) != 1 ) goto error; |
| 18650 | if( !little_endian ) |
| 18651 | swap32((unsigned char *)&chunkSize); |
| 18652 | |
| 18653 | if ( fseek(fd, chunkSize, SEEK_CUR) == -1 ) goto error; |
| 18654 | if ( fread(&id, 4, 1, fd) != 1 ) goto error; |
| 18655 | } |
| 18656 | |
| 18657 | // Check that the data is not compressed. |
| 18658 | SINT16 format_tag; |
| 18659 | if ( fread(&chunkSize, 4, 1, fd) != 1 ) goto error; // Read fmt chunk size. |
| 18660 | if ( fread(&format_tag, 2, 1, fd) != 1 ) goto error; |
| 18661 | if( !little_endian ) |
| 18662 | { |
| 18663 | swap16((unsigned char *)&format_tag); |
| 18664 | swap32((unsigned char *)&chunkSize); |
| 18665 | } |
| 18666 | if (format_tag != 1 && format_tag != 3 ) { // PCM = 1, FLOAT = 3 |
| 18667 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): %s contains an unsupported data format type (%d).", fileName, format_tag); |
| 18668 | return false; |
| 18669 | } |
| 18670 | |
| 18671 | // Get number of channels from the header. |
| 18672 | SINT16 temp; |
| 18673 | if ( fread(&temp, 2, 1, fd) != 1 ) goto error; |
| 18674 | if( !little_endian ) |
| 18675 | swap16((unsigned char *)&temp); |
| 18676 | |
| 18677 | channels = (unsigned int ) temp; |
| 18678 | |
| 18679 | // Get file sample rate from the header. |
| 18680 | SINT32 theSrate; |
| 18681 | if ( fread(&theSrate, 4, 1, fd) != 1 ) goto error; |
| 18682 | if( !little_endian ) |
| 18683 | swap32((unsigned char *)&theSrate); |
| 18684 | |
| 18685 | fileRate = (MY_FLOAT)theSrate; |
| 18686 | |
| 18687 | // Set default rate based on file sampling rate. |
| 18688 | rate = (MY_FLOAT)(theSrate / Stk::sampleRate() ); |
| 18689 | |
| 18690 | // Determine the data type. |
| 18691 | dataType = 0; |
| 18692 | if ( fseek(fd, 6, SEEK_CUR) == -1 ) goto error; // Locate bits_per_sample info. |
| 18693 | if ( fread(&temp, 2, 1, fd) != 1 ) goto error; |
| 18694 | if( !little_endian ) |
| 18695 | swap16((unsigned char *)&temp); |
| 18696 | |
| 18697 | if ( format_tag == 1 ) { |
| 18698 | if (temp == 8) |
| 18699 | dataType = STK_SINT8; |
| 18700 | else if (temp == 16) |
| 18701 | dataType = STK_SINT16; |
| 18702 | else if (temp == 24) // 1.5.0.1 (ge) added |
| 18703 | dataType = STK_SINT24; |
| 18704 | else if (temp == 32) |
| 18705 | dataType = STK_SINT32; |
| 18706 | } |
| 18707 | else if ( format_tag == 3 ) { |
| 18708 | if (temp == 32) |
| 18709 | dataType = MY_FLOAT32; |
| 18710 | else if (temp == 64) |
| 18711 | dataType = MY_FLOAT64; |
| 18712 | } |
| 18713 | if ( dataType == 0 ) { |
| 18714 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): %d bits per sample with data format %d are not supported (%s).", temp, format_tag, fileName); |
| 18715 | return false; |
| 18716 | } |
| 18717 | |
| 18718 | // Jump over any remaining part of the "fmt" chunk. |
| 18719 | if ( fseek(fd, chunkSize-16, SEEK_CUR) == -1 ) goto error; |
| 18720 | |
| 18721 | // Find "data" chunk ... it must come after the "fmt" chunk. |
| 18722 | if ( fread(&id, 4, 1, fd) != 1 ) goto error; |
| 18723 | |
| 18724 | while ( strncmp(id, "data", 4) ) { |
| 18725 | if ( fread(&chunkSize, 4, 1, fd) != 1 ) goto error; |
| 18726 | if( !little_endian ) |
| 18727 | swap32((unsigned char *)&chunkSize); |
| 18728 | |
| 18729 | if ( fseek(fd, chunkSize, SEEK_CUR) == -1 ) goto error; |
| 18730 | if ( fread(&id, 4, 1, fd) != 1 ) goto error; |
| 18731 | } |
| 18732 | |
| 18733 | // Get length of data from the header. |
| 18734 | SINT32 bytes; |
| 18735 | if ( fread(&bytes, 4, 1, fd) != 1 ) goto error; |
| 18736 | if( !little_endian ) |
| 18737 | swap32((unsigned char *)&bytes); |
| 18738 | |
| 18739 | fileSize = 8 * bytes / temp / channels; // sample frames |
| 18740 | bufferSize = fileSize; |
| 18741 | if (fileSize > CHUNK_THRESHOLD) { |
| 18742 | chunking = true; |
| 18743 | bufferSize = CHUNK_SIZE; |
| 18744 | } |
| 18745 | |
| 18746 | dataOffset = ftell(fd); |
| 18747 | byteswap = false; |
| 18748 | if( !little_endian ) |
| 18749 | byteswap = true; |
| 18750 | |
| 18751 | return true; |
| 18752 | |
| 18753 | error: |
| 18754 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): Error reading WAV file (%s).", fileName); |
| 18755 | return false; |
| 18756 | } |
| 18757 | |
| 18758 | bool WvIn :: getSndInfo( const char *fileName ) |
| 18759 | { |
| 18760 | // Determine the data type. |
| 18761 | SINT32 format; |
| 18762 | if ( fseek(fd, 12, SEEK_SET) == -1 ) goto error; // Locate format |
| 18763 | if ( fread(&format, 4, 1, fd) != 1 ) goto error; |
| 18764 | if( little_endian ) |
| 18765 | swap32((unsigned char *)&format); |
| 18766 | |
| 18767 | if (format == 2) dataType = STK_SINT8; |
| 18768 | else if (format == 3) dataType = STK_SINT16; |
| 18769 | else if (format == 4) dataType = STK_SINT24; // 1.5.0.1 (ge) added |
| 18770 | else if (format == 5) dataType = STK_SINT32; |
| 18771 | else if (format == 6) dataType = MY_FLOAT32; |
| 18772 | else if (format == 7) dataType = MY_FLOAT64; |
| 18773 | else { |
| 18774 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): data format in file %s is not supported.", fileName); |
| 18775 | return false; |
| 18776 | } |
| 18777 | |
| 18778 | // Get file sample rate from the header. |
| 18779 | SINT32 theSrate; |
| 18780 | if ( fread(&theSrate, 4, 1, fd) != 1 ) goto error; |
| 18781 | if( little_endian ) |
| 18782 | swap32((unsigned char *)&theSrate); |
| 18783 | |
| 18784 | fileRate = (MY_FLOAT)theSrate; |
| 18785 | |
| 18786 | // Set default rate based on file sampling rate. |
| 18787 | rate = (MY_FLOAT) (theSrate / sampleRate() ); |
| 18788 | |
| 18789 | // Get number of channels from the header. |
| 18790 | SINT32 chans; |
| 18791 | if ( fread(&chans, 4, 1, fd) != 1 ) goto error; |
| 18792 | if( little_endian ) |
| 18793 | swap32((unsigned char *)&chans); |
| 18794 | |
| 18795 | channels = chans; |
| 18796 | |
| 18797 | if ( fseek(fd, 4, SEEK_SET) == -1 ) goto error; |
| 18798 | if ( fread(&dataOffset, 4, 1, fd) != 1 ) goto error; |
| 18799 | if( little_endian ) |
| 18800 | swap32((unsigned char *)&dataOffset); |
| 18801 | |
| 18802 | // Get length of data from the header. |
| 18803 | if ( fread(&fileSize, 4, 1, fd) != 1 ) goto error; |
| 18804 | if( little_endian ) |
| 18805 | swap32((unsigned char *)&fileSize); |
| 18806 | |
| 18807 | fileSize /= 2 * channels; // Convert to sample frames. |
| 18808 | bufferSize = fileSize; |
| 18809 | if (fileSize > CHUNK_THRESHOLD) { |
| 18810 | chunking = true; |
| 18811 | bufferSize = CHUNK_SIZE; |
| 18812 | } |
| 18813 | |
| 18814 | byteswap = false; |
| 18815 | if( little_endian ) |
| 18816 | byteswap = true; |
| 18817 | |
| 18818 | return true; |
| 18819 | |
| 18820 | error: |
| 18821 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): Error reading SND file (%s).", fileName); |
| 18822 | return false; |
| 18823 | } |
| 18824 | |
| 18825 | bool WvIn :: getAifInfo( const char *fileName ) |
| 18826 | { |
| 18827 | bool aifc = false; |
| 18828 | char id[4]; |
| 18829 | |
| 18830 | // Determine whether this is AIFF or AIFC. |
| 18831 | if ( fseek(fd, 8, SEEK_SET) == -1 ) goto error; |
| 18832 | if ( fread(&id, 4, 1, fd) != 1 ) goto error; |
| 18833 | if ( !strncmp(id, "AIFC", 4) ) aifc = true; |
| 18834 | |
| 18835 | // Find "common" chunk |
| 18836 | SINT32 chunkSize; |
| 18837 | if ( fread(&id, 4, 1, fd) != 1) goto error; |
| 18838 | while ( strncmp(id, "COMM", 4) ) { |
| 18839 | if ( fread(&chunkSize, 4, 1, fd) != 1 ) goto error; |
| 18840 | if( little_endian ) |
| 18841 | swap32((unsigned char *)&chunkSize); |
| 18842 | |
| 18843 | if ( fseek(fd, chunkSize, SEEK_CUR) == -1 ) goto error; |
| 18844 | if ( fread(&id, 4, 1, fd) != 1 ) goto error; |
| 18845 | } |
| 18846 | |
| 18847 | // Get number of channels from the header. |
| 18848 | SINT16 temp; |
| 18849 | if ( fseek(fd, 4, SEEK_CUR) == -1 ) goto error; // Jump over chunk size |
| 18850 | if ( fread(&temp, 2, 1, fd) != 1 ) goto error; |
| 18851 | if( little_endian ) |
| 18852 | swap16((unsigned char *)&temp); |
| 18853 | |
| 18854 | channels = temp; |
| 18855 | |
| 18856 | // Get length of data from the header. |
| 18857 | SINT32 frames; |
| 18858 | if ( fread(&frames, 4, 1, fd) != 1 ) goto error; |
| 18859 | if( little_endian ) |
| 18860 | swap32((unsigned char *)&frames); |
| 18861 | |
| 18862 | fileSize = frames; // sample frames |
| 18863 | bufferSize = fileSize; |
| 18864 | if (fileSize > CHUNK_THRESHOLD) { |
| 18865 | chunking = true; |
| 18866 | bufferSize = CHUNK_SIZE; |
| 18867 | } |
| 18868 | |
| 18869 | // Read the number of bits per sample. |
| 18870 | if ( fread(&temp, 2, 1, fd) != 1 ) goto error; |
| 18871 | if( little_endian ) |
| 18872 | swap16((unsigned char *)&temp); |
| 18873 | |
| 18874 | // Get file sample rate from the header. For AIFF files, this value |
| 18875 | // is stored in a 10-byte, IEEE Standard 754 floating point number, |
| 18876 | // so we need to convert it first. |
| 18877 | unsigned char theSrate[10]; |
| 18878 | unsigned char exp; |
| 18879 | unsigned long mantissa; |
| 18880 | unsigned long last; |
| 18881 | if ( fread(&theSrate, 10, 1, fd) != 1 ) goto error; |
| 18882 | mantissa = (unsigned long) *(unsigned long *)(theSrate+2); |
| 18883 | if( little_endian ) |
| 18884 | swap32((unsigned char *)&mantissa); |
| 18885 | |
| 18886 | exp = 30 - *(theSrate+1); |
| 18887 | last = 0; |
| 18888 | while (exp--) { |
| 18889 | last = mantissa; |
| 18890 | mantissa >>= 1; |
| 18891 | } |
| 18892 | if (last & 0x00000001) mantissa++; |
| 18893 | fileRate = (MY_FLOAT) mantissa; |
| 18894 | |
| 18895 | // Set default rate based on file sampling rate. |
| 18896 | rate = (MY_FLOAT) ( fileRate / sampleRate() ); |
| 18897 | |
| 18898 | // Determine the data format. |
| 18899 | dataType = 0; |
| 18900 | if ( aifc == false ) { |
| 18901 | if ( temp == 8 ) dataType = STK_SINT8; |
| 18902 | else if ( temp == 16 ) dataType = STK_SINT16; |
| 18903 | else if ( temp == 24 ) dataType = STK_SINT24; // 1.5.0.1 (ge) added |
| 18904 | else if ( temp == 32 ) dataType = STK_SINT32; |
| 18905 | } |
| 18906 | else { |
| 18907 | if ( fread(&id, 4, 1, fd) != 1 ) goto error; |
| 18908 | if ( (!strncmp(id, "fl32", 4) || !strncmp(id, "FL32", 4)) && temp == 32 ) dataType = MY_FLOAT32; |
| 18909 | else if ( (!strncmp(id, "fl64", 4) || !strncmp(id, "FL64", 4)) && temp == 64 ) dataType = MY_FLOAT64; |
| 18910 | } |
| 18911 | if ( dataType == 0 ) { |
| 18912 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): %d bits per sample in file %s are not supported.", temp, fileName); |
| 18913 | return false; |
| 18914 | } |
| 18915 | |
| 18916 | // Start at top to find data (SSND) chunk ... chunk order is undefined. |
| 18917 | if ( fseek(fd, 12, SEEK_SET) == -1 ) goto error; |
| 18918 | |
| 18919 | // Find data (SSND) chunk |
| 18920 | if ( fread(&id, 4, 1, fd) != 1 ) goto error; |
| 18921 | while ( strncmp(id, "SSND", 4) ) { |
| 18922 | if ( fread(&chunkSize, 4, 1, fd) != 1 ) goto error; |
| 18923 | if( little_endian ) |
| 18924 | swap32((unsigned char *)&chunkSize); |
| 18925 | |
| 18926 | if ( fseek(fd, chunkSize, SEEK_CUR) == -1 ) goto error; |
| 18927 | if ( fread(&id, 4, 1, fd) != 1 ) goto error; |
| 18928 | } |
| 18929 | |
| 18930 | // Skip over chunk size, offset, and blocksize fields |
| 18931 | if ( fseek(fd, 12, SEEK_CUR) == -1 ) goto error; |
| 18932 | |
| 18933 | dataOffset = ftell(fd); |
| 18934 | byteswap = false; |
| 18935 | if( little_endian ) |
| 18936 | byteswap = true; |
| 18937 | |
| 18938 | return true; |
| 18939 | |
| 18940 | error: |
| 18941 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): Error reading AIFF file (%s).", fileName); |
| 18942 | return false; |
| 18943 | } |
| 18944 | |
| 18945 | bool WvIn :: getMatInfo( const char *fileName ) |
| 18946 | { |
| 18947 | // Verify this is a version 5 MAT-file format. |
| 18948 | char head[4]; |
| 18949 | if ( fseek(fd, 0, SEEK_SET) == -1 ) goto error; |
| 18950 | if ( fread(&head, 4, 1, fd) != 1 ) goto error; |
| 18951 | // If any of the first 4 characters of the header = 0, then this is |
| 18952 | // a Version 4 MAT-file. |
| 18953 | if ( strstr(head, "0") ) { |
| 18954 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): %s appears to be a Version 4 MAT-file, which is not currently supported.", |
| 18955 | fileName); |
| 18956 | return false; |
| 18957 | } |
| 18958 | |
| 18959 | // Determine the endian-ness of the file. |
| 18960 | char mi[2]; |
| 18961 | byteswap = false; |
| 18962 | // Locate "M" and "I" characters in header. |
| 18963 | if ( fseek(fd, 126, SEEK_SET) == -1 ) goto error; |
| 18964 | if ( fread(&mi, 2, 1, fd) != 1) goto error; |
| 18965 | if( little_endian ) |
| 18966 | { |
| 18967 | if ( !strncmp(mi, "MI", 2) ) |
| 18968 | byteswap = true; |
| 18969 | else if ( strncmp(mi, "IM", 2) ) goto error; |
| 18970 | } |
| 18971 | else |
| 18972 | { |
| 18973 | if ( !strncmp(mi, "IM", 2)) |
| 18974 | byteswap = true; |
| 18975 | else if ( strncmp(mi, "MI", 2) ) goto error; |
| 18976 | } |
| 18977 | |
| 18978 | // Check the data element type |
| 18979 | SINT32 datatype; |
| 18980 | if ( fread(&datatype, 4, 1, fd) != 1 ) goto error; |
| 18981 | if ( byteswap ) swap32((unsigned char *)&datatype); |
| 18982 | if (datatype != 14) { |
| 18983 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): The file does not contain a single Matlab array (or matrix) data element."); |
| 18984 | return false; |
| 18985 | } |
| 18986 | |
| 18987 | // Determine the array data type. |
| 18988 | SINT32 tmp; |
| 18989 | SINT32 size; |
| 18990 | if ( fseek(fd, 168, SEEK_SET) == -1 ) goto error; |
| 18991 | if ( fread(&tmp, 4, 1, fd) != 1 ) goto error; |
| 18992 | if (byteswap) swap32((unsigned char *)&tmp); |
| 18993 | if (tmp == 1) { // array name > 4 characters |
| 18994 | if ( fread(&tmp, 4, 1, fd) != 1 ) goto error; // get array name length |
| 18995 | if (byteswap) swap32((unsigned char *)&tmp); |
| 18996 | size = (SINT32) ceil((float)tmp / 8); |
| 18997 | if ( fseek(fd, size*8, SEEK_CUR) == -1 ) goto error; // jump over array name |
| 18998 | } |
| 18999 | else { // array name <= 4 characters, compressed data element |
| 19000 | if ( fseek(fd, 4, SEEK_CUR) == -1 ) goto error; |
| 19001 | } |
| 19002 | if ( fread(&tmp, 4, 1, fd) != 1 ) goto error; |
| 19003 | if (byteswap) swap32((unsigned char *)&tmp); |
| 19004 | if ( tmp == 1 ) dataType = STK_SINT8; |
| 19005 | else if ( tmp == 3 ) dataType = STK_SINT16; |
| 19006 | // NOTE: MAT file format does not appear to support 24-bit | 1.5.0.1 (ge) |
| 19007 | else if ( tmp == 5 ) dataType = STK_SINT32; |
| 19008 | else if ( tmp == 7 ) dataType = MY_FLOAT32; |
| 19009 | else if ( tmp == 9 ) dataType = MY_FLOAT64; |
| 19010 | else { |
| 19011 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): The MAT-file array data format (%d) is not supported.", tmp); |
| 19012 | return false; |
| 19013 | } |
| 19014 | |
| 19015 | // Get number of rows from the header. |
| 19016 | SINT32 rows; |
| 19017 | if ( fseek(fd, 160, SEEK_SET) == -1 ) goto error; |
| 19018 | if ( fread(&rows, 4, 1, fd) != 1 ) goto error; |
| 19019 | if (byteswap) swap32((unsigned char *)&rows); |
| 19020 | |
| 19021 | // Get number of columns from the header. |
| 19022 | SINT32 columns; |
| 19023 | if ( fread(&columns,4, 1, fd) != 1 ) goto error; |
| 19024 | if (byteswap) swap32((unsigned char *)&columns); |
| 19025 | |
| 19026 | // Assume channels = smaller of rows or columns. |
| 19027 | if (rows < columns) { |
| 19028 | channels = rows; |
| 19029 | fileSize = columns; |
| 19030 | } |
| 19031 | else { |
| 19032 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): Transpose the MAT-file array so that audio channels fill matrix rows (not columns)."); |
| 19033 | return false; |
| 19034 | } |
| 19035 | bufferSize = fileSize; |
| 19036 | if (fileSize > CHUNK_THRESHOLD) { |
| 19037 | chunking = true; |
| 19038 | bufferSize = CHUNK_SIZE; |
| 19039 | } |
| 19040 | |
| 19041 | // Move read pointer to the data in the file. |
| 19042 | SINT32 headsize; |
| 19043 | if ( fseek(fd, 132, SEEK_SET) == -1 ) goto error; |
| 19044 | if ( fread(&headsize, 4, 1, fd) != 1 ) goto error; // file size from 132nd byte |
| 19045 | if (byteswap) swap32((unsigned char *)&headsize); |
| 19046 | headsize -= fileSize * 8 * channels; |
| 19047 | if ( fseek(fd, headsize, SEEK_CUR) == -1 ) goto error; |
| 19048 | dataOffset = ftell(fd); |
| 19049 | |
| 19050 | // Assume MAT-files have 44100 Hz sample rate. |
| 19051 | fileRate = 44100.0; |
| 19052 | |
| 19053 | // Set default rate based on file sampling rate. |
| 19054 | rate = (MY_FLOAT) ( fileRate / sampleRate() ); |
| 19055 | |
| 19056 | return true; |
| 19057 | |
| 19058 | error: |
| 19059 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): Error reading MAT-file (%s).", fileName); |
| 19060 | return false; |
| 19061 | } |
| 19062 | |
| 19063 | |
| 19064 | |
| 19065 | |
| 19066 | |
| 19067 | void WvIn :: readData( unsigned long index ) |
| 19068 | { |
| 19069 | while (index < (unsigned long)chunkPointer) { |
| 19070 | // Negative rate. |
| 19071 | chunkPointer -= CHUNK_SIZE; |
| 19072 | bufferSize = CHUNK_SIZE; |
| 19073 | if (chunkPointer < 0) { |
| 19074 | bufferSize += chunkPointer; |
| 19075 | chunkPointer = 0; |
| 19076 | } |
| 19077 | } |
| 19078 | while (index >= chunkPointer+bufferSize) { |
| 19079 | // Positive rate. |
| 19080 | chunkPointer += CHUNK_SIZE; |
| 19081 | bufferSize = CHUNK_SIZE; |
| 19082 | if ( (unsigned long)chunkPointer+CHUNK_SIZE >= fileSize) { |
| 19083 | bufferSize = fileSize - chunkPointer; |
| 19084 | } |
| 19085 | } |
| 19086 | |
| 19087 | long i, length = bufferSize; |
| 19088 | bool endfile = (chunkPointer+bufferSize == fileSize); |
| 19089 | if ( !endfile ) length += 1; |
| 19090 | |
| 19091 | // Read samples into data[]. Use MY_FLOAT data structure |
| 19092 | // to store samples. |
| 19093 | if ( dataType == STK_SINT16 ) { |
| 19094 | SINT16 *buf = (SINT16 *)data; |
| 19095 | if (fseek(fd, dataOffset+(long)(chunkPointer*channels*2), SEEK_SET) == -1) goto error; |
| 19096 | if (fread(buf, length*channels, 2, fd) != 2 ) goto error; |
| 19097 | if ( byteswap ) { |
| 19098 | SINT16 *ptr = buf; |
| 19099 | for (i=length*channels-1; i>=0; i--) |
| 19100 | swap16((unsigned char *)(ptr++)); |
| 19101 | } |
| 19102 | for (i=length*channels-1; i>=0; i--) |
| 19103 | data[i] = buf[i]; |
| 19104 | } |
| 19105 | else if ( dataType == STK_SINT24 ) { // 1.5.0.1 (ge) added |
| 19106 | SINT24 * buf = (SINT24 *)data; |
| 19107 | if (fseek(fd, dataOffset+(long)(chunkPointer*channels*3), SEEK_SET) == -1) goto error; |
| 19108 | if (fread(buf, length*channels, 3, fd) != 3 ) goto error; |
| 19109 | if ( byteswap ) { |
| 19110 | SINT24 * ptr = buf; |
| 19111 | for (i=length*channels-1; i>=0; i--, ptr++) |
| 19112 | ptr->byteswap(); |
| 19113 | } |
| 19114 | for (i=length*channels-1; i>=0; i--) |
| 19115 | data[i] = buf[i].asInt(); |
| 19116 | } |
| 19117 | else if ( dataType == STK_SINT32 ) { |
| 19118 | SINT32 *buf = (SINT32 *)data; |
| 19119 | if (fseek(fd, dataOffset+(long)(chunkPointer*channels*4), SEEK_SET) == -1) goto error; |
| 19120 | if (fread(buf, length*channels, 4, fd) != 4 ) goto error; |
| 19121 | if ( byteswap ) { |
| 19122 | SINT32 *ptr = buf; |
| 19123 | for (i=length*channels-1; i>=0; i--) |
| 19124 | swap32((unsigned char *)(ptr++)); |
| 19125 | } |
| 19126 | for (i=length*channels-1; i>=0; i--) |
| 19127 | data[i] = buf[i]; |
| 19128 | } |
| 19129 | else if ( dataType == MY_FLOAT32 ) { |
| 19130 | FLOAT32 *buf = (FLOAT32 *)data; |
| 19131 | if (fseek(fd, dataOffset+(long)(chunkPointer*channels*4), SEEK_SET) == -1) goto error; |
| 19132 | if (fread(buf, length*channels, 4, fd) != 4 ) goto error; |
| 19133 | if ( byteswap ) { |
| 19134 | FLOAT32 *ptr = buf; |
| 19135 | for (i=length*channels-1; i>=0; i--) |
| 19136 | swap32((unsigned char *)(ptr++)); |
| 19137 | } |
| 19138 | for (i=length*channels-1; i>=0; i--) |
| 19139 | data[i] = buf[i]; |
| 19140 | } |
| 19141 | else if ( dataType == MY_FLOAT64 ) { |
| 19142 | FLOAT64 *buf = (FLOAT64 *)data; |
| 19143 | if (fseek(fd, dataOffset+(long)(chunkPointer*channels*8), SEEK_SET) == -1) goto error; |
| 19144 | if (fread(buf, length*channels, 8, fd) != 8 ) goto error; |
| 19145 | if ( byteswap ) { |
| 19146 | FLOAT64 *ptr = buf; |
| 19147 | for (i=length*channels-1; i>=0; i--) |
| 19148 | swap64((unsigned char *)(ptr++)); |
| 19149 | } |
| 19150 | for (i=length*channels-1; i>=0; i--) |
| 19151 | data[i] = buf[i]; |
| 19152 | } |
| 19153 | else if ( dataType == STK_SINT8 ) { |
| 19154 | unsigned char *buf = (unsigned char *)data; |
| 19155 | if (fseek(fd, dataOffset+(long)(chunkPointer*channels), SEEK_SET) == -1) goto error; |
| 19156 | if (fread(buf, length*channels, 1, fd) != 1 ) goto error; |
| 19157 | for (i=length*channels-1; i>=0; i--) |
| 19158 | data[i] = buf[i] - 128.0; // 8-bit WAV data is unsigned! |
| 19159 | } |
| 19160 | |
| 19161 | // If at end of file, repeat last sample frame for interpolation. |
| 19162 | if ( endfile ) { |
| 19163 | for (unsigned int j=0; j<channels; j++) |
| 19164 | data[bufferSize*channels+j] = data[(bufferSize-1)*channels+j]; |
| 19165 | } |
| 19166 | |
| 19167 | if (!chunking) { |
| 19168 | fclose(fd); |
| 19169 | fd = 0; |
| 19170 | } |
| 19171 | |
| 19172 | return; |
| 19173 | |
| 19174 | error: |
| 19175 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvIn): Error reading file data."); |
| 19176 | handleError(msg, StkError::FILE_ERROR); |
| 19177 | } |
| 19178 | |
| 19179 | void WvIn :: reset(void) |
| 19180 | { |
| 19181 | time = (MY_FLOAT) 0.0; |
| 19182 | for (unsigned int i=0; i<channels; i++) |
| 19183 | lastOutput[i] = (MY_FLOAT) 0.0; |
| 19184 | finished = false; |
| 19185 | } |
| 19186 | |
| 19187 | void WvIn :: normalize(void) |
| 19188 | { |
| 19189 | this->normalize((MY_FLOAT) 1.0); |
| 19190 | } |
| 19191 | |
| 19192 | // Normalize all channels equally by the greatest magnitude in all of the data. |
| 19193 | void WvIn :: normalize(MY_FLOAT peak) |
| 19194 | { |
| 19195 | if( chunking ) |
| 19196 | { |
| 19197 | if( dataType == STK_SINT8 ) gain = peak / 128.0; |
| 19198 | else if( dataType == STK_SINT16 ) gain = peak / 32768.0; |
| 19199 | else if( dataType == STK_SINT24 ) gain = peak / 8388608.0; |
| 19200 | else if( dataType == STK_SINT32 ) gain = peak / 2147483648.0; |
| 19201 | else if( dataType == MY_FLOAT32 || dataType == MY_FLOAT64 ) gain = peak; |
| 19202 | return; |
| 19203 | } |
| 19204 | |
| 19205 | unsigned long i; |
| 19206 | MY_FLOAT max = (MY_FLOAT) 0.0; |
| 19207 | |
| 19208 | for (i=0; i<channels*bufferSize; i++) { |
| 19209 | if (fabs(data[i]) > max) |
| 19210 | max = (MY_FLOAT) fabs((double) data[i]); |
| 19211 | } |
| 19212 | |
| 19213 | if (max > 0.0) { |
| 19214 | max = (MY_FLOAT) 1.0 / max; |
| 19215 | max *= peak; |
| 19216 | for (i=0;i<=channels*bufferSize;i++) |
| 19217 | data[i] *= max; |
| 19218 | } |
| 19219 | } |
| 19220 | |
| 19221 | unsigned long WvIn :: getSize(void) const |
| 19222 | { |
| 19223 | return fileSize; |
| 19224 | } |
| 19225 | |
| 19226 | unsigned int WvIn :: getChannels(void) const |
| 19227 | { |
| 19228 | return channels; |
| 19229 | } |
| 19230 | |
| 19231 | MY_FLOAT WvIn :: getFileRate(void) const |
| 19232 | { |
| 19233 | return fileRate; |
| 19234 | } |
| 19235 | |
| 19236 | bool WvIn :: isFinished(void) const |
| 19237 | { |
| 19238 | return finished; |
| 19239 | } |
| 19240 | |
| 19241 | void WvIn :: setRate(MY_FLOAT aRate) |
| 19242 | { |
| 19243 | rate = aRate; |
| 19244 | |
| 19245 | // If negative rate and at beginning of sound, move pointer to end |
| 19246 | // of sound. |
| 19247 | if ( (rate < 0) && (time == 0.0) ) time += rate + fileSize; |
| 19248 | |
| 19249 | if (fmod(rate, 1.0) != 0.0) interpolate = true; |
| 19250 | else interpolate = false; |
| 19251 | } |
| 19252 | |
| 19253 | void WvIn :: addTime(MY_FLOAT aTime) |
| 19254 | { |
| 19255 | // Add an absolute time in samples |
| 19256 | time += aTime; |
| 19257 | |
| 19258 | if (time < 0.0) time = 0.0; |
| 19259 | if (time >= fileSize) { |
| 19260 | time = fileSize; |
| 19261 | finished = true; |
| 19262 | } |
| 19263 | } |
| 19264 | |
| 19265 | void WvIn :: setInterpolate(bool doInterpolate) |
| 19266 | { |
| 19267 | interpolate = doInterpolate; |
| 19268 | } |
| 19269 | |
| 19270 | const MY_FLOAT *WvIn :: lastFrame(void) const |
| 19271 | { |
| 19272 | return lastOutput; |
| 19273 | } |
| 19274 | |
| 19275 | MY_FLOAT WvIn :: lastOut(void) const |
| 19276 | { |
| 19277 | if ( channels == 1 ) |
| 19278 | return *lastOutput; |
| 19279 | |
| 19280 | MY_FLOAT output = 0.0; |
| 19281 | for (unsigned int i=0; i<channels; i++ ) { |
| 19282 | output += lastOutput[i]; |
| 19283 | } |
| 19284 | return output / channels; |
| 19285 | } |
| 19286 | |
| 19287 | MY_FLOAT WvIn :: tick(void) |
| 19288 | { |
| 19289 | tickFrame(); |
| 19290 | return lastOut(); |
| 19291 | } |
| 19292 | |
| 19293 | MY_FLOAT * WvIn :: tick(MY_FLOAT *vec, unsigned int vectorSize) |
| 19294 | { |
| 19295 | for ( unsigned int i=0; i<vectorSize; i++ ) |
| 19296 | vec[i] = tick(); |
| 19297 | |
| 19298 | return vec; |
| 19299 | } |
| 19300 | |
| 19301 | const MY_FLOAT * WvIn :: tickFrame(void) |
| 19302 | { |
| 19303 | /* register */ MY_FLOAT tyme, alpha; |
| 19304 | /* register */ unsigned long i, index; |
| 19305 | |
| 19306 | if (finished) return lastOutput; |
| 19307 | |
| 19308 | tyme = time; |
| 19309 | if (chunking) { |
| 19310 | // Check the time address vs. our current buffer limits. |
| 19311 | if ( (tyme < chunkPointer) || (tyme >= chunkPointer+bufferSize) ) |
| 19312 | this->readData((long) tyme); |
| 19313 | // Adjust index for the current buffer. |
| 19314 | tyme -= chunkPointer; |
| 19315 | } |
| 19316 | |
| 19317 | // Integer part of time address. |
| 19318 | index = (long) tyme; |
| 19319 | |
| 19320 | if (interpolate) { |
| 19321 | // Linear interpolation ... fractional part of time address. |
| 19322 | alpha = tyme - (MY_FLOAT) index; |
| 19323 | index *= channels; |
| 19324 | for (i=0; i<channels; i++) { |
| 19325 | lastOutput[i] = data[index]; |
| 19326 | lastOutput[i] += (alpha * (data[index+channels] - lastOutput[i])); |
| 19327 | index++; |
| 19328 | lastOutput[i] *= scaleToOne; // 1.5.0.0 (ge) | scaleToOne |
| 19329 | } |
| 19330 | } |
| 19331 | else { |
| 19332 | index *= channels; |
| 19333 | for (i=0; i<channels; i++) { |
| 19334 | lastOutput[i] = data[index++]; |
| 19335 | lastOutput[i] *= scaleToOne; // 1.5.0.0 (ge) | scaleToOne |
| 19336 | } |
| 19337 | } |
| 19338 | |
| 19339 | if (chunking) { |
| 19340 | // Scale outputs by gain. |
| 19341 | for (i=0; i<channels; i++) lastOutput[i] *= gain; |
| 19342 | } |
| 19343 | |
| 19344 | // Increment time, which can be negative. |
| 19345 | time += rate; |
| 19346 | if ( time < 0.0 || time >= fileSize ) finished = true; |
| 19347 | |
| 19348 | return lastOutput; |
| 19349 | } |
| 19350 | |
| 19351 | MY_FLOAT *WvIn :: tickFrame(MY_FLOAT *frameVector, unsigned int frames) |
| 19352 | { |
| 19353 | unsigned int j; |
| 19354 | for ( unsigned int i=0; i<frames; i++ ) { |
| 19355 | tickFrame(); |
| 19356 | for ( j=0; j<channels; j++ ) |
| 19357 | frameVector[i*channels+j] = lastOutput[j]; |
| 19358 | } |
| 19359 | |
| 19360 | return frameVector; |
| 19361 | } |
| 19362 | /***************************************************/ |
| 19363 | /*! \class WvOut |
| 19364 | \brief STK audio data output base class. |
| 19365 | |
| 19366 | This class provides output support for various |
| 19367 | audio file formats. It also serves as a base |
| 19368 | class for "realtime" streaming subclasses. |
| 19369 | |
| 19370 | WvOut writes samples to an audio file. It |
| 19371 | supports multi-channel data in interleaved |
| 19372 | format. It is important to distinguish the |
| 19373 | tick() methods, which output single samples |
| 19374 | to all channels in a sample frame, from the |
| 19375 | tickFrame() method, which takes a pointer |
| 19376 | to multi-channel sample frame data. |
| 19377 | |
| 19378 | WvOut currently supports WAV, AIFF, AIFC, SND |
| 19379 | (AU), MAT-file (Matlab), and STK RAW file |
| 19380 | formats. Signed integer (8-, 16-, and 32-bit) |
| 19381 | and floating- point (32- and 64-bit) data types |
| 19382 | are supported. STK RAW files use 16-bit |
| 19383 | integers by definition. MAT-files will always |
| 19384 | be written as 64-bit floats. If a data type |
| 19385 | specification does not match the specified file |
| 19386 | type, the data type will automatically be |
| 19387 | modified. Uncompressed data types are not |
| 19388 | supported. |
| 19389 | |
| 19390 | Currently, WvOut is non-interpolating and the |
| 19391 | output rate is always Stk::sampleRate(). |
| 19392 | |
| 19393 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 19394 | */ |
| 19395 | /***************************************************/ |
| 19396 | |
| 19397 | |
| 19398 | #ifndef __DISABLE_WVOUT__ |
| 19399 | const WvOut::FILE_TYPE WvOut :: WVOUT_RAW = 1; |
| 19400 | const WvOut::FILE_TYPE WvOut :: WVOUT_WAV = 2; |
| 19401 | const WvOut::FILE_TYPE WvOut :: WVOUT_SND = 3; |
| 19402 | const WvOut::FILE_TYPE WvOut :: WVOUT_AIF = 4; |
| 19403 | const WvOut::FILE_TYPE WvOut :: WVOUT_MAT = 5; |
| 19404 | #endif |
| 19405 | |
| 19406 | // WAV header structure. See ftp://ftp.isi.edu/in-notes/rfc2361.txt |
| 19407 | // for information regarding format codes. |
| 19408 | struct wavhdr { |
| 19409 | char riff[4]; // "RIFF" |
| 19410 | SINT32 file_size; // in bytes |
| 19411 | char wave[4]; // "WAVE" |
| 19412 | char fmt[4]; // "fmt " |
| 19413 | SINT32 chunk_size; // in bytes (16 for PCM) |
| 19414 | SINT16 format_tag; // 1=PCM, 2=ADPCM, 3=IEEE float, 6=A-Law, 7=Mu-Law |
| 19415 | SINT16 num_chans; // 1=mono, 2=stereo |
| 19416 | SINT32 sample_rate; |
| 19417 | SINT32 bytes_per_sec; |
| 19418 | SINT16 bytes_per_samp; // 2=16-bit mono, 4=16-bit stereo |
| 19419 | SINT16 bits_per_samp; |
| 19420 | char data[4]; // "data" |
| 19421 | SINT32 data_length; // in bytes |
| 19422 | }; |
| 19423 | |
| 19424 | // SND (AU) header structure (NeXT and Sun). |
| 19425 | struct sndhdr { |
| 19426 | char pref[4]; |
| 19427 | SINT32 hdr_length; |
| 19428 | SINT32 data_length; |
| 19429 | SINT32 format; |
| 19430 | SINT32 sample_rate; |
| 19431 | SINT32 num_channels; |
| 19432 | char comment[16]; |
| 19433 | }; |
| 19434 | |
| 19435 | // AIFF/AIFC header structure ... only the part common to both |
| 19436 | // formats. |
| 19437 | struct aifhdr { |
| 19438 | char form[4]; // "FORM" |
| 19439 | SINT32 form_size; // in bytes |
| 19440 | char aiff[4]; // "AIFF" or "AIFC" |
| 19441 | char comm[4]; // "COMM" |
| 19442 | SINT32 comm_size; // "COMM" chunk size (18 for AIFF, 24 for AIFC) |
| 19443 | SINT16 num_chans; // number of channels |
| 19444 | unsigned long sample_frames; // sample frames of audio data |
| 19445 | SINT16 sample_size; // in bits |
| 19446 | unsigned char srate[10]; // IEEE 754 floating point format |
| 19447 | }; |
| 19448 | |
| 19449 | struct aifssnd { |
| 19450 | char ssnd[4]; // "SSND" |
| 19451 | SINT32 ssnd_size; // "SSND" chunk size |
| 19452 | unsigned long offset; // data offset in data block (should be 0) |
| 19453 | unsigned long block_size; // not used by STK (should be 0) |
| 19454 | }; |
| 19455 | |
| 19456 | // MAT-file 5 header structure. |
| 19457 | struct mathdr { |
| 19458 | char heading[124]; // Header text field |
| 19459 | SINT16 hff[2]; // Header flag fields |
| 19460 | SINT32 adf[11]; // Array data format fields |
| 19461 | // There's more, but it's of variable length |
| 19462 | }; |
| 19463 | |
| 19464 | |
| 19465 | #ifndef __DISABLE_WVOUT__ |
| 19466 | size_t WvOut::fwrite(const void * ptr, size_t size, size_t nitems, FILE * stream) |
| 19467 | { |
| 19468 | #ifndef __DISABLE_THREADS__ |
| 19469 | if(asyncIO) |
| 19470 | return asyncWriteThread->fwrite(ptr, size, nitems, stream); |
| 19471 | else |
| 19472 | return ::fwrite(ptr, size, nitems, stream); |
| 19473 | #else |
| 19474 | return ::fwrite(ptr, size, nitems, stream); |
| 19475 | #endif |
| 19476 | } |
| 19477 | |
| 19478 | int WvOut::fseek(FILE *stream, long offset, int whence) |
| 19479 | { |
| 19480 | #ifndef __DISABLE_THREADS__ |
| 19481 | if(asyncIO) |
| 19482 | return asyncWriteThread->fseek(stream, offset, whence); |
| 19483 | else |
| 19484 | return ::fseek(stream, offset, whence); |
| 19485 | #else |
| 19486 | return ::fseek(stream, offset, whence); |
| 19487 | #endif |
| 19488 | } |
| 19489 | |
| 19490 | int WvOut::fflush(FILE *stream) |
| 19491 | { |
| 19492 | #ifndef __DISABLE_THREADS__ |
| 19493 | if(asyncIO) |
| 19494 | return asyncWriteThread->fflush(stream); |
| 19495 | else |
| 19496 | return ::fflush(stream); |
| 19497 | #else |
| 19498 | return ::fflush(stream); |
| 19499 | #endif |
| 19500 | } |
| 19501 | |
| 19502 | int WvOut::fclose(FILE *stream) |
| 19503 | { |
| 19504 | #ifndef __DISABLE_THREADS__ |
| 19505 | if(asyncIO) |
| 19506 | return asyncWriteThread->fclose(stream); |
| 19507 | else |
| 19508 | return ::fclose(stream); |
| 19509 | #else |
| 19510 | return ::fclose(stream); |
| 19511 | #endif |
| 19512 | } |
| 19513 | |
| 19514 | size_t WvOut::fread(void *ptr, size_t size, size_t nitems, FILE *stream) |
| 19515 | { |
| 19516 | #ifndef __DISABLE_THREADS__ |
| 19517 | if( asyncIO ) { |
| 19518 | // can't read asynchronously (yet) |
| 19519 | EM_error3( "WvOut: internal error/warning -- cannot read asynchronously yet..." ); |
| 19520 | // assert(0); |
| 19521 | return 0; |
| 19522 | } else { return ::fread( ptr, size, nitems, stream ); } |
| 19523 | #else |
| 19524 | return ::fread( ptr, size, nitems, stream ); |
| 19525 | #endif |
| 19526 | } |
| 19527 | |
| 19528 | WvOut :: WvOut() |
| 19529 | { |
| 19530 | init(); |
| 19531 | } |
| 19532 | |
| 19533 | WvOut::WvOut( const char *fileName, unsigned int nChannels, FILE_TYPE type, Stk::STK_FORMAT format ) |
| 19534 | { |
| 19535 | init(); |
| 19536 | openFile( fileName, nChannels, type, format ); |
| 19537 | } |
| 19538 | |
| 19539 | WvOut :: ~WvOut() |
| 19540 | { |
| 19541 | closeFile(); |
| 19542 | |
| 19543 | // 1.5.0.1 (ge) using macro |
| 19544 | // if (data) delete [] data; |
| 19545 | CK_SAFE_DELETE_ARRAY( data ); |
| 19546 | } |
| 19547 | |
| 19548 | void WvOut :: init() |
| 19549 | { |
| 19550 | fd = 0; |
| 19551 | data = 0; |
| 19552 | fileType = 0; |
| 19553 | dataType = 0; |
| 19554 | channels = 0; |
| 19555 | counter = 0; |
| 19556 | totalCount = 0; |
| 19557 | //m_filename[0] = '\0'; |
| 19558 | start = TRUE; |
| 19559 | flush = 0; |
| 19560 | fileGain = 1; |
| 19561 | |
| 19562 | // spencer: added as flag for off-thread write |
| 19563 | asyncIO = FALSE; |
| 19564 | asyncWriteThread = NULL; |
| 19565 | } |
| 19566 | |
| 19567 | void WvOut :: closeFile( void ) |
| 19568 | { |
| 19569 | if( fd ) { |
| 19570 | // If there's an existing file, close it first. |
| 19571 | writeData( counter ); |
| 19572 | |
| 19573 | if ( fileType == WVOUT_RAW ) |
| 19574 | fclose( fd ); |
| 19575 | else if ( fileType == WVOUT_WAV ) |
| 19576 | closeWavFile(); |
| 19577 | else if ( fileType == WVOUT_SND ) |
| 19578 | closeSndFile(); |
| 19579 | else if ( fileType == WVOUT_AIF ) |
| 19580 | closeAifFile(); |
| 19581 | else if ( fileType == WVOUT_MAT ) |
| 19582 | closeMatFile(); |
| 19583 | fd = 0; |
| 19584 | |
| 19585 | // printf("%f Seconds Computed\n\n", getTime() ); |
| 19586 | totalCount = 0; |
| 19587 | } |
| 19588 | |
| 19589 | str_filename = ""; |
| 19590 | //m_filename[0] = '\0'; |
| 19591 | } |
| 19592 | |
| 19593 | void WvOut :: openFile( const char *fileName, unsigned int nChannels, WvOut::FILE_TYPE type, Stk::STK_FORMAT format ) |
| 19594 | { |
| 19595 | closeFile(); |
| 19596 | str_filename = fileName; |
| 19597 | //strncpy( m_filename, fileName, 255); |
| 19598 | //if ( strlen( fileName ) > 255 ) |
| 19599 | // m_filename[255] = '\0'; |
| 19600 | |
| 19601 | if ( nChannels < 1 ) { |
| 19602 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): the channels argument must be greater than zero!"); |
| 19603 | handleError( msg, StkError::FUNCTION_ARGUMENT ); |
| 19604 | } |
| 19605 | |
| 19606 | unsigned int lastChannels = channels; |
| 19607 | channels = nChannels; |
| 19608 | fileType = type; |
| 19609 | |
| 19610 | if( format != STK_SINT8 && format != STK_SINT16 && format != STK_SINT24 && // 1.4.1.0 SINT24 attempt | 1.5.0.1 second attempt |
| 19611 | format != STK_SINT32 && format != MY_FLOAT32 && format != MY_FLOAT64 ) |
| 19612 | { |
| 19613 | snprintf( msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Unknown data type specified (%ld).", format ); |
| 19614 | handleError(msg, StkError::FUNCTION_ARGUMENT); |
| 19615 | } |
| 19616 | dataType = format; |
| 19617 | |
| 19618 | // 1.5.0.0 (ge) | disable asyncIO for MAT files #HACK |
| 19619 | // reason: closeMatFile() currently does a fread(), which is not yet |
| 19620 | // supported in async mode likely due to trickiness of asycnchronously |
| 19621 | // getting values back to the calling thread |
| 19622 | // implication: file IO for MAT files is done on the audio thread |
| 19623 | // which could adversely affect real-time audio stability |
| 19624 | #ifndef __DISABLE_THREADS__ |
| 19625 | if( fileType == WVOUT_MAT ) |
| 19626 | { asyncIO = FALSE; } |
| 19627 | else |
| 19628 | { asyncIO = asyncWriteThread != NULL; } |
| 19629 | #else |
| 19630 | // do nothing; already taken care of (WvOut_ctor) |
| 19631 | #endif |
| 19632 | |
| 19633 | bool result = false; |
| 19634 | if ( fileType == WVOUT_RAW ) { |
| 19635 | if ( channels != 1 ) { |
| 19636 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): STK RAW files are, by definition, always monaural (channels = %d not supported)!", nChannels); |
| 19637 | handleError( msg, StkError::FUNCTION_ARGUMENT ); |
| 19638 | } |
| 19639 | result = setRawFile( fileName ); |
| 19640 | } |
| 19641 | else if ( fileType == WVOUT_WAV ) |
| 19642 | result = setWavFile( fileName ); |
| 19643 | else if ( fileType == WVOUT_SND ) |
| 19644 | result = setSndFile( fileName ); |
| 19645 | else if ( fileType == WVOUT_AIF ) |
| 19646 | result = setAifFile( fileName ); |
| 19647 | else if ( fileType == WVOUT_MAT ) |
| 19648 | result = setMatFile( fileName ); |
| 19649 | else { |
| 19650 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Unknown file type specified (%ld).", fileType); |
| 19651 | handleError(msg, StkError::FUNCTION_ARGUMENT); |
| 19652 | } |
| 19653 | |
| 19654 | if ( result == false ) |
| 19655 | { |
| 19656 | //closeFile(); |
| 19657 | handleError(msg, StkError::FILE_ERROR); |
| 19658 | // handleError( msg, StkError::WARNING ); |
| 19659 | // return; |
| 19660 | } |
| 19661 | |
| 19662 | // Allocate new memory if necessary. |
| 19663 | if ( lastChannels < channels ) { |
| 19664 | if ( data ) delete [] data; |
| 19665 | data = (MY_FLOAT *) new MY_FLOAT[BUFFER_SIZE*channels]; |
| 19666 | } |
| 19667 | counter = 0; |
| 19668 | } |
| 19669 | |
| 19670 | bool WvOut :: setRawFile( const char *fileName ) |
| 19671 | { |
| 19672 | char name[130]; |
| 19673 | strncpy(name, fileName, 128); |
| 19674 | if ( strstr(name, ".raw") == NULL) strcat(name, ".raw"); |
| 19675 | fd = fopen(name, "wb"); |
| 19676 | if ( !fd ) { |
| 19677 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Could not create RAW file: %s", name); |
| 19678 | return false; |
| 19679 | } |
| 19680 | |
| 19681 | if ( dataType != STK_SINT16 ) { |
| 19682 | dataType = STK_SINT16; |
| 19683 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Using 16-bit signed integer data format for file %s.", name); |
| 19684 | handleError(msg, StkError::WARNING); |
| 19685 | } |
| 19686 | |
| 19687 | byteswap = false; |
| 19688 | if( little_endian ) |
| 19689 | byteswap = true; |
| 19690 | |
| 19691 | // printf("\nCreating RAW file: %s\n", name); |
| 19692 | return true; |
| 19693 | } |
| 19694 | |
| 19695 | bool WvOut :: setWavFile( const char *fileName ) |
| 19696 | { |
| 19697 | char name[130]; |
| 19698 | strncpy(name, fileName, 128); |
| 19699 | if( strstr(name, ".wav") == NULL ) strcat(name, ".wav"); |
| 19700 | fd = fopen( name, "wb" ); |
| 19701 | if( !fd ) { |
| 19702 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Could not create WAV file: %s", name); |
| 19703 | return false; |
| 19704 | } |
| 19705 | |
| 19706 | struct wavhdr hdr = {"RIF", 44, "WAV", "fmt", 16, 1, 1, |
| 19707 | (SINT32) Stk::sampleRate(), 0, 2, 16, "dat", 0}; |
| 19708 | hdr.riff[3] = 'F'; |
| 19709 | hdr.wave[3] = 'E'; |
| 19710 | hdr.fmt[3] = ' '; |
| 19711 | hdr.data[3] = 'a'; |
| 19712 | hdr.num_chans = (SINT16) channels; |
| 19713 | if ( dataType == STK_SINT8 ) |
| 19714 | hdr.bits_per_samp = 8; |
| 19715 | else if ( dataType == STK_SINT16 ) |
| 19716 | hdr.bits_per_samp = 16; |
| 19717 | else if ( dataType == STK_SINT24 ) // 1.5.0.1 |
| 19718 | hdr.bits_per_samp = 24; |
| 19719 | else if ( dataType == STK_SINT32 ) |
| 19720 | hdr.bits_per_samp = 32; |
| 19721 | else if ( dataType == MY_FLOAT32 ) { |
| 19722 | hdr.format_tag = 3; |
| 19723 | hdr.bits_per_samp = 32; |
| 19724 | } |
| 19725 | else if ( dataType == MY_FLOAT64 ) { |
| 19726 | hdr.format_tag = 3; |
| 19727 | hdr.bits_per_samp = 64; |
| 19728 | } |
| 19729 | hdr.bytes_per_samp = (SINT16) (channels * hdr.bits_per_samp / 8); |
| 19730 | hdr.bytes_per_sec = (SINT32) (hdr.sample_rate * hdr.bytes_per_samp); |
| 19731 | |
| 19732 | byteswap = false; |
| 19733 | if( !little_endian ) |
| 19734 | { |
| 19735 | byteswap = true; |
| 19736 | swap32((unsigned char *)&hdr.file_size); |
| 19737 | swap32((unsigned char *)&hdr.chunk_size); |
| 19738 | swap16((unsigned char *)&hdr.format_tag); |
| 19739 | swap16((unsigned char *)&hdr.num_chans); |
| 19740 | swap32((unsigned char *)&hdr.sample_rate); |
| 19741 | swap32((unsigned char *)&hdr.bytes_per_sec); |
| 19742 | swap16((unsigned char *)&hdr.bytes_per_samp); |
| 19743 | swap16((unsigned char *)&hdr.bits_per_samp); |
| 19744 | } |
| 19745 | |
| 19746 | if ( fwrite(&hdr, 4, 11, fd) != 11 ) { |
| 19747 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Could not write WAV header for file %s", name); |
| 19748 | return false; |
| 19749 | } |
| 19750 | |
| 19751 | // printf("\nCreating WAV file: %s\n", name); |
| 19752 | return true; |
| 19753 | } |
| 19754 | |
| 19755 | void WvOut :: closeWavFile( void ) |
| 19756 | { |
| 19757 | int bytes_per_sample = 1; |
| 19758 | if ( dataType == STK_SINT16 ) |
| 19759 | bytes_per_sample = 2; |
| 19760 | else if ( dataType == STK_SINT24 ) |
| 19761 | bytes_per_sample = 3; |
| 19762 | else if ( dataType == STK_SINT32 || dataType == MY_FLOAT32 ) |
| 19763 | bytes_per_sample = 4; |
| 19764 | else if ( dataType == MY_FLOAT64 ) |
| 19765 | bytes_per_sample = 8; |
| 19766 | |
| 19767 | SINT32 bytes = (SINT32)(totalCount * channels * bytes_per_sample); |
| 19768 | if( !little_endian ) |
| 19769 | swap32((unsigned char *)&bytes); |
| 19770 | |
| 19771 | fseek(fd, 40, SEEK_SET); // jump to data length |
| 19772 | fwrite(&bytes, 4, 1, fd); |
| 19773 | |
| 19774 | bytes = (SINT32)(totalCount * channels * bytes_per_sample + 44); |
| 19775 | if( !little_endian ) |
| 19776 | swap32((unsigned char *)&bytes); |
| 19777 | |
| 19778 | fseek(fd, 4, SEEK_SET); // jump to file size |
| 19779 | fwrite(&bytes, 4, 1, fd); |
| 19780 | fclose( fd ); |
| 19781 | } |
| 19782 | |
| 19783 | bool WvOut :: setSndFile( const char *fileName ) |
| 19784 | { |
| 19785 | char name[130]; |
| 19786 | strncpy(name, fileName, 128); |
| 19787 | if ( strstr(name, ".snd") == NULL) strcat(name, ".snd"); |
| 19788 | fd = fopen(name, "wb"); |
| 19789 | if ( !fd ) { |
| 19790 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Could not create SND file: %s", name); |
| 19791 | return false; |
| 19792 | } |
| 19793 | |
| 19794 | struct sndhdr hdr = {".sn", 40, 0, 3, (SINT32) Stk::sampleRate(), 1, "Created by STK"}; |
| 19795 | hdr.pref[3] = 'd'; |
| 19796 | hdr.num_channels = channels; |
| 19797 | if ( dataType == STK_SINT8 ) |
| 19798 | hdr.format = 2; |
| 19799 | else if ( dataType == STK_SINT16 ) |
| 19800 | hdr.format = 3; |
| 19801 | else if ( dataType == STK_SINT24 ) // 1.5.0.1 (ge) added |
| 19802 | hdr.format = 4; |
| 19803 | else if ( dataType == STK_SINT32 ) |
| 19804 | hdr.format = 5; |
| 19805 | else if ( dataType == MY_FLOAT32 ) |
| 19806 | hdr.format = 6; |
| 19807 | else if ( dataType == MY_FLOAT64 ) |
| 19808 | hdr.format = 7; |
| 19809 | |
| 19810 | byteswap = false; |
| 19811 | if( little_endian ) |
| 19812 | { |
| 19813 | byteswap = true; |
| 19814 | swap32 ((unsigned char *)&hdr.hdr_length); |
| 19815 | swap32 ((unsigned char *)&hdr.format); |
| 19816 | swap32 ((unsigned char *)&hdr.sample_rate); |
| 19817 | swap32 ((unsigned char *)&hdr.num_channels); |
| 19818 | } |
| 19819 | |
| 19820 | if ( fwrite(&hdr, 4, 10, fd) != 10 ) { |
| 19821 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Could not write SND header for file %s", name); |
| 19822 | return false; |
| 19823 | } |
| 19824 | |
| 19825 | // printf("\nCreating SND file: %s\n", name); |
| 19826 | return true; |
| 19827 | } |
| 19828 | |
| 19829 | void WvOut :: closeSndFile( void ) |
| 19830 | { |
| 19831 | int bytes_per_sample = 1; |
| 19832 | if ( dataType == STK_SINT16 ) |
| 19833 | bytes_per_sample = 2; |
| 19834 | else if ( dataType == STK_SINT32 ) |
| 19835 | bytes_per_sample = 4; |
| 19836 | else if ( dataType == MY_FLOAT32 ) |
| 19837 | bytes_per_sample = 4; |
| 19838 | else if ( dataType == MY_FLOAT64 ) |
| 19839 | bytes_per_sample = 8; |
| 19840 | |
| 19841 | SINT32 bytes = (SINT32)(totalCount * bytes_per_sample * channels); |
| 19842 | if( little_endian ) |
| 19843 | swap32 ((unsigned char *)&bytes); |
| 19844 | |
| 19845 | fseek(fd, 8, SEEK_SET); // jump to data size |
| 19846 | fwrite(&bytes, 4, 1, fd); |
| 19847 | fclose(fd); |
| 19848 | } |
| 19849 | |
| 19850 | bool WvOut :: setAifFile( const char *fileName ) |
| 19851 | { |
| 19852 | char name[130]; |
| 19853 | strncpy(name, fileName, 128); |
| 19854 | if ( strstr(name, ".aif") == NULL) strcat(name, ".aif"); |
| 19855 | fd = fopen(name, "wb"); |
| 19856 | if ( !fd ) { |
| 19857 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Could not create AIF file: %s", name); |
| 19858 | return false; |
| 19859 | } |
| 19860 | |
| 19861 | // Common parts of AIFF/AIFC header. |
| 19862 | struct aifhdr hdr = {"FOR", 46, "AIF", "COM", 18, 0, 0, 16, "0"}; |
| 19863 | struct aifssnd ssnd = {"SSN", 8, 0, 0}; |
| 19864 | hdr.form[3] = 'M'; |
| 19865 | hdr.aiff[3] = 'F'; |
| 19866 | hdr.comm[3] = 'M'; |
| 19867 | ssnd.ssnd[3] = 'D'; |
| 19868 | hdr.num_chans = channels; |
| 19869 | if ( dataType == STK_SINT8 ) |
| 19870 | hdr.sample_size = 8; |
| 19871 | else if ( dataType == STK_SINT16 ) |
| 19872 | hdr.sample_size = 16; |
| 19873 | else if ( dataType == STK_SINT24 ) // 1.5.0.1 (ge) added |
| 19874 | hdr.sample_size = 24; |
| 19875 | else if ( dataType == STK_SINT32 ) |
| 19876 | hdr.sample_size = 32; |
| 19877 | else if ( dataType == MY_FLOAT32 ) { |
| 19878 | hdr.aiff[3] = 'C'; |
| 19879 | hdr.sample_size = 32; |
| 19880 | hdr.comm_size = 24; |
| 19881 | } |
| 19882 | else if ( dataType == MY_FLOAT64 ) { |
| 19883 | hdr.aiff[3] = 'C'; |
| 19884 | hdr.sample_size = 64; |
| 19885 | hdr.comm_size = 24; |
| 19886 | } |
| 19887 | |
| 19888 | // For AIFF files, the sample rate is stored in a 10-byte, |
| 19889 | // IEEE Standard 754 floating point number, so we need to |
| 19890 | // convert to that. |
| 19891 | SINT16 i; |
| 19892 | unsigned long exp; |
| 19893 | unsigned long rate = (unsigned long) Stk::sampleRate(); |
| 19894 | memset(hdr.srate, 0, 10); |
| 19895 | exp = rate; |
| 19896 | for (i=0; i<32; i++) { |
| 19897 | exp >>= 1; |
| 19898 | if (!exp) break; |
| 19899 | } |
| 19900 | i += 16383; |
| 19901 | if( little_endian ) |
| 19902 | swap16((unsigned char *)&i); |
| 19903 | |
| 19904 | *(SINT16 *)(hdr.srate) = (SINT16) i; |
| 19905 | |
| 19906 | for (i=32; i; i--) { |
| 19907 | if (rate & 0x80000000) break; |
| 19908 | rate <<= 1; |
| 19909 | } |
| 19910 | |
| 19911 | if( little_endian ) |
| 19912 | swap32((unsigned char *)&rate); |
| 19913 | |
| 19914 | *(unsigned long *)(hdr.srate+2) = (unsigned long) rate; |
| 19915 | |
| 19916 | byteswap = false; |
| 19917 | if( little_endian ) |
| 19918 | { |
| 19919 | byteswap = true; |
| 19920 | swap32((unsigned char *)&hdr.form_size); |
| 19921 | swap32((unsigned char *)&hdr.comm_size); |
| 19922 | swap16((unsigned char *)&hdr.num_chans); |
| 19923 | swap16((unsigned char *)&hdr.sample_size); |
| 19924 | swap32((unsigned char *)&ssnd.ssnd_size); |
| 19925 | swap32((unsigned char *)&ssnd.offset); |
| 19926 | swap32((unsigned char *)&ssnd.block_size); |
| 19927 | } |
| 19928 | |
| 19929 | // The structure boundaries don't allow a single write of 54 bytes. |
| 19930 | if ( fwrite(&hdr, 4, 5, fd) != 5 ) goto error; |
| 19931 | if ( fwrite(&hdr.num_chans, 2, 1, fd) != 1 ) goto error; |
| 19932 | if ( fwrite(&hdr.sample_frames, 4, 1, fd) != 1 ) goto error; |
| 19933 | if ( fwrite(&hdr.sample_size, 2, 1, fd) != 1 ) goto error; |
| 19934 | if ( fwrite(&hdr.srate, 10, 1, fd) != 1 ) goto error; |
| 19935 | |
| 19936 | if ( dataType == MY_FLOAT32 ) { |
| 19937 | char type[4] = {'f','l','3','2'}; |
| 19938 | char zeroes[2] = { 0, 0 }; |
| 19939 | if ( fwrite(&type, 4, 1, fd) != 1 ) goto error; |
| 19940 | if ( fwrite(&zeroes, 2, 1, fd) != 1 ) goto error; |
| 19941 | } |
| 19942 | else if ( dataType == MY_FLOAT64 ) { |
| 19943 | char type[4] = {'f','l','6','4'}; |
| 19944 | char zeroes[2] = { 0, 0 }; |
| 19945 | if ( fwrite(&type, 4, 1, fd) != 1 ) goto error; |
| 19946 | if ( fwrite(&zeroes, 2, 1, fd) != 1 ) goto error; |
| 19947 | } |
| 19948 | |
| 19949 | if ( fwrite(&ssnd, 4, 4, fd) != 4 ) goto error; |
| 19950 | |
| 19951 | // printf("\nCreating AIF file: %s\n", name); |
| 19952 | return true; |
| 19953 | |
| 19954 | error: |
| 19955 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Could not write AIF header for file %s", name); |
| 19956 | return false; |
| 19957 | } |
| 19958 | |
| 19959 | void WvOut :: closeAifFile( void ) |
| 19960 | { |
| 19961 | unsigned long frames = (unsigned long) totalCount; |
| 19962 | if( little_endian ) |
| 19963 | swap32((unsigned char *)&frames); |
| 19964 | |
| 19965 | fseek(fd, 22, SEEK_SET); // jump to "COMM" sample_frames |
| 19966 | fwrite(&frames, 4, 1, fd); |
| 19967 | |
| 19968 | int bytes_per_sample = 1; |
| 19969 | if ( dataType == STK_SINT16 ) |
| 19970 | bytes_per_sample = 2; |
| 19971 | else if ( dataType == STK_SINT24 ) |
| 19972 | bytes_per_sample = 3; |
| 19973 | else if ( dataType == STK_SINT32 || dataType == MY_FLOAT32 ) |
| 19974 | bytes_per_sample = 4; |
| 19975 | else if ( dataType == MY_FLOAT64 ) |
| 19976 | bytes_per_sample = 8; |
| 19977 | |
| 19978 | unsigned long bytes = totalCount * bytes_per_sample * channels + 46; |
| 19979 | if ( dataType == MY_FLOAT32 || dataType == MY_FLOAT64 ) bytes += 6; |
| 19980 | if( little_endian ) |
| 19981 | swap32((unsigned char *)&bytes); |
| 19982 | |
| 19983 | fseek(fd, 4, SEEK_SET); // jump to file size |
| 19984 | fwrite(&bytes, 4, 1, fd); |
| 19985 | |
| 19986 | bytes = totalCount * bytes_per_sample * channels + 8; |
| 19987 | if ( dataType == MY_FLOAT32 || dataType == MY_FLOAT64 ) bytes += 6; |
| 19988 | if( little_endian ) |
| 19989 | swap32((unsigned char *)&bytes); |
| 19990 | |
| 19991 | if ( dataType == MY_FLOAT32 || dataType == MY_FLOAT64 ) |
| 19992 | fseek(fd, 48, SEEK_SET); // jump to "SSND" chunk size |
| 19993 | else |
| 19994 | fseek(fd, 42, SEEK_SET); // jump to "SSND" chunk size |
| 19995 | fwrite(&bytes, 4, 1, fd); |
| 19996 | |
| 19997 | fclose( fd ); |
| 19998 | } |
| 19999 | |
| 20000 | bool WvOut :: setMatFile( const char *fileName ) |
| 20001 | { |
| 20002 | char name[130]; |
| 20003 | strncpy(name, fileName, 128); |
| 20004 | if ( strstr(name, ".mat") == NULL) strcat(name, ".mat"); |
| 20005 | fd = fopen(name, "w+b"); |
| 20006 | if ( !fd ) { |
| 20007 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Could not create MAT file: %s", name); |
| 20008 | return false; |
| 20009 | } |
| 20010 | |
| 20011 | if ( dataType != MY_FLOAT64 ) { |
| 20012 | dataType = MY_FLOAT64; |
| 20013 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Using 64-bit floating-point data format for file %s", name); |
| 20014 | handleError(msg, StkError::WARNING); |
| 20015 | } |
| 20016 | |
| 20017 | struct mathdr hdr; |
| 20018 | // 1.4.1.0 (ge) zero out |
| 20019 | memset( hdr.heading, 0, sizeof(hdr.heading) ); |
| 20020 | strcpy(hdr.heading,"MATLAB 5.0 MAT-file, Generated using the Synthesis ToolKit in C++ (STK). By Perry R. Cook and Gary P. Scavone, 1995-2002."); |
| 20021 | |
| 20022 | t_CKINT i; |
| 20023 | for (i=strlen(hdr.heading);i<124;i++) hdr.heading[i] = ' '; |
| 20024 | |
| 20025 | // Header Flag Fields |
| 20026 | hdr.hff[0] = (SINT16) 0x0100; // Version field |
| 20027 | hdr.hff[1] = (SINT16) 'M'; // Endian indicator field ("MI") |
| 20028 | hdr.hff[1] <<= 8; |
| 20029 | hdr.hff[1] += 'I'; |
| 20030 | |
| 20031 | hdr.adf[0] = (SINT32) 14; // Matlab array data type value |
| 20032 | hdr.adf[1] = (SINT32) 0; // Size of file after this point to end (in bytes) |
| 20033 | // Don't know size yet. |
| 20034 | |
| 20035 | // Numeric Array Subelements (4): |
| 20036 | // 1. Array Flags |
| 20037 | hdr.adf[2] = (SINT32) 6; // Matlab 32-bit unsigned integer data type value |
| 20038 | hdr.adf[3] = (SINT32) 8; // 8 bytes of data to follow |
| 20039 | hdr.adf[4] = (SINT32) 6; // Double-precision array, no array flags set |
| 20040 | hdr.adf[5] = (SINT32) 0; // 4 bytes undefined |
| 20041 | // 2. Array Dimensions |
| 20042 | hdr.adf[6] = (SINT32) 5; // Matlab 32-bit signed integer data type value |
| 20043 | hdr.adf[7] = (SINT32) 8; // 8 bytes of data to follow (2D array) |
| 20044 | hdr.adf[8] = (SINT32) channels; // This is the number of rows |
| 20045 | hdr.adf[9] = (SINT32) 0; // This is the number of columns |
| 20046 | |
| 20047 | // 3. Array Name |
| 20048 | // We'll use fileName for the matlab array name (as well as the file name). |
| 20049 | // If fileName is 4 characters or less, we have to use a compressed data element |
| 20050 | // format for the array name data element. Otherwise, the array name must |
| 20051 | // be formatted in 8-byte increments (up to 31 characters + NULL). |
| 20052 | SINT32 namelength = (SINT32) strlen(fileName); |
| 20053 | if (strstr(fileName, ".mat")) namelength -= 4; |
| 20054 | if (namelength > 31) namelength = 31; // Truncate name to 31 characters. |
| 20055 | char arrayName[64]; |
| 20056 | strncpy(arrayName, fileName, namelength); |
| 20057 | arrayName[namelength] = '\0'; |
| 20058 | if (namelength > 4) { |
| 20059 | hdr.adf[10] = (SINT32) 1; // Matlab 8-bit signed integer data type value |
| 20060 | } |
| 20061 | else { // Compressed data element format |
| 20062 | hdr.adf[10] = namelength; |
| 20063 | hdr.adf[10] <<= 16; |
| 20064 | hdr.adf[10] += 1; |
| 20065 | } |
| 20066 | SINT32 headsize = 40; // Number of bytes in data element so far. |
| 20067 | |
| 20068 | // Write the fixed portion of the header |
| 20069 | if ( fwrite(&hdr, 172, 1, fd) != 1 ) goto error; |
| 20070 | |
| 20071 | // Write MATLAB array name |
| 20072 | SINT32 tmp; |
| 20073 | if (namelength > 4) { |
| 20074 | if ( fwrite(&namelength, 4, 1, fd) != 1) goto error; |
| 20075 | if ( fwrite(arrayName, namelength, 1, fd) != 1 ) goto error; |
| 20076 | tmp = (SINT32) ceil((float)namelength / 8); |
| 20077 | if ( fseek(fd, tmp*8-namelength, SEEK_CUR) == -1 ) goto error; |
| 20078 | headsize += tmp * 8; |
| 20079 | } |
| 20080 | else { // Compressed data element format |
| 20081 | if ( fwrite(arrayName, namelength, 1, fd) != 1 ) goto error; |
| 20082 | tmp = 4 - namelength; |
| 20083 | if ( fseek(fd, tmp, SEEK_CUR) == -1 ) goto error; |
| 20084 | } |
| 20085 | |
| 20086 | // Finish writing known header information |
| 20087 | tmp = 9; // Matlab IEEE 754 double data type |
| 20088 | if ( fwrite(&tmp, 4, 1, fd) != 1 ) goto error; |
| 20089 | tmp = 0; // Size of real part subelement in bytes (8 per sample) |
| 20090 | if ( fwrite(&tmp, 4, 1, fd) != 1 ) goto error; |
| 20091 | headsize += 8; // Total number of bytes in data element so far |
| 20092 | |
| 20093 | if ( fseek(fd, 132, SEEK_SET) == -1 ) goto error; |
| 20094 | if ( fwrite(&headsize, 4, 1, fd) != 1 ) goto error; // Write header size ... will update at end |
| 20095 | if ( fseek(fd, 0, SEEK_END) == -1 ) goto error; |
| 20096 | |
| 20097 | byteswap = false; |
| 20098 | CK_FPRINTF_STDERR( "[chuck]:(via STK): creating MAT-file (%s) containing MATLAB array: %s\n", name, arrayName); |
| 20099 | return true; |
| 20100 | |
| 20101 | error: |
| 20102 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Could not write MAT-file header for file %s", name); |
| 20103 | return false; |
| 20104 | } |
| 20105 | |
| 20106 | void WvOut :: closeMatFile( void ) |
| 20107 | { |
| 20108 | fseek(fd, 164, SEEK_SET); // jump to number of columns |
| 20109 | fwrite(&totalCount, 4, 1, fd); |
| 20110 | |
| 20111 | SINT32 headsize, temp; |
| 20112 | fseek(fd, 132, SEEK_SET); // jump to header size |
| 20113 | fread(&headsize, 4, 1, fd); |
| 20114 | temp = headsize; |
| 20115 | headsize += (SINT32) (totalCount * 8 * channels); |
| 20116 | fseek(fd, 132, SEEK_SET); |
| 20117 | // Write file size (minus some header info) |
| 20118 | fwrite(&headsize, 4, 1, fd); |
| 20119 | |
| 20120 | fseek(fd, temp+132, SEEK_SET); // jumpt to data size (in bytes) |
| 20121 | temp = (SINT32)(totalCount * 8 * channels); |
| 20122 | fwrite(&temp, 4, 1, fd); |
| 20123 | |
| 20124 | // explicitly flush |
| 20125 | fflush(fd); // 1.5.0.0 (ge) added...but why? (fclose() flushes, does it not) |
| 20126 | // close |
| 20127 | fclose(fd); |
| 20128 | } |
| 20129 | |
| 20130 | unsigned long WvOut :: getFrames( void ) const |
| 20131 | { |
| 20132 | return totalCount; |
| 20133 | } |
| 20134 | |
| 20135 | MY_FLOAT WvOut :: getTime( void ) const |
| 20136 | { |
| 20137 | return (MY_FLOAT) totalCount / Stk::sampleRate(); |
| 20138 | } |
| 20139 | |
| 20140 | void WvOut :: writeData( unsigned long frames ) |
| 20141 | { |
| 20142 | // make sure we have file descriptor |
| 20143 | if( !fd ) return; |
| 20144 | |
| 20145 | if ( dataType == STK_SINT8 ) { |
| 20146 | if ( fileType == WVOUT_WAV ) { // 8-bit WAV data is unsigned! |
| 20147 | for ( unsigned long k=0; k<frames*channels; k++ ) { |
| 20148 | float float_sample = data[k] * 127.0 + 128.0; |
| 20149 | if(float_sample < 0) float_sample = 0; |
| 20150 | if(float_sample > 255) float_sample = 255; |
| 20151 | unsigned char sample = (unsigned char) float_sample; |
| 20152 | |
| 20153 | if ( fwrite(&sample, 1, 1, fd) != 1 ) goto error; |
| 20154 | } |
| 20155 | } |
| 20156 | else { |
| 20157 | for ( unsigned long k=0; k<frames*channels; k++ ) { |
| 20158 | float float_sample = data[k] * 127.0; |
| 20159 | if(float_sample < -128) float_sample = -128; |
| 20160 | if(float_sample > 127) float_sample = 127; |
| 20161 | signed char sample = (signed char) float_sample; |
| 20162 | |
| 20163 | if ( fwrite(&sample, 1, 1, fd) != 1 ) goto error; |
| 20164 | } |
| 20165 | } |
| 20166 | } |
| 20167 | else if ( dataType == STK_SINT16 ) { |
| 20168 | for ( unsigned long k=0; k<frames*channels; k++ ) { |
| 20169 | float float_sample = data[k] * 32767.0; |
| 20170 | if(float_sample < -32767) float_sample = -32767; |
| 20171 | if(float_sample > 32767) float_sample = 32767; |
| 20172 | SINT16 sample = (SINT16) float_sample; |
| 20173 | |
| 20174 | if ( byteswap ) swap16( (unsigned char *)&sample ); |
| 20175 | if ( fwrite(&sample, 2, 1, fd) != 1 ) goto error; |
| 20176 | } |
| 20177 | } |
| 20178 | else if( dataType == STK_SINT24 ) { // 1.5.0.1 (ge) added |
| 20179 | for( unsigned long k=0; k<frames*channels; k++ ) { |
| 20180 | double float_sample = data[k] * 8388607.0; |
| 20181 | if(float_sample < -8388607.0 ) float_sample = -8388607.0; |
| 20182 | if(float_sample > 8388607.0 ) float_sample = 8388607.0; |
| 20183 | SINT24 sample( float_sample ); |
| 20184 | if( byteswap ) sample.byteswap(); |
| 20185 | if( fwrite(&sample, 3, 1, fd) != 1 ) goto error; |
| 20186 | } |
| 20187 | } |
| 20188 | else if ( dataType == STK_SINT32 ) { |
| 20189 | for ( unsigned long k=0; k<frames*channels; k++ ) { |
| 20190 | double float_sample = data[k] * 2147483647.0; // 1.4.2.0 (ge) | change datatype to double from float for precision |
| 20191 | if(float_sample < -2147483647.0 ) float_sample = -2147483647.0; // 1.4.2.0 (ge) | using float literal, instead of conversion from int |
| 20192 | if(float_sample > 2147483647.0 ) float_sample = 2147483647.0; // 1.4.2.0 (ge) | using float literal, instead of conversion from int |
| 20193 | SINT32 sample = (SINT32) float_sample; |
| 20194 | |
| 20195 | if ( byteswap ) swap32( (unsigned char *)&sample ); |
| 20196 | if ( fwrite(&sample, 4, 1, fd) != 1 ) goto error; |
| 20197 | } |
| 20198 | } |
| 20199 | else if ( dataType == MY_FLOAT32 ) { |
| 20200 | FLOAT32 sample; |
| 20201 | for ( unsigned long k=0; k<frames*channels; k++ ) { |
| 20202 | sample = (FLOAT32) (data[k]); |
| 20203 | |
| 20204 | if ( byteswap ) swap32( (unsigned char *)&sample ); |
| 20205 | if ( fwrite(&sample, 4, 1, fd) != 1 ) goto error; |
| 20206 | } |
| 20207 | } |
| 20208 | else if ( dataType == MY_FLOAT64 ) { |
| 20209 | FLOAT64 sample; |
| 20210 | for ( unsigned long k=0; k<frames*channels; k++ ) { |
| 20211 | sample = (FLOAT64) (data[k]); |
| 20212 | |
| 20213 | if ( byteswap ) swap64( (unsigned char *)&sample ); |
| 20214 | if ( fwrite(&sample, 8, 1, fd) != 1 ) goto error; |
| 20215 | } |
| 20216 | } |
| 20217 | |
| 20218 | flush += frames; |
| 20219 | if( flush >= 8192 ) |
| 20220 | { |
| 20221 | flush = 0; |
| 20222 | fflush( fd ); |
| 20223 | } |
| 20224 | |
| 20225 | return; |
| 20226 | |
| 20227 | error: |
| 20228 | snprintf(msg, STK_MSG_BUF_LENGTH, "[chuck](via WvOut): Error writing data to file."); |
| 20229 | handleError(msg, StkError::FILE_ERROR); |
| 20230 | } |
| 20231 | |
| 20232 | void WvOut :: tick(const MY_FLOAT sample) |
| 20233 | { |
| 20234 | if ( !fd ) return; |
| 20235 | |
| 20236 | for ( unsigned int j=0; j<channels; j++ ) |
| 20237 | data[counter*channels+j] = sample; |
| 20238 | |
| 20239 | counter++; |
| 20240 | totalCount++; |
| 20241 | |
| 20242 | if ( counter == BUFFER_SIZE ) { |
| 20243 | writeData( BUFFER_SIZE ); |
| 20244 | counter = 0; |
| 20245 | } |
| 20246 | } |
| 20247 | |
| 20248 | void WvOut :: tick(const MY_FLOAT *vec, unsigned int vectorSize) |
| 20249 | { |
| 20250 | if ( !fd ) return; |
| 20251 | |
| 20252 | for (unsigned int i=0; i<vectorSize; i++) |
| 20253 | tick( vec[i] ); |
| 20254 | } |
| 20255 | |
| 20256 | void WvOut :: tickFrame(const MY_FLOAT *frameVector, unsigned int frames) |
| 20257 | { |
| 20258 | if ( !fd ) return; |
| 20259 | |
| 20260 | unsigned int j; |
| 20261 | for ( unsigned int i=0; i<frames; i++ ) { |
| 20262 | for ( j=0; j<channels; j++ ) { |
| 20263 | data[counter*channels+j] = frameVector[i*channels+j]; |
| 20264 | } |
| 20265 | counter++; |
| 20266 | totalCount++; |
| 20267 | |
| 20268 | if ( counter == BUFFER_SIZE ) { |
| 20269 | writeData( BUFFER_SIZE ); |
| 20270 | counter = 0; |
| 20271 | } |
| 20272 | } |
| 20273 | } |
| 20274 | #endif //__DISABLE_WVOUT__ |
| 20275 | |
| 20276 | |
| 20277 | |
| 20278 | |
| 20279 | /**********************************************************************/ |
| 20280 | /*! \class MidiFileIn |
| 20281 | \brief A standard MIDI file reading/parsing class. |
| 20282 | |
| 20283 | This class can be used to read events from a standard MIDI file. |
| 20284 | Event bytes are copied to a C++ vector and must be subsequently |
| 20285 | interpreted by the user. The function getNextMidiEvent() skips |
| 20286 | meta and sysex events, returning only MIDI channel messages. |
| 20287 | Event delta-times are returned in the form of "ticks" and a |
| 20288 | function is provided to determine the current "seconds per tick". |
| 20289 | Tempo changes are internally tracked by the class and reflected in |
| 20290 | the values returned by the function getTickSeconds(). |
| 20291 | |
| 20292 | by Gary P. Scavone, 2003 - 2010. |
| 20293 | */ |
| 20294 | /**********************************************************************/ |
| 20295 | |
| 20296 | #include <cstring> |
| 20297 | #include <iostream> |
| 20298 | |
| 20299 | #if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) |
| 20300 | #define __LITTLE_ENDIAN__ |
| 20301 | #endif // !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) |
| 20302 | |
| 20303 | namespace stk { |
| 20304 | |
| 20305 | MidiFileIn :: MidiFileIn( std::string fileName ) |
| 20306 | { |
| 20307 | // ge: initialize |
| 20308 | bpm_ = 0; |
| 20309 | // ge & alex & kiran |
| 20310 | tpq_ = 0; |
| 20311 | // 1.4.1.1 (ge) string buffer for error message |
| 20312 | std::stringstream msg; |
| 20313 | // 1.5.0.4 (ge) add initialization |
| 20314 | format_ = 0; |
| 20315 | division_ = 0; |
| 20316 | nTracks_ = 0; |
| 20317 | usingTimeCode_ = false; |
| 20318 | |
| 20319 | // Attempt to open the file. |
| 20320 | file_.open( fileName.c_str(), std::ios::in | std::ios::binary ); |
| 20321 | if ( !file_ ) { |
| 20322 | msg << "MidiFileIn: error opening or finding file (" << fileName << ")."; |
| 20323 | handleError( msg.str().c_str(), StkError::FILE_NOT_FOUND ); |
| 20324 | } |
| 20325 | |
| 20326 | // Parse header info. |
| 20327 | char chunkType[4]; |
| 20328 | char buffer[4]; |
| 20329 | SINT32 *length; |
| 20330 | if ( !file_.read( chunkType, 4 ) ) goto error; |
| 20331 | if ( !file_.read( buffer, 4 ) ) goto error; |
| 20332 | #ifdef __LITTLE_ENDIAN__ |
| 20333 | swap32((unsigned char *)&buffer); |
| 20334 | #endif |
| 20335 | length = (SINT32 *) &buffer; |
| 20336 | if ( strncmp( chunkType, "MThd", 4 ) || ( *length != 6 ) ) { |
| 20337 | msg << "MidiFileIn: file (" << fileName << ") does not appear to be a MIDI file!"; |
| 20338 | handleError( msg.str().c_str(), StkError::FILE_UNKNOWN_FORMAT ); |
| 20339 | } |
| 20340 | |
| 20341 | // Read the MIDI file format. |
| 20342 | SINT16 *data; |
| 20343 | if ( !file_.read( buffer, 2 ) ) goto error; |
| 20344 | #ifdef __LITTLE_ENDIAN__ |
| 20345 | swap16((unsigned char *)&buffer); |
| 20346 | #endif |
| 20347 | data = (SINT16 *) &buffer; |
| 20348 | if ( *data < 0 || *data > 2 ) { |
| 20349 | msg << "MidiFileIn: the file (" << fileName << ") format is invalid!"; |
| 20350 | handleError( msg.str().c_str(), StkError::FILE_ERROR ); |
| 20351 | } |
| 20352 | format_ = *data; |
| 20353 | |
| 20354 | // Read the number of tracks. |
| 20355 | if ( !file_.read( buffer, 2 ) ) goto error; |
| 20356 | #ifdef __LITTLE_ENDIAN__ |
| 20357 | swap16((unsigned char *)&buffer); |
| 20358 | #endif |
| 20359 | if ( format_ == 0 && *data != 1 ) { |
| 20360 | msg << "MidiFileIn: invalid number of tracks (>1) for a file format = 0!"; |
| 20361 | handleError( msg.str().c_str(), StkError::FILE_ERROR ); |
| 20362 | } |
| 20363 | nTracks_ = *data; |
| 20364 | |
| 20365 | // Read the beat division. |
| 20366 | if ( !file_.read( buffer, 2 ) ) goto error; |
| 20367 | #ifdef __LITTLE_ENDIAN__ |
| 20368 | swap16((unsigned char *)&buffer); |
| 20369 | #endif |
| 20370 | division_ = (int) *data; |
| 20371 | double tickrate; |
| 20372 | usingTimeCode_ = false; |
| 20373 | if ( *data & 0x8000 ) { |
| 20374 | // Determine ticks per second from time-code formats. |
| 20375 | tickrate = (double) -(*data & 0x7F00); |
| 20376 | // If frames per second value is 29, it really should be 29.97. |
| 20377 | if ( tickrate == 29.0 ) tickrate = 29.97; |
| 20378 | tickrate *= (*data & 0x00FF); |
| 20379 | usingTimeCode_ = true; |
| 20380 | } |
| 20381 | else { |
| 20382 | tickrate = (double) (*data & 0x7FFF); // ticks per quarter note |
| 20383 | // save for lookup later | (ge & alex & kiran) 1.5.3.2 |
| 20384 | tpq_ = tickrate; |
| 20385 | } |
| 20386 | |
| 20387 | // Now locate the track offsets and lengths. If not using time |
| 20388 | // code, we can initialize the "tick time" using a default tempo of |
| 20389 | // 120 beats per minute. We will then check for tempo meta-events |
| 20390 | // afterward. |
| 20391 | unsigned int i; |
| 20392 | for ( i=0; i<nTracks_; i++ ) { |
| 20393 | if ( !file_.read( chunkType, 4 ) ) goto error; |
| 20394 | if ( strncmp( chunkType, "MTrk", 4 ) ) goto error; |
| 20395 | if ( !file_.read( buffer, 4 ) ) goto error; |
| 20396 | #ifdef __LITTLE_ENDIAN__ |
| 20397 | swap32((unsigned char *)&buffer); |
| 20398 | #endif |
| 20399 | length = (SINT32 *) &buffer; |
| 20400 | trackLengths_.push_back( *length ); |
| 20401 | trackOffsets_.push_back( (long) file_.tellg() ); |
| 20402 | trackPointers_.push_back( (long) file_.tellg() ); |
| 20403 | trackStatus_.push_back( 0 ); |
| 20404 | file_.seekg( *length, std::ios_base::cur ); |
| 20405 | if ( usingTimeCode_ ) tickSeconds_.push_back( (double) (1.0 / tickrate) ); |
| 20406 | else tickSeconds_.push_back( (double) (0.5 / tickrate) ); |
| 20407 | } |
| 20408 | |
| 20409 | // Save the initial tickSeconds parameter. |
| 20410 | TempoChange tempoEvent; |
| 20411 | tempoEvent.count = 0; |
| 20412 | tempoEvent.tickSeconds = tickSeconds_[0]; |
| 20413 | tempoEvents_.push_back( tempoEvent ); |
| 20414 | |
| 20415 | // If format 1 and not using time code, parse and save the tempo map |
| 20416 | // on track 0. |
| 20417 | if ( format_ == 1 && !usingTimeCode_ ) { |
| 20418 | std::vector<unsigned char> event; |
| 20419 | unsigned long value, count; |
| 20420 | |
| 20421 | // We need to temporarily change the usingTimeCode_ value here so |
| 20422 | // that the getNextEvent() function doesn't try to check the tempo |
| 20423 | // map (which we're creating here). |
| 20424 | usingTimeCode_ = true; |
| 20425 | count = getNextEvent( &event, 0 ); |
| 20426 | while ( event.size() ) { |
| 20427 | if ( ( event.size() == 6 ) && ( event[0] == 0xff ) && |
| 20428 | ( event[1] == 0x51 ) && ( event[2] == 0x03 ) ) { |
| 20429 | tempoEvent.count = count; |
| 20430 | value = ( event[3] << 16 ) + ( event[4] << 8 ) + event[5]; |
| 20431 | tempoEvent.tickSeconds = (double) (0.000001 * value / tickrate); |
| 20432 | // ge: check |
| 20433 | // std::cerr << "tick: " << 60000000 / value << std::endl; |
| 20434 | // ge: set BPM |
| 20435 | bpm_ = 60000000.0 / value; |
| 20436 | if ( count > tempoEvents_.back().count ) |
| 20437 | tempoEvents_.push_back( tempoEvent ); |
| 20438 | else |
| 20439 | tempoEvents_.back() = tempoEvent; |
| 20440 | } |
| 20441 | count += getNextEvent( &event, 0 ); |
| 20442 | } |
| 20443 | rewindTrack( 0 ); |
| 20444 | for ( unsigned int j=0; j<nTracks_; j++ ) { |
| 20445 | trackCounters_.push_back( 0 ); |
| 20446 | trackTempoIndex_.push_back( 0 ); |
| 20447 | } |
| 20448 | // Change the time code flag back! |
| 20449 | usingTimeCode_ = false; |
| 20450 | } |
| 20451 | |
| 20452 | return; |
| 20453 | |
| 20454 | error: |
| 20455 | msg << "MidiFileIn: error reading from file (" << fileName << ")."; |
| 20456 | handleError( msg.str().c_str(), StkError::FILE_ERROR ); |
| 20457 | } |
| 20458 | |
| 20459 | MidiFileIn :: ~MidiFileIn() |
| 20460 | { |
| 20461 | // An ifstream object implicitly closes itself during destruction |
| 20462 | // but we'll make an explicit call to "close" anyway. |
| 20463 | file_.close(); |
| 20464 | } |
| 20465 | |
| 20466 | int MidiFileIn :: getFileFormat() const |
| 20467 | { |
| 20468 | return format_; |
| 20469 | } |
| 20470 | |
| 20471 | unsigned int MidiFileIn :: getNumberOfTracks() const |
| 20472 | { |
| 20473 | return nTracks_; |
| 20474 | } |
| 20475 | |
| 20476 | int MidiFileIn :: getDivision() const |
| 20477 | { |
| 20478 | return division_; |
| 20479 | } |
| 20480 | |
| 20481 | void MidiFileIn :: rewindTrack( unsigned int track ) |
| 20482 | { |
| 20483 | if ( track >= nTracks_ ) { |
| 20484 | CK_STDCOUT << "MidiFileIn::getNextEvent: invalid track argument (" << track << ")."; |
| 20485 | handleError( "", StkError::WARNING ); return; |
| 20486 | } |
| 20487 | |
| 20488 | trackPointers_[track] = trackOffsets_[track]; |
| 20489 | trackStatus_[track] = 0; |
| 20490 | tickSeconds_[track] = tempoEvents_[0].tickSeconds; |
| 20491 | } |
| 20492 | |
| 20493 | double MidiFileIn :: getTickSeconds( unsigned int track ) |
| 20494 | { |
| 20495 | std::stringstream msg; |
| 20496 | // Return the current tick value in seconds for the given track. |
| 20497 | if ( track >= nTracks_ ) { |
| 20498 | msg << "MidiFileIn::getTickSeconds: invalid track argument (" << track << ")."; |
| 20499 | handleError( msg.str().c_str(), StkError::WARNING ); return 0.0; |
| 20500 | } |
| 20501 | |
| 20502 | return tickSeconds_[track]; |
| 20503 | } |
| 20504 | |
| 20505 | // ge: implemented |
| 20506 | double MidiFileIn :: getBPM() |
| 20507 | { |
| 20508 | return bpm_; |
| 20509 | } |
| 20510 | |
| 20511 | // ge & alex & kiran: implemented 1.5.3.2 |
| 20512 | double MidiFileIn :: getTPQ() |
| 20513 | { |
| 20514 | return tpq_; |
| 20515 | } |
| 20516 | |
| 20517 | unsigned long MidiFileIn :: getNextEvent( std::vector<unsigned char> *event, unsigned int track ) |
| 20518 | { |
| 20519 | // Fill the user-provided vector with the next event in the |
| 20520 | // specified track (default = 0) and return the event delta time in |
| 20521 | // ticks. This function assumes that the stored track pointer is |
| 20522 | // positioned at the start of a track event. If the track has |
| 20523 | // reached its end, the event vector size will be zero. |
| 20524 | // |
| 20525 | // If we have a format 0 or 2 file and we're not using timecode, we |
| 20526 | // should check every meta-event for tempo changes and make |
| 20527 | // appropriate updates to the tickSeconds_ parameter if so. |
| 20528 | // |
| 20529 | // If we have a format 1 file and we're not using timecode, keep a |
| 20530 | // running sum of ticks for each track and update the tickSeconds_ |
| 20531 | // parameter as needed based on the stored tempo map. |
| 20532 | |
| 20533 | // 1.4.1.1 (ge) string buffer for error message |
| 20534 | std::stringstream msg; |
| 20535 | |
| 20536 | event->clear(); |
| 20537 | if ( track >= nTracks_ ) { |
| 20538 | msg << "MidiFileIn::getNextEvent: invalid track argument (" << track << ")."; |
| 20539 | handleError( msg.str().c_str(), StkError::WARNING ); return 0; |
| 20540 | } |
| 20541 | |
| 20542 | // Check for the end of the track. |
| 20543 | if ( (trackPointers_[track] - trackOffsets_[track]) >= trackLengths_[track] ) |
| 20544 | return 0; |
| 20545 | |
| 20546 | unsigned long ticks = 0, bytes = 0; |
| 20547 | bool isTempoEvent = false; |
| 20548 | |
| 20549 | // Read the event delta time. |
| 20550 | file_.seekg( trackPointers_[track], std::ios_base::beg ); |
| 20551 | if ( !readVariableLength( &ticks ) ) goto error; |
| 20552 | |
| 20553 | // Parse the event stream to determine the event length. |
| 20554 | unsigned char c; |
| 20555 | if ( !file_.read( (char *)&c, 1 ) ) goto error; |
| 20556 | switch ( c ) { |
| 20557 | |
| 20558 | case 0xFF: // A Meta-Event |
| 20559 | unsigned long position; |
| 20560 | trackStatus_[track] = 0; |
| 20561 | event->push_back( c ); |
| 20562 | if ( !file_.read( (char *)&c, 1 ) ) goto error; |
| 20563 | event->push_back( c ); |
| 20564 | if ( format_ != 1 && ( c == 0x51 ) ) isTempoEvent = true; |
| 20565 | position = file_.tellg(); |
| 20566 | if ( !readVariableLength( &bytes ) ) goto error; |
| 20567 | bytes += ( (unsigned long)file_.tellg() - position ); |
| 20568 | file_.seekg( position, std::ios_base::beg ); |
| 20569 | break; |
| 20570 | |
| 20571 | case 0xF0: |
| 20572 | case 0xF7: // The start or continuation of a Sysex event |
| 20573 | trackStatus_[track] = 0; |
| 20574 | event->push_back( c ); |
| 20575 | position = file_.tellg(); |
| 20576 | if ( !readVariableLength( &bytes ) ) goto error; |
| 20577 | bytes += ( (unsigned long)file_.tellg() - position ); |
| 20578 | file_.seekg( position, std::ios_base::beg ); |
| 20579 | break; |
| 20580 | |
| 20581 | default: // Should be a MIDI channel event |
| 20582 | if ( c & 0x80 ) { // MIDI status byte |
| 20583 | if ( c > 0xF0 ) goto error; |
| 20584 | trackStatus_[track] = c; |
| 20585 | event->push_back( c ); |
| 20586 | c &= 0xF0; |
| 20587 | if ( (c == 0xC0) || (c == 0xD0) ) bytes = 1; |
| 20588 | else bytes = 2; |
| 20589 | } |
| 20590 | else if ( trackStatus_[track] & 0x80 ) { // Running status |
| 20591 | event->push_back( trackStatus_[track] ); |
| 20592 | event->push_back( c ); |
| 20593 | c = trackStatus_[track] & 0xF0; |
| 20594 | if ( (c != 0xC0) && (c != 0xD0) ) bytes = 1; |
| 20595 | } |
| 20596 | else goto error; |
| 20597 | |
| 20598 | } |
| 20599 | |
| 20600 | // Read the rest of the event into the event vector. |
| 20601 | unsigned long i; |
| 20602 | for ( i=0; i<bytes; i++ ) { |
| 20603 | if ( !file_.read( (char *)&c, 1 ) ) goto error; |
| 20604 | event->push_back( c ); |
| 20605 | } |
| 20606 | |
| 20607 | if ( !usingTimeCode_ ) { |
| 20608 | if ( isTempoEvent ) { |
| 20609 | // Parse the tempo event and update tickSeconds_[track]. |
| 20610 | double tickrate = (double) (division_ & 0x7FFF); |
| 20611 | unsigned long value = ( event->at(3) << 16 ) + ( event->at(4) << 8 ) + event->at(5); |
| 20612 | tickSeconds_[track] = (double) (0.000001 * value / tickrate); |
| 20613 | |
| 20614 | // ge: set BPM |
| 20615 | bpm_ = 60000000.0 / value; |
| 20616 | } |
| 20617 | |
| 20618 | if ( format_ == 1 ) { |
| 20619 | // Update track counter and check the tempo map. |
| 20620 | trackCounters_[track] += ticks; |
| 20621 | TempoChange tempoEvent = tempoEvents_[ trackTempoIndex_[track] ]; |
| 20622 | if ( trackCounters_[track] >= tempoEvent.count && trackTempoIndex_[track] < tempoEvents_.size() - 1 ) { |
| 20623 | trackTempoIndex_[track]++; |
| 20624 | tickSeconds_[track] = tempoEvent.tickSeconds; |
| 20625 | } |
| 20626 | } |
| 20627 | } |
| 20628 | |
| 20629 | // Save the current track pointer value. |
| 20630 | trackPointers_[track] = file_.tellg(); |
| 20631 | |
| 20632 | return ticks; |
| 20633 | |
| 20634 | error: |
| 20635 | msg << "MidiFileIn::getNextEvent: file read error!"; |
| 20636 | handleError( msg.str().c_str(), StkError::FILE_ERROR ); |
| 20637 | return 0; |
| 20638 | } |
| 20639 | |
| 20640 | unsigned long MidiFileIn :: getNextMidiEvent( std::vector<unsigned char> *midiEvent, unsigned int track ) |
| 20641 | { |
| 20642 | std::stringstream msg; |
| 20643 | // Fill the user-provided vector with the next MIDI event in the |
| 20644 | // specified track (default = 0) and return the event delta time in |
| 20645 | // ticks. Meta-Events preceeding this event are skipped and ignored. |
| 20646 | if ( track >= nTracks_ ) { |
| 20647 | msg << "MidiFileIn::getNextMidiEvent: invalid track argument (" << track << ")."; |
| 20648 | handleError( msg.str().c_str(), StkError::WARNING ); return 0; |
| 20649 | } |
| 20650 | |
| 20651 | unsigned long ticks = getNextEvent( midiEvent, track ); |
| 20652 | while ( midiEvent->size() && ( midiEvent->at(0) >= 0xF0 ) ) { |
| 20653 | //for ( unsigned int i=0; i<midiEvent->size(); i++ ) |
| 20654 | //CK_STDCOUT << "event byte = " << i << ", value = " << (int)midiEvent->at(i) << CK_STDENDL; |
| 20655 | ticks = getNextEvent( midiEvent, track ); |
| 20656 | } |
| 20657 | |
| 20658 | //for ( unsigned int i=0; i<midiEvent->size(); i++ ) |
| 20659 | //CK_STDCOUT << "event byte = " << i << ", value = " << (int)midiEvent->at(i) << CK_STDENDL; |
| 20660 | |
| 20661 | return ticks; |
| 20662 | } |
| 20663 | |
| 20664 | bool MidiFileIn :: readVariableLength( unsigned long *value ) |
| 20665 | { |
| 20666 | // It is assumed that this function is called with the file read |
| 20667 | // pointer positioned at the start of a variable-length value. The |
| 20668 | // function returns "true" if the value is successfully parsed and |
| 20669 | // "false" otherwise. |
| 20670 | *value = 0; |
| 20671 | char c; |
| 20672 | |
| 20673 | if ( !file_.read( &c, 1 ) ) return false; |
| 20674 | *value = (unsigned long) c; |
| 20675 | if ( *value & 0x80 ) { |
| 20676 | *value &= 0x7f; |
| 20677 | do { |
| 20678 | if ( !file_.read( &c, 1 ) ) return false; |
| 20679 | *value = ( *value << 7 ) + ( c & 0x7f ); |
| 20680 | } while ( c & 0x80 ); |
| 20681 | } |
| 20682 | |
| 20683 | return true; |
| 20684 | } |
| 20685 | |
| 20686 | } // stk namespace |
| 20687 | |
| 20688 | // chuck - import |
| 20689 | // wrapper functions |
| 20690 | |
| 20691 | //convenience functions |
| 20692 | /* void |
| 20693 | ck_domidi ( Instrmnt * inst, unsigned int i ) { |
| 20694 | unsigned char status = (i>>16)&&0xff; |
| 20695 | unsigned char data1 = (i>>8)&&0xff; |
| 20696 | unsigned char data2 = (i)&&0xff; |
| 20697 | |
| 20698 | } |
| 20699 | |
| 20700 | void |
| 20701 | ck_domidi ( Instrmnt * inst, unsigned char status, unsigned char data1, unsigned char data2) { |
| 20702 | unsigned char type = status && 0xf0; |
| 20703 | switch ( type ) { |
| 20704 | case __SK_NoteOn_: |
| 20705 | inst->noteOn( ck_mtof ( (float)data1 ), ((float)data2) / 128.0 ); |
| 20706 | break; |
| 20707 | case __SK_NoteOff_: |
| 20708 | inst->noteOff( ((float)data2) / 128.0 ); |
| 20709 | break; |
| 20710 | case __SK_ControlChange_: |
| 20711 | inst->controlChange( data1, data2 ); |
| 20712 | break; |
| 20713 | case __SK_AfterTouch_: |
| 20714 | inst->controlChange( __SK_AfterTouch_, ((float)data1) / 128.0 ); |
| 20715 | case __SK_PitchBend_: |
| 20716 | unsigned int mnum = ((unsigned int)data2) << 7 || data1 ); |
| 20717 | inst->controlChange( __SK_PitchBend_, ((float)mnum) / 16384.0 ); |
| 20718 | break; |
| 20719 | } |
| 20720 | } |
| 20721 | |
| 20722 | */ |
| 20723 | |
| 20724 | |
| 20725 | |
| 20726 | |
| 20727 | // StkInstrument |
| 20728 | //----------------------------------------------------------------------------- |
| 20729 | // name: Instrmnt_ctor() |
| 20730 | // desc: CTOR function ... |
| 20731 | //----------------------------------------------------------------------------- |
| 20732 | CK_DLL_CTOR( Instrmnt_ctor ) |
| 20733 | { |
| 20734 | // initialize member object |
| 20735 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)0; |
| 20736 | } |
| 20737 | |
| 20738 | |
| 20739 | //----------------------------------------------------------------------------- |
| 20740 | // name: Instrmnt_dtor() |
| 20741 | // desc: DTOR function ... |
| 20742 | //----------------------------------------------------------------------------- |
| 20743 | CK_DLL_DTOR( Instrmnt_dtor ) |
| 20744 | { |
| 20745 | // should be done already by now |
| 20746 | } |
| 20747 | |
| 20748 | |
| 20749 | //----------------------------------------------------------------------------- |
| 20750 | // name: Instrmnt_tick() |
| 20751 | // desc: TICK function ... |
| 20752 | //----------------------------------------------------------------------------- |
| 20753 | CK_DLL_TICK( Instrmnt_tick ) |
| 20754 | { |
| 20755 | // Instrmnt * i = (Instrmnt *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20756 | |
| 20757 | // generally, we should not get here -- but is possible since there are |
| 20758 | // abstract classes, such as this one, but currently chuck has no |
| 20759 | // provisions for marking classes as abstract... this is a workaround |
| 20760 | // 1.5.0.0 | (ge) changed CK_FPRINTF_STDERR to EM_log; allow program to proceed |
| 20761 | EM_log( CK_LOG_WARNING, "(STK) error -- StkInstrmnt.tick() is abstract!" ); |
| 20762 | EM_log( CK_LOG_WARNING, "(STK) |- likely StkInstrmnt was declared/used directly," ); |
| 20763 | EM_log( CK_LOG_WARNING, "(STK) |- instead of a subclass of StkInstrmnt" ); |
| 20764 | |
| 20765 | // TODO: type system should not allow direct declaration of abstract classes |
| 20766 | // TODO: should detect, give a compiler error, with a short explanation and |
| 20767 | // TODO: suggestion on what to do: e.g., |
| 20768 | // TODO: "XXX cannot be instantiated directly (use '@' to declare a reference)" |
| 20769 | |
| 20770 | // 1.5.0.0 | (ge) commented out to avoid a potentially confusing crash |
| 20771 | // *out = i->tick(); |
| 20772 | // instead we will return silence |
| 20773 | *out = 0; |
| 20774 | |
| 20775 | return TRUE; |
| 20776 | } |
| 20777 | |
| 20778 | |
| 20779 | //----------------------------------------------------------------------------- |
| 20780 | // name: BlowBotl_pmsg() |
| 20781 | // desc: PMSG function ... |
| 20782 | //----------------------------------------------------------------------------- |
| 20783 | CK_DLL_PMSG( Instrmnt_pmsg ) |
| 20784 | { |
| 20785 | return TRUE; |
| 20786 | } |
| 20787 | |
| 20788 | |
| 20789 | //----------------------------------------------------------------------------- |
| 20790 | // name: Instrmnt_ctrl_noteOn() |
| 20791 | // desc: CTRL function ... |
| 20792 | //----------------------------------------------------------------------------- |
| 20793 | CK_DLL_CTRL( Instrmnt_ctrl_noteOn ) |
| 20794 | { |
| 20795 | Instrmnt * i = (Instrmnt *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20796 | //--------------------------------------------------------------------- |
| 20797 | // check for base class pointer; throw exception and halt shred if NULL |
| 20798 | if( !stk_verify_baseclass(i, SELF->type_ref->name(), SHRED) ) return; |
| 20799 | //--------------------------------------------------------------------- |
| 20800 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 20801 | i->noteOn( i->m_frequency, f ); |
| 20802 | } |
| 20803 | |
| 20804 | |
| 20805 | //----------------------------------------------------------------------------- |
| 20806 | // name: Instrmnt_ctrl_noteOff() |
| 20807 | // desc: CTRL function ... |
| 20808 | //----------------------------------------------------------------------------- |
| 20809 | CK_DLL_CTRL( Instrmnt_ctrl_noteOff ) |
| 20810 | { |
| 20811 | Instrmnt * i = (Instrmnt *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20812 | //--------------------------------------------------------------------- |
| 20813 | // check for base class pointer; throw exception and halt shred if NULL |
| 20814 | if( !stk_verify_baseclass(i, SELF->type_ref->name(), SHRED) ) return; |
| 20815 | //--------------------------------------------------------------------- |
| 20816 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 20817 | i->noteOff( f ); |
| 20818 | } |
| 20819 | |
| 20820 | |
| 20821 | |
| 20822 | |
| 20823 | //----------------------------------------------------------------------------- |
| 20824 | // name: Instrmnt_ctrl_freq() |
| 20825 | // desc: CTRL function ... |
| 20826 | //----------------------------------------------------------------------------- |
| 20827 | CK_DLL_CTRL( Instrmnt_ctrl_freq ) |
| 20828 | { |
| 20829 | Instrmnt * i = (Instrmnt *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20830 | //--------------------------------------------------------------------- |
| 20831 | // check for base class pointer; throw exception and halt shred if NULL |
| 20832 | if( !stk_verify_baseclass(i, SELF->type_ref->name(), SHRED) ) return; |
| 20833 | //--------------------------------------------------------------------- |
| 20834 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 20835 | i->setFrequency( f ); |
| 20836 | RETURN->v_float = (t_CKFLOAT)i->m_frequency; |
| 20837 | } |
| 20838 | |
| 20839 | |
| 20840 | //----------------------------------------------------------------------------- |
| 20841 | // name: Instrmnt_cget_freq() |
| 20842 | // desc: CGET function ... |
| 20843 | //----------------------------------------------------------------------------- |
| 20844 | CK_DLL_CGET( Instrmnt_cget_freq ) |
| 20845 | { |
| 20846 | Instrmnt * i = (Instrmnt *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20847 | //--------------------------------------------------------------------- |
| 20848 | // check for base class pointer; throw exception and halt shred if NULL |
| 20849 | if( !stk_verify_baseclass(i, SELF->type_ref->name(), SHRED) ) return; |
| 20850 | //--------------------------------------------------------------------- |
| 20851 | RETURN->v_float = (t_CKFLOAT)i->m_frequency; |
| 20852 | } |
| 20853 | |
| 20854 | |
| 20855 | //----------------------------------------------------------------------------- |
| 20856 | // name: Instrmnt_ctrl_controlChange() |
| 20857 | // desc: CTRL function ... |
| 20858 | //----------------------------------------------------------------------------- |
| 20859 | CK_DLL_CTRL(Instrmnt_ctrl_controlChange ) |
| 20860 | { |
| 20861 | Instrmnt * ii = (Instrmnt *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20862 | //--------------------------------------------------------------------- |
| 20863 | // check for base class pointer; throw exception and halt shred if NULL |
| 20864 | if( !stk_verify_baseclass(ii, SELF->type_ref->name(), SHRED) ) return; |
| 20865 | //--------------------------------------------------------------------- |
| 20866 | t_CKINT i = GET_NEXT_INT(ARGS); |
| 20867 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 20868 | ii->controlChange( i, f ); |
| 20869 | } |
| 20870 | |
| 20871 | |
| 20872 | |
| 20873 | |
| 20874 | //----------------------------------------------------------------------------- |
| 20875 | // name: BandedWG_ctor() |
| 20876 | // desc: CTOR function ... |
| 20877 | //----------------------------------------------------------------------------- |
| 20878 | CK_DLL_CTOR( BandedWG_ctor ) |
| 20879 | { |
| 20880 | // initialize member object |
| 20881 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT) new BandedWG(); |
| 20882 | } |
| 20883 | |
| 20884 | //----------------------------------------------------------------------------- |
| 20885 | // name: BandedWG_dtor() |
| 20886 | // desc: DTOR function ... |
| 20887 | //----------------------------------------------------------------------------- |
| 20888 | CK_DLL_DTOR( BandedWG_dtor ) |
| 20889 | { |
| 20890 | delete (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20891 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 20892 | } |
| 20893 | |
| 20894 | //----------------------------------------------------------------------------- |
| 20895 | // name: BandedWG_tick() |
| 20896 | // desc: TICK function ... |
| 20897 | //----------------------------------------------------------------------------- |
| 20898 | CK_DLL_TICK( BandedWG_tick ) |
| 20899 | { |
| 20900 | *out = ((BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data))->tick(); |
| 20901 | return TRUE; |
| 20902 | } |
| 20903 | |
| 20904 | //----------------------------------------------------------------------------- |
| 20905 | // name: BandedWG_pmsg() |
| 20906 | // desc: PMSG function ... |
| 20907 | //----------------------------------------------------------------------------- |
| 20908 | CK_DLL_PMSG( BandedWG_pmsg ) |
| 20909 | { |
| 20910 | return FALSE; |
| 20911 | } |
| 20912 | |
| 20913 | //----------------------------------------------------------------------------- |
| 20914 | // name: BandedWG_ctrl_pluck() |
| 20915 | // desc: CTRL function ... |
| 20916 | //----------------------------------------------------------------------------- |
| 20917 | CK_DLL_CTRL( BandedWG_ctrl_pluck ) |
| 20918 | { |
| 20919 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20920 | f->pluck( GET_NEXT_FLOAT(ARGS)); |
| 20921 | } |
| 20922 | |
| 20923 | //----------------------------------------------------------------------------- |
| 20924 | // name: BandedWG_ctrl_strikePosition() |
| 20925 | // desc: CTRL function ... |
| 20926 | //----------------------------------------------------------------------------- |
| 20927 | CK_DLL_CTRL( BandedWG_ctrl_strikePosition ) |
| 20928 | { |
| 20929 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20930 | f->setStrikePosition( GET_NEXT_FLOAT(ARGS) ); |
| 20931 | RETURN->v_float = (t_CKFLOAT)f->m_strikePosition; |
| 20932 | } |
| 20933 | |
| 20934 | //----------------------------------------------------------------------------- |
| 20935 | // name: BandedWG_cget_strikePosition() |
| 20936 | // desc: CGET function ... |
| 20937 | //----------------------------------------------------------------------------- |
| 20938 | |
| 20939 | CK_DLL_CGET( BandedWG_cget_strikePosition ) |
| 20940 | { |
| 20941 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20942 | RETURN->v_float = (t_CKFLOAT)f->m_strikePosition; |
| 20943 | } |
| 20944 | |
| 20945 | |
| 20946 | //----------------------------------------------------------------------------- |
| 20947 | // name: BandedWG_ctrl_bowRate() |
| 20948 | // desc: CTRL function ... |
| 20949 | //----------------------------------------------------------------------------- |
| 20950 | CK_DLL_CTRL( BandedWG_ctrl_bowRate ) |
| 20951 | { |
| 20952 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20953 | f->m_rate = GET_NEXT_FLOAT(ARGS); |
| 20954 | RETURN->v_float = (t_CKFLOAT) f->m_rate; |
| 20955 | } |
| 20956 | |
| 20957 | //----------------------------------------------------------------------------- |
| 20958 | // name: BandedWG_cget_bowRate() |
| 20959 | // desc: CGET function ... |
| 20960 | //----------------------------------------------------------------------------- |
| 20961 | |
| 20962 | CK_DLL_CGET( BandedWG_cget_bowRate ) |
| 20963 | { |
| 20964 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20965 | RETURN->v_float = (t_CKFLOAT) f->m_rate; |
| 20966 | } |
| 20967 | |
| 20968 | |
| 20969 | //----------------------------------------------------------------------------- |
| 20970 | // name: BandedWG_ctrl_bowPressure() |
| 20971 | // desc: CTRL function ... |
| 20972 | //----------------------------------------------------------------------------- |
| 20973 | CK_DLL_CTRL( BandedWG_ctrl_bowPressure ) |
| 20974 | { |
| 20975 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20976 | f->controlChange( __SK_BowPressure_, GET_NEXT_FLOAT(ARGS) * 128.0 ); |
| 20977 | RETURN->v_float = (t_CKFLOAT)f->m_bowPressure; |
| 20978 | } |
| 20979 | |
| 20980 | //----------------------------------------------------------------------------- |
| 20981 | // name: BandedWG_cget_bowPressure() |
| 20982 | // desc: CGET function ... |
| 20983 | //----------------------------------------------------------------------------- |
| 20984 | CK_DLL_CGET( BandedWG_cget_bowPressure ) |
| 20985 | { |
| 20986 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20987 | RETURN->v_float = (t_CKFLOAT)f->m_bowPressure; |
| 20988 | } |
| 20989 | |
| 20990 | //----------------------------------------------------------------------------- |
| 20991 | // name: BandedWG_ctrl_bowMotion() |
| 20992 | // desc: CTRL function ... |
| 20993 | //----------------------------------------------------------------------------- |
| 20994 | CK_DLL_CTRL( BandedWG_ctrl_bowMotion ) |
| 20995 | { |
| 20996 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 20997 | f->controlChange( 4, GET_NEXT_FLOAT(ARGS) * 128.0 ); |
| 20998 | RETURN->v_float = (t_CKFLOAT)f->m_bowMotion; |
| 20999 | } |
| 21000 | |
| 21001 | //----------------------------------------------------------------------------- |
| 21002 | // name: BandedWG_cget_bowMotion() |
| 21003 | // desc: CGET function ... |
| 21004 | //----------------------------------------------------------------------------- |
| 21005 | CK_DLL_CGET( BandedWG_cget_bowMotion ) |
| 21006 | { |
| 21007 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21008 | RETURN->v_float = (t_CKFLOAT)f->m_bowMotion; |
| 21009 | } |
| 21010 | |
| 21011 | //----------------------------------------------------------------------------- |
| 21012 | // name: BandedWG_ctrl_vibratoFreq() |
| 21013 | // desc: CTRL function ... |
| 21014 | //----------------------------------------------------------------------------- |
| 21015 | CK_DLL_CTRL( BandedWG_ctrl_vibratoFreq ) |
| 21016 | { |
| 21017 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21018 | f->controlChange( 4, GET_NEXT_FLOAT(ARGS) * 128.0 ); |
| 21019 | RETURN->v_float = (t_CKFLOAT)f->integrationConstant; |
| 21020 | } |
| 21021 | |
| 21022 | //----------------------------------------------------------------------------- |
| 21023 | // name: BandedWG_cget_vibratoFreq() |
| 21024 | // desc: CGET function ... |
| 21025 | //----------------------------------------------------------------------------- |
| 21026 | CK_DLL_CGET( BandedWG_cget_vibratoFreq ) |
| 21027 | { |
| 21028 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21029 | RETURN->v_float = (t_CKFLOAT)f->integrationConstant; |
| 21030 | } |
| 21031 | |
| 21032 | //----------------------------------------------------------------------------- |
| 21033 | // name: BandedWG_ctrl_modesGain() |
| 21034 | // desc: CTRL function ... |
| 21035 | //----------------------------------------------------------------------------- |
| 21036 | CK_DLL_CTRL( BandedWG_ctrl_modesGain ) |
| 21037 | { |
| 21038 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21039 | f->controlChange( 1, GET_NEXT_FLOAT(ARGS) * 128.0 ); |
| 21040 | RETURN->v_float = (t_CKFLOAT)f->m_modesGain; |
| 21041 | } |
| 21042 | |
| 21043 | //----------------------------------------------------------------------------- |
| 21044 | // name: BandedWG_cget_modesGain() |
| 21045 | // desc: CGET function ... |
| 21046 | //----------------------------------------------------------------------------- |
| 21047 | CK_DLL_CGET( BandedWG_cget_modesGain ) |
| 21048 | { |
| 21049 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21050 | RETURN->v_float = (t_CKFLOAT)f->m_modesGain; |
| 21051 | } |
| 21052 | |
| 21053 | //----------------------------------------------------------------------------- |
| 21054 | // name: BandedWG_ctrl_preset() |
| 21055 | // desc: CTRL function ... |
| 21056 | //----------------------------------------------------------------------------- |
| 21057 | CK_DLL_CTRL( BandedWG_ctrl_preset ) |
| 21058 | { |
| 21059 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21060 | f->setPreset ( GET_NEXT_INT(ARGS) ); |
| 21061 | RETURN->v_int = (t_CKINT) f->m_preset; |
| 21062 | } |
| 21063 | |
| 21064 | |
| 21065 | //----------------------------------------------------------------------------- |
| 21066 | // name: BandedWG_cget_preset() |
| 21067 | // desc: CGET function ... |
| 21068 | //----------------------------------------------------------------------------- |
| 21069 | CK_DLL_CGET( BandedWG_cget_preset ) |
| 21070 | { |
| 21071 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21072 | RETURN->v_int = (t_CKINT) f->m_preset; |
| 21073 | } |
| 21074 | |
| 21075 | |
| 21076 | //----------------------------------------------------------------------------- |
| 21077 | // name: BandedWG_ctrl_startBowing() |
| 21078 | // desc: CTRL function ... |
| 21079 | //----------------------------------------------------------------------------- |
| 21080 | CK_DLL_CTRL( BandedWG_ctrl_startBowing ) |
| 21081 | { |
| 21082 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21083 | f->startBowing( GET_NEXT_FLOAT(ARGS), f->m_rate ); |
| 21084 | } |
| 21085 | |
| 21086 | |
| 21087 | //----------------------------------------------------------------------------- |
| 21088 | // name: BandedWG_ctrl_stopBowing() |
| 21089 | // desc: CTRL function ... |
| 21090 | //----------------------------------------------------------------------------- |
| 21091 | CK_DLL_CTRL( BandedWG_ctrl_stopBowing ) |
| 21092 | { |
| 21093 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21094 | f->stopBowing( GET_NEXT_FLOAT(ARGS) ); |
| 21095 | } |
| 21096 | |
| 21097 | |
| 21098 | //----------------------------------------------------------------------------- |
| 21099 | // name: BandedWG_ctrl_controlChange() |
| 21100 | // desc: CTRL function ... |
| 21101 | //----------------------------------------------------------------------------- |
| 21102 | CK_DLL_CTRL( BandedWG_ctrl_controlChange ) |
| 21103 | { |
| 21104 | BandedWG * f = (BandedWG *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21105 | t_CKINT i = GET_NEXT_INT(ARGS); |
| 21106 | t_CKFLOAT v = GET_NEXT_FLOAT(ARGS); |
| 21107 | f->controlChange( i, v ); |
| 21108 | } |
| 21109 | |
| 21110 | |
| 21111 | // BiQuad |
| 21112 | struct BiQuad_ |
| 21113 | { |
| 21114 | BiQuad biquad; |
| 21115 | t_CKFLOAT pfreq; |
| 21116 | t_CKFLOAT prad; |
| 21117 | t_CKFLOAT zfreq; |
| 21118 | t_CKFLOAT zrad; |
| 21119 | t_CKBOOL norm; |
| 21120 | |
| 21121 | // constructor |
| 21122 | BiQuad_() : pfreq(0), prad(0), zfreq(0), zrad(0), norm(FALSE) { } |
| 21123 | }; |
| 21124 | |
| 21125 | |
| 21126 | //----------------------------------------------------------------------------- |
| 21127 | // name: BiQuad_ctor() |
| 21128 | // desc: CTOR function ... |
| 21129 | //----------------------------------------------------------------------------- |
| 21130 | CK_DLL_CTOR( BiQuad_ctor ) |
| 21131 | { |
| 21132 | BiQuad_ * d = new BiQuad_; |
| 21133 | OBJ_MEMBER_UINT(SELF, BiQuad_offset_data) = (t_CKUINT)d; |
| 21134 | } |
| 21135 | |
| 21136 | |
| 21137 | //----------------------------------------------------------------------------- |
| 21138 | // name: BiQuad_dtor() |
| 21139 | // desc: DTOR function ... |
| 21140 | //----------------------------------------------------------------------------- |
| 21141 | CK_DLL_DTOR( BiQuad_dtor ) |
| 21142 | { |
| 21143 | delete (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21144 | OBJ_MEMBER_UINT(SELF, BiQuad_offset_data) = 0; |
| 21145 | } |
| 21146 | |
| 21147 | |
| 21148 | //----------------------------------------------------------------------------- |
| 21149 | // name: BiQuad_tick() |
| 21150 | // desc: TICK function ... |
| 21151 | //----------------------------------------------------------------------------- |
| 21152 | CK_DLL_TICK( BiQuad_tick ) |
| 21153 | { |
| 21154 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21155 | *out = (SAMPLE)f->biquad.tick( in ); |
| 21156 | return TRUE; |
| 21157 | } |
| 21158 | |
| 21159 | |
| 21160 | //----------------------------------------------------------------------------- |
| 21161 | // name: BiQuad_pmsg() |
| 21162 | // desc: PMSG function ... |
| 21163 | //----------------------------------------------------------------------------- |
| 21164 | CK_DLL_PMSG( BiQuad_pmsg ) |
| 21165 | { |
| 21166 | return FALSE; |
| 21167 | } |
| 21168 | |
| 21169 | |
| 21170 | //----------------------------------------------------------------------------- |
| 21171 | // name: BiQuad_ctrl_b2() |
| 21172 | // desc: CTRL function ... |
| 21173 | //----------------------------------------------------------------------------- |
| 21174 | CK_DLL_CTRL( BiQuad_ctrl_b2 ) |
| 21175 | { |
| 21176 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21177 | f->biquad.setB2( GET_NEXT_FLOAT(ARGS) ); |
| 21178 | RETURN->v_float = (t_CKFLOAT) f->biquad.b[2]; |
| 21179 | } |
| 21180 | |
| 21181 | |
| 21182 | //----------------------------------------------------------------------------- |
| 21183 | // name: BiQuad_cget_b2() |
| 21184 | // desc: CGET function ... |
| 21185 | //----------------------------------------------------------------------------- |
| 21186 | CK_DLL_CGET( BiQuad_cget_b2 ) |
| 21187 | { |
| 21188 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21189 | RETURN->v_float = (t_CKFLOAT) f->biquad.b[2]; |
| 21190 | } |
| 21191 | |
| 21192 | |
| 21193 | //----------------------------------------------------------------------------- |
| 21194 | // name: BiQuad_ctrl_b1() |
| 21195 | // desc: CTRL function ... |
| 21196 | //----------------------------------------------------------------------------- |
| 21197 | CK_DLL_CTRL( BiQuad_ctrl_b1 ) |
| 21198 | { |
| 21199 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21200 | f->biquad.setB1( GET_NEXT_FLOAT(ARGS) ); |
| 21201 | RETURN->v_float = (t_CKFLOAT) f->biquad.b[1]; |
| 21202 | } |
| 21203 | |
| 21204 | |
| 21205 | //----------------------------------------------------------------------------- |
| 21206 | // name: BiQuad_cget_b1() |
| 21207 | // desc: CGET function ... |
| 21208 | //----------------------------------------------------------------------------- |
| 21209 | CK_DLL_CGET( BiQuad_cget_b1 ) |
| 21210 | { |
| 21211 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21212 | RETURN->v_float = (t_CKFLOAT) f->biquad.b[1]; |
| 21213 | } |
| 21214 | |
| 21215 | |
| 21216 | //----------------------------------------------------------------------------- |
| 21217 | // name: BiQuad_ctrl_b0() |
| 21218 | // desc: CTRL function ... |
| 21219 | //----------------------------------------------------------------------------- |
| 21220 | CK_DLL_CTRL( BiQuad_ctrl_b0 ) |
| 21221 | { |
| 21222 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21223 | f->biquad.setB0( GET_NEXT_FLOAT(ARGS) ); |
| 21224 | RETURN->v_float = (t_CKFLOAT) f->biquad.b[0]; |
| 21225 | } |
| 21226 | |
| 21227 | |
| 21228 | //----------------------------------------------------------------------------- |
| 21229 | // name: BiQuad_cget_b0() |
| 21230 | // desc: CGET function ... |
| 21231 | //----------------------------------------------------------------------------- |
| 21232 | CK_DLL_CGET( BiQuad_cget_b0 ) |
| 21233 | { |
| 21234 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21235 | RETURN->v_float = (t_CKFLOAT) f->biquad.b[0]; |
| 21236 | } |
| 21237 | |
| 21238 | |
| 21239 | //----------------------------------------------------------------------------- |
| 21240 | // name: BiQuad_ctrl_a2() |
| 21241 | // desc: CTRL function ... |
| 21242 | //----------------------------------------------------------------------------- |
| 21243 | CK_DLL_CTRL( BiQuad_ctrl_a2 ) |
| 21244 | { |
| 21245 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21246 | f->biquad.setA2( GET_NEXT_FLOAT(ARGS) ); |
| 21247 | RETURN->v_float = (t_CKFLOAT) f->biquad.a[2]; |
| 21248 | } |
| 21249 | |
| 21250 | |
| 21251 | //----------------------------------------------------------------------------- |
| 21252 | // name: BiQuad_cget_a2() |
| 21253 | // desc: CGET function ... |
| 21254 | //----------------------------------------------------------------------------- |
| 21255 | CK_DLL_CGET( BiQuad_cget_a2 ) |
| 21256 | { |
| 21257 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21258 | RETURN->v_float = (t_CKFLOAT) f->biquad.a[2]; |
| 21259 | } |
| 21260 | |
| 21261 | |
| 21262 | //----------------------------------------------------------------------------- |
| 21263 | // name: BiQuad_ctrl_a1() |
| 21264 | // desc: CTRL function ... |
| 21265 | //----------------------------------------------------------------------------- |
| 21266 | CK_DLL_CTRL( BiQuad_ctrl_a1 ) |
| 21267 | { |
| 21268 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21269 | f->biquad.setA1( GET_NEXT_FLOAT(ARGS) ); |
| 21270 | RETURN->v_float = (t_CKFLOAT) f->biquad.a[1]; |
| 21271 | } |
| 21272 | |
| 21273 | |
| 21274 | //----------------------------------------------------------------------------- |
| 21275 | // name: BiQuad_cget_a1() |
| 21276 | // desc: CGET function ... |
| 21277 | //----------------------------------------------------------------------------- |
| 21278 | CK_DLL_CGET( BiQuad_cget_a1 ) |
| 21279 | { |
| 21280 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21281 | RETURN->v_float = (t_CKFLOAT) f->biquad.a[1]; |
| 21282 | } |
| 21283 | |
| 21284 | |
| 21285 | //----------------------------------------------------------------------------- |
| 21286 | // name: BiQuad_cget_a0() |
| 21287 | // desc: CGET function ... |
| 21288 | //----------------------------------------------------------------------------- |
| 21289 | CK_DLL_CGET( BiQuad_cget_a0 ) |
| 21290 | { |
| 21291 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21292 | RETURN->v_float = (t_CKFLOAT) f->biquad.a[0]; |
| 21293 | } |
| 21294 | |
| 21295 | |
| 21296 | //----------------------------------------------------------------------------- |
| 21297 | // name: BiQuad_ctrl_pfreq() |
| 21298 | // desc: CTRL function ... |
| 21299 | //----------------------------------------------------------------------------- |
| 21300 | CK_DLL_CTRL( BiQuad_ctrl_pfreq ) |
| 21301 | { |
| 21302 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21303 | f->pfreq = GET_NEXT_FLOAT(ARGS); |
| 21304 | f->biquad.setResonance( f->pfreq, f->prad, f->norm != 0 ); |
| 21305 | RETURN->v_float = (t_CKFLOAT)f->pfreq; |
| 21306 | } |
| 21307 | |
| 21308 | |
| 21309 | //----------------------------------------------------------------------------- |
| 21310 | // name: BiQuad_cget_pfreq() |
| 21311 | // desc: CGET function ... |
| 21312 | //----------------------------------------------------------------------------- |
| 21313 | CK_DLL_CTRL( BiQuad_cget_pfreq ) |
| 21314 | { |
| 21315 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21316 | RETURN->v_float = (t_CKFLOAT)f->pfreq; |
| 21317 | } |
| 21318 | |
| 21319 | |
| 21320 | //----------------------------------------------------------------------------- |
| 21321 | // name: BiQuad_ctrl_prad() |
| 21322 | // desc: CTRL function ... |
| 21323 | //----------------------------------------------------------------------------- |
| 21324 | CK_DLL_CTRL( BiQuad_ctrl_prad ) |
| 21325 | { |
| 21326 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21327 | f->prad = GET_NEXT_FLOAT(ARGS); |
| 21328 | f->biquad.setResonance( f->pfreq, f->prad, f->norm != 0 ); |
| 21329 | RETURN->v_float = (t_CKFLOAT)f->prad; |
| 21330 | } |
| 21331 | |
| 21332 | |
| 21333 | //----------------------------------------------------------------------------- |
| 21334 | // name: BiQuad_cget_prad() |
| 21335 | // desc: CGET function ... |
| 21336 | //----------------------------------------------------------------------------- |
| 21337 | CK_DLL_CTRL( BiQuad_cget_prad ) |
| 21338 | { |
| 21339 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21340 | RETURN->v_float = (t_CKFLOAT)f->prad; |
| 21341 | } |
| 21342 | |
| 21343 | |
| 21344 | //----------------------------------------------------------------------------- |
| 21345 | // name: BiQuad_ctrl_zfreq() |
| 21346 | // desc: CTRL function ... |
| 21347 | //----------------------------------------------------------------------------- |
| 21348 | CK_DLL_CTRL( BiQuad_ctrl_zfreq ) |
| 21349 | { |
| 21350 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21351 | f->zfreq = GET_NEXT_FLOAT(ARGS); |
| 21352 | f->biquad.setNotch( f->zfreq, f->zrad ); |
| 21353 | RETURN->v_float = (t_CKFLOAT)f->zfreq; |
| 21354 | } |
| 21355 | |
| 21356 | |
| 21357 | //----------------------------------------------------------------------------- |
| 21358 | // name: BiQuad_cget_zfreq() |
| 21359 | // desc: CGET function ... |
| 21360 | //----------------------------------------------------------------------------- |
| 21361 | CK_DLL_CTRL( BiQuad_cget_zfreq ) |
| 21362 | { |
| 21363 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21364 | RETURN->v_float = (t_CKFLOAT)f->zfreq; |
| 21365 | } |
| 21366 | |
| 21367 | |
| 21368 | //----------------------------------------------------------------------------- |
| 21369 | // name: BiQuad_ctrl_zrad() |
| 21370 | // desc: CTRL function ... |
| 21371 | //----------------------------------------------------------------------------- |
| 21372 | CK_DLL_CTRL( BiQuad_ctrl_zrad ) |
| 21373 | { |
| 21374 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21375 | f->zrad = GET_NEXT_FLOAT(ARGS); |
| 21376 | f->biquad.setNotch( f->zfreq, f->zrad ); |
| 21377 | RETURN->v_float = f->zrad; |
| 21378 | } |
| 21379 | |
| 21380 | |
| 21381 | //----------------------------------------------------------------------------- |
| 21382 | // name: BiQuad_cget_zrad() |
| 21383 | // desc: CGET function ... |
| 21384 | //----------------------------------------------------------------------------- |
| 21385 | CK_DLL_CTRL( BiQuad_cget_zrad ) |
| 21386 | { |
| 21387 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21388 | RETURN->v_float = f->zrad; |
| 21389 | } |
| 21390 | |
| 21391 | |
| 21392 | //----------------------------------------------------------------------------- |
| 21393 | // name: BiQuad_ctrl_norm() |
| 21394 | // desc: CTRL function ... |
| 21395 | //----------------------------------------------------------------------------- |
| 21396 | CK_DLL_CTRL( BiQuad_ctrl_norm ) |
| 21397 | { |
| 21398 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21399 | f->norm = GET_NEXT_UINT(ARGS) != 0; |
| 21400 | f->biquad.setResonance( f->pfreq, f->prad, f->norm != 0 ); |
| 21401 | RETURN->v_int = f->norm; |
| 21402 | } |
| 21403 | |
| 21404 | |
| 21405 | //----------------------------------------------------------------------------- |
| 21406 | // name: BiQuad_ctrl_eqzs() |
| 21407 | // desc: CTRL function ... |
| 21408 | //----------------------------------------------------------------------------- |
| 21409 | CK_DLL_CTRL( BiQuad_ctrl_eqzs ) |
| 21410 | { |
| 21411 | BiQuad_ * f = (BiQuad_ *)OBJ_MEMBER_UINT(SELF, BiQuad_offset_data); |
| 21412 | f->biquad.setEqualGainZeroes(); |
| 21413 | } |
| 21414 | |
| 21415 | |
| 21416 | // BlowBotl |
| 21417 | //----------------------------------------------------------------------------- |
| 21418 | // name: BlowBotl_ctor() |
| 21419 | // desc: CTOR function ... |
| 21420 | //----------------------------------------------------------------------------- |
| 21421 | CK_DLL_CTOR( BlowBotl_ctor ) |
| 21422 | { |
| 21423 | // initialize member object |
| 21424 | BlowBotl * botl = new BlowBotl(); |
| 21425 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)botl; |
| 21426 | // default |
| 21427 | botl->setFrequency( 220 ); |
| 21428 | } |
| 21429 | |
| 21430 | |
| 21431 | //----------------------------------------------------------------------------- |
| 21432 | // name: BlowBotl_dtor() |
| 21433 | // desc: DTOR function ... |
| 21434 | //----------------------------------------------------------------------------- |
| 21435 | CK_DLL_DTOR( BlowBotl_dtor ) |
| 21436 | { |
| 21437 | delete (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21438 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 21439 | } |
| 21440 | |
| 21441 | |
| 21442 | //----------------------------------------------------------------------------- |
| 21443 | // name: BlowBotl_tick() |
| 21444 | // desc: TICK function ... |
| 21445 | //----------------------------------------------------------------------------- |
| 21446 | CK_DLL_TICK( BlowBotl_tick ) |
| 21447 | { |
| 21448 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21449 | *out = p->tick(); |
| 21450 | return TRUE; |
| 21451 | } |
| 21452 | |
| 21453 | |
| 21454 | //----------------------------------------------------------------------------- |
| 21455 | // name: BlowBotl_pmsg() |
| 21456 | // desc: PMSG function ... |
| 21457 | //----------------------------------------------------------------------------- |
| 21458 | CK_DLL_PMSG( BlowBotl_pmsg ) |
| 21459 | { |
| 21460 | return TRUE; |
| 21461 | } |
| 21462 | |
| 21463 | |
| 21464 | //----------------------------------------------------------------------------- |
| 21465 | // name: BlowBotl_ctrl_startBlowing() |
| 21466 | // desc: CTRL function ... |
| 21467 | //----------------------------------------------------------------------------- |
| 21468 | CK_DLL_CTRL( BlowBotl_ctrl_startBlowing ) |
| 21469 | { |
| 21470 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21471 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21472 | p->startBlowing( f ); |
| 21473 | } |
| 21474 | |
| 21475 | |
| 21476 | //----------------------------------------------------------------------------- |
| 21477 | // name: BlowBotl_ctrl_stopBlowing() |
| 21478 | // desc: CTRL function ... |
| 21479 | //----------------------------------------------------------------------------- |
| 21480 | CK_DLL_CTRL( BlowBotl_ctrl_stopBlowing ) |
| 21481 | { |
| 21482 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21483 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21484 | p->stopBlowing( f ); |
| 21485 | } |
| 21486 | |
| 21487 | |
| 21488 | //----------------------------------------------------------------------------- |
| 21489 | // name: BlowBotl_ctrl_rate() |
| 21490 | // desc: CTRL function ... |
| 21491 | //----------------------------------------------------------------------------- |
| 21492 | CK_DLL_CTRL( BlowBotl_ctrl_rate ) |
| 21493 | { |
| 21494 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21495 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21496 | p->m_rate = f; |
| 21497 | RETURN->v_float = (t_CKFLOAT)p->m_rate; |
| 21498 | } |
| 21499 | |
| 21500 | |
| 21501 | //----------------------------------------------------------------------------- |
| 21502 | // name: BlowBotl_cget_rate() |
| 21503 | // desc: CGET function ... |
| 21504 | //----------------------------------------------------------------------------- |
| 21505 | CK_DLL_CGET( BlowBotl_cget_rate ) |
| 21506 | { |
| 21507 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21508 | RETURN->v_float = (t_CKFLOAT) p->m_rate; |
| 21509 | } |
| 21510 | |
| 21511 | |
| 21512 | //----------------------------------------------------------------------------- |
| 21513 | // name: BlowBotl_ctrl_noiseGain() |
| 21514 | // desc: CTRL function ... |
| 21515 | //----------------------------------------------------------------------------- |
| 21516 | CK_DLL_CTRL( BlowBotl_ctrl_noiseGain ) |
| 21517 | { |
| 21518 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21519 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21520 | p->controlChange( 4, f * 128 ); |
| 21521 | RETURN->v_float = (t_CKFLOAT)p->m_noiseGain; |
| 21522 | } |
| 21523 | |
| 21524 | |
| 21525 | //----------------------------------------------------------------------------- |
| 21526 | // name: BlowBotl_cget_noiseGain() |
| 21527 | // desc: CGET function ... |
| 21528 | //----------------------------------------------------------------------------- |
| 21529 | CK_DLL_CGET( BlowBotl_cget_noiseGain ) |
| 21530 | { |
| 21531 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21532 | RETURN->v_float = (t_CKFLOAT)p->m_noiseGain; |
| 21533 | } |
| 21534 | |
| 21535 | |
| 21536 | //----------------------------------------------------------------------------- |
| 21537 | // name: BlowBotl_ctrl_vibratoFreq() |
| 21538 | // desc: CTRL function ... |
| 21539 | //----------------------------------------------------------------------------- |
| 21540 | CK_DLL_CTRL( BlowBotl_ctrl_vibratoFreq ) |
| 21541 | { |
| 21542 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21543 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21544 | p->setVibratoFreq( f ); |
| 21545 | RETURN->v_float = (t_CKFLOAT)p->m_vibratoFreq; |
| 21546 | } |
| 21547 | |
| 21548 | |
| 21549 | //----------------------------------------------------------------------------- |
| 21550 | // name: BlowBotl_cget_vibratoFreq() |
| 21551 | // desc: CGET function ... |
| 21552 | //----------------------------------------------------------------------------- |
| 21553 | CK_DLL_CGET( BlowBotl_cget_vibratoFreq ) |
| 21554 | { |
| 21555 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21556 | RETURN->v_float = (t_CKFLOAT)p->m_vibratoFreq; |
| 21557 | } |
| 21558 | |
| 21559 | |
| 21560 | //----------------------------------------------------------------------------- |
| 21561 | // name: BlowBotl_ctrl_vibratoGain() |
| 21562 | // desc: CTRL function ... |
| 21563 | //----------------------------------------------------------------------------- |
| 21564 | CK_DLL_CTRL( BlowBotl_ctrl_vibratoGain ) |
| 21565 | { |
| 21566 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21567 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21568 | p->controlChange( 1, f * 128 ); |
| 21569 | RETURN->v_float = (t_CKFLOAT)p->m_vibratoGain; |
| 21570 | } |
| 21571 | |
| 21572 | |
| 21573 | //----------------------------------------------------------------------------- |
| 21574 | // name: BlowBotl_cget_vibratoGain() |
| 21575 | // desc: CGET function ... |
| 21576 | //----------------------------------------------------------------------------- |
| 21577 | CK_DLL_CGET( BlowBotl_cget_vibratoGain ) |
| 21578 | { |
| 21579 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21580 | RETURN->v_float = (t_CKFLOAT)p->m_vibratoGain; |
| 21581 | } |
| 21582 | |
| 21583 | |
| 21584 | //----------------------------------------------------------------------------- |
| 21585 | // name: BlowBotl_ctrl_volume() |
| 21586 | // desc: CTRL function ... |
| 21587 | //----------------------------------------------------------------------------- |
| 21588 | CK_DLL_CTRL( BlowBotl_ctrl_volume ) |
| 21589 | { |
| 21590 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21591 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21592 | p->controlChange( 128, f * 128 ); |
| 21593 | RETURN->v_float = (t_CKFLOAT)p->m_volume; |
| 21594 | } |
| 21595 | |
| 21596 | |
| 21597 | //----------------------------------------------------------------------------- |
| 21598 | // name: BlowBotl_cget_volume() |
| 21599 | // desc: CGET function ... |
| 21600 | //----------------------------------------------------------------------------- |
| 21601 | CK_DLL_CGET( BlowBotl_cget_volume ) |
| 21602 | { |
| 21603 | BlowBotl * p = (BlowBotl *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21604 | RETURN->v_float = (t_CKFLOAT)p->m_volume; |
| 21605 | } |
| 21606 | |
| 21607 | |
| 21608 | // BlowHole |
| 21609 | //----------------------------------------------------------------------------- |
| 21610 | // name: BlowHole_ctor() |
| 21611 | // desc: CTOR function ... |
| 21612 | //----------------------------------------------------------------------------- |
| 21613 | CK_DLL_CTOR( BlowHole_ctor ) |
| 21614 | { |
| 21615 | // initialize member object |
| 21616 | BlowHole * hole = new BlowHole( 20 ); |
| 21617 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)hole; |
| 21618 | // default |
| 21619 | hole->setFrequency( 220 ); |
| 21620 | } |
| 21621 | |
| 21622 | |
| 21623 | //----------------------------------------------------------------------------- |
| 21624 | // name: BlowHole_dtor() |
| 21625 | // desc: DTOR function ... |
| 21626 | //----------------------------------------------------------------------------- |
| 21627 | CK_DLL_DTOR( BlowHole_dtor ) |
| 21628 | { |
| 21629 | delete (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21630 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 21631 | } |
| 21632 | |
| 21633 | |
| 21634 | //----------------------------------------------------------------------------- |
| 21635 | // name: BlowHole_tick() |
| 21636 | // desc: TICK function ... |
| 21637 | //----------------------------------------------------------------------------- |
| 21638 | CK_DLL_TICK( BlowHole_tick ) |
| 21639 | { |
| 21640 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21641 | *out = p->tick(); |
| 21642 | return TRUE; |
| 21643 | } |
| 21644 | |
| 21645 | |
| 21646 | //----------------------------------------------------------------------------- |
| 21647 | // name: BlowHole_pmsg() |
| 21648 | // desc: PMSG function ... |
| 21649 | //----------------------------------------------------------------------------- |
| 21650 | CK_DLL_PMSG( BlowHole_pmsg ) |
| 21651 | { |
| 21652 | return TRUE; |
| 21653 | } |
| 21654 | |
| 21655 | |
| 21656 | //----------------------------------------------------------------------------- |
| 21657 | // name: BlowHole_ctrl_startBlowing() |
| 21658 | // desc: CTRL function ... |
| 21659 | //----------------------------------------------------------------------------- |
| 21660 | CK_DLL_CTRL( BlowHole_ctrl_startBlowing ) |
| 21661 | { |
| 21662 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21663 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21664 | p->startBlowing ( f ); |
| 21665 | } |
| 21666 | |
| 21667 | |
| 21668 | //----------------------------------------------------------------------------- |
| 21669 | // name: BlowHole_ctrl_stopBlowing() |
| 21670 | // desc: CTRL function ... |
| 21671 | //----------------------------------------------------------------------------- |
| 21672 | CK_DLL_CTRL( BlowHole_ctrl_stopBlowing ) |
| 21673 | { |
| 21674 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21675 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21676 | p->stopBlowing( f ); |
| 21677 | } |
| 21678 | |
| 21679 | |
| 21680 | //----------------------------------------------------------------------------- |
| 21681 | // name: BlowHole_ctrl_rate() |
| 21682 | // desc: CTRL function ... |
| 21683 | //----------------------------------------------------------------------------- |
| 21684 | CK_DLL_CTRL( BlowHole_ctrl_rate ) |
| 21685 | { |
| 21686 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21687 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21688 | p->m_rate = f; |
| 21689 | RETURN->v_float = (t_CKFLOAT)p->m_rate; |
| 21690 | } |
| 21691 | |
| 21692 | |
| 21693 | //----------------------------------------------------------------------------- |
| 21694 | // name: BlowHole_cget_rate() |
| 21695 | // desc: CGET function ... |
| 21696 | //----------------------------------------------------------------------------- |
| 21697 | CK_DLL_CGET( BlowHole_cget_rate ) |
| 21698 | { |
| 21699 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21700 | RETURN->v_float = (t_CKFLOAT)p->m_rate; |
| 21701 | } |
| 21702 | |
| 21703 | |
| 21704 | //----------------------------------------------------------------------------- |
| 21705 | // name: BlowHole_ctrl_tonehole() |
| 21706 | // desc: CTRL function ... |
| 21707 | //----------------------------------------------------------------------------- |
| 21708 | CK_DLL_CTRL( BlowHole_ctrl_tonehole ) |
| 21709 | { |
| 21710 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21711 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21712 | p->setTonehole( f ); |
| 21713 | RETURN->v_float = (t_CKFLOAT)p->m_tonehole; |
| 21714 | } |
| 21715 | |
| 21716 | |
| 21717 | //----------------------------------------------------------------------------- |
| 21718 | // name: BlowHole_cget_tonehole() |
| 21719 | // desc: CGET function ... |
| 21720 | //----------------------------------------------------------------------------- |
| 21721 | CK_DLL_CGET( BlowHole_cget_tonehole ) |
| 21722 | { |
| 21723 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21724 | RETURN->v_float = (t_CKFLOAT)p->m_tonehole; |
| 21725 | } |
| 21726 | |
| 21727 | |
| 21728 | //----------------------------------------------------------------------------- |
| 21729 | // name: BlowHole_ctrl_vent() |
| 21730 | // desc: CTRL function ... |
| 21731 | //----------------------------------------------------------------------------- |
| 21732 | CK_DLL_CTRL( BlowHole_ctrl_vent ) |
| 21733 | { |
| 21734 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21735 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21736 | p->setVent( f ); |
| 21737 | RETURN->v_float = (t_CKFLOAT)p->m_vent; |
| 21738 | } |
| 21739 | |
| 21740 | |
| 21741 | //----------------------------------------------------------------------------- |
| 21742 | // name: BlowHole_cget_vent() |
| 21743 | // desc: CGET function ... |
| 21744 | //----------------------------------------------------------------------------- |
| 21745 | CK_DLL_CGET( BlowHole_cget_vent ) |
| 21746 | { |
| 21747 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21748 | RETURN->v_float = (t_CKFLOAT)p->m_vent; |
| 21749 | } |
| 21750 | |
| 21751 | |
| 21752 | //----------------------------------------------------------------------------- |
| 21753 | // name: BlowHole_ctrl_reed() |
| 21754 | // desc: CTRL function ... |
| 21755 | //----------------------------------------------------------------------------- |
| 21756 | CK_DLL_CTRL( BlowHole_ctrl_reed ) |
| 21757 | { |
| 21758 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21759 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21760 | p->controlChange(__SK_ReedStiffness_, f * 128.0); |
| 21761 | RETURN->v_float = (t_CKFLOAT)p->m_reed; |
| 21762 | } |
| 21763 | |
| 21764 | |
| 21765 | //----------------------------------------------------------------------------- |
| 21766 | // name: BlowHole_cget_reed() |
| 21767 | // desc: CGET function ... |
| 21768 | //----------------------------------------------------------------------------- |
| 21769 | CK_DLL_CGET( BlowHole_cget_reed ) |
| 21770 | { |
| 21771 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21772 | RETURN->v_float = (t_CKFLOAT)p->m_reed; |
| 21773 | } |
| 21774 | |
| 21775 | |
| 21776 | //----------------------------------------------------------------------------- |
| 21777 | // name: BlowHole_ctrl_noiseGain() |
| 21778 | // desc: CTRL function ... |
| 21779 | //----------------------------------------------------------------------------- |
| 21780 | CK_DLL_CTRL( BlowHole_ctrl_noiseGain ) |
| 21781 | { |
| 21782 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21783 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21784 | p->controlChange( 4, f * 128.0 ); |
| 21785 | RETURN->v_float = (t_CKFLOAT)p->m_noiseGain; |
| 21786 | } |
| 21787 | |
| 21788 | |
| 21789 | //----------------------------------------------------------------------------- |
| 21790 | // name: BlowHole_cget_noiseGain() |
| 21791 | // desc: CGET function ... |
| 21792 | //----------------------------------------------------------------------------- |
| 21793 | CK_DLL_CGET( BlowHole_cget_noiseGain ) |
| 21794 | { |
| 21795 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21796 | RETURN->v_float = (t_CKFLOAT)p->m_noiseGain; |
| 21797 | } |
| 21798 | |
| 21799 | |
| 21800 | //----------------------------------------------------------------------------- |
| 21801 | // name: BlowHole_ctrl_pressure() |
| 21802 | // desc: CTRL function ... |
| 21803 | //----------------------------------------------------------------------------- |
| 21804 | CK_DLL_CTRL( BlowHole_ctrl_pressure ) |
| 21805 | { |
| 21806 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21807 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21808 | p->controlChange( 128, f * 128.0 ); |
| 21809 | RETURN->v_float = (t_CKFLOAT)p->m_pressure; |
| 21810 | } |
| 21811 | |
| 21812 | |
| 21813 | //----------------------------------------------------------------------------- |
| 21814 | // name: BlowHole_cget_pressure() |
| 21815 | // desc: CGET function ... |
| 21816 | //----------------------------------------------------------------------------- |
| 21817 | CK_DLL_CGET( BlowHole_cget_pressure ) |
| 21818 | { |
| 21819 | BlowHole * p = (BlowHole *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21820 | RETURN->v_float = (t_CKFLOAT)p->m_pressure; |
| 21821 | } |
| 21822 | |
| 21823 | |
| 21824 | // Bowed |
| 21825 | //----------------------------------------------------------------------------- |
| 21826 | // name: Bowed_ctor() |
| 21827 | // desc: CTOR function ... |
| 21828 | //----------------------------------------------------------------------------- |
| 21829 | CK_DLL_CTOR( Bowed_ctor ) |
| 21830 | { |
| 21831 | // initialize member object |
| 21832 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT) new Bowed(40.0); |
| 21833 | } |
| 21834 | |
| 21835 | |
| 21836 | //----------------------------------------------------------------------------- |
| 21837 | // name: Bowed_dtor() |
| 21838 | // desc: DTOR function ... |
| 21839 | //----------------------------------------------------------------------------- |
| 21840 | CK_DLL_DTOR( Bowed_dtor ) |
| 21841 | { |
| 21842 | delete (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21843 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 21844 | } |
| 21845 | |
| 21846 | |
| 21847 | //----------------------------------------------------------------------------- |
| 21848 | // name: Bowed_tick() |
| 21849 | // desc: TICK function ... |
| 21850 | //----------------------------------------------------------------------------- |
| 21851 | CK_DLL_TICK( Bowed_tick ) |
| 21852 | { |
| 21853 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21854 | *out = p->tick(); |
| 21855 | return TRUE; |
| 21856 | } |
| 21857 | |
| 21858 | |
| 21859 | //----------------------------------------------------------------------------- |
| 21860 | // name: Bowed_pmsg() |
| 21861 | // desc: PMSG function ... |
| 21862 | //----------------------------------------------------------------------------- |
| 21863 | CK_DLL_PMSG( Bowed_pmsg ) |
| 21864 | { |
| 21865 | return TRUE; |
| 21866 | } |
| 21867 | |
| 21868 | |
| 21869 | //----------------------------------------------------------------------------- |
| 21870 | // name: Bowed_ctrl_startBowing() |
| 21871 | // desc: CTRL function ... |
| 21872 | //----------------------------------------------------------------------------- |
| 21873 | CK_DLL_CTRL( Bowed_ctrl_startBowing ) |
| 21874 | { |
| 21875 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21876 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21877 | p->startBowing( f ); |
| 21878 | } |
| 21879 | |
| 21880 | |
| 21881 | //----------------------------------------------------------------------------- |
| 21882 | // name: Bowed_ctrl_stopBowing() |
| 21883 | // desc: CTRL function ... |
| 21884 | //----------------------------------------------------------------------------- |
| 21885 | CK_DLL_CTRL( Bowed_ctrl_stopBowing ) |
| 21886 | { |
| 21887 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21888 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21889 | p->stopBowing( f ); |
| 21890 | } |
| 21891 | |
| 21892 | |
| 21893 | //----------------------------------------------------------------------------- |
| 21894 | // name: Bowed_ctrl_bowPressure() |
| 21895 | // desc: CTRL function ... |
| 21896 | //----------------------------------------------------------------------------- |
| 21897 | CK_DLL_CTRL( Bowed_ctrl_bowPressure ) |
| 21898 | { |
| 21899 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21900 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21901 | p->controlChange( 2, f * 128.0 ); |
| 21902 | RETURN->v_float = (t_CKFLOAT)p->m_bowPressure; |
| 21903 | } |
| 21904 | |
| 21905 | |
| 21906 | //----------------------------------------------------------------------------- |
| 21907 | // name: Bowed_cget_bowPressure() |
| 21908 | // desc: CGET function ... |
| 21909 | //----------------------------------------------------------------------------- |
| 21910 | CK_DLL_CGET( Bowed_cget_bowPressure ) |
| 21911 | { |
| 21912 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21913 | RETURN->v_float = (t_CKFLOAT)p->m_bowPressure; |
| 21914 | } |
| 21915 | |
| 21916 | |
| 21917 | //----------------------------------------------------------------------------- |
| 21918 | // name: Bowed_ctrl_bowPos() |
| 21919 | // desc: CTRL function ... |
| 21920 | //----------------------------------------------------------------------------- |
| 21921 | CK_DLL_CTRL( Bowed_ctrl_bowPos ) |
| 21922 | { |
| 21923 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21924 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21925 | p->controlChange( 4, f * 128.0 ); |
| 21926 | RETURN->v_float = (t_CKFLOAT)p->m_bowPosition; |
| 21927 | } |
| 21928 | |
| 21929 | |
| 21930 | //----------------------------------------------------------------------------- |
| 21931 | // name: Bowed_cget_bowPos() |
| 21932 | // desc: CGET function ... |
| 21933 | //----------------------------------------------------------------------------- |
| 21934 | CK_DLL_CGET( Bowed_cget_bowPos ) |
| 21935 | { |
| 21936 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21937 | RETURN->v_float = (t_CKFLOAT)p->m_bowPosition; |
| 21938 | } |
| 21939 | |
| 21940 | |
| 21941 | //----------------------------------------------------------------------------- |
| 21942 | // name: Bowed_ctrl_vibratoFreq() |
| 21943 | // desc: CTRL function ... |
| 21944 | //----------------------------------------------------------------------------- |
| 21945 | CK_DLL_CTRL( Bowed_ctrl_vibratoFreq ) |
| 21946 | { |
| 21947 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21948 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21949 | p->setVibratoFreq( f ); |
| 21950 | RETURN->v_float = (t_CKFLOAT)p->m_vibratoFreq; |
| 21951 | } |
| 21952 | |
| 21953 | |
| 21954 | //----------------------------------------------------------------------------- |
| 21955 | // name: Bowed_cget_vibratoFreq() |
| 21956 | // desc: CGET function ... |
| 21957 | //----------------------------------------------------------------------------- |
| 21958 | CK_DLL_CGET( Bowed_cget_vibratoFreq ) |
| 21959 | { |
| 21960 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21961 | RETURN->v_float = (t_CKFLOAT)p->m_vibratoFreq; |
| 21962 | } |
| 21963 | |
| 21964 | |
| 21965 | //----------------------------------------------------------------------------- |
| 21966 | // name: Bowed_ctrl_vibratoGain() |
| 21967 | // desc: CTRL function ... |
| 21968 | //----------------------------------------------------------------------------- |
| 21969 | CK_DLL_CTRL( Bowed_ctrl_vibratoGain ) |
| 21970 | { |
| 21971 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21972 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21973 | p->controlChange( 1, f * 128.0 ); |
| 21974 | RETURN->v_float = (t_CKFLOAT)p->m_vibratoGain; |
| 21975 | } |
| 21976 | |
| 21977 | |
| 21978 | //----------------------------------------------------------------------------- |
| 21979 | // name: Bowed_cget_vibratoGain() |
| 21980 | // desc: CGET function ... |
| 21981 | //----------------------------------------------------------------------------- |
| 21982 | CK_DLL_CGET( Bowed_cget_vibratoGain ) |
| 21983 | { |
| 21984 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21985 | RETURN->v_float = (t_CKFLOAT)p->m_vibratoGain; |
| 21986 | } |
| 21987 | |
| 21988 | |
| 21989 | //----------------------------------------------------------------------------- |
| 21990 | // name: Bowed_ctrl_volume() |
| 21991 | // desc: CTRL function ... |
| 21992 | //----------------------------------------------------------------------------- |
| 21993 | CK_DLL_CTRL( Bowed_ctrl_volume ) |
| 21994 | { |
| 21995 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 21996 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 21997 | p->controlChange( 128, f * 128.0 ); |
| 21998 | RETURN->v_float = (t_CKFLOAT)p->m_volume; |
| 21999 | } |
| 22000 | |
| 22001 | |
| 22002 | //----------------------------------------------------------------------------- |
| 22003 | // name: Bowed_cget_volume() |
| 22004 | // desc: CGET function ... |
| 22005 | //----------------------------------------------------------------------------- |
| 22006 | CK_DLL_CGET( Bowed_cget_volume ) |
| 22007 | { |
| 22008 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22009 | RETURN->v_float = (t_CKFLOAT)p->m_volume; |
| 22010 | } |
| 22011 | |
| 22012 | |
| 22013 | //----------------------------------------------------------------------------- |
| 22014 | // name: Bowed_ctrl_rate() |
| 22015 | // desc: CTRL function ... |
| 22016 | //----------------------------------------------------------------------------- |
| 22017 | CK_DLL_CTRL( Bowed_ctrl_rate ) |
| 22018 | { |
| 22019 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22020 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22021 | p->m_rate = f; |
| 22022 | RETURN->v_float = (t_CKFLOAT) p->m_rate; |
| 22023 | } |
| 22024 | |
| 22025 | |
| 22026 | //----------------------------------------------------------------------------- |
| 22027 | // name: Bowed_cget_rate() |
| 22028 | // desc: CGET function ... |
| 22029 | //----------------------------------------------------------------------------- |
| 22030 | CK_DLL_CGET( Bowed_cget_rate ) |
| 22031 | { |
| 22032 | Bowed * p = (Bowed *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22033 | RETURN->v_float = (t_CKFLOAT) p->m_rate; |
| 22034 | } |
| 22035 | |
| 22036 | |
| 22037 | // Chorus |
| 22038 | //----------------------------------------------------------------------------- |
| 22039 | // name: Chorus_ctor() |
| 22040 | // desc: CTOR function ... |
| 22041 | //----------------------------------------------------------------------------- |
| 22042 | CK_DLL_CTOR( Chorus_ctor ) |
| 22043 | { |
| 22044 | // initialize member object |
| 22045 | OBJ_MEMBER_UINT(SELF, Chorus_offset_data) = (t_CKUINT) new Chorus( 3000 ); |
| 22046 | } |
| 22047 | |
| 22048 | |
| 22049 | //----------------------------------------------------------------------------- |
| 22050 | // name: Chorus_ctor_freq() |
| 22051 | // desc: CTOR function ... |
| 22052 | //----------------------------------------------------------------------------- |
| 22053 | CK_DLL_CTOR( Chorus_ctor_freq ) |
| 22054 | { |
| 22055 | Chorus * c = (Chorus*)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22056 | c->setModFrequency( GET_NEXT_FLOAT(ARGS) ); |
| 22057 | } |
| 22058 | |
| 22059 | |
| 22060 | //----------------------------------------------------------------------------- |
| 22061 | // name: Chorus_ctor_freq_depth() |
| 22062 | // desc: CTOR function ... |
| 22063 | //----------------------------------------------------------------------------- |
| 22064 | CK_DLL_CTOR( Chorus_ctor_freq_depth ) |
| 22065 | { |
| 22066 | Chorus * c = (Chorus*)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22067 | c->setModFrequency( GET_NEXT_FLOAT(ARGS) ); |
| 22068 | c->setModDepth( GET_NEXT_FLOAT(ARGS) ); |
| 22069 | } |
| 22070 | |
| 22071 | |
| 22072 | //----------------------------------------------------------------------------- |
| 22073 | // name: Chorus_ctor_freq_depth_mix() |
| 22074 | // desc: CTOR function ... |
| 22075 | //----------------------------------------------------------------------------- |
| 22076 | CK_DLL_CTOR( Chorus_ctor_freq_depth_mix ) |
| 22077 | { |
| 22078 | Chorus * c = (Chorus*)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22079 | c->setModFrequency( GET_NEXT_FLOAT(ARGS) ); |
| 22080 | c->setModDepth( GET_NEXT_FLOAT(ARGS) ); |
| 22081 | c->setEffectMix( GET_NEXT_FLOAT(ARGS) ); |
| 22082 | } |
| 22083 | |
| 22084 | |
| 22085 | //----------------------------------------------------------------------------- |
| 22086 | // name: Chorus_dtor() |
| 22087 | // desc: DTOR function ... |
| 22088 | //----------------------------------------------------------------------------- |
| 22089 | CK_DLL_DTOR( Chorus_dtor ) |
| 22090 | { |
| 22091 | delete (Chorus *)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22092 | OBJ_MEMBER_UINT(SELF, Chorus_offset_data) = 0; |
| 22093 | } |
| 22094 | |
| 22095 | |
| 22096 | //----------------------------------------------------------------------------- |
| 22097 | // name: Chorus_tick() |
| 22098 | // desc: TICK function ... |
| 22099 | //----------------------------------------------------------------------------- |
| 22100 | CK_DLL_TICK( Chorus_tick ) |
| 22101 | { |
| 22102 | Chorus * p = (Chorus *)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22103 | *out = p->tick(in); |
| 22104 | return TRUE; |
| 22105 | } |
| 22106 | |
| 22107 | |
| 22108 | //----------------------------------------------------------------------------- |
| 22109 | // name: Chorus_pmsg() |
| 22110 | // desc: PMSG function ... |
| 22111 | //----------------------------------------------------------------------------- |
| 22112 | CK_DLL_PMSG( Chorus_pmsg ) |
| 22113 | { |
| 22114 | return TRUE; |
| 22115 | } |
| 22116 | |
| 22117 | |
| 22118 | //----------------------------------------------------------------------------- |
| 22119 | // name: Chorus_ctrl_mix() |
| 22120 | // desc: CTRL function ... |
| 22121 | //----------------------------------------------------------------------------- |
| 22122 | CK_DLL_CTRL( Chorus_ctrl_mix ) |
| 22123 | { |
| 22124 | Chorus * p = (Chorus *)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22125 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22126 | p->setEffectMix( f ); |
| 22127 | RETURN->v_float = (t_CKFLOAT) p->effectMix; |
| 22128 | } |
| 22129 | |
| 22130 | |
| 22131 | //----------------------------------------------------------------------------- |
| 22132 | // name: Chorus_ctrl_modDepth() |
| 22133 | // desc: CTRL function ... |
| 22134 | //----------------------------------------------------------------------------- |
| 22135 | CK_DLL_CTRL( Chorus_ctrl_modDepth ) |
| 22136 | { |
| 22137 | Chorus * p = (Chorus *)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22138 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22139 | p->setModDepth( f ); |
| 22140 | RETURN->v_float = (t_CKFLOAT) p->modDepth; |
| 22141 | } |
| 22142 | |
| 22143 | |
| 22144 | //----------------------------------------------------------------------------- |
| 22145 | // name: Chorus_ctrl_modFreq() |
| 22146 | // desc: CTRL function ... |
| 22147 | //----------------------------------------------------------------------------- |
| 22148 | CK_DLL_CTRL( Chorus_ctrl_modFreq ) |
| 22149 | { |
| 22150 | Chorus * p = (Chorus *)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22151 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22152 | p->setModFrequency( f ); |
| 22153 | RETURN->v_float = (t_CKFLOAT) p->mods[0]->m_freq; |
| 22154 | } |
| 22155 | |
| 22156 | |
| 22157 | //----------------------------------------------------------------------------- |
| 22158 | // name: Chorus_ctrl_baseDelay() |
| 22159 | // desc: CTRL function ... |
| 22160 | //----------------------------------------------------------------------------- |
| 22161 | CK_DLL_CTRL( Chorus_ctrl_baseDelay ) |
| 22162 | { |
| 22163 | Chorus * p = (Chorus *)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22164 | t_CKDUR f = GET_NEXT_DUR(ARGS); |
| 22165 | p->setDelay( f ); |
| 22166 | RETURN->v_float = (t_CKFLOAT) p->baseLength; |
| 22167 | } |
| 22168 | |
| 22169 | |
| 22170 | //----------------------------------------------------------------------------- |
| 22171 | // name: Chorus_cget_mix() |
| 22172 | // desc: CGET function ... |
| 22173 | //----------------------------------------------------------------------------- |
| 22174 | CK_DLL_CGET( Chorus_cget_mix ) |
| 22175 | { |
| 22176 | Chorus * p = (Chorus *)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22177 | RETURN->v_float = (t_CKFLOAT) p->effectMix; |
| 22178 | } |
| 22179 | |
| 22180 | |
| 22181 | //----------------------------------------------------------------------------- |
| 22182 | // name: Chorus_cget_baseDelay() |
| 22183 | // desc: CGET function ... |
| 22184 | //----------------------------------------------------------------------------- |
| 22185 | CK_DLL_CGET( Chorus_cget_baseDelay ) |
| 22186 | { |
| 22187 | Chorus * p = (Chorus *)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22188 | RETURN->v_dur = (t_CKFLOAT)p->baseLength; |
| 22189 | } |
| 22190 | |
| 22191 | |
| 22192 | //----------------------------------------------------------------------------- |
| 22193 | // name: Chorus_cget_modDepth() |
| 22194 | // desc: CGET function ... |
| 22195 | //----------------------------------------------------------------------------- |
| 22196 | CK_DLL_CGET( Chorus_cget_modDepth ) |
| 22197 | { |
| 22198 | Chorus * p = (Chorus *)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22199 | RETURN->v_float = (t_CKFLOAT) p->modDepth; |
| 22200 | } |
| 22201 | |
| 22202 | |
| 22203 | //----------------------------------------------------------------------------- |
| 22204 | // name: Chorus_cget_modFreq() |
| 22205 | // desc: CGET function ... |
| 22206 | //----------------------------------------------------------------------------- |
| 22207 | CK_DLL_CGET( Chorus_cget_modFreq ) |
| 22208 | { |
| 22209 | Chorus * p = (Chorus *)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22210 | RETURN->v_float = (t_CKFLOAT) p->mods[0]->m_freq; |
| 22211 | } |
| 22212 | |
| 22213 | |
| 22214 | //----------------------------------------------------------------------------- |
| 22215 | // name: Chorus_ctrl_set() |
| 22216 | // desc: set ... |
| 22217 | //----------------------------------------------------------------------------- |
| 22218 | CK_DLL_CTRL( Chorus_ctrl_set ) |
| 22219 | { |
| 22220 | Chorus * p = (Chorus *)OBJ_MEMBER_UINT(SELF, Chorus_offset_data); |
| 22221 | t_CKDUR d = GET_NEXT_DUR(ARGS); |
| 22222 | t_CKFLOAT dd = GET_NEXT_FLOAT(ARGS); |
| 22223 | p->set( d, dd ); |
| 22224 | } |
| 22225 | |
| 22226 | |
| 22227 | // Brass |
| 22228 | /* |
| 22229 | struct Brass_ |
| 22230 | { |
| 22231 | Brass * imp; |
| 22232 | |
| 22233 | t_CKFLOAT m_frequency; |
| 22234 | t_CKFLOAT m_rate; |
| 22235 | t_CKFLOAT m_lip; |
| 22236 | |
| 22237 | Brass_( t_CKFLOAT d ) |
| 22238 | { |
| 22239 | imp = new Brass(d); |
| 22240 | m_frequency = 100.0; |
| 22241 | m_rate = 0.5; |
| 22242 | m_lip = 0.1; |
| 22243 | } |
| 22244 | |
| 22245 | ~Brass_() |
| 22246 | { |
| 22247 | CK_SAFE_DELETE( imp ); |
| 22248 | } |
| 22249 | }; */ |
| 22250 | |
| 22251 | |
| 22252 | //----------------------------------------------------------------------------- |
| 22253 | // name: Brass_ctor() |
| 22254 | // desc: CTOR function ... |
| 22255 | //----------------------------------------------------------------------------- |
| 22256 | CK_DLL_CTOR( Brass_ctor ) |
| 22257 | { |
| 22258 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new Brass( 20.0 ); |
| 22259 | } |
| 22260 | |
| 22261 | |
| 22262 | //----------------------------------------------------------------------------- |
| 22263 | // name: Brass_dtor() |
| 22264 | // desc: DTOR function ... |
| 22265 | //----------------------------------------------------------------------------- |
| 22266 | CK_DLL_DTOR( Brass_dtor ) |
| 22267 | { |
| 22268 | delete (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22269 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 22270 | } |
| 22271 | |
| 22272 | |
| 22273 | //----------------------------------------------------------------------------- |
| 22274 | // name: Brass_tick() |
| 22275 | // desc: TICK function ... |
| 22276 | //----------------------------------------------------------------------------- |
| 22277 | CK_DLL_TICK( Brass_tick ) |
| 22278 | { |
| 22279 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22280 | *out = b->tick(); |
| 22281 | return TRUE; |
| 22282 | } |
| 22283 | |
| 22284 | |
| 22285 | //----------------------------------------------------------------------------- |
| 22286 | // name: Brass_pmsg() |
| 22287 | // desc: PMSG function ... |
| 22288 | //----------------------------------------------------------------------------- |
| 22289 | CK_DLL_PMSG( Brass_pmsg ) |
| 22290 | { |
| 22291 | return TRUE; |
| 22292 | } |
| 22293 | |
| 22294 | |
| 22295 | //----------------------------------------------------------------------------- |
| 22296 | // name: Brass_ctrl_startBlowing() |
| 22297 | // desc: CTRL function ... |
| 22298 | //----------------------------------------------------------------------------- |
| 22299 | CK_DLL_CTRL( Brass_ctrl_startBlowing ) |
| 22300 | { |
| 22301 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22302 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22303 | b->startBlowing( f, b->m_rate ); |
| 22304 | } |
| 22305 | |
| 22306 | |
| 22307 | //----------------------------------------------------------------------------- |
| 22308 | // name: Brass_ctrl_stopBlowing() |
| 22309 | // desc: CTRL function ... |
| 22310 | //----------------------------------------------------------------------------- |
| 22311 | CK_DLL_CTRL( Brass_ctrl_stopBlowing ) |
| 22312 | { |
| 22313 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22314 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22315 | b->stopBlowing( f ); |
| 22316 | } |
| 22317 | |
| 22318 | |
| 22319 | //----------------------------------------------------------------------------- |
| 22320 | // name: Brass_ctrl_clear() |
| 22321 | // desc: CTRL function ... |
| 22322 | //----------------------------------------------------------------------------- |
| 22323 | CK_DLL_CTRL( Brass_ctrl_clear ) |
| 22324 | { |
| 22325 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22326 | b->clear(); |
| 22327 | } |
| 22328 | |
| 22329 | |
| 22330 | //----------------------------------------------------------------------------- |
| 22331 | // name: Brass_ctrl_rate() |
| 22332 | // desc: CTRL function ... |
| 22333 | //----------------------------------------------------------------------------- |
| 22334 | CK_DLL_CTRL( Brass_ctrl_rate ) |
| 22335 | { |
| 22336 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22337 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22338 | b->m_rate = f; |
| 22339 | RETURN->v_float = (t_CKFLOAT)b->m_rate; |
| 22340 | } |
| 22341 | |
| 22342 | |
| 22343 | //----------------------------------------------------------------------------- |
| 22344 | // name: Brass_cget_rate() |
| 22345 | // desc: CGET function ... |
| 22346 | //----------------------------------------------------------------------------- |
| 22347 | CK_DLL_CGET( Brass_cget_rate ) |
| 22348 | { |
| 22349 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22350 | RETURN->v_float = (t_CKFLOAT)b->m_rate; |
| 22351 | } |
| 22352 | |
| 22353 | |
| 22354 | //----------------------------------------------------------------------------- |
| 22355 | // name: Brass_ctrl_lip() |
| 22356 | // desc: CTRL function ... |
| 22357 | //----------------------------------------------------------------------------- |
| 22358 | CK_DLL_CTRL( Brass_ctrl_lip ) |
| 22359 | { |
| 22360 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22361 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22362 | b->controlChange( 2, f * 128.0 ); |
| 22363 | RETURN->v_float = (t_CKFLOAT)b->m_lip; |
| 22364 | } |
| 22365 | |
| 22366 | |
| 22367 | //----------------------------------------------------------------------------- |
| 22368 | // name: Brass_cget_lip() |
| 22369 | // desc: CGET function ... |
| 22370 | //----------------------------------------------------------------------------- |
| 22371 | CK_DLL_CGET( Brass_cget_lip ) |
| 22372 | { |
| 22373 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22374 | RETURN->v_float = (t_CKFLOAT)b->m_lip; |
| 22375 | } |
| 22376 | |
| 22377 | |
| 22378 | //----------------------------------------------------------------------------- |
| 22379 | // name: Brass_ctrl_slide() |
| 22380 | // desc: CTRL function ... |
| 22381 | //----------------------------------------------------------------------------- |
| 22382 | CK_DLL_CTRL( Brass_ctrl_slide ) |
| 22383 | { |
| 22384 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22385 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22386 | b->controlChange( 4, f * 128.0 ); |
| 22387 | RETURN->v_float = (t_CKFLOAT)b->m_slide; |
| 22388 | } |
| 22389 | |
| 22390 | |
| 22391 | //----------------------------------------------------------------------------- |
| 22392 | // name: Brass_cget_slide() |
| 22393 | // desc: CGET function ... |
| 22394 | //----------------------------------------------------------------------------- |
| 22395 | CK_DLL_CGET( Brass_cget_slide ) |
| 22396 | { |
| 22397 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22398 | RETURN->v_float = (t_CKFLOAT)b->m_slide; |
| 22399 | } |
| 22400 | |
| 22401 | |
| 22402 | //----------------------------------------------------------------------------- |
| 22403 | // name: Brass_ctrl_vibratoFreq() |
| 22404 | // desc: CTRL function ... |
| 22405 | //----------------------------------------------------------------------------- |
| 22406 | CK_DLL_CTRL( Brass_ctrl_vibratoFreq ) |
| 22407 | { |
| 22408 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22409 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22410 | b->setVibratoFreq( f ); |
| 22411 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq; |
| 22412 | } |
| 22413 | |
| 22414 | |
| 22415 | //----------------------------------------------------------------------------- |
| 22416 | // name: Brass_cget_vibratoFreq() |
| 22417 | // desc: CGET function ... |
| 22418 | //----------------------------------------------------------------------------- |
| 22419 | CK_DLL_CGET( Brass_cget_vibratoFreq ) |
| 22420 | { |
| 22421 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22422 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq; |
| 22423 | } |
| 22424 | |
| 22425 | |
| 22426 | //----------------------------------------------------------------------------- |
| 22427 | // name: Brass_ctrl_vibratoGain() |
| 22428 | // desc: CTRL function ... |
| 22429 | //----------------------------------------------------------------------------- |
| 22430 | CK_DLL_CTRL( Brass_ctrl_vibratoGain ) |
| 22431 | { |
| 22432 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22433 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22434 | b->controlChange( 1, f * 128.0 ); |
| 22435 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain; |
| 22436 | } |
| 22437 | |
| 22438 | |
| 22439 | //----------------------------------------------------------------------------- |
| 22440 | // name: Brass_cget_vibratoGain() |
| 22441 | // desc: CGET function ... |
| 22442 | //----------------------------------------------------------------------------- |
| 22443 | CK_DLL_CGET( Brass_cget_vibratoGain) |
| 22444 | { |
| 22445 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22446 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain; |
| 22447 | } |
| 22448 | |
| 22449 | |
| 22450 | //----------------------------------------------------------------------------- |
| 22451 | // name: Brass_ctrl_volume() |
| 22452 | // desc: CTRL function ... |
| 22453 | //----------------------------------------------------------------------------- |
| 22454 | CK_DLL_CTRL( Brass_ctrl_volume ) |
| 22455 | { |
| 22456 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22457 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22458 | b->controlChange( 128, f * 128.0 ); |
| 22459 | RETURN->v_float = (t_CKFLOAT)b->m_volume; |
| 22460 | } |
| 22461 | |
| 22462 | |
| 22463 | //----------------------------------------------------------------------------- |
| 22464 | // name: Brass_cget_volume() |
| 22465 | // desc: CGET function ... |
| 22466 | //----------------------------------------------------------------------------- |
| 22467 | CK_DLL_CGET( Brass_cget_volume ) |
| 22468 | { |
| 22469 | Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22470 | RETURN->v_float = (t_CKFLOAT)b->m_volume; |
| 22471 | } |
| 22472 | |
| 22473 | |
| 22474 | |
| 22475 | |
| 22476 | /* |
| 22477 | struct Clarinet_ { |
| 22478 | Clarinet * imp; |
| 22479 | double m_frequency; |
| 22480 | double m_rate; |
| 22481 | double m_reed; |
| 22482 | Clarinet_ ( double d ) { |
| 22483 | imp = new Clarinet(d); |
| 22484 | m_frequency = 100.0; |
| 22485 | m_rate = 0.5; |
| 22486 | m_reed = 0.5; |
| 22487 | } |
| 22488 | }; */ |
| 22489 | |
| 22490 | |
| 22491 | // Clarinet |
| 22492 | //----------------------------------------------------------------------------- |
| 22493 | // name: Clarinet_ctor() |
| 22494 | // desc: CTOR function ... |
| 22495 | //----------------------------------------------------------------------------- |
| 22496 | CK_DLL_CTOR( Clarinet_ctor ) |
| 22497 | { |
| 22498 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new Clarinet( 30.0 ); |
| 22499 | } |
| 22500 | |
| 22501 | |
| 22502 | //----------------------------------------------------------------------------- |
| 22503 | // name: Clarinet_dtor() |
| 22504 | // desc: DTOR function ... |
| 22505 | //----------------------------------------------------------------------------- |
| 22506 | CK_DLL_DTOR( Clarinet_dtor ) |
| 22507 | { |
| 22508 | delete (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22509 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 22510 | } |
| 22511 | |
| 22512 | //----------------------------------------------------------------------------- |
| 22513 | // name: Clarinet_tick() |
| 22514 | // desc: TICK function ... |
| 22515 | //----------------------------------------------------------------------------- |
| 22516 | CK_DLL_TICK( Clarinet_tick ) |
| 22517 | { |
| 22518 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22519 | *out = b->tick(); |
| 22520 | return TRUE; |
| 22521 | } |
| 22522 | |
| 22523 | |
| 22524 | //----------------------------------------------------------------------------- |
| 22525 | // name: Clarinet_pmsg() |
| 22526 | // desc: PMSG function ... |
| 22527 | //----------------------------------------------------------------------------- |
| 22528 | CK_DLL_PMSG( Clarinet_pmsg ) |
| 22529 | { |
| 22530 | return TRUE; |
| 22531 | } |
| 22532 | |
| 22533 | |
| 22534 | //----------------------------------------------------------------------------- |
| 22535 | // name: Clarinet_ctrl_startBlowing() |
| 22536 | // desc: CTRL function ... |
| 22537 | //----------------------------------------------------------------------------- |
| 22538 | CK_DLL_CTRL( Clarinet_ctrl_startBlowing ) |
| 22539 | { |
| 22540 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22541 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22542 | b->startBlowing( f, b->m_rate ); |
| 22543 | } |
| 22544 | |
| 22545 | |
| 22546 | //----------------------------------------------------------------------------- |
| 22547 | // name: Clarinet_ctrl_stopBlowing() |
| 22548 | // desc: CTRL function ... |
| 22549 | //----------------------------------------------------------------------------- |
| 22550 | CK_DLL_CTRL( Clarinet_ctrl_stopBlowing ) |
| 22551 | { |
| 22552 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22553 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22554 | b->stopBlowing( f ); |
| 22555 | } |
| 22556 | |
| 22557 | |
| 22558 | //----------------------------------------------------------------------------- |
| 22559 | // name: Clarinet_ctrl_clear() |
| 22560 | // desc: CTRL function ... |
| 22561 | //----------------------------------------------------------------------------- |
| 22562 | CK_DLL_CTRL( Clarinet_ctrl_clear ) |
| 22563 | { |
| 22564 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22565 | b->clear(); |
| 22566 | } |
| 22567 | |
| 22568 | |
| 22569 | //----------------------------------------------------------------------------- |
| 22570 | // name: Clarinet_ctrl_reed() |
| 22571 | // desc: CTRL function ... |
| 22572 | //----------------------------------------------------------------------------- |
| 22573 | CK_DLL_CTRL( Clarinet_ctrl_reed ) |
| 22574 | { |
| 22575 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22576 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22577 | b->controlChange( 2, f * 128.0 ); |
| 22578 | RETURN->v_float = (t_CKFLOAT)b->m_reed; |
| 22579 | } |
| 22580 | |
| 22581 | |
| 22582 | //----------------------------------------------------------------------------- |
| 22583 | // name: Clarinet_cget_reed() |
| 22584 | // desc: CGET function ... |
| 22585 | //----------------------------------------------------------------------------- |
| 22586 | CK_DLL_CGET( Clarinet_cget_reed ) |
| 22587 | { |
| 22588 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22589 | RETURN->v_float = (t_CKFLOAT)b->m_reed; |
| 22590 | } |
| 22591 | |
| 22592 | |
| 22593 | //----------------------------------------------------------------------------- |
| 22594 | // name: Clarinet_ctrl_rate() |
| 22595 | // desc: CTRL function ... |
| 22596 | //----------------------------------------------------------------------------- |
| 22597 | CK_DLL_CTRL( Clarinet_ctrl_rate ) |
| 22598 | { |
| 22599 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22600 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22601 | b->m_rate = f; |
| 22602 | RETURN->v_float = (t_CKFLOAT)b->m_rate; |
| 22603 | } |
| 22604 | |
| 22605 | |
| 22606 | //----------------------------------------------------------------------------- |
| 22607 | // name: Clarinet_cget_rate() |
| 22608 | // desc: CGET function ... |
| 22609 | //----------------------------------------------------------------------------- |
| 22610 | CK_DLL_CGET( Clarinet_cget_rate ) |
| 22611 | { |
| 22612 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22613 | RETURN->v_float = (t_CKFLOAT) b->m_rate; |
| 22614 | } |
| 22615 | |
| 22616 | |
| 22617 | //----------------------------------------------------------------------------- |
| 22618 | // name: Clarinet_ctrl_noiseGain() |
| 22619 | // desc: CTRL function ... |
| 22620 | //----------------------------------------------------------------------------- |
| 22621 | CK_DLL_CTRL( Clarinet_ctrl_noiseGain ) |
| 22622 | { |
| 22623 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22624 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22625 | b->controlChange( 4, f * 128.0 ); |
| 22626 | RETURN->v_float = (t_CKFLOAT)b->m_noiseGain; |
| 22627 | } |
| 22628 | |
| 22629 | |
| 22630 | //----------------------------------------------------------------------------- |
| 22631 | // name: Clarinet_cget_noiseGain() |
| 22632 | // desc: CGET function ... |
| 22633 | //----------------------------------------------------------------------------- |
| 22634 | CK_DLL_CGET( Clarinet_cget_noiseGain ) |
| 22635 | { |
| 22636 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22637 | RETURN->v_float = (t_CKFLOAT)b->m_noiseGain; |
| 22638 | } |
| 22639 | |
| 22640 | |
| 22641 | //----------------------------------------------------------------------------- |
| 22642 | // name: Clarinet_ctrl_vibratoFreq() |
| 22643 | // desc: CTRL function ... |
| 22644 | //----------------------------------------------------------------------------- |
| 22645 | CK_DLL_CTRL( Clarinet_ctrl_vibratoFreq ) |
| 22646 | { |
| 22647 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22648 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22649 | b->setVibratoFreq( f ); |
| 22650 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq; |
| 22651 | } |
| 22652 | |
| 22653 | |
| 22654 | //----------------------------------------------------------------------------- |
| 22655 | // name: Clarinet_cget_vibratoFreq() |
| 22656 | // desc: CGET function ... |
| 22657 | //----------------------------------------------------------------------------- |
| 22658 | CK_DLL_CGET( Clarinet_cget_vibratoFreq ) |
| 22659 | { |
| 22660 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22661 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq; |
| 22662 | } |
| 22663 | |
| 22664 | |
| 22665 | //----------------------------------------------------------------------------- |
| 22666 | // name: Clarinet_ctrl_vibratoGain() |
| 22667 | // desc: CTRL function ... |
| 22668 | //----------------------------------------------------------------------------- |
| 22669 | CK_DLL_CTRL( Clarinet_ctrl_vibratoGain ) |
| 22670 | { |
| 22671 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22672 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22673 | b->controlChange( 1, f * 128.0 ); |
| 22674 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain; |
| 22675 | } |
| 22676 | |
| 22677 | |
| 22678 | //----------------------------------------------------------------------------- |
| 22679 | // name: Clarinet_cget_vibratoGain() |
| 22680 | // desc: CGET function ... |
| 22681 | //----------------------------------------------------------------------------- |
| 22682 | CK_DLL_CGET( Clarinet_cget_vibratoGain ) |
| 22683 | { |
| 22684 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22685 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain; |
| 22686 | } |
| 22687 | |
| 22688 | |
| 22689 | //----------------------------------------------------------------------------- |
| 22690 | // name: Clarinet_ctrl_pressure() |
| 22691 | // desc: CTRL function ... |
| 22692 | //----------------------------------------------------------------------------- |
| 22693 | CK_DLL_CTRL( Clarinet_ctrl_pressure ) |
| 22694 | { |
| 22695 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22696 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22697 | b->controlChange( 128, f * 128.0 ); |
| 22698 | RETURN->v_float = (t_CKFLOAT)b->m_volume; |
| 22699 | } |
| 22700 | |
| 22701 | |
| 22702 | //----------------------------------------------------------------------------- |
| 22703 | // name: Clarinet_cget_pressure() |
| 22704 | // desc: CGET function ... |
| 22705 | //----------------------------------------------------------------------------- |
| 22706 | CK_DLL_CGET( Clarinet_cget_pressure ) |
| 22707 | { |
| 22708 | Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22709 | RETURN->v_float = (t_CKFLOAT)b->m_volume; |
| 22710 | } |
| 22711 | |
| 22712 | |
| 22713 | // Flute |
| 22714 | struct Flute_ { |
| 22715 | Flute * imp; |
| 22716 | |
| 22717 | double m_frequency; |
| 22718 | double m_rate; |
| 22719 | double m_jetDelay; |
| 22720 | double m_jetReflection; |
| 22721 | double m_endReflection; |
| 22722 | |
| 22723 | Flute_ ( double d ) { |
| 22724 | imp = new Flute(d); |
| 22725 | m_frequency = 100.0; |
| 22726 | m_rate = 0.5; |
| 22727 | m_jetDelay = 0.0; |
| 22728 | m_jetReflection = 0.0; |
| 22729 | m_endReflection = 0.0; |
| 22730 | } |
| 22731 | }; |
| 22732 | |
| 22733 | |
| 22734 | //----------------------------------------------------------------------------- |
| 22735 | // name: Flute_ctor() |
| 22736 | // desc: CTOR function ... |
| 22737 | //----------------------------------------------------------------------------- |
| 22738 | CK_DLL_CTOR( Flute_ctor ) |
| 22739 | { |
| 22740 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT) new Flute( 40.0 ); |
| 22741 | } |
| 22742 | |
| 22743 | |
| 22744 | //----------------------------------------------------------------------------- |
| 22745 | // name: Flute_dtor() |
| 22746 | // desc: DTOR function ... |
| 22747 | //----------------------------------------------------------------------------- |
| 22748 | CK_DLL_DTOR( Flute_dtor ) |
| 22749 | { |
| 22750 | Flute * f = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22751 | CK_SAFE_DELETE(f); |
| 22752 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 22753 | } |
| 22754 | |
| 22755 | |
| 22756 | //----------------------------------------------------------------------------- |
| 22757 | // name: Flute_tick() |
| 22758 | // desc: TICK function ... |
| 22759 | //----------------------------------------------------------------------------- |
| 22760 | CK_DLL_TICK( Flute_tick ) |
| 22761 | { |
| 22762 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22763 | *out = b->tick(); |
| 22764 | return TRUE; |
| 22765 | } |
| 22766 | |
| 22767 | //----------------------------------------------------------------------------- |
| 22768 | // name: Flute_pmsg() |
| 22769 | // desc: PMSG function ... |
| 22770 | //----------------------------------------------------------------------------- |
| 22771 | CK_DLL_PMSG( Flute_pmsg ) |
| 22772 | { |
| 22773 | return TRUE; |
| 22774 | } |
| 22775 | |
| 22776 | |
| 22777 | //----------------------------------------------------------------------------- |
| 22778 | // name: Flute_ctrl_startBlowing() |
| 22779 | // desc: CTRL function ... |
| 22780 | //----------------------------------------------------------------------------- |
| 22781 | CK_DLL_CTRL( Flute_ctrl_startBlowing ) |
| 22782 | { |
| 22783 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22784 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22785 | b->startBlowing( f, b->m_rate ); |
| 22786 | } |
| 22787 | |
| 22788 | //----------------------------------------------------------------------------- |
| 22789 | // name: Flute_ctrl_stopBlowing() |
| 22790 | // desc: CTRL function ... |
| 22791 | //----------------------------------------------------------------------------- |
| 22792 | CK_DLL_CTRL( Flute_ctrl_stopBlowing ) |
| 22793 | { |
| 22794 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22795 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22796 | b->stopBlowing( f ); |
| 22797 | } |
| 22798 | |
| 22799 | |
| 22800 | //----------------------------------------------------------------------------- |
| 22801 | // name: Flute_ctrl_clear() |
| 22802 | // desc: CTRL function ... |
| 22803 | //----------------------------------------------------------------------------- |
| 22804 | CK_DLL_CTRL( Flute_ctrl_clear ) |
| 22805 | { |
| 22806 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22807 | b->clear(); |
| 22808 | } |
| 22809 | |
| 22810 | |
| 22811 | //----------------------------------------------------------------------------- |
| 22812 | // name: Flute_ctrl_rate() |
| 22813 | // desc: CTRL function ... |
| 22814 | //----------------------------------------------------------------------------- |
| 22815 | CK_DLL_CTRL( Flute_ctrl_rate ) |
| 22816 | { |
| 22817 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22818 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22819 | b->m_rate = f; |
| 22820 | RETURN->v_float = (t_CKFLOAT)b->m_rate; |
| 22821 | } |
| 22822 | |
| 22823 | |
| 22824 | //----------------------------------------------------------------------------- |
| 22825 | // name: Flute_cget_rate() |
| 22826 | // desc: CGET function ... |
| 22827 | //----------------------------------------------------------------------------- |
| 22828 | CK_DLL_CGET( Flute_cget_rate ) |
| 22829 | { |
| 22830 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22831 | RETURN->v_float = (t_CKFLOAT)b->m_rate; |
| 22832 | } |
| 22833 | |
| 22834 | |
| 22835 | //----------------------------------------------------------------------------- |
| 22836 | // name: Flute_ctrl_jetDelay() |
| 22837 | // desc: CTRL function ... |
| 22838 | //----------------------------------------------------------------------------- |
| 22839 | CK_DLL_CTRL( Flute_ctrl_jetDelay ) |
| 22840 | { |
| 22841 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22842 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22843 | b->setJetDelay( f); |
| 22844 | RETURN->v_float = (t_CKFLOAT)b->m_jetDelay; |
| 22845 | } |
| 22846 | |
| 22847 | |
| 22848 | //----------------------------------------------------------------------------- |
| 22849 | // name: Flute_cget_jetDelay() |
| 22850 | // desc: CGET function ... |
| 22851 | //----------------------------------------------------------------------------- |
| 22852 | CK_DLL_CGET( Flute_cget_jetDelay ) |
| 22853 | { |
| 22854 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22855 | RETURN->v_float = (t_CKFLOAT)b->m_jetDelay; |
| 22856 | } |
| 22857 | |
| 22858 | |
| 22859 | //----------------------------------------------------------------------------- |
| 22860 | // name: Flute_ctrl_jetReflection() |
| 22861 | // desc: CTRL function ... |
| 22862 | //----------------------------------------------------------------------------- |
| 22863 | CK_DLL_CTRL( Flute_ctrl_jetReflection ) |
| 22864 | { |
| 22865 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22866 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22867 | b->setJetReflection( f); |
| 22868 | RETURN->v_float = (t_CKFLOAT)b->m_jetReflection; |
| 22869 | } |
| 22870 | |
| 22871 | |
| 22872 | //----------------------------------------------------------------------------- |
| 22873 | // name: Flute_cget_jetReflection() |
| 22874 | // desc: CGET function ... |
| 22875 | //----------------------------------------------------------------------------- |
| 22876 | CK_DLL_CGET( Flute_cget_jetReflection ) |
| 22877 | { |
| 22878 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22879 | RETURN->v_float = (t_CKFLOAT)b->m_jetReflection; |
| 22880 | } |
| 22881 | |
| 22882 | |
| 22883 | //----------------------------------------------------------------------------- |
| 22884 | // name: Flute_ctrl_endReflection() |
| 22885 | // desc: CTRL function ... |
| 22886 | //----------------------------------------------------------------------------- |
| 22887 | CK_DLL_CTRL( Flute_ctrl_endReflection ) |
| 22888 | { |
| 22889 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22890 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22891 | b->setEndReflection(f); |
| 22892 | RETURN->v_float = (t_CKFLOAT)b->m_endReflection; |
| 22893 | } |
| 22894 | |
| 22895 | |
| 22896 | //----------------------------------------------------------------------------- |
| 22897 | // name: Flute_cget_endReflection() |
| 22898 | // desc: CGET function ... |
| 22899 | //----------------------------------------------------------------------------- |
| 22900 | CK_DLL_CGET( Flute_cget_endReflection ) |
| 22901 | { |
| 22902 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22903 | RETURN->v_float = (t_CKFLOAT)b->m_endReflection; |
| 22904 | } |
| 22905 | |
| 22906 | |
| 22907 | //----------------------------------------------------------------------------- |
| 22908 | // name: Flute_ctrl_noiseGain() |
| 22909 | // desc: CTRL function ... |
| 22910 | //----------------------------------------------------------------------------- |
| 22911 | CK_DLL_CTRL( Flute_ctrl_noiseGain ) |
| 22912 | { |
| 22913 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22914 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22915 | b->controlChange( 4, f * 128.0 ); |
| 22916 | RETURN->v_float = (t_CKFLOAT)b->m_noiseGain; |
| 22917 | } |
| 22918 | |
| 22919 | |
| 22920 | //----------------------------------------------------------------------------- |
| 22921 | // name: Flute_cget_noiseGain() |
| 22922 | // desc: CGET function ... |
| 22923 | //----------------------------------------------------------------------------- |
| 22924 | CK_DLL_CGET( Flute_cget_noiseGain ) |
| 22925 | { |
| 22926 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22927 | RETURN->v_float = (t_CKFLOAT)b->m_noiseGain; |
| 22928 | } |
| 22929 | |
| 22930 | |
| 22931 | //----------------------------------------------------------------------------- |
| 22932 | // name: Flute_ctrl_vibratoFreq() |
| 22933 | // desc: CTRL function ... |
| 22934 | //----------------------------------------------------------------------------- |
| 22935 | CK_DLL_CTRL( Flute_ctrl_vibratoFreq ) |
| 22936 | { |
| 22937 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22938 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22939 | b->setVibratoFreq( f ); |
| 22940 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq; |
| 22941 | } |
| 22942 | |
| 22943 | |
| 22944 | //----------------------------------------------------------------------------- |
| 22945 | // name: Flute_cget_vibratoFreq() |
| 22946 | // desc: CGET function ... |
| 22947 | //----------------------------------------------------------------------------- |
| 22948 | CK_DLL_CGET( Flute_cget_vibratoFreq ) |
| 22949 | { |
| 22950 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22951 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq; |
| 22952 | } |
| 22953 | |
| 22954 | |
| 22955 | //----------------------------------------------------------------------------- |
| 22956 | // name: Flute_ctrl_vibratoGain() |
| 22957 | // desc: CTRL function ... |
| 22958 | //----------------------------------------------------------------------------- |
| 22959 | CK_DLL_CTRL( Flute_ctrl_vibratoGain ) |
| 22960 | { |
| 22961 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22962 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22963 | b->controlChange( 1, f * 128.0 ); |
| 22964 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain; |
| 22965 | } |
| 22966 | |
| 22967 | |
| 22968 | //----------------------------------------------------------------------------- |
| 22969 | // name: Flute_cget_vibratoGain() |
| 22970 | // desc: CGET function ... |
| 22971 | //----------------------------------------------------------------------------- |
| 22972 | CK_DLL_CGET( Flute_cget_vibratoGain ) |
| 22973 | { |
| 22974 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22975 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain; |
| 22976 | } |
| 22977 | |
| 22978 | |
| 22979 | //----------------------------------------------------------------------------- |
| 22980 | // name: Flute_ctrl_pressure() |
| 22981 | // desc: CTRL function ... |
| 22982 | //----------------------------------------------------------------------------- |
| 22983 | CK_DLL_CTRL( Flute_ctrl_pressure ) |
| 22984 | { |
| 22985 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22986 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 22987 | b->controlChange( 128, f * 128.0 ); |
| 22988 | RETURN->v_float = (t_CKFLOAT)b->m_pressure; |
| 22989 | } |
| 22990 | |
| 22991 | |
| 22992 | //----------------------------------------------------------------------------- |
| 22993 | // name: Flute_cget_pressure() |
| 22994 | // desc: CGET function ... |
| 22995 | //----------------------------------------------------------------------------- |
| 22996 | CK_DLL_CGET( Flute_cget_pressure ) |
| 22997 | { |
| 22998 | Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 22999 | RETURN->v_float = (t_CKFLOAT)b->m_pressure; |
| 23000 | } |
| 23001 | |
| 23002 | |
| 23003 | // ModalBar |
| 23004 | struct ModalBar_ { |
| 23005 | ModalBar modalbar; |
| 23006 | |
| 23007 | int m_preset; |
| 23008 | int m_modeIndex; |
| 23009 | double m_modeRatio; |
| 23010 | double m_modeRadius; |
| 23011 | |
| 23012 | ModalBar_ ( ) { |
| 23013 | m_preset = 0; |
| 23014 | m_modeIndex = 0; |
| 23015 | } |
| 23016 | }; |
| 23017 | |
| 23018 | |
| 23019 | //----------------------------------------------------------------------------- |
| 23020 | // name: ModalBar_ctor() |
| 23021 | // desc: CTOR function ... |
| 23022 | //----------------------------------------------------------------------------- |
| 23023 | CK_DLL_CTOR( ModalBar_ctor ) |
| 23024 | { |
| 23025 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new ModalBar_(); |
| 23026 | } |
| 23027 | |
| 23028 | |
| 23029 | //----------------------------------------------------------------------------- |
| 23030 | // name: ModalBar_dtor() |
| 23031 | // desc: DTOR function ... |
| 23032 | //----------------------------------------------------------------------------- |
| 23033 | CK_DLL_DTOR( ModalBar_dtor ) |
| 23034 | { |
| 23035 | delete (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23036 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 23037 | } |
| 23038 | |
| 23039 | |
| 23040 | //----------------------------------------------------------------------------- |
| 23041 | // name: ModalBar_tick() |
| 23042 | // desc: TICK function ... |
| 23043 | //----------------------------------------------------------------------------- |
| 23044 | CK_DLL_TICK( ModalBar_tick ) |
| 23045 | { |
| 23046 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23047 | *out = b->modalbar.tick(); |
| 23048 | return TRUE; |
| 23049 | } |
| 23050 | |
| 23051 | |
| 23052 | //----------------------------------------------------------------------------- |
| 23053 | // name: ModalBar_pmsg() |
| 23054 | // desc: PMSG function ... |
| 23055 | //----------------------------------------------------------------------------- |
| 23056 | CK_DLL_PMSG( ModalBar_pmsg ) |
| 23057 | { |
| 23058 | return TRUE; |
| 23059 | } |
| 23060 | |
| 23061 | |
| 23062 | //----------------------------------------------------------------------------- |
| 23063 | // name: ModalBar_ctrl_strike() |
| 23064 | // desc: CTRL function ... |
| 23065 | //----------------------------------------------------------------------------- |
| 23066 | CK_DLL_CTRL( ModalBar_ctrl_strike ) |
| 23067 | { |
| 23068 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23069 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23070 | b->modalbar.strike( f ); |
| 23071 | } |
| 23072 | |
| 23073 | |
| 23074 | //----------------------------------------------------------------------------- |
| 23075 | // name: ModalBar_ctrl_damp() |
| 23076 | // desc: CTRL function ... |
| 23077 | //----------------------------------------------------------------------------- |
| 23078 | CK_DLL_CTRL( ModalBar_ctrl_damp ) |
| 23079 | { |
| 23080 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23081 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23082 | b->modalbar.damp( f ); |
| 23083 | } |
| 23084 | |
| 23085 | |
| 23086 | //----------------------------------------------------------------------------- |
| 23087 | // name: ModalBar_ctrl_clear() |
| 23088 | // desc: CTRL function ... |
| 23089 | //----------------------------------------------------------------------------- |
| 23090 | CK_DLL_CTRL( ModalBar_ctrl_clear ) |
| 23091 | { |
| 23092 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23093 | b->modalbar.clear(); |
| 23094 | } |
| 23095 | |
| 23096 | |
| 23097 | //----------------------------------------------------------------------------- |
| 23098 | // name: ModalBar_ctrl_preset() |
| 23099 | // desc: CTRL function ... |
| 23100 | //----------------------------------------------------------------------------- |
| 23101 | CK_DLL_CTRL( ModalBar_ctrl_preset ) |
| 23102 | { |
| 23103 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23104 | int f = GET_CK_INT(ARGS); |
| 23105 | b->m_preset = f; |
| 23106 | b->modalbar.setPreset ( f ); |
| 23107 | RETURN->v_int = (t_CKINT)b->m_preset; |
| 23108 | } |
| 23109 | |
| 23110 | |
| 23111 | //----------------------------------------------------------------------------- |
| 23112 | // name: ModalBar_cget_preset() |
| 23113 | // desc: CGET function ... |
| 23114 | //----------------------------------------------------------------------------- |
| 23115 | CK_DLL_CGET( ModalBar_cget_preset ) |
| 23116 | { |
| 23117 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23118 | RETURN->v_int = (t_CKINT)b->m_preset; |
| 23119 | } |
| 23120 | |
| 23121 | |
| 23122 | //----------------------------------------------------------------------------- |
| 23123 | // name: ModalBar_ctrl_strikePosition() |
| 23124 | // desc: CTRL function ... |
| 23125 | //----------------------------------------------------------------------------- |
| 23126 | CK_DLL_CTRL( ModalBar_ctrl_strikePosition ) |
| 23127 | { |
| 23128 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23129 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23130 | b->modalbar.setStrikePosition( f ); |
| 23131 | RETURN->v_float = (t_CKFLOAT)b->modalbar.strikePosition; |
| 23132 | } |
| 23133 | |
| 23134 | |
| 23135 | //----------------------------------------------------------------------------- |
| 23136 | // name: ModalBar_cget_strikePosition() |
| 23137 | // desc: CGET function ... |
| 23138 | //----------------------------------------------------------------------------- |
| 23139 | CK_DLL_CGET( ModalBar_cget_strikePosition ) |
| 23140 | { |
| 23141 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23142 | RETURN->v_float = (t_CKFLOAT)b->modalbar.strikePosition; |
| 23143 | } |
| 23144 | |
| 23145 | |
| 23146 | //----------------------------------------------------------------------------- |
| 23147 | // name: ModalBar_ctrl_vibratoGain() |
| 23148 | // desc: CTRL function ... |
| 23149 | //----------------------------------------------------------------------------- |
| 23150 | CK_DLL_CTRL( ModalBar_ctrl_vibratoGain ) |
| 23151 | { |
| 23152 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23153 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23154 | b->modalbar.controlChange( 11, f*128 ); |
| 23155 | RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoGain; |
| 23156 | } |
| 23157 | |
| 23158 | |
| 23159 | //----------------------------------------------------------------------------- |
| 23160 | // name: ModalBar_cget_vibratoGain() |
| 23161 | // desc: CGET function ... |
| 23162 | //----------------------------------------------------------------------------- |
| 23163 | CK_DLL_CGET( ModalBar_cget_vibratoGain ) |
| 23164 | { |
| 23165 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23166 | RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoGain; |
| 23167 | } |
| 23168 | |
| 23169 | |
| 23170 | //----------------------------------------------------------------------------- |
| 23171 | // name: ModalBar_ctrl_vibratoFreq() |
| 23172 | // desc: CTRL function ... |
| 23173 | //----------------------------------------------------------------------------- |
| 23174 | CK_DLL_CTRL( ModalBar_ctrl_vibratoFreq ) |
| 23175 | { |
| 23176 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23177 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23178 | b->modalbar.vibrato->setFrequency( f ); |
| 23179 | b->modalbar.m_vibratoFreq = b->modalbar.vibrato->m_freq; |
| 23180 | RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoFreq; |
| 23181 | } |
| 23182 | |
| 23183 | |
| 23184 | //----------------------------------------------------------------------------- |
| 23185 | // name: ModalBar_cget_vibratoFreq() |
| 23186 | // desc: CGET function ... |
| 23187 | //----------------------------------------------------------------------------- |
| 23188 | CK_DLL_CGET( ModalBar_cget_vibratoFreq ) |
| 23189 | { |
| 23190 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23191 | RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoFreq; |
| 23192 | } |
| 23193 | |
| 23194 | |
| 23195 | //----------------------------------------------------------------------------- |
| 23196 | // name: ModalBar_ctrl_stickHardness() |
| 23197 | // desc: CTRL function ... |
| 23198 | //----------------------------------------------------------------------------- |
| 23199 | CK_DLL_CTRL( ModalBar_ctrl_stickHardness ) |
| 23200 | { |
| 23201 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23202 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23203 | b->modalbar.setStickHardness ( f ); |
| 23204 | RETURN->v_float = (t_CKFLOAT)b->modalbar.stickHardness; |
| 23205 | } |
| 23206 | |
| 23207 | |
| 23208 | |
| 23209 | //----------------------------------------------------------------------------- |
| 23210 | // name: ModalBar_cget_stickHardness() |
| 23211 | // desc: CGET function ... |
| 23212 | //----------------------------------------------------------------------------- |
| 23213 | CK_DLL_CGET( ModalBar_cget_stickHardness ) |
| 23214 | { |
| 23215 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23216 | RETURN->v_float = (t_CKFLOAT)b->modalbar.stickHardness; |
| 23217 | } |
| 23218 | |
| 23219 | |
| 23220 | //----------------------------------------------------------------------------- |
| 23221 | // name: ModalBar_ctrl_masterGain() |
| 23222 | // desc: CTRL function ... |
| 23223 | //----------------------------------------------------------------------------- |
| 23224 | CK_DLL_CTRL( ModalBar_ctrl_masterGain ) |
| 23225 | { |
| 23226 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23227 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23228 | b->modalbar.setMasterGain( f ); |
| 23229 | RETURN->v_float = (t_CKFLOAT)b->modalbar.masterGain; |
| 23230 | } |
| 23231 | |
| 23232 | |
| 23233 | //----------------------------------------------------------------------------- |
| 23234 | // name: ModalBar_cget_masterGain() |
| 23235 | // desc: CGET function ... |
| 23236 | //----------------------------------------------------------------------------- |
| 23237 | CK_DLL_CGET( ModalBar_cget_masterGain ) |
| 23238 | { |
| 23239 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23240 | RETURN->v_float = (t_CKFLOAT)b->modalbar.masterGain; |
| 23241 | } |
| 23242 | |
| 23243 | |
| 23244 | //----------------------------------------------------------------------------- |
| 23245 | // name: ModalBar_ctrl_directGain() |
| 23246 | // desc: CTRL function ... |
| 23247 | //----------------------------------------------------------------------------- |
| 23248 | CK_DLL_CTRL( ModalBar_ctrl_directGain ) |
| 23249 | { |
| 23250 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23251 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23252 | b->modalbar.setDirectGain( f ); |
| 23253 | RETURN->v_float = (t_CKFLOAT) b->modalbar.directGain; |
| 23254 | } |
| 23255 | |
| 23256 | |
| 23257 | //----------------------------------------------------------------------------- |
| 23258 | // name: ModalBar_cget_directGain() |
| 23259 | // desc: CGET function ... |
| 23260 | //----------------------------------------------------------------------------- |
| 23261 | CK_DLL_CGET( ModalBar_cget_directGain ) |
| 23262 | { |
| 23263 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23264 | RETURN->v_float = (t_CKFLOAT)b->modalbar.directGain; |
| 23265 | } |
| 23266 | |
| 23267 | |
| 23268 | //----------------------------------------------------------------------------- |
| 23269 | // name: ModalBar_ctrl_mode() |
| 23270 | // desc: CTRL function ... |
| 23271 | //----------------------------------------------------------------------------- |
| 23272 | CK_DLL_CTRL( ModalBar_ctrl_mode ) |
| 23273 | { |
| 23274 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23275 | int i = GET_CK_INT(ARGS); |
| 23276 | if ( i >= 0 && i < b->modalbar.nModes ) |
| 23277 | { |
| 23278 | b->m_modeIndex = i; |
| 23279 | b->m_modeRatio = b->modalbar.ratios[i]; |
| 23280 | b->m_modeRadius = b->modalbar.radii[i]; |
| 23281 | RETURN->v_float = (t_CKFLOAT)b->m_modeIndex; |
| 23282 | } |
| 23283 | } |
| 23284 | |
| 23285 | |
| 23286 | //----------------------------------------------------------------------------- |
| 23287 | // name: ModalBar_cget_mode() |
| 23288 | // desc: CGET function ... |
| 23289 | //----------------------------------------------------------------------------- |
| 23290 | CK_DLL_CGET( ModalBar_cget_mode ) |
| 23291 | { |
| 23292 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23293 | RETURN->v_float = (t_CKFLOAT)b->m_modeIndex; |
| 23294 | } |
| 23295 | |
| 23296 | |
| 23297 | //----------------------------------------------------------------------------- |
| 23298 | // name: ModalBar_ctrl_modeGain() |
| 23299 | // desc: CTRL function ... |
| 23300 | //----------------------------------------------------------------------------- |
| 23301 | CK_DLL_CTRL( ModalBar_ctrl_modeGain ) |
| 23302 | { |
| 23303 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23304 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23305 | b->modalbar.setModeGain( b->m_modeIndex, f ); |
| 23306 | RETURN->v_float = (t_CKFLOAT)b->modalbar.filters[b->m_modeIndex]->getGain(); |
| 23307 | } |
| 23308 | |
| 23309 | |
| 23310 | //----------------------------------------------------------------------------- |
| 23311 | // name: ModalBar_cget_modeGain() |
| 23312 | // desc: CGET function ... |
| 23313 | //----------------------------------------------------------------------------- |
| 23314 | CK_DLL_CGET( ModalBar_cget_modeGain ) |
| 23315 | { |
| 23316 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23317 | RETURN->v_float = (t_CKFLOAT)b->modalbar.filters[b->m_modeIndex]->getGain(); |
| 23318 | } |
| 23319 | |
| 23320 | |
| 23321 | //----------------------------------------------------------------------------- |
| 23322 | // name: ModalBar_ctrl_modeRatio() |
| 23323 | // desc: CTRL function ... |
| 23324 | //----------------------------------------------------------------------------- |
| 23325 | CK_DLL_CTRL( ModalBar_ctrl_modeRatio ) |
| 23326 | { |
| 23327 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23328 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23329 | if ( b->m_modeIndex >= 0 && b->m_modeIndex < b->modalbar.nModes ) |
| 23330 | { |
| 23331 | b->modalbar.setRatioAndRadius( b->m_modeIndex, f , b->m_modeRadius ); |
| 23332 | b->m_modeRatio = b->modalbar.ratios[b->m_modeIndex]; |
| 23333 | RETURN->v_float = (t_CKFLOAT) b->m_modeRatio; |
| 23334 | } |
| 23335 | } |
| 23336 | |
| 23337 | |
| 23338 | //----------------------------------------------------------------------------- |
| 23339 | // name: ModalBar_cget_modeRatio() |
| 23340 | // desc: CGET function ... |
| 23341 | //----------------------------------------------------------------------------- |
| 23342 | CK_DLL_CGET( ModalBar_cget_modeRatio ) |
| 23343 | { |
| 23344 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23345 | RETURN->v_float = (t_CKFLOAT)b->m_modeRatio; |
| 23346 | } |
| 23347 | |
| 23348 | |
| 23349 | //----------------------------------------------------------------------------- |
| 23350 | // name: ModalBar_ctrl_modeRadius() |
| 23351 | // desc: CTRL function ... |
| 23352 | //----------------------------------------------------------------------------- |
| 23353 | CK_DLL_CTRL( ModalBar_ctrl_modeRadius ) |
| 23354 | { |
| 23355 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23356 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23357 | if( b->m_modeIndex >= 0 && b->m_modeIndex < b->modalbar.nModes ) |
| 23358 | { |
| 23359 | b->modalbar.setRatioAndRadius ( b->m_modeIndex, b->m_modeRatio, f ); |
| 23360 | b->m_modeRadius = b->modalbar.radii[b->m_modeIndex]; |
| 23361 | RETURN->v_float = (t_CKFLOAT) b->m_modeRadius; |
| 23362 | } |
| 23363 | } |
| 23364 | |
| 23365 | |
| 23366 | //----------------------------------------------------------------------------- |
| 23367 | // name: ModalBar_cget_modeRadius() |
| 23368 | // desc: CGET function ... |
| 23369 | //----------------------------------------------------------------------------- |
| 23370 | CK_DLL_CGET( ModalBar_cget_modeRadius ) |
| 23371 | { |
| 23372 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23373 | RETURN->v_float = (t_CKFLOAT)b->m_modeRadius; |
| 23374 | } |
| 23375 | |
| 23376 | |
| 23377 | //----------------------------------------------------------------------------- |
| 23378 | // name: ModalBar_ctrl_volume() |
| 23379 | // desc: CTRL function ... |
| 23380 | //----------------------------------------------------------------------------- |
| 23381 | CK_DLL_CTRL( ModalBar_ctrl_volume ) |
| 23382 | { |
| 23383 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23384 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23385 | b->modalbar.controlChange( 128, f*128 ); |
| 23386 | RETURN->v_float = (t_CKFLOAT)b->modalbar.m_volume; |
| 23387 | } |
| 23388 | |
| 23389 | |
| 23390 | //----------------------------------------------------------------------------- |
| 23391 | // name: ModalBar_cget_volume() |
| 23392 | // desc: CGET function ... |
| 23393 | //----------------------------------------------------------------------------- |
| 23394 | CK_DLL_CGET( ModalBar_cget_volume ) |
| 23395 | { |
| 23396 | ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23397 | RETURN->v_float = (t_CKFLOAT)b->modalbar.m_volume; |
| 23398 | } |
| 23399 | |
| 23400 | |
| 23401 | |
| 23402 | |
| 23403 | // Sitar |
| 23404 | /* |
| 23405 | struct Sitar_ { |
| 23406 | Sitar * imp; |
| 23407 | double m_frequency; |
| 23408 | |
| 23409 | Sitar_ ( double d ) { |
| 23410 | imp = new Sitar(d); |
| 23411 | m_frequency = 100.0; |
| 23412 | } |
| 23413 | };*/ |
| 23414 | |
| 23415 | |
| 23416 | //----------------------------------------------------------------------------- |
| 23417 | // name: Sitar_ctor() |
| 23418 | // desc: CTOR function ... |
| 23419 | //----------------------------------------------------------------------------- |
| 23420 | CK_DLL_CTOR( Sitar_ctor ) |
| 23421 | { |
| 23422 | Sitar * sitar = new Sitar( 20 ); |
| 23423 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)sitar; |
| 23424 | // default |
| 23425 | sitar->setFrequency( 220 ); |
| 23426 | } |
| 23427 | |
| 23428 | |
| 23429 | //----------------------------------------------------------------------------- |
| 23430 | // name: Sitar_dtor() |
| 23431 | // desc: DTOR function ... |
| 23432 | //----------------------------------------------------------------------------- |
| 23433 | CK_DLL_DTOR( Sitar_dtor ) |
| 23434 | { |
| 23435 | Sitar * s = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23436 | CK_SAFE_DELETE(s); |
| 23437 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 23438 | } |
| 23439 | |
| 23440 | |
| 23441 | //----------------------------------------------------------------------------- |
| 23442 | // name: Sitar_tick() |
| 23443 | // desc: TICK function ... |
| 23444 | //----------------------------------------------------------------------------- |
| 23445 | CK_DLL_TICK( Sitar_tick ) |
| 23446 | { |
| 23447 | Sitar * b = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23448 | *out = b->tick(); |
| 23449 | return TRUE; |
| 23450 | } |
| 23451 | |
| 23452 | |
| 23453 | //----------------------------------------------------------------------------- |
| 23454 | // name: Sitar_pmsg() |
| 23455 | // desc: PMSG function ... |
| 23456 | //----------------------------------------------------------------------------- |
| 23457 | CK_DLL_PMSG( Sitar_pmsg ) |
| 23458 | { |
| 23459 | return TRUE; |
| 23460 | } |
| 23461 | |
| 23462 | |
| 23463 | //----------------------------------------------------------------------------- |
| 23464 | // name: Sitar_ctrl_pluck() |
| 23465 | // desc: CTRL function ... |
| 23466 | //----------------------------------------------------------------------------- |
| 23467 | CK_DLL_CTRL( Sitar_ctrl_pluck ) |
| 23468 | { |
| 23469 | Sitar * b = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23470 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23471 | b->pluck( f ); |
| 23472 | } |
| 23473 | |
| 23474 | |
| 23475 | //----------------------------------------------------------------------------- |
| 23476 | // name: Sitar_ctrl_clear() |
| 23477 | // desc: CTRL function ... |
| 23478 | //----------------------------------------------------------------------------- |
| 23479 | CK_DLL_CTRL( Sitar_ctrl_clear ) |
| 23480 | { |
| 23481 | Sitar * b = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23482 | b->clear(); |
| 23483 | } |
| 23484 | |
| 23485 | |
| 23486 | |
| 23487 | |
| 23488 | //----------------------------------------------------------------------------- |
| 23489 | // name: Saxofony_ctor() |
| 23490 | // desc: CTOR function ... |
| 23491 | //----------------------------------------------------------------------------- |
| 23492 | CK_DLL_CTOR( Saxofony_ctor ) |
| 23493 | { |
| 23494 | Saxofony * fony = new Saxofony( 20 ); |
| 23495 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)fony; |
| 23496 | // default |
| 23497 | fony->setFrequency( 220 ); |
| 23498 | } |
| 23499 | |
| 23500 | |
| 23501 | //----------------------------------------------------------------------------- |
| 23502 | // name: Saxofony_dtor() |
| 23503 | // desc: DTOR function ... |
| 23504 | //----------------------------------------------------------------------------- |
| 23505 | CK_DLL_DTOR( Saxofony_dtor ) |
| 23506 | { |
| 23507 | Saxofony * d = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23508 | CK_SAFE_DELETE(d); |
| 23509 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 23510 | } |
| 23511 | |
| 23512 | |
| 23513 | //----------------------------------------------------------------------------- |
| 23514 | // name: Saxofony_tick() |
| 23515 | // desc: TICK function ... |
| 23516 | //----------------------------------------------------------------------------- |
| 23517 | CK_DLL_TICK( Saxofony_tick ) |
| 23518 | { |
| 23519 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23520 | *out = b->tick(); |
| 23521 | return TRUE; |
| 23522 | } |
| 23523 | |
| 23524 | |
| 23525 | //----------------------------------------------------------------------------- |
| 23526 | // name: Saxofony_pmsg() |
| 23527 | // desc: PMSG function ... |
| 23528 | //----------------------------------------------------------------------------- |
| 23529 | CK_DLL_PMSG( Saxofony_pmsg ) |
| 23530 | { |
| 23531 | return TRUE; |
| 23532 | } |
| 23533 | |
| 23534 | |
| 23535 | //----------------------------------------------------------------------------- |
| 23536 | // name: Saxofony_ctrl_startBlowing() |
| 23537 | // desc: CTRL function ... |
| 23538 | //----------------------------------------------------------------------------- |
| 23539 | CK_DLL_CTRL( Saxofony_ctrl_startBlowing ) |
| 23540 | { |
| 23541 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23542 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23543 | b->startBlowing( f, b->m_rate ); |
| 23544 | } |
| 23545 | |
| 23546 | |
| 23547 | //----------------------------------------------------------------------------- |
| 23548 | // name: Saxofony_ctrl_stopBlowing() |
| 23549 | // desc: CTRL function ... |
| 23550 | //----------------------------------------------------------------------------- |
| 23551 | CK_DLL_CTRL( Saxofony_ctrl_stopBlowing ) |
| 23552 | { |
| 23553 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23554 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23555 | b->stopBlowing( f ); |
| 23556 | } |
| 23557 | |
| 23558 | |
| 23559 | //----------------------------------------------------------------------------- |
| 23560 | // name: Saxofony_ctrl_clear() |
| 23561 | // desc: CTRL function ... |
| 23562 | //----------------------------------------------------------------------------- |
| 23563 | CK_DLL_CTRL( Saxofony_ctrl_clear ) |
| 23564 | { |
| 23565 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23566 | b->clear(); |
| 23567 | } |
| 23568 | |
| 23569 | |
| 23570 | //----------------------------------------------------------------------------- |
| 23571 | // name: Saxofony_ctrl_rate() |
| 23572 | // desc: CTRL function ... |
| 23573 | //----------------------------------------------------------------------------- |
| 23574 | CK_DLL_CTRL( Saxofony_ctrl_rate ) |
| 23575 | { |
| 23576 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23577 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23578 | b->m_rate = f; |
| 23579 | RETURN->v_float = (t_CKFLOAT)b->m_rate; |
| 23580 | } |
| 23581 | |
| 23582 | |
| 23583 | //----------------------------------------------------------------------------- |
| 23584 | // name: Saxofony_cget_rate() |
| 23585 | // desc: CGET function ... |
| 23586 | //----------------------------------------------------------------------------- |
| 23587 | CK_DLL_CGET( Saxofony_cget_rate ) |
| 23588 | { |
| 23589 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23590 | RETURN->v_float = (t_CKFLOAT)b->m_rate; |
| 23591 | } |
| 23592 | |
| 23593 | |
| 23594 | //----------------------------------------------------------------------------- |
| 23595 | // name: Saxofony_ctrl_blowPosition() |
| 23596 | // desc: CTRL function ... |
| 23597 | //----------------------------------------------------------------------------- |
| 23598 | CK_DLL_CTRL( Saxofony_ctrl_blowPosition ) |
| 23599 | { |
| 23600 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23601 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23602 | b->setBlowPosition(f); |
| 23603 | RETURN->v_float = (t_CKFLOAT)b->position; |
| 23604 | } |
| 23605 | |
| 23606 | |
| 23607 | //----------------------------------------------------------------------------- |
| 23608 | // name: Saxofony_cget_blowPosition() |
| 23609 | // desc: CGET function ... |
| 23610 | //----------------------------------------------------------------------------- |
| 23611 | CK_DLL_CGET( Saxofony_cget_blowPosition ) |
| 23612 | { |
| 23613 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23614 | RETURN->v_float = (t_CKFLOAT)b->position; |
| 23615 | } |
| 23616 | |
| 23617 | |
| 23618 | //----------------------------------------------------------------------------- |
| 23619 | // name: Saxofony_ctrl_reed() |
| 23620 | // desc: CTRL function ... |
| 23621 | //----------------------------------------------------------------------------- |
| 23622 | CK_DLL_CTRL( Saxofony_ctrl_reed ) |
| 23623 | { |
| 23624 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23625 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23626 | b->controlChange( 2, f * 128 ); |
| 23627 | RETURN->v_float = (t_CKFLOAT)b->m_stiffness; |
| 23628 | } |
| 23629 | |
| 23630 | |
| 23631 | //----------------------------------------------------------------------------- |
| 23632 | // name: Saxofony_cget_reed() |
| 23633 | // desc: CGET function ... |
| 23634 | //----------------------------------------------------------------------------- |
| 23635 | CK_DLL_CGET( Saxofony_cget_reed ) |
| 23636 | { |
| 23637 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23638 | RETURN->v_float = (t_CKFLOAT)b->m_stiffness; |
| 23639 | } |
| 23640 | |
| 23641 | |
| 23642 | //----------------------------------------------------------------------------- |
| 23643 | // name: Saxofony_ctrl_aperture() |
| 23644 | // desc: CTRL function ... |
| 23645 | //----------------------------------------------------------------------------- |
| 23646 | CK_DLL_CTRL( Saxofony_ctrl_aperture ) |
| 23647 | { |
| 23648 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23649 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23650 | b->controlChange( 26, f * 128 ); |
| 23651 | RETURN->v_float = (t_CKFLOAT)b->m_aperture; |
| 23652 | } |
| 23653 | |
| 23654 | |
| 23655 | //----------------------------------------------------------------------------- |
| 23656 | // name: Saxofony_cget_aperture() |
| 23657 | // desc: CGET function ... |
| 23658 | //----------------------------------------------------------------------------- |
| 23659 | CK_DLL_CGET( Saxofony_cget_aperture ) |
| 23660 | { |
| 23661 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23662 | RETURN->v_float = (t_CKFLOAT)b->m_aperture; |
| 23663 | } |
| 23664 | |
| 23665 | |
| 23666 | //----------------------------------------------------------------------------- |
| 23667 | // name: Saxofony_ctrl_noiseGain() |
| 23668 | // desc: CTRL function ... |
| 23669 | //----------------------------------------------------------------------------- |
| 23670 | CK_DLL_CTRL( Saxofony_ctrl_noiseGain ) |
| 23671 | { |
| 23672 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23673 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23674 | b->controlChange( 4, f * 128 ); |
| 23675 | RETURN->v_float = (t_CKFLOAT)b->m_noiseGain; |
| 23676 | } |
| 23677 | |
| 23678 | |
| 23679 | //----------------------------------------------------------------------------- |
| 23680 | // name: Saxofony_cget_noiseGain() |
| 23681 | // desc: CGET function ... |
| 23682 | //----------------------------------------------------------------------------- |
| 23683 | CK_DLL_CGET( Saxofony_cget_noiseGain ) |
| 23684 | { |
| 23685 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23686 | RETURN->v_float = (t_CKFLOAT)b->m_noiseGain; |
| 23687 | } |
| 23688 | |
| 23689 | |
| 23690 | //----------------------------------------------------------------------------- |
| 23691 | // name: Saxofony_ctrl_vibratoFreq() |
| 23692 | // desc: CTRL function ... |
| 23693 | //----------------------------------------------------------------------------- |
| 23694 | CK_DLL_CTRL( Saxofony_ctrl_vibratoFreq ) |
| 23695 | { |
| 23696 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23697 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23698 | b->vibrato->setFrequency( f ); |
| 23699 | RETURN->v_float = (t_CKFLOAT)b->vibrato->m_freq; |
| 23700 | } |
| 23701 | |
| 23702 | |
| 23703 | //----------------------------------------------------------------------------- |
| 23704 | // name: Saxofony_cget_vibratoFreq() |
| 23705 | // desc: CGET function ... |
| 23706 | //----------------------------------------------------------------------------- |
| 23707 | CK_DLL_CGET( Saxofony_cget_vibratoFreq ) |
| 23708 | { |
| 23709 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23710 | RETURN->v_float = (t_CKFLOAT)b->vibrato->m_freq; |
| 23711 | } |
| 23712 | |
| 23713 | |
| 23714 | //----------------------------------------------------------------------------- |
| 23715 | // name: Saxofony_ctrl_vibratoGain() |
| 23716 | // desc: CTRL function ... |
| 23717 | //----------------------------------------------------------------------------- |
| 23718 | CK_DLL_CTRL( Saxofony_ctrl_vibratoGain ) |
| 23719 | { |
| 23720 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23721 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23722 | b->controlChange( 1, f * 128 ); |
| 23723 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain; |
| 23724 | } |
| 23725 | |
| 23726 | |
| 23727 | //----------------------------------------------------------------------------- |
| 23728 | // name: Saxofony_cget_vibratoGain() |
| 23729 | // desc: CGET function ... |
| 23730 | //----------------------------------------------------------------------------- |
| 23731 | CK_DLL_CGET( Saxofony_cget_vibratoGain ) |
| 23732 | { |
| 23733 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23734 | RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain; |
| 23735 | } |
| 23736 | |
| 23737 | |
| 23738 | //----------------------------------------------------------------------------- |
| 23739 | // name: Saxofony_ctrl_pressure() |
| 23740 | // desc: CTRL function ... |
| 23741 | //----------------------------------------------------------------------------- |
| 23742 | CK_DLL_CTRL( Saxofony_ctrl_pressure ) |
| 23743 | { |
| 23744 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23745 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23746 | b->controlChange( 128, f * 128 ); |
| 23747 | RETURN->v_float = (t_CKFLOAT)b->m_pressure; |
| 23748 | } |
| 23749 | |
| 23750 | |
| 23751 | //----------------------------------------------------------------------------- |
| 23752 | // name: Saxofony_cget_pressure() |
| 23753 | // desc: CGET function ... |
| 23754 | //----------------------------------------------------------------------------- |
| 23755 | CK_DLL_CGET( Saxofony_cget_pressure ) |
| 23756 | { |
| 23757 | Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23758 | RETURN->v_float = (t_CKFLOAT)b->m_pressure; |
| 23759 | } |
| 23760 | |
| 23761 | |
| 23762 | |
| 23763 | |
| 23764 | // StifKarp |
| 23765 | |
| 23766 | //----------------------------------------------------------------------------- |
| 23767 | // name: StifKarp_ctor() |
| 23768 | // desc: CTOR function ... |
| 23769 | //----------------------------------------------------------------------------- |
| 23770 | CK_DLL_CTOR( StifKarp_ctor ) |
| 23771 | { |
| 23772 | // initialize member object |
| 23773 | StifKarp * karp = new StifKarp( 20.0 ); |
| 23774 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)karp; |
| 23775 | // default |
| 23776 | karp->setFrequency( 220.0 ); |
| 23777 | } |
| 23778 | |
| 23779 | |
| 23780 | //----------------------------------------------------------------------------- |
| 23781 | // name: StifKarp_dtor() |
| 23782 | // desc: DTOR function ... |
| 23783 | //----------------------------------------------------------------------------- |
| 23784 | CK_DLL_DTOR( StifKarp_dtor ) |
| 23785 | { |
| 23786 | delete (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23787 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 23788 | } |
| 23789 | |
| 23790 | |
| 23791 | //----------------------------------------------------------------------------- |
| 23792 | // name: StifKarp_tick() |
| 23793 | // desc: TICK function ... |
| 23794 | //----------------------------------------------------------------------------- |
| 23795 | CK_DLL_TICK( StifKarp_tick ) |
| 23796 | { |
| 23797 | StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23798 | *out = b->tick(); |
| 23799 | return TRUE; |
| 23800 | } |
| 23801 | |
| 23802 | |
| 23803 | //----------------------------------------------------------------------------- |
| 23804 | // name: StifKarp_pmsg() |
| 23805 | // desc: PMSG function ... |
| 23806 | //----------------------------------------------------------------------------- |
| 23807 | CK_DLL_PMSG( StifKarp_pmsg ) |
| 23808 | { |
| 23809 | return TRUE; |
| 23810 | } |
| 23811 | |
| 23812 | |
| 23813 | //----------------------------------------------------------------------------- |
| 23814 | // name: StifKarp_ctrl_pluck() |
| 23815 | // desc: CTRL function ... |
| 23816 | //----------------------------------------------------------------------------- |
| 23817 | CK_DLL_CTRL( StifKarp_ctrl_pluck ) |
| 23818 | { |
| 23819 | StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23820 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23821 | b->pluck( f ); |
| 23822 | } |
| 23823 | |
| 23824 | |
| 23825 | //----------------------------------------------------------------------------- |
| 23826 | // name: StifKarp_ctrl_clear() |
| 23827 | // desc: CTRL function ... |
| 23828 | //----------------------------------------------------------------------------- |
| 23829 | CK_DLL_CTRL( StifKarp_ctrl_clear ) |
| 23830 | { |
| 23831 | StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23832 | b->clear(); |
| 23833 | } |
| 23834 | |
| 23835 | |
| 23836 | //----------------------------------------------------------------------------- |
| 23837 | // name: StifKarp_ctrl_pickupPosition() |
| 23838 | // desc: CTRL function ... |
| 23839 | //----------------------------------------------------------------------------- |
| 23840 | CK_DLL_CTRL( StifKarp_ctrl_pickupPosition ) |
| 23841 | { |
| 23842 | StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23843 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23844 | b->setPickupPosition( f ); |
| 23845 | RETURN->v_float = (t_CKFLOAT)b->pickupPosition; |
| 23846 | } |
| 23847 | |
| 23848 | |
| 23849 | //----------------------------------------------------------------------------- |
| 23850 | // name: StifKarp_cget_pickupPosition() |
| 23851 | // desc: CGET function ... |
| 23852 | //----------------------------------------------------------------------------- |
| 23853 | CK_DLL_CGET( StifKarp_cget_pickupPosition ) |
| 23854 | { |
| 23855 | StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23856 | RETURN->v_float = (t_CKFLOAT)b->pickupPosition; |
| 23857 | } |
| 23858 | |
| 23859 | |
| 23860 | //----------------------------------------------------------------------------- |
| 23861 | // name: StifKarp_ctrl_stretch() |
| 23862 | // desc: CTRL function ... |
| 23863 | //----------------------------------------------------------------------------- |
| 23864 | CK_DLL_CTRL( StifKarp_ctrl_stretch ) |
| 23865 | { |
| 23866 | StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23867 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23868 | b->setStretch( f ); |
| 23869 | RETURN->v_float = (t_CKFLOAT)b->stretching; |
| 23870 | } |
| 23871 | |
| 23872 | |
| 23873 | //----------------------------------------------------------------------------- |
| 23874 | // name: StifKarp_cget_stretch() |
| 23875 | // desc: CGET function ... |
| 23876 | //----------------------------------------------------------------------------- |
| 23877 | CK_DLL_CGET( StifKarp_cget_stretch ) |
| 23878 | { |
| 23879 | StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23880 | RETURN->v_float = (t_CKFLOAT)b->stretching; |
| 23881 | } |
| 23882 | |
| 23883 | |
| 23884 | //----------------------------------------------------------------------------- |
| 23885 | // name: StifKarp_ctrl_sustain() |
| 23886 | // desc: CTRL function ... |
| 23887 | //----------------------------------------------------------------------------- |
| 23888 | CK_DLL_CTRL( StifKarp_ctrl_sustain ) |
| 23889 | { |
| 23890 | StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23891 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23892 | b->controlChange( __SK_StringDamping_, f * 128 ); |
| 23893 | RETURN->v_float = (t_CKFLOAT)b->m_sustain; |
| 23894 | } |
| 23895 | |
| 23896 | |
| 23897 | //----------------------------------------------------------------------------- |
| 23898 | // name: StifKarp_cget_sustain() |
| 23899 | // desc: CGET function ... |
| 23900 | //----------------------------------------------------------------------------- |
| 23901 | CK_DLL_CGET( StifKarp_cget_sustain ) |
| 23902 | { |
| 23903 | StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23904 | RETURN->v_float = (t_CKFLOAT)b->m_sustain; |
| 23905 | } |
| 23906 | |
| 23907 | |
| 23908 | //----------------------------------------------------------------------------- |
| 23909 | // name: StifKarp_ctrl_baseLoopGain() |
| 23910 | // desc: CTRL function ... |
| 23911 | //----------------------------------------------------------------------------- |
| 23912 | CK_DLL_CTRL( StifKarp_ctrl_baseLoopGain ) |
| 23913 | { |
| 23914 | StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23915 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 23916 | b->setBaseLoopGain( f ); |
| 23917 | RETURN->v_float = (t_CKFLOAT)b->baseLoopGain; |
| 23918 | } |
| 23919 | |
| 23920 | |
| 23921 | //----------------------------------------------------------------------------- |
| 23922 | // name: StifKarp_cget_baseLoopGain() |
| 23923 | // desc: CGET function ... |
| 23924 | //----------------------------------------------------------------------------- |
| 23925 | CK_DLL_CGET( StifKarp_cget_baseLoopGain ) |
| 23926 | { |
| 23927 | StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 23928 | RETURN->v_float = (t_CKFLOAT)b->baseLoopGain; |
| 23929 | } |
| 23930 | |
| 23931 | |
| 23932 | |
| 23933 | // Delay |
| 23934 | //----------------------------------------------------------------------------- |
| 23935 | // name: Delay_ctor() |
| 23936 | // desc: CTOR function ... |
| 23937 | //----------------------------------------------------------------------------- |
| 23938 | CK_DLL_CTOR( Delay_ctor ) |
| 23939 | { |
| 23940 | OBJ_MEMBER_UINT(SELF, Delay_offset_data) = (t_CKUINT)new DelayBase; |
| 23941 | } |
| 23942 | |
| 23943 | |
| 23944 | //----------------------------------------------------------------------------- |
| 23945 | // name: Delay_ctor_delay() |
| 23946 | // desc: CTOR function (because this is a pre-ctro, it is already run) |
| 23947 | //----------------------------------------------------------------------------- |
| 23948 | CK_DLL_CTOR( Delay_ctor_delay ) |
| 23949 | { |
| 23950 | // get delay |
| 23951 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 23952 | |
| 23953 | // internal object should already be instantiated in pre-ctor |
| 23954 | DelayBase * d = (DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data); |
| 23955 | // set delay (again) and max, unit is in samples |
| 23956 | d->set( (long)(delay+.5), (long)(delay+.5) ); |
| 23957 | } |
| 23958 | |
| 23959 | |
| 23960 | //----------------------------------------------------------------------------- |
| 23961 | // name: Delay_ctor_delay_max() |
| 23962 | // desc: CTOR function ... |
| 23963 | //----------------------------------------------------------------------------- |
| 23964 | CK_DLL_CTOR( Delay_ctor_delay_max ) |
| 23965 | { |
| 23966 | // get delay |
| 23967 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 23968 | // get delay max |
| 23969 | t_CKDUR max = GET_NEXT_DUR(ARGS); |
| 23970 | // internal object should already be instantiated in pre-ctor |
| 23971 | DelayBase * d = (DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data); |
| 23972 | // set delay (again) and max, unit is in samples |
| 23973 | d->set( (long)(delay+.5), (long)(max+.5) ); |
| 23974 | } |
| 23975 | |
| 23976 | |
| 23977 | //----------------------------------------------------------------------------- |
| 23978 | // name: Delay_dtor() |
| 23979 | // desc: DTOR function ... |
| 23980 | //----------------------------------------------------------------------------- |
| 23981 | CK_DLL_DTOR( Delay_dtor ) |
| 23982 | { |
| 23983 | delete (DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data); |
| 23984 | OBJ_MEMBER_UINT(SELF, Delay_offset_data) = 0; |
| 23985 | } |
| 23986 | |
| 23987 | |
| 23988 | //----------------------------------------------------------------------------- |
| 23989 | // name: Delay_ctrl_set() |
| 23990 | // desc: set function ... |
| 23991 | //----------------------------------------------------------------------------- |
| 23992 | CK_DLL_CTRL( Delay_ctrl_set ) |
| 23993 | { |
| 23994 | // get delay |
| 23995 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 23996 | // get delay max |
| 23997 | t_CKDUR max = GET_NEXT_DUR(ARGS); |
| 23998 | // get the object |
| 23999 | DelayBase * d = (DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data); |
| 24000 | // set it |
| 24001 | d->set( (long)(delay+.5), (long)(max+.5) ); |
| 24002 | } |
| 24003 | |
| 24004 | |
| 24005 | //----------------------------------------------------------------------------- |
| 24006 | // name: Delay_tick() |
| 24007 | // desc: TICK function ... |
| 24008 | //----------------------------------------------------------------------------- |
| 24009 | CK_DLL_TICK( Delay_tick ) |
| 24010 | { |
| 24011 | *out = (SAMPLE)((DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->tick( in ); |
| 24012 | return TRUE; |
| 24013 | } |
| 24014 | |
| 24015 | |
| 24016 | //----------------------------------------------------------------------------- |
| 24017 | // name: Delay_pmsg() |
| 24018 | // desc: PMSG function ... |
| 24019 | //----------------------------------------------------------------------------- |
| 24020 | CK_DLL_PMSG( Delay_pmsg ) |
| 24021 | { |
| 24022 | return FALSE; |
| 24023 | } |
| 24024 | |
| 24025 | |
| 24026 | //----------------------------------------------------------------------------- |
| 24027 | // name: Delay_ctrl_delay() |
| 24028 | // desc: CTRL function ... |
| 24029 | //----------------------------------------------------------------------------- |
| 24030 | CK_DLL_CTRL( Delay_ctrl_delay ) |
| 24031 | { |
| 24032 | ((DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->setDelay( (long)(GET_NEXT_DUR(ARGS)+.5) ); |
| 24033 | RETURN->v_dur = (t_CKDUR)((DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->getDelay(); |
| 24034 | } |
| 24035 | |
| 24036 | |
| 24037 | //----------------------------------------------------------------------------- |
| 24038 | // name: Delay_cget_delay() |
| 24039 | // desc: CGET function ... |
| 24040 | //----------------------------------------------------------------------------- |
| 24041 | CK_DLL_CGET( Delay_cget_delay ) |
| 24042 | { |
| 24043 | RETURN->v_dur = (t_CKDUR)((DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->getDelay(); |
| 24044 | } |
| 24045 | |
| 24046 | |
| 24047 | //----------------------------------------------------------------------------- |
| 24048 | // name: Delay_ctrl_max() |
| 24049 | // desc: CTRL function ... |
| 24050 | //----------------------------------------------------------------------------- |
| 24051 | CK_DLL_CTRL( Delay_ctrl_max ) |
| 24052 | { |
| 24053 | DelayBase * delay = (DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data); |
| 24054 | t_CKFLOAT val = (t_CKFLOAT)delay->getDelay(); |
| 24055 | t_CKDUR max = GET_NEXT_DUR(ARGS); |
| 24056 | delay->set( (long)(val+.5), (long)(max+1.5) ); |
| 24057 | RETURN->v_dur = (t_CKDUR)((DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->length-1.0; |
| 24058 | } |
| 24059 | |
| 24060 | |
| 24061 | //----------------------------------------------------------------------------- |
| 24062 | // name: Delay_cget_max() |
| 24063 | // desc: CGET function ... |
| 24064 | //----------------------------------------------------------------------------- |
| 24065 | CK_DLL_CGET( Delay_cget_max ) |
| 24066 | { |
| 24067 | RETURN->v_dur = (t_CKDUR)((DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->length-1.0; |
| 24068 | } |
| 24069 | |
| 24070 | |
| 24071 | //----------------------------------------------------------------------------- |
| 24072 | // name: Delay_clear() |
| 24073 | // desc: CGET function ... |
| 24074 | //----------------------------------------------------------------------------- |
| 24075 | CK_DLL_CGET( Delay_clear ) |
| 24076 | { |
| 24077 | DelayBase * delay = (DelayBase *)OBJ_MEMBER_UINT(SELF, Delay_offset_data); |
| 24078 | delay->clear(); |
| 24079 | } |
| 24080 | |
| 24081 | |
| 24082 | |
| 24083 | |
| 24084 | // DelayA |
| 24085 | //----------------------------------------------------------------------------- |
| 24086 | // name: DelayA_ctor() |
| 24087 | // desc: base/pre CTOR function |
| 24088 | //----------------------------------------------------------------------------- |
| 24089 | CK_DLL_CTOR( DelayA_ctor ) |
| 24090 | { |
| 24091 | // instantiate internal object; this is DelayA's pre-ctor, which means |
| 24092 | // it will always be run before any overloaded contructors |
| 24093 | OBJ_MEMBER_UINT(SELF, DelayA_offset_data) = (t_CKUINT)new DelayA; |
| 24094 | } |
| 24095 | |
| 24096 | |
| 24097 | //----------------------------------------------------------------------------- |
| 24098 | // name: DelayA_ctor_delay() |
| 24099 | // desc: overloaded CTOR function |
| 24100 | //----------------------------------------------------------------------------- |
| 24101 | CK_DLL_CTOR( DelayA_ctor_delay ) |
| 24102 | { |
| 24103 | // get delay |
| 24104 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 24105 | // internal object should already be instantiated in pre-ctor |
| 24106 | DelayA * d = (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data); |
| 24107 | // set delay (double) and max (long), unit is samps |
| 24108 | d->set( delay, (long)(delay+.5) ); |
| 24109 | } |
| 24110 | |
| 24111 | |
| 24112 | //----------------------------------------------------------------------------- |
| 24113 | // name: DelayA_ctor_delay_max() |
| 24114 | // desc: overloaded CTOR function ... |
| 24115 | //----------------------------------------------------------------------------- |
| 24116 | CK_DLL_CTOR( DelayA_ctor_delay_max ) |
| 24117 | { |
| 24118 | // get delay |
| 24119 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 24120 | // get delay max |
| 24121 | t_CKDUR max = GET_NEXT_DUR(ARGS); |
| 24122 | // internal object should already be instantiated in pre-ctor |
| 24123 | DelayA * d = (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data); |
| 24124 | // set delay (double) and max (long), unit is samps |
| 24125 | d->set( delay, (long)(max+.5) ); |
| 24126 | } |
| 24127 | |
| 24128 | |
| 24129 | //----------------------------------------------------------------------------- |
| 24130 | // name: DelayA_dtor() |
| 24131 | // desc: DTOR function ... |
| 24132 | //----------------------------------------------------------------------------- |
| 24133 | CK_DLL_DTOR( DelayA_dtor ) |
| 24134 | { |
| 24135 | delete (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data); |
| 24136 | OBJ_MEMBER_UINT(SELF, DelayA_offset_data) = 0; |
| 24137 | } |
| 24138 | |
| 24139 | |
| 24140 | //----------------------------------------------------------------------------- |
| 24141 | // name: DelayA_ctrl_set() |
| 24142 | // desc: set function ... |
| 24143 | //----------------------------------------------------------------------------- |
| 24144 | CK_DLL_CTRL( DelayA_ctrl_set ) |
| 24145 | { |
| 24146 | // get delay |
| 24147 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 24148 | // get delay max |
| 24149 | t_CKDUR max = GET_NEXT_DUR(ARGS); |
| 24150 | // get the object |
| 24151 | DelayA * d = (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data); |
| 24152 | // set it |
| 24153 | d->set( delay, (long)(max+.5) ); |
| 24154 | } |
| 24155 | |
| 24156 | |
| 24157 | //----------------------------------------------------------------------------- |
| 24158 | // name: DelayA_tick() |
| 24159 | // desc: TICK function ... |
| 24160 | //----------------------------------------------------------------------------- |
| 24161 | CK_DLL_TICK( DelayA_tick ) |
| 24162 | { |
| 24163 | *out = (SAMPLE)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->tick( in ); |
| 24164 | return TRUE; |
| 24165 | } |
| 24166 | |
| 24167 | |
| 24168 | //----------------------------------------------------------------------------- |
| 24169 | // name: DelayA_pmsg() |
| 24170 | // desc: PMSG function ... |
| 24171 | //----------------------------------------------------------------------------- |
| 24172 | CK_DLL_PMSG( DelayA_pmsg ) |
| 24173 | { |
| 24174 | return FALSE; |
| 24175 | } |
| 24176 | |
| 24177 | |
| 24178 | //----------------------------------------------------------------------------- |
| 24179 | // name: DelayA_ctrl_delay() |
| 24180 | // desc: CTRL function ... |
| 24181 | //----------------------------------------------------------------------------- |
| 24182 | CK_DLL_CTRL( DelayA_ctrl_delay ) |
| 24183 | { |
| 24184 | ((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->setDelay( GET_NEXT_DUR(ARGS) ); |
| 24185 | RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->getDelay(); |
| 24186 | } |
| 24187 | |
| 24188 | |
| 24189 | //----------------------------------------------------------------------------- |
| 24190 | // name: DelayA_cget_delay() |
| 24191 | // desc: CGET function ... |
| 24192 | //----------------------------------------------------------------------------- |
| 24193 | CK_DLL_CGET( DelayA_cget_delay ) |
| 24194 | { |
| 24195 | RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->getDelay(); |
| 24196 | } |
| 24197 | |
| 24198 | |
| 24199 | //----------------------------------------------------------------------------- |
| 24200 | // name: DelayA_ctrl_max() |
| 24201 | // desc: CTRL function ... |
| 24202 | //----------------------------------------------------------------------------- |
| 24203 | CK_DLL_CTRL( DelayA_ctrl_max ) |
| 24204 | { |
| 24205 | DelayA * delay = (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data); |
| 24206 | t_CKDUR val = (t_CKDUR)delay->getDelay(); |
| 24207 | t_CKDUR max = GET_NEXT_DUR(ARGS); |
| 24208 | delay->set( val, (long)(max+1.5) ); |
| 24209 | RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->length-1.0; |
| 24210 | } |
| 24211 | |
| 24212 | |
| 24213 | //----------------------------------------------------------------------------- |
| 24214 | // name: DelayA_cget_max() |
| 24215 | // desc: CGET function ... |
| 24216 | //----------------------------------------------------------------------------- |
| 24217 | CK_DLL_CGET( DelayA_cget_max ) |
| 24218 | { |
| 24219 | RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->length-1.0; |
| 24220 | } |
| 24221 | |
| 24222 | |
| 24223 | //----------------------------------------------------------------------------- |
| 24224 | // name: DelayA_clear() |
| 24225 | // desc: CGET function ... |
| 24226 | //----------------------------------------------------------------------------- |
| 24227 | CK_DLL_CGET( DelayA_clear ) |
| 24228 | { |
| 24229 | DelayA * delay = (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data); |
| 24230 | delay->clear(); |
| 24231 | } |
| 24232 | |
| 24233 | |
| 24234 | |
| 24235 | |
| 24236 | // DelayL |
| 24237 | //----------------------------------------------------------------------------- |
| 24238 | // name: DelayL_ctor() |
| 24239 | // desc: CTOR function ... |
| 24240 | //----------------------------------------------------------------------------- |
| 24241 | CK_DLL_CTOR( DelayL_ctor ) |
| 24242 | { |
| 24243 | OBJ_MEMBER_UINT(SELF, DelayL_offset_data) = (t_CKUINT)new DelayL; |
| 24244 | } |
| 24245 | |
| 24246 | |
| 24247 | //----------------------------------------------------------------------------- |
| 24248 | // name: DelayL_ctor_delay() |
| 24249 | // desc: CTOR function ... |
| 24250 | //----------------------------------------------------------------------------- |
| 24251 | CK_DLL_CTOR( DelayL_ctor_delay ) |
| 24252 | { |
| 24253 | // get delay |
| 24254 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 24255 | // internal object should already be instantiated in pre-ctor |
| 24256 | DelayL * d = (DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data); |
| 24257 | // set delay (double) and max (long), unit is samps |
| 24258 | d->set( delay, (long)(delay+.5) ); |
| 24259 | } |
| 24260 | |
| 24261 | |
| 24262 | //----------------------------------------------------------------------------- |
| 24263 | // name: DelayL_ctor_delay_max() |
| 24264 | // desc: CTOR function ... |
| 24265 | //----------------------------------------------------------------------------- |
| 24266 | CK_DLL_CTOR( DelayL_ctor_delay_max ) |
| 24267 | { |
| 24268 | // get delay |
| 24269 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 24270 | // get delay max |
| 24271 | t_CKDUR max = GET_NEXT_DUR(ARGS); |
| 24272 | // internal object should already be instantiated in pre-ctor |
| 24273 | DelayL * d = (DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data); |
| 24274 | // set delay (double) and max (long), unit is samps |
| 24275 | d->set( delay, (long)(max+.5) ); |
| 24276 | } |
| 24277 | |
| 24278 | |
| 24279 | //----------------------------------------------------------------------------- |
| 24280 | // name: DelayL_ctrl_set() |
| 24281 | // desc: set function ... |
| 24282 | //----------------------------------------------------------------------------- |
| 24283 | CK_DLL_CTRL( DelayL_ctrl_set ) |
| 24284 | { |
| 24285 | // get delay |
| 24286 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 24287 | // get delay max |
| 24288 | t_CKDUR max = GET_NEXT_DUR(ARGS); |
| 24289 | // get the object |
| 24290 | DelayL * d = (DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data); |
| 24291 | // set it |
| 24292 | d->set( delay, (long)(max+.5) ); |
| 24293 | } |
| 24294 | |
| 24295 | |
| 24296 | //----------------------------------------------------------------------------- |
| 24297 | // name: DelayL_dtor() |
| 24298 | // desc: DTOR function ... |
| 24299 | //----------------------------------------------------------------------------- |
| 24300 | CK_DLL_DTOR( DelayL_dtor ) |
| 24301 | { |
| 24302 | delete (DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data); |
| 24303 | OBJ_MEMBER_UINT(SELF, DelayL_offset_data) = 0; |
| 24304 | } |
| 24305 | |
| 24306 | |
| 24307 | //----------------------------------------------------------------------------- |
| 24308 | // name: DelayL_tick() |
| 24309 | // desc: TICK function ... |
| 24310 | //----------------------------------------------------------------------------- |
| 24311 | CK_DLL_TICK( DelayL_tick ) |
| 24312 | { |
| 24313 | *out = (SAMPLE)((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->tick( in ); |
| 24314 | return TRUE; |
| 24315 | } |
| 24316 | |
| 24317 | |
| 24318 | //----------------------------------------------------------------------------- |
| 24319 | // name: DelayL_pmsg() |
| 24320 | // desc: PMSG function ... |
| 24321 | //----------------------------------------------------------------------------- |
| 24322 | CK_DLL_PMSG( DelayL_pmsg ) |
| 24323 | { |
| 24324 | return FALSE; |
| 24325 | } |
| 24326 | |
| 24327 | |
| 24328 | //----------------------------------------------------------------------------- |
| 24329 | // name: DelayL_ctrl_delay() |
| 24330 | // desc: CTRL function ... |
| 24331 | //----------------------------------------------------------------------------- |
| 24332 | CK_DLL_CTRL( DelayL_ctrl_delay ) |
| 24333 | { |
| 24334 | ((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->setDelay( GET_NEXT_DUR(ARGS) ); |
| 24335 | RETURN->v_dur = (t_CKDUR)((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->getDelay(); |
| 24336 | } |
| 24337 | |
| 24338 | |
| 24339 | //----------------------------------------------------------------------------- |
| 24340 | // name: DelayL_cget_delay() |
| 24341 | // desc: CGET function ... |
| 24342 | //----------------------------------------------------------------------------- |
| 24343 | CK_DLL_CGET( DelayL_cget_delay ) |
| 24344 | { |
| 24345 | RETURN->v_dur = (t_CKDUR)((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->getDelay(); |
| 24346 | } |
| 24347 | |
| 24348 | |
| 24349 | //----------------------------------------------------------------------------- |
| 24350 | // name: DelayL_ctrl_max() |
| 24351 | // desc: CTRL function ... |
| 24352 | //----------------------------------------------------------------------------- |
| 24353 | CK_DLL_CTRL( DelayL_ctrl_max ) |
| 24354 | { |
| 24355 | DelayL * delay = (DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data); |
| 24356 | t_CKDUR val = (t_CKDUR)delay->getDelay(); |
| 24357 | t_CKDUR max = GET_NEXT_DUR(ARGS); |
| 24358 | delay->set( val, (long)(max+1.5) ); |
| 24359 | RETURN->v_dur = (t_CKDUR)delay->length-1.0; |
| 24360 | } |
| 24361 | |
| 24362 | |
| 24363 | //----------------------------------------------------------------------------- |
| 24364 | // name: DelayL_cget_max() |
| 24365 | // desc: CGET function ... |
| 24366 | //----------------------------------------------------------------------------- |
| 24367 | CK_DLL_CGET( DelayL_cget_max ) |
| 24368 | { |
| 24369 | RETURN->v_dur = (t_CKDUR)((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->length-1.0; |
| 24370 | } |
| 24371 | |
| 24372 | |
| 24373 | //----------------------------------------------------------------------------- |
| 24374 | // name: DelayL_clear() |
| 24375 | // desc: CGET function ... |
| 24376 | //----------------------------------------------------------------------------- |
| 24377 | CK_DLL_CGET( DelayL_clear ) |
| 24378 | { |
| 24379 | DelayL * delay = (DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data); |
| 24380 | delay->clear(); |
| 24381 | } |
| 24382 | |
| 24383 | |
| 24384 | |
| 24385 | |
| 24386 | // Echo |
| 24387 | //----------------------------------------------------------------------------- |
| 24388 | // name: Echo_ctor() |
| 24389 | // desc: CTOR function ... |
| 24390 | //----------------------------------------------------------------------------- |
| 24391 | CK_DLL_CTOR( Echo_ctor ) |
| 24392 | { |
| 24393 | // initialize member object |
| 24394 | OBJ_MEMBER_UINT(SELF, Echo_offset_data) = (t_CKUINT)new Echo( Stk::sampleRate() / 2.0 ); |
| 24395 | } |
| 24396 | |
| 24397 | |
| 24398 | //----------------------------------------------------------------------------- |
| 24399 | // name: Echo_ctor_delay() |
| 24400 | // desc: CTOR function ... |
| 24401 | //----------------------------------------------------------------------------- |
| 24402 | CK_DLL_CTOR( Echo_ctor_delay ) |
| 24403 | { |
| 24404 | // get delay |
| 24405 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 24406 | // internal object should already be instantiated in pre-ctor |
| 24407 | Echo * d = (Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data); |
| 24408 | // set echo delay max (double); unit is samps |
| 24409 | d->set( delay ); |
| 24410 | } |
| 24411 | |
| 24412 | |
| 24413 | //----------------------------------------------------------------------------- |
| 24414 | // name: Echo_ctor_delay_max() |
| 24415 | // desc: CTOR function ... |
| 24416 | //----------------------------------------------------------------------------- |
| 24417 | CK_DLL_CTOR( Echo_ctor_delay_max ) |
| 24418 | { |
| 24419 | // get delay |
| 24420 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 24421 | // get delay max |
| 24422 | t_CKDUR max = GET_NEXT_DUR(ARGS); |
| 24423 | |
| 24424 | // internal object should already be instantiated in pre-ctor |
| 24425 | Echo * d = (Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data); |
| 24426 | // set echo delay max (double); unit is samps |
| 24427 | d->set( max ); |
| 24428 | // set echo delay; unit is samps |
| 24429 | d->setDelay( delay ); |
| 24430 | } |
| 24431 | |
| 24432 | |
| 24433 | //----------------------------------------------------------------------------- |
| 24434 | // name: Echo_dtor() |
| 24435 | // desc: DTOR function ... |
| 24436 | //----------------------------------------------------------------------------- |
| 24437 | CK_DLL_DTOR( Echo_dtor ) |
| 24438 | { |
| 24439 | delete (Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data); |
| 24440 | OBJ_MEMBER_UINT(SELF, Echo_offset_data) = 0; |
| 24441 | } |
| 24442 | |
| 24443 | |
| 24444 | //----------------------------------------------------------------------------- |
| 24445 | // name: Echo_ctrl_set() |
| 24446 | // desc: set function ... |
| 24447 | //----------------------------------------------------------------------------- |
| 24448 | CK_DLL_CTRL( Echo_ctrl_set ) |
| 24449 | { |
| 24450 | // get delay |
| 24451 | t_CKDUR delay = GET_NEXT_DUR(ARGS); |
| 24452 | // get delay max |
| 24453 | t_CKDUR max = GET_NEXT_DUR(ARGS); |
| 24454 | // get the object |
| 24455 | Echo * d = (Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data); |
| 24456 | // set max |
| 24457 | d->set( (long)(max+.5) ); |
| 24458 | // set delay |
| 24459 | d->setDelay( delay ); |
| 24460 | } |
| 24461 | |
| 24462 | |
| 24463 | //----------------------------------------------------------------------------- |
| 24464 | // name: Echo_tick() |
| 24465 | // desc: TICK function ... |
| 24466 | //----------------------------------------------------------------------------- |
| 24467 | CK_DLL_TICK( Echo_tick ) |
| 24468 | { |
| 24469 | *out = (SAMPLE)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->tick( in ); |
| 24470 | return TRUE; |
| 24471 | } |
| 24472 | |
| 24473 | |
| 24474 | //----------------------------------------------------------------------------- |
| 24475 | // name: Echo_pmsg() |
| 24476 | // desc: PMSG function ... |
| 24477 | //----------------------------------------------------------------------------- |
| 24478 | CK_DLL_PMSG( Echo_pmsg ) |
| 24479 | { |
| 24480 | return FALSE; |
| 24481 | } |
| 24482 | |
| 24483 | |
| 24484 | //----------------------------------------------------------------------------- |
| 24485 | // name: Echo_ctrl_delay() |
| 24486 | // desc: CTRL function ... |
| 24487 | //----------------------------------------------------------------------------- |
| 24488 | CK_DLL_CTRL( Echo_ctrl_delay ) |
| 24489 | { |
| 24490 | ((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->setDelay( GET_NEXT_DUR(ARGS) ); |
| 24491 | RETURN->v_dur = (t_CKDUR)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->getDelay(); |
| 24492 | } |
| 24493 | |
| 24494 | |
| 24495 | //----------------------------------------------------------------------------- |
| 24496 | // name: Echo_cget_delay() |
| 24497 | // desc: CGET function ... |
| 24498 | //----------------------------------------------------------------------------- |
| 24499 | CK_DLL_CGET( Echo_cget_delay ) |
| 24500 | { |
| 24501 | RETURN->v_dur = (t_CKDUR)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->getDelay(); |
| 24502 | } |
| 24503 | |
| 24504 | |
| 24505 | //----------------------------------------------------------------------------- |
| 24506 | // name: Echo_ctrl_max() |
| 24507 | // desc: CTRL function ... |
| 24508 | //----------------------------------------------------------------------------- |
| 24509 | CK_DLL_CTRL( Echo_ctrl_max ) |
| 24510 | { |
| 24511 | ((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->set( GET_NEXT_DUR(ARGS) ); |
| 24512 | RETURN->v_dur = (t_CKDUR)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->length; |
| 24513 | } |
| 24514 | |
| 24515 | |
| 24516 | //----------------------------------------------------------------------------- |
| 24517 | // name: Echo_cget_max() |
| 24518 | // desc: CGET function ... |
| 24519 | //----------------------------------------------------------------------------- |
| 24520 | CK_DLL_CGET( Echo_cget_max ) |
| 24521 | { |
| 24522 | RETURN->v_dur = (t_CKDUR)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->length; |
| 24523 | } |
| 24524 | |
| 24525 | |
| 24526 | //----------------------------------------------------------------------------- |
| 24527 | // name: Echo_ctrl_mix() |
| 24528 | // desc: CTRL function ... |
| 24529 | //----------------------------------------------------------------------------- |
| 24530 | CK_DLL_CTRL( Echo_ctrl_mix ) |
| 24531 | { |
| 24532 | ((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->setEffectMix( GET_NEXT_FLOAT(ARGS) ); |
| 24533 | RETURN->v_float = (t_CKFLOAT)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->effectMix; |
| 24534 | } |
| 24535 | |
| 24536 | |
| 24537 | //----------------------------------------------------------------------------- |
| 24538 | // name: Echo_cget_mix() |
| 24539 | // desc: CGET function ... |
| 24540 | //----------------------------------------------------------------------------- |
| 24541 | CK_DLL_CGET( Echo_cget_mix ) |
| 24542 | { |
| 24543 | RETURN->v_float = (t_CKFLOAT)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->effectMix; |
| 24544 | } |
| 24545 | |
| 24546 | |
| 24547 | //----------------------------------------------------------------------------- |
| 24548 | // name: Envelope - import |
| 24549 | // desc: .. |
| 24550 | //----------------------------------------------------------------------------- |
| 24551 | //----------------------------------------------------------------------------- |
| 24552 | // name: Envelope_ctor() |
| 24553 | // desc: base/pre CTOR |
| 24554 | //----------------------------------------------------------------------------- |
| 24555 | CK_DLL_CTOR( Envelope_ctor ) |
| 24556 | { |
| 24557 | OBJ_MEMBER_UINT(SELF, Envelope_offset_data) = (t_CKUINT)new Envelope; |
| 24558 | } |
| 24559 | |
| 24560 | |
| 24561 | //----------------------------------------------------------------------------- |
| 24562 | // name: Envelope_dtor() |
| 24563 | // desc: destructor |
| 24564 | //----------------------------------------------------------------------------- |
| 24565 | CK_DLL_DTOR( Envelope_dtor ) |
| 24566 | { |
| 24567 | delete (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24568 | OBJ_MEMBER_UINT(SELF, Envelope_offset_data) = 0; |
| 24569 | } |
| 24570 | |
| 24571 | |
| 24572 | //----------------------------------------------------------------------------- |
| 24573 | // name: Envelope_tick() |
| 24574 | // desc: TICK function |
| 24575 | //----------------------------------------------------------------------------- |
| 24576 | CK_DLL_TICK( Envelope_tick ) |
| 24577 | { |
| 24578 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24579 | *out = in * d->tick(); |
| 24580 | return TRUE; |
| 24581 | } |
| 24582 | |
| 24583 | |
| 24584 | //----------------------------------------------------------------------------- |
| 24585 | // name: Envelope_pmsg() |
| 24586 | // desc: PMSG function |
| 24587 | //----------------------------------------------------------------------------- |
| 24588 | CK_DLL_PMSG( Envelope_pmsg ) |
| 24589 | { |
| 24590 | return FALSE; |
| 24591 | } |
| 24592 | |
| 24593 | |
| 24594 | //----------------------------------------------------------------------------- |
| 24595 | // name: Envelope_ctor_duration() |
| 24596 | // desc: ctor( dur durationToTarget ) |
| 24597 | //----------------------------------------------------------------------------- |
| 24598 | CK_DLL_CTOR( Envelope_ctor_duration ) |
| 24599 | { |
| 24600 | // internal object should be already instantiated in pre-ctor |
| 24601 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24602 | // prep (without triggering envelope) |
| 24603 | d->prepTime( GET_NEXT_DUR(ARGS) / Stk::sampleRate() ); |
| 24604 | } |
| 24605 | |
| 24606 | |
| 24607 | //----------------------------------------------------------------------------- |
| 24608 | // name: Envelope_ctor_float() |
| 24609 | // desc: ctor( float secondsToTarget ) |
| 24610 | //----------------------------------------------------------------------------- |
| 24611 | CK_DLL_CTOR( Envelope_ctor_float ) |
| 24612 | { |
| 24613 | // internal object should be already instantiated in pre-ctor |
| 24614 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24615 | // prep (without triggering envelope) |
| 24616 | d->prepTime( GET_NEXT_FLOAT(ARGS) ); |
| 24617 | } |
| 24618 | |
| 24619 | |
| 24620 | //----------------------------------------------------------------------------- |
| 24621 | // name: Envelope_ctor_duration_target() |
| 24622 | // desc: ctor( dur durationToTarget, float target ) |
| 24623 | //----------------------------------------------------------------------------- |
| 24624 | CK_DLL_CTOR( Envelope_ctor_duration_target ) |
| 24625 | { |
| 24626 | // internal object should be already instantiated in pre-ctor |
| 24627 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24628 | d->prepTime( GET_NEXT_DUR(ARGS) / Stk::sampleRate() ); |
| 24629 | d->prepTarget( GET_NEXT_FLOAT(ARGS) ); |
| 24630 | } |
| 24631 | |
| 24632 | |
| 24633 | //----------------------------------------------------------------------------- |
| 24634 | // name: Envelope_ctor_float_target() |
| 24635 | // desc: ctor( float secondsToTarget, float target ) |
| 24636 | //----------------------------------------------------------------------------- |
| 24637 | CK_DLL_CTOR( Envelope_ctor_float_target ) |
| 24638 | { |
| 24639 | // internal object should be already instantiated in pre-ctor |
| 24640 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24641 | d->prepTime( GET_NEXT_FLOAT(ARGS) ); |
| 24642 | d->prepTarget( GET_NEXT_FLOAT(ARGS) ); |
| 24643 | } |
| 24644 | |
| 24645 | |
| 24646 | //----------------------------------------------------------------------------- |
| 24647 | // name: Envelope_mfun_duration_target() |
| 24648 | // desc: ramp( dur durationToTarget, float target ) |
| 24649 | //----------------------------------------------------------------------------- |
| 24650 | CK_DLL_MFUN( Envelope_mfun_duration_target ) |
| 24651 | { |
| 24652 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24653 | t_CKDUR vdur = GET_NEXT_DUR(ARGS); |
| 24654 | d->prepTime( vdur / Stk::sampleRate() ); |
| 24655 | d->setTarget( GET_NEXT_FLOAT(ARGS) ); |
| 24656 | RETURN->v_dur = vdur; |
| 24657 | } |
| 24658 | |
| 24659 | |
| 24660 | //----------------------------------------------------------------------------- |
| 24661 | // name: Envelope_mfun_float_target() |
| 24662 | // desc: ramp( float secondsToTarget, float target ) |
| 24663 | //----------------------------------------------------------------------------- |
| 24664 | CK_DLL_MFUN( Envelope_mfun_float_target ) |
| 24665 | { |
| 24666 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24667 | t_CKFLOAT s = GET_NEXT_FLOAT(ARGS); |
| 24668 | d->prepTime( s ); |
| 24669 | d->setTarget( GET_NEXT_FLOAT(ARGS) ); |
| 24670 | RETURN->v_dur = s * Stk::sampleRate(); |
| 24671 | } |
| 24672 | |
| 24673 | |
| 24674 | //----------------------------------------------------------------------------- |
| 24675 | // name: Envelope_ctrl_time() |
| 24676 | // desc: CTRL function ... |
| 24677 | //----------------------------------------------------------------------------- |
| 24678 | CK_DLL_CTRL( Envelope_ctrl_time ) |
| 24679 | { |
| 24680 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24681 | d->setTime( GET_NEXT_FLOAT(ARGS) ); |
| 24682 | RETURN->v_float = d->m_time; |
| 24683 | } |
| 24684 | |
| 24685 | |
| 24686 | //----------------------------------------------------------------------------- |
| 24687 | // name: Envelope_cget_time() |
| 24688 | // desc: CGET function ... |
| 24689 | //----------------------------------------------------------------------------- |
| 24690 | CK_DLL_CGET( Envelope_cget_time ) |
| 24691 | { |
| 24692 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24693 | RETURN->v_float = d->m_time; |
| 24694 | } |
| 24695 | |
| 24696 | |
| 24697 | //----------------------------------------------------------------------------- |
| 24698 | // name: Envelope_ctrl_duration() |
| 24699 | // desc: CTRL function ... |
| 24700 | //----------------------------------------------------------------------------- |
| 24701 | CK_DLL_CTRL( Envelope_ctrl_duration ) |
| 24702 | { |
| 24703 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24704 | d->setTime( GET_NEXT_DUR(ARGS) / Stk::sampleRate() ); |
| 24705 | RETURN->v_float = d->m_time * Stk::sampleRate(); |
| 24706 | } |
| 24707 | |
| 24708 | |
| 24709 | //----------------------------------------------------------------------------- |
| 24710 | // name: Envelope_cget_duration() |
| 24711 | // desc: CGET function ... |
| 24712 | //----------------------------------------------------------------------------- |
| 24713 | CK_DLL_CGET( Envelope_cget_duration ) |
| 24714 | { |
| 24715 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24716 | RETURN->v_float = d->m_time * Stk::sampleRate(); |
| 24717 | } |
| 24718 | |
| 24719 | |
| 24720 | //----------------------------------------------------------------------------- |
| 24721 | // name: Envelope_ctrl_rate() |
| 24722 | // desc: CTRL function ... |
| 24723 | //----------------------------------------------------------------------------- |
| 24724 | CK_DLL_CTRL( Envelope_ctrl_rate ) |
| 24725 | { |
| 24726 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24727 | d->setRate( GET_NEXT_FLOAT(ARGS) ); |
| 24728 | RETURN->v_float = (t_CKFLOAT)d->rate; |
| 24729 | } |
| 24730 | |
| 24731 | |
| 24732 | //----------------------------------------------------------------------------- |
| 24733 | // name: Envelope_cget_rate() |
| 24734 | // desc: CGET function ... |
| 24735 | //----------------------------------------------------------------------------- |
| 24736 | CK_DLL_CGET( Envelope_cget_rate ) |
| 24737 | { |
| 24738 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24739 | RETURN->v_float = (t_CKFLOAT)d->rate; |
| 24740 | } |
| 24741 | |
| 24742 | |
| 24743 | //----------------------------------------------------------------------------- |
| 24744 | // name: Envelope_ctrl_target() |
| 24745 | // desc: CTRL function ... |
| 24746 | //----------------------------------------------------------------------------- |
| 24747 | CK_DLL_CTRL( Envelope_ctrl_target ) |
| 24748 | { |
| 24749 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24750 | d->setTarget( GET_NEXT_FLOAT(ARGS) ); |
| 24751 | RETURN->v_float = (t_CKFLOAT)d->target; |
| 24752 | } |
| 24753 | |
| 24754 | |
| 24755 | //----------------------------------------------------------------------------- |
| 24756 | // name: Envelope_cget_target() |
| 24757 | // desc: CGET function ... |
| 24758 | //----------------------------------------------------------------------------- |
| 24759 | CK_DLL_CGET( Envelope_cget_target ) |
| 24760 | { |
| 24761 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24762 | RETURN->v_float = (t_CKFLOAT)d->target; |
| 24763 | } |
| 24764 | |
| 24765 | |
| 24766 | //----------------------------------------------------------------------------- |
| 24767 | // name: Envelope_ctrl_value() |
| 24768 | // desc: CTRL function ... |
| 24769 | //----------------------------------------------------------------------------- |
| 24770 | CK_DLL_CTRL( Envelope_ctrl_value ) |
| 24771 | { |
| 24772 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24773 | d->setValue( GET_NEXT_FLOAT(ARGS) ); |
| 24774 | RETURN->v_float = (t_CKFLOAT)d->value; |
| 24775 | } |
| 24776 | |
| 24777 | |
| 24778 | //----------------------------------------------------------------------------- |
| 24779 | // name: Envelope_cget_value() |
| 24780 | // desc: CGET function ... |
| 24781 | //----------------------------------------------------------------------------- |
| 24782 | CK_DLL_CGET( Envelope_cget_value ) |
| 24783 | { |
| 24784 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24785 | RETURN->v_float = (t_CKFLOAT)d->value; |
| 24786 | } |
| 24787 | |
| 24788 | |
| 24789 | //----------------------------------------------------------------------------- |
| 24790 | // name: Envelope_ctrl_keyOn0() |
| 24791 | // desc: CTRL function ... |
| 24792 | //----------------------------------------------------------------------------- |
| 24793 | CK_DLL_CTRL( Envelope_ctrl_keyOn0 ) |
| 24794 | { |
| 24795 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24796 | d->keyOn(); |
| 24797 | RETURN->v_int = 1; |
| 24798 | } |
| 24799 | |
| 24800 | |
| 24801 | //----------------------------------------------------------------------------- |
| 24802 | // name: Envelope_ctrl_keyOn() |
| 24803 | // desc: CTRL function ... |
| 24804 | //----------------------------------------------------------------------------- |
| 24805 | CK_DLL_CTRL( Envelope_ctrl_keyOn ) |
| 24806 | { |
| 24807 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24808 | if( GET_NEXT_INT(ARGS) ) |
| 24809 | { |
| 24810 | d->keyOn(); |
| 24811 | RETURN->v_int = 1; |
| 24812 | } |
| 24813 | else |
| 24814 | { |
| 24815 | d->keyOff(); |
| 24816 | RETURN->v_int = 0; |
| 24817 | } |
| 24818 | } |
| 24819 | |
| 24820 | |
| 24821 | //----------------------------------------------------------------------------- |
| 24822 | // name: Envelope_ctrl_keyOff0() |
| 24823 | // desc: CTRL function ... |
| 24824 | //----------------------------------------------------------------------------- |
| 24825 | CK_DLL_CTRL( Envelope_ctrl_keyOff0 ) |
| 24826 | { |
| 24827 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24828 | d->keyOff(); |
| 24829 | RETURN->v_int = 1; |
| 24830 | } |
| 24831 | |
| 24832 | |
| 24833 | //----------------------------------------------------------------------------- |
| 24834 | // name: Envelope_ctrl_keyOff() |
| 24835 | // desc: CTRL function ... |
| 24836 | //----------------------------------------------------------------------------- |
| 24837 | CK_DLL_CTRL( Envelope_ctrl_keyOff ) |
| 24838 | { |
| 24839 | Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24840 | if( !GET_NEXT_INT(ARGS) ) |
| 24841 | { |
| 24842 | d->keyOn(); |
| 24843 | RETURN->v_int = 0; |
| 24844 | } |
| 24845 | else |
| 24846 | { |
| 24847 | d->keyOff(); |
| 24848 | RETURN->v_int = 1; |
| 24849 | } |
| 24850 | } |
| 24851 | |
| 24852 | |
| 24853 | //----------------------------------------------------------------------------- |
| 24854 | // name: ADSR - import |
| 24855 | // desc: .. |
| 24856 | //----------------------------------------------------------------------------- |
| 24857 | //----------------------------------------------------------------------------- |
| 24858 | // name: ADSR_ctor() |
| 24859 | // desc: base/pre CTOR function |
| 24860 | //----------------------------------------------------------------------------- |
| 24861 | CK_DLL_CTOR( ADSR_ctor ) |
| 24862 | { |
| 24863 | // TODO: fix this horrid thing |
| 24864 | Envelope * e = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24865 | // ugh, delete the internal object for Envelope |
| 24866 | CK_SAFE_DELETE(e); |
| 24867 | |
| 24868 | // allocate internal object for ADSR |
| 24869 | OBJ_MEMBER_UINT(SELF, Envelope_offset_data) = (t_CKUINT)new ADSR; |
| 24870 | |
| 24871 | // this is highly non-aesthetic but seems to work robustly |
| 24872 | } |
| 24873 | |
| 24874 | |
| 24875 | //----------------------------------------------------------------------------- |
| 24876 | // name: ADSR_dtor() |
| 24877 | // desc: DTOR function ... |
| 24878 | //----------------------------------------------------------------------------- |
| 24879 | CK_DLL_DTOR( ADSR_dtor ) |
| 24880 | { |
| 24881 | delete (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24882 | OBJ_MEMBER_UINT(SELF, Envelope_offset_data) = 0; |
| 24883 | } |
| 24884 | |
| 24885 | |
| 24886 | //----------------------------------------------------------------------------- |
| 24887 | // name: ADSR_tick() |
| 24888 | // desc: TICK function ... |
| 24889 | //----------------------------------------------------------------------------- |
| 24890 | CK_DLL_TICK( ADSR_tick ) |
| 24891 | { |
| 24892 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24893 | *out = in * d->tick(); |
| 24894 | return TRUE; |
| 24895 | } |
| 24896 | |
| 24897 | |
| 24898 | //----------------------------------------------------------------------------- |
| 24899 | // name: ADSR_pmsg() |
| 24900 | // desc: PMSG function ... |
| 24901 | //----------------------------------------------------------------------------- |
| 24902 | CK_DLL_PMSG( ADSR_pmsg ) |
| 24903 | { |
| 24904 | return FALSE; |
| 24905 | } |
| 24906 | |
| 24907 | |
| 24908 | //----------------------------------------------------------------------------- |
| 24909 | // name: ADSR_ctor_floats() |
| 24910 | // desc: ctor( float attack, float decay, float sustain, float release ) |
| 24911 | //----------------------------------------------------------------------------- |
| 24912 | CK_DLL_CTOR( ADSR_ctor_floats ) |
| 24913 | { |
| 24914 | // internal object should be already instantiated in pre-ctor |
| 24915 | ADSR * e = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24916 | t_CKFLOAT a = GET_NEXT_FLOAT(ARGS); |
| 24917 | t_CKFLOAT d = GET_NEXT_FLOAT(ARGS); |
| 24918 | t_CKFLOAT s = GET_NEXT_FLOAT(ARGS); |
| 24919 | t_CKFLOAT r = GET_NEXT_FLOAT(ARGS); |
| 24920 | |
| 24921 | // set A D S R |
| 24922 | e->setAllTimes( a, d, s, r ); |
| 24923 | } |
| 24924 | |
| 24925 | |
| 24926 | //----------------------------------------------------------------------------- |
| 24927 | // name: ADSR_ctor_durs() |
| 24928 | // desc: ctor( dur attack, dur decay, dur sustain, dur release ) |
| 24929 | //----------------------------------------------------------------------------- |
| 24930 | CK_DLL_CTOR( ADSR_ctor_durs ) |
| 24931 | { |
| 24932 | // internal object should be already instantiated in pre-ctor |
| 24933 | ADSR * e = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24934 | t_CKDUR a = GET_NEXT_DUR(ARGS); |
| 24935 | t_CKDUR d = GET_NEXT_DUR(ARGS); |
| 24936 | t_CKFLOAT s = GET_NEXT_FLOAT(ARGS); |
| 24937 | t_CKDUR r = GET_NEXT_DUR(ARGS); |
| 24938 | |
| 24939 | // set A D S R |
| 24940 | e->setAllTimes( a/Stk::sampleRate(), d/Stk::sampleRate(), s, r/Stk::sampleRate() ); |
| 24941 | } |
| 24942 | |
| 24943 | |
| 24944 | //----------------------------------------------------------------------------- |
| 24945 | // name: ADSR_ctrl_attackTime() |
| 24946 | // desc: CTRL function ... |
| 24947 | //----------------------------------------------------------------------------- |
| 24948 | CK_DLL_CTRL( ADSR_ctrl_attackTime ) |
| 24949 | { |
| 24950 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24951 | t_CKDUR t = GET_NEXT_DUR(ARGS); |
| 24952 | d->setAttackTime( t / Stk::sampleRate() ); |
| 24953 | RETURN->v_dur = t; |
| 24954 | } |
| 24955 | |
| 24956 | |
| 24957 | //----------------------------------------------------------------------------- |
| 24958 | // name: ADSR_cget_attackTime() |
| 24959 | // desc: CGET function ... |
| 24960 | //----------------------------------------------------------------------------- |
| 24961 | CK_DLL_CGET( ADSR_cget_attackTime ) |
| 24962 | { |
| 24963 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24964 | RETURN->v_dur = d->getAttackTime() * Stk::sampleRate(); |
| 24965 | } |
| 24966 | |
| 24967 | |
| 24968 | //----------------------------------------------------------------------------- |
| 24969 | // name: ADSR_ctrl_attackRate() |
| 24970 | // desc: CTRL function ... |
| 24971 | //----------------------------------------------------------------------------- |
| 24972 | CK_DLL_CTRL( ADSR_ctrl_attackRate ) |
| 24973 | { |
| 24974 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24975 | d->setAttackRate( GET_NEXT_FLOAT(ARGS) ); |
| 24976 | RETURN->v_float = (t_CKFLOAT)d->attackRate; |
| 24977 | } |
| 24978 | |
| 24979 | |
| 24980 | //----------------------------------------------------------------------------- |
| 24981 | // name: ADSR_cget_attackRate() |
| 24982 | // desc: CGET function ... |
| 24983 | //----------------------------------------------------------------------------- |
| 24984 | CK_DLL_CGET( ADSR_cget_attackRate ) |
| 24985 | { |
| 24986 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24987 | RETURN->v_float = (t_CKFLOAT)d->attackRate; |
| 24988 | } |
| 24989 | |
| 24990 | |
| 24991 | //----------------------------------------------------------------------------- |
| 24992 | // name: ADSR_ctrl_decayTime() |
| 24993 | // desc: CTRL function ... |
| 24994 | //----------------------------------------------------------------------------- |
| 24995 | CK_DLL_CTRL( ADSR_ctrl_decayTime ) |
| 24996 | { |
| 24997 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 24998 | t_CKDUR t = GET_NEXT_DUR(ARGS); |
| 24999 | d->setDecayTime( t / Stk::sampleRate() ); |
| 25000 | RETURN->v_dur = t; |
| 25001 | } |
| 25002 | |
| 25003 | |
| 25004 | //----------------------------------------------------------------------------- |
| 25005 | // name: ADSR_cget_decayTime() |
| 25006 | // desc: CGET function ... |
| 25007 | //----------------------------------------------------------------------------- |
| 25008 | CK_DLL_CGET( ADSR_cget_decayTime ) |
| 25009 | { |
| 25010 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25011 | RETURN->v_dur = d->getDecayTime() * Stk::sampleRate(); |
| 25012 | } |
| 25013 | |
| 25014 | |
| 25015 | //----------------------------------------------------------------------------- |
| 25016 | // name: ADSR_ctrl_decayRate() |
| 25017 | // desc: CTRL function ... |
| 25018 | //----------------------------------------------------------------------------- |
| 25019 | CK_DLL_CTRL( ADSR_ctrl_decayRate ) |
| 25020 | { |
| 25021 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25022 | d->setDecayRate( GET_NEXT_FLOAT(ARGS) ); |
| 25023 | RETURN->v_float = (t_CKFLOAT)d->decayRate; |
| 25024 | } |
| 25025 | |
| 25026 | |
| 25027 | //----------------------------------------------------------------------------- |
| 25028 | // name: ADSR_cget_decayRate() |
| 25029 | // desc: CTRL function ... |
| 25030 | //----------------------------------------------------------------------------- |
| 25031 | CK_DLL_CGET( ADSR_cget_decayRate ) |
| 25032 | { |
| 25033 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25034 | RETURN->v_float = (t_CKFLOAT)d->decayRate; |
| 25035 | } |
| 25036 | |
| 25037 | |
| 25038 | //----------------------------------------------------------------------------- |
| 25039 | // name: ADSR_ctrl_sustainLevel() |
| 25040 | // desc: CTRL function ... |
| 25041 | //----------------------------------------------------------------------------- |
| 25042 | CK_DLL_CTRL( ADSR_ctrl_sustainLevel ) |
| 25043 | { |
| 25044 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25045 | d->setSustainLevel( GET_NEXT_FLOAT(ARGS) ); |
| 25046 | RETURN->v_float = (t_CKFLOAT)d->sustainLevel; |
| 25047 | } |
| 25048 | |
| 25049 | |
| 25050 | //----------------------------------------------------------------------------- |
| 25051 | // name: ADSR_cget_sustainLevel() |
| 25052 | // desc: CTRL function ... |
| 25053 | //----------------------------------------------------------------------------- |
| 25054 | CK_DLL_CGET( ADSR_cget_sustainLevel ) |
| 25055 | { |
| 25056 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25057 | RETURN->v_float = (t_CKFLOAT)d->sustainLevel; |
| 25058 | } |
| 25059 | |
| 25060 | |
| 25061 | //----------------------------------------------------------------------------- |
| 25062 | // name: ADSR_ctrl_releaseTime() |
| 25063 | // desc: CTRL function ... |
| 25064 | //----------------------------------------------------------------------------- |
| 25065 | CK_DLL_CTRL( ADSR_ctrl_releaseTime ) |
| 25066 | { |
| 25067 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25068 | t_CKDUR t = GET_NEXT_DUR(ARGS); |
| 25069 | d->setReleaseTime( t / Stk::sampleRate() ); |
| 25070 | RETURN->v_dur = t; |
| 25071 | } |
| 25072 | |
| 25073 | |
| 25074 | //----------------------------------------------------------------------------- |
| 25075 | // name: ADSR_cget_releaseTime() |
| 25076 | // desc: CGET function ... |
| 25077 | //----------------------------------------------------------------------------- |
| 25078 | CK_DLL_CGET( ADSR_cget_releaseTime ) |
| 25079 | { |
| 25080 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25081 | RETURN->v_dur = d->getReleaseTime() * Stk::sampleRate(); |
| 25082 | } |
| 25083 | |
| 25084 | |
| 25085 | //----------------------------------------------------------------------------- |
| 25086 | // name: ADSR_ctrl_releaseRate() |
| 25087 | // desc: CTRL function ... |
| 25088 | //----------------------------------------------------------------------------- |
| 25089 | CK_DLL_CTRL( ADSR_ctrl_releaseRate ) |
| 25090 | { |
| 25091 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25092 | d->setReleaseRate( GET_NEXT_FLOAT(ARGS) ); |
| 25093 | RETURN->v_float = (t_CKFLOAT)d->releaseRate; |
| 25094 | } |
| 25095 | |
| 25096 | |
| 25097 | //----------------------------------------------------------------------------- |
| 25098 | // name: ADSR_cget_releaseRate() |
| 25099 | // desc: CTRL function ... |
| 25100 | //----------------------------------------------------------------------------- |
| 25101 | CK_DLL_CGET( ADSR_cget_releaseRate ) |
| 25102 | { |
| 25103 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25104 | RETURN->v_float = (t_CKFLOAT)d->releaseRate; |
| 25105 | } |
| 25106 | |
| 25107 | |
| 25108 | //----------------------------------------------------------------------------- |
| 25109 | // name: ADSR_cget_state() |
| 25110 | // desc: CTRL function ... |
| 25111 | //----------------------------------------------------------------------------- |
| 25112 | CK_DLL_CGET( ADSR_cget_state ) |
| 25113 | { |
| 25114 | ADSR * d = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25115 | RETURN->v_int = (t_CKINT) d->state; |
| 25116 | } |
| 25117 | |
| 25118 | |
| 25119 | //----------------------------------------------------------------------------- |
| 25120 | // name: ADSR_ctrl_set() |
| 25121 | // desc: CTRL function ... |
| 25122 | //----------------------------------------------------------------------------- |
| 25123 | CK_DLL_CTRL( ADSR_ctrl_set ) |
| 25124 | { |
| 25125 | ADSR * e = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25126 | t_CKFLOAT a = GET_NEXT_FLOAT(ARGS); |
| 25127 | t_CKFLOAT d = GET_NEXT_FLOAT(ARGS); |
| 25128 | t_CKFLOAT s = GET_NEXT_FLOAT(ARGS); |
| 25129 | t_CKFLOAT r = GET_NEXT_FLOAT(ARGS); |
| 25130 | |
| 25131 | // 1.4.1.0 calling this aggregate function |
| 25132 | e->setAllTimes( a, d, s, r ); |
| 25133 | // e->setAttackTime( a ); |
| 25134 | // e->setDecayTime( d ); |
| 25135 | // e->setSustainLevel( s ); |
| 25136 | // e->setReleaseTime( r ); |
| 25137 | } |
| 25138 | |
| 25139 | |
| 25140 | //----------------------------------------------------------------------------- |
| 25141 | // name: ADSR_ctrl_set2() |
| 25142 | // desc: CTRL function ... |
| 25143 | //----------------------------------------------------------------------------- |
| 25144 | CK_DLL_CTRL( ADSR_ctrl_set2 ) |
| 25145 | { |
| 25146 | ADSR * e = (ADSR *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data); |
| 25147 | t_CKDUR a = GET_NEXT_DUR(ARGS); |
| 25148 | t_CKDUR d = GET_NEXT_DUR(ARGS); |
| 25149 | t_CKFLOAT s = GET_NEXT_FLOAT(ARGS); |
| 25150 | t_CKDUR r = GET_NEXT_DUR(ARGS); |
| 25151 | |
| 25152 | // 1.4.1.0 calling this aggregate function |
| 25153 | e->setAllTimes( a/Stk::sampleRate(), d/Stk::sampleRate(), s, r/Stk::sampleRate() ); |
| 25154 | // e->setAttackTime( a / Stk::sampleRate() ); |
| 25155 | // e->setDecayTime( d / Stk::sampleRate() ); |
| 25156 | // e->setSustainLevel( s ); |
| 25157 | // e->setReleaseTime( r / Stk::sampleRate() ); |
| 25158 | } |
| 25159 | |
| 25160 | |
| 25161 | |
| 25162 | |
| 25163 | // FilterStk |
| 25164 | //----------------------------------------------------------------------------- |
| 25165 | // name: FilterStk_ctor() |
| 25166 | // desc: CTOR function ... |
| 25167 | //----------------------------------------------------------------------------- |
| 25168 | CK_DLL_CTOR( FilterStk_ctor ) |
| 25169 | { |
| 25170 | OBJ_MEMBER_UINT(SELF, FilterStk_offset_data) = (t_CKUINT)new FilterStk; |
| 25171 | } |
| 25172 | |
| 25173 | |
| 25174 | //----------------------------------------------------------------------------- |
| 25175 | // name: FilterStk_dtor() |
| 25176 | // desc: DTOR function ... |
| 25177 | //----------------------------------------------------------------------------- |
| 25178 | CK_DLL_DTOR( FilterStk_dtor ) |
| 25179 | { |
| 25180 | delete (FilterStk *)OBJ_MEMBER_UINT(SELF, FilterStk_offset_data); |
| 25181 | OBJ_MEMBER_UINT(SELF, FilterStk_offset_data) = 0; |
| 25182 | } |
| 25183 | |
| 25184 | |
| 25185 | //----------------------------------------------------------------------------- |
| 25186 | // name: FilterStk_tick() |
| 25187 | // desc: TICK function ... |
| 25188 | //----------------------------------------------------------------------------- |
| 25189 | CK_DLL_TICK( FilterStk_tick ) |
| 25190 | { |
| 25191 | FilterStk * d = (FilterStk *)OBJ_MEMBER_UINT(SELF, FilterStk_offset_data); |
| 25192 | *out = d->tick( in ); |
| 25193 | return TRUE; |
| 25194 | } |
| 25195 | |
| 25196 | |
| 25197 | //----------------------------------------------------------------------------- |
| 25198 | // name: FilterStk_pmsg() |
| 25199 | // desc: PMSG function ... |
| 25200 | //----------------------------------------------------------------------------- |
| 25201 | CK_DLL_PMSG( FilterStk_pmsg ) |
| 25202 | { |
| 25203 | return FALSE; |
| 25204 | } |
| 25205 | |
| 25206 | |
| 25207 | //----------------------------------------------------------------------------- |
| 25208 | // name: FilterStk_ctrl_coefs() |
| 25209 | // desc: CTRL function ... |
| 25210 | //----------------------------------------------------------------------------- |
| 25211 | CK_DLL_CTRL( FilterStk_ctrl_coefs ) |
| 25212 | { |
| 25213 | // FilterStk * d = (FilterStk *)OBJ_MEMBER_UINT(SELF, FilterStk_offset_data); |
| 25214 | CK_FPRINTF_STDERR( "FilterStk.coefs :: not implemented\n" ); |
| 25215 | } |
| 25216 | |
| 25217 | |
| 25218 | //----------------------------------------------------------------------------- |
| 25219 | // name: OnePole_ctor() |
| 25220 | // desc: CTOR function ... |
| 25221 | //----------------------------------------------------------------------------- |
| 25222 | CK_DLL_CTOR( OnePole_ctor ) |
| 25223 | { |
| 25224 | // initialize member object |
| 25225 | OBJ_MEMBER_UINT(SELF, OnePole_offset_data) = (t_CKUINT)new OnePole(); |
| 25226 | } |
| 25227 | |
| 25228 | |
| 25229 | //----------------------------------------------------------------------------- |
| 25230 | // name: OnePole_dtor() |
| 25231 | // desc: DTOR function ... |
| 25232 | //----------------------------------------------------------------------------- |
| 25233 | CK_DLL_DTOR( OnePole_dtor ) |
| 25234 | { |
| 25235 | delete (OnePole *)OBJ_MEMBER_UINT(SELF, OnePole_offset_data); |
| 25236 | OBJ_MEMBER_UINT(SELF, OnePole_offset_data) = 0; |
| 25237 | } |
| 25238 | |
| 25239 | |
| 25240 | //----------------------------------------------------------------------------- |
| 25241 | // name: OnePole_tick() |
| 25242 | // desc: TICK function ... |
| 25243 | //----------------------------------------------------------------------------- |
| 25244 | CK_DLL_TICK( OnePole_tick ) |
| 25245 | { |
| 25246 | OnePole * m = (OnePole *)OBJ_MEMBER_UINT(SELF, OnePole_offset_data); |
| 25247 | *out = m->tick( in ); |
| 25248 | return TRUE; |
| 25249 | } |
| 25250 | |
| 25251 | |
| 25252 | //----------------------------------------------------------------------------- |
| 25253 | // name: OnePole_pmsg() |
| 25254 | // desc: PMSG function ... |
| 25255 | //----------------------------------------------------------------------------- |
| 25256 | CK_DLL_PMSG( OnePole_pmsg ) |
| 25257 | { |
| 25258 | return TRUE; |
| 25259 | } |
| 25260 | |
| 25261 | |
| 25262 | //----------------------------------------------------------------------------- |
| 25263 | // name: OnePole_ctrl_a1() |
| 25264 | // desc: CTRL function ... |
| 25265 | //----------------------------------------------------------------------------- |
| 25266 | CK_DLL_CTRL( OnePole_ctrl_a1 ) |
| 25267 | { |
| 25268 | OnePole * filter = (OnePole *)OBJ_MEMBER_UINT(SELF, OnePole_offset_data); |
| 25269 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25270 | filter->setA1( f ); |
| 25271 | RETURN->v_float = (t_CKFLOAT) filter->a[1]; |
| 25272 | } |
| 25273 | |
| 25274 | |
| 25275 | //----------------------------------------------------------------------------- |
| 25276 | // name: OnePole_cget_a1() |
| 25277 | // desc: CGET function ... |
| 25278 | //----------------------------------------------------------------------------- |
| 25279 | CK_DLL_CGET( OnePole_cget_a1 ) |
| 25280 | { |
| 25281 | OnePole * filter = (OnePole *)OBJ_MEMBER_UINT(SELF, OnePole_offset_data); |
| 25282 | RETURN->v_float = (t_CKFLOAT) filter->a[1]; |
| 25283 | } |
| 25284 | |
| 25285 | |
| 25286 | //----------------------------------------------------------------------------- |
| 25287 | // name: OnePole_ctrl_b0() |
| 25288 | // desc: CTRL function ... |
| 25289 | //----------------------------------------------------------------------------- |
| 25290 | CK_DLL_CTRL( OnePole_ctrl_b0 ) |
| 25291 | { |
| 25292 | OnePole * filter = (OnePole *)OBJ_MEMBER_UINT(SELF, OnePole_offset_data); |
| 25293 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25294 | filter->setB0( f ); |
| 25295 | RETURN->v_float = (t_CKFLOAT) filter->b[0]; |
| 25296 | } |
| 25297 | |
| 25298 | |
| 25299 | //----------------------------------------------------------------------------- |
| 25300 | // name: OnePole_cget_b0() |
| 25301 | // desc: CGET function ... |
| 25302 | //----------------------------------------------------------------------------- |
| 25303 | CK_DLL_CGET( OnePole_cget_b0 ) |
| 25304 | { |
| 25305 | OnePole * filter = (OnePole *)OBJ_MEMBER_UINT(SELF, OnePole_offset_data); |
| 25306 | RETURN->v_float = (t_CKFLOAT) filter->b[0]; |
| 25307 | } |
| 25308 | |
| 25309 | |
| 25310 | //----------------------------------------------------------------------------- |
| 25311 | // name: OnePole_ctrl_pole() |
| 25312 | // desc: CTRL function ... |
| 25313 | //----------------------------------------------------------------------------- |
| 25314 | CK_DLL_CTRL( OnePole_ctrl_pole ) |
| 25315 | { |
| 25316 | OnePole * filter = (OnePole *)OBJ_MEMBER_UINT(SELF, OnePole_offset_data); |
| 25317 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25318 | filter->setPole( f ); |
| 25319 | RETURN->v_float = (t_CKFLOAT) -filter->a[1]; |
| 25320 | } |
| 25321 | |
| 25322 | |
| 25323 | //----------------------------------------------------------------------------- |
| 25324 | // name: OnePole_cget_pole() |
| 25325 | // desc: CGET function ... |
| 25326 | //----------------------------------------------------------------------------- |
| 25327 | CK_DLL_CGET( OnePole_cget_pole ) |
| 25328 | { |
| 25329 | OnePole * filter = (OnePole *)OBJ_MEMBER_UINT(SELF, OnePole_offset_data); |
| 25330 | RETURN->v_float = (t_CKFLOAT) -filter->a[1]; |
| 25331 | } |
| 25332 | |
| 25333 | |
| 25334 | |
| 25335 | //TwoPole functions |
| 25336 | |
| 25337 | //----------------------------------------------------------------------------- |
| 25338 | // name: TwoPole_ctor() |
| 25339 | // desc: CTOR function ... |
| 25340 | //----------------------------------------------------------------------------- |
| 25341 | CK_DLL_CTOR( TwoPole_ctor ) |
| 25342 | { |
| 25343 | // initialize member object |
| 25344 | OBJ_MEMBER_UINT(SELF, TwoPole_offset_data) = (t_CKUINT)new TwoPole(); |
| 25345 | } |
| 25346 | |
| 25347 | |
| 25348 | //----------------------------------------------------------------------------- |
| 25349 | // name: TwoPole_dtor() |
| 25350 | // desc: DTOR function ... |
| 25351 | //----------------------------------------------------------------------------- |
| 25352 | CK_DLL_DTOR( TwoPole_dtor ) |
| 25353 | { |
| 25354 | delete (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25355 | OBJ_MEMBER_UINT(SELF, TwoPole_offset_data) = 0; |
| 25356 | } |
| 25357 | |
| 25358 | |
| 25359 | //----------------------------------------------------------------------------- |
| 25360 | // name: TwoPole_tick() |
| 25361 | // desc: TICK function ... |
| 25362 | //----------------------------------------------------------------------------- |
| 25363 | CK_DLL_TICK( TwoPole_tick ) |
| 25364 | { |
| 25365 | TwoPole * m = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25366 | *out = m->tick( in ); |
| 25367 | return TRUE; |
| 25368 | } |
| 25369 | |
| 25370 | |
| 25371 | //----------------------------------------------------------------------------- |
| 25372 | // name: TwoPole_pmsg() |
| 25373 | // desc: PMSG function ... |
| 25374 | //----------------------------------------------------------------------------- |
| 25375 | CK_DLL_PMSG( TwoPole_pmsg ) |
| 25376 | { |
| 25377 | return TRUE; |
| 25378 | } |
| 25379 | |
| 25380 | |
| 25381 | //----------------------------------------------------------------------------- |
| 25382 | // name: TwoPole_ctrl_a1() |
| 25383 | // desc: CTRL function ... |
| 25384 | //----------------------------------------------------------------------------- |
| 25385 | CK_DLL_CTRL( TwoPole_ctrl_a1 ) |
| 25386 | { |
| 25387 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25388 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25389 | filter->setA1( f ); |
| 25390 | RETURN->v_float = (t_CKFLOAT) filter->a[1]; |
| 25391 | } |
| 25392 | |
| 25393 | |
| 25394 | //----------------------------------------------------------------------------- |
| 25395 | // name: TwoPole_cget_a1() |
| 25396 | // desc: CGET function ... |
| 25397 | //----------------------------------------------------------------------------- |
| 25398 | CK_DLL_CGET( TwoPole_cget_a1 ) |
| 25399 | { |
| 25400 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25401 | RETURN->v_float = (t_CKFLOAT) filter->a[1]; |
| 25402 | } |
| 25403 | |
| 25404 | |
| 25405 | //----------------------------------------------------------------------------- |
| 25406 | // name: TwoPole_ctrl_a2() |
| 25407 | // desc: CTRL function ... |
| 25408 | //----------------------------------------------------------------------------- |
| 25409 | CK_DLL_CTRL( TwoPole_ctrl_a2 ) |
| 25410 | { |
| 25411 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25412 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25413 | filter->setA2( f ); |
| 25414 | RETURN->v_float = (t_CKFLOAT) filter->a[2]; |
| 25415 | } |
| 25416 | |
| 25417 | |
| 25418 | //----------------------------------------------------------------------------- |
| 25419 | // name: TwoPole_cget_a2() |
| 25420 | // desc: CGET function ... |
| 25421 | //----------------------------------------------------------------------------- |
| 25422 | CK_DLL_CGET( TwoPole_cget_a2 ) |
| 25423 | { |
| 25424 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25425 | RETURN->v_float = (t_CKFLOAT) filter->a[2]; |
| 25426 | } |
| 25427 | |
| 25428 | |
| 25429 | //----------------------------------------------------------------------------- |
| 25430 | // name: TwoPole_ctrl_b0() |
| 25431 | // desc: CTRL function ... |
| 25432 | //----------------------------------------------------------------------------- |
| 25433 | CK_DLL_CTRL( TwoPole_ctrl_b0 ) |
| 25434 | { |
| 25435 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25436 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25437 | filter->setB0( f ); |
| 25438 | RETURN->v_float = (t_CKFLOAT) filter->b[0]; |
| 25439 | } |
| 25440 | |
| 25441 | |
| 25442 | //----------------------------------------------------------------------------- |
| 25443 | // name: TwoPole_cget_b0() |
| 25444 | // desc: CGET function ... |
| 25445 | //----------------------------------------------------------------------------- |
| 25446 | CK_DLL_CGET( TwoPole_cget_b0 ) |
| 25447 | { |
| 25448 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25449 | RETURN->v_float = (t_CKFLOAT) filter->b[0]; |
| 25450 | } |
| 25451 | |
| 25452 | |
| 25453 | //----------------------------------------------------------------------------- |
| 25454 | // name: TwoPole_ctrl_freq() |
| 25455 | // desc: CTRL function ... |
| 25456 | //----------------------------------------------------------------------------- |
| 25457 | CK_DLL_CTRL( TwoPole_ctrl_freq ) |
| 25458 | { |
| 25459 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25460 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25461 | filter->ck_setResFreq( f ); |
| 25462 | RETURN->v_float = (t_CKFLOAT) filter->m_resFreq; |
| 25463 | } |
| 25464 | |
| 25465 | |
| 25466 | //----------------------------------------------------------------------------- |
| 25467 | // name: TwoPole_cget_freq() |
| 25468 | // desc: CGET function ... |
| 25469 | //----------------------------------------------------------------------------- |
| 25470 | CK_DLL_CGET( TwoPole_cget_freq ) |
| 25471 | { |
| 25472 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25473 | RETURN->v_float = (t_CKFLOAT) filter->m_resFreq; |
| 25474 | } |
| 25475 | |
| 25476 | |
| 25477 | //----------------------------------------------------------------------------- |
| 25478 | // name: TwoPole_ctrl_radius() |
| 25479 | // desc: CTRL function ... |
| 25480 | //----------------------------------------------------------------------------- |
| 25481 | CK_DLL_CTRL( TwoPole_ctrl_radius ) |
| 25482 | { |
| 25483 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25484 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25485 | filter->ck_setResRad( f ); |
| 25486 | RETURN->v_float = (t_CKFLOAT) filter->m_resRad; |
| 25487 | } |
| 25488 | |
| 25489 | |
| 25490 | //----------------------------------------------------------------------------- |
| 25491 | // name: TwoPole_cget_radius() |
| 25492 | // desc: CGET function ... |
| 25493 | //----------------------------------------------------------------------------- |
| 25494 | CK_DLL_CGET( TwoPole_cget_radius ) |
| 25495 | { |
| 25496 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25497 | RETURN->v_float = (t_CKFLOAT) filter->m_resRad; |
| 25498 | } |
| 25499 | |
| 25500 | |
| 25501 | //----------------------------------------------------------------------------- |
| 25502 | // name: TwoPole_ctrl_norm() |
| 25503 | // desc: CTRL function ... |
| 25504 | //----------------------------------------------------------------------------- |
| 25505 | CK_DLL_CTRL( TwoPole_ctrl_norm ) |
| 25506 | { |
| 25507 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25508 | bool b = ( GET_CK_INT(ARGS) != 0 ); |
| 25509 | filter->ck_setResNorm( b ); |
| 25510 | RETURN->v_int = (t_CKINT) filter->m_resNorm; |
| 25511 | } |
| 25512 | |
| 25513 | |
| 25514 | //----------------------------------------------------------------------------- |
| 25515 | // name: TwoPole_cget_norm() |
| 25516 | // desc: CGET function ... |
| 25517 | //----------------------------------------------------------------------------- |
| 25518 | CK_DLL_CGET( TwoPole_cget_norm ) |
| 25519 | { |
| 25520 | TwoPole * filter = (TwoPole *)OBJ_MEMBER_UINT(SELF, TwoPole_offset_data); |
| 25521 | RETURN->v_int = (t_CKINT) filter->m_resNorm; |
| 25522 | } |
| 25523 | |
| 25524 | |
| 25525 | |
| 25526 | |
| 25527 | //OneZero functions |
| 25528 | |
| 25529 | //----------------------------------------------------------------------------- |
| 25530 | // name: OneZero_ctor() |
| 25531 | // desc: CTOR function ... |
| 25532 | //----------------------------------------------------------------------------- |
| 25533 | CK_DLL_CTOR( OneZero_ctor ) |
| 25534 | { |
| 25535 | // initialize member object |
| 25536 | OBJ_MEMBER_UINT(SELF, OneZero_offset_data) = (t_CKUINT) new OneZero(); |
| 25537 | } |
| 25538 | |
| 25539 | |
| 25540 | //----------------------------------------------------------------------------- |
| 25541 | // name: OneZero_dtor() |
| 25542 | // desc: DTOR function ... |
| 25543 | //----------------------------------------------------------------------------- |
| 25544 | CK_DLL_DTOR( OneZero_dtor ) |
| 25545 | { |
| 25546 | delete (OneZero *)OBJ_MEMBER_UINT(SELF, OneZero_offset_data); |
| 25547 | OBJ_MEMBER_UINT(SELF, OneZero_offset_data) = 0; |
| 25548 | } |
| 25549 | |
| 25550 | |
| 25551 | //----------------------------------------------------------------------------- |
| 25552 | // name: OneZero_tick() |
| 25553 | // desc: TICK function ... |
| 25554 | //----------------------------------------------------------------------------- |
| 25555 | CK_DLL_TICK( OneZero_tick ) |
| 25556 | { |
| 25557 | OneZero * m = (OneZero *)OBJ_MEMBER_UINT(SELF, OneZero_offset_data); |
| 25558 | *out = m->tick( in ); |
| 25559 | return TRUE; |
| 25560 | } |
| 25561 | |
| 25562 | |
| 25563 | //----------------------------------------------------------------------------- |
| 25564 | // name: OneZero_pmsg() |
| 25565 | // desc: PMSG function ... |
| 25566 | //----------------------------------------------------------------------------- |
| 25567 | CK_DLL_PMSG( OneZero_pmsg ) |
| 25568 | { |
| 25569 | return TRUE; |
| 25570 | } |
| 25571 | |
| 25572 | |
| 25573 | //----------------------------------------------------------------------------- |
| 25574 | // name: OneZero_ctrl_zero() |
| 25575 | // desc: CTRL function ... |
| 25576 | //----------------------------------------------------------------------------- |
| 25577 | CK_DLL_CTRL( OneZero_ctrl_zero ) |
| 25578 | { |
| 25579 | OneZero * filter = (OneZero *)OBJ_MEMBER_UINT(SELF, OneZero_offset_data); |
| 25580 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25581 | filter->setZero( f ); |
| 25582 | double zeeroo = ( filter->b[0] == 0 ) ? 0 : -filter->b[1] / filter->b[0]; |
| 25583 | RETURN->v_float = (t_CKFLOAT) zeeroo; |
| 25584 | } |
| 25585 | |
| 25586 | |
| 25587 | //----------------------------------------------------------------------------- |
| 25588 | // name: OneZero_cget_zero() |
| 25589 | // desc: CGET function ... |
| 25590 | //----------------------------------------------------------------------------- |
| 25591 | CK_DLL_CGET( OneZero_cget_zero ) |
| 25592 | { |
| 25593 | OneZero * filter = (OneZero *)OBJ_MEMBER_UINT(SELF, OneZero_offset_data); |
| 25594 | double zeeroo = ( filter->b[0] == 0 ) ? 0 : -filter->b[1] / filter->b[0]; |
| 25595 | RETURN->v_float = (t_CKFLOAT)zeeroo; |
| 25596 | } |
| 25597 | |
| 25598 | |
| 25599 | //----------------------------------------------------------------------------- |
| 25600 | // name: OneZero_ctrl_b0() |
| 25601 | // desc: CTRL function ... |
| 25602 | //----------------------------------------------------------------------------- |
| 25603 | CK_DLL_CTRL( OneZero_ctrl_b0 ) |
| 25604 | { |
| 25605 | OneZero * filter = (OneZero *)OBJ_MEMBER_UINT(SELF, OneZero_offset_data); |
| 25606 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25607 | filter->setB0( f ); |
| 25608 | RETURN->v_float = (t_CKFLOAT) filter->b[0]; |
| 25609 | } |
| 25610 | |
| 25611 | |
| 25612 | //----------------------------------------------------------------------------- |
| 25613 | // name: OneZero_cget_b0() |
| 25614 | // desc: CGET function ... |
| 25615 | //----------------------------------------------------------------------------- |
| 25616 | CK_DLL_CGET( OneZero_cget_b0 ) |
| 25617 | { |
| 25618 | OneZero * filter = (OneZero *)OBJ_MEMBER_UINT(SELF, OneZero_offset_data); |
| 25619 | RETURN->v_float = (t_CKFLOAT) filter->b[0]; |
| 25620 | } |
| 25621 | |
| 25622 | |
| 25623 | //----------------------------------------------------------------------------- |
| 25624 | // name: OneZero_ctrl_b1() |
| 25625 | // desc: CTRL function ... |
| 25626 | //----------------------------------------------------------------------------- |
| 25627 | CK_DLL_CTRL( OneZero_ctrl_b1 ) |
| 25628 | { |
| 25629 | OneZero * filter = (OneZero *)OBJ_MEMBER_UINT(SELF, OneZero_offset_data); |
| 25630 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25631 | filter->setB1( f ); |
| 25632 | RETURN->v_float = (t_CKFLOAT) filter->b[1]; |
| 25633 | } |
| 25634 | |
| 25635 | |
| 25636 | //----------------------------------------------------------------------------- |
| 25637 | // name: OneZero_cget_b1() |
| 25638 | // desc: CGET function ... |
| 25639 | //----------------------------------------------------------------------------- |
| 25640 | CK_DLL_CGET( OneZero_cget_b1 ) |
| 25641 | { |
| 25642 | |
| 25643 | OneZero * filter = (OneZero *)OBJ_MEMBER_UINT(SELF, OneZero_offset_data); |
| 25644 | RETURN->v_float = (t_CKFLOAT) filter->b[1]; |
| 25645 | } |
| 25646 | |
| 25647 | |
| 25648 | //TwoZero functions |
| 25649 | |
| 25650 | //----------------------------------------------------------------------------- |
| 25651 | // name: TwoZero_ctor() |
| 25652 | // desc: CTOR function ... |
| 25653 | //----------------------------------------------------------------------------- |
| 25654 | CK_DLL_CTOR( TwoZero_ctor ) |
| 25655 | { |
| 25656 | // initialize member object |
| 25657 | OBJ_MEMBER_UINT(SELF, TwoZero_offset_data) = (t_CKUINT)new TwoZero(); |
| 25658 | } |
| 25659 | |
| 25660 | |
| 25661 | //----------------------------------------------------------------------------- |
| 25662 | // name: TwoZero_dtor() |
| 25663 | // desc: DTOR function ... |
| 25664 | //----------------------------------------------------------------------------- |
| 25665 | CK_DLL_DTOR( TwoZero_dtor ) |
| 25666 | { |
| 25667 | delete (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25668 | OBJ_MEMBER_UINT(SELF, TwoZero_offset_data) = 0; |
| 25669 | } |
| 25670 | |
| 25671 | |
| 25672 | //----------------------------------------------------------------------------- |
| 25673 | // name: TwoZero_tick() |
| 25674 | // desc: TICK function ... |
| 25675 | //----------------------------------------------------------------------------- |
| 25676 | CK_DLL_TICK( TwoZero_tick ) |
| 25677 | { |
| 25678 | TwoZero * m = (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25679 | *out = m->tick( in ); |
| 25680 | return TRUE; |
| 25681 | } |
| 25682 | |
| 25683 | |
| 25684 | //----------------------------------------------------------------------------- |
| 25685 | // name: TwoZero_pmsg() |
| 25686 | // desc: PMSG function ... |
| 25687 | //----------------------------------------------------------------------------- |
| 25688 | CK_DLL_PMSG( TwoZero_pmsg ) |
| 25689 | { |
| 25690 | return TRUE; |
| 25691 | } |
| 25692 | |
| 25693 | |
| 25694 | //----------------------------------------------------------------------------- |
| 25695 | // name: TwoZero_ctrl_b0() |
| 25696 | // desc: CTRL function ... |
| 25697 | //----------------------------------------------------------------------------- |
| 25698 | CK_DLL_CTRL( TwoZero_ctrl_b0 ) |
| 25699 | { |
| 25700 | TwoZero * filter = (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25701 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25702 | filter->setB0( f ); |
| 25703 | } |
| 25704 | |
| 25705 | |
| 25706 | //----------------------------------------------------------------------------- |
| 25707 | // name: TwoZero_cget_b0() |
| 25708 | // desc: CGET function ... |
| 25709 | //----------------------------------------------------------------------------- |
| 25710 | CK_DLL_CGET( TwoZero_cget_b0 ) |
| 25711 | { |
| 25712 | TwoZero * filter = (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25713 | RETURN->v_float = (t_CKFLOAT) filter->b[0]; |
| 25714 | } |
| 25715 | |
| 25716 | |
| 25717 | //----------------------------------------------------------------------------- |
| 25718 | // name: TwoZero_ctrl_b1() |
| 25719 | // desc: CTRL function ... |
| 25720 | //----------------------------------------------------------------------------- |
| 25721 | CK_DLL_CTRL( TwoZero_ctrl_b1 ) |
| 25722 | { |
| 25723 | TwoZero * filter = (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25724 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25725 | filter->setB1( f ); |
| 25726 | } |
| 25727 | |
| 25728 | //----------------------------------------------------------------------------- |
| 25729 | // name: TwoZero_cget_b1() |
| 25730 | // desc: CGET function ... |
| 25731 | //----------------------------------------------------------------------------- |
| 25732 | CK_DLL_CGET( TwoZero_cget_b1 ) |
| 25733 | { |
| 25734 | TwoZero * filter = (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25735 | RETURN->v_float = (t_CKFLOAT) filter->b[1]; |
| 25736 | } |
| 25737 | |
| 25738 | //----------------------------------------------------------------------------- |
| 25739 | // name: TwoZero_ctrl_b2() |
| 25740 | // desc: CTRL function ... |
| 25741 | //----------------------------------------------------------------------------- |
| 25742 | CK_DLL_CTRL( TwoZero_ctrl_b2 ) |
| 25743 | { |
| 25744 | TwoZero * filter = (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25745 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25746 | filter->setB2( f ); |
| 25747 | } |
| 25748 | |
| 25749 | |
| 25750 | //----------------------------------------------------------------------------- |
| 25751 | // name: TwoZero_cget_b2() |
| 25752 | // desc: CGET function ... |
| 25753 | //----------------------------------------------------------------------------- |
| 25754 | CK_DLL_CGET( TwoZero_cget_b2 ) |
| 25755 | { |
| 25756 | TwoZero * filter = (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25757 | RETURN->v_float = (t_CKFLOAT) filter->b[2]; |
| 25758 | } |
| 25759 | |
| 25760 | |
| 25761 | //----------------------------------------------------------------------------- |
| 25762 | // name: TwoZero_ctrl_freq() |
| 25763 | // desc: CTRL function ... |
| 25764 | //----------------------------------------------------------------------------- |
| 25765 | CK_DLL_CTRL( TwoZero_ctrl_freq ) |
| 25766 | { |
| 25767 | TwoZero * filter = (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25768 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25769 | filter->ck_setNotchFreq( f ); |
| 25770 | } |
| 25771 | |
| 25772 | |
| 25773 | //----------------------------------------------------------------------------- |
| 25774 | // name: TwoZero_cget_freq() |
| 25775 | // desc: CGET function ... |
| 25776 | //----------------------------------------------------------------------------- |
| 25777 | CK_DLL_CGET( TwoZero_cget_freq ) |
| 25778 | { |
| 25779 | TwoZero * filter = (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25780 | RETURN->v_float = (t_CKFLOAT) filter->m_notchFreq; |
| 25781 | } |
| 25782 | |
| 25783 | |
| 25784 | //----------------------------------------------------------------------------- |
| 25785 | // name: TwoZero_ctrl_radius() |
| 25786 | // desc: CTRL function ... |
| 25787 | //----------------------------------------------------------------------------- |
| 25788 | CK_DLL_CTRL( TwoZero_ctrl_radius ) |
| 25789 | { |
| 25790 | TwoZero * filter = (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25791 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25792 | filter->ck_setNotchRad( f ); |
| 25793 | } |
| 25794 | |
| 25795 | //----------------------------------------------------------------------------- |
| 25796 | // name: TwoZero_cget_radius() |
| 25797 | // desc: CGET function ... |
| 25798 | //----------------------------------------------------------------------------- |
| 25799 | CK_DLL_CGET( TwoZero_cget_radius ) |
| 25800 | { |
| 25801 | TwoZero * filter = (TwoZero *)OBJ_MEMBER_UINT(SELF, TwoZero_offset_data); |
| 25802 | RETURN->v_float = (t_CKFLOAT) filter->m_notchRad; |
| 25803 | } |
| 25804 | |
| 25805 | |
| 25806 | |
| 25807 | //PoleZero functions |
| 25808 | |
| 25809 | //----------------------------------------------------------------------------- |
| 25810 | // name: PoleZero_ctor() |
| 25811 | // desc: CTOR function ... |
| 25812 | //----------------------------------------------------------------------------- |
| 25813 | CK_DLL_CTOR( PoleZero_ctor ) |
| 25814 | { |
| 25815 | // initialize member object |
| 25816 | OBJ_MEMBER_UINT(SELF, PoleZero_offset_data) = (t_CKUINT) new PoleZero(); |
| 25817 | } |
| 25818 | |
| 25819 | |
| 25820 | //----------------------------------------------------------------------------- |
| 25821 | // name: PoleZero_dtor() |
| 25822 | // desc: DTOR function ... |
| 25823 | //----------------------------------------------------------------------------- |
| 25824 | CK_DLL_DTOR( PoleZero_dtor ) |
| 25825 | { |
| 25826 | delete (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25827 | OBJ_MEMBER_UINT(SELF, PoleZero_offset_data) = 0; |
| 25828 | } |
| 25829 | |
| 25830 | |
| 25831 | //----------------------------------------------------------------------------- |
| 25832 | // name: PoleZero_tick() |
| 25833 | // desc: TICK function ... |
| 25834 | //----------------------------------------------------------------------------- |
| 25835 | CK_DLL_TICK( PoleZero_tick ) |
| 25836 | { |
| 25837 | PoleZero * m = (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25838 | *out = m->tick( in ); |
| 25839 | return TRUE; |
| 25840 | } |
| 25841 | |
| 25842 | |
| 25843 | //----------------------------------------------------------------------------- |
| 25844 | // name: PoleZero_pmsg() |
| 25845 | // desc: PMSG function ... |
| 25846 | //----------------------------------------------------------------------------- |
| 25847 | CK_DLL_PMSG( PoleZero_pmsg ) |
| 25848 | { |
| 25849 | return TRUE; |
| 25850 | } |
| 25851 | |
| 25852 | |
| 25853 | //----------------------------------------------------------------------------- |
| 25854 | // name: PoleZero_ctrl_a1() |
| 25855 | // desc: CTRL function ... |
| 25856 | //----------------------------------------------------------------------------- |
| 25857 | CK_DLL_CTRL( PoleZero_ctrl_a1 ) |
| 25858 | { |
| 25859 | PoleZero * filter = (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25860 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25861 | filter->setA1( f ); |
| 25862 | RETURN->v_float = (t_CKFLOAT) filter->a[1]; |
| 25863 | } |
| 25864 | |
| 25865 | |
| 25866 | //----------------------------------------------------------------------------- |
| 25867 | // name: PoleZero_cget_a1() |
| 25868 | // desc: CGET function ... |
| 25869 | //----------------------------------------------------------------------------- |
| 25870 | CK_DLL_CGET( PoleZero_cget_a1 ) |
| 25871 | { |
| 25872 | PoleZero * filter = (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25873 | RETURN->v_float = (t_CKFLOAT) filter->a[1]; |
| 25874 | } |
| 25875 | |
| 25876 | |
| 25877 | //----------------------------------------------------------------------------- |
| 25878 | // name: PoleZero_ctrl_b0() |
| 25879 | // desc: CTRL function ... |
| 25880 | //----------------------------------------------------------------------------- |
| 25881 | CK_DLL_CTRL( PoleZero_ctrl_b0 ) |
| 25882 | { |
| 25883 | PoleZero * filter = (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25884 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25885 | filter->setB0( f ); |
| 25886 | RETURN->v_float = (t_CKFLOAT) filter->b[0]; |
| 25887 | } |
| 25888 | |
| 25889 | |
| 25890 | //----------------------------------------------------------------------------- |
| 25891 | // name: PoleZero_cget_b0() |
| 25892 | // desc: CGET function ... |
| 25893 | //----------------------------------------------------------------------------- |
| 25894 | CK_DLL_CGET( PoleZero_cget_b0 ) |
| 25895 | { |
| 25896 | PoleZero * filter = (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25897 | RETURN->v_float = (t_CKFLOAT) filter->b[0]; |
| 25898 | } |
| 25899 | |
| 25900 | |
| 25901 | |
| 25902 | //----------------------------------------------------------------------------- |
| 25903 | // name: PoleZero_ctrl_b1() |
| 25904 | // desc: CTRL function ... |
| 25905 | //----------------------------------------------------------------------------- |
| 25906 | CK_DLL_CTRL( PoleZero_ctrl_b1 ) |
| 25907 | { |
| 25908 | PoleZero * filter = (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25909 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25910 | filter->setB1( f ); |
| 25911 | RETURN->v_float = (t_CKFLOAT) filter->b[1]; |
| 25912 | } |
| 25913 | |
| 25914 | |
| 25915 | //----------------------------------------------------------------------------- |
| 25916 | // name: PoleZero_cget_b1() |
| 25917 | // desc: CGET function ... |
| 25918 | //----------------------------------------------------------------------------- |
| 25919 | CK_DLL_CGET( PoleZero_cget_b1 ) |
| 25920 | { |
| 25921 | PoleZero * filter = (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25922 | RETURN->v_float = (t_CKFLOAT) filter->b[1]; |
| 25923 | } |
| 25924 | |
| 25925 | |
| 25926 | //----------------------------------------------------------------------------- |
| 25927 | // name: PoleZero_ctrl_allpass() |
| 25928 | // desc: CTRL function ... |
| 25929 | //----------------------------------------------------------------------------- |
| 25930 | CK_DLL_CTRL( PoleZero_ctrl_allpass ) |
| 25931 | { |
| 25932 | PoleZero * filter = (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25933 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25934 | filter->setAllpass( f ); |
| 25935 | RETURN->v_float = (t_CKFLOAT) filter->b[0]; |
| 25936 | } |
| 25937 | |
| 25938 | |
| 25939 | //----------------------------------------------------------------------------- |
| 25940 | // name: PoleZero_cget_allpass() |
| 25941 | // desc: CGET function ... |
| 25942 | //----------------------------------------------------------------------------- |
| 25943 | CK_DLL_CGET( PoleZero_cget_allpass ) |
| 25944 | { |
| 25945 | PoleZero * filter = (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25946 | RETURN->v_float = (t_CKFLOAT) filter->b[0]; |
| 25947 | } |
| 25948 | |
| 25949 | |
| 25950 | //----------------------------------------------------------------------------- |
| 25951 | // name: PoleZero_ctrl_blockZero() |
| 25952 | // desc: CTRL function ... |
| 25953 | //----------------------------------------------------------------------------- |
| 25954 | CK_DLL_CTRL( PoleZero_ctrl_blockZero ) |
| 25955 | { |
| 25956 | PoleZero * filter = (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25957 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 25958 | filter->setBlockZero( f ); |
| 25959 | RETURN->v_float = (t_CKFLOAT) -filter->a[1]; |
| 25960 | } |
| 25961 | |
| 25962 | |
| 25963 | //----------------------------------------------------------------------------- |
| 25964 | // name: PoleZero_cget_blockZero() |
| 25965 | // desc: CGET function ... |
| 25966 | //----------------------------------------------------------------------------- |
| 25967 | CK_DLL_CGET( PoleZero_cget_blockZero ) |
| 25968 | { |
| 25969 | PoleZero * filter = (PoleZero *)OBJ_MEMBER_UINT(SELF, PoleZero_offset_data); |
| 25970 | RETURN->v_float = (t_CKFLOAT) -filter->a[1]; |
| 25971 | } |
| 25972 | |
| 25973 | |
| 25974 | |
| 25975 | |
| 25976 | //----------------------------------------------------------------------------- |
| 25977 | // FM functions |
| 25978 | //----------------------------------------------------------------------------- |
| 25979 | // name: FM_ctor() |
| 25980 | // desc: CTOR function ... |
| 25981 | //----------------------------------------------------------------------------- |
| 25982 | CK_DLL_CTOR( FM_ctor ) |
| 25983 | { |
| 25984 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = 0; |
| 25985 | } |
| 25986 | |
| 25987 | |
| 25988 | //----------------------------------------------------------------------------- |
| 25989 | // name: FM_dtor() |
| 25990 | // desc: DTOR function ... |
| 25991 | //----------------------------------------------------------------------------- |
| 25992 | CK_DLL_DTOR( FM_dtor ) |
| 25993 | { |
| 25994 | // delete (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 25995 | } |
| 25996 | |
| 25997 | |
| 25998 | // 1.5.0.0 | (ge) added for error report |
| 25999 | //----------------------------------------------------------------------------- |
| 26000 | // name: FM_tick() |
| 26001 | // desc: TICK function ... |
| 26002 | //----------------------------------------------------------------------------- |
| 26003 | CK_DLL_TICK( FM_tick ) |
| 26004 | { |
| 26005 | // FM should be NULL |
| 26006 | // FM * m = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26007 | |
| 26008 | // generally, we should not get here -- but is possible since there are |
| 26009 | // abstract classes, such as this one, but currently chuck has no |
| 26010 | // provisions for marking classes as abstract... this is a workaround |
| 26011 | // 1.5.0.0 | (ge) changed CK_FPRINTF_STDERR to EM_log; allow program to proceed |
| 26012 | EM_log( CK_LOG_WARNING, "(STK) error -- FM.tick() is abstract!" ); |
| 26013 | EM_log( CK_LOG_WARNING, "(STK) |- likely FM was declared/used directly," ); |
| 26014 | EM_log( CK_LOG_WARNING, "(STK) |- instead of a subclass of FM" ); |
| 26015 | |
| 26016 | // TODO: type system should not allow direct declaration of abstract classes |
| 26017 | // TODO: should detect, give a compiler error, with a short explanation and |
| 26018 | // TODO: suggestion on what to do: e.g., |
| 26019 | // TODO: "XXX cannot be instantiated directly (use '@' to declare a reference)" |
| 26020 | |
| 26021 | // 1.5.0.0 | (ge) commented out to avoid a potentially confusing crash |
| 26022 | // *out = m->tick(); |
| 26023 | // instead we will return silence |
| 26024 | *out = 0; |
| 26025 | |
| 26026 | return TRUE; |
| 26027 | } |
| 26028 | |
| 26029 | |
| 26030 | //----------------------------------------------------------------------------- |
| 26031 | // name: FM_pmsg() |
| 26032 | // desc: PMSG function ... |
| 26033 | //----------------------------------------------------------------------------- |
| 26034 | CK_DLL_PMSG( FM_pmsg ) |
| 26035 | { |
| 26036 | return TRUE; |
| 26037 | } |
| 26038 | |
| 26039 | |
| 26040 | //----------------------------------------------------------------------------- |
| 26041 | // 1.4.1.0 ***** REPAIRATHON2021 NEW SET/GET ACCESSING FUNCTIONS ***** |
| 26042 | //----------------------------------------------------------------------------- |
| 26043 | // name: FM_ctrl_opADSR() |
| 26044 | // desc: CTRL function ... |
| 26045 | //----------------------------------------------------------------------------- |
| 26046 | CK_DLL_CTRL( FM_ctrl_opADSR ) |
| 26047 | { |
| 26048 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26049 | //--------------------------------------------------------------------- |
| 26050 | // check for base class pointer; throw exception and halt shred if NULL |
| 26051 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26052 | //--------------------------------------------------------------------- |
| 26053 | t_CKINT w = GET_NEXT_INT(ARGS); |
| 26054 | t_CKFLOAT a = GET_NEXT_FLOAT(ARGS); |
| 26055 | t_CKFLOAT d = GET_NEXT_FLOAT(ARGS); |
| 26056 | t_CKFLOAT s = GET_NEXT_FLOAT(ARGS); |
| 26057 | t_CKFLOAT r = GET_NEXT_FLOAT(ARGS); |
| 26058 | fm->setADSR(w, a, d, s, r); |
| 26059 | RETURN->v_int = w; |
| 26060 | } |
| 26061 | |
| 26062 | |
| 26063 | //----------------------------------------------------------------------------- |
| 26064 | // name: FM_ctrl_opGain() |
| 26065 | // desc: CTRL function ... |
| 26066 | //----------------------------------------------------------------------------- |
| 26067 | CK_DLL_CTRL( FM_ctrl_opGain ) |
| 26068 | { |
| 26069 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26070 | //--------------------------------------------------------------------- |
| 26071 | // check for base class pointer; throw exception and halt shred if NULL |
| 26072 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26073 | //--------------------------------------------------------------------- |
| 26074 | t_CKINT w = GET_NEXT_INT(ARGS); |
| 26075 | t_CKFLOAT g = GET_NEXT_FLOAT(ARGS); |
| 26076 | fm->setOpGain(w, g); |
| 26077 | RETURN->v_float = g; |
| 26078 | } |
| 26079 | |
| 26080 | |
| 26081 | //----------------------------------------------------------------------------- |
| 26082 | // name: FM_cget_opGain() |
| 26083 | // desc: CGET function ... |
| 26084 | //----------------------------------------------------------------------------- |
| 26085 | CK_DLL_CGET( FM_cget_opGain ) |
| 26086 | { |
| 26087 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26088 | //--------------------------------------------------------------------- |
| 26089 | // check for base class pointer; throw exception and halt shred if NULL |
| 26090 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26091 | //--------------------------------------------------------------------- |
| 26092 | t_CKINT w = GET_NEXT_INT(ARGS); |
| 26093 | RETURN->v_float = fm->getOpGain(w); |
| 26094 | } |
| 26095 | |
| 26096 | |
| 26097 | //----------------------------------------------------------------------------- |
| 26098 | // name: FM_ctrl_opAM() |
| 26099 | // desc: CTRL function ... |
| 26100 | //----------------------------------------------------------------------------- |
| 26101 | CK_DLL_CTRL( FM_ctrl_opAM ) |
| 26102 | { |
| 26103 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26104 | //--------------------------------------------------------------------- |
| 26105 | // check for base class pointer; throw exception and halt shred if NULL |
| 26106 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26107 | //--------------------------------------------------------------------- |
| 26108 | t_CKINT w = GET_NEXT_INT(ARGS); |
| 26109 | t_CKFLOAT g = GET_NEXT_FLOAT(ARGS); |
| 26110 | fm->setOpAM(w, g); |
| 26111 | RETURN->v_float = g; |
| 26112 | } |
| 26113 | |
| 26114 | |
| 26115 | //----------------------------------------------------------------------------- |
| 26116 | // name: FM_cget_opAM() |
| 26117 | // desc: CGET function ... |
| 26118 | //----------------------------------------------------------------------------- |
| 26119 | CK_DLL_CGET( FM_cget_opAM ) |
| 26120 | { |
| 26121 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26122 | //--------------------------------------------------------------------- |
| 26123 | // check for base class pointer; throw exception and halt shred if NULL |
| 26124 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26125 | //--------------------------------------------------------------------- |
| 26126 | t_CKINT w = GET_NEXT_INT(ARGS); |
| 26127 | RETURN->v_float = fm->getOpAM(w); |
| 26128 | } |
| 26129 | |
| 26130 | |
| 26131 | //----------------------------------------------------------------------------- |
| 26132 | // name: FM_ctrl_opWave() |
| 26133 | // desc: CTRL function ... |
| 26134 | //----------------------------------------------------------------------------- |
| 26135 | CK_DLL_CTRL( FM_ctrl_opWave ) |
| 26136 | { |
| 26137 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26138 | //--------------------------------------------------------------------- |
| 26139 | // check for base class pointer; throw exception and halt shred if NULL |
| 26140 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26141 | //--------------------------------------------------------------------- |
| 26142 | t_CKINT w = GET_NEXT_INT(ARGS); |
| 26143 | t_CKINT w2 = GET_NEXT_INT(ARGS); |
| 26144 | fm->setOpWave(w, w2); |
| 26145 | RETURN->v_int = w2; |
| 26146 | } |
| 26147 | |
| 26148 | |
| 26149 | //----------------------------------------------------------------------------- |
| 26150 | // name: FM_ctrl_opRatio() |
| 26151 | // desc: CTRL function ... |
| 26152 | //----------------------------------------------------------------------------- |
| 26153 | CK_DLL_CTRL( FM_ctrl_opRatio ) |
| 26154 | { |
| 26155 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26156 | //--------------------------------------------------------------------- |
| 26157 | // check for base class pointer; throw exception and halt shred if NULL |
| 26158 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26159 | //--------------------------------------------------------------------- |
| 26160 | t_CKINT w = GET_NEXT_INT(ARGS); |
| 26161 | t_CKFLOAT r = GET_NEXT_FLOAT(ARGS); |
| 26162 | fm->setRatio(w, r); |
| 26163 | RETURN->v_float = r; |
| 26164 | } |
| 26165 | |
| 26166 | |
| 26167 | //----------------------------------------------------------------------------- |
| 26168 | // name: FM_cget_opRatio() |
| 26169 | // desc: CGET function ... |
| 26170 | //----------------------------------------------------------------------------- |
| 26171 | CK_DLL_CGET( FM_cget_opRatio ) |
| 26172 | { |
| 26173 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26174 | //--------------------------------------------------------------------- |
| 26175 | // check for base class pointer; throw exception and halt shred if NULL |
| 26176 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26177 | //--------------------------------------------------------------------- |
| 26178 | t_CKINT w = GET_NEXT_INT(ARGS); |
| 26179 | RETURN->v_float = fm->getRatio(w); |
| 26180 | } |
| 26181 | |
| 26182 | |
| 26183 | //----------------------------------------------------------------------------- |
| 26184 | // name: FM_ctrl_op4Feedback() |
| 26185 | // desc: CTRL function ... |
| 26186 | //----------------------------------------------------------------------------- |
| 26187 | CK_DLL_CTRL( FM_ctrl_op4Feedback ) |
| 26188 | { |
| 26189 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26190 | //--------------------------------------------------------------------- |
| 26191 | // check for base class pointer; throw exception and halt shred if NULL |
| 26192 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26193 | //--------------------------------------------------------------------- |
| 26194 | t_CKFLOAT r = GET_NEXT_FLOAT(ARGS); |
| 26195 | fm->setOp4Feedback(r); |
| 26196 | RETURN->v_float = r; |
| 26197 | } |
| 26198 | |
| 26199 | |
| 26200 | //----------------------------------------------------------------------------- |
| 26201 | // name: FM_cget_op4Feedback() |
| 26202 | // desc: CGET function ... |
| 26203 | //----------------------------------------------------------------------------- |
| 26204 | CK_DLL_CGET( FM_cget_op4Feedback ) |
| 26205 | { |
| 26206 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26207 | //--------------------------------------------------------------------- |
| 26208 | // check for base class pointer; throw exception and halt shred if NULL |
| 26209 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26210 | //--------------------------------------------------------------------- |
| 26211 | RETURN->v_float = fm->getOp4Feedback(); |
| 26212 | } |
| 26213 | |
| 26214 | |
| 26215 | //----------------------------------------------------------------------------- |
| 26216 | // name: FM_cget_getFMTableGain() |
| 26217 | // desc: CGET function ... |
| 26218 | //----------------------------------------------------------------------------- |
| 26219 | CK_DLL_CGET( FM_cget_getFMTableGain ) |
| 26220 | { |
| 26221 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26222 | //--------------------------------------------------------------------- |
| 26223 | // check for base class pointer; throw exception and halt shred if NULL |
| 26224 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26225 | //--------------------------------------------------------------------- |
| 26226 | t_CKINT w = GET_NEXT_INT(ARGS); |
| 26227 | RETURN->v_float = fm->getFMTableGain(w); |
| 26228 | } |
| 26229 | |
| 26230 | //----------------------------------------------------------------------------- |
| 26231 | // name: FM_cget_getFMTableTime() |
| 26232 | // desc: CGET function ... |
| 26233 | //----------------------------------------------------------------------------- |
| 26234 | CK_DLL_CGET( FM_cget_getFMTableTime ) |
| 26235 | { |
| 26236 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26237 | //--------------------------------------------------------------------- |
| 26238 | // check for base class pointer; throw exception and halt shred if NULL |
| 26239 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26240 | //--------------------------------------------------------------------- |
| 26241 | t_CKINT w = GET_NEXT_INT(ARGS); |
| 26242 | RETURN->v_float = fm->getFMTableTime(w); |
| 26243 | } |
| 26244 | |
| 26245 | //----------------------------------------------------------------------------- |
| 26246 | // name: FM_cget_getFMTableSusLevel() |
| 26247 | // desc: CGET function ... |
| 26248 | //----------------------------------------------------------------------------- |
| 26249 | CK_DLL_CGET( FM_cget_getFMTableSusLevel ) |
| 26250 | { |
| 26251 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26252 | //--------------------------------------------------------------------- |
| 26253 | // check for base class pointer; throw exception and halt shred if NULL |
| 26254 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26255 | //--------------------------------------------------------------------- |
| 26256 | t_CKINT w = GET_NEXT_INT(ARGS); |
| 26257 | RETURN->v_float = fm->getFMTableSusLevel(w); |
| 26258 | } |
| 26259 | //----------------------------------------------------------------------------- |
| 26260 | // 1.4.1.0 ***** END BLOCK REPARIATHON2021 **** |
| 26261 | //----------------------------------------------------------------------------- |
| 26262 | |
| 26263 | |
| 26264 | //----------------------------------------------------------------------------- |
| 26265 | // name: FM_ctrl_modDepth() |
| 26266 | // desc: CTRL function ... |
| 26267 | //----------------------------------------------------------------------------- |
| 26268 | CK_DLL_CTRL( FM_ctrl_modDepth ) |
| 26269 | { |
| 26270 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26271 | //--------------------------------------------------------------------- |
| 26272 | // check for base class pointer; throw exception and halt shred if NULL |
| 26273 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26274 | //--------------------------------------------------------------------- |
| 26275 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 26276 | fm->setModulationDepth( f ); |
| 26277 | RETURN->v_float = f; |
| 26278 | } |
| 26279 | |
| 26280 | |
| 26281 | //----------------------------------------------------------------------------- |
| 26282 | // name: FM_cget_modDepth() |
| 26283 | // desc: CTRL function ... |
| 26284 | //----------------------------------------------------------------------------- |
| 26285 | CK_DLL_CTRL( FM_cget_modDepth ) |
| 26286 | { |
| 26287 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26288 | //--------------------------------------------------------------------- |
| 26289 | // check for base class pointer; throw exception and halt shred if NULL |
| 26290 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26291 | //--------------------------------------------------------------------- |
| 26292 | RETURN->v_float = fm->modDepth; |
| 26293 | } |
| 26294 | |
| 26295 | |
| 26296 | //----------------------------------------------------------------------------- |
| 26297 | // name: FM_ctrl_modSpeed() |
| 26298 | // desc: CTRL function ... |
| 26299 | //----------------------------------------------------------------------------- |
| 26300 | CK_DLL_CTRL( FM_ctrl_modSpeed ) |
| 26301 | { |
| 26302 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26303 | //--------------------------------------------------------------------- |
| 26304 | // check for base class pointer; throw exception and halt shred if NULL |
| 26305 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26306 | //--------------------------------------------------------------------- |
| 26307 | |
| 26308 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 26309 | fm->setModulationSpeed( f ); |
| 26310 | RETURN->v_float = fm->vibrato->m_freq; |
| 26311 | } |
| 26312 | |
| 26313 | |
| 26314 | //----------------------------------------------------------------------------- |
| 26315 | // name: FM_ctrl_modSpeed() |
| 26316 | // desc: CTRL function ... |
| 26317 | //----------------------------------------------------------------------------- |
| 26318 | CK_DLL_CTRL( FM_cget_modSpeed ) |
| 26319 | { |
| 26320 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26321 | //--------------------------------------------------------------------- |
| 26322 | // check for base class pointer; throw exception and halt shred if NULL |
| 26323 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26324 | //--------------------------------------------------------------------- |
| 26325 | RETURN->v_float = fm->vibrato->m_freq; |
| 26326 | } |
| 26327 | |
| 26328 | |
| 26329 | //----------------------------------------------------------------------------- |
| 26330 | // name: FM_ctrl_control1() |
| 26331 | // desc: CTRL function ... |
| 26332 | //----------------------------------------------------------------------------- |
| 26333 | CK_DLL_CTRL( FM_ctrl_control1 ) |
| 26334 | { |
| 26335 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26336 | //--------------------------------------------------------------------- |
| 26337 | // check for base class pointer; throw exception and halt shred if NULL |
| 26338 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26339 | //--------------------------------------------------------------------- |
| 26340 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 26341 | fm->setControl1( f ); |
| 26342 | RETURN->v_float = fm->control1 / 2.0; |
| 26343 | } |
| 26344 | |
| 26345 | |
| 26346 | //----------------------------------------------------------------------------- |
| 26347 | // name: FM_cget_control1() |
| 26348 | // desc: CTRL function ... |
| 26349 | //----------------------------------------------------------------------------- |
| 26350 | CK_DLL_CTRL( FM_cget_control1 ) |
| 26351 | { |
| 26352 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26353 | //--------------------------------------------------------------------- |
| 26354 | // check for base class pointer; throw exception and halt shred if NULL |
| 26355 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26356 | //--------------------------------------------------------------------- |
| 26357 | RETURN->v_float = fm->control1 / 2.0; |
| 26358 | } |
| 26359 | |
| 26360 | |
| 26361 | //----------------------------------------------------------------------------- |
| 26362 | // name: FM_ctrl_control2() |
| 26363 | // desc: CTRL function ... |
| 26364 | //----------------------------------------------------------------------------- |
| 26365 | CK_DLL_CTRL( FM_ctrl_control2 ) |
| 26366 | { |
| 26367 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26368 | //--------------------------------------------------------------------- |
| 26369 | // check for base class pointer; throw exception and halt shred if NULL |
| 26370 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26371 | //--------------------------------------------------------------------- |
| 26372 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 26373 | fm->setControl2( f ); |
| 26374 | RETURN->v_float = fm->control2 / 2.0; |
| 26375 | } |
| 26376 | |
| 26377 | |
| 26378 | //----------------------------------------------------------------------------- |
| 26379 | // name: FM_cget_control2() |
| 26380 | // desc: CTRL function ... |
| 26381 | //----------------------------------------------------------------------------- |
| 26382 | CK_DLL_CTRL( FM_cget_control2 ) |
| 26383 | { |
| 26384 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26385 | //--------------------------------------------------------------------- |
| 26386 | // check for base class pointer; throw exception and halt shred if NULL |
| 26387 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26388 | //--------------------------------------------------------------------- |
| 26389 | RETURN->v_float = fm->control2 / 2.0; |
| 26390 | } |
| 26391 | |
| 26392 | |
| 26393 | //----------------------------------------------------------------------------- |
| 26394 | // name: FM_ctrl_afterTouch() |
| 26395 | // desc: CTRL function ... |
| 26396 | //----------------------------------------------------------------------------- |
| 26397 | CK_DLL_CTRL( FM_ctrl_afterTouch ) |
| 26398 | { |
| 26399 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26400 | //--------------------------------------------------------------------- |
| 26401 | // check for base class pointer; throw exception and halt shred if NULL |
| 26402 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26403 | //--------------------------------------------------------------------- |
| 26404 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 26405 | fm->controlChange( __SK_AfterTouch_Cont_, f * 128.0 ); |
| 26406 | RETURN->v_float = fm->adsr[1]->target; |
| 26407 | } |
| 26408 | |
| 26409 | |
| 26410 | //----------------------------------------------------------------------------- |
| 26411 | // name: FM_cget_afterTouch() |
| 26412 | // desc: CTRL function ... |
| 26413 | //----------------------------------------------------------------------------- |
| 26414 | CK_DLL_CTRL( FM_cget_afterTouch ) |
| 26415 | { |
| 26416 | FM * fm = (FM *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26417 | //--------------------------------------------------------------------- |
| 26418 | // check for base class pointer; throw exception and halt shred if NULL |
| 26419 | if( !stk_verify_baseclass(fm, SELF->type_ref->name(), SHRED) ) return; |
| 26420 | //--------------------------------------------------------------------- |
| 26421 | RETURN->v_float = fm->adsr[1]->target; |
| 26422 | } |
| 26423 | |
| 26424 | |
| 26425 | |
| 26426 | |
| 26427 | //----------------------------------------------------------------------------- |
| 26428 | // name: BeeThree_ctor() |
| 26429 | // desc: CTOR function ... |
| 26430 | //----------------------------------------------------------------------------- |
| 26431 | CK_DLL_CTOR( BeeThree_ctor ) |
| 26432 | { |
| 26433 | // initialize member object |
| 26434 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = (t_CKUINT) new BeeThree(); |
| 26435 | } |
| 26436 | |
| 26437 | |
| 26438 | //----------------------------------------------------------------------------- |
| 26439 | // name: BeeThree_dtor() |
| 26440 | // desc: DTOR function ... |
| 26441 | //----------------------------------------------------------------------------- |
| 26442 | CK_DLL_DTOR( BeeThree_dtor ) |
| 26443 | { |
| 26444 | delete (BeeThree *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26445 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = 0; |
| 26446 | } |
| 26447 | |
| 26448 | |
| 26449 | //----------------------------------------------------------------------------- |
| 26450 | // name: BeeThree_tick() |
| 26451 | // desc: TICK function ... |
| 26452 | //----------------------------------------------------------------------------- |
| 26453 | CK_DLL_TICK( BeeThree_tick ) |
| 26454 | { |
| 26455 | BeeThree * m = (BeeThree *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26456 | *out = m->tick(); |
| 26457 | return TRUE; |
| 26458 | } |
| 26459 | |
| 26460 | |
| 26461 | //----------------------------------------------------------------------------- |
| 26462 | // name: BeeThree_pmsg() |
| 26463 | // desc: PMSG function ... |
| 26464 | //----------------------------------------------------------------------------- |
| 26465 | CK_DLL_PMSG( BeeThree_pmsg ) |
| 26466 | { |
| 26467 | return TRUE; |
| 26468 | } |
| 26469 | |
| 26470 | |
| 26471 | |
| 26472 | |
| 26473 | //----------------------------------------------------------------------------- |
| 26474 | // name: FMVoices_ctor() |
| 26475 | // desc: CTOR function ... |
| 26476 | //----------------------------------------------------------------------------- |
| 26477 | CK_DLL_CTOR( FMVoices_ctor ) |
| 26478 | { |
| 26479 | // initialize member object |
| 26480 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = (t_CKUINT) new FMVoices(); |
| 26481 | } |
| 26482 | |
| 26483 | |
| 26484 | //----------------------------------------------------------------------------- |
| 26485 | // name: FMVoices_dtor() |
| 26486 | // desc: DTOR function ... |
| 26487 | //----------------------------------------------------------------------------- |
| 26488 | CK_DLL_DTOR( FMVoices_dtor ) |
| 26489 | { |
| 26490 | delete (FMVoices *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26491 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = 0; |
| 26492 | } |
| 26493 | |
| 26494 | |
| 26495 | //----------------------------------------------------------------------------- |
| 26496 | // name: FMVoices_tick() |
| 26497 | // desc: TICK function ... |
| 26498 | //----------------------------------------------------------------------------- |
| 26499 | CK_DLL_TICK( FMVoices_tick ) |
| 26500 | { |
| 26501 | FMVoices * m = (FMVoices *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26502 | *out = m->tick(); |
| 26503 | return TRUE; |
| 26504 | } |
| 26505 | |
| 26506 | |
| 26507 | //----------------------------------------------------------------------------- |
| 26508 | // name: FMVoices_pmsg() |
| 26509 | // desc: PMSG function ... |
| 26510 | //----------------------------------------------------------------------------- |
| 26511 | CK_DLL_PMSG( FMVoices_pmsg ) |
| 26512 | { |
| 26513 | return TRUE; |
| 26514 | } |
| 26515 | |
| 26516 | |
| 26517 | //----------------------------------------------------------------------------- |
| 26518 | // name: FMVoices_ctrl_vowel() |
| 26519 | // desc: CTRL function ... |
| 26520 | //----------------------------------------------------------------------------- |
| 26521 | CK_DLL_CTRL( FMVoices_ctrl_vowel ) |
| 26522 | { |
| 26523 | FMVoices * voc= (FMVoices *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26524 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 26525 | voc->controlChange( __SK_Breath_, f * 128.0 ); |
| 26526 | RETURN->v_float = f; |
| 26527 | } |
| 26528 | |
| 26529 | |
| 26530 | //----------------------------------------------------------------------------- |
| 26531 | // name: FMVoices_cget_vowel() |
| 26532 | // desc: CTRL function ... |
| 26533 | //----------------------------------------------------------------------------- |
| 26534 | CK_DLL_CTRL( FMVoices_cget_vowel ) |
| 26535 | { |
| 26536 | } |
| 26537 | |
| 26538 | |
| 26539 | //----------------------------------------------------------------------------- |
| 26540 | // name: FMVoices_ctrl_spectralTilt() |
| 26541 | // desc: CTRL function ... |
| 26542 | //----------------------------------------------------------------------------- |
| 26543 | CK_DLL_CTRL( FMVoices_ctrl_spectralTilt ) |
| 26544 | { |
| 26545 | FMVoices * voc= (FMVoices *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26546 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 26547 | voc->controlChange( __SK_FootControl_, f * 128.0); |
| 26548 | RETURN->v_float = f; |
| 26549 | } |
| 26550 | |
| 26551 | |
| 26552 | //----------------------------------------------------------------------------- |
| 26553 | // name: FMVoices_cget_spectralTilt() |
| 26554 | // desc: CTRL function ... |
| 26555 | //----------------------------------------------------------------------------- |
| 26556 | CK_DLL_CTRL( FMVoices_cget_spectralTilt ) |
| 26557 | { |
| 26558 | } |
| 26559 | |
| 26560 | |
| 26561 | //----------------------------------------------------------------------------- |
| 26562 | // name: FMVoices_ctrl_adsrTarget() |
| 26563 | // desc: CTRL function ... |
| 26564 | //----------------------------------------------------------------------------- |
| 26565 | CK_DLL_CTRL( FMVoices_ctrl_adsrTarget ) |
| 26566 | { |
| 26567 | FMVoices * voc= (FMVoices *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26568 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 26569 | voc->controlChange( __SK_AfterTouch_Cont_, f * 128.0); |
| 26570 | RETURN->v_float = f; |
| 26571 | } |
| 26572 | |
| 26573 | |
| 26574 | //----------------------------------------------------------------------------- |
| 26575 | // name: FMVoices_cget_adsrTarget() |
| 26576 | // desc: CTRL function ... |
| 26577 | //----------------------------------------------------------------------------- |
| 26578 | CK_DLL_CTRL( FMVoices_cget_adsrTarget ) |
| 26579 | { |
| 26580 | } |
| 26581 | |
| 26582 | |
| 26583 | |
| 26584 | |
| 26585 | //----------------------------------------------------------------------------- |
| 26586 | // name: HevyMetl_ctor() |
| 26587 | // desc: CTOR function ... |
| 26588 | //----------------------------------------------------------------------------- |
| 26589 | CK_DLL_CTOR( HevyMetl_ctor ) |
| 26590 | { |
| 26591 | // initialize member object |
| 26592 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = (t_CKUINT) new HevyMetl(); |
| 26593 | } |
| 26594 | |
| 26595 | |
| 26596 | //----------------------------------------------------------------------------- |
| 26597 | // name: HevyMetl_dtor() |
| 26598 | // desc: DTOR function ... |
| 26599 | //----------------------------------------------------------------------------- |
| 26600 | CK_DLL_DTOR( HevyMetl_dtor ) |
| 26601 | { |
| 26602 | delete (HevyMetl *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26603 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = 0; |
| 26604 | } |
| 26605 | |
| 26606 | |
| 26607 | //----------------------------------------------------------------------------- |
| 26608 | // name: HevyMetl_tick() |
| 26609 | // desc: TICK function ... |
| 26610 | //----------------------------------------------------------------------------- |
| 26611 | CK_DLL_TICK( HevyMetl_tick ) |
| 26612 | { |
| 26613 | HevyMetl * m = (HevyMetl *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26614 | *out = m->tick(); |
| 26615 | return TRUE; |
| 26616 | } |
| 26617 | |
| 26618 | |
| 26619 | //----------------------------------------------------------------------------- |
| 26620 | // name: HevyMetl_pmsg() |
| 26621 | // desc: PMSG function ... |
| 26622 | //----------------------------------------------------------------------------- |
| 26623 | CK_DLL_PMSG( HevyMetl_pmsg ) |
| 26624 | { |
| 26625 | return TRUE; |
| 26626 | } |
| 26627 | |
| 26628 | |
| 26629 | |
| 26630 | |
| 26631 | //----------------------------------------------------------------------------- |
| 26632 | // 1.4.1.0 (prc) REPAIRATHON2021 BRAND NEW FM INSTRUMENTS AND ALGORITHMS!!! *** |
| 26633 | //----------------------------------------------------------------------------- |
| 26634 | // name: HnkyTonk_ctor() |
| 26635 | // desc: CTOR function ... |
| 26636 | //----------------------------------------------------------------------------- |
| 26637 | CK_DLL_CTOR( HnkyTonk_ctor ) |
| 26638 | { |
| 26639 | // initialize member object |
| 26640 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = (t_CKUINT) new HnkyTonk(); |
| 26641 | } |
| 26642 | |
| 26643 | |
| 26644 | //----------------------------------------------------------------------------- |
| 26645 | // name: HnkyTonk_dtor() |
| 26646 | // desc: DTOR function ... |
| 26647 | //----------------------------------------------------------------------------- |
| 26648 | CK_DLL_DTOR( HnkyTonk_dtor ) |
| 26649 | { |
| 26650 | delete (HnkyTonk *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26651 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = 0; |
| 26652 | } |
| 26653 | |
| 26654 | |
| 26655 | //----------------------------------------------------------------------------- |
| 26656 | // name: HnkyTonk_tick() |
| 26657 | // desc: TICK function ... |
| 26658 | //----------------------------------------------------------------------------- |
| 26659 | CK_DLL_TICK( HnkyTonk_tick ) |
| 26660 | { |
| 26661 | HnkyTonk * m = (HnkyTonk *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26662 | *out = m->tick(); |
| 26663 | return TRUE; |
| 26664 | } |
| 26665 | |
| 26666 | |
| 26667 | //----------------------------------------------------------------------------- |
| 26668 | // name: HnkyTonk_pmsg() |
| 26669 | // desc: PMSG function ... |
| 26670 | //----------------------------------------------------------------------------- |
| 26671 | CK_DLL_PMSG( HnkyTonk_pmsg ) |
| 26672 | { |
| 26673 | return TRUE; |
| 26674 | } |
| 26675 | |
| 26676 | |
| 26677 | //----------------------------------------------------------------------------- |
| 26678 | // name: FrencHrn_ctor() |
| 26679 | // desc: CTOR function ... |
| 26680 | //----------------------------------------------------------------------------- |
| 26681 | CK_DLL_CTOR( FrencHrn_ctor ) |
| 26682 | { |
| 26683 | // initialize member object |
| 26684 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = (t_CKUINT) new FrencHrn(); |
| 26685 | } |
| 26686 | |
| 26687 | |
| 26688 | //----------------------------------------------------------------------------- |
| 26689 | // name: FrencHrn_dtor() |
| 26690 | // desc: DTOR function ... |
| 26691 | //----------------------------------------------------------------------------- |
| 26692 | CK_DLL_DTOR( FrencHrn_dtor ) |
| 26693 | { |
| 26694 | delete (FrencHrn *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26695 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = 0; |
| 26696 | } |
| 26697 | |
| 26698 | |
| 26699 | //----------------------------------------------------------------------------- |
| 26700 | // name: FrencHrn_tick() |
| 26701 | // desc: TICK function ... |
| 26702 | //----------------------------------------------------------------------------- |
| 26703 | CK_DLL_TICK( FrencHrn_tick ) |
| 26704 | { |
| 26705 | FrencHrn * m = (FrencHrn *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26706 | *out = m->tick(); |
| 26707 | return TRUE; |
| 26708 | } |
| 26709 | |
| 26710 | |
| 26711 | //----------------------------------------------------------------------------- |
| 26712 | // name: FrencHrn_pmsg() |
| 26713 | // desc: PMSG function ... |
| 26714 | //----------------------------------------------------------------------------- |
| 26715 | CK_DLL_PMSG( FrencHrn_pmsg ) |
| 26716 | { |
| 26717 | return TRUE; |
| 26718 | } |
| 26719 | |
| 26720 | |
| 26721 | //----------------------------------------------------------------------------- |
| 26722 | // name: KrstlChr_ctor() |
| 26723 | // desc: CTOR function ... |
| 26724 | //----------------------------------------------------------------------------- |
| 26725 | CK_DLL_CTOR( KrstlChr_ctor ) |
| 26726 | { |
| 26727 | // initialize member object |
| 26728 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = (t_CKUINT) new KrstlChr(); |
| 26729 | } |
| 26730 | |
| 26731 | |
| 26732 | //----------------------------------------------------------------------------- |
| 26733 | // name: KrstlChr_dtor() |
| 26734 | // desc: DTOR function ... |
| 26735 | //----------------------------------------------------------------------------- |
| 26736 | CK_DLL_DTOR( KrstlChr_dtor ) |
| 26737 | { |
| 26738 | delete (KrstlChr *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26739 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = 0; |
| 26740 | } |
| 26741 | |
| 26742 | |
| 26743 | //----------------------------------------------------------------------------- |
| 26744 | // name: KrstlChr_tick() |
| 26745 | // desc: TICK function ... |
| 26746 | //----------------------------------------------------------------------------- |
| 26747 | CK_DLL_TICK( KrstlChr_tick ) |
| 26748 | { |
| 26749 | KrstlChr * m = (KrstlChr *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26750 | *out = m->tick(); |
| 26751 | return TRUE; |
| 26752 | } |
| 26753 | |
| 26754 | |
| 26755 | //----------------------------------------------------------------------------- |
| 26756 | // name: KrstlChr_pmsg() |
| 26757 | // desc: PMSG function ... |
| 26758 | //----------------------------------------------------------------------------- |
| 26759 | CK_DLL_PMSG( KrstlChr_pmsg ) |
| 26760 | { |
| 26761 | return TRUE; |
| 26762 | } |
| 26763 | //----------------------------------------------------------------------------- |
| 26764 | /***** END REPAIRATHON2021 BRAND NEW FM INSTRUMENTS AND ALGORITHMS *****/ |
| 26765 | //----------------------------------------------------------------------------- |
| 26766 | |
| 26767 | |
| 26768 | |
| 26769 | |
| 26770 | //----------------------------------------------------------------------------- |
| 26771 | // name: PercFlut_ctor() |
| 26772 | // desc: CTOR function ... |
| 26773 | //----------------------------------------------------------------------------- |
| 26774 | CK_DLL_CTOR( PercFlut_ctor ) |
| 26775 | { |
| 26776 | // initialize member object |
| 26777 | PercFlut * flut = new PercFlut(); |
| 26778 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = (t_CKUINT)flut; |
| 26779 | // default |
| 26780 | flut->setFrequency( 220 ); |
| 26781 | } |
| 26782 | |
| 26783 | |
| 26784 | //----------------------------------------------------------------------------- |
| 26785 | // name: PercFlut_dtor() |
| 26786 | // desc: DTOR function ... |
| 26787 | //----------------------------------------------------------------------------- |
| 26788 | CK_DLL_DTOR( PercFlut_dtor ) |
| 26789 | { |
| 26790 | delete (PercFlut *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26791 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = 0; |
| 26792 | } |
| 26793 | |
| 26794 | |
| 26795 | //----------------------------------------------------------------------------- |
| 26796 | // name: PercFlut_tick() |
| 26797 | // desc: TICK function ... |
| 26798 | //----------------------------------------------------------------------------- |
| 26799 | CK_DLL_TICK( PercFlut_tick ) |
| 26800 | { |
| 26801 | PercFlut * m = (PercFlut *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26802 | *out = m->tick(); |
| 26803 | return TRUE; |
| 26804 | } |
| 26805 | |
| 26806 | |
| 26807 | //----------------------------------------------------------------------------- |
| 26808 | // name: PercFlut_pmsg() |
| 26809 | // desc: PMSG function ... |
| 26810 | //----------------------------------------------------------------------------- |
| 26811 | CK_DLL_PMSG( PercFlut_pmsg ) |
| 26812 | { |
| 26813 | return TRUE; |
| 26814 | } |
| 26815 | |
| 26816 | |
| 26817 | |
| 26818 | |
| 26819 | //----------------------------------------------------------------------------- |
| 26820 | // name: Rhodey_ctor() |
| 26821 | // desc: CTOR function ... |
| 26822 | //----------------------------------------------------------------------------- |
| 26823 | CK_DLL_CTOR( Rhodey_ctor ) |
| 26824 | { |
| 26825 | // initialize member object |
| 26826 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = (t_CKUINT) new Rhodey(); |
| 26827 | } |
| 26828 | |
| 26829 | |
| 26830 | //----------------------------------------------------------------------------- |
| 26831 | // name: Rhodey_dtor() |
| 26832 | // desc: DTOR function ... |
| 26833 | //----------------------------------------------------------------------------- |
| 26834 | CK_DLL_DTOR( Rhodey_dtor ) |
| 26835 | { |
| 26836 | delete (Rhodey *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26837 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = 0; |
| 26838 | } |
| 26839 | |
| 26840 | |
| 26841 | //----------------------------------------------------------------------------- |
| 26842 | // name: Rhodey_tick() |
| 26843 | // desc: TICK function ... |
| 26844 | //----------------------------------------------------------------------------- |
| 26845 | CK_DLL_TICK( Rhodey_tick ) |
| 26846 | { |
| 26847 | Rhodey * m = (Rhodey *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26848 | *out = m->tick(); |
| 26849 | return TRUE; |
| 26850 | } |
| 26851 | |
| 26852 | |
| 26853 | //----------------------------------------------------------------------------- |
| 26854 | // name: Rhodey_pmsg() |
| 26855 | // desc: PMSG function ... |
| 26856 | //----------------------------------------------------------------------------- |
| 26857 | CK_DLL_PMSG( Rhodey_pmsg ) |
| 26858 | { |
| 26859 | return TRUE; |
| 26860 | } |
| 26861 | |
| 26862 | |
| 26863 | |
| 26864 | |
| 26865 | //----------------------------------------------------------------------------- |
| 26866 | // name: TubeBell_ctor() |
| 26867 | // desc: CTOR function ... |
| 26868 | //----------------------------------------------------------------------------- |
| 26869 | CK_DLL_CTOR( TubeBell_ctor ) |
| 26870 | { |
| 26871 | // initialize member object |
| 26872 | TubeBell * bell = new TubeBell(); |
| 26873 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = (t_CKUINT)bell; |
| 26874 | // default |
| 26875 | bell->setFrequency( 220 ); |
| 26876 | } |
| 26877 | |
| 26878 | |
| 26879 | //----------------------------------------------------------------------------- |
| 26880 | // name: TubeBell_dtor() |
| 26881 | // desc: DTOR function ... |
| 26882 | //----------------------------------------------------------------------------- |
| 26883 | CK_DLL_DTOR( TubeBell_dtor ) |
| 26884 | { |
| 26885 | delete (TubeBell *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26886 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = 0; |
| 26887 | } |
| 26888 | |
| 26889 | |
| 26890 | //----------------------------------------------------------------------------- |
| 26891 | // name: TubeBell_tick() |
| 26892 | // desc: TICK function ... |
| 26893 | //----------------------------------------------------------------------------- |
| 26894 | CK_DLL_TICK( TubeBell_tick ) |
| 26895 | { |
| 26896 | TubeBell * m = (TubeBell *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26897 | *out = m->tick(); |
| 26898 | return TRUE; |
| 26899 | } |
| 26900 | |
| 26901 | |
| 26902 | //----------------------------------------------------------------------------- |
| 26903 | // name: TubeBell_pmsg() |
| 26904 | // desc: PMSG function ... |
| 26905 | //----------------------------------------------------------------------------- |
| 26906 | CK_DLL_PMSG( TubeBell_pmsg ) |
| 26907 | { |
| 26908 | return TRUE; |
| 26909 | } |
| 26910 | |
| 26911 | |
| 26912 | |
| 26913 | |
| 26914 | //----------------------------------------------------------------------------- |
| 26915 | // name: Wurley_ctor() |
| 26916 | // desc: CTOR function ... |
| 26917 | //----------------------------------------------------------------------------- |
| 26918 | CK_DLL_CTOR( Wurley_ctor ) |
| 26919 | { |
| 26920 | // initialize member object |
| 26921 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = (t_CKUINT)new Wurley(); |
| 26922 | } |
| 26923 | |
| 26924 | |
| 26925 | //----------------------------------------------------------------------------- |
| 26926 | // name: Wurley_dtor() |
| 26927 | // desc: DTOR function ... |
| 26928 | //----------------------------------------------------------------------------- |
| 26929 | CK_DLL_DTOR( Wurley_dtor ) |
| 26930 | { |
| 26931 | delete (Wurley *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26932 | OBJ_MEMBER_UINT(SELF, FM_offset_data) = 0; |
| 26933 | } |
| 26934 | |
| 26935 | |
| 26936 | //----------------------------------------------------------------------------- |
| 26937 | // name: Wurley_tick() |
| 26938 | // desc: TICK function ... |
| 26939 | //----------------------------------------------------------------------------- |
| 26940 | CK_DLL_TICK( Wurley_tick ) |
| 26941 | { |
| 26942 | Wurley * m = (Wurley *)OBJ_MEMBER_UINT(SELF, FM_offset_data); |
| 26943 | *out = m->tick(); |
| 26944 | return TRUE; |
| 26945 | } |
| 26946 | |
| 26947 | |
| 26948 | //----------------------------------------------------------------------------- |
| 26949 | // name: Wurley_pmsg() |
| 26950 | // desc: PMSG function ... |
| 26951 | //----------------------------------------------------------------------------- |
| 26952 | CK_DLL_PMSG( Wurley_pmsg ) |
| 26953 | { |
| 26954 | return TRUE; |
| 26955 | } |
| 26956 | |
| 26957 | |
| 26958 | |
| 26959 | |
| 26960 | //----------------------------------------------------------------------------- |
| 26961 | // name: FormSwep_ctor() |
| 26962 | // desc: CTOR function ... |
| 26963 | //----------------------------------------------------------------------------- |
| 26964 | CK_DLL_CTOR( FormSwep_ctor ) |
| 26965 | { |
| 26966 | // initialize member object |
| 26967 | OBJ_MEMBER_UINT(SELF, FormSwep_offset_data) = (t_CKUINT)new FormSwep(); |
| 26968 | } |
| 26969 | |
| 26970 | |
| 26971 | //----------------------------------------------------------------------------- |
| 26972 | // name: FormSwep_dtor() |
| 26973 | // desc: DTOR function ... |
| 26974 | //----------------------------------------------------------------------------- |
| 26975 | CK_DLL_DTOR( FormSwep_dtor ) |
| 26976 | { |
| 26977 | delete (FormSwep *)OBJ_MEMBER_UINT(SELF, FormSwep_offset_data); |
| 26978 | OBJ_MEMBER_UINT(SELF, FormSwep_offset_data) = 0; |
| 26979 | } |
| 26980 | |
| 26981 | |
| 26982 | //----------------------------------------------------------------------------- |
| 26983 | // name: FormSwep_tick() |
| 26984 | // desc: TICK function ... |
| 26985 | //----------------------------------------------------------------------------- |
| 26986 | CK_DLL_TICK( FormSwep_tick ) |
| 26987 | { |
| 26988 | FormSwep * m = (FormSwep *)OBJ_MEMBER_UINT(SELF, FormSwep_offset_data); |
| 26989 | *out = m->tick(in); |
| 26990 | return TRUE; |
| 26991 | } |
| 26992 | |
| 26993 | |
| 26994 | //----------------------------------------------------------------------------- |
| 26995 | // name: FormSwep_pmsg() |
| 26996 | // desc: PMSG function ... |
| 26997 | //----------------------------------------------------------------------------- |
| 26998 | CK_DLL_PMSG( FormSwep_pmsg ) |
| 26999 | { |
| 27000 | return TRUE; |
| 27001 | } |
| 27002 | |
| 27003 | //FormSwep requires multiple arguments |
| 27004 | //to most of its parameters. |
| 27005 | |
| 27006 | |
| 27007 | |
| 27008 | //----------------------------------------------------------------------------- |
| 27009 | // name: JCRev_ctor() |
| 27010 | // desc: CTOR function ... |
| 27011 | //----------------------------------------------------------------------------- |
| 27012 | CK_DLL_CTOR( JCRev_ctor ) |
| 27013 | { |
| 27014 | // initialize member object |
| 27015 | OBJ_MEMBER_UINT(SELF, JCRev_offset_data) = (t_CKUINT)new JCRev( 4.0f ); |
| 27016 | } |
| 27017 | |
| 27018 | |
| 27019 | //----------------------------------------------------------------------------- |
| 27020 | // name: JCRev_ctor_mix() |
| 27021 | // desc: CTOR function ... |
| 27022 | //----------------------------------------------------------------------------- |
| 27023 | CK_DLL_CTOR( JCRev_ctor_mix ) |
| 27024 | { |
| 27025 | JCRev * j = (JCRev*)OBJ_MEMBER_UINT(SELF, JCRev_offset_data); |
| 27026 | j->setEffectMix( GET_NEXT_FLOAT(ARGS) ); |
| 27027 | } |
| 27028 | |
| 27029 | |
| 27030 | //----------------------------------------------------------------------------- |
| 27031 | // name: JCRev_dtor() |
| 27032 | // desc: DTOR function ... |
| 27033 | //----------------------------------------------------------------------------- |
| 27034 | CK_DLL_DTOR( JCRev_dtor ) |
| 27035 | { |
| 27036 | delete (JCRev *)OBJ_MEMBER_UINT(SELF, JCRev_offset_data); |
| 27037 | OBJ_MEMBER_UINT(SELF, JCRev_offset_data) = 0; |
| 27038 | } |
| 27039 | |
| 27040 | |
| 27041 | //----------------------------------------------------------------------------- |
| 27042 | // name: JCRev_tick() |
| 27043 | // desc: TICK function ... |
| 27044 | //----------------------------------------------------------------------------- |
| 27045 | CK_DLL_TICK( JCRev_tick ) |
| 27046 | { |
| 27047 | JCRev * j = (JCRev *)OBJ_MEMBER_UINT(SELF, JCRev_offset_data); |
| 27048 | *out = j->tick( in ); |
| 27049 | return TRUE; |
| 27050 | } |
| 27051 | |
| 27052 | |
| 27053 | //----------------------------------------------------------------------------- |
| 27054 | // name: JCRev_pmsg() |
| 27055 | // desc: PMSG function ... |
| 27056 | //----------------------------------------------------------------------------- |
| 27057 | CK_DLL_PMSG( JCRev_pmsg ) |
| 27058 | { |
| 27059 | return TRUE; |
| 27060 | } |
| 27061 | |
| 27062 | |
| 27063 | //----------------------------------------------------------------------------- |
| 27064 | // name: JCRev_ctrl_mix() |
| 27065 | // desc: CTRL function ... |
| 27066 | //----------------------------------------------------------------------------- |
| 27067 | CK_DLL_CTRL( JCRev_ctrl_mix ) |
| 27068 | { |
| 27069 | JCRev * j = (JCRev *)OBJ_MEMBER_UINT(SELF, JCRev_offset_data); |
| 27070 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27071 | j->setEffectMix( f ); |
| 27072 | RETURN->v_float = (t_CKFLOAT) j->effectMix; |
| 27073 | } |
| 27074 | |
| 27075 | |
| 27076 | //----------------------------------------------------------------------------- |
| 27077 | // name: JCRev_cget_mix() |
| 27078 | // desc: CGET function ... |
| 27079 | //----------------------------------------------------------------------------- |
| 27080 | CK_DLL_CGET( JCRev_cget_mix ) |
| 27081 | { |
| 27082 | JCRev * j = (JCRev *)OBJ_MEMBER_UINT(SELF, JCRev_offset_data); |
| 27083 | RETURN->v_float = (t_CKFLOAT) j->effectMix; |
| 27084 | } |
| 27085 | |
| 27086 | |
| 27087 | //----------------------------------------------------------------------------- |
| 27088 | // name: Mandolin_ctor() |
| 27089 | // desc: CTOR function ... |
| 27090 | //----------------------------------------------------------------------------- |
| 27091 | CK_DLL_CTOR( Mandolin_ctor ) |
| 27092 | { |
| 27093 | // initialize member object |
| 27094 | Mandolin * m = new Mandolin( 20 ); |
| 27095 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)m; |
| 27096 | // default |
| 27097 | m->setFrequency( 220 ); |
| 27098 | } |
| 27099 | |
| 27100 | |
| 27101 | //----------------------------------------------------------------------------- |
| 27102 | // name: Mandolin_dtor() |
| 27103 | // desc: DTOR function ... |
| 27104 | //----------------------------------------------------------------------------- |
| 27105 | CK_DLL_DTOR( Mandolin_dtor ) |
| 27106 | { |
| 27107 | delete (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27108 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 27109 | } |
| 27110 | |
| 27111 | |
| 27112 | //----------------------------------------------------------------------------- |
| 27113 | // name: Mandolin_tick() |
| 27114 | // desc: TICK function ... |
| 27115 | //----------------------------------------------------------------------------- |
| 27116 | CK_DLL_TICK( Mandolin_tick ) |
| 27117 | { |
| 27118 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27119 | *out = m->tick(); |
| 27120 | return TRUE; |
| 27121 | } |
| 27122 | |
| 27123 | |
| 27124 | //----------------------------------------------------------------------------- |
| 27125 | // name: Mandolin_pmsg() |
| 27126 | // desc: PMSG function ... |
| 27127 | //----------------------------------------------------------------------------- |
| 27128 | CK_DLL_PMSG( Mandolin_pmsg ) |
| 27129 | { |
| 27130 | return TRUE; |
| 27131 | } |
| 27132 | |
| 27133 | |
| 27134 | //----------------------------------------------------------------------------- |
| 27135 | // name: Mandolin_ctrl_pluck() |
| 27136 | // desc: CTRL function ... |
| 27137 | //----------------------------------------------------------------------------- |
| 27138 | CK_DLL_CTRL( Mandolin_ctrl_pluck ) |
| 27139 | { |
| 27140 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27141 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27142 | m->pluck( f ); |
| 27143 | } |
| 27144 | |
| 27145 | |
| 27146 | //----------------------------------------------------------------------------- |
| 27147 | // name: Mandolin_ctrl_pluckPos() |
| 27148 | // desc: CTRL function ... |
| 27149 | //----------------------------------------------------------------------------- |
| 27150 | CK_DLL_CTRL( Mandolin_ctrl_pluckPos ) |
| 27151 | { |
| 27152 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27153 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27154 | m->setPluckPosition( f ); |
| 27155 | RETURN->v_float = f; |
| 27156 | } |
| 27157 | |
| 27158 | |
| 27159 | //----------------------------------------------------------------------------- |
| 27160 | // name: Mandolin_cget_pluckPos() |
| 27161 | // desc: CGET function ... |
| 27162 | //----------------------------------------------------------------------------- |
| 27163 | CK_DLL_CGET( Mandolin_cget_pluckPos ) |
| 27164 | { |
| 27165 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27166 | RETURN->v_float = (t_CKFLOAT)m->pluckPosition; |
| 27167 | } |
| 27168 | |
| 27169 | |
| 27170 | //----------------------------------------------------------------------------- |
| 27171 | // name: Mandolin_ctrl_bodySize() |
| 27172 | // desc: CTRL function ... |
| 27173 | //----------------------------------------------------------------------------- |
| 27174 | CK_DLL_CTRL( Mandolin_ctrl_bodySize ) |
| 27175 | { |
| 27176 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27177 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27178 | m->setBodySize( f ); |
| 27179 | RETURN->v_float = f; |
| 27180 | } |
| 27181 | |
| 27182 | |
| 27183 | //----------------------------------------------------------------------------- |
| 27184 | // name: Mandolin_cget_bodySize() |
| 27185 | // desc: CGET function ... |
| 27186 | //----------------------------------------------------------------------------- |
| 27187 | CK_DLL_CGET( Mandolin_cget_bodySize ) |
| 27188 | { |
| 27189 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27190 | RETURN->v_float = (t_CKFLOAT)m->m_bodySize; |
| 27191 | } |
| 27192 | |
| 27193 | |
| 27194 | //----------------------------------------------------------------------------- |
| 27195 | // name: Mandolin_ctrl_stringDamping() |
| 27196 | // desc: CTRL function ... |
| 27197 | //----------------------------------------------------------------------------- |
| 27198 | CK_DLL_CTRL( Mandolin_ctrl_stringDamping ) |
| 27199 | { |
| 27200 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27201 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27202 | // m->setBaseLoopGain( f ); |
| 27203 | m->setBaseLoopGain( 0.97f + f * 0.03f ); |
| 27204 | RETURN->v_float = f; |
| 27205 | } |
| 27206 | |
| 27207 | |
| 27208 | //----------------------------------------------------------------------------- |
| 27209 | // name: Mandolin_cget_stringDamping() |
| 27210 | // desc: CGET function ... |
| 27211 | //----------------------------------------------------------------------------- |
| 27212 | CK_DLL_CGET( Mandolin_cget_stringDamping ) |
| 27213 | { |
| 27214 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27215 | RETURN->v_float = (t_CKFLOAT)m->baseLoopGain; |
| 27216 | } |
| 27217 | |
| 27218 | |
| 27219 | //----------------------------------------------------------------------------- |
| 27220 | // name: Mandolin_ctrl_stringDetune() |
| 27221 | // desc: CTRL function ... |
| 27222 | //----------------------------------------------------------------------------- |
| 27223 | CK_DLL_CTRL( Mandolin_ctrl_stringDetune ) |
| 27224 | { |
| 27225 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27226 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27227 | // m->setDetune( f ); |
| 27228 | m->setDetune( 1.0f - 0.1f * f ); |
| 27229 | RETURN->v_float = f; |
| 27230 | } |
| 27231 | |
| 27232 | |
| 27233 | //----------------------------------------------------------------------------- |
| 27234 | // name: Mandolin_cget_stringDetune() |
| 27235 | // desc: CGET function ... |
| 27236 | //----------------------------------------------------------------------------- |
| 27237 | CK_DLL_CGET( Mandolin_cget_stringDetune ) |
| 27238 | { |
| 27239 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27240 | RETURN->v_float = (t_CKFLOAT)m->detuning; |
| 27241 | } |
| 27242 | |
| 27243 | |
| 27244 | //----------------------------------------------------------------------------- |
| 27245 | // name: Mandolin_ctrl_afterTouch() |
| 27246 | // desc: CTRL function ... |
| 27247 | //----------------------------------------------------------------------------- |
| 27248 | CK_DLL_CTRL( Mandolin_ctrl_afterTouch ) |
| 27249 | { |
| 27250 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27251 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27252 | // not sure what this does in stk version so we'll just call controlChange |
| 27253 | m->controlChange( __SK_AfterTouch_Cont_, f * 128.0 ); |
| 27254 | } |
| 27255 | |
| 27256 | |
| 27257 | //----------------------------------------------------------------------------- |
| 27258 | // name: Mandolin_ctrl_bodyIR() |
| 27259 | // desc: ... |
| 27260 | //----------------------------------------------------------------------------- |
| 27261 | CK_DLL_CTRL( Mandolin_ctrl_bodyIR ) |
| 27262 | { |
| 27263 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27264 | Chuck_String * str = GET_NEXT_STRING(ARGS); |
| 27265 | if( str != NULL ) { |
| 27266 | m->setBodyIR( str->str().c_str(), strstr(str->str().c_str(), ".raw") != NULL ); |
| 27267 | } |
| 27268 | RETURN->v_string = str; |
| 27269 | } |
| 27270 | |
| 27271 | |
| 27272 | //----------------------------------------------------------------------------- |
| 27273 | // name: Mandolin_cget_bodyIR() |
| 27274 | // desc: ... |
| 27275 | //----------------------------------------------------------------------------- |
| 27276 | CK_DLL_CGET( Mandolin_cget_bodyIR ) |
| 27277 | { |
| 27278 | Mandolin * m = (Mandolin *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27279 | // instantiate | 1.5.0.0 (ge) added to dynamic allocate chuck string |
| 27280 | Chuck_String * str = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->ckt_string, SHRED ); |
| 27281 | str->set( m->soundfile[0]->str_filename ); |
| 27282 | RETURN->v_string = str; |
| 27283 | } |
| 27284 | |
| 27285 | |
| 27286 | // Modulate |
| 27287 | //----------------------------------------------------------------------------- |
| 27288 | // name: Modulate_ctor() |
| 27289 | // desc: CTOR function ... |
| 27290 | //----------------------------------------------------------------------------- |
| 27291 | CK_DLL_CTOR( Modulate_ctor ) |
| 27292 | { |
| 27293 | // initialize member object |
| 27294 | OBJ_MEMBER_UINT(SELF, Modulate_offset_data) = (t_CKUINT) new Modulate( ); |
| 27295 | } |
| 27296 | |
| 27297 | |
| 27298 | //----------------------------------------------------------------------------- |
| 27299 | // name: Modulate_ctor_rate() |
| 27300 | // desc: CTOR function ... |
| 27301 | //----------------------------------------------------------------------------- |
| 27302 | CK_DLL_CTOR( Modulate_ctor_rate ) |
| 27303 | { |
| 27304 | Modulate * m = (Modulate*)OBJ_MEMBER_UINT(SELF, Modulate_offset_data); |
| 27305 | m->setVibratoRate( GET_NEXT_FLOAT(ARGS) ); |
| 27306 | } |
| 27307 | |
| 27308 | |
| 27309 | //----------------------------------------------------------------------------- |
| 27310 | // name: Modulate_ctor_rate_gain() |
| 27311 | // desc: CTOR function ... |
| 27312 | //----------------------------------------------------------------------------- |
| 27313 | CK_DLL_CTOR( Modulate_ctor_rate_gain ) |
| 27314 | { |
| 27315 | Modulate * m = (Modulate*)OBJ_MEMBER_UINT(SELF, Modulate_offset_data); |
| 27316 | m->setVibratoRate( GET_NEXT_FLOAT(ARGS) ); |
| 27317 | m->setVibratoGain( GET_NEXT_FLOAT(ARGS) ); |
| 27318 | } |
| 27319 | |
| 27320 | |
| 27321 | //----------------------------------------------------------------------------- |
| 27322 | // name: Modulate_ctor_rate_gain_random() |
| 27323 | // desc: CTOR function ... |
| 27324 | //----------------------------------------------------------------------------- |
| 27325 | CK_DLL_CTOR( Modulate_ctor_rate_gain_random ) |
| 27326 | { |
| 27327 | Modulate * m = (Modulate*)OBJ_MEMBER_UINT(SELF, Modulate_offset_data); |
| 27328 | m->setVibratoRate( GET_NEXT_FLOAT(ARGS) ); |
| 27329 | m->setVibratoGain( GET_NEXT_FLOAT(ARGS) ); |
| 27330 | m->setRandomGain( GET_NEXT_FLOAT(ARGS) ); |
| 27331 | } |
| 27332 | |
| 27333 | |
| 27334 | //----------------------------------------------------------------------------- |
| 27335 | // name: Modulate_dtor() |
| 27336 | // desc: DTOR function ... |
| 27337 | //----------------------------------------------------------------------------- |
| 27338 | CK_DLL_DTOR( Modulate_dtor ) |
| 27339 | { |
| 27340 | delete (Modulate *)OBJ_MEMBER_UINT(SELF, Modulate_offset_data); |
| 27341 | OBJ_MEMBER_UINT(SELF, Modulate_offset_data) = 0; |
| 27342 | } |
| 27343 | |
| 27344 | |
| 27345 | //----------------------------------------------------------------------------- |
| 27346 | // name: Modulate_tick() |
| 27347 | // desc: TICK function ... |
| 27348 | //----------------------------------------------------------------------------- |
| 27349 | CK_DLL_TICK( Modulate_tick ) |
| 27350 | { |
| 27351 | Modulate * j = (Modulate *)OBJ_MEMBER_UINT(SELF, Modulate_offset_data); |
| 27352 | *out = j->tick(); |
| 27353 | return TRUE; |
| 27354 | } |
| 27355 | |
| 27356 | |
| 27357 | //----------------------------------------------------------------------------- |
| 27358 | // name: Modulate_pmsg() |
| 27359 | // desc: PMSG function ... |
| 27360 | //----------------------------------------------------------------------------- |
| 27361 | CK_DLL_PMSG( Modulate_pmsg ) |
| 27362 | { |
| 27363 | return TRUE; |
| 27364 | } |
| 27365 | |
| 27366 | |
| 27367 | //----------------------------------------------------------------------------- |
| 27368 | // name: Modulate_ctrl_vibratoRate() |
| 27369 | // desc: CTRL function ... |
| 27370 | //----------------------------------------------------------------------------- |
| 27371 | CK_DLL_CTRL( Modulate_ctrl_vibratoRate ) |
| 27372 | { |
| 27373 | Modulate * j = (Modulate *)OBJ_MEMBER_UINT(SELF, Modulate_offset_data); |
| 27374 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27375 | j->setVibratoRate( f ); |
| 27376 | RETURN->v_float = (t_CKFLOAT) j->vibrato->m_freq; |
| 27377 | } |
| 27378 | |
| 27379 | |
| 27380 | //----------------------------------------------------------------------------- |
| 27381 | // name: Modulate_cget_vibratoRate() |
| 27382 | // desc: CGET function ... |
| 27383 | //----------------------------------------------------------------------------- |
| 27384 | CK_DLL_CGET( Modulate_cget_vibratoRate ) |
| 27385 | { |
| 27386 | Modulate * j = (Modulate *)OBJ_MEMBER_UINT(SELF, Modulate_offset_data); |
| 27387 | RETURN->v_float = (t_CKFLOAT) j->vibrato->m_freq; |
| 27388 | } |
| 27389 | |
| 27390 | |
| 27391 | //----------------------------------------------------------------------------- |
| 27392 | // name: Modulate_ctrl_vibratoGain() |
| 27393 | // desc: CTRL function ... |
| 27394 | //----------------------------------------------------------------------------- |
| 27395 | CK_DLL_CTRL( Modulate_ctrl_vibratoGain ) |
| 27396 | { |
| 27397 | Modulate * j = (Modulate *)OBJ_MEMBER_UINT(SELF, Modulate_offset_data); |
| 27398 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27399 | j->setVibratoGain( f ); |
| 27400 | RETURN->v_float = (t_CKFLOAT) j->vibratoGain; |
| 27401 | } |
| 27402 | |
| 27403 | |
| 27404 | //----------------------------------------------------------------------------- |
| 27405 | // name: Modulate_cget_vibratoGain() |
| 27406 | // desc: CGET function ... |
| 27407 | //----------------------------------------------------------------------------- |
| 27408 | |
| 27409 | CK_DLL_CGET( Modulate_cget_vibratoGain ) |
| 27410 | { |
| 27411 | Modulate * j = (Modulate *)OBJ_MEMBER_UINT(SELF, Modulate_offset_data); |
| 27412 | RETURN->v_float = (t_CKFLOAT) j->vibratoGain; |
| 27413 | } |
| 27414 | |
| 27415 | |
| 27416 | //----------------------------------------------------------------------------- |
| 27417 | // name: Modulate_ctrl_randomGain() |
| 27418 | // desc: CTRL function ... |
| 27419 | //----------------------------------------------------------------------------- |
| 27420 | CK_DLL_CTRL( Modulate_ctrl_randomGain ) |
| 27421 | { |
| 27422 | Modulate * j = (Modulate *)OBJ_MEMBER_UINT(SELF, Modulate_offset_data); |
| 27423 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27424 | j->setRandomGain(f ); |
| 27425 | RETURN->v_float = (t_CKFLOAT) j->randomGain; |
| 27426 | } |
| 27427 | |
| 27428 | |
| 27429 | //----------------------------------------------------------------------------- |
| 27430 | // name: Modulate_cget_randomGain() |
| 27431 | // desc: CGET function ... |
| 27432 | //----------------------------------------------------------------------------- |
| 27433 | CK_DLL_CGET( Modulate_cget_randomGain ) |
| 27434 | { |
| 27435 | Modulate * j = (Modulate *)OBJ_MEMBER_UINT(SELF, Modulate_offset_data); |
| 27436 | RETURN->v_float = (t_CKFLOAT) j->randomGain; |
| 27437 | } |
| 27438 | |
| 27439 | |
| 27440 | //----------------------------------------------------------------------------- |
| 27441 | // name: Moog_ctor() |
| 27442 | // desc: CTOR function ... |
| 27443 | //----------------------------------------------------------------------------- |
| 27444 | CK_DLL_CTOR( Moog_ctor ) |
| 27445 | { |
| 27446 | // initialize member object |
| 27447 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new Moog(); |
| 27448 | } |
| 27449 | |
| 27450 | |
| 27451 | //----------------------------------------------------------------------------- |
| 27452 | // name: Moog_dtor() |
| 27453 | // desc: DTOR function ... |
| 27454 | //----------------------------------------------------------------------------- |
| 27455 | CK_DLL_DTOR( Moog_dtor ) |
| 27456 | { |
| 27457 | delete (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27458 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 27459 | } |
| 27460 | |
| 27461 | |
| 27462 | //----------------------------------------------------------------------------- |
| 27463 | // name: Moog_tick() |
| 27464 | // desc: TICK function ... |
| 27465 | //----------------------------------------------------------------------------- |
| 27466 | CK_DLL_TICK( Moog_tick ) |
| 27467 | { |
| 27468 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27469 | *out = m->tick(); |
| 27470 | return TRUE; |
| 27471 | } |
| 27472 | |
| 27473 | |
| 27474 | //----------------------------------------------------------------------------- |
| 27475 | // name: Moog_pmsg() |
| 27476 | // desc: PMSG function ... |
| 27477 | //----------------------------------------------------------------------------- |
| 27478 | CK_DLL_PMSG( Moog_pmsg ) |
| 27479 | { |
| 27480 | return TRUE; |
| 27481 | } |
| 27482 | |
| 27483 | |
| 27484 | //----------------------------------------------------------------------------- |
| 27485 | // name: Moog_ctrl_modSpeed() |
| 27486 | // desc: CTRL function ... |
| 27487 | //----------------------------------------------------------------------------- |
| 27488 | CK_DLL_CTRL( Moog_ctrl_modSpeed ) |
| 27489 | { |
| 27490 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27491 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27492 | m->setModulationSpeed(f); |
| 27493 | RETURN->v_float = (t_CKFLOAT) m->loops[1]->m_freq; |
| 27494 | } |
| 27495 | |
| 27496 | |
| 27497 | //----------------------------------------------------------------------------- |
| 27498 | // name: Moog_cget_modSpeed() |
| 27499 | // desc: CGET function ... |
| 27500 | //----------------------------------------------------------------------------- |
| 27501 | CK_DLL_CGET( Moog_cget_modSpeed ) |
| 27502 | { |
| 27503 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27504 | RETURN->v_float = (t_CKFLOAT) m->loops[1]->m_freq; |
| 27505 | } |
| 27506 | |
| 27507 | |
| 27508 | //----------------------------------------------------------------------------- |
| 27509 | // name: Moog_ctrl_modDepth() |
| 27510 | // desc: CTRL function ... |
| 27511 | //----------------------------------------------------------------------------- |
| 27512 | CK_DLL_CTRL( Moog_ctrl_modDepth ) |
| 27513 | { |
| 27514 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27515 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27516 | m->setModulationDepth(f); |
| 27517 | RETURN->v_float = (t_CKFLOAT) m->modDepth * 2.0; |
| 27518 | } |
| 27519 | |
| 27520 | |
| 27521 | //----------------------------------------------------------------------------- |
| 27522 | // name: Moog_cget_modDepth() |
| 27523 | // desc: CGET function ... |
| 27524 | //----------------------------------------------------------------------------- |
| 27525 | CK_DLL_CGET( Moog_cget_modDepth ) |
| 27526 | { |
| 27527 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27528 | RETURN->v_float = (t_CKFLOAT) m->modDepth * 2.0; |
| 27529 | } |
| 27530 | |
| 27531 | |
| 27532 | //----------------------------------------------------------------------------- |
| 27533 | // name: Moog_ctrl_filterQ() |
| 27534 | // desc: CTRL function ... |
| 27535 | //----------------------------------------------------------------------------- |
| 27536 | CK_DLL_CTRL( Moog_ctrl_filterQ ) |
| 27537 | { |
| 27538 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27539 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27540 | m->controlChange( __SK_FilterQ_, f * 128.0 ); |
| 27541 | RETURN->v_float = (t_CKFLOAT)10.0 * ( m->filterQ - 0.80 ); |
| 27542 | } |
| 27543 | |
| 27544 | |
| 27545 | //----------------------------------------------------------------------------- |
| 27546 | // name: Moog_cget_filterQ() |
| 27547 | // desc: CGET function ... |
| 27548 | //----------------------------------------------------------------------------- |
| 27549 | CK_DLL_CGET( Moog_cget_filterQ ) |
| 27550 | { |
| 27551 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27552 | RETURN->v_float = (t_CKFLOAT)10.0 * ( m->filterQ - 0.80 ); |
| 27553 | } |
| 27554 | |
| 27555 | |
| 27556 | //----------------------------------------------------------------------------- |
| 27557 | // name: Moog_ctrl_filterSweepRate() |
| 27558 | // desc: CTRL function ... |
| 27559 | //----------------------------------------------------------------------------- |
| 27560 | CK_DLL_CTRL( Moog_ctrl_filterSweepRate ) |
| 27561 | { |
| 27562 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27563 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27564 | m->controlChange( __SK_FilterSweepRate_, f * 128.0 ); |
| 27565 | RETURN->v_float = (t_CKFLOAT)m->filterRate * 5000; |
| 27566 | } |
| 27567 | |
| 27568 | |
| 27569 | //----------------------------------------------------------------------------- |
| 27570 | // name: Moog_cget_filterSweepRate() |
| 27571 | // desc: CGET function ... |
| 27572 | //----------------------------------------------------------------------------- |
| 27573 | CK_DLL_CGET( Moog_cget_filterSweepRate ) |
| 27574 | { |
| 27575 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27576 | RETURN->v_float = (t_CKFLOAT)m->filterRate * 5000; |
| 27577 | } |
| 27578 | |
| 27579 | |
| 27580 | //----------------------------------------------------------------------------- |
| 27581 | // name: Moog_ctrl_filterStartFreq() |
| 27582 | // desc: CTRL function | added 1.4.1.0 (prc) REPAIRATHON2021 |
| 27583 | //----------------------------------------------------------------------------- |
| 27584 | CK_DLL_CTRL( Moog_ctrl_filterStartFreq ) |
| 27585 | { |
| 27586 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27587 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27588 | // m->filterStartFreq( f ); |
| 27589 | m->filterStartFreq = f; |
| 27590 | RETURN->v_float = (t_CKFLOAT)m->filterStartFreq; |
| 27591 | } |
| 27592 | |
| 27593 | |
| 27594 | //----------------------------------------------------------------------------- |
| 27595 | // name: Moog_cget_filterStartFreq() |
| 27596 | // desc: CGET function | added 1.4.1.0 (prc) REPAIRATHON2021 |
| 27597 | //----------------------------------------------------------------------------- |
| 27598 | CK_DLL_CGET( Moog_cget_filterStartFreq ) |
| 27599 | { |
| 27600 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27601 | RETURN->v_float = (t_CKFLOAT)m->filterStartFreq; |
| 27602 | } |
| 27603 | |
| 27604 | |
| 27605 | //----------------------------------------------------------------------------- |
| 27606 | // name: Moog_ctrl_afterTouch() |
| 27607 | // desc: CTRL function ... |
| 27608 | //----------------------------------------------------------------------------- |
| 27609 | CK_DLL_CTRL( Moog_ctrl_afterTouch ) |
| 27610 | { |
| 27611 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27612 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27613 | m->controlChange( __SK_AfterTouch_Cont_, f * 128.0 ); |
| 27614 | } |
| 27615 | |
| 27616 | |
| 27617 | //----------------------------------------------------------------------------- |
| 27618 | // name: Moog_ctrl_vibratoFreq() |
| 27619 | // desc: CTRL function ... |
| 27620 | //----------------------------------------------------------------------------- |
| 27621 | CK_DLL_CTRL( Moog_ctrl_vibratoFreq ) |
| 27622 | { |
| 27623 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27624 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27625 | m->setModulationSpeed(f); |
| 27626 | RETURN->v_float = (t_CKFLOAT)m->m_vibratoFreq; |
| 27627 | } |
| 27628 | |
| 27629 | |
| 27630 | //----------------------------------------------------------------------------- |
| 27631 | // name: Moog_cget_vibratoFreq() |
| 27632 | // desc: CGET function ... |
| 27633 | //----------------------------------------------------------------------------- |
| 27634 | CK_DLL_CGET( Moog_cget_vibratoFreq ) |
| 27635 | { |
| 27636 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27637 | RETURN->v_float = (t_CKFLOAT)m->m_vibratoFreq; |
| 27638 | } |
| 27639 | |
| 27640 | |
| 27641 | //----------------------------------------------------------------------------- |
| 27642 | // name: Moog_ctrl_vibratoGain() |
| 27643 | // desc: CTRL function ... |
| 27644 | //----------------------------------------------------------------------------- |
| 27645 | CK_DLL_CTRL( Moog_ctrl_vibratoGain ) |
| 27646 | { |
| 27647 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27648 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27649 | m->controlChange( __SK_ModWheel_, f * 128.0 ); |
| 27650 | RETURN->v_float = (t_CKFLOAT)m->m_vibratoGain; |
| 27651 | } |
| 27652 | |
| 27653 | |
| 27654 | //----------------------------------------------------------------------------- |
| 27655 | // name: Moog_cget_vibratoGain() |
| 27656 | // desc: CGET function ... |
| 27657 | //----------------------------------------------------------------------------- |
| 27658 | CK_DLL_CGET( Moog_cget_vibratoGain ) |
| 27659 | { |
| 27660 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27661 | RETURN->v_float = (t_CKFLOAT)m->m_vibratoGain; |
| 27662 | } |
| 27663 | |
| 27664 | |
| 27665 | //----------------------------------------------------------------------------- |
| 27666 | // name: Moog_ctrl_volume() |
| 27667 | // desc: CTRL function ... |
| 27668 | //----------------------------------------------------------------------------- |
| 27669 | CK_DLL_CTRL( Moog_ctrl_volume ) |
| 27670 | { |
| 27671 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27672 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27673 | m->controlChange( __SK_AfterTouch_Cont_, f * 128.0 ); |
| 27674 | RETURN->v_float = (t_CKFLOAT)m->m_volume; |
| 27675 | } |
| 27676 | |
| 27677 | |
| 27678 | //----------------------------------------------------------------------------- |
| 27679 | // name: Moog_cget_volume() |
| 27680 | // desc: CGET function ... |
| 27681 | //----------------------------------------------------------------------------- |
| 27682 | CK_DLL_CGET( Moog_cget_volume ) |
| 27683 | { |
| 27684 | Moog * m = (Moog *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27685 | RETURN->v_float = (t_CKFLOAT)m->m_volume; |
| 27686 | } |
| 27687 | |
| 27688 | |
| 27689 | |
| 27690 | |
| 27691 | // NRev |
| 27692 | //----------------------------------------------------------------------------- |
| 27693 | // name: NRev_ctor() |
| 27694 | // desc: CTOR function ... |
| 27695 | //----------------------------------------------------------------------------- |
| 27696 | CK_DLL_CTOR( NRev_ctor ) |
| 27697 | { |
| 27698 | // initialize member object |
| 27699 | OBJ_MEMBER_UINT(SELF, NRev_offset_data) = (t_CKUINT)new NRev( 4.0f ); |
| 27700 | } |
| 27701 | |
| 27702 | |
| 27703 | //----------------------------------------------------------------------------- |
| 27704 | // name: NRev_ctor_mix() |
| 27705 | // desc: CTOR function ... |
| 27706 | //----------------------------------------------------------------------------- |
| 27707 | CK_DLL_CTOR( NRev_ctor_mix ) |
| 27708 | { |
| 27709 | NRev * n = (NRev*)OBJ_MEMBER_UINT(SELF, NRev_offset_data); |
| 27710 | n->setEffectMix( GET_NEXT_FLOAT(ARGS) ); |
| 27711 | } |
| 27712 | |
| 27713 | |
| 27714 | //----------------------------------------------------------------------------- |
| 27715 | // name: NRev_dtor() |
| 27716 | // desc: DTOR function ... |
| 27717 | //----------------------------------------------------------------------------- |
| 27718 | CK_DLL_DTOR( NRev_dtor ) |
| 27719 | { |
| 27720 | delete (NRev *)OBJ_MEMBER_UINT(SELF, NRev_offset_data); |
| 27721 | OBJ_MEMBER_UINT(SELF, NRev_offset_data) = 0; |
| 27722 | } |
| 27723 | |
| 27724 | |
| 27725 | //----------------------------------------------------------------------------- |
| 27726 | // name: NRev_tick() |
| 27727 | // desc: TICK function ... |
| 27728 | //----------------------------------------------------------------------------- |
| 27729 | CK_DLL_TICK( NRev_tick ) |
| 27730 | { |
| 27731 | NRev * j = (NRev *)OBJ_MEMBER_UINT(SELF, NRev_offset_data); |
| 27732 | *out = j->tick( in ); |
| 27733 | return TRUE; |
| 27734 | } |
| 27735 | |
| 27736 | |
| 27737 | //----------------------------------------------------------------------------- |
| 27738 | // name: NRev_pmsg() |
| 27739 | // desc: PMSG function ... |
| 27740 | //----------------------------------------------------------------------------- |
| 27741 | CK_DLL_PMSG( NRev_pmsg ) |
| 27742 | { |
| 27743 | return TRUE; |
| 27744 | } |
| 27745 | |
| 27746 | |
| 27747 | //----------------------------------------------------------------------------- |
| 27748 | // name: NRev_ctrl_mix() |
| 27749 | // desc: CTRL function ... |
| 27750 | //----------------------------------------------------------------------------- |
| 27751 | CK_DLL_CTRL( NRev_ctrl_mix ) |
| 27752 | { |
| 27753 | NRev * j = (NRev *)OBJ_MEMBER_UINT(SELF, NRev_offset_data); |
| 27754 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27755 | j->setEffectMix( f ); |
| 27756 | RETURN->v_float = (t_CKFLOAT) j->effectMix; |
| 27757 | } |
| 27758 | |
| 27759 | |
| 27760 | //----------------------------------------------------------------------------- |
| 27761 | // name: NRev_cget_mix() |
| 27762 | // desc: CGET function ... |
| 27763 | //----------------------------------------------------------------------------- |
| 27764 | CK_DLL_CGET( NRev_cget_mix ) |
| 27765 | { |
| 27766 | NRev * j = (NRev *)OBJ_MEMBER_UINT(SELF, NRev_offset_data); |
| 27767 | RETURN->v_float = (t_CKFLOAT) j->effectMix; |
| 27768 | } |
| 27769 | |
| 27770 | |
| 27771 | |
| 27772 | // PitShift |
| 27773 | //----------------------------------------------------------------------------- |
| 27774 | // name: PitShift_ctor() |
| 27775 | // desc: CTOR function ... |
| 27776 | //----------------------------------------------------------------------------- |
| 27777 | CK_DLL_CTOR( PitShift_ctor ) |
| 27778 | { |
| 27779 | // initialize member object |
| 27780 | OBJ_MEMBER_UINT(SELF, PitShift_offset_data) = (t_CKUINT)new PitShift( ); |
| 27781 | } |
| 27782 | |
| 27783 | |
| 27784 | //----------------------------------------------------------------------------- |
| 27785 | // name: PitShift_ctor_shift() |
| 27786 | // desc: CTOR function ... |
| 27787 | //----------------------------------------------------------------------------- |
| 27788 | CK_DLL_CTOR( PitShift_ctor_shift ) |
| 27789 | { |
| 27790 | PitShift * p = (PitShift*)OBJ_MEMBER_UINT(SELF, PitShift_offset_data); |
| 27791 | p->setShift( GET_NEXT_FLOAT(ARGS) ); |
| 27792 | } |
| 27793 | |
| 27794 | |
| 27795 | //----------------------------------------------------------------------------- |
| 27796 | // name: PitShift_ctor_shift_mix() |
| 27797 | // desc: CTOR function ... |
| 27798 | //----------------------------------------------------------------------------- |
| 27799 | CK_DLL_CTOR( PitShift_ctor_shift_mix ) |
| 27800 | { |
| 27801 | PitShift * p = (PitShift*)OBJ_MEMBER_UINT(SELF, PitShift_offset_data); |
| 27802 | p->setShift( GET_NEXT_FLOAT(ARGS) ); |
| 27803 | p->setEffectMix( GET_NEXT_FLOAT(ARGS) ); |
| 27804 | } |
| 27805 | |
| 27806 | |
| 27807 | //----------------------------------------------------------------------------- |
| 27808 | // name: PitShift_dtor() |
| 27809 | // desc: DTOR function ... |
| 27810 | //----------------------------------------------------------------------------- |
| 27811 | CK_DLL_DTOR( PitShift_dtor ) |
| 27812 | { |
| 27813 | delete (PitShift *)OBJ_MEMBER_UINT(SELF, PitShift_offset_data); |
| 27814 | OBJ_MEMBER_UINT(SELF, PitShift_offset_data) = 0; |
| 27815 | } |
| 27816 | |
| 27817 | |
| 27818 | //----------------------------------------------------------------------------- |
| 27819 | // name: PitShift_tick() |
| 27820 | // desc: TICK function ... |
| 27821 | //----------------------------------------------------------------------------- |
| 27822 | CK_DLL_TICK( PitShift_tick ) |
| 27823 | { |
| 27824 | PitShift * p = (PitShift *)OBJ_MEMBER_UINT(SELF, PitShift_offset_data); |
| 27825 | *out = p->tick( in ); |
| 27826 | return TRUE; |
| 27827 | } |
| 27828 | |
| 27829 | |
| 27830 | //----------------------------------------------------------------------------- |
| 27831 | // name: PitShift_pmsg() |
| 27832 | // desc: PMSG function ... |
| 27833 | //----------------------------------------------------------------------------- |
| 27834 | CK_DLL_PMSG( PitShift_pmsg ) |
| 27835 | { |
| 27836 | return TRUE; |
| 27837 | } |
| 27838 | |
| 27839 | |
| 27840 | //----------------------------------------------------------------------------- |
| 27841 | // name: PitShift_ctrl_shift() |
| 27842 | // desc: CTRL function ... |
| 27843 | //----------------------------------------------------------------------------- |
| 27844 | CK_DLL_CTRL( PitShift_ctrl_shift ) |
| 27845 | { |
| 27846 | PitShift * p = (PitShift *)OBJ_MEMBER_UINT(SELF, PitShift_offset_data); |
| 27847 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27848 | p->setShift( f ); |
| 27849 | RETURN->v_float = (t_CKFLOAT)1.0 - p->rate; |
| 27850 | } |
| 27851 | |
| 27852 | |
| 27853 | //----------------------------------------------------------------------------- |
| 27854 | // name: PitShift_cget_shift() |
| 27855 | // desc: CGET function ... |
| 27856 | //----------------------------------------------------------------------------- |
| 27857 | CK_DLL_CGET( PitShift_cget_shift ) |
| 27858 | { |
| 27859 | PitShift * p = (PitShift *)OBJ_MEMBER_UINT(SELF, PitShift_offset_data); |
| 27860 | RETURN->v_float = (t_CKFLOAT)1.0 - p->rate; |
| 27861 | } |
| 27862 | |
| 27863 | |
| 27864 | //----------------------------------------------------------------------------- |
| 27865 | // name: PitShift_ctrl_effectMix() |
| 27866 | // desc: CTRL function ... |
| 27867 | //----------------------------------------------------------------------------- |
| 27868 | CK_DLL_CTRL( PitShift_ctrl_effectMix ) |
| 27869 | { |
| 27870 | PitShift * p = (PitShift *)OBJ_MEMBER_UINT(SELF, PitShift_offset_data); |
| 27871 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27872 | p->setEffectMix( f ); |
| 27873 | RETURN->v_float = (t_CKFLOAT)p->effectMix; |
| 27874 | } |
| 27875 | |
| 27876 | |
| 27877 | //----------------------------------------------------------------------------- |
| 27878 | // name: PitShift_cget_effectMix() |
| 27879 | // desc: CGET function ... |
| 27880 | //----------------------------------------------------------------------------- |
| 27881 | CK_DLL_CGET( PitShift_cget_effectMix ) |
| 27882 | { |
| 27883 | PitShift * p = (PitShift *)OBJ_MEMBER_UINT(SELF, PitShift_offset_data); |
| 27884 | RETURN->v_float = (t_CKFLOAT)p->effectMix; |
| 27885 | } |
| 27886 | |
| 27887 | |
| 27888 | |
| 27889 | // PRCRev |
| 27890 | //----------------------------------------------------------------------------- |
| 27891 | // name: PRCRev_ctor() |
| 27892 | // desc: CTOR function ... |
| 27893 | //----------------------------------------------------------------------------- |
| 27894 | CK_DLL_CTOR( PRCRev_ctor ) |
| 27895 | { |
| 27896 | // initialize member object |
| 27897 | OBJ_MEMBER_UINT(SELF, PRCRev_offset_data) = (t_CKUINT)new PRCRev( 4.0f ); |
| 27898 | } |
| 27899 | |
| 27900 | |
| 27901 | //----------------------------------------------------------------------------- |
| 27902 | // name: PRCRev_ctor_mix() |
| 27903 | // desc: CTOR function ... |
| 27904 | //----------------------------------------------------------------------------- |
| 27905 | CK_DLL_CTOR( PRCRev_ctor_mix ) |
| 27906 | { |
| 27907 | PRCRev * p = (PRCRev*)OBJ_MEMBER_UINT(SELF, PRCRev_offset_data); |
| 27908 | p->setEffectMix( GET_NEXT_FLOAT(ARGS) ); |
| 27909 | } |
| 27910 | |
| 27911 | |
| 27912 | //----------------------------------------------------------------------------- |
| 27913 | // name: PRCRev_dtor() |
| 27914 | // desc: DTOR function ... |
| 27915 | //----------------------------------------------------------------------------- |
| 27916 | CK_DLL_DTOR( PRCRev_dtor ) |
| 27917 | { |
| 27918 | delete (PRCRev *)OBJ_MEMBER_UINT(SELF, PRCRev_offset_data); |
| 27919 | OBJ_MEMBER_UINT(SELF, PRCRev_offset_data) = 0; |
| 27920 | } |
| 27921 | |
| 27922 | |
| 27923 | //----------------------------------------------------------------------------- |
| 27924 | // name: PRCRev_tick() |
| 27925 | // desc: TICK function ... |
| 27926 | //----------------------------------------------------------------------------- |
| 27927 | CK_DLL_TICK( PRCRev_tick ) |
| 27928 | { |
| 27929 | PRCRev * j = (PRCRev *)OBJ_MEMBER_UINT(SELF, PRCRev_offset_data); |
| 27930 | *out = j->tick( in ); |
| 27931 | return TRUE; |
| 27932 | } |
| 27933 | |
| 27934 | |
| 27935 | //----------------------------------------------------------------------------- |
| 27936 | // name: PRCRev_pmsg() |
| 27937 | // desc: PMSG function ... |
| 27938 | //----------------------------------------------------------------------------- |
| 27939 | CK_DLL_PMSG( PRCRev_pmsg ) |
| 27940 | { |
| 27941 | return TRUE; |
| 27942 | } |
| 27943 | |
| 27944 | |
| 27945 | //----------------------------------------------------------------------------- |
| 27946 | // name: PRCRev_ctrl_mix() |
| 27947 | // desc: CTRL function ... |
| 27948 | //----------------------------------------------------------------------------- |
| 27949 | CK_DLL_CTRL( PRCRev_ctrl_mix ) |
| 27950 | { |
| 27951 | PRCRev * j = (PRCRev *)OBJ_MEMBER_UINT(SELF, PRCRev_offset_data); |
| 27952 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 27953 | j->setEffectMix( f ); |
| 27954 | RETURN->v_float = (t_CKFLOAT)j->effectMix; |
| 27955 | } |
| 27956 | |
| 27957 | |
| 27958 | //----------------------------------------------------------------------------- |
| 27959 | // name: PRCRev_cget_mix() |
| 27960 | // desc: CGET function ... |
| 27961 | //----------------------------------------------------------------------------- |
| 27962 | CK_DLL_CGET( PRCRev_cget_mix ) |
| 27963 | { |
| 27964 | PRCRev * j = (PRCRev *)OBJ_MEMBER_UINT(SELF, PRCRev_offset_data); |
| 27965 | RETURN->v_float = (t_CKFLOAT)j->effectMix; |
| 27966 | } |
| 27967 | |
| 27968 | |
| 27969 | //----------------------------------------------------------------------------- |
| 27970 | // name: Shakers_ctor() |
| 27971 | // desc: CTOR function ... |
| 27972 | //----------------------------------------------------------------------------- |
| 27973 | CK_DLL_CTOR( Shakers_ctor ) |
| 27974 | { |
| 27975 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new Shakers; |
| 27976 | } |
| 27977 | |
| 27978 | |
| 27979 | //----------------------------------------------------------------------------- |
| 27980 | // name: Shakers_dtor() |
| 27981 | // desc: DTOR function ... |
| 27982 | //----------------------------------------------------------------------------- |
| 27983 | CK_DLL_DTOR( Shakers_dtor ) |
| 27984 | { |
| 27985 | delete (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27986 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 27987 | } |
| 27988 | |
| 27989 | |
| 27990 | //----------------------------------------------------------------------------- |
| 27991 | // name: Shakers_tick() |
| 27992 | // desc: TICK function ... |
| 27993 | //----------------------------------------------------------------------------- |
| 27994 | CK_DLL_TICK( Shakers_tick ) |
| 27995 | { |
| 27996 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 27997 | *out = s->tick(); |
| 27998 | return TRUE; |
| 27999 | } |
| 28000 | |
| 28001 | |
| 28002 | //----------------------------------------------------------------------------- |
| 28003 | // name: Shakers_pmsg() |
| 28004 | // desc: PMSG function ... |
| 28005 | //----------------------------------------------------------------------------- |
| 28006 | CK_DLL_PMSG( Shakers_pmsg ) |
| 28007 | { |
| 28008 | return TRUE; |
| 28009 | } |
| 28010 | |
| 28011 | |
| 28012 | //----------------------------------------------------------------------------- |
| 28013 | // name: Shakers_ctrl_which() |
| 28014 | // desc: CTRL function ... |
| 28015 | //----------------------------------------------------------------------------- |
| 28016 | CK_DLL_CTRL( Shakers_ctrl_which ) |
| 28017 | { |
| 28018 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28019 | t_CKINT c = GET_CK_INT(ARGS); |
| 28020 | s->setupNum( c ); |
| 28021 | RETURN->v_int = (t_CKINT)s->m_noteNum; |
| 28022 | } |
| 28023 | |
| 28024 | |
| 28025 | //----------------------------------------------------------------------------- |
| 28026 | // name: Shakers_cget_which() |
| 28027 | // desc: CGET function ... |
| 28028 | //----------------------------------------------------------------------------- |
| 28029 | CK_DLL_CGET( Shakers_cget_which ) |
| 28030 | { |
| 28031 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28032 | RETURN->v_int = (t_CKINT)s->m_noteNum; |
| 28033 | } |
| 28034 | |
| 28035 | |
| 28036 | //----------------------------------------------------------------------------- |
| 28037 | // name: Shakers_ctrl_energy() |
| 28038 | // desc: CTRL function ... |
| 28039 | //----------------------------------------------------------------------------- |
| 28040 | CK_DLL_CTRL( Shakers_ctrl_energy ) |
| 28041 | { |
| 28042 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28043 | t_CKFLOAT e = GET_NEXT_FLOAT(ARGS); |
| 28044 | s->controlChange( 2, e * 128.0 ); |
| 28045 | s->m_energy = e; |
| 28046 | RETURN->v_float = (t_CKFLOAT)s->m_energy; |
| 28047 | } |
| 28048 | |
| 28049 | |
| 28050 | //----------------------------------------------------------------------------- |
| 28051 | // name: Shakers_cget_energy() |
| 28052 | // desc: CGET function ... |
| 28053 | //----------------------------------------------------------------------------- |
| 28054 | CK_DLL_CGET( Shakers_cget_energy ) |
| 28055 | { |
| 28056 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28057 | RETURN->v_float = (t_CKFLOAT)s->m_energy; |
| 28058 | } |
| 28059 | |
| 28060 | |
| 28061 | //----------------------------------------------------------------------------- |
| 28062 | // name: Shakers_ctrl_decay() |
| 28063 | // desc: CTRL function ... |
| 28064 | //----------------------------------------------------------------------------- |
| 28065 | CK_DLL_CTRL( Shakers_ctrl_decay ) |
| 28066 | { |
| 28067 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28068 | t_CKFLOAT e = GET_NEXT_FLOAT(ARGS); |
| 28069 | s->controlChange( 4, e * 128.0 ); |
| 28070 | s->m_decay = e; |
| 28071 | RETURN->v_float = (t_CKFLOAT)s->m_decay; |
| 28072 | } |
| 28073 | |
| 28074 | |
| 28075 | //----------------------------------------------------------------------------- |
| 28076 | // name: Shakers_cget_decay() |
| 28077 | // desc: CGET function ... |
| 28078 | //----------------------------------------------------------------------------- |
| 28079 | CK_DLL_CGET( Shakers_cget_decay ) |
| 28080 | { |
| 28081 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28082 | RETURN->v_float = (t_CKFLOAT)s->m_decay; |
| 28083 | } |
| 28084 | |
| 28085 | |
| 28086 | //----------------------------------------------------------------------------- |
| 28087 | // name: Shakers_ctrl_objects() |
| 28088 | // desc: CTRL function ... |
| 28089 | //----------------------------------------------------------------------------- |
| 28090 | CK_DLL_CTRL( Shakers_ctrl_objects ) |
| 28091 | { |
| 28092 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28093 | t_CKFLOAT e = GET_NEXT_FLOAT(ARGS); |
| 28094 | s->controlChange( 11, e ); |
| 28095 | s->m_objects = e; |
| 28096 | RETURN->v_float = (t_CKFLOAT)s->m_objects; |
| 28097 | } |
| 28098 | |
| 28099 | |
| 28100 | //----------------------------------------------------------------------------- |
| 28101 | // name: Shakers_cget_objects() |
| 28102 | // desc: CGET function ... |
| 28103 | //----------------------------------------------------------------------------- |
| 28104 | CK_DLL_CGET( Shakers_cget_objects ) |
| 28105 | { |
| 28106 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28107 | RETURN->v_float = (t_CKFLOAT)s->m_objects; |
| 28108 | } |
| 28109 | |
| 28110 | |
| 28111 | //----------------------------------------------------------------------------- |
| 28112 | // name: Shakers_ctrl_freq() |
| 28113 | // desc: CTRL function ... |
| 28114 | //----------------------------------------------------------------------------- |
| 28115 | CK_DLL_CTRL( Shakers_ctrl_freq ) |
| 28116 | { |
| 28117 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28118 | s->freq = GET_NEXT_FLOAT(ARGS); |
| 28119 | s->controlChange( __SK_ModWheel_, ck_ftom(s->freq) ); |
| 28120 | RETURN->v_float = (t_CKFLOAT)s->freq; |
| 28121 | } |
| 28122 | |
| 28123 | |
| 28124 | //----------------------------------------------------------------------------- |
| 28125 | // name: Shakers_cget_freq() |
| 28126 | // desc: CGET function ... |
| 28127 | //----------------------------------------------------------------------------- |
| 28128 | CK_DLL_CGET( Shakers_cget_freq ) |
| 28129 | { |
| 28130 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT( SELF, Instrmnt_offset_data); |
| 28131 | RETURN->v_float = (t_CKFLOAT)s->freq; |
| 28132 | } |
| 28133 | |
| 28134 | |
| 28135 | //----------------------------------------------------------------------------- |
| 28136 | // name: Shakers_ctrl_noteOn() |
| 28137 | // desc: CTRL function ... |
| 28138 | //----------------------------------------------------------------------------- |
| 28139 | CK_DLL_CTRL( Shakers_ctrl_noteOn ) |
| 28140 | { |
| 28141 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28142 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28143 | s->ck_noteOn( f ); |
| 28144 | } |
| 28145 | |
| 28146 | |
| 28147 | //----------------------------------------------------------------------------- |
| 28148 | // name: Shakers_ctrl_noteOff() |
| 28149 | // desc: CTRL function ... |
| 28150 | //----------------------------------------------------------------------------- |
| 28151 | CK_DLL_CTRL( Shakers_ctrl_noteOff ) |
| 28152 | { |
| 28153 | Shakers * s = (Shakers *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28154 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28155 | s->noteOff( f ); |
| 28156 | } |
| 28157 | |
| 28158 | |
| 28159 | |
| 28160 | |
| 28161 | //----------------------------------------------------------------------------- |
| 28162 | // name: SubNoise_ctor() |
| 28163 | // desc: CTOR function ... |
| 28164 | //----------------------------------------------------------------------------- |
| 28165 | CK_DLL_CTOR( SubNoise_ctor ) |
| 28166 | { |
| 28167 | // initialize member object |
| 28168 | OBJ_MEMBER_UINT(SELF, SubNoise_offset_data) = (t_CKUINT)new SubNoise( ); |
| 28169 | } |
| 28170 | |
| 28171 | |
| 28172 | //----------------------------------------------------------------------------- |
| 28173 | // name: SubNoise_dtor() |
| 28174 | // desc: DTOR function ... |
| 28175 | //----------------------------------------------------------------------------- |
| 28176 | CK_DLL_DTOR( SubNoise_dtor ) |
| 28177 | { |
| 28178 | delete (SubNoise *)OBJ_MEMBER_UINT(SELF, SubNoise_offset_data); |
| 28179 | OBJ_MEMBER_UINT(SELF, SubNoise_offset_data) = 0; |
| 28180 | } |
| 28181 | |
| 28182 | |
| 28183 | //----------------------------------------------------------------------------- |
| 28184 | // name: SubNoise_tick() |
| 28185 | // desc: TICK function ... |
| 28186 | //----------------------------------------------------------------------------- |
| 28187 | CK_DLL_TICK( SubNoise_tick ) |
| 28188 | { |
| 28189 | SubNoise * p = (SubNoise *)OBJ_MEMBER_UINT(SELF, SubNoise_offset_data); |
| 28190 | *out = p->tick(); |
| 28191 | return TRUE; |
| 28192 | } |
| 28193 | |
| 28194 | |
| 28195 | //----------------------------------------------------------------------------- |
| 28196 | // name: SubNoise_pmsg() |
| 28197 | // desc: PMSG function ... |
| 28198 | //----------------------------------------------------------------------------- |
| 28199 | CK_DLL_PMSG( SubNoise_pmsg ) |
| 28200 | { |
| 28201 | return TRUE; |
| 28202 | } |
| 28203 | |
| 28204 | |
| 28205 | //----------------------------------------------------------------------------- |
| 28206 | // name: SubNoise_ctrl_rate() |
| 28207 | // desc: CTRL function ... |
| 28208 | //----------------------------------------------------------------------------- |
| 28209 | CK_DLL_CTRL( SubNoise_ctrl_rate ) |
| 28210 | { |
| 28211 | SubNoise * p = (SubNoise *)OBJ_MEMBER_UINT(SELF, SubNoise_offset_data); |
| 28212 | int i = GET_CK_INT(ARGS); |
| 28213 | p->setRate( i ); |
| 28214 | RETURN->v_int = (t_CKINT) (int)((SubNoise *)OBJ_MEMBER_UINT(SELF, SubNoise_offset_data))->subRate(); |
| 28215 | } |
| 28216 | |
| 28217 | |
| 28218 | //----------------------------------------------------------------------------- |
| 28219 | // name: SubNoise_cget_rate() |
| 28220 | // desc: CTRL function ... |
| 28221 | //----------------------------------------------------------------------------- |
| 28222 | CK_DLL_CGET( SubNoise_cget_rate ) |
| 28223 | { |
| 28224 | RETURN->v_int = (t_CKINT) (int)((SubNoise *)OBJ_MEMBER_UINT(SELF, SubNoise_offset_data))->subRate(); |
| 28225 | } |
| 28226 | |
| 28227 | |
| 28228 | |
| 28229 | |
| 28230 | |
| 28231 | //----------------------------------------------------------------------------- |
| 28232 | // name: VoicForm_ctor() |
| 28233 | // desc: CTOR function ... |
| 28234 | //----------------------------------------------------------------------------- |
| 28235 | CK_DLL_CTOR( VoicForm_ctor ) |
| 28236 | { |
| 28237 | // initialize member object |
| 28238 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new VoicForm(); |
| 28239 | } |
| 28240 | |
| 28241 | |
| 28242 | //----------------------------------------------------------------------------- |
| 28243 | // name: VoicForm_dtor() |
| 28244 | // desc: DTOR function ... |
| 28245 | //----------------------------------------------------------------------------- |
| 28246 | CK_DLL_DTOR( VoicForm_dtor ) |
| 28247 | { |
| 28248 | delete (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28249 | OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0; |
| 28250 | } |
| 28251 | |
| 28252 | |
| 28253 | //----------------------------------------------------------------------------- |
| 28254 | // name: VoicForm_tick() |
| 28255 | // desc: TICK function ... |
| 28256 | //----------------------------------------------------------------------------- |
| 28257 | CK_DLL_TICK( VoicForm_tick ) |
| 28258 | { |
| 28259 | VoicForm * m = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28260 | *out = m->tick(); |
| 28261 | return TRUE; |
| 28262 | } |
| 28263 | |
| 28264 | |
| 28265 | //----------------------------------------------------------------------------- |
| 28266 | // name: VoicForm_pmsg() |
| 28267 | // desc: PMSG function ... |
| 28268 | //----------------------------------------------------------------------------- |
| 28269 | CK_DLL_PMSG( VoicForm_pmsg ) |
| 28270 | { |
| 28271 | return TRUE; |
| 28272 | } |
| 28273 | |
| 28274 | |
| 28275 | //----------------------------------------------------------------------------- |
| 28276 | // name: VoicForm_ctrl_speak() |
| 28277 | // desc: CTRL function ... |
| 28278 | //----------------------------------------------------------------------------- |
| 28279 | CK_DLL_CTRL( VoicForm_ctrl_speak ) |
| 28280 | { |
| 28281 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28282 | v->speak(); |
| 28283 | } |
| 28284 | |
| 28285 | |
| 28286 | //----------------------------------------------------------------------------- |
| 28287 | // name: VoicForm_ctrl_quiet() |
| 28288 | // desc: CTRL function ... |
| 28289 | //----------------------------------------------------------------------------- |
| 28290 | CK_DLL_CTRL( VoicForm_ctrl_quiet ) |
| 28291 | { |
| 28292 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28293 | v->quiet(); |
| 28294 | } |
| 28295 | |
| 28296 | |
| 28297 | //----------------------------------------------------------------------------- |
| 28298 | // name: VoicForm_ctrl_phoneme() |
| 28299 | // desc: CTRL function ... |
| 28300 | //----------------------------------------------------------------------------- |
| 28301 | CK_DLL_CTRL( VoicForm_ctrl_phoneme ) |
| 28302 | { |
| 28303 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28304 | Chuck_String * phoneme = GET_NEXT_STRING( ARGS ); |
| 28305 | // check for NULL | 1.5.0.0 (ge) |
| 28306 | if( phoneme != NULL) |
| 28307 | { |
| 28308 | // set phoneme |
| 28309 | v->setPhoneme( phoneme->str().c_str() ); |
| 28310 | } |
| 28311 | // return value |
| 28312 | RETURN->v_string = phoneme; |
| 28313 | } |
| 28314 | |
| 28315 | |
| 28316 | //----------------------------------------------------------------------------- |
| 28317 | // name: VoicForm_cget_phoneme() |
| 28318 | // desc: CGET function ... |
| 28319 | //----------------------------------------------------------------------------- |
| 28320 | CK_DLL_CGET( VoicForm_cget_phoneme ) |
| 28321 | { |
| 28322 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28323 | // instantiate | 1.5.0.0 (ge) added to dynamic allocate chuck string |
| 28324 | Chuck_String * str = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->ckt_string, SHRED ); |
| 28325 | // set |
| 28326 | str->set( v->str_phoneme ); |
| 28327 | RETURN->v_string = str; |
| 28328 | } |
| 28329 | |
| 28330 | |
| 28331 | //----------------------------------------------------------------------------- |
| 28332 | // name: VoicForm_ctrl_voiced() |
| 28333 | // desc: CTRL function ... |
| 28334 | //----------------------------------------------------------------------------- |
| 28335 | CK_DLL_CTRL( VoicForm_ctrl_voiced ) |
| 28336 | { |
| 28337 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28338 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28339 | v->setVoiced( f ); |
| 28340 | RETURN->v_float = (t_CKFLOAT)v->voiced->envelope->value; |
| 28341 | } |
| 28342 | |
| 28343 | |
| 28344 | //----------------------------------------------------------------------------- |
| 28345 | // name: VoicForm_cget_voiced() |
| 28346 | // desc: CGET function ... |
| 28347 | //----------------------------------------------------------------------------- |
| 28348 | CK_DLL_CGET( VoicForm_cget_voiced ) |
| 28349 | { |
| 28350 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28351 | |
| 28352 | RETURN->v_float = (t_CKFLOAT)v->voiced->envelope->value; |
| 28353 | } |
| 28354 | |
| 28355 | |
| 28356 | //----------------------------------------------------------------------------- |
| 28357 | // name: VoicForm_ctrl_unVoiced() |
| 28358 | // desc: CTRL function ... |
| 28359 | //----------------------------------------------------------------------------- |
| 28360 | CK_DLL_CTRL( VoicForm_ctrl_unVoiced ) |
| 28361 | { |
| 28362 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28363 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28364 | v->setUnVoiced( f ); //not sure if this should be multiplied |
| 28365 | RETURN->v_float = (t_CKFLOAT)v->noiseEnv->value; |
| 28366 | } |
| 28367 | |
| 28368 | |
| 28369 | //----------------------------------------------------------------------------- |
| 28370 | // name: VoicForm_cget_unVoiced() |
| 28371 | // desc: CGET function ... |
| 28372 | //----------------------------------------------------------------------------- |
| 28373 | CK_DLL_CGET( VoicForm_cget_unVoiced ) |
| 28374 | { |
| 28375 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28376 | RETURN->v_float = (t_CKFLOAT)v->noiseEnv->value; |
| 28377 | } |
| 28378 | |
| 28379 | |
| 28380 | //----------------------------------------------------------------------------- |
| 28381 | // name: VoicForm_ctrl_voiceMix() |
| 28382 | // desc: CTRL function ... |
| 28383 | //----------------------------------------------------------------------------- |
| 28384 | CK_DLL_CTRL( VoicForm_ctrl_voiceMix ) |
| 28385 | { |
| 28386 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28387 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28388 | v->controlChange(__SK_Breath_, f * 128.0 ); |
| 28389 | RETURN->v_float = (t_CKFLOAT)v->voiced->envelope->value; |
| 28390 | } |
| 28391 | |
| 28392 | |
| 28393 | //----------------------------------------------------------------------------- |
| 28394 | // name: VoicForm_cget_voiceMix() |
| 28395 | // desc: CGET function ... |
| 28396 | //----------------------------------------------------------------------------- |
| 28397 | CK_DLL_CGET( VoicForm_cget_voiceMix ) |
| 28398 | { |
| 28399 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28400 | RETURN->v_float = (t_CKFLOAT)v->voiced->envelope->value; |
| 28401 | } |
| 28402 | |
| 28403 | |
| 28404 | //----------------------------------------------------------------------------- |
| 28405 | // name: VoicForm_ctrl_selPhoneme() |
| 28406 | // desc: CTRL function ... |
| 28407 | //----------------------------------------------------------------------------- |
| 28408 | CK_DLL_CTRL( VoicForm_ctrl_selPhoneme ) |
| 28409 | { |
| 28410 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28411 | t_CKINT i = GET_CK_INT(ARGS); |
| 28412 | v->controlChange(__SK_FootControl_, i); |
| 28413 | RETURN->v_float = (t_CKFLOAT)v->m_phonemeNum; |
| 28414 | } |
| 28415 | |
| 28416 | |
| 28417 | //----------------------------------------------------------------------------- |
| 28418 | // name: VoicForm_cget_selPhoneme() |
| 28419 | // desc: CGET function ... |
| 28420 | //----------------------------------------------------------------------------- |
| 28421 | CK_DLL_CGET( VoicForm_cget_selPhoneme ) |
| 28422 | { |
| 28423 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28424 | RETURN->v_float = (t_CKFLOAT)v->m_phonemeNum; |
| 28425 | } |
| 28426 | |
| 28427 | |
| 28428 | //----------------------------------------------------------------------------- |
| 28429 | // name: VoicForm_ctrl_vibratoFreq() |
| 28430 | // desc: CTRL function ... |
| 28431 | //----------------------------------------------------------------------------- |
| 28432 | CK_DLL_CTRL( VoicForm_ctrl_vibratoFreq ) |
| 28433 | { |
| 28434 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28435 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28436 | v->voiced->modulator->vibrato->setFrequency( f ); |
| 28437 | RETURN->v_float = (t_CKFLOAT)v->voiced->modulator->vibrato->m_freq; |
| 28438 | } |
| 28439 | |
| 28440 | |
| 28441 | //----------------------------------------------------------------------------- |
| 28442 | // name: VoicForm_cget_vibratoFreq() |
| 28443 | // desc: CGET function ... |
| 28444 | //----------------------------------------------------------------------------- |
| 28445 | CK_DLL_CGET( VoicForm_cget_vibratoFreq ) |
| 28446 | { |
| 28447 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28448 | RETURN->v_float = (t_CKFLOAT)v->voiced->modulator->vibrato->m_freq; |
| 28449 | } |
| 28450 | |
| 28451 | |
| 28452 | //----------------------------------------------------------------------------- |
| 28453 | // name: VoicForm_ctrl_vibratoGain() |
| 28454 | // desc: CTRL function ... |
| 28455 | //----------------------------------------------------------------------------- |
| 28456 | CK_DLL_CTRL( VoicForm_ctrl_vibratoGain ) |
| 28457 | { |
| 28458 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28459 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28460 | v->controlChange(__SK_ModWheel_, f * 128.0 ); |
| 28461 | RETURN->v_float = (t_CKFLOAT) v->voiced->modulator->vibratoGain; |
| 28462 | } |
| 28463 | |
| 28464 | |
| 28465 | //----------------------------------------------------------------------------- |
| 28466 | // name: VoicForm_cget_vibratoGain() |
| 28467 | // desc: CGET function ... |
| 28468 | //----------------------------------------------------------------------------- |
| 28469 | CK_DLL_CGET( VoicForm_cget_vibratoGain ) |
| 28470 | { |
| 28471 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28472 | RETURN->v_float = (t_CKFLOAT) v->voiced->modulator->vibratoGain; |
| 28473 | } |
| 28474 | |
| 28475 | |
| 28476 | //----------------------------------------------------------------------------- |
| 28477 | // name: VoicForm_ctrl_loudness() |
| 28478 | // desc: CTRL function ... |
| 28479 | //----------------------------------------------------------------------------- |
| 28480 | CK_DLL_CTRL( VoicForm_ctrl_loudness ) |
| 28481 | { |
| 28482 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28483 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28484 | v->controlChange(__SK_AfterTouch_Cont_, f * 128.0 ); |
| 28485 | RETURN->v_float = (t_CKFLOAT) v->voiced->envelope->value; |
| 28486 | } |
| 28487 | |
| 28488 | |
| 28489 | //----------------------------------------------------------------------------- |
| 28490 | // name: VoicForm_cget_loudness() |
| 28491 | // desc: CGET function ... |
| 28492 | //----------------------------------------------------------------------------- |
| 28493 | CK_DLL_CGET( VoicForm_cget_loudness ) |
| 28494 | { |
| 28495 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28496 | RETURN->v_float = (t_CKFLOAT) v->voiced->envelope->value; |
| 28497 | } |
| 28498 | |
| 28499 | |
| 28500 | //----------------------------------------------------------------------------- |
| 28501 | // name: VoicForm_ctrl_pitchSweepRate() |
| 28502 | // desc: CTRL function ... |
| 28503 | //----------------------------------------------------------------------------- |
| 28504 | CK_DLL_CTRL( VoicForm_ctrl_pitchSweepRate ) |
| 28505 | { |
| 28506 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28507 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28508 | v->setPitchSweepRate( f ); |
| 28509 | RETURN->v_float = (t_CKFLOAT) v->voiced->m_freq; |
| 28510 | } |
| 28511 | |
| 28512 | |
| 28513 | //----------------------------------------------------------------------------- |
| 28514 | // name: VoicForm_cget_pitchSweepRate() |
| 28515 | // desc: CGET function ... |
| 28516 | //----------------------------------------------------------------------------- |
| 28517 | CK_DLL_CGET( VoicForm_cget_pitchSweepRate ) |
| 28518 | { |
| 28519 | VoicForm * v = (VoicForm *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data); |
| 28520 | RETURN->v_float = (t_CKFLOAT) v->voiced->m_freq; |
| 28521 | } |
| 28522 | |
| 28523 | |
| 28524 | |
| 28525 | // WvIn |
| 28526 | //----------------------------------------------------------------------------- |
| 28527 | // name: WvIn_ctor() |
| 28528 | // desc: CTOR function ... |
| 28529 | //----------------------------------------------------------------------------- |
| 28530 | CK_DLL_CTOR( WvIn_ctor ) |
| 28531 | { |
| 28532 | // initialize member object |
| 28533 | OBJ_MEMBER_UINT(SELF, WvIn_offset_data) = (t_CKUINT)new WvIn; |
| 28534 | } |
| 28535 | |
| 28536 | |
| 28537 | //----------------------------------------------------------------------------- |
| 28538 | // name: WvIn_dtor() |
| 28539 | // desc: DTOR function ... |
| 28540 | //----------------------------------------------------------------------------- |
| 28541 | CK_DLL_DTOR( WvIn_dtor ) |
| 28542 | { |
| 28543 | delete (WvIn *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28544 | OBJ_MEMBER_UINT(SELF, WvIn_offset_data) = 0; |
| 28545 | } |
| 28546 | |
| 28547 | |
| 28548 | //----------------------------------------------------------------------------- |
| 28549 | // name: WvIn_tick() |
| 28550 | // desc: TICK function ... |
| 28551 | //----------------------------------------------------------------------------- |
| 28552 | CK_DLL_TICK( WvIn_tick ) |
| 28553 | { |
| 28554 | WvIn * w = (WvIn *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28555 | |
| 28556 | // value is auto-scaled OR normalized in w->openFile() | 1.5.0.0 (ge) |
| 28557 | *out = ( w->m_loaded ? (t_CKFLOAT)w->tick() : (SAMPLE)0.0 ); |
| 28558 | // old: dividing by SHRT_MAX no good for for non-16bit datatypes |
| 28559 | // *out = ( w->m_loaded ? (t_CKFLOAT)w->tick() / SHRT_MAX : (SAMPLE)0.0 ); |
| 28560 | |
| 28561 | return TRUE; |
| 28562 | } |
| 28563 | |
| 28564 | |
| 28565 | //----------------------------------------------------------------------------- |
| 28566 | // name: WvIn_pmsg() |
| 28567 | // desc: PMSG function ... |
| 28568 | //----------------------------------------------------------------------------- |
| 28569 | CK_DLL_PMSG( WvIn_pmsg ) |
| 28570 | { |
| 28571 | return TRUE; |
| 28572 | } |
| 28573 | |
| 28574 | |
| 28575 | //----------------------------------------------------------------------------- |
| 28576 | // name: WvIn_ctrl_rate() |
| 28577 | // desc: CTRL function ... |
| 28578 | //----------------------------------------------------------------------------- |
| 28579 | CK_DLL_CTRL( WvIn_ctrl_rate ) |
| 28580 | { |
| 28581 | WvIn * w = (WvIn *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28582 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28583 | w->setRate( f ); |
| 28584 | RETURN->v_float = (t_CKFLOAT) w->rate; |
| 28585 | } |
| 28586 | |
| 28587 | |
| 28588 | //----------------------------------------------------------------------------- |
| 28589 | // name: WvIn_ctrl_path() |
| 28590 | // desc: CTRL function ... |
| 28591 | //----------------------------------------------------------------------------- |
| 28592 | CK_DLL_CTRL( WvIn_ctrl_path ) |
| 28593 | { |
| 28594 | WvIn * w = (WvIn *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28595 | Chuck_String * path = GET_NEXT_STRING(ARGS); |
| 28596 | |
| 28597 | // check if not null | 1.5.0.0 (ge) |
| 28598 | if( path != NULL ) |
| 28599 | { |
| 28600 | // open |
| 28601 | w->openFile( path->str().c_str(), FALSE, FALSE ); |
| 28602 | // try { w->openFile( path->str().c_str(), FALSE, FALSE ); } |
| 28603 | // catch( StkError & e ) |
| 28604 | // { |
| 28605 | // do nothing here; should have already printed |
| 28606 | // const char * s = e.getMessage(); |
| 28607 | // CK_FPRINTF_STDERR( "[chuck](via STK): WvIn cannot load file '%s'\n", c ); |
| 28608 | // } |
| 28609 | } |
| 28610 | |
| 28611 | // return value |
| 28612 | RETURN->v_string = path; |
| 28613 | } |
| 28614 | |
| 28615 | |
| 28616 | //----------------------------------------------------------------------------- |
| 28617 | // name: WvIn_cget_rate() |
| 28618 | // desc: CGET function ... |
| 28619 | //----------------------------------------------------------------------------- |
| 28620 | CK_DLL_CGET( WvIn_cget_rate ) |
| 28621 | { |
| 28622 | WvIn * w = (WvIn *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28623 | RETURN->v_float = (t_CKFLOAT) w->rate; |
| 28624 | } |
| 28625 | |
| 28626 | |
| 28627 | //----------------------------------------------------------------------------- |
| 28628 | // name: WvIn_cget_path() |
| 28629 | // desc: CGET function ... |
| 28630 | //----------------------------------------------------------------------------- |
| 28631 | CK_DLL_CGET( WvIn_cget_path ) |
| 28632 | { |
| 28633 | WvIn * w = (WvIn *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28634 | // instantiate | 1.5.0.0 (ge) added to dynamic allocate chuck string |
| 28635 | Chuck_String * str = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->ckt_string, SHRED ); |
| 28636 | str->set( w->str_filename ); |
| 28637 | // return value |
| 28638 | RETURN->v_string = str; |
| 28639 | } |
| 28640 | |
| 28641 | |
| 28642 | // WaveLoop |
| 28643 | //----------------------------------------------------------------------------- |
| 28644 | // name: WaveLoop_ctor() |
| 28645 | // desc: CTOR function ... |
| 28646 | //----------------------------------------------------------------------------- |
| 28647 | CK_DLL_CTOR( WaveLoop_ctor ) |
| 28648 | { |
| 28649 | // initialize member object |
| 28650 | OBJ_MEMBER_UINT(SELF, WvIn_offset_data) = (t_CKUINT)new WaveLoop; |
| 28651 | } |
| 28652 | |
| 28653 | |
| 28654 | //----------------------------------------------------------------------------- |
| 28655 | // name: WaveLoop_dtor() |
| 28656 | // desc: DTOR function ... |
| 28657 | //----------------------------------------------------------------------------- |
| 28658 | CK_DLL_DTOR( WaveLoop_dtor ) |
| 28659 | { |
| 28660 | delete (WaveLoop *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28661 | OBJ_MEMBER_UINT(SELF, WvIn_offset_data) = 0; |
| 28662 | } |
| 28663 | |
| 28664 | |
| 28665 | //----------------------------------------------------------------------------- |
| 28666 | // name: WaveLoop_tick() |
| 28667 | // desc: TICK function ... |
| 28668 | //----------------------------------------------------------------------------- |
| 28669 | CK_DLL_TICK( WaveLoop_tick ) |
| 28670 | { |
| 28671 | WaveLoop * w = (WaveLoop *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28672 | |
| 28673 | // value is auto-scaled OR normalized in w->openFile() | 1.5.0.0 (ge) |
| 28674 | *out = ( w->m_loaded ? (t_CKFLOAT)w->tick() : (SAMPLE)0.0 ); |
| 28675 | // old: dividing by SHRT_MAX no good for for non-16bit datatypes |
| 28676 | // *out = ( w->m_loaded ? (t_CKFLOAT)w->tick() / SHRT_MAX : (SAMPLE)0.0 ); |
| 28677 | |
| 28678 | return TRUE; |
| 28679 | } |
| 28680 | |
| 28681 | |
| 28682 | //----------------------------------------------------------------------------- |
| 28683 | // name: WaveLoop_pmsg() |
| 28684 | // desc: PMSG function ... |
| 28685 | //----------------------------------------------------------------------------- |
| 28686 | CK_DLL_PMSG( WaveLoop_pmsg ) |
| 28687 | { |
| 28688 | return TRUE; |
| 28689 | } |
| 28690 | |
| 28691 | |
| 28692 | //----------------------------------------------------------------------------- |
| 28693 | // name: WaveLoop_ctrl_freq() |
| 28694 | // desc: CTRL function ... |
| 28695 | //----------------------------------------------------------------------------- |
| 28696 | CK_DLL_CTRL( WaveLoop_ctrl_freq ) |
| 28697 | { |
| 28698 | WaveLoop * w = (WaveLoop *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28699 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28700 | w->setFrequency( f ); |
| 28701 | RETURN->v_float = (t_CKFLOAT) w->m_freq; |
| 28702 | } |
| 28703 | |
| 28704 | |
| 28705 | //----------------------------------------------------------------------------- |
| 28706 | // name: WaveLoop_cget_freq() |
| 28707 | // desc: CGET function ... |
| 28708 | //----------------------------------------------------------------------------- |
| 28709 | CK_DLL_CGET( WaveLoop_cget_freq ) |
| 28710 | { |
| 28711 | WaveLoop * w = (WaveLoop *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28712 | RETURN->v_float = (t_CKFLOAT) w->m_freq; |
| 28713 | } |
| 28714 | |
| 28715 | |
| 28716 | //----------------------------------------------------------------------------- |
| 28717 | // name: WaveLoop_ctrl_phase() |
| 28718 | // desc: CTRL function ... |
| 28719 | //----------------------------------------------------------------------------- |
| 28720 | CK_DLL_CTRL( WaveLoop_ctrl_phase ) |
| 28721 | { |
| 28722 | WaveLoop * w = (WaveLoop *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28723 | float f = (float)GET_NEXT_FLOAT(ARGS); |
| 28724 | w->addPhase( f ); |
| 28725 | RETURN->v_float = (t_CKFLOAT) w->time / w->fileSize; |
| 28726 | } |
| 28727 | |
| 28728 | |
| 28729 | //----------------------------------------------------------------------------- |
| 28730 | // name: WaveLoop_cget_phase() |
| 28731 | // desc: CGET function ... |
| 28732 | //----------------------------------------------------------------------------- |
| 28733 | CK_DLL_CGET( WaveLoop_cget_phase ) |
| 28734 | { |
| 28735 | WaveLoop * w = (WaveLoop *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28736 | RETURN->v_float = (t_CKFLOAT) w->time / w->fileSize; |
| 28737 | } |
| 28738 | |
| 28739 | |
| 28740 | //----------------------------------------------------------------------------- |
| 28741 | // name: WaveLoop_ctrl_phaseOffset() |
| 28742 | // desc: CTRL function ... |
| 28743 | //----------------------------------------------------------------------------- |
| 28744 | CK_DLL_CTRL( WaveLoop_ctrl_phaseOffset ) |
| 28745 | { |
| 28746 | WaveLoop * w = (WaveLoop *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28747 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 28748 | w->addPhaseOffset( f ); |
| 28749 | RETURN->v_float = (t_CKFLOAT) w->phaseOffset; |
| 28750 | } |
| 28751 | |
| 28752 | |
| 28753 | //----------------------------------------------------------------------------- |
| 28754 | // name: WaveLoop_cget_phaseOffset() |
| 28755 | // desc: CGET function ... |
| 28756 | //----------------------------------------------------------------------------- |
| 28757 | CK_DLL_CGET( WaveLoop_cget_phaseOffset ) |
| 28758 | { |
| 28759 | WaveLoop * w = (WaveLoop *)OBJ_MEMBER_UINT(SELF, WvIn_offset_data); |
| 28760 | RETURN->v_float = (t_CKFLOAT) w->phaseOffset; |
| 28761 | } |
| 28762 | |
| 28763 | |
| 28764 | |
| 28765 | |
| 28766 | //----------------------------------------------------------------------------- |
| 28767 | // name: getCarrier() |
| 28768 | // desc: get ChucK_Carrier from Chuck_VM_Shred, with error checking |
| 28769 | //----------------------------------------------------------------------------- |
| 28770 | Chuck_Carrier * getCarrier( Chuck_VM * vm, const std::string & where = "" ) |
| 28771 | { |
| 28772 | if( vm == NULL ) |
| 28773 | { |
| 28774 | CK_STDCERR << "[chuck](via STK): NULL VM ref!"; |
| 28775 | if( where != "" ) CK_STDCERR << " where: '" << where << "'"; |
| 28776 | CK_STDCERR << CK_STDENDL; |
| 28777 | return NULL; |
| 28778 | } |
| 28779 | else if( vm->carrier() == NULL ) |
| 28780 | { |
| 28781 | CK_STDCERR << "[chuck](via STK): NULL VM carrier!";; |
| 28782 | if( where != "" ) CK_STDCERR << " where: '" << where << "'"; |
| 28783 | CK_STDCERR << CK_STDENDL; |
| 28784 | return NULL; |
| 28785 | } |
| 28786 | |
| 28787 | // return it |
| 28788 | return vm->carrier(); |
| 28789 | } |
| 28790 | |
| 28791 | |
| 28792 | |
| 28793 | |
| 28794 | #ifndef __DISABLE_WVOUT__ |
| 28795 | // WvOut |
| 28796 | //----------------------------------------------------------------------------- |
| 28797 | // name: WvOut_ctor() |
| 28798 | // desc: CTOR function ... |
| 28799 | //----------------------------------------------------------------------------- |
| 28800 | CK_DLL_CTOR( WvOut_ctor ) |
| 28801 | { |
| 28802 | WvOut * yo = new WvOut; |
| 28803 | yo->autoPrefix = "chuck-session"; |
| 28804 | // default write mode is synchronous |
| 28805 | yo->asyncIO = FALSE; |
| 28806 | // get the carrier |
| 28807 | Chuck_Carrier * carrier = getCarrier( VM, "WvOut ctor" ); |
| 28808 | // check |
| 28809 | if( carrier != NULL ) |
| 28810 | { |
| 28811 | #ifndef __DISABLE_THREADS__ |
| 28812 | // REFACTOR-2017 TODO Ge: Fix wvout realtime audio [DONE] |
| 28813 | // check if need to create per-VM write thread |
| 28814 | if( carrier->stk_writeThread == NULL ) |
| 28815 | { |
| 28816 | // create new write thread, one per VM |
| 28817 | carrier->stk_writeThread = new XWriteThread( 2<<20, 1024 ); |
| 28818 | // 1.5.0.1 (ge) increased message buffer capacity from 32 to 1024 |
| 28819 | // message being dropped when a lot of WvOuts are present |
| 28820 | } |
| 28821 | |
| 28822 | // REFACTOR-2017: set async mode, if on realtime audio thread... |
| 28823 | yo->asyncIO = carrier->hintIsRealtimeAudio(); |
| 28824 | yo->asyncWriteThread = carrier->stk_writeThread; |
| 28825 | #endif |
| 28826 | } |
| 28827 | |
| 28828 | // set offset data |
| 28829 | OBJ_MEMBER_UINT(SELF, WvOut_offset_data) = (t_CKUINT)yo; |
| 28830 | } |
| 28831 | |
| 28832 | |
| 28833 | |
| 28834 | |
| 28835 | //----------------------------------------------------------------------------- |
| 28836 | // name: WvOut_dtor() |
| 28837 | // desc: DTOR function ... |
| 28838 | //----------------------------------------------------------------------------- |
| 28839 | CK_DLL_DTOR( WvOut_dtor ) |
| 28840 | { |
| 28841 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 28842 | w->closeFile(); |
| 28843 | |
| 28844 | // REFACTOR-2017: get the carrier |
| 28845 | Chuck_Carrier * carrier = getCarrier( ((Chuck_UGen *)(SELF))->originVM(), "WvOut dtor" ); |
| 28846 | // check |
| 28847 | if( carrier != NULL ) |
| 28848 | { |
| 28849 | std::map<WvOut *, WvOut *>::iterator iter; |
| 28850 | iter = carrier->stk_wvOutMap.find( w ); |
| 28851 | if(iter != carrier->stk_wvOutMap.end()) |
| 28852 | carrier->stk_wvOutMap.erase( iter ); |
| 28853 | } |
| 28854 | |
| 28855 | delete (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 28856 | OBJ_MEMBER_UINT(SELF, WvOut_offset_data) = 0; |
| 28857 | } |
| 28858 | |
| 28859 | |
| 28860 | |
| 28861 | |
| 28862 | //----------------------------------------------------------------------------- |
| 28863 | // name: WvOut_tick() |
| 28864 | // desc: TICK function ... |
| 28865 | //----------------------------------------------------------------------------- |
| 28866 | CK_DLL_TICK( WvOut_tick ) |
| 28867 | { |
| 28868 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 28869 | // added 1.3.0.0: apply fileGain |
| 28870 | if( w->start ) w->tick( w->fileGain * in ); |
| 28871 | *out = in; // pass samples downstream |
| 28872 | return TRUE; |
| 28873 | } |
| 28874 | |
| 28875 | |
| 28876 | |
| 28877 | |
| 28878 | //----------------------------------------------------------------------------- |
| 28879 | // name: WvOut_tick() |
| 28880 | // desc: TICK function ... |
| 28881 | //----------------------------------------------------------------------------- |
| 28882 | CK_DLL_TICKF( WvOut2_tickf ) |
| 28883 | { |
| 28884 | // assumption: stereo (2-channel) operation |
| 28885 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 28886 | MY_FLOAT frame[2]; |
| 28887 | for(int i = 0; i < nframes; i++) |
| 28888 | { |
| 28889 | frame[0] = in[i*2] * w->fileGain; |
| 28890 | frame[1] = in[i*2+1] * w->fileGain; |
| 28891 | |
| 28892 | // tick frame into WvOut |
| 28893 | if( w->start ) w->tickFrame( frame, 1 ); |
| 28894 | |
| 28895 | out[i*2] = in[i*2]; // pass samples downstream |
| 28896 | out[i*2+1] = in[i*2+1]; // pass samples downstream |
| 28897 | } |
| 28898 | return TRUE; |
| 28899 | } |
| 28900 | |
| 28901 | |
| 28902 | |
| 28903 | |
| 28904 | //----------------------------------------------------------------------------- |
| 28905 | // name: WvOut_pmsg() |
| 28906 | // desc: PMSG function ... |
| 28907 | //----------------------------------------------------------------------------- |
| 28908 | CK_DLL_PMSG( WvOut_pmsg ) |
| 28909 | { |
| 28910 | return TRUE; |
| 28911 | } |
| 28912 | |
| 28913 | |
| 28914 | |
| 28915 | |
| 28916 | //----------------------------------------------------------------------------- |
| 28917 | // name: fileType2fileExt() | 1.5.0.1 (ge) added |
| 28918 | // desc: helper function for converting WvOut type enum to file extension |
| 28919 | //----------------------------------------------------------------------------- |
| 28920 | static std::string fileType2fileExt( WvOut::FILE_TYPE type ) |
| 28921 | { |
| 28922 | switch( type ) |
| 28923 | { |
| 28924 | case WvOut::WVOUT_WAV: return "wav"; break; |
| 28925 | case WvOut::WVOUT_SND: return "snd"; break; |
| 28926 | case WvOut::WVOUT_AIF: return "aiff"; break; |
| 28927 | case WvOut::WVOUT_MAT: return "mat"; break; |
| 28928 | case WvOut::WVOUT_RAW: return "raw"; break; |
| 28929 | // unregonized type, assume raw |
| 28930 | default: return "raw"; break; |
| 28931 | } |
| 28932 | } |
| 28933 | |
| 28934 | |
| 28935 | |
| 28936 | |
| 28937 | //----------------------------------------------------------------------------- |
| 28938 | // name: openWvOutFile() |
| 28939 | // desc: helper function for opening audio files with WvOut | 1.5.0.1 (ge) |
| 28940 | //----------------------------------------------------------------------------- |
| 28941 | static t_CKBOOL openWvOutFile( WvOut * w, Chuck_VM * vm, |
| 28942 | Chuck_String * filename, t_CKINT channels, |
| 28943 | WvOut::FILE_TYPE type, t_CKINT ioFormat ) |
| 28944 | { |
| 28945 | // actual file name |
| 28946 | std::string theFilename; |
| 28947 | // actual STK file format |
| 28948 | Stk::STK_FORMAT theFormat = 0; |
| 28949 | // chuck carrier containing vm vitals |
| 28950 | Chuck_Carrier * carrier; |
| 28951 | |
| 28952 | // check for NULL |
| 28953 | if( filename == NULL ) return FALSE; |
| 28954 | |
| 28955 | // check chuck IO format enumeration |
| 28956 | if( ioFormat == Chuck_IO::INT16 ) theFormat = Stk::STK_SINT16; |
| 28957 | else if( ioFormat == Chuck_IO::INT24 ) theFormat = Stk::STK_SINT24; |
| 28958 | else if( ioFormat == Chuck_IO::INT32 ) theFormat = Stk::STK_SINT32; |
| 28959 | else if( ioFormat == Chuck_IO::FLOAT32 ) theFormat = Stk::MY_FLOAT32; |
| 28960 | else if( ioFormat == Chuck_IO::FLOAT64 ) theFormat = Stk::MY_FLOAT64; |
| 28961 | |
| 28962 | // error check |
| 28963 | if( theFormat == 0 ) |
| 28964 | { |
| 28965 | // error message |
| 28966 | EM_error3( "unrecognized format value '%d' in WvOut while opening file...", ioFormat ); |
| 28967 | goto done; |
| 28968 | } |
| 28969 | |
| 28970 | // REFACTOR-2017: get the carrier |
| 28971 | carrier = getCarrier( vm, "WvOut helper: openWvOutFile()" ); |
| 28972 | |
| 28973 | // special |
| 28974 | if( strstr( filename->str().c_str(), "special:auto" ) ) |
| 28975 | { |
| 28976 | theFilename = autoFilename( w->autoPrefix, fileType2fileExt(type) ); |
| 28977 | } |
| 28978 | else |
| 28979 | { |
| 28980 | // not special case |
| 28981 | theFilename = filename->str(); |
| 28982 | } |
| 28983 | |
| 28984 | // open |
| 28985 | try { w->openFile( theFilename.c_str(), (unsigned int)channels, type, theFormat ); } |
| 28986 | catch( StkError ) { goto done; } |
| 28987 | |
| 28988 | // check |
| 28989 | if( carrier != NULL ) |
| 28990 | { |
| 28991 | // insert into map |
| 28992 | carrier->stk_wvOutMap[w] = w; |
| 28993 | } |
| 28994 | |
| 28995 | return TRUE; |
| 28996 | |
| 28997 | done: |
| 28998 | return FALSE; |
| 28999 | } |
| 29000 | |
| 29001 | |
| 29002 | |
| 29003 | |
| 29004 | //----------------------------------------------------------------------------- |
| 29005 | // name: WvOut_ctrl_wavFilename() |
| 29006 | // desc: CTRL function ... |
| 29007 | //----------------------------------------------------------------------------- |
| 29008 | CK_DLL_CTRL( WvOut_ctrl_wavFilename ) |
| 29009 | { |
| 29010 | Chuck_UGen * ugen = (Chuck_UGen *)SELF; |
| 29011 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29012 | Chuck_String * filename = GET_NEXT_STRING(ARGS); |
| 29013 | // open the file |
| 29014 | openWvOutFile( w, VM, filename, ugen->m_num_ins, WvOut::WVOUT_WAV, Chuck_IO::INT16 ); |
| 29015 | // return |
| 29016 | RETURN->v_string = filename; |
| 29017 | } |
| 29018 | |
| 29019 | |
| 29020 | |
| 29021 | |
| 29022 | //----------------------------------------------------------------------------- |
| 29023 | // name: WvOut_ctrl_wavFilename2() |
| 29024 | // desc: CTRL function ... |
| 29025 | //----------------------------------------------------------------------------- |
| 29026 | CK_DLL_CTRL( WvOut_ctrl_wavFilename2 ) |
| 29027 | { |
| 29028 | Chuck_UGen * ugen = (Chuck_UGen *)SELF; |
| 29029 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29030 | Chuck_String * filename = GET_NEXT_STRING(ARGS); |
| 29031 | t_CKINT ioFormat = GET_NEXT_INT(ARGS); |
| 29032 | // open the file |
| 29033 | openWvOutFile( w, VM, filename, ugen->m_num_ins, WvOut::WVOUT_WAV, ioFormat ); |
| 29034 | // return |
| 29035 | RETURN->v_string = filename; |
| 29036 | } |
| 29037 | |
| 29038 | |
| 29039 | |
| 29040 | |
| 29041 | //----------------------------------------------------------------------------- |
| 29042 | // name: WvOut_ctrl_aifFilename() |
| 29043 | // desc: CTRL function ... |
| 29044 | //----------------------------------------------------------------------------- |
| 29045 | CK_DLL_CTRL( WvOut_ctrl_aifFilename ) |
| 29046 | { |
| 29047 | Chuck_UGen * ugen = (Chuck_UGen *)SELF; |
| 29048 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29049 | Chuck_String * filename = GET_NEXT_STRING(ARGS); |
| 29050 | // open the file |
| 29051 | openWvOutFile( w, VM, filename, ugen->m_num_ins, WvOut::WVOUT_AIF, Chuck_IO::INT16 ); |
| 29052 | // return |
| 29053 | RETURN->v_string = filename; |
| 29054 | } |
| 29055 | |
| 29056 | |
| 29057 | |
| 29058 | |
| 29059 | //----------------------------------------------------------------------------- |
| 29060 | // name: WvOut_ctrl_aifFilename() |
| 29061 | // desc: CTRL function ... |
| 29062 | //----------------------------------------------------------------------------- |
| 29063 | CK_DLL_CTRL( WvOut_ctrl_aifFilename2 ) |
| 29064 | { |
| 29065 | Chuck_UGen * ugen = (Chuck_UGen *)SELF; |
| 29066 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29067 | Chuck_String * filename = GET_NEXT_STRING(ARGS); |
| 29068 | t_CKINT ioFormat = GET_NEXT_INT(ARGS); |
| 29069 | // open the file |
| 29070 | openWvOutFile( w, VM, filename, ugen->m_num_ins, WvOut::WVOUT_AIF, ioFormat ); |
| 29071 | // return |
| 29072 | RETURN->v_string = filename; |
| 29073 | } |
| 29074 | |
| 29075 | |
| 29076 | |
| 29077 | |
| 29078 | //----------------------------------------------------------------------------- |
| 29079 | // name: WvOut_ctrl_sndFilename() |
| 29080 | // desc: CTRL function ... |
| 29081 | //----------------------------------------------------------------------------- |
| 29082 | CK_DLL_CTRL( WvOut_ctrl_sndFilename ) |
| 29083 | { |
| 29084 | Chuck_UGen * ugen = (Chuck_UGen *)SELF; |
| 29085 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29086 | Chuck_String * filename = GET_NEXT_STRING(ARGS); |
| 29087 | // open the file |
| 29088 | openWvOutFile( w, VM, filename, ugen->m_num_ins, WvOut::WVOUT_SND, Chuck_IO::INT16 ); |
| 29089 | // return |
| 29090 | RETURN->v_string = filename; |
| 29091 | } |
| 29092 | |
| 29093 | |
| 29094 | |
| 29095 | |
| 29096 | //----------------------------------------------------------------------------- |
| 29097 | // name: WvOut_ctrl_sndFilename() |
| 29098 | // desc: CTRL function ... |
| 29099 | //----------------------------------------------------------------------------- |
| 29100 | CK_DLL_CTRL( WvOut_ctrl_sndFilename2 ) |
| 29101 | { |
| 29102 | Chuck_UGen * ugen = (Chuck_UGen *)SELF; |
| 29103 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29104 | Chuck_String * filename = GET_NEXT_STRING(ARGS); |
| 29105 | t_CKINT ioFormat = GET_NEXT_INT(ARGS); |
| 29106 | // open the file |
| 29107 | openWvOutFile( w, VM, filename, ugen->m_num_ins, WvOut::WVOUT_SND, ioFormat ); |
| 29108 | // return |
| 29109 | RETURN->v_string = filename; |
| 29110 | } |
| 29111 | |
| 29112 | |
| 29113 | |
| 29114 | |
| 29115 | //----------------------------------------------------------------------------- |
| 29116 | // name: WvOut_ctrl_matFilename() |
| 29117 | // desc: CTRL function ... |
| 29118 | //----------------------------------------------------------------------------- |
| 29119 | CK_DLL_CTRL( WvOut_ctrl_matFilename ) |
| 29120 | { |
| 29121 | Chuck_UGen * ugen = (Chuck_UGen *)SELF; |
| 29122 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29123 | Chuck_String * filename = GET_NEXT_STRING(ARGS); |
| 29124 | // open the file |
| 29125 | openWvOutFile( w, VM, filename, ugen->m_num_ins, WvOut::WVOUT_MAT, Chuck_IO::INT16 ); |
| 29126 | // return |
| 29127 | RETURN->v_string = filename; |
| 29128 | } |
| 29129 | |
| 29130 | |
| 29131 | |
| 29132 | |
| 29133 | //----------------------------------------------------------------------------- |
| 29134 | // name: WvOut_ctrl_matFilename() |
| 29135 | // desc: CTRL function ... |
| 29136 | //----------------------------------------------------------------------------- |
| 29137 | CK_DLL_CTRL( WvOut_ctrl_matFilename2 ) |
| 29138 | { |
| 29139 | Chuck_UGen * ugen = (Chuck_UGen *)SELF; |
| 29140 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29141 | Chuck_String * filename = GET_NEXT_STRING(ARGS); |
| 29142 | t_CKINT ioFormat = GET_NEXT_INT(ARGS); |
| 29143 | // open the file |
| 29144 | openWvOutFile( w, VM, filename, ugen->m_num_ins, WvOut::WVOUT_MAT, ioFormat ); |
| 29145 | // return |
| 29146 | RETURN->v_string = filename; |
| 29147 | } |
| 29148 | |
| 29149 | |
| 29150 | |
| 29151 | |
| 29152 | //----------------------------------------------------------------------------- |
| 29153 | // name: WvOut_ctrl_rawFilename() |
| 29154 | // desc: CTRL function ... |
| 29155 | //----------------------------------------------------------------------------- |
| 29156 | CK_DLL_CTRL( WvOut_ctrl_rawFilename ) |
| 29157 | { |
| 29158 | Chuck_UGen * ugen = (Chuck_UGen *)SELF; |
| 29159 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29160 | Chuck_String * filename = GET_NEXT_STRING(ARGS); |
| 29161 | // open the file |
| 29162 | openWvOutFile( w, VM, filename, ugen->m_num_ins, WvOut::WVOUT_RAW, Chuck_IO::INT16 ); |
| 29163 | // return |
| 29164 | RETURN->v_string = filename; |
| 29165 | } |
| 29166 | |
| 29167 | |
| 29168 | |
| 29169 | |
| 29170 | //----------------------------------------------------------------------------- |
| 29171 | // name: WvOut_ctrl_rawFilename() |
| 29172 | // desc: CTRL function ... |
| 29173 | //----------------------------------------------------------------------------- |
| 29174 | CK_DLL_CTRL( WvOut_ctrl_rawFilename2 ) |
| 29175 | { |
| 29176 | Chuck_UGen * ugen = (Chuck_UGen *)SELF; |
| 29177 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29178 | Chuck_String * filename = GET_NEXT_STRING(ARGS); |
| 29179 | t_CKINT ioFormat = GET_NEXT_INT(ARGS); |
| 29180 | // open the file |
| 29181 | openWvOutFile( w, VM, filename, ugen->m_num_ins, WvOut::WVOUT_RAW, ioFormat ); |
| 29182 | // return |
| 29183 | RETURN->v_string = filename; |
| 29184 | } |
| 29185 | |
| 29186 | |
| 29187 | |
| 29188 | |
| 29189 | //----------------------------------------------------------------------------- |
| 29190 | // name: WvOut_cget_filename() |
| 29191 | // desc: CGET function ... |
| 29192 | //----------------------------------------------------------------------------- |
| 29193 | CK_DLL_CGET( WvOut_cget_filename ) |
| 29194 | { |
| 29195 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29196 | |
| 29197 | // instantiate | 1.5.0.0 (ge) added to dynamic allocate chuck string |
| 29198 | Chuck_String * str = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->ckt_string, SHRED ); |
| 29199 | str->set( w->str_filename ); |
| 29200 | |
| 29201 | RETURN->v_string = str; |
| 29202 | } |
| 29203 | |
| 29204 | |
| 29205 | |
| 29206 | |
| 29207 | //----------------------------------------------------------------------------- |
| 29208 | // name: WvOut_ctrl_closeFile() |
| 29209 | // desc: CTRL function ... |
| 29210 | //----------------------------------------------------------------------------- |
| 29211 | CK_DLL_CTRL( WvOut_ctrl_closeFile ) |
| 29212 | { |
| 29213 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29214 | w->closeFile(); |
| 29215 | |
| 29216 | // REFACTOR-2017: get the carrier |
| 29217 | Chuck_Carrier * carrier = getCarrier( VM, "WvOut ctrl closeFile" ); |
| 29218 | // check |
| 29219 | if( carrier != NULL ) |
| 29220 | { |
| 29221 | // remove from map |
| 29222 | std::map<WvOut *, WvOut *>::iterator iter; |
| 29223 | iter = carrier->stk_wvOutMap.find( w ); |
| 29224 | if(iter != carrier->stk_wvOutMap.end()) |
| 29225 | carrier->stk_wvOutMap.erase( iter ); |
| 29226 | } |
| 29227 | |
| 29228 | } |
| 29229 | |
| 29230 | |
| 29231 | |
| 29232 | |
| 29233 | //----------------------------------------------------------------------------- |
| 29234 | // name: WvOut_ctrl_record() |
| 29235 | // desc: CTRL function ... |
| 29236 | //----------------------------------------------------------------------------- |
| 29237 | CK_DLL_CTRL( WvOut_ctrl_record ) |
| 29238 | { |
| 29239 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29240 | t_CKINT i = GET_NEXT_INT(ARGS); |
| 29241 | w->start = i ? 1 : 0; |
| 29242 | RETURN->v_int = (t_CKINT) w->start; |
| 29243 | } |
| 29244 | |
| 29245 | |
| 29246 | //----------------------------------------------------------------------------- |
| 29247 | // name: WvOut_cget_record() |
| 29248 | // desc: CGET function ... |
| 29249 | //----------------------------------------------------------------------------- |
| 29250 | CK_DLL_CGET( WvOut_cget_record ) |
| 29251 | { |
| 29252 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29253 | RETURN->v_int = (t_CKINT) w->start; |
| 29254 | } |
| 29255 | |
| 29256 | |
| 29257 | //----------------------------------------------------------------------------- |
| 29258 | // name: WvOut_ctrl_autoPrefix() |
| 29259 | // desc: CTRL function ... |
| 29260 | //----------------------------------------------------------------------------- |
| 29261 | CK_DLL_CTRL( WvOut_ctrl_autoPrefix ) |
| 29262 | { |
| 29263 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29264 | Chuck_String * prefix = GET_NEXT_STRING(ARGS); |
| 29265 | // check |
| 29266 | if( prefix != NULL ) w->autoPrefix = prefix->str(); |
| 29267 | // pass through |
| 29268 | RETURN->v_string = prefix; |
| 29269 | } |
| 29270 | |
| 29271 | |
| 29272 | //----------------------------------------------------------------------------- |
| 29273 | // name: WvOut_cget_autoPrefix() |
| 29274 | // desc: CGET function ... |
| 29275 | //----------------------------------------------------------------------------- |
| 29276 | CK_DLL_CGET( WvOut_cget_autoPrefix ) |
| 29277 | { |
| 29278 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29279 | // instantiate | 1.5.0.0 (ge) added to dynamic allocate chuck string |
| 29280 | Chuck_String * str = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->ckt_string, SHRED ); |
| 29281 | str->set( w->autoPrefix ); |
| 29282 | // return value |
| 29283 | RETURN->v_string = str; |
| 29284 | } |
| 29285 | |
| 29286 | |
| 29287 | //----------------------------------------------------------------------------- |
| 29288 | // name: WvOut_ctrl_fileGain() |
| 29289 | // desc: CTRL function ... |
| 29290 | //----------------------------------------------------------------------------- |
| 29291 | CK_DLL_CTRL( WvOut_ctrl_fileGain ) |
| 29292 | { |
| 29293 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29294 | w->fileGain = GET_NEXT_FLOAT(ARGS); |
| 29295 | RETURN->v_float = w->fileGain; |
| 29296 | } |
| 29297 | |
| 29298 | |
| 29299 | //----------------------------------------------------------------------------- |
| 29300 | // name: WvOut_cget_fileGain() |
| 29301 | // desc: CGET function ... |
| 29302 | //----------------------------------------------------------------------------- |
| 29303 | CK_DLL_CGET( WvOut_cget_fileGain ) |
| 29304 | { |
| 29305 | WvOut * w = (WvOut *)OBJ_MEMBER_UINT(SELF, WvOut_offset_data); |
| 29306 | RETURN->v_float = w->fileGain; |
| 29307 | } |
| 29308 | #endif //__DISABLE_WVOUT__ |
| 29309 | |
| 29310 | |
| 29311 | |
| 29312 | //----------------------------------------------------------------------------- |
| 29313 | // BLT |
| 29314 | //----------------------------------------------------------------------------- |
| 29315 | CK_DLL_CTOR( BLT_ctor ) |
| 29316 | { /* do nothing here */ } |
| 29317 | |
| 29318 | CK_DLL_DTOR( BLT_dtor ) |
| 29319 | { /* do nothing here */ } |
| 29320 | |
| 29321 | CK_DLL_TICK( BLT_tick ) |
| 29322 | { |
| 29323 | // 1.5.0.0 | (ge) changed CK_FPRINTF_STDERR to EM_log; allow program to proceed; |
| 29324 | EM_log( CK_LOG_WARNING, "(STK) error -- BLT.tick() is abstract!" ); |
| 29325 | EM_log( CK_LOG_WARNING, "(STK) |- likely BLT was declared/used directly," ); |
| 29326 | EM_log( CK_LOG_WARNING, "(STK) |- instead of a subclass of BLT" ); |
| 29327 | |
| 29328 | // TODO: type system should not allow direct declaration of abstract classes |
| 29329 | // TODO: should detect, give a compiler error, with a short explanation and |
| 29330 | // TODO: suggestion on what to do: e.g., |
| 29331 | // TODO: "XXX cannot be instantiated directly (use '@' to declare a reference)" |
| 29332 | |
| 29333 | // 1.5.0.0 (ge) | added return silence |
| 29334 | *out = 0; |
| 29335 | |
| 29336 | return TRUE; |
| 29337 | } |
| 29338 | |
| 29339 | CK_DLL_PMSG( BLT_pmsg ) |
| 29340 | { |
| 29341 | return TRUE; |
| 29342 | } |
| 29343 | |
| 29344 | CK_DLL_CTRL( BLT_ctrl_phase ) |
| 29345 | { |
| 29346 | BLT * blt = (BLT *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29347 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 29348 | blt->setPhase( f ); |
| 29349 | blt->m_phase = f; |
| 29350 | RETURN->v_float = f; |
| 29351 | } |
| 29352 | |
| 29353 | CK_DLL_CGET( BLT_cget_phase ) |
| 29354 | { |
| 29355 | BLT * blt = (BLT *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29356 | RETURN->v_float = blt->getValuePhase(); |
| 29357 | } |
| 29358 | |
| 29359 | CK_DLL_CTRL( BLT_ctrl_freq ) |
| 29360 | { |
| 29361 | BLT * blt = (BLT *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29362 | t_CKFLOAT f = GET_NEXT_FLOAT(ARGS); |
| 29363 | blt->setFrequency( f ); |
| 29364 | blt->m_freq = f; |
| 29365 | RETURN->v_float = f; |
| 29366 | } |
| 29367 | |
| 29368 | CK_DLL_CGET( BLT_cget_freq ) |
| 29369 | { |
| 29370 | BLT * blt = (BLT *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29371 | RETURN->v_float = blt->getValueFreq(); |
| 29372 | } |
| 29373 | |
| 29374 | CK_DLL_CTRL( BLT_ctrl_harmonics ) |
| 29375 | { |
| 29376 | BLT * blt = (BLT *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29377 | t_CKINT i = GET_CK_INT(ARGS); |
| 29378 | if( i < 0 ) i = -i; |
| 29379 | blt->setHarmonics( i ); |
| 29380 | blt->m_harmonics = i; |
| 29381 | RETURN->v_int = i; |
| 29382 | } |
| 29383 | |
| 29384 | CK_DLL_CGET( BLT_cget_harmonics ) |
| 29385 | { |
| 29386 | BLT * blt = (BLT *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29387 | RETURN->v_int = blt->getValueHarmonics(); |
| 29388 | } |
| 29389 | |
| 29390 | |
| 29391 | //----------------------------------------------------------------------------- |
| 29392 | // Blit |
| 29393 | //----------------------------------------------------------------------------- |
| 29394 | CK_DLL_CTOR( Blit_ctor ) |
| 29395 | { |
| 29396 | Blit * blit = new Blit; |
| 29397 | OBJ_MEMBER_UINT(SELF, BLT_offset_data) = (t_CKUINT)blit; |
| 29398 | } |
| 29399 | |
| 29400 | CK_DLL_DTOR( Blit_dtor ) |
| 29401 | { |
| 29402 | delete (Blit *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29403 | OBJ_MEMBER_UINT(SELF, BLT_offset_data) = 0; |
| 29404 | } |
| 29405 | |
| 29406 | CK_DLL_TICK( Blit_tick ) |
| 29407 | { |
| 29408 | Blit * blit = (Blit *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29409 | *out = blit->tick(); |
| 29410 | return TRUE; |
| 29411 | } |
| 29412 | |
| 29413 | CK_DLL_PMSG( Blit_pmsg ) |
| 29414 | { |
| 29415 | return TRUE; |
| 29416 | } |
| 29417 | |
| 29418 | |
| 29419 | //----------------------------------------------------------------------------- |
| 29420 | // BlitSaw |
| 29421 | //----------------------------------------------------------------------------- |
| 29422 | CK_DLL_CTOR( BlitSaw_ctor ) |
| 29423 | { |
| 29424 | BlitSaw * blit = new BlitSaw; |
| 29425 | OBJ_MEMBER_UINT(SELF, BLT_offset_data) = (t_CKUINT)blit; |
| 29426 | } |
| 29427 | |
| 29428 | CK_DLL_DTOR( BlitSaw_dtor ) |
| 29429 | { |
| 29430 | delete (BlitSaw *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29431 | OBJ_MEMBER_UINT(SELF, BLT_offset_data) = 0; |
| 29432 | } |
| 29433 | |
| 29434 | CK_DLL_TICK( BlitSaw_tick ) |
| 29435 | { |
| 29436 | BlitSaw * blit = (BlitSaw *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29437 | *out = blit->tick(); |
| 29438 | return TRUE; |
| 29439 | } |
| 29440 | |
| 29441 | CK_DLL_PMSG( BlitSaw_pmsg ) |
| 29442 | { |
| 29443 | return TRUE; |
| 29444 | } |
| 29445 | |
| 29446 | |
| 29447 | //----------------------------------------------------------------------------- |
| 29448 | // BlitSquare |
| 29449 | //----------------------------------------------------------------------------- |
| 29450 | CK_DLL_CTOR( BlitSquare_ctor ) |
| 29451 | { |
| 29452 | BlitSquare * blit = new BlitSquare; |
| 29453 | OBJ_MEMBER_UINT(SELF, BLT_offset_data) = (t_CKUINT)blit; |
| 29454 | } |
| 29455 | |
| 29456 | CK_DLL_DTOR( BlitSquare_dtor ) |
| 29457 | { |
| 29458 | delete (BlitSquare *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29459 | OBJ_MEMBER_UINT(SELF, BLT_offset_data) = 0; |
| 29460 | } |
| 29461 | |
| 29462 | CK_DLL_TICK( BlitSquare_tick ) |
| 29463 | { |
| 29464 | BlitSquare * blit = (BlitSquare *)OBJ_MEMBER_UINT(SELF, BLT_offset_data); |
| 29465 | *out = blit->tick(); |
| 29466 | return TRUE; |
| 29467 | } |
| 29468 | |
| 29469 | CK_DLL_PMSG( BlitSquare_pmsg ) |
| 29470 | { |
| 29471 | return TRUE; |
| 29472 | } |
| 29473 | |
| 29474 | |
| 29475 | //----------------------------------------------------------------------------- |
| 29476 | // name: JetTable |
| 29477 | // desc: ... |
| 29478 | //----------------------------------------------------------------------------- |
| 29479 | |
| 29480 | CK_DLL_CTOR( JetTabl_ctor ) |
| 29481 | { |
| 29482 | JetTabl * j = new JetTabl; |
| 29483 | OBJ_MEMBER_UINT(SELF, JetTabl_offset_data) = (t_CKUINT)j; |
| 29484 | } |
| 29485 | |
| 29486 | CK_DLL_DTOR( JetTabl_dtor ) |
| 29487 | { |
| 29488 | JetTabl * j = (JetTabl *)OBJ_MEMBER_UINT(SELF, JetTabl_offset_data); |
| 29489 | CK_SAFE_DELETE(j); |
| 29490 | OBJ_MEMBER_UINT(SELF, JetTabl_offset_data) = 0; |
| 29491 | } |
| 29492 | |
| 29493 | CK_DLL_TICK( JetTabl_tick ) |
| 29494 | { |
| 29495 | JetTabl * j = (JetTabl *)OBJ_MEMBER_UINT(SELF, JetTabl_offset_data); |
| 29496 | *out = j->tick( in ); |
| 29497 | return TRUE; |
| 29498 | } |
| 29499 | |
| 29500 | CK_DLL_PMSG( JetTabl_pmsg ) |
| 29501 | { |
| 29502 | return TRUE; |
| 29503 | } |
| 29504 | |
| 29505 | |
| 29506 | //----------------------------------------------------------------------------- |
| 29507 | // name: Mesh2D ctor |
| 29508 | // desc: CGET function ... |
| 29509 | //----------------------------------------------------------------------------- |
| 29510 | |
| 29511 | CK_DLL_CTOR( Mesh2D_ctor ) { |
| 29512 | Mesh2D * m = new Mesh2D( 2,2 ); |
| 29513 | OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data) = (t_CKUINT)m; |
| 29514 | } |
| 29515 | |
| 29516 | |
| 29517 | CK_DLL_DTOR( Mesh2D_dtor ) { |
| 29518 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29519 | CK_SAFE_DELETE(m); |
| 29520 | OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data) = 0; |
| 29521 | } |
| 29522 | |
| 29523 | |
| 29524 | CK_DLL_TICK( Mesh2D_tick ) { |
| 29525 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29526 | *out = m->tick( in ); |
| 29527 | return TRUE; |
| 29528 | } |
| 29529 | |
| 29530 | CK_DLL_PMSG( Mesh2D_pmsg ) { |
| 29531 | return TRUE; |
| 29532 | } |
| 29533 | |
| 29534 | CK_DLL_CTRL( Mesh2D_ctrl_nx ) { |
| 29535 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29536 | m->setNX( GET_NEXT_INT ( ARGS ) ); |
| 29537 | } |
| 29538 | |
| 29539 | CK_DLL_CTRL( Mesh2D_ctrl_ny ) { |
| 29540 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29541 | m->setNY( GET_NEXT_INT ( ARGS ) ); |
| 29542 | |
| 29543 | } |
| 29544 | |
| 29545 | CK_DLL_CGET( Mesh2D_cget_nx ) { |
| 29546 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29547 | RETURN->v_int = m->NX; |
| 29548 | } |
| 29549 | |
| 29550 | CK_DLL_CGET( Mesh2D_cget_ny ) { |
| 29551 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29552 | RETURN->v_int = m->NY; |
| 29553 | } |
| 29554 | |
| 29555 | |
| 29556 | CK_DLL_CTRL( Mesh2D_ctrl_input_position ) { |
| 29557 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29558 | t_CKFLOAT xpos = GET_NEXT_FLOAT(ARGS); |
| 29559 | t_CKFLOAT ypos = GET_NEXT_FLOAT(ARGS); |
| 29560 | m->setInputPosition(xpos,ypos); |
| 29561 | } |
| 29562 | |
| 29563 | CK_DLL_CTRL( Mesh2D_cget_input_position ) { |
| 29564 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29565 | RETURN->v_float = m->xInput / (m->NX - 1); |
| 29566 | } |
| 29567 | |
| 29568 | |
| 29569 | CK_DLL_CTRL( Mesh2D_ctrl_decay ) { |
| 29570 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29571 | t_CKFLOAT dec = GET_NEXT_FLOAT ( ARGS ); |
| 29572 | m->setDecay( dec ); |
| 29573 | RETURN->v_float = dec; |
| 29574 | } |
| 29575 | |
| 29576 | CK_DLL_CGET( Mesh2D_cget_decay ) { |
| 29577 | } |
| 29578 | |
| 29579 | CK_DLL_CTRL( Mesh2D_ctrl_note_on ) { |
| 29580 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29581 | t_CKFLOAT note = GET_NEXT_FLOAT(ARGS); |
| 29582 | t_CKFLOAT vel = GET_NEXT_FLOAT(ARGS); |
| 29583 | m->noteOn( note, vel ); |
| 29584 | } |
| 29585 | |
| 29586 | CK_DLL_CTRL( Mesh2D_ctrl_note_off ) { |
| 29587 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29588 | m->noteOff( GET_NEXT_FLOAT(ARGS) ); //need a version that takes a float |
| 29589 | } |
| 29590 | |
| 29591 | CK_DLL_CGET( Mesh2D_cget_energy ) { |
| 29592 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29593 | RETURN->v_float = m->energy(); |
| 29594 | } |
| 29595 | |
| 29596 | CK_DLL_CTRL ( Mesh2D_ctrl_control_change ) { |
| 29597 | Mesh2D * m = (Mesh2D *)OBJ_MEMBER_UINT(SELF, Mesh2D_offset_data); |
| 29598 | t_CKINT ctrl = GET_NEXT_INT(ARGS); |
| 29599 | t_CKFLOAT val = GET_NEXT_FLOAT(ARGS); |
| 29600 | m->controlChange( ctrl, val ); |
| 29601 | |
| 29602 | } |
| 29603 | |
| 29604 | // MidiFileIn |
| 29605 | CK_DLL_CTOR( MidiFileIn_ctor ) |
| 29606 | { |
| 29607 | OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data) = 0; |
| 29608 | } |
| 29609 | |
| 29610 | CK_DLL_DTOR( MidiFileIn_dtor ) |
| 29611 | { |
| 29612 | stk::MidiFileIn *f = (stk::MidiFileIn *) OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data); |
| 29613 | CK_SAFE_DELETE(f); |
| 29614 | OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data) = 0; |
| 29615 | } |
| 29616 | |
| 29617 | CK_DLL_MFUN( MidiFileIn_open ) |
| 29618 | { |
| 29619 | stk::MidiFileIn *f = (stk::MidiFileIn *) OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data); |
| 29620 | CK_SAFE_DELETE(f); |
| 29621 | Chuck_String * str = GET_NEXT_STRING(ARGS); |
| 29622 | |
| 29623 | try |
| 29624 | { |
| 29625 | f = new stk::MidiFileIn(str->str()); |
| 29626 | OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data) = (t_CKUINT) f; |
| 29627 | RETURN->v_int = 1; |
| 29628 | } |
| 29629 | catch (StkError /* & e */) |
| 29630 | { |
| 29631 | // CK_STDCERR << "[chuck]: error opening MIDI file: " << str->str() << CK_STDENDL; |
| 29632 | // CK_STDCERR << "[chuck]: MidiFileIn error message '" << e.getMessage() << "'" << CK_STDENDL; |
| 29633 | RETURN->v_int = 0; |
| 29634 | } |
| 29635 | } |
| 29636 | |
| 29637 | CK_DLL_MFUN( MidiFileIn_close ) |
| 29638 | { |
| 29639 | stk::MidiFileIn *f = (stk::MidiFileIn *) OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data); |
| 29640 | CK_SAFE_DELETE(f); |
| 29641 | OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data) = 0; |
| 29642 | } |
| 29643 | |
| 29644 | CK_DLL_MFUN( MidiFileIn_numTracks ) |
| 29645 | { |
| 29646 | stk::MidiFileIn *f = (stk::MidiFileIn *) OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data); |
| 29647 | |
| 29648 | if(f) |
| 29649 | RETURN->v_int = f->getNumberOfTracks(); |
| 29650 | else |
| 29651 | RETURN->v_int = 0; |
| 29652 | } |
| 29653 | |
| 29654 | CK_DLL_MFUN( MidiFileIn_beatsPerMinute ) |
| 29655 | { |
| 29656 | stk::MidiFileIn *f = (stk::MidiFileIn *) OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data); |
| 29657 | |
| 29658 | if(f) |
| 29659 | RETURN->v_float = f->getBPM(); |
| 29660 | else |
| 29661 | RETURN->v_float = 0; |
| 29662 | } |
| 29663 | |
| 29664 | CK_DLL_MFUN( MidiFileIn_ticksPerQuarter ) |
| 29665 | { |
| 29666 | stk::MidiFileIn *f = (stk::MidiFileIn *) OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data); |
| 29667 | |
| 29668 | if(f) |
| 29669 | RETURN->v_int = f->getTPQ(); |
| 29670 | else |
| 29671 | RETURN->v_int = 0; |
| 29672 | } |
| 29673 | |
| 29674 | CK_DLL_MFUN( MidiFileIn_read ) |
| 29675 | { |
| 29676 | stk::MidiFileIn *f = (stk::MidiFileIn *) OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data); |
| 29677 | |
| 29678 | RETURN->v_int = 0; |
| 29679 | |
| 29680 | if(f) |
| 29681 | { |
| 29682 | Chuck_Object * msg = GET_NEXT_OBJECT(ARGS); |
| 29683 | |
| 29684 | std::vector<unsigned char> event; |
| 29685 | t_CKDUR dur = f->getNextMidiEvent(&event) * f->getTickSeconds() * Stk::sampleRate(); |
| 29686 | |
| 29687 | if(event.size()) |
| 29688 | { |
| 29689 | OBJ_MEMBER_INT(msg, MidiMsg_offset_data1) = event[0]; |
| 29690 | OBJ_MEMBER_INT(msg, MidiMsg_offset_data2) = event.size() >= 2 ? event[1] : 0; |
| 29691 | OBJ_MEMBER_INT(msg, MidiMsg_offset_data3) = event.size() >= 3 ? event[2] : 0; |
| 29692 | OBJ_MEMBER_DUR(msg, MidiMsg_offset_when) = dur; |
| 29693 | |
| 29694 | RETURN->v_int = 1; |
| 29695 | } |
| 29696 | } |
| 29697 | } |
| 29698 | |
| 29699 | CK_DLL_MFUN( MidiFileIn_readTrack ) |
| 29700 | { |
| 29701 | stk::MidiFileIn *f = (stk::MidiFileIn *) OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data); |
| 29702 | |
| 29703 | RETURN->v_int = 0; |
| 29704 | |
| 29705 | if(f) |
| 29706 | { |
| 29707 | Chuck_Object * msg = GET_NEXT_OBJECT(ARGS); |
| 29708 | t_CKINT track = GET_NEXT_INT(ARGS); |
| 29709 | |
| 29710 | if(track >= 0 && track < f->getNumberOfTracks()) |
| 29711 | { |
| 29712 | std::vector<unsigned char> event; |
| 29713 | t_CKDUR dur = f->getNextMidiEvent(&event, track) * f->getTickSeconds() * Stk::sampleRate(); |
| 29714 | |
| 29715 | if(event.size()) |
| 29716 | { |
| 29717 | OBJ_MEMBER_INT(msg, MidiMsg_offset_data1) = event[0]; |
| 29718 | OBJ_MEMBER_INT(msg, MidiMsg_offset_data2) = event.size() >= 2 ? event[1] : 0; |
| 29719 | OBJ_MEMBER_INT(msg, MidiMsg_offset_data3) = event.size() >= 3 ? event[2] : 0; |
| 29720 | OBJ_MEMBER_DUR(msg, MidiMsg_offset_when) = dur; |
| 29721 | |
| 29722 | RETURN->v_int = 1; |
| 29723 | } |
| 29724 | } |
| 29725 | } |
| 29726 | } |
| 29727 | |
| 29728 | CK_DLL_MFUN( MidiFileIn_rewind ) |
| 29729 | { |
| 29730 | stk::MidiFileIn *f = (stk::MidiFileIn *) OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data); |
| 29731 | if(f) f->rewindTrack(); // default track (0) |
| 29732 | } |
| 29733 | |
| 29734 | // 1.5.0.0 (ge) added |
| 29735 | CK_DLL_MFUN( MidiFileIn_rewindTrack ) |
| 29736 | { |
| 29737 | stk::MidiFileIn *f = (stk::MidiFileIn *) OBJ_MEMBER_UINT(SELF, MidiFileIn_offset_data); |
| 29738 | t_CKINT track = GET_NEXT_INT(ARGS); |
| 29739 | if( f ) f->rewindTrack( track ); |
| 29740 | } |
| 29741 | |
| 29742 | |
| 29743 | |
| 29744 | //----------------------------------------------------------------------------- |
| 29745 | // name: stk_detach() |
| 29746 | // desc: called upon per-VM cleanup; REFACTOR-2017 |
| 29747 | //----------------------------------------------------------------------------- |
| 29748 | t_CKBOOL stk_detach( Chuck_Carrier * carrier ) |
| 29749 | { |
| 29750 | // log |
| 29751 | EM_log( CK_LOG_INFO, "cleaning up STK resources..." ); |
| 29752 | // check |
| 29753 | if( carrier != NULL ) |
| 29754 | { |
| 29755 | // push log (auto cleaning smart pointer) |
| 29756 | SmartPushLog pushLog; |
| 29757 | |
| 29758 | #ifndef __DISABLE_WVOUT__ |
| 29759 | // log |
| 29760 | EM_log( CK_LOG_INFO, "(via STK): detaching file handles..." ); |
| 29761 | // close files |
| 29762 | std::map<WvOut *, WvOut *>::iterator iter; |
| 29763 | for( iter = carrier->stk_wvOutMap.begin(); |
| 29764 | iter != carrier->stk_wvOutMap.end(); iter++ ) { |
| 29765 | (*iter).second->closeFile(); |
| 29766 | } |
| 29767 | |
| 29768 | // TODO: release the WvOut |
| 29769 | carrier->stk_wvOutMap.clear(); |
| 29770 | |
| 29771 | // deal with per-VM stk write thread |
| 29772 | #ifndef __DISABLE_THREADS__ |
| 29773 | // log |
| 29774 | EM_log( CK_LOG_INFO, "(via STK): stopping write threads..." ); |
| 29775 | if( carrier->stk_writeThread ) |
| 29776 | { |
| 29777 | carrier->stk_writeThread->shutdown(); // deletes itself |
| 29778 | carrier->stk_writeThread = NULL; |
| 29779 | } |
| 29780 | #endif //__DISABLE_THREADS__ |
| 29781 | #endif //__DISABLE_WVOUT__ |
| 29782 | } |
| 29783 | |
| 29784 | return TRUE; |
| 29785 | } |