| 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.h |
| 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 | #ifndef __UGEN_STK_H__ |
| 40 | #define __UGEN_STK_H__ |
| 41 | |
| 42 | #include "chuck_dl.h" |
| 43 | #include "chuck_carrier.h" |
| 44 | |
| 45 | // forward reference; REFACTOR-2017 |
| 46 | struct Chuck_Carrier; |
| 47 | |
| 48 | // query |
| 49 | DLL_QUERY stk_query( Chuck_DL_Query * QUERY ); |
| 50 | t_CKBOOL stk_detach( Chuck_Carrier * carrier ); |
| 51 | |
| 52 | // this determines STK float type and de-denormal method |
| 53 | #ifndef __STK_USE_SINGLE_PRECISION__ |
| 54 | #define MY_FLOAT double |
| 55 | #define CK_STK_DDN CK_DDN_DOUBLE |
| 56 | #else |
| 57 | #define MY_FLOAT float |
| 58 | #define CK_STK_DDN CK_DDN_SINGLE |
| 59 | #endif |
| 60 | |
| 61 | // 1.4.2.0 (ge) | added as part of switch to snprintf() |
| 62 | #define STK_MSG_BUF_LENGTH 256 |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | /***************************************************/ |
| 68 | /*! \class Stk |
| 69 | \brief STK base class |
| 70 | |
| 71 | Nearly all STK classes inherit from this class. |
| 72 | The global sample rate and rawwave path variables |
| 73 | can be queried and modified via Stk. In addition, |
| 74 | this class provides error handling and |
| 75 | byte-swapping functions. |
| 76 | |
| 77 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 78 | */ |
| 79 | /***************************************************/ |
| 80 | |
| 81 | #if !defined(__STK_H) |
| 82 | #define __STK_H |
| 83 | |
| 84 | #include <string> |
| 85 | #include <map> |
| 86 | |
| 87 | // Most data in STK is passed and calculated with the |
| 88 | // following user-definable floating-point type. You |
| 89 | // can change this to "float" if you prefer or perhaps |
| 90 | // a "long double" in the future. |
| 91 | |
| 92 | //XXX sample is already defined in chuck_def.h!!! |
| 93 | #if !defined(SAMPLE) |
| 94 | typedef SAMPLE MY_FLOAT; |
| 95 | #endif |
| 96 | // The "MY_FLOAT" type will be deprecated in STK |
| 97 | // versions higher than 4.1.2 and replaced with the variable |
| 98 | // "StkFloat". |
| 99 | //typedef double StkFloat; |
| 100 | //#if defined(__PLATFORM_WINDOWS__) || |
| 101 | // #pragma deprecated(MY_FLOAT) |
| 102 | //#else |
| 103 | // typedef StkFloat MY_FLOAT __attribute__ ((deprecated)); |
| 104 | //#endif |
| 105 | |
| 106 | //! STK error handling class. |
| 107 | /*! |
| 108 | This is a fairly abstract exception handling class. There could |
| 109 | be sub-classes to take care of more specific error conditions ... or |
| 110 | not. |
| 111 | */ |
| 112 | class StkError |
| 113 | { |
| 114 | public: |
| 115 | enum TYPE { |
| 116 | WARNING, |
| 117 | DEBUG_WARNING, |
| 118 | FUNCTION_ARGUMENT, |
| 119 | FILE_NOT_FOUND, |
| 120 | FILE_UNKNOWN_FORMAT, |
| 121 | FILE_ERROR, |
| 122 | PROCESS_THREAD, |
| 123 | PROCESS_SOCKET, |
| 124 | PROCESS_SOCKET_IPADDR, |
| 125 | AUDIO_SYSTEM, |
| 126 | MIDI_SYSTEM, |
| 127 | UNSPECIFIED |
| 128 | }; |
| 129 | |
| 130 | public: // SWAP formerly protected |
| 131 | char message[STK_MSG_BUF_LENGTH]; |
| 132 | TYPE type; |
| 133 | |
| 134 | public: |
| 135 | //! The constructor. |
| 136 | StkError(const char *p, TYPE tipe = StkError::UNSPECIFIED); |
| 137 | |
| 138 | //! The destructor. |
| 139 | virtual ~StkError(void); |
| 140 | |
| 141 | //! Prints "thrown" error message to stdout. |
| 142 | virtual void printMessage(void); |
| 143 | |
| 144 | //! Returns the "thrown" error message TYPE. |
| 145 | virtual const TYPE& getType(void) { return type; } |
| 146 | |
| 147 | //! Returns the "thrown" error message string. |
| 148 | virtual const char *getMessage(void) const { return message; } |
| 149 | }; |
| 150 | |
| 151 | |
| 152 | class Stk |
| 153 | { |
| 154 | public: |
| 155 | |
| 156 | typedef unsigned long STK_FORMAT; |
| 157 | static const STK_FORMAT STK_SINT8; /*!< -128 to +127 */ |
| 158 | static const STK_FORMAT STK_SINT16; /*!< -32768 to +32767 */ |
| 159 | static const STK_FORMAT STK_SINT24; /*!< -8388608 to +8388607 | added 1.5.0.1 */ |
| 160 | static const STK_FORMAT STK_SINT32; /*!< -2147483648 to +2147483647. */ |
| 161 | static const STK_FORMAT STK_SINT64; /*!< -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807. */ |
| 162 | static const STK_FORMAT MY_FLOAT32; /*!< Normalized between plus/minus 1.0. */ |
| 163 | static const STK_FORMAT MY_FLOAT64; /*!< Normalized between plus/minus 1.0. */ |
| 164 | |
| 165 | //! Static method which returns the current STK sample rate. |
| 166 | static MY_FLOAT sampleRate(void); |
| 167 | |
| 168 | //! Static method which sets the STK sample rate. |
| 169 | /*! |
| 170 | The sample rate set using this method is queried by all STK |
| 171 | classes which depend on its value. It is initialized to the |
| 172 | default SRATE set in Stk.h. Many STK classes use the sample rate |
| 173 | during instantiation. Therefore, if you wish to use a rate which |
| 174 | is different from the default rate, it is imperative that it be |
| 175 | set \e BEFORE STK objects are instantiated. |
| 176 | */ |
| 177 | static void setSampleRate(MY_FLOAT newRate); |
| 178 | |
| 179 | //! Static method which returns the current rawwave path. |
| 180 | static std::string rawwavePath(void); |
| 181 | |
| 182 | //! Static method which sets the STK rawwave path. |
| 183 | static void setRawwavePath(std::string newPath); |
| 184 | |
| 185 | //! Static method which byte-swaps a 16-bit data type. |
| 186 | static void swap16(unsigned char *ptr); |
| 187 | |
| 188 | //! Static method which byte-swaps a 32-bit data type. |
| 189 | static void swap32(unsigned char *ptr); |
| 190 | |
| 191 | //! Static method which byte-swaps a 64-bit data type. |
| 192 | static void swap64(unsigned char *ptr); |
| 193 | |
| 194 | //! Static cross-platform method to sleep for a number of milliseconds. |
| 195 | static void sleep(unsigned long milliseconds); |
| 196 | |
| 197 | public: // SWAP formerly private |
| 198 | static MY_FLOAT srate; |
| 199 | static std::string rawwavepath; |
| 200 | |
| 201 | public: // SWAP formerly protected |
| 202 | |
| 203 | //! Default constructor. |
| 204 | Stk(void); |
| 205 | |
| 206 | //! Class destructor. |
| 207 | virtual ~Stk(void); |
| 208 | |
| 209 | //! Function for error reporting and handling. |
| 210 | static void handleError( const char *message, StkError::TYPE type ); |
| 211 | |
| 212 | }; |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | //----------------------------------------------------------------------------- |
| 218 | // name: struct SINT24 | 1.5.0.1 (ge) added |
| 219 | // desc: custom 24-bit integer type; based on RtAudio's S24 by Gary Scavone |
| 220 | //----------------------------------------------------------------------------- |
| 221 | #pragma pack(push, 1) |
| 222 | struct SINT24 |
| 223 | { |
| 224 | protected: |
| 225 | // the data in three unsigned bytes |
| 226 | unsigned char c3[3]; |
| 227 | |
| 228 | public: |
| 229 | // default constructor |
| 230 | SINT24() { } |
| 231 | |
| 232 | // copy from int |
| 233 | SINT24 & operator =( const int & i ) |
| 234 | { |
| 235 | c3[0] = (unsigned char)(i & 0x000000ff); |
| 236 | c3[1] = (unsigned char)((i & 0x0000ff00) >> 8); |
| 237 | c3[2] = (unsigned char)((i & 0x00ff0000) >> 16); |
| 238 | return *this; |
| 239 | } |
| 240 | |
| 241 | // constructors |
| 242 | SINT24( const double & d ) { *this = (int)d; } |
| 243 | SINT24( const float & f ) { *this = (int)f; } |
| 244 | SINT24( const signed short & s ) { *this = (int)s; } |
| 245 | SINT24( const char & c ) { *this = (int)c; } |
| 246 | |
| 247 | // byte swap |
| 248 | void byteswap() |
| 249 | { |
| 250 | // swap the outer bytes |
| 251 | unsigned char temp = c3[0]; |
| 252 | c3[0] = c3[2]; |
| 253 | c3[2] = temp; |
| 254 | } |
| 255 | |
| 256 | // reconstruct as a signed int |
| 257 | int asInt() |
| 258 | { |
| 259 | int i = c3[0] | (c3[1] << 8) | (c3[2] << 16); |
| 260 | if (i & 0x800000) i |= ~0xffffff; |
| 261 | return i; |
| 262 | } |
| 263 | }; |
| 264 | #pragma pack(pop) |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | // Here are a few other useful typedefs. |
| 270 | typedef signed short SINT16; |
| 271 | typedef signed int SINT32; |
| 272 | // SINT24 -- see above |
| 273 | typedef float FLOAT32; |
| 274 | typedef double FLOAT64; |
| 275 | |
| 276 | // Boolean values |
| 277 | #ifndef TRUE |
| 278 | #define FALSE 0 |
| 279 | #define TRUE 1 |
| 280 | #endif |
| 281 | |
| 282 | // The default sampling rate. |
| 283 | #define SRATE (MY_FLOAT) 44100.0 |
| 284 | |
| 285 | // The default real-time audio input and output buffer size. If |
| 286 | // clicks are occuring in the input and/or output sound stream, a |
| 287 | // larger buffer size may help. Larger buffer sizes, however, produce |
| 288 | // more latency. |
| 289 | #define RT_BUFFER_SIZE 512 |
| 290 | |
| 291 | // The default rawwave path value is set with the preprocessor |
| 292 | // definition RAWWAVE_PATH. This can be specified as an argument to |
| 293 | // the configure script, in an integrated development environment, or |
| 294 | // below. The global STK rawwave path variable can be dynamically set |
| 295 | // with the Stk::setRawwavePath() function. This value is |
| 296 | // concatenated to the beginning of all references to rawwave files in |
| 297 | // the various STK core classes (ex. Clarinet.cpp). If you wish to |
| 298 | // move the rawwaves directory to a different location in your file |
| 299 | // system, you will need to set this path definition appropriately. |
| 300 | #if !defined(RAWWAVE_PATH) |
| 301 | #define RAWWAVE_PATH "../../rawwaves/" |
| 302 | #endif |
| 303 | |
| 304 | //#define PI (MY_FLOAT) 3.14159265359 |
| 305 | //#define TWO_PI (MY_FLOAT) (2 * PI) |
| 306 | |
| 307 | #define ONE_OVER_128 (MY_FLOAT) 0.0078125 |
| 308 | |
| 309 | #if defined(__PLATFORM_CYGWIN__) |
| 310 | #define __OS_WINDOWS_CYGWIN__ |
| 311 | #define __STK_REALTIME__ |
| 312 | #elif defined(__PLATFORM_WINDOWS__) |
| 313 | #define __OS_WINDOWS__ |
| 314 | #define __STK_REALTIME__ |
| 315 | #elif defined(__PLATFORM_LINUX__) |
| 316 | #define __OS_LINUX__ |
| 317 | #define __STK_REALTIME__ |
| 318 | #elif defined(__IRIX_AL__) |
| 319 | #define __OS_IRIX__ |
| 320 | #define __STK_REALTIME__ |
| 321 | #elif defined(__PLATFORM_APPLE__) |
| 322 | #define __OS_MACOSX__ |
| 323 | #define __STK_REALTIME__ |
| 324 | #endif |
| 325 | |
| 326 | //#define _STK_DEBUG_ |
| 327 | |
| 328 | #endif |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | /***************************************************/ |
| 334 | /*! \class Envelope |
| 335 | \brief STK envelope base class. |
| 336 | |
| 337 | This class implements a simple envelope |
| 338 | generator which is capable of ramping to |
| 339 | a target value by a specified \e rate. |
| 340 | It also responds to simple \e keyOn and |
| 341 | \e keyOff messages, ramping to 1.0 on |
| 342 | keyOn and to 0.0 on keyOff. |
| 343 | |
| 344 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 345 | */ |
| 346 | /***************************************************/ |
| 347 | |
| 348 | #if !defined(__ENVELOPE_H) |
| 349 | #define __ENVELOPE_H |
| 350 | |
| 351 | |
| 352 | class Envelope : public Stk |
| 353 | { |
| 354 | public: |
| 355 | |
| 356 | //! Default constructor. |
| 357 | Envelope(void); |
| 358 | |
| 359 | //! Class destructor. |
| 360 | virtual ~Envelope(void); |
| 361 | |
| 362 | //! Set target = 1. |
| 363 | virtual void keyOn(void); |
| 364 | |
| 365 | //! Set target = 0. |
| 366 | virtual void keyOff(void); |
| 367 | |
| 368 | //! Set the \e rate. |
| 369 | void setRate(MY_FLOAT aRate); |
| 370 | |
| 371 | //! Set the \e rate based on a time duration. |
| 372 | void setTime(MY_FLOAT aTime); |
| 373 | |
| 374 | //! Set the target value. |
| 375 | virtual void setTarget(MY_FLOAT aTarget); |
| 376 | |
| 377 | //! Set current and target values to \e aValue. |
| 378 | virtual void setValue(MY_FLOAT aValue); |
| 379 | |
| 380 | //! Return the current envelope \e state (0 = at target, 1 otherwise). |
| 381 | virtual int getState(void) const; |
| 382 | |
| 383 | //! Return one envelope output value. |
| 384 | virtual MY_FLOAT tick(void); |
| 385 | |
| 386 | //! Return \e vectorSize envelope outputs in \e vector. |
| 387 | virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 388 | |
| 389 | //! Return the last computed output value. |
| 390 | MY_FLOAT lastOut(void) const; |
| 391 | |
| 392 | //! Set the target value (without triggering the envelope) | 1.5.2.5 (ge & eito) added |
| 393 | void prepTarget(MY_FLOAT aTarget); |
| 394 | //! Set the time value (without triggering the envelope) | 1.5.2.5 (ge & eito) added |
| 395 | void prepTime(MY_FLOAT aTime); |
| 396 | |
| 397 | public: |
| 398 | MY_FLOAT value; |
| 399 | MY_FLOAT target; |
| 400 | MY_FLOAT rate; |
| 401 | MY_FLOAT m_target; // chuck |
| 402 | MY_FLOAT m_time; // chuck |
| 403 | int state; |
| 404 | }; |
| 405 | |
| 406 | #endif |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | /***************************************************/ |
| 412 | /*! \class ADSR |
| 413 | \brief STK ADSR envelope class. |
| 414 | |
| 415 | This Envelope subclass implements a |
| 416 | traditional ADSR (Attack, Decay, |
| 417 | Sustain, Release) envelope. It |
| 418 | responds to simple keyOn and keyOff |
| 419 | messages, keeping track of its state. |
| 420 | The \e state = ADSR::DONE after the |
| 421 | envelope value reaches 0.0 in the |
| 422 | ADSR::RELEASE state. |
| 423 | |
| 424 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 425 | */ |
| 426 | /***************************************************/ |
| 427 | |
| 428 | #if !defined(__ADSR_H) |
| 429 | #define __ADSR_H |
| 430 | |
| 431 | |
| 432 | class ADSR : public Envelope |
| 433 | { |
| 434 | public: |
| 435 | |
| 436 | //! Envelope states. |
| 437 | enum { ATTACK, DECAY, SUSTAIN, RELEASE, DONE }; |
| 438 | |
| 439 | //! Default constructor. |
| 440 | ADSR(void); |
| 441 | |
| 442 | //! Class destructor. |
| 443 | virtual ~ADSR(void); |
| 444 | |
| 445 | //! Set target = 1, state = \e ADSR::ATTACK. |
| 446 | virtual void keyOn(void); |
| 447 | |
| 448 | //! Set target = 0, state = \e ADSR::RELEASE. |
| 449 | virtual void keyOff(void); |
| 450 | |
| 451 | //! Set the attack rate. |
| 452 | void setAttackRate(MY_FLOAT aRate); |
| 453 | |
| 454 | //! Set the decay rate. |
| 455 | void setDecayRate(MY_FLOAT aRate); |
| 456 | |
| 457 | //! Set the sustain level. |
| 458 | void setSustainLevel(MY_FLOAT aLevel); |
| 459 | |
| 460 | //! Set the release rate. |
| 461 | void setReleaseRate(MY_FLOAT aRate); |
| 462 | |
| 463 | //! Set the attack rate based on a time duration. |
| 464 | void setAttackTime(MY_FLOAT aTime); |
| 465 | |
| 466 | //! Set the decay rate based on a time duration. |
| 467 | void setDecayTime(MY_FLOAT aTime); |
| 468 | |
| 469 | //! Set the release rate based on a time duration. |
| 470 | void setReleaseTime(MY_FLOAT aTime); |
| 471 | |
| 472 | //! Set sustain level and attack, decay, and release state rates based on time durations. |
| 473 | void setAllTimes(MY_FLOAT aTime, MY_FLOAT dTime, MY_FLOAT sLevel, MY_FLOAT rTime); |
| 474 | |
| 475 | //! Set the target value. |
| 476 | void setTarget(MY_FLOAT aTarget); |
| 477 | |
| 478 | //! Return the current envelope \e state (ATTACK, DECAY, SUSTAIN, RELEASE, DONE). |
| 479 | int getState(void) const; |
| 480 | |
| 481 | //! Set to state = ADSR::SUSTAIN with current and target values of \e aValue. |
| 482 | void setValue(MY_FLOAT aValue); |
| 483 | |
| 484 | //! Return one envelope output value. |
| 485 | MY_FLOAT tick(void); |
| 486 | |
| 487 | //! Return \e vectorSize envelope outputs in \e vector. |
| 488 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 489 | |
| 490 | // chuck |
| 491 | MY_FLOAT getAttackTime(); |
| 492 | MY_FLOAT getDecayTime(); |
| 493 | MY_FLOAT getReleaseTime(); |
| 494 | |
| 495 | public: |
| 496 | MY_FLOAT attackRate; |
| 497 | MY_FLOAT decayRate; |
| 498 | MY_FLOAT sustainLevel; |
| 499 | MY_FLOAT releaseRate; |
| 500 | // chuck |
| 501 | MY_FLOAT m_attackTime; // 1.4.1.0 |
| 502 | MY_FLOAT m_decayTime; |
| 503 | MY_FLOAT m_releaseTime; |
| 504 | }; |
| 505 | |
| 506 | #endif |
| 507 | |
| 508 | |
| 509 | |
| 510 | |
| 511 | /***************************************************/ |
| 512 | /*! \class Instrmnt |
| 513 | \brief STK instrument abstract base class. |
| 514 | |
| 515 | This class provides a common interface for |
| 516 | all STK instruments. |
| 517 | |
| 518 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 519 | */ |
| 520 | /***************************************************/ |
| 521 | |
| 522 | #if !defined(__INSTRMNT_H) |
| 523 | #define __INSTRMNT_H |
| 524 | |
| 525 | #include <iostream> |
| 526 | |
| 527 | class Instrmnt : public Stk |
| 528 | { |
| 529 | public: |
| 530 | //! Default constructor. |
| 531 | Instrmnt(); |
| 532 | |
| 533 | //! Class destructor. |
| 534 | virtual ~Instrmnt(); |
| 535 | |
| 536 | //! Start a note with the given frequency and amplitude. |
| 537 | virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude) = 0; |
| 538 | |
| 539 | //! Stop a note with the given amplitude (speed of decay). |
| 540 | virtual void noteOff(MY_FLOAT amplitude) = 0; |
| 541 | |
| 542 | //! Set instrument parameters for a particular frequency. |
| 543 | virtual void setFrequency(MY_FLOAT frequency); |
| 544 | |
| 545 | //! Return the last output value. |
| 546 | MY_FLOAT lastOut() const; |
| 547 | |
| 548 | //! Return the last left output value. |
| 549 | MY_FLOAT lastOutLeft() const; |
| 550 | |
| 551 | //! Return the last right output value. |
| 552 | MY_FLOAT lastOutRight() const; |
| 553 | |
| 554 | //! Compute one output sample. |
| 555 | virtual MY_FLOAT tick() = 0; |
| 556 | |
| 557 | //! Computer \e vectorSize outputs and return them in \e vector. |
| 558 | virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 559 | |
| 560 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 561 | virtual void controlChange(int number, MY_FLOAT value); |
| 562 | |
| 563 | public: // SWAP formerly protected |
| 564 | MY_FLOAT lastOutput; |
| 565 | // chuck |
| 566 | t_CKFLOAT m_frequency; |
| 567 | }; |
| 568 | |
| 569 | |
| 570 | #endif |
| 571 | |
| 572 | |
| 573 | |
| 574 | |
| 575 | /***************************************************/ |
| 576 | /*! \class Filter (renamed to FilterStk) |
| 577 | \brief STK filter class. |
| 578 | |
| 579 | This class implements a generic structure which |
| 580 | can be used to create a wide range of filters. |
| 581 | It can function independently or be subclassed |
| 582 | to provide more specific controls based on a |
| 583 | particular filter type. |
| 584 | |
| 585 | In particular, this class implements the standard |
| 586 | difference equation: |
| 587 | |
| 588 | a[0]*y[n] = b[0]*x[n] + ... + b[nb]*x[n-nb] - |
| 589 | a[1]*y[n-1] - ... - a[na]*y[n-na] |
| 590 | |
| 591 | If a[0] is not equal to 1, the filter coeffcients |
| 592 | are normalized by a[0]. |
| 593 | |
| 594 | The \e gain parameter is applied at the filter |
| 595 | input and does not affect the coefficient values. |
| 596 | The default gain value is 1.0. This structure |
| 597 | results in one extra multiply per computed sample, |
| 598 | but allows easy control of the overall filter gain. |
| 599 | |
| 600 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 601 | */ |
| 602 | /***************************************************/ |
| 603 | |
| 604 | #if !defined(__FILTER_H) |
| 605 | #define __FILTER_H |
| 606 | |
| 607 | |
| 608 | class FilterStk : public Stk |
| 609 | { |
| 610 | public: |
| 611 | //! Default constructor creates a zero-order pass-through "filter". |
| 612 | FilterStk(void); |
| 613 | |
| 614 | //! Overloaded constructor which takes filter coefficients. |
| 615 | /*! |
| 616 | An StkError can be thrown if either \e nb or \e na is less than |
| 617 | one, or if the a[0] coefficient is equal to zero. |
| 618 | */ |
| 619 | FilterStk(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients); |
| 620 | |
| 621 | //! Class destructor. |
| 622 | virtual ~FilterStk(void); |
| 623 | |
| 624 | //! Clears all internal states of the filter. |
| 625 | void clear(void); |
| 626 | |
| 627 | //! Set filter coefficients. |
| 628 | /*! |
| 629 | An StkError can be thrown if either \e nb or \e na is less than |
| 630 | one, or if the a[0] coefficient is equal to zero. If a[0] is not |
| 631 | equal to 1, the filter coeffcients are normalized by a[0]. |
| 632 | */ |
| 633 | void setCoefficients(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients); |
| 634 | |
| 635 | //! Set numerator coefficients. |
| 636 | /*! |
| 637 | An StkError can be thrown if \e nb is less than one. Any |
| 638 | previously set denominator coefficients are left unaffected. |
| 639 | Note that the default constructor sets the single denominator |
| 640 | coefficient a[0] to 1.0. |
| 641 | */ |
| 642 | void setNumerator(int nb, MY_FLOAT *bCoefficients); |
| 643 | |
| 644 | //! Set denominator coefficients. |
| 645 | /*! |
| 646 | An StkError can be thrown if \e na is less than one or if the |
| 647 | a[0] coefficient is equal to zero. Previously set numerator |
| 648 | coefficients are unaffected unless a[0] is not equal to 1, in |
| 649 | which case all coeffcients are normalized by a[0]. Note that the |
| 650 | default constructor sets the single numerator coefficient b[0] |
| 651 | to 1.0. |
| 652 | */ |
| 653 | void setDenominator(int na, MY_FLOAT *aCoefficients); |
| 654 | |
| 655 | //! Set the filter gain. |
| 656 | /*! |
| 657 | The gain is applied at the filter input and does not affect the |
| 658 | coefficient values. The default gain value is 1.0. |
| 659 | */ |
| 660 | virtual void setGain(MY_FLOAT theGain); |
| 661 | |
| 662 | //! Return the current filter gain. |
| 663 | virtual MY_FLOAT getGain(void) const; |
| 664 | |
| 665 | //! Return the last computed output value. |
| 666 | virtual MY_FLOAT lastOut(void) const; |
| 667 | |
| 668 | //! Input one sample to the filter and return one output. |
| 669 | virtual MY_FLOAT tick(MY_FLOAT sample); |
| 670 | |
| 671 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 672 | virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 673 | |
| 674 | public: |
| 675 | MY_FLOAT gain; |
| 676 | int nB; |
| 677 | int nA; |
| 678 | MY_FLOAT *b; |
| 679 | MY_FLOAT *a; |
| 680 | MY_FLOAT *outputs; |
| 681 | MY_FLOAT *inputs; |
| 682 | |
| 683 | }; |
| 684 | |
| 685 | #endif |
| 686 | |
| 687 | |
| 688 | |
| 689 | |
| 690 | /***************************************************/ |
| 691 | /*! \class DelayBase |
| 692 | \brief STK non-interpolating delay line class. |
| 693 | |
| 694 | This protected Filter subclass implements |
| 695 | a non-interpolating digital delay-line. |
| 696 | A fixed maximum length of 4095 and a delay |
| 697 | of zero is set using the default constructor. |
| 698 | Alternatively, the delay and maximum length |
| 699 | can be set during instantiation with an |
| 700 | overloaded constructor. |
| 701 | |
| 702 | A non-interpolating delay line is typically |
| 703 | used in fixed delay-length applications, such |
| 704 | as for reverberation. |
| 705 | |
| 706 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 707 | */ |
| 708 | /***************************************************/ |
| 709 | |
| 710 | #if !defined(__DELAY_H) |
| 711 | #define __DELAY_H |
| 712 | |
| 713 | |
| 714 | class DelayBase : public FilterStk |
| 715 | { |
| 716 | public: |
| 717 | |
| 718 | //! Default constructor creates a delay-line with maximum length of 4095 samples and zero delay. |
| 719 | DelayBase(); |
| 720 | |
| 721 | //! Overloaded constructor which specifies the current and maximum delay-line lengths. |
| 722 | DelayBase(long theDelay, long maxDelay); |
| 723 | |
| 724 | //! Class destructor. |
| 725 | virtual ~DelayBase(); |
| 726 | |
| 727 | //! Clears the internal state of the delay line. |
| 728 | void clear(); |
| 729 | |
| 730 | //! Set the delay-line length. |
| 731 | /*! |
| 732 | The valid range for \e theDelay is from 0 to the maximum delay-line length. |
| 733 | */ |
| 734 | void setDelay(long theDelay); |
| 735 | void set( long delay, long max ); |
| 736 | |
| 737 | //! Return the current delay-line length. |
| 738 | MY_FLOAT getDelay(void) const; |
| 739 | |
| 740 | //! Calculate and return the signal energy in the delay-line. |
| 741 | MY_FLOAT energy(void) const; |
| 742 | |
| 743 | //! Return the value at \e tapDelay samples from the delay-line input. |
| 744 | /*! |
| 745 | The tap point is determined modulo the delay-line length and is |
| 746 | relative to the last input value (i.e., a tapDelay of zero returns |
| 747 | the last input value). |
| 748 | */ |
| 749 | MY_FLOAT contentsAt(unsigned long tapDelay) const; |
| 750 | |
| 751 | //! Return the last computed output value. |
| 752 | MY_FLOAT lastOut(void) const; |
| 753 | |
| 754 | //! Return the value which will be output by the next call to tick(). |
| 755 | /*! |
| 756 | This method is valid only for delay settings greater than zero! |
| 757 | [VERSION #] Removed const qualification because derived class signatures are non-const: avoid virtual function shadowing warnings by agreeing signatures |
| 758 | */ |
| 759 | virtual MY_FLOAT nextOut(void); |
| 760 | |
| 761 | //! Input one sample to the delay-line and return one output. |
| 762 | virtual MY_FLOAT tick(MY_FLOAT sample); |
| 763 | |
| 764 | //! Input \e vectorSize samples to the delay-line and return an equal number of outputs in \e vector. |
| 765 | virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 766 | |
| 767 | public: |
| 768 | long inPoint; |
| 769 | long outPoint; |
| 770 | long length; |
| 771 | MY_FLOAT delay; |
| 772 | }; |
| 773 | |
| 774 | #endif |
| 775 | |
| 776 | |
| 777 | |
| 778 | |
| 779 | /***************************************************/ |
| 780 | /*! \class DelayL |
| 781 | \brief STK linear interpolating delay line class. |
| 782 | |
| 783 | This Delay subclass implements a fractional- |
| 784 | length digital delay-line using first-order |
| 785 | linear interpolation. A fixed maximum length |
| 786 | of 4095 and a delay of zero is set using the |
| 787 | default constructor. Alternatively, the |
| 788 | delay and maximum length can be set during |
| 789 | instantiation with an overloaded constructor. |
| 790 | |
| 791 | Linear interpolation is an efficient technique |
| 792 | for achieving fractional delay lengths, though |
| 793 | it does introduce high-frequency signal |
| 794 | attenuation to varying degrees depending on the |
| 795 | fractional delay setting. The use of higher |
| 796 | order Lagrange interpolators can typically |
| 797 | improve (minimize) this attenuation characteristic. |
| 798 | |
| 799 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 800 | */ |
| 801 | /***************************************************/ |
| 802 | |
| 803 | #if !defined(__DELAYL_H) |
| 804 | #define __DELAYL_H |
| 805 | |
| 806 | |
| 807 | class DelayL : public DelayBase |
| 808 | { |
| 809 | public: |
| 810 | |
| 811 | //! Default constructor creates a delay-line with maximum length of 4095 samples and zero delay. |
| 812 | DelayL(); |
| 813 | |
| 814 | //! Overloaded constructor which specifies the current and maximum delay-line lengths. |
| 815 | |
| 816 | DelayL(MY_FLOAT theDelay, long maxDelay); |
| 817 | |
| 818 | //! Class destructor. |
| 819 | ~DelayL(); |
| 820 | |
| 821 | //! Set the delay-line length. |
| 822 | /*! |
| 823 | The valid range for \e theDelay is from 0 to the maximum delay-line length. |
| 824 | */ |
| 825 | void setDelay(MY_FLOAT theDelay); |
| 826 | void set( MY_FLOAT delay, long max ); |
| 827 | |
| 828 | //! Return the value which will be output by the next call to tick(). |
| 829 | /*! |
| 830 | This method is valid only for delay settings greater than zero! |
| 831 | */ |
| 832 | virtual MY_FLOAT nextOut(void); |
| 833 | |
| 834 | //! Input one sample to the delay-line and return one output. |
| 835 | virtual MY_FLOAT tick(MY_FLOAT sample); |
| 836 | |
| 837 | public: // SWAP formerly protected |
| 838 | MY_FLOAT alpha; |
| 839 | MY_FLOAT omAlpha; |
| 840 | MY_FLOAT nextOutput; |
| 841 | bool doNextOut; |
| 842 | }; |
| 843 | |
| 844 | #endif |
| 845 | |
| 846 | |
| 847 | |
| 848 | |
| 849 | /***************************************************/ |
| 850 | /*! \class BowTabl |
| 851 | \brief STK bowed string table class. |
| 852 | |
| 853 | This class implements a simple bowed string |
| 854 | non-linear function, as described by Smith (1986). |
| 855 | |
| 856 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 857 | */ |
| 858 | /***************************************************/ |
| 859 | |
| 860 | #if !defined(__BOWTABL_H) |
| 861 | #define __BOWTABL_H |
| 862 | |
| 863 | |
| 864 | class BowTabl : public Stk |
| 865 | { |
| 866 | public: |
| 867 | //! Default constructor. |
| 868 | BowTabl(); |
| 869 | |
| 870 | //! Class destructor. |
| 871 | ~BowTabl(); |
| 872 | |
| 873 | //! Set the table offset value. |
| 874 | /*! |
| 875 | The table offset is a bias which controls the |
| 876 | symmetry of the friction. If you want the |
| 877 | friction to vary with direction, use a non-zero |
| 878 | value for the offset. The default value is zero. |
| 879 | */ |
| 880 | void setOffset(MY_FLOAT aValue); |
| 881 | |
| 882 | //! Set the table slope value. |
| 883 | /*! |
| 884 | The table slope controls the width of the friction |
| 885 | pulse, which is related to bow force. |
| 886 | */ |
| 887 | void setSlope(MY_FLOAT aValue); |
| 888 | |
| 889 | //! Return the last output value. |
| 890 | MY_FLOAT lastOut(void) const; |
| 891 | |
| 892 | //! Return the function value for \e input. |
| 893 | /*! |
| 894 | The function input represents differential |
| 895 | string-to-bow velocity. |
| 896 | */ |
| 897 | MY_FLOAT tick(const MY_FLOAT input); |
| 898 | |
| 899 | //! Take \e vectorSize inputs and return the corresponding function values in \e vector. |
| 900 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 901 | |
| 902 | public: // SWAP formerly protected |
| 903 | MY_FLOAT offSet; |
| 904 | MY_FLOAT slope; |
| 905 | MY_FLOAT lastOutput; |
| 906 | |
| 907 | }; |
| 908 | |
| 909 | #endif |
| 910 | |
| 911 | |
| 912 | |
| 913 | |
| 914 | /***************************************************/ |
| 915 | /*! \class BiQuad |
| 916 | \brief STK biquad (two-pole, two-zero) filter class. |
| 917 | |
| 918 | This protected Filter subclass implements a |
| 919 | two-pole, two-zero digital filter. A method |
| 920 | is provided for creating a resonance in the |
| 921 | frequency response while maintaining a constant |
| 922 | filter gain. |
| 923 | |
| 924 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 925 | */ |
| 926 | /***************************************************/ |
| 927 | |
| 928 | #if !defined(__BIQUAD_H) |
| 929 | #define __BIQUAD_H |
| 930 | |
| 931 | |
| 932 | class BiQuad : public FilterStk |
| 933 | { |
| 934 | public: |
| 935 | |
| 936 | //! Default constructor creates a second-order pass-through filter. |
| 937 | BiQuad(); |
| 938 | |
| 939 | //! Class destructor. |
| 940 | virtual ~BiQuad(); |
| 941 | |
| 942 | //! Clears all internal states of the filter. |
| 943 | void clear(void); |
| 944 | |
| 945 | //! Set the b[0] coefficient value. |
| 946 | void setB0(MY_FLOAT b0); |
| 947 | |
| 948 | //! Set the b[1] coefficient value. |
| 949 | void setB1(MY_FLOAT b1); |
| 950 | |
| 951 | //! Set the b[2] coefficient value. |
| 952 | void setB2(MY_FLOAT b2); |
| 953 | |
| 954 | //! Set the a[1] coefficient value. |
| 955 | void setA1(MY_FLOAT a1); |
| 956 | |
| 957 | //! Set the a[2] coefficient value. |
| 958 | void setA2(MY_FLOAT a2); |
| 959 | |
| 960 | //! Sets the filter coefficients for a resonance at \e frequency (in Hz). |
| 961 | /*! |
| 962 | This method determines the filter coefficients corresponding to |
| 963 | two complex-conjugate poles with the given \e frequency (in Hz) |
| 964 | and \e radius from the z-plane origin. If \e normalize is true, |
| 965 | the filter zeros are placed at z = 1, z = -1, and the coefficients |
| 966 | are then normalized to produce a constant unity peak gain |
| 967 | (independent of the filter \e gain parameter). The resulting |
| 968 | filter frequency response has a resonance at the given \e |
| 969 | frequency. The closer the poles are to the unit-circle (\e radius |
| 970 | close to one), the narrower the resulting resonance width. |
| 971 | */ |
| 972 | void setResonance(MY_FLOAT frequency, MY_FLOAT radius, bool normalize = FALSE); |
| 973 | |
| 974 | //! Set the filter coefficients for a notch at \e frequency (in Hz). |
| 975 | /*! |
| 976 | This method determines the filter coefficients corresponding to |
| 977 | two complex-conjugate zeros with the given \e frequency (in Hz) |
| 978 | and \e radius from the z-plane origin. No filter normalization |
| 979 | is attempted. |
| 980 | */ |
| 981 | void setNotch(MY_FLOAT frequency, MY_FLOAT radius); |
| 982 | |
| 983 | //! Sets the filter zeroes for equal resonance gain. |
| 984 | /*! |
| 985 | When using the filter as a resonator, zeroes places at z = 1, z |
| 986 | = -1 will result in a constant gain at resonance of 1 / (1 - R), |
| 987 | where R is the pole radius setting. |
| 988 | |
| 989 | */ |
| 990 | void setEqualGainZeroes(); |
| 991 | |
| 992 | //! Set the filter gain. |
| 993 | /*! |
| 994 | The gain is applied at the filter input and does not affect the |
| 995 | coefficient values. The default gain value is 1.0. |
| 996 | */ |
| 997 | void setGain(MY_FLOAT theGain); |
| 998 | |
| 999 | //! Return the current filter gain. |
| 1000 | MY_FLOAT getGain(void) const; |
| 1001 | |
| 1002 | //! Return the last computed output value. |
| 1003 | MY_FLOAT lastOut(void) const; |
| 1004 | |
| 1005 | //! Input one sample to the filter and return one output. |
| 1006 | MY_FLOAT tick(MY_FLOAT sample); |
| 1007 | |
| 1008 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 1009 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 1010 | }; |
| 1011 | |
| 1012 | #endif |
| 1013 | |
| 1014 | |
| 1015 | |
| 1016 | |
| 1017 | /***************************************************/ |
| 1018 | /*! \class BandedWG |
| 1019 | \brief Banded waveguide modeling class. |
| 1020 | |
| 1021 | This class uses banded waveguide techniques to |
| 1022 | model a variety of sounds, including bowed |
| 1023 | bars, glasses, and bowls. For more |
| 1024 | information, see Essl, G. and Cook, P. "Banded |
| 1025 | Waveguides: Towards Physical Modelling of Bar |
| 1026 | Percussion Instruments", Proceedings of the |
| 1027 | 1999 International Computer Music Conference. |
| 1028 | |
| 1029 | Control Change Numbers: |
| 1030 | - Bow Pressure = 2 |
| 1031 | - Bow Motion = 4 |
| 1032 | - Strike Position = 8 (not implemented) |
| 1033 | - Vibrato Frequency = 11 |
| 1034 | - Gain = 1 |
| 1035 | - Bow Velocity = 128 |
| 1036 | - Set Striking = 64 |
| 1037 | - Instrument Presets = 16 |
| 1038 | - Uniform Bar = 0 |
| 1039 | - Tuned Bar = 1 |
| 1040 | - Glass Harmonica = 2 |
| 1041 | - Tibetan Bowl = 3 |
| 1042 | |
| 1043 | by Georg Essl, 1999 - 2002. |
| 1044 | Modified for Stk 4.0 by Gary Scavone. |
| 1045 | */ |
| 1046 | /***************************************************/ |
| 1047 | |
| 1048 | #if !defined(__BANDEDWG_H) |
| 1049 | #define __BANDEDWG_H |
| 1050 | |
| 1051 | #define MAX_BANDED_MODES 20 |
| 1052 | |
| 1053 | |
| 1054 | class BandedWG : public Instrmnt |
| 1055 | { |
| 1056 | public: |
| 1057 | //! Class constructor. |
| 1058 | BandedWG(); |
| 1059 | |
| 1060 | //! Class destructor. |
| 1061 | ~BandedWG(); |
| 1062 | |
| 1063 | //! Reset and clear all internal state. |
| 1064 | void clear(); |
| 1065 | |
| 1066 | //! Set strike position (0.0 - 1.0). |
| 1067 | void setStrikePosition(MY_FLOAT position); |
| 1068 | |
| 1069 | //! Select a preset. |
| 1070 | void setPreset(int preset); |
| 1071 | |
| 1072 | //! Set instrument parameters for a particular frequency. |
| 1073 | void setFrequency(MY_FLOAT frequency); |
| 1074 | |
| 1075 | //! Apply bow velocity/pressure to instrument with given amplitude and rate of increase. |
| 1076 | void startBowing(MY_FLOAT amplitude, MY_FLOAT rate); |
| 1077 | |
| 1078 | //! Decrease bow velocity/breath pressure with given rate of decrease. |
| 1079 | void stopBowing(MY_FLOAT rate); |
| 1080 | |
| 1081 | //! Pluck the instrument with given amplitude. |
| 1082 | void pluck(MY_FLOAT amp); |
| 1083 | |
| 1084 | //! Start a note with the given frequency and amplitude. |
| 1085 | void noteOn(MY_FLOAT amplitude) { noteOn ( freakency, amplitude ); } |
| 1086 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 1087 | |
| 1088 | //! Stop a note with the given amplitude (speed of decay). |
| 1089 | void noteOff(MY_FLOAT amplitude); |
| 1090 | |
| 1091 | //! Compute one output sample. |
| 1092 | MY_FLOAT tick(); |
| 1093 | |
| 1094 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 1095 | void controlChange(int number, MY_FLOAT value); |
| 1096 | |
| 1097 | public: // SWAP formerly protected |
| 1098 | //chuck |
| 1099 | t_CKFLOAT m_rate; |
| 1100 | t_CKINT m_preset; |
| 1101 | t_CKFLOAT m_bowPressure; |
| 1102 | t_CKFLOAT m_bowMotion; |
| 1103 | t_CKFLOAT m_modesGain; |
| 1104 | t_CKFLOAT m_strikePosition; |
| 1105 | |
| 1106 | bool doPluck; |
| 1107 | bool trackVelocity; |
| 1108 | int nModes; |
| 1109 | int presetModes; |
| 1110 | BowTabl *bowTabl; |
| 1111 | ADSR *adsr; |
| 1112 | BiQuad *bandpass; |
| 1113 | DelayL *delay; |
| 1114 | MY_FLOAT maxVelocity; |
| 1115 | MY_FLOAT modes[MAX_BANDED_MODES]; |
| 1116 | MY_FLOAT freakency; |
| 1117 | MY_FLOAT baseGain; |
| 1118 | MY_FLOAT gains[MAX_BANDED_MODES]; |
| 1119 | MY_FLOAT outGains[MAX_BANDED_MODES]; // 1.4.1.0 (prc): REPAIRATHON2021 addition |
| 1120 | MY_FLOAT modeReson; // 1.4.1.0 (prc): REPAIRATHON2021 addition |
| 1121 | MY_FLOAT basegains[MAX_BANDED_MODES]; |
| 1122 | MY_FLOAT excitation[MAX_BANDED_MODES]; |
| 1123 | MY_FLOAT integrationConstant; |
| 1124 | MY_FLOAT velocityInput; |
| 1125 | MY_FLOAT bowVelocity; |
| 1126 | MY_FLOAT bowTarget; |
| 1127 | MY_FLOAT bowPosition; |
| 1128 | MY_FLOAT strikeAmp; |
| 1129 | MY_FLOAT strikePosition; // 1.4.1.0 (prc): REPAIRATHON2021 changed from int |
| 1130 | }; |
| 1131 | |
| 1132 | #endif |
| 1133 | |
| 1134 | |
| 1135 | |
| 1136 | |
| 1137 | /***************************************************/ |
| 1138 | /*! \class WvIn |
| 1139 | \brief STK audio data input base class. |
| 1140 | |
| 1141 | This class provides input support for various |
| 1142 | audio file formats. It also serves as a base |
| 1143 | class for "realtime" streaming subclasses. |
| 1144 | |
| 1145 | WvIn loads the contents of an audio file for |
| 1146 | subsequent output. Linear interpolation is |
| 1147 | used for fractional "read rates". |
| 1148 | |
| 1149 | WvIn supports multi-channel data in interleaved |
| 1150 | format. It is important to distinguish the |
| 1151 | tick() methods, which return samples produced |
| 1152 | by averaging across sample frames, from the |
| 1153 | tickFrame() methods, which return pointers to |
| 1154 | multi-channel sample frames. For single-channel |
| 1155 | data, these methods return equivalent values. |
| 1156 | |
| 1157 | Small files are completely read into local memory |
| 1158 | during instantiation. Large files are read |
| 1159 | incrementally from disk. The file size threshold |
| 1160 | and the increment size values are defined in |
| 1161 | WvIn.h. |
| 1162 | |
| 1163 | WvIn currently supports WAV, AIFF, SND (AU), |
| 1164 | MAT-file (Matlab), and STK RAW file formats. |
| 1165 | Signed integer (8-, 16-, and 32-bit) and floating- |
| 1166 | point (32- and 64-bit) data types are supported. |
| 1167 | Uncompressed data types are not supported. If |
| 1168 | using MAT-files, data should be saved in an array |
| 1169 | with each data channel filling a matrix row. |
| 1170 | |
| 1171 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 1172 | */ |
| 1173 | /***************************************************/ |
| 1174 | |
| 1175 | #if !defined(__WVIN_H) |
| 1176 | #define __WVIN_H |
| 1177 | |
| 1178 | // Files larger than CHUNK_THRESHOLD will be copied into memory |
| 1179 | // in CHUNK_SIZE increments, rather than completely loaded into |
| 1180 | // a buffer at once. |
| 1181 | |
| 1182 | #define CHUNK_THRESHOLD 5000000 // 5 Mb |
| 1183 | #define CHUNK_SIZE 1024 // sample frames |
| 1184 | |
| 1185 | #include <stdio.h> |
| 1186 | |
| 1187 | class WvIn : public Stk |
| 1188 | { |
| 1189 | public: |
| 1190 | //! Default constructor. |
| 1191 | WvIn(); |
| 1192 | |
| 1193 | //! Overloaded constructor for file input. |
| 1194 | /*! |
| 1195 | An StkError will be thrown if the file is not found, its format is |
| 1196 | unknown, or a read error occurs. |
| 1197 | */ |
| 1198 | WvIn( const char *fileName, bool raw = FALSE, bool doNormalize = TRUE, bool generate = TRUE ); |
| 1199 | |
| 1200 | //! Class destructor. |
| 1201 | virtual ~WvIn(); |
| 1202 | |
| 1203 | //! Open the specified file and load its data. |
| 1204 | /*! |
| 1205 | An StkError will be thrown if the file is not found, its format is |
| 1206 | unknown, or a read error occurs. |
| 1207 | */ |
| 1208 | virtual void openFile( const char *fileName, bool raw = FALSE, bool doNormalize = TRUE, bool generate = TRUE ); |
| 1209 | |
| 1210 | //! If a file is open, close it. |
| 1211 | void closeFile(void); |
| 1212 | |
| 1213 | //! Clear outputs and reset time (file pointer) to zero. |
| 1214 | void reset(void); |
| 1215 | |
| 1216 | //! Normalize data to a maximum of +-1.0. |
| 1217 | /*! |
| 1218 | For large, incrementally loaded files with integer data types, |
| 1219 | normalization is computed relative to the data type maximum. |
| 1220 | No normalization is performed for incrementally loaded files |
| 1221 | with floating-point data types. |
| 1222 | */ |
| 1223 | void normalize(void); |
| 1224 | |
| 1225 | //! Normalize data to a maximum of \e +-peak. |
| 1226 | /*! |
| 1227 | For large, incrementally loaded files with integer data types, |
| 1228 | normalization is computed relative to the data type maximum |
| 1229 | (\e peak/maximum). For incrementally loaded files with floating- |
| 1230 | point data types, direct scaling by \e peak is performed. |
| 1231 | */ |
| 1232 | void normalize(MY_FLOAT peak); |
| 1233 | |
| 1234 | //! Return the file size in sample frames. |
| 1235 | unsigned long getSize(void) const; |
| 1236 | |
| 1237 | //! Return the number of audio channels in the file. |
| 1238 | unsigned int getChannels(void) const; |
| 1239 | |
| 1240 | //! Return the input file sample rate in Hz (not the data read rate). |
| 1241 | /*! |
| 1242 | WAV, SND, and AIF formatted files specify a sample rate in |
| 1243 | their headers. STK RAW files have a sample rate of 22050 Hz |
| 1244 | by definition. MAT-files are assumed to have a rate of 44100 Hz. |
| 1245 | */ |
| 1246 | MY_FLOAT getFileRate(void) const; |
| 1247 | |
| 1248 | //! Query whether reading is complete. |
| 1249 | bool isFinished(void) const; |
| 1250 | |
| 1251 | //! Set the data read rate in samples. The rate can be negative. |
| 1252 | /*! |
| 1253 | If the rate value is negative, the data is read in reverse order. |
| 1254 | */ |
| 1255 | void setRate(MY_FLOAT aRate); |
| 1256 | |
| 1257 | //! Increment the read pointer by \e aTime samples. |
| 1258 | virtual void addTime(MY_FLOAT aTime); |
| 1259 | |
| 1260 | //! Turn linear interpolation on/off. |
| 1261 | /*! |
| 1262 | Interpolation is automatically off when the read rate is |
| 1263 | an integer value. If interpolation is turned off for a |
| 1264 | fractional rate, the time index is truncated to an integer |
| 1265 | value. |
| 1266 | */ |
| 1267 | void setInterpolate(bool doInterpolate); |
| 1268 | |
| 1269 | //! Return the average across the last output sample frame. |
| 1270 | virtual MY_FLOAT lastOut(void) const; |
| 1271 | |
| 1272 | //! Read out the average across one sample frame of data. |
| 1273 | /*! |
| 1274 | An StkError will be thrown if a file is read incrementally and a read error occurs. |
| 1275 | */ |
| 1276 | virtual MY_FLOAT tick(void); |
| 1277 | |
| 1278 | //! Read out vectorSize averaged sample frames of data in \e vector. |
| 1279 | /*! |
| 1280 | An StkError will be thrown if a file is read incrementally and a read error occurs. |
| 1281 | */ |
| 1282 | virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 1283 | |
| 1284 | //! Return a pointer to the last output sample frame. |
| 1285 | virtual const MY_FLOAT *lastFrame(void) const; |
| 1286 | |
| 1287 | //! Return a pointer to the next sample frame of data. |
| 1288 | /*! |
| 1289 | An StkError will be thrown if a file is read incrementally and a read error occurs. |
| 1290 | */ |
| 1291 | virtual const MY_FLOAT *tickFrame(void); |
| 1292 | |
| 1293 | //! Read out sample \e frames of data to \e frameVector. |
| 1294 | /*! |
| 1295 | An StkError will be thrown if a file is read incrementally and a read error occurs. |
| 1296 | */ |
| 1297 | virtual MY_FLOAT *tickFrame(MY_FLOAT *frameVector, unsigned int frames); |
| 1298 | |
| 1299 | public: // SWAP formerly protected |
| 1300 | |
| 1301 | // Initialize class variables. |
| 1302 | void init( void ); |
| 1303 | |
| 1304 | // Read file data. |
| 1305 | virtual void readData(unsigned long index); |
| 1306 | |
| 1307 | // Get STK RAW file information. |
| 1308 | bool getRawInfo( const char *fileName ); |
| 1309 | |
| 1310 | // Get WAV file header information. |
| 1311 | bool getWavInfo( const char *fileName ); |
| 1312 | |
| 1313 | // Get SND (AU) file header information. |
| 1314 | bool getSndInfo( const char *fileName ); |
| 1315 | |
| 1316 | // Get AIFF file header information. |
| 1317 | bool getAifInfo( const char *fileName ); |
| 1318 | |
| 1319 | // Get MAT-file header information. |
| 1320 | bool getMatInfo( const char *fileName ); |
| 1321 | |
| 1322 | char msg[STK_MSG_BUF_LENGTH]; |
| 1323 | // char m_filename[STK_MSG_BUF_LENGTH]; // chuck data |
| 1324 | // Chuck_String str_filename; // chuck data |
| 1325 | // NOTE: all Chuck_Objects needs heap allocation using 'new' |
| 1326 | // since reference counting automatically calls 'delete' |
| 1327 | std::string str_filename; |
| 1328 | FILE *fd; |
| 1329 | MY_FLOAT *data; |
| 1330 | MY_FLOAT *lastOutput; |
| 1331 | bool chunking; |
| 1332 | bool finished; |
| 1333 | bool interpolate; |
| 1334 | bool byteswap; |
| 1335 | unsigned long fileSize; |
| 1336 | unsigned long bufferSize; |
| 1337 | unsigned long dataOffset; |
| 1338 | unsigned int channels; |
| 1339 | long chunkPointer; |
| 1340 | STK_FORMAT dataType; |
| 1341 | MY_FLOAT fileRate; |
| 1342 | MY_FLOAT gain; |
| 1343 | MY_FLOAT time; |
| 1344 | MY_FLOAT rate; |
| 1345 | MY_FLOAT scaleToOne; |
| 1346 | public: |
| 1347 | bool m_loaded; |
| 1348 | }; |
| 1349 | |
| 1350 | #endif // defined(__WVIN_H) |
| 1351 | |
| 1352 | |
| 1353 | |
| 1354 | |
| 1355 | /***************************************************/ |
| 1356 | /*! \class WaveLoop |
| 1357 | \brief STK waveform oscillator class. |
| 1358 | |
| 1359 | This class inherits from WvIn and provides |
| 1360 | audio file looping functionality. |
| 1361 | |
| 1362 | WaveLoop supports multi-channel data in |
| 1363 | interleaved format. It is important to |
| 1364 | distinguish the tick() methods, which return |
| 1365 | samples produced by averaging across sample |
| 1366 | frames, from the tickFrame() methods, which |
| 1367 | return pointers to multi-channel sample frames. |
| 1368 | For single-channel data, these methods return |
| 1369 | equivalent values. |
| 1370 | |
| 1371 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 1372 | */ |
| 1373 | /***************************************************/ |
| 1374 | |
| 1375 | #if !defined(__WAVELOOP_H) |
| 1376 | #define __WAVELOOP_H |
| 1377 | |
| 1378 | #include <stdio.h> |
| 1379 | |
| 1380 | class WaveLoop : public WvIn |
| 1381 | { |
| 1382 | public: |
| 1383 | WaveLoop( ); |
| 1384 | //! Class constructor. |
| 1385 | WaveLoop( const char *fileName, bool raw = FALSE, bool generate = true ); |
| 1386 | |
| 1387 | using WvIn::openFile; // tell the compiler we're OK overloading/shadowing a virtual function |
| 1388 | virtual void openFile( const char * fileName, bool raw = FALSE, bool n = TRUE ); |
| 1389 | |
| 1390 | //! Class destructor. |
| 1391 | virtual ~WaveLoop(); |
| 1392 | |
| 1393 | //! Set the data interpolation rate based on a looping frequency. |
| 1394 | /*! |
| 1395 | This function determines the interpolation rate based on the file |
| 1396 | size and the current Stk::sampleRate. The \e aFrequency value |
| 1397 | corresponds to file cycles per second. The frequency can be |
| 1398 | negative, in which case the loop is read in reverse order. |
| 1399 | */ |
| 1400 | void setFrequency(MY_FLOAT aFrequency); |
| 1401 | |
| 1402 | //! Increment the read pointer by \e aTime samples, modulo file size. |
| 1403 | void addTime(MY_FLOAT aTime); |
| 1404 | |
| 1405 | //! Increment current read pointer by \e anAngle, relative to a looping frequency. |
| 1406 | /*! |
| 1407 | This function increments the read pointer based on the file |
| 1408 | size and the current Stk::sampleRate. The \e anAngle value |
| 1409 | is a multiple of file size. |
| 1410 | */ |
| 1411 | void addPhase(MY_FLOAT anAngle); |
| 1412 | |
| 1413 | //! Add a phase offset to the current read pointer. |
| 1414 | /*! |
| 1415 | This function determines a time offset based on the file |
| 1416 | size and the current Stk::sampleRate. The \e anAngle value |
| 1417 | is a multiple of file size. |
| 1418 | */ |
| 1419 | void addPhaseOffset(MY_FLOAT anAngle); |
| 1420 | |
| 1421 | //! Return a pointer to the next sample frame of data. |
| 1422 | const MY_FLOAT *tickFrame(void); |
| 1423 | |
| 1424 | public: |
| 1425 | |
| 1426 | // Read file data. |
| 1427 | void readData(unsigned long index); |
| 1428 | MY_FLOAT phaseOffset; |
| 1429 | MY_FLOAT m_freq; // chuck data; |
| 1430 | }; |
| 1431 | |
| 1432 | #endif // defined(__WAVELOOP_H) |
| 1433 | |
| 1434 | |
| 1435 | |
| 1436 | |
| 1437 | /***************************************************/ |
| 1438 | /*! \class TwoZero |
| 1439 | \brief STK two-zero filter class. |
| 1440 | |
| 1441 | This protected Filter subclass implements |
| 1442 | a two-zero digital filter. A method is |
| 1443 | provided for creating a "notch" in the |
| 1444 | frequency response while maintaining a |
| 1445 | constant filter gain. |
| 1446 | |
| 1447 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 1448 | */ |
| 1449 | /***************************************************/ |
| 1450 | |
| 1451 | #if !defined(__TWOZERO_H) |
| 1452 | #define __TWOZERO_H |
| 1453 | |
| 1454 | |
| 1455 | class TwoZero : public FilterStk // formerly protected Filter |
| 1456 | { |
| 1457 | public: |
| 1458 | //! Default constructor creates a second-order pass-through filter. |
| 1459 | TwoZero(); |
| 1460 | |
| 1461 | //! Class destructor. |
| 1462 | ~TwoZero(); |
| 1463 | |
| 1464 | //! Clears the internal states of the filter. |
| 1465 | void clear(void); |
| 1466 | |
| 1467 | //! Set the b[0] coefficient value. |
| 1468 | void setB0(MY_FLOAT b0); |
| 1469 | |
| 1470 | //! Set the b[1] coefficient value. |
| 1471 | void setB1(MY_FLOAT b1); |
| 1472 | |
| 1473 | //! Set the b[2] coefficient value. |
| 1474 | void setB2(MY_FLOAT b2); |
| 1475 | |
| 1476 | //! Sets the filter coefficients for a "notch" at \e frequency (in Hz). |
| 1477 | /*! |
| 1478 | This method determines the filter coefficients corresponding to |
| 1479 | two complex-conjugate zeros with the given \e frequency (in Hz) |
| 1480 | and \e radius from the z-plane origin. The coefficients are then |
| 1481 | normalized to produce a maximum filter gain of one (independent of |
| 1482 | the filter \e gain parameter). The resulting filter frequency |
| 1483 | response has a "notch" or anti-resonance at the given \e |
| 1484 | frequency. The closer the zeros are to the unit-circle (\e radius |
| 1485 | close to or equal to one), the narrower the resulting notch width. |
| 1486 | */ |
| 1487 | void setNotch(MY_FLOAT frequency, MY_FLOAT radius); |
| 1488 | |
| 1489 | void ck_setNotchFreq ( MY_FLOAT freq ) { m_notchFreq = freq; setNotch (m_notchFreq, m_notchRad); } |
| 1490 | void ck_setNotchRad ( MY_FLOAT rad ) { m_notchRad = rad; setNotch (m_notchFreq, m_notchRad); } |
| 1491 | |
| 1492 | |
| 1493 | //chuck helper functions |
| 1494 | MY_FLOAT m_notchFreq; |
| 1495 | MY_FLOAT m_notchRad; |
| 1496 | |
| 1497 | //! Set the filter gain. |
| 1498 | /*! |
| 1499 | The gain is applied at the filter input and does not affect the |
| 1500 | coefficient values. The default gain value is 1.0. |
| 1501 | */ |
| 1502 | void setGain(MY_FLOAT theGain); |
| 1503 | |
| 1504 | //! Return the current filter gain. |
| 1505 | MY_FLOAT getGain(void) const; |
| 1506 | |
| 1507 | //! Return the last computed output value. |
| 1508 | MY_FLOAT lastOut(void) const; |
| 1509 | |
| 1510 | //! Input one sample to the filter and return one output. |
| 1511 | MY_FLOAT tick(MY_FLOAT sample); |
| 1512 | |
| 1513 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 1514 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 1515 | }; |
| 1516 | |
| 1517 | #endif |
| 1518 | |
| 1519 | |
| 1520 | |
| 1521 | |
| 1522 | /***************************************************/ |
| 1523 | /*! \class FM |
| 1524 | \brief STK abstract FM synthesis base class. |
| 1525 | |
| 1526 | This class controls an arbitrary number of |
| 1527 | waves and envelopes, determined via a |
| 1528 | constructor argument. |
| 1529 | |
| 1530 | Control Change Numbers: |
| 1531 | - Control One = 2 |
| 1532 | - Control Two = 4 |
| 1533 | - LFO Speed = 11 |
| 1534 | - LFO Depth = 1 |
| 1535 | - ADSR 2 & 4 Target = 128 |
| 1536 | |
| 1537 | The basic Chowning/Stanford FM patent expired |
| 1538 | in 1995, but there exist follow-on patents, |
| 1539 | mostly assigned to Yamaha. If you are of the |
| 1540 | type who should worry about this (making |
| 1541 | money) worry away. |
| 1542 | |
| 1543 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 1544 | */ |
| 1545 | /***************************************************/ |
| 1546 | |
| 1547 | #if !defined(__FM_H) |
| 1548 | #define __FM_H |
| 1549 | |
| 1550 | |
| 1551 | class FM : public Instrmnt |
| 1552 | { |
| 1553 | public: |
| 1554 | //! Class constructor, taking the number of wave/envelope operators to control. |
| 1555 | FM( int operators = 4 ); |
| 1556 | |
| 1557 | //! Class destructor. |
| 1558 | virtual ~FM(); |
| 1559 | |
| 1560 | //! Reset and clear all wave and envelope states. |
| 1561 | void clear(); |
| 1562 | |
| 1563 | //! Load the rawwave filenames in waves. |
| 1564 | void loadWaves(const char **filenames); |
| 1565 | |
| 1566 | /***************************************/ |
| 1567 | // 1.4.1.0 (prc): *** REPAIRATHON2021 *** |
| 1568 | // NEW FM PARAMETER ACCESS, NEW PARAMETERS!!! |
| 1569 | //! Set all parameters of one of the internal ADSRs |
| 1570 | void setADSR(int which, MY_FLOAT a, MY_FLOAT d, MY_FLOAT s, MY_FLOAT r); |
| 1571 | |
| 1572 | //! Set gain of individual operator |
| 1573 | void setOpGain(int opNum, MY_FLOAT g); |
| 1574 | |
| 1575 | //! Get the value of operator gain |
| 1576 | MY_FLOAT getOpGain(int opNum); |
| 1577 | |
| 1578 | //! Set individual operator Amplitude Modulation |
| 1579 | void setOpAM(int opNum, MY_FLOAT g); |
| 1580 | |
| 1581 | //! Get the value of operator Amplitude Modulation |
| 1582 | MY_FLOAT getOpAM(int opNum); |
| 1583 | |
| 1584 | //! Get the value of operator Frequency Ratio |
| 1585 | MY_FLOAT getRatio(int opNum); |
| 1586 | |
| 1587 | //! Set individual operator waveform (0-7) |
| 1588 | void setOpWave(int opNum, int wave); |
| 1589 | |
| 1590 | //! Set the value of operator 4 feedback |
| 1591 | void setOp4Feedback(MY_FLOAT fbVal); |
| 1592 | |
| 1593 | //! Get the value of operator 4 feedback |
| 1594 | MY_FLOAT getOp4Feedback(); |
| 1595 | |
| 1596 | MY_FLOAT getFMTableGain(int index); // table lookup accessing functions |
| 1597 | MY_FLOAT getFMTableTime(int index); // to mimic TX81Z integer |
| 1598 | MY_FLOAT getFMTableSusLevel(int index); // programming settings |
| 1599 | // 1.4.1.0 (prc): *** END REPAIRATHON2021 BLOCK *** |
| 1600 | /****************************************/ |
| 1601 | |
| 1602 | //! Set instrument parameters for a particular frequency. |
| 1603 | virtual void setFrequency(MY_FLOAT frequency); |
| 1604 | |
| 1605 | //! Set the frequency ratio for the specified wave. |
| 1606 | void setRatio(int waveIndex, MY_FLOAT ratio); |
| 1607 | |
| 1608 | //! Set the gain for the specified wave. |
| 1609 | void setGain(int waveIndex, MY_FLOAT gain); |
| 1610 | |
| 1611 | //! Set the modulation speed in Hz. |
| 1612 | void setModulationSpeed(MY_FLOAT mSpeed); |
| 1613 | |
| 1614 | //! Set the modulation depth. |
| 1615 | void setModulationDepth(MY_FLOAT mDepth); |
| 1616 | |
| 1617 | //! Set the value of control1. |
| 1618 | void setControl1(MY_FLOAT cVal); |
| 1619 | |
| 1620 | //! Set the value of control2. |
| 1621 | void setControl2(MY_FLOAT cVal); |
| 1622 | |
| 1623 | //! Start envelopes toward "on" targets. |
| 1624 | void keyOn(); |
| 1625 | |
| 1626 | //! Start envelopes toward "off" targets. |
| 1627 | void keyOff(); |
| 1628 | |
| 1629 | //! Stop a note with the given amplitude (speed of decay). |
| 1630 | void noteOff(MY_FLOAT amplitude); |
| 1631 | |
| 1632 | //! Pure virtual function ... must be defined in subclasses. |
| 1633 | virtual MY_FLOAT tick() = 0; |
| 1634 | |
| 1635 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 1636 | virtual void controlChange(int number, MY_FLOAT value); |
| 1637 | |
| 1638 | public: // SWAP formerly protected |
| 1639 | ADSR **adsr; |
| 1640 | WaveLoop **waves; |
| 1641 | WaveLoop *vibrato; |
| 1642 | TwoZero *twozero; |
| 1643 | int nOperators; |
| 1644 | MY_FLOAT baseFrequency; |
| 1645 | MY_FLOAT *ratios; |
| 1646 | MY_FLOAT *gains; |
| 1647 | MY_FLOAT *baseGains; // 1.4.1.0 (prc): REPAIRATHON2021 addition |
| 1648 | MY_FLOAT op4Feedback; // 1.4.1.0 (prc): REPAIRATHON2021 addition |
| 1649 | MY_FLOAT *opAMs; // 1.4.1.0 (prc): REPAIRATHON2021 addition |
| 1650 | int bCompatible; // 1.4.1.0 (prc): REPAIRATHON2021 backward compatibilty |
| 1651 | // addition (Rhodey, Wurley, and TubeBell AM) |
| 1652 | |
| 1653 | MY_FLOAT modDepth; |
| 1654 | MY_FLOAT control1; |
| 1655 | MY_FLOAT control2; |
| 1656 | MY_FLOAT __FM_gains[100]; |
| 1657 | MY_FLOAT __FM_susLevels[16]; |
| 1658 | MY_FLOAT __FM_attTimes[32]; |
| 1659 | }; |
| 1660 | |
| 1661 | #endif |
| 1662 | |
| 1663 | |
| 1664 | |
| 1665 | |
| 1666 | /***************************************************/ |
| 1667 | /*! \class BeeThree |
| 1668 | \brief STK Hammond-oid organ FM synthesis instrument. |
| 1669 | |
| 1670 | This class implements a simple 4 operator |
| 1671 | topology, also referred to as algorithm 8 of |
| 1672 | the TX81Z. |
| 1673 | |
| 1674 | \code |
| 1675 | Algorithm 8 is : |
| 1676 | 1 --. |
| 1677 | 2 -\| |
| 1678 | +-> Out |
| 1679 | 3 -/| |
| 1680 | 4 -- |
| 1681 | \endcode |
| 1682 | |
| 1683 | Control Change Numbers: |
| 1684 | - Operator 4 (feedback) Gain = 2 |
| 1685 | - Operator 3 Gain = 4 |
| 1686 | - LFO Speed = 11 |
| 1687 | - LFO Depth = 1 |
| 1688 | - ADSR 2 & 4 Target = 128 |
| 1689 | |
| 1690 | The basic Chowning/Stanford FM patent expired |
| 1691 | in 1995, but there exist follow-on patents, |
| 1692 | mostly assigned to Yamaha. If you are of the |
| 1693 | type who should worry about this (making |
| 1694 | money) worry away. |
| 1695 | |
| 1696 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 1697 | */ |
| 1698 | /***************************************************/ |
| 1699 | |
| 1700 | #if !defined(__BEETHREE_H) |
| 1701 | #define __BEETHREE_H |
| 1702 | |
| 1703 | |
| 1704 | class BeeThree : public FM |
| 1705 | { |
| 1706 | public: |
| 1707 | //! Class constructor. |
| 1708 | BeeThree(); |
| 1709 | |
| 1710 | //! Class destructor. |
| 1711 | ~BeeThree(); |
| 1712 | |
| 1713 | //! Start a note with the given frequency and amplitude. |
| 1714 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 1715 | void noteOn( MY_FLOAT amplitude) { noteOn( baseFrequency, amplitude ); } |
| 1716 | //! Compute one output sample. |
| 1717 | MY_FLOAT tick(); |
| 1718 | }; |
| 1719 | |
| 1720 | #endif |
| 1721 | |
| 1722 | |
| 1723 | |
| 1724 | |
| 1725 | /***************************************************/ |
| 1726 | /*! \class JetTabl |
| 1727 | \brief STK jet table class. |
| 1728 | |
| 1729 | This class implements a flue jet non-linear |
| 1730 | function, computed by a polynomial calculation. |
| 1731 | Contrary to the name, this is not a "table". |
| 1732 | |
| 1733 | Consult Fletcher and Rossing, Karjalainen, |
| 1734 | Cook, and others for more information. |
| 1735 | |
| 1736 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 1737 | */ |
| 1738 | /***************************************************/ |
| 1739 | |
| 1740 | #if !defined(__JETTABL_H) |
| 1741 | #define __JETTABL_H |
| 1742 | |
| 1743 | |
| 1744 | class JetTabl : public Stk |
| 1745 | { |
| 1746 | public: |
| 1747 | //! Default constructor. |
| 1748 | JetTabl(); |
| 1749 | |
| 1750 | //! Class destructor. |
| 1751 | ~JetTabl(); |
| 1752 | |
| 1753 | //! Return the last output value. |
| 1754 | MY_FLOAT lastOut() const; |
| 1755 | |
| 1756 | //! Return the function value for \e input. |
| 1757 | MY_FLOAT tick(MY_FLOAT input); |
| 1758 | |
| 1759 | //! Take \e vectorSize inputs and return the corresponding function values in \e vector. |
| 1760 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 1761 | |
| 1762 | public: // SWAP formerly protected |
| 1763 | MY_FLOAT lastOutput; |
| 1764 | |
| 1765 | }; |
| 1766 | |
| 1767 | #endif |
| 1768 | |
| 1769 | |
| 1770 | |
| 1771 | |
| 1772 | /***************************************************/ |
| 1773 | /*! \class PoleZero |
| 1774 | \brief STK one-pole, one-zero filter class. |
| 1775 | |
| 1776 | This protected Filter subclass implements |
| 1777 | a one-pole, one-zero digital filter. A |
| 1778 | method is provided for creating an allpass |
| 1779 | filter with a given coefficient. Another |
| 1780 | method is provided to create a DC blocking filter. |
| 1781 | |
| 1782 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 1783 | */ |
| 1784 | /***************************************************/ |
| 1785 | |
| 1786 | #if !defined(__POLEZERO_H) |
| 1787 | #define __POLEZERO_H |
| 1788 | |
| 1789 | |
| 1790 | class PoleZero : public FilterStk // formerly protected Filter |
| 1791 | { |
| 1792 | public: |
| 1793 | |
| 1794 | //! Default constructor creates a first-order pass-through filter. |
| 1795 | PoleZero(); |
| 1796 | |
| 1797 | //! Class destructor. |
| 1798 | ~PoleZero(); |
| 1799 | |
| 1800 | //! Clears the internal states of the filter. |
| 1801 | void clear(void); |
| 1802 | |
| 1803 | //! Set the b[0] coefficient value. |
| 1804 | void setB0(MY_FLOAT b0); |
| 1805 | |
| 1806 | //! Set the b[1] coefficient value. |
| 1807 | void setB1(MY_FLOAT b1); |
| 1808 | |
| 1809 | //! Set the a[1] coefficient value. |
| 1810 | void setA1(MY_FLOAT a1); |
| 1811 | |
| 1812 | //! Set the filter for allpass behavior using \e coefficient. |
| 1813 | /*! |
| 1814 | This method uses \e coefficient to create an allpass filter, |
| 1815 | which has unity gain at all frequencies. Note that the \e |
| 1816 | coefficient magnitude must be less than one to maintain stability. |
| 1817 | */ |
| 1818 | void setAllpass(MY_FLOAT coefficient); |
| 1819 | |
| 1820 | //! Create a DC blocking filter with the given pole position in the z-plane. |
| 1821 | /*! |
| 1822 | This method sets the given pole position, together with a zero |
| 1823 | at z=1, to create a DC blocking filter. \e thePole should be |
| 1824 | close to one to minimize low-frequency attenuation. |
| 1825 | |
| 1826 | */ |
| 1827 | void setBlockZero(MY_FLOAT thePole = 0.99); |
| 1828 | |
| 1829 | //! Set the filter gain. |
| 1830 | /*! |
| 1831 | The gain is applied at the filter input and does not affect the |
| 1832 | coefficient values. The default gain value is 1.0. |
| 1833 | */ |
| 1834 | void setGain(MY_FLOAT theGain); |
| 1835 | |
| 1836 | //! Return the current filter gain. |
| 1837 | MY_FLOAT getGain(void) const; |
| 1838 | |
| 1839 | //! Return the last computed output value. |
| 1840 | MY_FLOAT lastOut(void) const; |
| 1841 | |
| 1842 | //! Input one sample to the filter and return one output. |
| 1843 | MY_FLOAT tick(MY_FLOAT sample); |
| 1844 | |
| 1845 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 1846 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 1847 | }; |
| 1848 | |
| 1849 | #endif |
| 1850 | |
| 1851 | |
| 1852 | |
| 1853 | |
| 1854 | /***************************************************/ |
| 1855 | /*! \class Noise |
| 1856 | \brief STK noise generator. |
| 1857 | |
| 1858 | Generic random number generation using the |
| 1859 | C rand() function. The quality of the rand() |
| 1860 | function varies from one OS to another. |
| 1861 | |
| 1862 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 1863 | */ |
| 1864 | /***************************************************/ |
| 1865 | |
| 1866 | #if !defined(__NOISE_H) |
| 1867 | #define __NOISE_H |
| 1868 | |
| 1869 | |
| 1870 | class Noise : public Stk |
| 1871 | { |
| 1872 | public: |
| 1873 | |
| 1874 | //! Default constructor which seeds the random number generator with the system time. |
| 1875 | Noise(); |
| 1876 | |
| 1877 | //! Constructor which seeds the random number generator with a given seed. |
| 1878 | /*! |
| 1879 | If the seed value is zero, the random number generator is |
| 1880 | seeded with the system time. |
| 1881 | */ |
| 1882 | Noise( unsigned int seed ); |
| 1883 | |
| 1884 | //! Class destructor. |
| 1885 | virtual ~Noise(); |
| 1886 | |
| 1887 | //! Seed the random number generator with a specific seed value. |
| 1888 | /*! |
| 1889 | If no seed is provided or the seed value is zero, the random |
| 1890 | number generator is seeded with the current system time. |
| 1891 | */ |
| 1892 | void setSeed( unsigned int seed = 0 ); |
| 1893 | |
| 1894 | //! Return a random number between -1.0 and 1.0 using rand(). |
| 1895 | virtual MY_FLOAT tick(); |
| 1896 | |
| 1897 | //! Return \e vectorSize random numbers between -1.0 and 1.0 in \e vector. |
| 1898 | virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 1899 | |
| 1900 | //! Return the last computed value. |
| 1901 | MY_FLOAT lastOut() const; |
| 1902 | |
| 1903 | public: // SWAP formerly protected |
| 1904 | |
| 1905 | MY_FLOAT lastOutput; |
| 1906 | |
| 1907 | }; |
| 1908 | |
| 1909 | #endif |
| 1910 | |
| 1911 | |
| 1912 | |
| 1913 | |
| 1914 | /***************************************************/ |
| 1915 | /*! \class BlowBotl |
| 1916 | \brief STK blown bottle instrument class. |
| 1917 | |
| 1918 | This class implements a helmholtz resonator |
| 1919 | (biquad filter) with a polynomial jet |
| 1920 | excitation (a la Cook). |
| 1921 | |
| 1922 | Control Change Numbers: |
| 1923 | - Noise Gain = 4 |
| 1924 | - Vibrato Frequency = 11 |
| 1925 | - Vibrato Gain = 1 |
| 1926 | - Volume = 128 |
| 1927 | |
| 1928 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 1929 | */ |
| 1930 | /***************************************************/ |
| 1931 | |
| 1932 | #if !defined(__BOTTLE_H) |
| 1933 | #define __BOTTLE_H |
| 1934 | |
| 1935 | |
| 1936 | class BlowBotl : public Instrmnt |
| 1937 | { |
| 1938 | public: |
| 1939 | //! Class constructor. |
| 1940 | BlowBotl(); |
| 1941 | |
| 1942 | //! Class destructor. |
| 1943 | ~BlowBotl(); |
| 1944 | |
| 1945 | //! Reset and clear all internal state. |
| 1946 | void clear(); |
| 1947 | |
| 1948 | //! Set instrument parameters for a particular frequency. |
| 1949 | void setFrequency(MY_FLOAT frequency); |
| 1950 | |
| 1951 | //! Apply breath velocity to instrument |
| 1952 | void startBlowing(MY_FLOAT amplitude) { startBlowing ( amplitude, m_rate ); } //chuck |
| 1953 | |
| 1954 | //! Apply breath velocity to instrument with given amplitude and rate of increase. |
| 1955 | void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate); |
| 1956 | |
| 1957 | //! Decrease breath velocity with given rate of decrease. |
| 1958 | void stopBlowing(MY_FLOAT rate); |
| 1959 | |
| 1960 | //! Start a note with the given frequency and amplitude. |
| 1961 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 1962 | |
| 1963 | //! Stop a note with the given amplitude (speed of decay). |
| 1964 | void noteOff(MY_FLOAT amplitude); |
| 1965 | |
| 1966 | //! Compute one output sample. |
| 1967 | MY_FLOAT tick(); |
| 1968 | |
| 1969 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 1970 | void controlChange(int number, MY_FLOAT value); |
| 1971 | |
| 1972 | public: // SWAP formerly protected |
| 1973 | // chuck |
| 1974 | t_CKFLOAT m_rate; |
| 1975 | t_CKFLOAT m_noiseGain; |
| 1976 | t_CKFLOAT m_vibratoFreq; |
| 1977 | t_CKFLOAT m_vibratoGain; |
| 1978 | t_CKFLOAT m_volume; |
| 1979 | |
| 1980 | void setVibratoFreq(MY_FLOAT freq) |
| 1981 | { vibrato->setFrequency( freq ); m_vibratoFreq = vibrato->m_freq; } |
| 1982 | void setVibratoGain(MY_FLOAT gain) |
| 1983 | { vibratoGain = gain; m_vibratoGain = vibratoGain; } |
| 1984 | void setNoiseGain(MY_FLOAT gain) |
| 1985 | { noiseGain = gain; m_noiseGain = gain; } |
| 1986 | |
| 1987 | JetTabl *jetTable; |
| 1988 | BiQuad *resonator; |
| 1989 | PoleZero *dcBlock; |
| 1990 | Noise *noise; |
| 1991 | ADSR *adsr; |
| 1992 | WaveLoop *vibrato; |
| 1993 | MY_FLOAT maxPressure; |
| 1994 | MY_FLOAT noiseGain; |
| 1995 | MY_FLOAT vibratoGain; |
| 1996 | MY_FLOAT outputGain; |
| 1997 | }; |
| 1998 | |
| 1999 | #endif |
| 2000 | |
| 2001 | |
| 2002 | |
| 2003 | |
| 2004 | /***************************************************/ |
| 2005 | /*! \class ReedTabl |
| 2006 | \brief STK reed table class. |
| 2007 | |
| 2008 | This class implements a simple one breakpoint, |
| 2009 | non-linear reed function, as described by |
| 2010 | Smith (1986). This function is based on a |
| 2011 | memoryless non-linear spring model of the reed |
| 2012 | (the reed mass is ignored) which saturates when |
| 2013 | the reed collides with the mouthpiece facing. |
| 2014 | |
| 2015 | See McIntyre, Schumacher, & Woodhouse (1983), |
| 2016 | Smith (1986), Hirschman, Cook, Scavone, and |
| 2017 | others for more information. |
| 2018 | |
| 2019 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2020 | */ |
| 2021 | /***************************************************/ |
| 2022 | |
| 2023 | #if !defined(__REEDTABL_H) |
| 2024 | #define __REEDTABL_H |
| 2025 | |
| 2026 | |
| 2027 | class ReedTabl : public Stk |
| 2028 | { |
| 2029 | public: |
| 2030 | //! Default constructor. |
| 2031 | ReedTabl(); |
| 2032 | |
| 2033 | //! Class destructor. |
| 2034 | ~ReedTabl(); |
| 2035 | |
| 2036 | //! Set the table offset value. |
| 2037 | /*! |
| 2038 | The table offset roughly corresponds to the size |
| 2039 | of the initial reed tip opening (a greater offset |
| 2040 | represents a smaller opening). |
| 2041 | */ |
| 2042 | void setOffset(MY_FLOAT aValue); |
| 2043 | |
| 2044 | //! Set the table slope value. |
| 2045 | /*! |
| 2046 | The table slope roughly corresponds to the reed |
| 2047 | stiffness (a greater slope represents a harder |
| 2048 | reed). |
| 2049 | */ |
| 2050 | void setSlope(MY_FLOAT aValue); |
| 2051 | |
| 2052 | //! Return the last output value. |
| 2053 | MY_FLOAT lastOut() const; |
| 2054 | |
| 2055 | //! Return the function value for \e input. |
| 2056 | /*! |
| 2057 | The function input represents the differential |
| 2058 | pressure across the reeds. |
| 2059 | */ |
| 2060 | MY_FLOAT tick(MY_FLOAT input); |
| 2061 | |
| 2062 | //! Take \e vectorSize inputs and return the corresponding function values in \e vector. |
| 2063 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 2064 | |
| 2065 | public: // SWAP formerly protected |
| 2066 | MY_FLOAT offSet; |
| 2067 | MY_FLOAT slope; |
| 2068 | MY_FLOAT lastOutput; |
| 2069 | |
| 2070 | }; |
| 2071 | |
| 2072 | #endif |
| 2073 | |
| 2074 | |
| 2075 | |
| 2076 | |
| 2077 | /***************************************************/ |
| 2078 | /*! \class OneZero |
| 2079 | \brief STK one-zero filter class. |
| 2080 | |
| 2081 | This protected Filter subclass implements |
| 2082 | a one-zero digital filter. A method is |
| 2083 | provided for setting the zero position |
| 2084 | along the real axis of the z-plane while |
| 2085 | maintaining a constant filter gain. |
| 2086 | |
| 2087 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2088 | */ |
| 2089 | /***************************************************/ |
| 2090 | |
| 2091 | #if !defined(__ONEZERO_H) |
| 2092 | #define __ONEZERO_H |
| 2093 | |
| 2094 | |
| 2095 | class OneZero : public FilterStk // formerly protected Filter |
| 2096 | { |
| 2097 | public: |
| 2098 | |
| 2099 | //! Default constructor creates a first-order low-pass filter. |
| 2100 | OneZero(); |
| 2101 | |
| 2102 | //! Overloaded constructor which sets the zero position during instantiation. |
| 2103 | OneZero(MY_FLOAT theZero); |
| 2104 | |
| 2105 | //! Class destructor. |
| 2106 | ~OneZero(); |
| 2107 | |
| 2108 | //! Clears the internal state of the filter. |
| 2109 | void clear(void); |
| 2110 | |
| 2111 | //! Set the b[0] coefficient value. |
| 2112 | void setB0(MY_FLOAT b0); |
| 2113 | |
| 2114 | //! Set the b[1] coefficient value. |
| 2115 | void setB1(MY_FLOAT b1); |
| 2116 | |
| 2117 | //! Set the zero position in the z-plane. |
| 2118 | /*! |
| 2119 | This method sets the zero position along the real-axis of the |
| 2120 | z-plane and normalizes the coefficients for a maximum gain of one. |
| 2121 | A positive zero value produces a high-pass filter, while a |
| 2122 | negative zero value produces a low-pass filter. This method does |
| 2123 | not affect the filter \e gain value. |
| 2124 | */ |
| 2125 | void setZero(MY_FLOAT theZero); |
| 2126 | |
| 2127 | //! Set the filter gain. |
| 2128 | /*! |
| 2129 | The gain is applied at the filter input and does not affect the |
| 2130 | coefficient values. The default gain value is 1.0. |
| 2131 | */ |
| 2132 | void setGain(MY_FLOAT theGain); |
| 2133 | |
| 2134 | //! Return the current filter gain. |
| 2135 | MY_FLOAT getGain(void) const; |
| 2136 | |
| 2137 | //! Return the last computed output value. |
| 2138 | MY_FLOAT lastOut(void) const; |
| 2139 | |
| 2140 | //! Input one sample to the filter and return one output. |
| 2141 | MY_FLOAT tick(MY_FLOAT sample); |
| 2142 | |
| 2143 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 2144 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 2145 | }; |
| 2146 | |
| 2147 | #endif |
| 2148 | |
| 2149 | |
| 2150 | |
| 2151 | |
| 2152 | /***************************************************/ |
| 2153 | /*! \class BlowHole |
| 2154 | \brief STK clarinet physical model with one register hole and one tonehole. |
| 2155 | |
| 2156 | This class is based on the clarinet model, |
| 2157 | with the addition of a two-port register hole |
| 2158 | and a three-port dynamic tonehole |
| 2159 | implementation, as discussed by Scavone and |
| 2160 | Cook (1998). |
| 2161 | |
| 2162 | In this implementation, the distances between |
| 2163 | the reed/register hole and tonehole/bell are |
| 2164 | fixed. As a result, both the tonehole and |
| 2165 | register hole will have variable influence on |
| 2166 | the playing frequency, which is dependent on |
| 2167 | the length of the air column. In addition, |
| 2168 | the highest playing freqeuency is limited by |
| 2169 | these fixed lengths. |
| 2170 | |
| 2171 | This is a digital waveguide model, making its |
| 2172 | use possibly subject to patents held by Stanford |
| 2173 | University, Yamaha, and others. |
| 2174 | |
| 2175 | Control Change Numbers: |
| 2176 | - Reed Stiffness = 2 |
| 2177 | - Noise Gain = 4 |
| 2178 | - Tonehole State = 11 |
| 2179 | - Register State = 1 |
| 2180 | - Breath Pressure = 128 |
| 2181 | |
| 2182 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2183 | */ |
| 2184 | /***************************************************/ |
| 2185 | |
| 2186 | #if !defined(__BLOWHOLE_H) |
| 2187 | #define __BLOWHOLE_H |
| 2188 | |
| 2189 | |
| 2190 | class BlowHole : public Instrmnt |
| 2191 | { |
| 2192 | public: |
| 2193 | //! Class constructor. |
| 2194 | BlowHole(MY_FLOAT lowestFrequency); |
| 2195 | |
| 2196 | //! Class destructor. |
| 2197 | ~BlowHole(); |
| 2198 | |
| 2199 | //! Reset and clear all internal state. |
| 2200 | void clear(); |
| 2201 | |
| 2202 | //! Set instrument parameters for a particular frequency. |
| 2203 | void setFrequency(MY_FLOAT frequency); |
| 2204 | |
| 2205 | //! Set the tonehole state (0.0 = closed, 1.0 = fully open). |
| 2206 | void setTonehole(MY_FLOAT newValue); |
| 2207 | |
| 2208 | //! Set the register hole state (0.0 = closed, 1.0 = fully open). |
| 2209 | void setVent(MY_FLOAT newValue); |
| 2210 | |
| 2211 | //! Apply breath velocity to instrument |
| 2212 | void startBlowing(MY_FLOAT amplitude) { startBlowing ( amplitude, m_rate ); } //chuck |
| 2213 | |
| 2214 | //! Apply breath pressure to instrument with given amplitude and rate of increase. |
| 2215 | void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate); |
| 2216 | |
| 2217 | //! Decrease breath pressure with given rate of decrease. |
| 2218 | void stopBlowing(MY_FLOAT rate); |
| 2219 | |
| 2220 | //! Start a note with the given frequency and amplitude. |
| 2221 | void noteOn( MY_FLOAT amplitude ) { noteOn ( m_frequency, amplitude ); } |
| 2222 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 2223 | |
| 2224 | //! Stop a note with the given amplitude (speed of decay). |
| 2225 | void noteOff(MY_FLOAT amplitude); |
| 2226 | |
| 2227 | //! Compute one output sample. |
| 2228 | MY_FLOAT tick(); |
| 2229 | |
| 2230 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 2231 | void controlChange(int number, MY_FLOAT value); |
| 2232 | |
| 2233 | public: // SWAP formerly protected |
| 2234 | |
| 2235 | // CHUCK |
| 2236 | t_CKFLOAT m_reed; |
| 2237 | t_CKFLOAT m_noiseGain; |
| 2238 | t_CKFLOAT m_tonehole; |
| 2239 | t_CKFLOAT m_vent; |
| 2240 | t_CKFLOAT m_pressure; |
| 2241 | t_CKFLOAT m_rate; |
| 2242 | |
| 2243 | DelayL *delays[3]; |
| 2244 | ReedTabl *reedTable; |
| 2245 | OneZero *filter; |
| 2246 | PoleZero *tonehole; |
| 2247 | PoleZero *vent; |
| 2248 | Envelope *envelope; |
| 2249 | Noise *noise; |
| 2250 | WaveLoop *vibrato; |
| 2251 | long length; |
| 2252 | MY_FLOAT scatter; |
| 2253 | MY_FLOAT th_coeff; |
| 2254 | MY_FLOAT r_th; |
| 2255 | MY_FLOAT rh_coeff; |
| 2256 | MY_FLOAT rh_gain; |
| 2257 | MY_FLOAT outputGain; |
| 2258 | MY_FLOAT noiseGain; |
| 2259 | MY_FLOAT vibratoGain; |
| 2260 | |
| 2261 | }; |
| 2262 | |
| 2263 | #endif |
| 2264 | |
| 2265 | |
| 2266 | |
| 2267 | |
| 2268 | /***************************************************/ |
| 2269 | /*! \class OnePole |
| 2270 | \brief STK one-pole filter class. |
| 2271 | |
| 2272 | This protected Filter subclass implements |
| 2273 | a one-pole digital filter. A method is |
| 2274 | provided for setting the pole position along |
| 2275 | the real axis of the z-plane while maintaining |
| 2276 | a constant peak filter gain. |
| 2277 | |
| 2278 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2279 | */ |
| 2280 | /***************************************************/ |
| 2281 | |
| 2282 | #if !defined(__ONEPOLE_H) |
| 2283 | #define __ONEPOLE_H |
| 2284 | |
| 2285 | class OnePole : public FilterStk // formerly protected Filter |
| 2286 | { |
| 2287 | public: |
| 2288 | |
| 2289 | //! Default constructor creates a first-order low-pass filter. |
| 2290 | OnePole(); |
| 2291 | |
| 2292 | //! Overloaded constructor which sets the pole position during instantiation. |
| 2293 | OnePole(MY_FLOAT thePole); |
| 2294 | |
| 2295 | //! Class destructor. |
| 2296 | ~OnePole(); |
| 2297 | |
| 2298 | //! Clears the internal state of the filter. |
| 2299 | void clear(void); |
| 2300 | |
| 2301 | //! Set the b[0] coefficient value. |
| 2302 | void setB0(MY_FLOAT b0); |
| 2303 | |
| 2304 | //! Set the a[1] coefficient value. |
| 2305 | void setA1(MY_FLOAT a1); |
| 2306 | |
| 2307 | //! Set the pole position in the z-plane. |
| 2308 | /*! |
| 2309 | This method sets the pole position along the real-axis of the |
| 2310 | z-plane and normalizes the coefficients for a maximum gain of one. |
| 2311 | A positive pole value produces a low-pass filter, while a negative |
| 2312 | pole value produces a high-pass filter. This method does not |
| 2313 | affect the filter \e gain value. |
| 2314 | */ |
| 2315 | void setPole(MY_FLOAT thePole); |
| 2316 | |
| 2317 | //! Set the filter gain. |
| 2318 | /*! |
| 2319 | The gain is applied at the filter input and does not affect the |
| 2320 | coefficient values. The default gain value is 1.0. |
| 2321 | */ |
| 2322 | void setGain(MY_FLOAT theGain); |
| 2323 | |
| 2324 | //! Return the current filter gain. |
| 2325 | MY_FLOAT getGain(void) const; |
| 2326 | |
| 2327 | //! Return the last computed output value. |
| 2328 | MY_FLOAT lastOut(void) const; |
| 2329 | |
| 2330 | //! Input one sample to the filter and return one output. |
| 2331 | MY_FLOAT tick(MY_FLOAT sample); |
| 2332 | |
| 2333 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 2334 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 2335 | }; |
| 2336 | |
| 2337 | #endif |
| 2338 | |
| 2339 | |
| 2340 | |
| 2341 | |
| 2342 | /***************************************************/ |
| 2343 | /*! \class Bowed |
| 2344 | \brief STK bowed string instrument class. |
| 2345 | |
| 2346 | This class implements a bowed string model, a |
| 2347 | la Smith (1986), after McIntyre, Schumacher, |
| 2348 | Woodhouse (1983). |
| 2349 | |
| 2350 | This is a digital waveguide model, making its |
| 2351 | use possibly subject to patents held by |
| 2352 | Stanford University, Yamaha, and others. |
| 2353 | |
| 2354 | Control Change Numbers: |
| 2355 | - Bow Pressure = 2 |
| 2356 | - Bow Position = 4 |
| 2357 | - Vibrato Frequency = 11 |
| 2358 | - Vibrato Gain = 1 |
| 2359 | - Volume = 128 |
| 2360 | |
| 2361 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2362 | */ |
| 2363 | /***************************************************/ |
| 2364 | |
| 2365 | #if !defined(__BOWED_H) |
| 2366 | #define __BOWED_H |
| 2367 | |
| 2368 | |
| 2369 | class Bowed : public Instrmnt |
| 2370 | { |
| 2371 | public: |
| 2372 | //! Class constructor, taking the lowest desired playing frequency. |
| 2373 | Bowed(MY_FLOAT lowestFrequency); |
| 2374 | |
| 2375 | //! Class destructor. |
| 2376 | ~Bowed(); |
| 2377 | |
| 2378 | //! Reset and clear all internal state. |
| 2379 | void clear(); |
| 2380 | |
| 2381 | //! Set instrument parameters for a particular frequency. |
| 2382 | void setFrequency(MY_FLOAT frequency); |
| 2383 | |
| 2384 | //! Set vibrato gain. |
| 2385 | void setVibrato(MY_FLOAT gain); |
| 2386 | |
| 2387 | void startBowing(MY_FLOAT amplitude) { startBowing(amplitude, m_rate ); } |
| 2388 | //! Apply breath pressure to instrument with given amplitude and rate of increase. |
| 2389 | void startBowing(MY_FLOAT amplitude, MY_FLOAT rate); |
| 2390 | |
| 2391 | //! Decrease breath pressure with given rate of decrease. |
| 2392 | void stopBowing(MY_FLOAT rate); |
| 2393 | |
| 2394 | void noteOn(MY_FLOAT amplitude) { noteOn ( m_frequency, amplitude ); } |
| 2395 | //! Start a note with the given frequency and amplitude. |
| 2396 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 2397 | |
| 2398 | //! Stop a note with the given amplitude (speed of decay). |
| 2399 | void noteOff(MY_FLOAT amplitude); |
| 2400 | |
| 2401 | //! Compute one output sample. |
| 2402 | MY_FLOAT tick(); |
| 2403 | |
| 2404 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 2405 | void controlChange(int number, MY_FLOAT value); |
| 2406 | |
| 2407 | public: // SWAP formerly protected |
| 2408 | |
| 2409 | // CHUCK |
| 2410 | t_CKFLOAT m_bowPressure; |
| 2411 | t_CKFLOAT m_bowPosition; |
| 2412 | t_CKFLOAT m_vibratoFreq; |
| 2413 | t_CKFLOAT m_vibratoGain; |
| 2414 | t_CKFLOAT m_volume; |
| 2415 | t_CKFLOAT m_rate; |
| 2416 | |
| 2417 | void setVibratoFreq(MY_FLOAT freq) |
| 2418 | { vibrato->setFrequency( freq ); m_vibratoFreq = vibrato->m_freq; } |
| 2419 | void setVibratoGain(MY_FLOAT gain) |
| 2420 | { vibratoGain = gain; m_vibratoGain = vibratoGain; } |
| 2421 | |
| 2422 | DelayL *neckDelay; |
| 2423 | DelayL *bridgeDelay; |
| 2424 | BowTabl *bowTable; |
| 2425 | OnePole *stringFilter; |
| 2426 | BiQuad *bodyFilter; |
| 2427 | WaveLoop *vibrato; |
| 2428 | ADSR *adsr; |
| 2429 | MY_FLOAT maxVelocity; |
| 2430 | MY_FLOAT baseDelay; |
| 2431 | MY_FLOAT vibratoGain; |
| 2432 | MY_FLOAT betaRatio; |
| 2433 | |
| 2434 | }; |
| 2435 | |
| 2436 | #endif |
| 2437 | |
| 2438 | |
| 2439 | |
| 2440 | |
| 2441 | /***************************************************/ |
| 2442 | /*! \class DelayA |
| 2443 | \brief STK allpass interpolating delay line class. |
| 2444 | |
| 2445 | This Delay subclass implements a fractional- |
| 2446 | length digital delay-line using a first-order |
| 2447 | allpass filter. A fixed maximum length |
| 2448 | of 4095 and a delay of 0.5 is set using the |
| 2449 | default constructor. Alternatively, the |
| 2450 | delay and maximum length can be set during |
| 2451 | instantiation with an overloaded constructor. |
| 2452 | |
| 2453 | An allpass filter has unity magnitude gain but |
| 2454 | variable phase delay properties, making it useful |
| 2455 | in achieving fractional delays without affecting |
| 2456 | a signal's frequency magnitude response. In |
| 2457 | order to achieve a maximally flat phase delay |
| 2458 | response, the minimum delay possible in this |
| 2459 | implementation is limited to a value of 0.5. |
| 2460 | |
| 2461 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2462 | */ |
| 2463 | /***************************************************/ |
| 2464 | |
| 2465 | #if !defined(__DelayA_h) |
| 2466 | #define __DelayA_h |
| 2467 | |
| 2468 | |
| 2469 | class DelayA : public DelayBase |
| 2470 | { |
| 2471 | public: |
| 2472 | |
| 2473 | //! Default constructor creates a delay-line with maximum length of 4095 samples and zero delay. |
| 2474 | DelayA(); |
| 2475 | |
| 2476 | //! Overloaded constructor which specifies the current and maximum delay-line lengths. |
| 2477 | |
| 2478 | DelayA(MY_FLOAT theDelay, long maxDelay); |
| 2479 | |
| 2480 | //! Class destructor. |
| 2481 | ~DelayA(); |
| 2482 | |
| 2483 | //! Clears the internal state of the delay line. |
| 2484 | void clear(); |
| 2485 | |
| 2486 | //! Set the delay-line length |
| 2487 | /*! |
| 2488 | The valid range for \e theDelay is from 0.5 to the maximum delay-line length. |
| 2489 | */ |
| 2490 | void setDelay(MY_FLOAT theDelay); |
| 2491 | void set( MY_FLOAT delay, long max ); |
| 2492 | |
| 2493 | //! Return the value which will be output by the next call to tick(). |
| 2494 | /*! |
| 2495 | This method is valid only for delay settings greater than zero! |
| 2496 | */ |
| 2497 | virtual MY_FLOAT nextOut(void); |
| 2498 | |
| 2499 | //! Input one sample to the delay-line and return one output. |
| 2500 | virtual MY_FLOAT tick(MY_FLOAT sample); |
| 2501 | |
| 2502 | public: // SWAP formerly protected |
| 2503 | MY_FLOAT alpha; |
| 2504 | MY_FLOAT coeff; |
| 2505 | MY_FLOAT apInput; |
| 2506 | MY_FLOAT nextOutput; |
| 2507 | bool doNextOut; |
| 2508 | }; |
| 2509 | |
| 2510 | #endif |
| 2511 | |
| 2512 | |
| 2513 | |
| 2514 | |
| 2515 | /***************************************************/ |
| 2516 | /*! \class Brass |
| 2517 | \brief STK simple brass instrument class. |
| 2518 | |
| 2519 | This class implements a simple brass instrument |
| 2520 | waveguide model, a la Cook (TBone, HosePlayer). |
| 2521 | |
| 2522 | This is a digital waveguide model, making its |
| 2523 | use possibly subject to patents held by |
| 2524 | Stanford University, Yamaha, and others. |
| 2525 | |
| 2526 | Control Change Numbers: |
| 2527 | - Lip Tension = 2 |
| 2528 | - Slide Length = 4 |
| 2529 | - Vibrato Frequency = 11 |
| 2530 | - Vibrato Gain = 1 |
| 2531 | - Volume = 128 |
| 2532 | |
| 2533 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2534 | */ |
| 2535 | /***************************************************/ |
| 2536 | |
| 2537 | #if !defined(__BRASS_H) |
| 2538 | #define __BRASS_H |
| 2539 | |
| 2540 | |
| 2541 | class Brass: public Instrmnt |
| 2542 | { |
| 2543 | public: |
| 2544 | //! Class constructor, taking the lowest desired playing frequency. |
| 2545 | Brass(MY_FLOAT lowestFrequency); |
| 2546 | |
| 2547 | //! Class destructor. |
| 2548 | ~Brass(); |
| 2549 | |
| 2550 | //! Reset and clear all internal state. |
| 2551 | void clear(); |
| 2552 | |
| 2553 | //! Set instrument parameters for a particular frequency. |
| 2554 | void setFrequency(MY_FLOAT frequency); |
| 2555 | |
| 2556 | //! Set the lips frequency. |
| 2557 | void setLip(MY_FLOAT frequency); |
| 2558 | |
| 2559 | //! Apply breath pressure to instrument with given amplitude and rate of increase. |
| 2560 | void startBlowing(MY_FLOAT amplitude,MY_FLOAT rate); |
| 2561 | |
| 2562 | //! Decrease breath pressure with given rate of decrease. |
| 2563 | void stopBlowing(MY_FLOAT rate); |
| 2564 | |
| 2565 | //! Start a note with the given frequency and amplitude. |
| 2566 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 2567 | |
| 2568 | //! Stop a note with the given amplitude (speed of decay). |
| 2569 | void noteOff(MY_FLOAT amplitude); |
| 2570 | |
| 2571 | //! Compute one output sample. |
| 2572 | MY_FLOAT tick(); |
| 2573 | |
| 2574 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 2575 | void controlChange(int number, MY_FLOAT value); |
| 2576 | |
| 2577 | public: // SWAP formerly protected |
| 2578 | |
| 2579 | // CHUCK |
| 2580 | t_CKFLOAT m_rate; |
| 2581 | t_CKFLOAT m_lip; |
| 2582 | t_CKFLOAT m_slide; |
| 2583 | t_CKFLOAT m_vibratoFreq; |
| 2584 | t_CKFLOAT m_vibratoGain; |
| 2585 | t_CKFLOAT m_volume; |
| 2586 | |
| 2587 | void setVibratoFreq(MY_FLOAT freq) |
| 2588 | { vibrato->setFrequency( freq ); m_vibratoFreq = vibrato->m_freq; } |
| 2589 | void setVibratoGain(MY_FLOAT gain) |
| 2590 | { vibratoGain = gain; m_vibratoGain = vibratoGain; } |
| 2591 | |
| 2592 | DelayA *delayLine; |
| 2593 | BiQuad *lipFilter; |
| 2594 | PoleZero *dcBlock; |
| 2595 | ADSR *adsr; |
| 2596 | WaveLoop *vibrato; |
| 2597 | long length; |
| 2598 | MY_FLOAT lipTarget; |
| 2599 | MY_FLOAT slideTarget; |
| 2600 | MY_FLOAT vibratoGain; |
| 2601 | MY_FLOAT maxPressure; |
| 2602 | }; |
| 2603 | |
| 2604 | #endif |
| 2605 | |
| 2606 | |
| 2607 | |
| 2608 | |
| 2609 | /***************************************************/ |
| 2610 | /*! \class Chorus |
| 2611 | \brief STK chorus effect class. |
| 2612 | |
| 2613 | This class implements a chorus effect. |
| 2614 | |
| 2615 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2616 | */ |
| 2617 | /***************************************************/ |
| 2618 | |
| 2619 | #if !defined(__CHORUS_H) |
| 2620 | #define __CHORUS_H |
| 2621 | |
| 2622 | |
| 2623 | class Chorus : public Stk |
| 2624 | { |
| 2625 | public: |
| 2626 | //! Class constructor, taking the longest desired delay length. |
| 2627 | Chorus(MY_FLOAT baseDelay); |
| 2628 | |
| 2629 | //! Class destructor. |
| 2630 | ~Chorus(); |
| 2631 | |
| 2632 | //! Set baseDelay and modDepth |
| 2633 | void set(MY_FLOAT baseDelay, MY_FLOAT depth); |
| 2634 | |
| 2635 | //! Reset and clear all internal state. |
| 2636 | void clear(); |
| 2637 | |
| 2638 | //! Set base delay |
| 2639 | void setDelay(MY_FLOAT baseDelay); // chuck |
| 2640 | |
| 2641 | //! Set modulation depth. |
| 2642 | void setModDepth(MY_FLOAT depth); |
| 2643 | |
| 2644 | //! Set modulation frequency. |
| 2645 | void setModFrequency(MY_FLOAT frequency); |
| 2646 | |
| 2647 | //! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only). |
| 2648 | void setEffectMix(MY_FLOAT mix); |
| 2649 | |
| 2650 | //! Return the last output value. |
| 2651 | MY_FLOAT lastOut() const; |
| 2652 | |
| 2653 | //! Return the last left output value. |
| 2654 | MY_FLOAT lastOutLeft() const; |
| 2655 | |
| 2656 | //! Return the last right output value. |
| 2657 | MY_FLOAT lastOutRight() const; |
| 2658 | |
| 2659 | //! Compute one output sample. |
| 2660 | MY_FLOAT tick(MY_FLOAT input); |
| 2661 | |
| 2662 | //! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector. |
| 2663 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 2664 | |
| 2665 | public: // SWAP formerly protected |
| 2666 | DelayL *delayLine[2]; |
| 2667 | WaveLoop *mods[2]; |
| 2668 | MY_FLOAT baseLength; |
| 2669 | MY_FLOAT modDepth; |
| 2670 | MY_FLOAT lastOutput[2]; |
| 2671 | MY_FLOAT effectMix; |
| 2672 | |
| 2673 | }; |
| 2674 | |
| 2675 | #endif |
| 2676 | |
| 2677 | |
| 2678 | |
| 2679 | |
| 2680 | |
| 2681 | /***************************************************/ |
| 2682 | /*! \class Clarinet |
| 2683 | \brief STK clarinet physical model class. |
| 2684 | |
| 2685 | This class implements a simple clarinet |
| 2686 | physical model, as discussed by Smith (1986), |
| 2687 | McIntyre, Schumacher, Woodhouse (1983), and |
| 2688 | others. |
| 2689 | |
| 2690 | This is a digital waveguide model, making its |
| 2691 | use possibly subject to patents held by Stanford |
| 2692 | University, Yamaha, and others. |
| 2693 | |
| 2694 | Control Change Numbers: |
| 2695 | - Reed Stiffness = 2 |
| 2696 | - Noise Gain = 4 |
| 2697 | - Vibrato Frequency = 11 |
| 2698 | - Vibrato Gain = 1 |
| 2699 | - Breath Pressure = 128 |
| 2700 | |
| 2701 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2702 | */ |
| 2703 | /***************************************************/ |
| 2704 | |
| 2705 | #if !defined(__CLARINET_H) |
| 2706 | #define __CLARINET_H |
| 2707 | |
| 2708 | |
| 2709 | class Clarinet : public Instrmnt |
| 2710 | { |
| 2711 | public: |
| 2712 | //! Class constructor, taking the lowest desired playing frequency. |
| 2713 | Clarinet(MY_FLOAT lowestFrequency); |
| 2714 | |
| 2715 | //! Class destructor. |
| 2716 | ~Clarinet(); |
| 2717 | |
| 2718 | //! Reset and clear all internal state. |
| 2719 | void clear(); |
| 2720 | |
| 2721 | //! Set instrument parameters for a particular frequency. |
| 2722 | void setFrequency(MY_FLOAT frequency); |
| 2723 | |
| 2724 | //! Apply breath pressure to instrument with given amplitude and rate of increase. |
| 2725 | void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate); |
| 2726 | |
| 2727 | //! Decrease breath pressure with given rate of decrease. |
| 2728 | void stopBlowing(MY_FLOAT rate); |
| 2729 | |
| 2730 | //! Start a note with the given frequency and amplitude. |
| 2731 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 2732 | |
| 2733 | //! Stop a note with the given amplitude (speed of decay). |
| 2734 | void noteOff(MY_FLOAT amplitude); |
| 2735 | |
| 2736 | //! Compute one output sample. |
| 2737 | MY_FLOAT tick(); |
| 2738 | |
| 2739 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 2740 | void controlChange(int number, MY_FLOAT value); |
| 2741 | |
| 2742 | public: // SWAP formerly protected |
| 2743 | |
| 2744 | // CHUCK |
| 2745 | t_CKFLOAT m_reed; |
| 2746 | t_CKFLOAT m_noiseGain; |
| 2747 | t_CKFLOAT m_vibratoFreq; |
| 2748 | t_CKFLOAT m_vibratoGain; |
| 2749 | t_CKFLOAT m_volume; |
| 2750 | t_CKFLOAT m_rate; |
| 2751 | |
| 2752 | void setVibratoFreq(MY_FLOAT freq) |
| 2753 | { vibrato->setFrequency( freq ); m_vibratoFreq = vibrato->m_freq; } |
| 2754 | void setVibratoGain(MY_FLOAT gain) |
| 2755 | { vibratoGain = gain; m_vibratoGain = vibratoGain; } |
| 2756 | void setNoiseGain(MY_FLOAT gain) |
| 2757 | { noiseGain = gain; m_noiseGain = gain; } |
| 2758 | |
| 2759 | DelayL *delayLine; |
| 2760 | ReedTabl *reedTable; |
| 2761 | OneZero *filter; |
| 2762 | Envelope *envelope; |
| 2763 | Noise *noise; |
| 2764 | WaveLoop *vibrato; |
| 2765 | long length; |
| 2766 | MY_FLOAT outputGain; |
| 2767 | MY_FLOAT noiseGain; |
| 2768 | MY_FLOAT vibratoGain; |
| 2769 | |
| 2770 | }; |
| 2771 | |
| 2772 | #endif |
| 2773 | |
| 2774 | |
| 2775 | |
| 2776 | |
| 2777 | /***************************************************/ |
| 2778 | /*! \class Drummer |
| 2779 | \brief STK drum sample player class. |
| 2780 | |
| 2781 | This class implements a drum sampling |
| 2782 | synthesizer using WvIn objects and one-pole |
| 2783 | filters. The drum rawwave files are sampled |
| 2784 | at 22050 Hz, but will be appropriately |
| 2785 | interpolated for other sample rates. You can |
| 2786 | specify the maximum polyphony (maximum number |
| 2787 | of simultaneous voices) via a #define in the |
| 2788 | Drummer.h. |
| 2789 | |
| 2790 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2791 | */ |
| 2792 | /***************************************************/ |
| 2793 | |
| 2794 | #if !defined(__DRUMMER_H) |
| 2795 | #define __DRUMMER_H |
| 2796 | |
| 2797 | |
| 2798 | #define DRUM_NUMWAVES 11 |
| 2799 | #define DRUM_POLYPHONY 4 |
| 2800 | |
| 2801 | class Drummer : public Instrmnt |
| 2802 | { |
| 2803 | public: |
| 2804 | //! Class constructor. |
| 2805 | Drummer(); |
| 2806 | |
| 2807 | //! Class destructor. |
| 2808 | ~Drummer(); |
| 2809 | |
| 2810 | //! Start a note with the given drum type and amplitude. |
| 2811 | /*! |
| 2812 | Use general MIDI drum instrument numbers, converted to |
| 2813 | frequency values as if MIDI note numbers, to select a |
| 2814 | particular instrument. |
| 2815 | */ |
| 2816 | void noteOn(MY_FLOAT instrument, MY_FLOAT amplitude); |
| 2817 | |
| 2818 | //! Stop a note with the given amplitude (speed of decay). |
| 2819 | void noteOff(MY_FLOAT amplitude); |
| 2820 | |
| 2821 | //! Compute one output sample. |
| 2822 | MY_FLOAT tick(); |
| 2823 | |
| 2824 | public: // SWAP formerly protected |
| 2825 | WvIn *waves[DRUM_POLYPHONY]; |
| 2826 | OnePole *filters[DRUM_POLYPHONY]; |
| 2827 | int sounding[DRUM_POLYPHONY]; |
| 2828 | int nSounding; |
| 2829 | |
| 2830 | }; |
| 2831 | |
| 2832 | #endif |
| 2833 | |
| 2834 | |
| 2835 | |
| 2836 | |
| 2837 | /***************************************************/ |
| 2838 | /*! \class Echo |
| 2839 | \brief STK echo effect class. |
| 2840 | |
| 2841 | This class implements a echo effect. |
| 2842 | |
| 2843 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2844 | */ |
| 2845 | /***************************************************/ |
| 2846 | |
| 2847 | #if !defined(__ECHO_H) |
| 2848 | #define __ECHO_H |
| 2849 | |
| 2850 | |
| 2851 | class Echo : public Stk |
| 2852 | { |
| 2853 | public: |
| 2854 | //! Class constructor, taking the longest desired delay length. |
| 2855 | Echo(MY_FLOAT longestDelay); |
| 2856 | |
| 2857 | //! Class destructor. |
| 2858 | ~Echo(); |
| 2859 | |
| 2860 | //! Reset and clear all internal state. |
| 2861 | void clear(); |
| 2862 | |
| 2863 | //! Set the delay line length in samples. |
| 2864 | void setDelay(MY_FLOAT delay); |
| 2865 | void set(MY_FLOAT max); |
| 2866 | MY_FLOAT getDelay(); |
| 2867 | |
| 2868 | //! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only). |
| 2869 | void setEffectMix(MY_FLOAT mix); |
| 2870 | |
| 2871 | //! Return the last output value. |
| 2872 | MY_FLOAT lastOut() const; |
| 2873 | |
| 2874 | //! Compute one output sample. |
| 2875 | MY_FLOAT tick(MY_FLOAT input); |
| 2876 | |
| 2877 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 2878 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 2879 | |
| 2880 | public: |
| 2881 | DelayBase *delayLine; |
| 2882 | long length; |
| 2883 | MY_FLOAT lastOutput; |
| 2884 | MY_FLOAT effectMix; |
| 2885 | |
| 2886 | }; |
| 2887 | |
| 2888 | #endif |
| 2889 | |
| 2890 | |
| 2891 | |
| 2892 | |
| 2893 | |
| 2894 | /***************************************************/ |
| 2895 | /*! \class FMVoices |
| 2896 | \brief STK singing FM synthesis instrument. |
| 2897 | |
| 2898 | This class implements 3 carriers and a common |
| 2899 | modulator, also referred to as algorithm 6 of |
| 2900 | the TX81Z. |
| 2901 | |
| 2902 | \code |
| 2903 | Algorithm 6 is : |
| 2904 | /->1 -\ |
| 2905 | 4-|-->2 - +-> Out |
| 2906 | \->3 -/ |
| 2907 | \endcode |
| 2908 | |
| 2909 | Control Change Numbers: |
| 2910 | - Vowel = 2 |
| 2911 | - Spectral Tilt = 4 |
| 2912 | - LFO Speed = 11 |
| 2913 | - LFO Depth = 1 |
| 2914 | - ADSR 2 & 4 Target = 128 |
| 2915 | |
| 2916 | The basic Chowning/Stanford FM patent expired |
| 2917 | in 1995, but there exist follow-on patents, |
| 2918 | mostly assigned to Yamaha. If you are of the |
| 2919 | type who should worry about this (making |
| 2920 | money) worry away. |
| 2921 | |
| 2922 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2923 | */ |
| 2924 | /***************************************************/ |
| 2925 | |
| 2926 | #if !defined(__FMVOICES_H) |
| 2927 | #define __FMVOICES_H |
| 2928 | |
| 2929 | |
| 2930 | class FMVoices : public FM |
| 2931 | { |
| 2932 | public: |
| 2933 | //! Class constructor. |
| 2934 | FMVoices(); |
| 2935 | |
| 2936 | //! Class destructor. |
| 2937 | ~FMVoices(); |
| 2938 | |
| 2939 | //! Set instrument parameters for a particular frequency. |
| 2940 | virtual void setFrequency(MY_FLOAT frequency); |
| 2941 | |
| 2942 | //! Start a note with the given frequency and amplitude. |
| 2943 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 2944 | void noteOn( MY_FLOAT amplitude) { noteOn(baseFrequency, amplitude); } |
| 2945 | |
| 2946 | //! Compute one output sample. |
| 2947 | MY_FLOAT tick(); |
| 2948 | |
| 2949 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 2950 | virtual void controlChange(int number, MY_FLOAT value); |
| 2951 | |
| 2952 | public: // SWAP formerly protected |
| 2953 | int currentVowel; |
| 2954 | MY_FLOAT tilt[3]; |
| 2955 | MY_FLOAT mods[3]; |
| 2956 | }; |
| 2957 | |
| 2958 | #endif |
| 2959 | |
| 2960 | |
| 2961 | |
| 2962 | |
| 2963 | /***************************************************/ |
| 2964 | /*! \class Flute |
| 2965 | \brief STK flute physical model class. |
| 2966 | |
| 2967 | This class implements a simple flute |
| 2968 | physical model, as discussed by Karjalainen, |
| 2969 | Smith, Waryznyk, etc. The jet model uses |
| 2970 | a polynomial, a la Cook. |
| 2971 | |
| 2972 | This is a digital waveguide model, making its |
| 2973 | use possibly subject to patents held by Stanford |
| 2974 | University, Yamaha, and others. |
| 2975 | |
| 2976 | Control Change Numbers: |
| 2977 | - Jet Delay = 2 |
| 2978 | - Noise Gain = 4 |
| 2979 | - Vibrato Frequency = 11 |
| 2980 | - Vibrato Gain = 1 |
| 2981 | - Breath Pressure = 128 |
| 2982 | |
| 2983 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 2984 | */ |
| 2985 | /***************************************************/ |
| 2986 | |
| 2987 | #if !defined(__FLUTE_H) |
| 2988 | #define __FLUTE_H |
| 2989 | |
| 2990 | |
| 2991 | class Flute : public Instrmnt |
| 2992 | { |
| 2993 | public: |
| 2994 | //! Class constructor, taking the lowest desired playing frequency. |
| 2995 | Flute(MY_FLOAT lowestFrequency); |
| 2996 | |
| 2997 | //! Class destructor. |
| 2998 | ~Flute(); |
| 2999 | |
| 3000 | //! Reset and clear all internal state. |
| 3001 | void clear(); |
| 3002 | |
| 3003 | //! Set instrument parameters for a particular frequency. |
| 3004 | void setFrequency(MY_FLOAT frequency); |
| 3005 | |
| 3006 | //! Set the reflection coefficient for the jet delay (-1.0 - 1.0). |
| 3007 | void setJetReflection(MY_FLOAT coefficient); |
| 3008 | |
| 3009 | //! Set the reflection coefficient for the air column delay (-1.0 - 1.0). |
| 3010 | void setEndReflection(MY_FLOAT coefficient); |
| 3011 | |
| 3012 | //! Set the length of the jet delay in terms of a ratio of jet delay to air column delay lengths. |
| 3013 | void setJetDelay(MY_FLOAT aRatio); |
| 3014 | |
| 3015 | //! Apply breath velocity to instrument with given amplitude and rate of increase. |
| 3016 | void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate); |
| 3017 | |
| 3018 | //! Decrease breath velocity with given rate of decrease. |
| 3019 | void stopBlowing(MY_FLOAT rate); |
| 3020 | |
| 3021 | //! Start a note with the given frequency and amplitude. |
| 3022 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 3023 | |
| 3024 | //! Stop a note with the given amplitude (speed of decay). |
| 3025 | void noteOff(MY_FLOAT amplitude); |
| 3026 | |
| 3027 | //! Compute one output sample. |
| 3028 | MY_FLOAT tick(); |
| 3029 | |
| 3030 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 3031 | void controlChange(int number, MY_FLOAT value); |
| 3032 | |
| 3033 | public: // SWAP formerly protected |
| 3034 | |
| 3035 | // CHUCK |
| 3036 | t_CKFLOAT m_jetDelay; |
| 3037 | t_CKFLOAT m_jetReflection; |
| 3038 | t_CKFLOAT m_endReflection; |
| 3039 | t_CKFLOAT m_noiseGain; |
| 3040 | t_CKFLOAT m_vibratoFreq; |
| 3041 | t_CKFLOAT m_vibratoGain; |
| 3042 | t_CKFLOAT m_pressure; |
| 3043 | t_CKFLOAT m_rate; |
| 3044 | |
| 3045 | void setVibratoFreq(MY_FLOAT freq) |
| 3046 | { vibrato->setFrequency( freq ); m_vibratoFreq = vibrato->m_freq; } |
| 3047 | void setVibratoGain(MY_FLOAT gain) |
| 3048 | { vibratoGain = gain; m_vibratoGain = vibratoGain; } |
| 3049 | void setNoiseGain(MY_FLOAT gain) |
| 3050 | { noiseGain = gain; m_noiseGain = gain; } |
| 3051 | |
| 3052 | DelayL *jetDelay; |
| 3053 | DelayL *boreDelay; |
| 3054 | JetTabl *jetTable; |
| 3055 | OnePole *filter; |
| 3056 | PoleZero *dcBlock; |
| 3057 | Noise *noise; |
| 3058 | ADSR *adsr; |
| 3059 | WaveLoop *vibrato; |
| 3060 | long length; |
| 3061 | MY_FLOAT lastFrequency; |
| 3062 | MY_FLOAT maxPressure; |
| 3063 | MY_FLOAT jetReflection; |
| 3064 | MY_FLOAT endReflection; |
| 3065 | MY_FLOAT noiseGain; |
| 3066 | MY_FLOAT vibratoGain; |
| 3067 | MY_FLOAT outputGain; |
| 3068 | MY_FLOAT jetRatio; |
| 3069 | |
| 3070 | }; |
| 3071 | |
| 3072 | #endif |
| 3073 | |
| 3074 | |
| 3075 | |
| 3076 | |
| 3077 | /***************************************************/ |
| 3078 | /*! \class FormSwep |
| 3079 | \brief STK sweepable formant filter class. |
| 3080 | |
| 3081 | This public BiQuad filter subclass implements |
| 3082 | a formant (resonance) which can be "swept" |
| 3083 | over time from one frequency setting to another. |
| 3084 | It provides methods for controlling the sweep |
| 3085 | rate and target frequency. |
| 3086 | |
| 3087 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 3088 | */ |
| 3089 | /***************************************************/ |
| 3090 | |
| 3091 | #if !defined(__FORMSWEP_H) |
| 3092 | #define __FORMSWEP_H |
| 3093 | |
| 3094 | |
| 3095 | class FormSwep : public BiQuad |
| 3096 | { |
| 3097 | public: |
| 3098 | |
| 3099 | //! Default constructor creates a second-order pass-through filter. |
| 3100 | FormSwep(); |
| 3101 | |
| 3102 | //! Class destructor. |
| 3103 | ~FormSwep(); |
| 3104 | |
| 3105 | //! Sets the filter coefficients for a resonance at \e frequency (in Hz). |
| 3106 | /*! |
| 3107 | This method determines the filter coefficients corresponding to |
| 3108 | two complex-conjugate poles with the given \e frequency (in Hz) |
| 3109 | and \e radius from the z-plane origin. The filter zeros are |
| 3110 | placed at z = 1, z = -1, and the coefficients are then normalized to |
| 3111 | produce a constant unity gain (independent of the filter \e gain |
| 3112 | parameter). The resulting filter frequency response has a |
| 3113 | resonance at the given \e frequency. The closer the poles are to |
| 3114 | the unit-circle (\e radius close to one), the narrower the |
| 3115 | resulting resonance width. |
| 3116 | */ |
| 3117 | void setResonance(MY_FLOAT aFrequency, MY_FLOAT aRadius); |
| 3118 | |
| 3119 | //! Set both the current and target resonance parameters. |
| 3120 | void setStates(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain = 1.0); |
| 3121 | |
| 3122 | //! Set target resonance parameters. |
| 3123 | void setTargets(MY_FLOAT aFrequency, MY_FLOAT aRadius, MY_FLOAT aGain = 1.0); |
| 3124 | |
| 3125 | //! Set the sweep rate (between 0.0 - 1.0). |
| 3126 | /*! |
| 3127 | The formant parameters are varied in increments of the |
| 3128 | sweep rate between their current and target values. |
| 3129 | A sweep rate of 1.0 will produce an immediate change in |
| 3130 | resonance parameters from their current values to the |
| 3131 | target values. A sweep rate of 0.0 will produce no |
| 3132 | change in resonance parameters. |
| 3133 | */ |
| 3134 | void setSweepRate(MY_FLOAT aRate); |
| 3135 | |
| 3136 | //! Set the sweep rate in terms of a time value in seconds. |
| 3137 | /*! |
| 3138 | This method adjusts the sweep rate based on a |
| 3139 | given time for the formant parameters to reach |
| 3140 | their target values. |
| 3141 | */ |
| 3142 | void setSweepTime(MY_FLOAT aTime); |
| 3143 | |
| 3144 | //! Input one sample to the filter and return one output. |
| 3145 | MY_FLOAT tick(MY_FLOAT sample); |
| 3146 | |
| 3147 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 3148 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 3149 | |
| 3150 | public: // SWAP formerly protected |
| 3151 | bool dirty; |
| 3152 | MY_FLOAT frequency; |
| 3153 | MY_FLOAT radius; |
| 3154 | MY_FLOAT startFrequency; |
| 3155 | MY_FLOAT startRadius; |
| 3156 | MY_FLOAT startGain; |
| 3157 | MY_FLOAT targetFrequency; |
| 3158 | MY_FLOAT targetRadius; |
| 3159 | MY_FLOAT targetGain; |
| 3160 | MY_FLOAT deltaFrequency; |
| 3161 | MY_FLOAT deltaRadius; |
| 3162 | MY_FLOAT deltaGain; |
| 3163 | MY_FLOAT sweepState; |
| 3164 | MY_FLOAT sweepRate; |
| 3165 | |
| 3166 | }; |
| 3167 | |
| 3168 | #endif |
| 3169 | |
| 3170 | |
| 3171 | |
| 3172 | |
| 3173 | /***************************************************/ |
| 3174 | /*! \class HevyMetl |
| 3175 | \brief STK heavy metal FM synthesis instrument. |
| 3176 | |
| 3177 | This class implements 3 cascade operators with |
| 3178 | feedback modulation, also referred to as |
| 3179 | algorithm 3 of the TX81Z. |
| 3180 | |
| 3181 | \code |
| 3182 | Algorithm 3 is : 4--\ |
| 3183 | 3-->2-- + -->1-->Out |
| 3184 | \endcode |
| 3185 | |
| 3186 | Control Change Numbers: |
| 3187 | - Total Modulator Index = 2 |
| 3188 | - Modulator Crossfade = 4 |
| 3189 | - LFO Speed = 11 |
| 3190 | - LFO Depth = 1 |
| 3191 | - ADSR 2 & 4 Target = 128 |
| 3192 | |
| 3193 | The basic Chowning/Stanford FM patent expired |
| 3194 | in 1995, but there exist follow-on patents, |
| 3195 | mostly assigned to Yamaha. If you are of the |
| 3196 | type who should worry about this (making |
| 3197 | money) worry away. |
| 3198 | |
| 3199 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 3200 | */ |
| 3201 | /***************************************************/ |
| 3202 | |
| 3203 | #if !defined(__HEVYMETL_H) |
| 3204 | #define __HEVYMETL_H |
| 3205 | |
| 3206 | |
| 3207 | class HevyMetl : public FM |
| 3208 | { |
| 3209 | public: |
| 3210 | //! Class constructor. |
| 3211 | HevyMetl(); |
| 3212 | |
| 3213 | //! Class destructor. |
| 3214 | ~HevyMetl(); |
| 3215 | |
| 3216 | //! Start a note with the given frequency and amplitude. |
| 3217 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 3218 | void noteOn( MY_FLOAT amplitude) { noteOn(baseFrequency, amplitude); } |
| 3219 | |
| 3220 | //! Compute one output sample. |
| 3221 | MY_FLOAT tick(); |
| 3222 | }; |
| 3223 | |
| 3224 | #endif |
| 3225 | |
| 3226 | |
| 3227 | |
| 3228 | |
| 3229 | /***** 1.4.1.0 REPAIRATHON2021 BRAND NEW FM ALGORITHMS!!! *****/ |
| 3230 | |
| 3231 | /***************************************************/ |
| 3232 | /*! \class HnkyTonk |
| 3233 | \brief STK Honkey Tonk Piano FM synthesis instrument. |
| 3234 | |
| 3235 | This class implements 4 cascade operators with |
| 3236 | feedback modulation on the master modulator, |
| 3237 | also referred to as algorithm 1 of the TX81Z. |
| 3238 | |
| 3239 | Algorithm 1 is : |
| 3240 | 4-->3-->2-->1-->Out |
| 3241 | |
| 3242 | Control Change Numbers: |
| 3243 | - Total Modulator Index = 2 |
| 3244 | - Modulator Crossfade = 4 |
| 3245 | - LFO Speed = 11 |
| 3246 | - LFO Depth = 1 |
| 3247 | - ADSR 2 & 4 Target = 128 |
| 3248 | |
| 3249 | The basic Chowning/Stanford FM patent expired |
| 3250 | in 1995, but there exist follow-on patents, |
| 3251 | mostly assigned to Yamaha. If you are of the |
| 3252 | type who should worry about this (making |
| 3253 | money) worry away. |
| 3254 | |
| 3255 | by Perry R. Cook, 2021. |
| 3256 | */ |
| 3257 | /***************************************************/ |
| 3258 | |
| 3259 | #if !defined(__HNKYTONK_H) |
| 3260 | #define __HNKYTONK_H |
| 3261 | |
| 3262 | class HnkyTonk : public FM |
| 3263 | { |
| 3264 | public: |
| 3265 | //! Class constructor. |
| 3266 | HnkyTonk(); |
| 3267 | |
| 3268 | //! Class destructor. |
| 3269 | ~HnkyTonk(); |
| 3270 | |
| 3271 | //! Start a note with the given frequency and amplitude. |
| 3272 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 3273 | void noteOn( MY_FLOAT amplitude) { noteOn(baseFrequency, amplitude); } |
| 3274 | |
| 3275 | //! Compute one output sample. |
| 3276 | MY_FLOAT tick(); |
| 3277 | }; |
| 3278 | |
| 3279 | #endif |
| 3280 | |
| 3281 | /***** 1.4.1.0 REPAIRATHON2021 BRAND NEW FM ALGORITHMS!!! *****/ |
| 3282 | |
| 3283 | /***************************************************/ |
| 3284 | /*! \class FrencHrn |
| 3285 | \brief NEW STK-style French Horn FM synthesis instrument. |
| 3286 | |
| 3287 | This class implements 3 cascade operators with |
| 3288 | feedback modulation, also referred to as |
| 3289 | algorithm 3 of the TX81Z. |
| 3290 | |
| 3291 | Algorithm 3 is : 4--\ |
| 3292 | 3-->2-- + -->1-->Out |
| 3293 | |
| 3294 | Control Change Numbers: |
| 3295 | - Total Modulator Index = 2 |
| 3296 | - Modulator Crossfade = 4 |
| 3297 | - LFO Speed = 11 |
| 3298 | - LFO Depth = 1 |
| 3299 | - ADSR 2 & 4 Target = 128 |
| 3300 | |
| 3301 | The basic Chowning/Stanford FM patent expired |
| 3302 | in 1995, but there exist follow-on patents, |
| 3303 | mostly assigned to Yamaha. If you are of the |
| 3304 | type who should worry about this (making |
| 3305 | money) worry away. |
| 3306 | |
| 3307 | by Perry R. Cook, 2021. |
| 3308 | */ |
| 3309 | /***************************************************/ |
| 3310 | |
| 3311 | #if !defined(__FRENCHRN_H) |
| 3312 | #define __FRENCHRN_H |
| 3313 | |
| 3314 | class FrencHrn : public FM |
| 3315 | { |
| 3316 | public: |
| 3317 | //! Class constructor. |
| 3318 | FrencHrn(); |
| 3319 | |
| 3320 | //! Class destructor. |
| 3321 | ~FrencHrn(); |
| 3322 | |
| 3323 | //! Start a note with the given frequency and amplitude. |
| 3324 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 3325 | void noteOn( MY_FLOAT amplitude) { noteOn(baseFrequency, amplitude); } |
| 3326 | |
| 3327 | //! Compute one output sample. |
| 3328 | MY_FLOAT tick(); |
| 3329 | }; |
| 3330 | |
| 3331 | #endif |
| 3332 | |
| 3333 | |
| 3334 | /***** 1.4.1.0 REPAIRATHON2021 BRAND NEW FM ALGORITHMS!!! *****/ |
| 3335 | |
| 3336 | /***************************************************/ |
| 3337 | /*! \class KrstlChr |
| 3338 | \brief New STK-style Crystal Choir FM synthesis instrument. |
| 3339 | |
| 3340 | This class implements 3 parallel operators with |
| 3341 | one modulated, by one with feedback modulation, |
| 3342 | also referred to as algorithm 7 of the TX81Z. |
| 3343 | |
| 3344 | Algorithm 3 is : 4-->3-->\ |
| 3345 | 2--> + -->Out |
| 3346 | 1-->/ |
| 3347 | |
| 3348 | Control Change Numbers: |
| 3349 | - Total Modulator Index = 2 |
| 3350 | - Modulator Crossfade = 4 |
| 3351 | - LFO Speed = 11 |
| 3352 | - LFO Depth = 1 |
| 3353 | - ADSR 2 & 4 Target = 128 |
| 3354 | |
| 3355 | The basic Chowning/Stanford FM patent expired |
| 3356 | in 1995, but there exist follow-on patents, |
| 3357 | mostly assigned to Yamaha. If you are of the |
| 3358 | type who should worry about this (making |
| 3359 | money) worry away. |
| 3360 | |
| 3361 | by Perry R. Cook, 2021. |
| 3362 | */ |
| 3363 | /***************************************************/ |
| 3364 | |
| 3365 | #if !defined(__KRSTLCHR_H) |
| 3366 | #define __KRSTLCHR_H |
| 3367 | |
| 3368 | class KrstlChr : public FM |
| 3369 | { |
| 3370 | public: |
| 3371 | //! Class constructor. |
| 3372 | KrstlChr(); |
| 3373 | |
| 3374 | //! Class destructor. |
| 3375 | ~KrstlChr(); |
| 3376 | |
| 3377 | //! Start a note with the given frequency and amplitude. |
| 3378 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 3379 | void noteOn( MY_FLOAT amplitude) { noteOn(baseFrequency, amplitude); } |
| 3380 | |
| 3381 | //! Compute one output sample. |
| 3382 | MY_FLOAT tick(); |
| 3383 | }; |
| 3384 | |
| 3385 | #endif |
| 3386 | |
| 3387 | /***** 1.4.1.0 END REPAIRATHON2021 BRAND NEW FM ALGORITHMS!!! *****/ |
| 3388 | |
| 3389 | |
| 3390 | |
| 3391 | |
| 3392 | /***************************************************/ |
| 3393 | /*! \class Reverb |
| 3394 | \brief STK abstract reverberator parent class. |
| 3395 | |
| 3396 | This class provides common functionality for |
| 3397 | STK reverberator subclasses. |
| 3398 | |
| 3399 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 3400 | */ |
| 3401 | /***************************************************/ |
| 3402 | |
| 3403 | |
| 3404 | #if !defined(__REVERB_H) |
| 3405 | #define __REVERB_H |
| 3406 | |
| 3407 | class Reverb : public Stk |
| 3408 | { |
| 3409 | public: |
| 3410 | //! Class constructor. |
| 3411 | Reverb(); |
| 3412 | |
| 3413 | //! Class destructor. |
| 3414 | virtual ~Reverb(); |
| 3415 | |
| 3416 | //! Reset and clear all internal state. |
| 3417 | virtual void clear() = 0; |
| 3418 | |
| 3419 | //! Set the mixture of input and "reverberated" levels in the output (0.0 = input only, 1.0 = reverb only). |
| 3420 | void setEffectMix(MY_FLOAT mix); |
| 3421 | |
| 3422 | //! Return the last output value. |
| 3423 | MY_FLOAT lastOut() const; |
| 3424 | |
| 3425 | //! Return the last left output value. |
| 3426 | MY_FLOAT lastOutLeft() const; |
| 3427 | |
| 3428 | //! Return the last right output value. |
| 3429 | MY_FLOAT lastOutRight() const; |
| 3430 | |
| 3431 | //! Abstract tick function ... must be implemented in subclasses. |
| 3432 | virtual MY_FLOAT tick(MY_FLOAT input) = 0; |
| 3433 | |
| 3434 | //! Take \e vectorSize inputs, compute the same number of outputs and return them in \e vector. |
| 3435 | virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 3436 | |
| 3437 | public: // SWAP formerly protected |
| 3438 | |
| 3439 | // Returns true if argument value is prime. |
| 3440 | bool isPrime(int number); |
| 3441 | |
| 3442 | MY_FLOAT lastOutput[2]; |
| 3443 | MY_FLOAT effectMix; |
| 3444 | |
| 3445 | }; |
| 3446 | |
| 3447 | #endif // defined(__REVERB_H) |
| 3448 | |
| 3449 | |
| 3450 | |
| 3451 | |
| 3452 | /***************************************************/ |
| 3453 | /*! \class JCRev |
| 3454 | \brief John Chowning's reverberator class. |
| 3455 | |
| 3456 | This class is derived from the CLM JCRev |
| 3457 | function, which is based on the use of |
| 3458 | networks of simple allpass and comb delay |
| 3459 | filters. This class implements three series |
| 3460 | allpass units, followed by four parallel comb |
| 3461 | filters, and two decorrelation delay lines in |
| 3462 | parallel at the output. |
| 3463 | |
| 3464 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 3465 | */ |
| 3466 | /***************************************************/ |
| 3467 | |
| 3468 | #if !defined(__JCREV_H) |
| 3469 | #define __JCREV_H |
| 3470 | |
| 3471 | |
| 3472 | class JCRev : public Reverb |
| 3473 | { |
| 3474 | public: |
| 3475 | //! Class constructor taking a T60 decay time argument. |
| 3476 | JCRev(MY_FLOAT T60); |
| 3477 | |
| 3478 | //! Class destructor. |
| 3479 | ~JCRev(); |
| 3480 | |
| 3481 | //! Reset and clear all internal state. |
| 3482 | void clear(); |
| 3483 | |
| 3484 | //! Compute one output sample. |
| 3485 | MY_FLOAT tick(MY_FLOAT input); |
| 3486 | |
| 3487 | public: // SWAP formerly protected |
| 3488 | DelayBase *allpassDelays[3]; |
| 3489 | DelayBase *combDelays[4]; |
| 3490 | DelayBase *outLeftDelay; |
| 3491 | DelayBase *outRightDelay; |
| 3492 | MY_FLOAT allpassCoefficient; |
| 3493 | MY_FLOAT combCoefficient[4]; |
| 3494 | |
| 3495 | }; |
| 3496 | |
| 3497 | #endif |
| 3498 | |
| 3499 | |
| 3500 | |
| 3501 | |
| 3502 | /***************************************************/ |
| 3503 | /*! \class PluckTwo |
| 3504 | \brief STK enhanced plucked string model class. |
| 3505 | |
| 3506 | This class implements an enhanced two-string, |
| 3507 | plucked physical model, a la Jaffe-Smith, |
| 3508 | Smith, and others. |
| 3509 | |
| 3510 | PluckTwo is an abstract class, with no excitation |
| 3511 | specified. Therefore, it can't be directly |
| 3512 | instantiated. |
| 3513 | |
| 3514 | This is a digital waveguide model, making its |
| 3515 | use possibly subject to patents held by |
| 3516 | Stanford University, Yamaha, and others. |
| 3517 | |
| 3518 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 3519 | */ |
| 3520 | /***************************************************/ |
| 3521 | |
| 3522 | #if !defined(__PLUCKTWO_H) |
| 3523 | #define __PLUCKTWO_H |
| 3524 | |
| 3525 | |
| 3526 | class PluckTwo : public Instrmnt |
| 3527 | { |
| 3528 | public: |
| 3529 | //! Class constructor, taking the lowest desired playing frequency. |
| 3530 | PluckTwo(MY_FLOAT lowestFrequency); |
| 3531 | |
| 3532 | //! Class destructor. |
| 3533 | virtual ~PluckTwo(); |
| 3534 | |
| 3535 | //! Reset and clear all internal state. |
| 3536 | void clear(); |
| 3537 | |
| 3538 | //! Set instrument parameters for a particular frequency. |
| 3539 | virtual void setFrequency(MY_FLOAT frequency); |
| 3540 | // 1.4.1.0. REPAIRATHON FIX HERE: |
| 3541 | // added minus 1 from length in setFrequency (tuning error) |
| 3542 | |
| 3543 | //! Detune the two strings by the given factor. A value of 1.0 produces unison strings. |
| 3544 | void setDetune(MY_FLOAT detune); |
| 3545 | |
| 3546 | //! Efficient combined setting of frequency and detuning. |
| 3547 | void setFreqAndDetune(MY_FLOAT frequency, MY_FLOAT detune); |
| 3548 | |
| 3549 | //! Set the pluck or "excitation" position along the string (0.0 - 1.0). |
| 3550 | void setPluckPosition(MY_FLOAT position); |
| 3551 | |
| 3552 | //! Set the base loop gain. |
| 3553 | /*! |
| 3554 | The actual loop gain is set according to the frequency. |
| 3555 | Because of high-frequency loop filter roll-off, higher |
| 3556 | frequency settings have greater loop gains. |
| 3557 | */ |
| 3558 | void setBaseLoopGain(MY_FLOAT aGain); |
| 3559 | |
| 3560 | //! Stop a note with the given amplitude (speed of decay). |
| 3561 | virtual void noteOff(MY_FLOAT amplitude); |
| 3562 | |
| 3563 | //! Virtual (abstract) tick function is implemented by subclasses. |
| 3564 | virtual MY_FLOAT tick() = 0; |
| 3565 | |
| 3566 | public: // SWAP formerly protected |
| 3567 | DelayA *delayLine; |
| 3568 | DelayA *delayLine2; |
| 3569 | DelayL *combDelay; |
| 3570 | OneZero *filter; |
| 3571 | OneZero *filter2; |
| 3572 | long length; |
| 3573 | MY_FLOAT loopGain; |
| 3574 | MY_FLOAT baseLoopGain; |
| 3575 | MY_FLOAT lastFrequency; |
| 3576 | MY_FLOAT lastLength; |
| 3577 | MY_FLOAT detuning; |
| 3578 | MY_FLOAT pluckAmplitude; |
| 3579 | MY_FLOAT pluckPosition; |
| 3580 | |
| 3581 | }; |
| 3582 | |
| 3583 | #endif |
| 3584 | |
| 3585 | |
| 3586 | |
| 3587 | |
| 3588 | /***************************************************/ |
| 3589 | /*! \class Mandolin |
| 3590 | \brief STK mandolin instrument model class. |
| 3591 | |
| 3592 | This class inherits from PluckTwo and uses |
| 3593 | "commuted synthesis" techniques to model a |
| 3594 | mandolin instrument. |
| 3595 | |
| 3596 | This is a digital waveguide model, making its |
| 3597 | use possibly subject to patents held by |
| 3598 | Stanford University, Yamaha, and others. |
| 3599 | Commuted Synthesis, in particular, is covered |
| 3600 | by patents, granted, pending, and/or |
| 3601 | applied-for. All are assigned to the Board of |
| 3602 | Trustees, Stanford University. For |
| 3603 | information, contact the Office of Technology |
| 3604 | Licensing, Stanford University. |
| 3605 | |
| 3606 | Control Change Numbers: |
| 3607 | - Body Size = 2 |
| 3608 | - Pluck Position = 4 |
| 3609 | - String Sustain = 11 |
| 3610 | - String Detuning = 1 |
| 3611 | - Microphone Position = 128 |
| 3612 | |
| 3613 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 3614 | */ |
| 3615 | /***************************************************/ |
| 3616 | |
| 3617 | #if !defined(__MANDOLIN_H) |
| 3618 | #define __MANDOLIN_H |
| 3619 | |
| 3620 | |
| 3621 | class Mandolin : public PluckTwo |
| 3622 | { |
| 3623 | public: |
| 3624 | //! Class constructor, taking the lowest desired playing frequency. |
| 3625 | Mandolin(MY_FLOAT lowestFrequency); |
| 3626 | |
| 3627 | //! Class destructor. |
| 3628 | virtual ~Mandolin(); |
| 3629 | |
| 3630 | //! Pluck the strings with the given amplitude (0.0 - 1.0) using the current frequency. |
| 3631 | void pluck(MY_FLOAT amplitude); |
| 3632 | |
| 3633 | //! Pluck the strings with the given amplitude (0.0 - 1.0) and position (0.0 - 1.0). |
| 3634 | void pluck(MY_FLOAT amplitude,MY_FLOAT position); |
| 3635 | |
| 3636 | //! Start a note with the given frequency and amplitude (0.0 - 1.0). |
| 3637 | virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 3638 | |
| 3639 | //! Set the body size (a value of 1.0 produces the "default" size). |
| 3640 | void setBodySize(MY_FLOAT size); |
| 3641 | |
| 3642 | //! Set the body impulse response |
| 3643 | bool setBodyIR( const char * path, bool isRaw ); |
| 3644 | |
| 3645 | //! Compute one output sample. |
| 3646 | virtual MY_FLOAT tick(); |
| 3647 | |
| 3648 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 3649 | virtual void controlChange(int number, MY_FLOAT value); |
| 3650 | |
| 3651 | public: // SWAP formerly protected |
| 3652 | WvIn *soundfile[12]; |
| 3653 | MY_FLOAT directBody; |
| 3654 | int mic; |
| 3655 | long dampTime; |
| 3656 | bool waveDone; |
| 3657 | MY_FLOAT m_bodySize; |
| 3658 | // MY_FLOAT m_stringDamping; |
| 3659 | // MY_FLOAT m_stringDetune; |
| 3660 | }; |
| 3661 | |
| 3662 | #endif |
| 3663 | |
| 3664 | |
| 3665 | |
| 3666 | |
| 3667 | /***************************************************/ |
| 3668 | /*! \class Mesh2D |
| 3669 | \brief Two-dimensional rectilinear waveguide mesh class. |
| 3670 | |
| 3671 | This class implements a rectilinear, |
| 3672 | two-dimensional digital waveguide mesh |
| 3673 | structure. For details, see Van Duyne and |
| 3674 | Smith, "Physical Modeling with the 2-D Digital |
| 3675 | Waveguide Mesh", Proceedings of the 1993 |
| 3676 | International Computer Music Conference. |
| 3677 | |
| 3678 | This is a digital waveguide model, making its |
| 3679 | use possibly subject to patents held by Stanford |
| 3680 | University, Yamaha, and others. |
| 3681 | |
| 3682 | Control Change Numbers: |
| 3683 | - X Dimension = 2 |
| 3684 | - Y Dimension = 4 |
| 3685 | - Mesh Decay = 11 |
| 3686 | - X-Y Input Position = 1 |
| 3687 | |
| 3688 | by Julius Smith, 2000 - 2002. |
| 3689 | Revised by Gary Scavone for STK, 2002. |
| 3690 | */ |
| 3691 | /***************************************************/ |
| 3692 | |
| 3693 | #if !defined(__MESH2D_H) |
| 3694 | #define __MESH2D_H |
| 3695 | |
| 3696 | |
| 3697 | #define NXMAX ((short)(12)) |
| 3698 | #define NYMAX ((short)(12)) |
| 3699 | |
| 3700 | class Mesh2D : public Instrmnt |
| 3701 | { |
| 3702 | public: |
| 3703 | //! Class constructor, taking the x and y dimensions in samples. |
| 3704 | Mesh2D(short nX, short nY); |
| 3705 | |
| 3706 | //! Class destructor. |
| 3707 | ~Mesh2D(); |
| 3708 | |
| 3709 | //! Reset and clear all internal state. |
| 3710 | void clear(); |
| 3711 | |
| 3712 | //! Set the x dimension size in samples. |
| 3713 | void setNX(short lenX); |
| 3714 | |
| 3715 | //! Set the y dimension size in samples. |
| 3716 | void setNY(short lenY); |
| 3717 | |
| 3718 | //! Set the x, y input position on a 0.0 - 1.0 scale. |
| 3719 | void setInputPosition(MY_FLOAT xFactor, MY_FLOAT yFactor); |
| 3720 | |
| 3721 | //! Set the loss filters gains (0.0 - 1.0). |
| 3722 | void setDecay(MY_FLOAT decayFactor); |
| 3723 | |
| 3724 | //! Impulse the mesh with the given amplitude (frequency ignored). |
| 3725 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 3726 | |
| 3727 | //! Stop a note with the given amplitude (speed of decay) ... currently ignored. |
| 3728 | void noteOff(MY_FLOAT amplitude); |
| 3729 | |
| 3730 | //! Calculate and return the signal energy stored in the mesh. |
| 3731 | MY_FLOAT energy(); |
| 3732 | |
| 3733 | //! Compute one output sample, without adding energy to the mesh. |
| 3734 | MY_FLOAT tick(); |
| 3735 | |
| 3736 | //! Input a sample to the mesh and compute one output sample. |
| 3737 | using Instrmnt::tick; // tell the compiler we're OK overloading/shadowing a virtual function |
| 3738 | MY_FLOAT tick(MY_FLOAT input); |
| 3739 | |
| 3740 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 3741 | void controlChange(int number, MY_FLOAT value); |
| 3742 | |
| 3743 | public: // SWAP formerly protected |
| 3744 | |
| 3745 | MY_FLOAT tick0(); |
| 3746 | MY_FLOAT tick1(); |
| 3747 | void clearMesh(); |
| 3748 | |
| 3749 | short NX, NY; |
| 3750 | short xInput, yInput; |
| 3751 | OnePole *filterX[NXMAX]; |
| 3752 | OnePole *filterY[NYMAX]; |
| 3753 | MY_FLOAT v[NXMAX-1][NYMAX-1]; // junction velocities |
| 3754 | MY_FLOAT vxp[NXMAX][NYMAX]; // positive-x velocity wave |
| 3755 | MY_FLOAT vxm[NXMAX][NYMAX]; // negative-x velocity wave |
| 3756 | MY_FLOAT vyp[NXMAX][NYMAX]; // positive-y velocity wave |
| 3757 | MY_FLOAT vym[NXMAX][NYMAX]; // negative-y velocity wave |
| 3758 | |
| 3759 | // Alternate buffers |
| 3760 | MY_FLOAT vxp1[NXMAX][NYMAX]; // positive-x velocity wave |
| 3761 | MY_FLOAT vxm1[NXMAX][NYMAX]; // negative-x velocity wave |
| 3762 | MY_FLOAT vyp1[NXMAX][NYMAX]; // positive-y velocity wave |
| 3763 | MY_FLOAT vym1[NXMAX][NYMAX]; // negative-y velocity wave |
| 3764 | |
| 3765 | int counter; // time in samples |
| 3766 | |
| 3767 | |
| 3768 | }; |
| 3769 | |
| 3770 | #endif |
| 3771 | |
| 3772 | |
| 3773 | |
| 3774 | |
| 3775 | /***************************************************/ |
| 3776 | /*! \class Modal |
| 3777 | \brief STK resonance model instrument. |
| 3778 | |
| 3779 | This class contains an excitation wavetable, |
| 3780 | an envelope, an oscillator, and N resonances |
| 3781 | (non-sweeping BiQuad filters), where N is set |
| 3782 | during instantiation. |
| 3783 | |
| 3784 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 3785 | */ |
| 3786 | /***************************************************/ |
| 3787 | #if !defined(__MODAL_H) |
| 3788 | #define __MODAL_H |
| 3789 | |
| 3790 | class Modal : public Instrmnt |
| 3791 | { |
| 3792 | public: |
| 3793 | //! Class constructor, taking the desired number of modes to create. |
| 3794 | Modal( int modes = 4 ); |
| 3795 | |
| 3796 | //! Class destructor. |
| 3797 | virtual ~Modal(); |
| 3798 | |
| 3799 | //! Reset and clear all internal state. |
| 3800 | void clear(); |
| 3801 | |
| 3802 | //! Set instrument parameters for a particular frequency. |
| 3803 | virtual void setFrequency(MY_FLOAT frequency); |
| 3804 | |
| 3805 | //! Set the ratio and radius for a specified mode filter. |
| 3806 | void setRatioAndRadius(int modeIndex, MY_FLOAT ratio, MY_FLOAT radius); |
| 3807 | |
| 3808 | //! Set the master gain. |
| 3809 | void setMasterGain(MY_FLOAT aGain); |
| 3810 | |
| 3811 | //! Set the direct gain. |
| 3812 | void setDirectGain(MY_FLOAT aGain); |
| 3813 | |
| 3814 | //! Set the gain for a specified mode filter. |
| 3815 | void setModeGain(int modeIndex, MY_FLOAT gain); |
| 3816 | |
| 3817 | //! Initiate a strike with the given amplitude (0.0 - 1.0). |
| 3818 | virtual void strike(MY_FLOAT amplitude); |
| 3819 | |
| 3820 | //! Damp modes with a given decay factor (0.0 - 1.0). |
| 3821 | void damp(MY_FLOAT amplitude); |
| 3822 | |
| 3823 | //! Start a note with the given frequency and amplitude. |
| 3824 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 3825 | |
| 3826 | //! Stop a note with the given amplitude (speed of decay). |
| 3827 | void noteOff(MY_FLOAT amplitude); |
| 3828 | |
| 3829 | //! Compute one output sample. |
| 3830 | virtual MY_FLOAT tick(); |
| 3831 | |
| 3832 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 3833 | virtual void controlChange(int number, MY_FLOAT value) = 0; |
| 3834 | |
| 3835 | public: // SWAP formerly protected |
| 3836 | // chuck |
| 3837 | t_CKFLOAT m_vibratoGain; |
| 3838 | t_CKFLOAT m_vibratoFreq; |
| 3839 | t_CKFLOAT m_volume; |
| 3840 | |
| 3841 | Envelope *envelope; |
| 3842 | WvIn *wave; |
| 3843 | BiQuad **filters; |
| 3844 | OnePole *onepole; |
| 3845 | WaveLoop *vibrato; |
| 3846 | int nModes; |
| 3847 | MY_FLOAT vibratoGain; |
| 3848 | MY_FLOAT masterGain; |
| 3849 | MY_FLOAT directGain; |
| 3850 | MY_FLOAT stickHardness; |
| 3851 | MY_FLOAT strikePosition; |
| 3852 | MY_FLOAT baseFrequency; |
| 3853 | MY_FLOAT *ratios; |
| 3854 | MY_FLOAT *radii; |
| 3855 | |
| 3856 | }; |
| 3857 | |
| 3858 | #endif |
| 3859 | |
| 3860 | |
| 3861 | |
| 3862 | |
| 3863 | /***************************************************/ |
| 3864 | /*! \class ModalBar |
| 3865 | \brief STK resonant bar instrument class. |
| 3866 | |
| 3867 | This class implements a number of different |
| 3868 | struck bar instruments. It inherits from the |
| 3869 | Modal class. |
| 3870 | |
| 3871 | Control Change Numbers: |
| 3872 | - Stick Hardness = 2 |
| 3873 | - Stick Position = 4 |
| 3874 | - Vibrato Gain = 11 |
| 3875 | - Vibrato Frequency = 7 |
| 3876 | - Volume = 128 |
| 3877 | - Modal Presets = 16 |
| 3878 | - Marimba = 0 |
| 3879 | - Vibraphone = 1 |
| 3880 | - Agogo = 2 |
| 3881 | - Wood1 = 3 |
| 3882 | - Reso = 4 |
| 3883 | - Wood2 = 5 |
| 3884 | - Beats = 6 |
| 3885 | - Two Fixed = 7 |
| 3886 | - Clump = 8 |
| 3887 | |
| 3888 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 3889 | */ |
| 3890 | /***************************************************/ |
| 3891 | |
| 3892 | #if !defined(__MODALBAR_H) |
| 3893 | #define __MODALBAR_H |
| 3894 | |
| 3895 | |
| 3896 | class ModalBar : public Modal |
| 3897 | { |
| 3898 | public: |
| 3899 | //! Class constructor. |
| 3900 | ModalBar(); |
| 3901 | |
| 3902 | //! Class destructor. |
| 3903 | ~ModalBar(); |
| 3904 | |
| 3905 | //! Set stick hardness (0.0 - 1.0). |
| 3906 | void setStickHardness(MY_FLOAT hardness); |
| 3907 | |
| 3908 | //! Set stick position (0.0 - 1.0). |
| 3909 | void setStrikePosition(MY_FLOAT position); |
| 3910 | |
| 3911 | //! Select a bar preset (currently modulo 9). |
| 3912 | void setPreset(int preset); |
| 3913 | |
| 3914 | //! Set the modulation (vibrato) depth. |
| 3915 | void setModulationDepth(MY_FLOAT mDepth); |
| 3916 | |
| 3917 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 3918 | void controlChange(int number, MY_FLOAT value); |
| 3919 | }; |
| 3920 | |
| 3921 | #endif |
| 3922 | |
| 3923 | |
| 3924 | |
| 3925 | |
| 3926 | /***************************************************/ |
| 3927 | /*! \class SubNoise |
| 3928 | \brief STK sub-sampled noise generator. |
| 3929 | |
| 3930 | Generates a new random number every "rate" ticks |
| 3931 | using the C rand() function. The quality of the |
| 3932 | rand() function varies from one OS to another. |
| 3933 | |
| 3934 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 3935 | */ |
| 3936 | /***************************************************/ |
| 3937 | |
| 3938 | #if !defined(__SUBNOISE_H) |
| 3939 | #define __SUBNOISE_H |
| 3940 | |
| 3941 | |
| 3942 | class SubNoise : public Noise |
| 3943 | { |
| 3944 | public: |
| 3945 | |
| 3946 | //! Default constructor sets sub-sample rate to 16. |
| 3947 | SubNoise(int subRate = 16); |
| 3948 | |
| 3949 | //! Class destructor. |
| 3950 | ~SubNoise(); |
| 3951 | |
| 3952 | //! Return the current sub-sampling rate. |
| 3953 | int subRate(void) const; |
| 3954 | |
| 3955 | //! Set the sub-sampling rate. |
| 3956 | void setRate(int subRate); |
| 3957 | |
| 3958 | //! Return a sub-sampled random number between -1.0 and 1.0. |
| 3959 | MY_FLOAT tick(); |
| 3960 | |
| 3961 | public: // SWAP formerly protected |
| 3962 | int counter; |
| 3963 | int rate; |
| 3964 | |
| 3965 | }; |
| 3966 | |
| 3967 | #endif |
| 3968 | |
| 3969 | |
| 3970 | |
| 3971 | |
| 3972 | /***************************************************/ |
| 3973 | /*! \class Modulate |
| 3974 | \brief STK periodic/random modulator. |
| 3975 | |
| 3976 | This class combines random and periodic |
| 3977 | modulations to give a nice, natural human |
| 3978 | modulation function. |
| 3979 | |
| 3980 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 3981 | */ |
| 3982 | /***************************************************/ |
| 3983 | |
| 3984 | #if !defined(__MODULATE_H) |
| 3985 | #define __MODULATE_H |
| 3986 | |
| 3987 | |
| 3988 | class Modulate : public Stk |
| 3989 | { |
| 3990 | public: |
| 3991 | //! Class constructor. |
| 3992 | Modulate(); |
| 3993 | |
| 3994 | //! Class destructor. |
| 3995 | ~Modulate(); |
| 3996 | |
| 3997 | //! Reset internal state. |
| 3998 | void reset(); |
| 3999 | |
| 4000 | //! Set the periodic (vibrato) rate or frequency in Hz. |
| 4001 | void setVibratoRate(MY_FLOAT aRate); |
| 4002 | |
| 4003 | //! Set the periodic (vibrato) gain. |
| 4004 | void setVibratoGain(MY_FLOAT aGain); |
| 4005 | |
| 4006 | //! Set the random modulation gain. |
| 4007 | void setRandomGain(MY_FLOAT aGain); |
| 4008 | |
| 4009 | //! Compute one output sample. |
| 4010 | MY_FLOAT tick(); |
| 4011 | |
| 4012 | //! Return \e vectorSize outputs in \e vector. |
| 4013 | virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 4014 | |
| 4015 | //! Return the last computed output value. |
| 4016 | MY_FLOAT lastOut() const; |
| 4017 | |
| 4018 | public: // SWAP formerly protected |
| 4019 | WaveLoop *vibrato; |
| 4020 | SubNoise *noise; |
| 4021 | OnePole *filter; |
| 4022 | MY_FLOAT vibratoGain; |
| 4023 | MY_FLOAT randomGain; |
| 4024 | MY_FLOAT lastOutput; |
| 4025 | |
| 4026 | }; |
| 4027 | |
| 4028 | #endif |
| 4029 | |
| 4030 | |
| 4031 | |
| 4032 | |
| 4033 | /***************************************************/ |
| 4034 | /*! \class Sampler |
| 4035 | \brief STK sampling synthesis abstract base class. |
| 4036 | |
| 4037 | This instrument contains up to 5 attack waves, |
| 4038 | 5 looped waves, and an ADSR envelope. |
| 4039 | |
| 4040 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4041 | */ |
| 4042 | /***************************************************/ |
| 4043 | |
| 4044 | #if !defined(__SAMPLER_H) |
| 4045 | #define __SAMPLER_H |
| 4046 | |
| 4047 | |
| 4048 | class Sampler : public Instrmnt |
| 4049 | { |
| 4050 | public: |
| 4051 | //! Default constructor. |
| 4052 | Sampler(); |
| 4053 | |
| 4054 | //! Class destructor. |
| 4055 | virtual ~Sampler(); |
| 4056 | |
| 4057 | //! Reset and clear all internal state. |
| 4058 | void clear(); |
| 4059 | |
| 4060 | //! Set instrument parameters for a particular frequency. |
| 4061 | virtual void setFrequency(MY_FLOAT frequency) = 0; |
| 4062 | |
| 4063 | //! Initiate the envelopes with a key-on event and reset the attack waves. |
| 4064 | void keyOn(); |
| 4065 | |
| 4066 | //! Signal a key-off event to the envelopes. |
| 4067 | void keyOff(); |
| 4068 | |
| 4069 | //! Stop a note with the given amplitude (speed of decay). |
| 4070 | virtual void noteOff(MY_FLOAT amplitude); |
| 4071 | |
| 4072 | //! Compute one output sample. |
| 4073 | virtual MY_FLOAT tick(); |
| 4074 | |
| 4075 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 4076 | virtual void controlChange(int number, MY_FLOAT value) = 0; |
| 4077 | |
| 4078 | public: // SWAP formerly protected |
| 4079 | ADSR *adsr; |
| 4080 | WvIn *attacks[5]; |
| 4081 | WaveLoop *loops[5]; |
| 4082 | OnePole *filter; |
| 4083 | MY_FLOAT baseFrequency; |
| 4084 | MY_FLOAT attackRatios[5]; |
| 4085 | MY_FLOAT loopRatios[5]; |
| 4086 | MY_FLOAT attackGain; |
| 4087 | MY_FLOAT loopGain; |
| 4088 | int whichOne; |
| 4089 | |
| 4090 | }; |
| 4091 | |
| 4092 | #endif |
| 4093 | |
| 4094 | |
| 4095 | |
| 4096 | |
| 4097 | /***************************************************/ |
| 4098 | /*! \class Moog |
| 4099 | \brief STK moog-like swept filter sampling synthesis class. |
| 4100 | |
| 4101 | This instrument uses one attack wave, one |
| 4102 | looped wave, and an ADSR envelope (inherited |
| 4103 | from the Sampler class) and adds two sweepable |
| 4104 | formant (FormSwep) filters. |
| 4105 | |
| 4106 | Control Change Numbers: |
| 4107 | - Filter Q = 2 |
| 4108 | - Filter Sweep Rate = 4 |
| 4109 | - Vibrato Frequency = 11 |
| 4110 | - Vibrato Gain = 1 |
| 4111 | - Gain = 128 |
| 4112 | |
| 4113 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4114 | */ |
| 4115 | /***************************************************/ |
| 4116 | |
| 4117 | #if !defined(__MOOG_H) |
| 4118 | #define __MOOG_H |
| 4119 | |
| 4120 | |
| 4121 | class Moog : public Sampler |
| 4122 | { |
| 4123 | public: |
| 4124 | //! Class constructor. |
| 4125 | Moog(); |
| 4126 | |
| 4127 | //! Class destructor. |
| 4128 | ~Moog(); |
| 4129 | |
| 4130 | //! Set instrument parameters for a particular frequency. |
| 4131 | virtual void setFrequency(MY_FLOAT frequency); |
| 4132 | |
| 4133 | //! Start a note with the given frequency and amplitude. |
| 4134 | virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 4135 | virtual void noteOn(MY_FLOAT amplitude ); //CHUCK! note start note with current frequency |
| 4136 | |
| 4137 | //! Set the modulation (vibrato) speed in Hz. |
| 4138 | void setModulationSpeed(MY_FLOAT mSpeed); |
| 4139 | |
| 4140 | //! Set the modulation (vibrato) depth. |
| 4141 | void setModulationDepth(MY_FLOAT mDepth); |
| 4142 | |
| 4143 | //! Compute one output sample. |
| 4144 | virtual MY_FLOAT tick(); |
| 4145 | |
| 4146 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 4147 | virtual void controlChange(int number, MY_FLOAT value); |
| 4148 | |
| 4149 | public: // SWAP formerly protected |
| 4150 | //chuck |
| 4151 | t_CKFLOAT m_vibratoFreq; |
| 4152 | t_CKFLOAT m_vibratoGain; |
| 4153 | t_CKFLOAT m_volume; |
| 4154 | |
| 4155 | FormSwep *filters[2]; |
| 4156 | MY_FLOAT modDepth; |
| 4157 | MY_FLOAT filterQ; |
| 4158 | MY_FLOAT filterRate; |
| 4159 | MY_FLOAT filterStartFreq; // 1.4.1.0 (prc) |
| 4160 | }; |
| 4161 | |
| 4162 | #endif |
| 4163 | |
| 4164 | |
| 4165 | |
| 4166 | |
| 4167 | /***************************************************/ |
| 4168 | /*! \class NRev |
| 4169 | \brief CCRMA's NRev reverberator class. |
| 4170 | |
| 4171 | This class is derived from the CLM NRev |
| 4172 | function, which is based on the use of |
| 4173 | networks of simple allpass and comb delay |
| 4174 | filters. This particular arrangement consists |
| 4175 | of 6 comb filters in parallel, followed by 3 |
| 4176 | allpass filters, a lowpass filter, and another |
| 4177 | allpass in series, followed by two allpass |
| 4178 | filters in parallel with corresponding right |
| 4179 | and left outputs. |
| 4180 | |
| 4181 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4182 | */ |
| 4183 | /***************************************************/ |
| 4184 | |
| 4185 | #if !defined(__NREV_H) |
| 4186 | #define __NREV_H |
| 4187 | |
| 4188 | |
| 4189 | class NRev : public Reverb |
| 4190 | { |
| 4191 | public: |
| 4192 | //! Class constructor taking a T60 decay time argument. |
| 4193 | NRev(MY_FLOAT T60); |
| 4194 | |
| 4195 | //! Class destructor. |
| 4196 | ~NRev(); |
| 4197 | |
| 4198 | //! Reset and clear all internal state. |
| 4199 | void clear(); |
| 4200 | |
| 4201 | //! Compute one output sample. |
| 4202 | MY_FLOAT tick(MY_FLOAT input); |
| 4203 | |
| 4204 | public: // SWAP formerly protected |
| 4205 | DelayBase *allpassDelays[8]; |
| 4206 | DelayBase *combDelays[6]; |
| 4207 | MY_FLOAT allpassCoefficient; |
| 4208 | MY_FLOAT combCoefficient[6]; |
| 4209 | MY_FLOAT lowpassState; |
| 4210 | |
| 4211 | }; |
| 4212 | |
| 4213 | #endif |
| 4214 | |
| 4215 | |
| 4216 | |
| 4217 | |
| 4218 | |
| 4219 | /***************************************************/ |
| 4220 | /*! \class PRCRev |
| 4221 | \brief Perry's simple reverberator class. |
| 4222 | |
| 4223 | This class is based on some of the famous |
| 4224 | Stanford/CCRMA reverbs (NRev, KipRev), which |
| 4225 | were based on the Chowning/Moorer/Schroeder |
| 4226 | reverberators using networks of simple allpass |
| 4227 | and comb delay filters. This class implements |
| 4228 | two series allpass units and two parallel comb |
| 4229 | filters. |
| 4230 | |
| 4231 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4232 | */ |
| 4233 | /***************************************************/ |
| 4234 | |
| 4235 | #if !defined(__PRCREV_H) |
| 4236 | #define __PRCREV_H |
| 4237 | |
| 4238 | |
| 4239 | class PRCRev : public Reverb |
| 4240 | { |
| 4241 | public: |
| 4242 | //! Class constructor taking a T60 decay time argument. |
| 4243 | PRCRev(MY_FLOAT T60); |
| 4244 | |
| 4245 | //! Class destructor. |
| 4246 | ~PRCRev(); |
| 4247 | |
| 4248 | //! Reset and clear all internal state. |
| 4249 | void clear(); |
| 4250 | |
| 4251 | //! Compute one output sample. |
| 4252 | MY_FLOAT tick(MY_FLOAT input); |
| 4253 | |
| 4254 | public: // SWAP formerly protected |
| 4255 | DelayBase *allpassDelays[2]; |
| 4256 | DelayBase *combDelays[2]; |
| 4257 | MY_FLOAT allpassCoefficient; |
| 4258 | MY_FLOAT combCoefficient[2]; |
| 4259 | |
| 4260 | }; |
| 4261 | |
| 4262 | #endif |
| 4263 | |
| 4264 | |
| 4265 | |
| 4266 | |
| 4267 | |
| 4268 | /***************************************************/ |
| 4269 | /*! \class PercFlut |
| 4270 | \brief STK percussive flute FM synthesis instrument. |
| 4271 | |
| 4272 | This class implements algorithm 4 of the TX81Z. |
| 4273 | |
| 4274 | \code |
| 4275 | Algorithm 4 is : 4->3--\ |
| 4276 | 2-- + -->1-->Out |
| 4277 | \endcode |
| 4278 | |
| 4279 | Control Change Numbers: |
| 4280 | - Total Modulator Index = 2 |
| 4281 | - Modulator Crossfade = 4 |
| 4282 | - LFO Speed = 11 |
| 4283 | - LFO Depth = 1 |
| 4284 | - ADSR 2 & 4 Target = 128 |
| 4285 | |
| 4286 | The basic Chowning/Stanford FM patent expired |
| 4287 | in 1995, but there exist follow-on patents, |
| 4288 | mostly assigned to Yamaha. If you are of the |
| 4289 | type who should worry about this (making |
| 4290 | money) worry away. |
| 4291 | |
| 4292 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4293 | */ |
| 4294 | /***************************************************/ |
| 4295 | |
| 4296 | #if !defined(__PERCFLUT_H) |
| 4297 | #define __PERCFLUT_H |
| 4298 | |
| 4299 | |
| 4300 | class PercFlut : public FM |
| 4301 | { |
| 4302 | public: |
| 4303 | //! Class constructor. |
| 4304 | PercFlut(); |
| 4305 | |
| 4306 | //! Class destructor. |
| 4307 | ~PercFlut(); |
| 4308 | |
| 4309 | //! Set instrument parameters for a particular frequency. |
| 4310 | void setFrequency(MY_FLOAT frequency); |
| 4311 | |
| 4312 | //! Start a note with the given frequency and amplitude. |
| 4313 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 4314 | void noteOn( MY_FLOAT amplitude) { noteOn(baseFrequency, amplitude); } |
| 4315 | |
| 4316 | //! Compute one output sample. |
| 4317 | MY_FLOAT tick(); |
| 4318 | }; |
| 4319 | |
| 4320 | #endif |
| 4321 | |
| 4322 | |
| 4323 | |
| 4324 | |
| 4325 | /***************************************************/ |
| 4326 | /*! \class Phonemes |
| 4327 | \brief STK phonemes table. |
| 4328 | |
| 4329 | This class does nothing other than declare a |
| 4330 | set of 32 static phoneme formant parameters |
| 4331 | and provide access to those values. |
| 4332 | |
| 4333 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4334 | */ |
| 4335 | /***************************************************/ |
| 4336 | |
| 4337 | #if !defined(__PHONEMES_H) |
| 4338 | #define __PHONEMES_H |
| 4339 | |
| 4340 | |
| 4341 | class Phonemes |
| 4342 | { |
| 4343 | public: |
| 4344 | |
| 4345 | Phonemes(void); |
| 4346 | ~Phonemes(void); |
| 4347 | |
| 4348 | //! Returns the phoneme name for the given index (0-31). |
| 4349 | static const char *name( unsigned int index ); |
| 4350 | |
| 4351 | //! Returns the voiced component gain for the given phoneme index (0-31). |
| 4352 | static MY_FLOAT voiceGain( unsigned int index ); |
| 4353 | |
| 4354 | //! Returns the unvoiced component gain for the given phoneme index (0-31). |
| 4355 | static MY_FLOAT noiseGain( unsigned int index ); |
| 4356 | |
| 4357 | //! Returns the formant frequency for the given phoneme index (0-31) and partial (0-3). |
| 4358 | static MY_FLOAT formantFrequency( unsigned int index, unsigned int partial ); |
| 4359 | |
| 4360 | //! Returns the formant radius for the given phoneme index (0-31) and partial (0-3). |
| 4361 | static MY_FLOAT formantRadius( unsigned int index, unsigned int partial ); |
| 4362 | |
| 4363 | //! Returns the formant gain for the given phoneme index (0-31) and partial (0-3). |
| 4364 | static MY_FLOAT formantGain( unsigned int index, unsigned int partial ); |
| 4365 | |
| 4366 | public: // SWAP formerly private |
| 4367 | |
| 4368 | static const char phonemeNames[][4]; |
| 4369 | static const MY_FLOAT phonemeGains[][2]; |
| 4370 | static const MY_FLOAT phonemeParameters[][4][3]; |
| 4371 | |
| 4372 | }; |
| 4373 | |
| 4374 | #endif |
| 4375 | |
| 4376 | |
| 4377 | |
| 4378 | |
| 4379 | /***************************************************/ |
| 4380 | /*! \class PitShift |
| 4381 | \brief STK simple pitch shifter effect class. |
| 4382 | |
| 4383 | This class implements a simple pitch shifter |
| 4384 | using delay lines. |
| 4385 | |
| 4386 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4387 | */ |
| 4388 | /***************************************************/ |
| 4389 | |
| 4390 | #if !defined(__PITSHIFT_H) |
| 4391 | #define __PITSHIFT_H |
| 4392 | |
| 4393 | |
| 4394 | class PitShift : public Stk |
| 4395 | { |
| 4396 | public: |
| 4397 | //! Class constructor. |
| 4398 | PitShift(); |
| 4399 | |
| 4400 | //! Class destructor. |
| 4401 | ~PitShift(); |
| 4402 | |
| 4403 | //! Reset and clear all internal state. |
| 4404 | void clear(); |
| 4405 | |
| 4406 | //! Set the pitch shift factor (1.0 produces no shift). |
| 4407 | void setShift(MY_FLOAT shift); |
| 4408 | |
| 4409 | //! Set the mixture of input and processed levels in the output (0.0 = input only, 1.0 = processed only). |
| 4410 | void setEffectMix(MY_FLOAT mix); |
| 4411 | |
| 4412 | //! Return the last output value. |
| 4413 | MY_FLOAT lastOut() const; |
| 4414 | |
| 4415 | //! Compute one output sample. |
| 4416 | MY_FLOAT tick(MY_FLOAT input); |
| 4417 | |
| 4418 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 4419 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 4420 | |
| 4421 | public: // SWAP formerly protected |
| 4422 | //chuck |
| 4423 | t_CKFLOAT m_vibratoGain; |
| 4424 | t_CKFLOAT m_vibratoFreq; |
| 4425 | t_CKFLOAT m_volume; |
| 4426 | |
| 4427 | DelayL *delayLine[2]; |
| 4428 | MY_FLOAT lastOutput; |
| 4429 | MY_FLOAT delay[2]; |
| 4430 | MY_FLOAT env[2]; |
| 4431 | MY_FLOAT effectMix; |
| 4432 | MY_FLOAT rate; |
| 4433 | |
| 4434 | }; |
| 4435 | |
| 4436 | #endif |
| 4437 | |
| 4438 | |
| 4439 | |
| 4440 | |
| 4441 | |
| 4442 | /***************************************************/ |
| 4443 | /*! \class Plucked |
| 4444 | \brief STK plucked string model class. |
| 4445 | |
| 4446 | This class implements a simple plucked string |
| 4447 | physical model based on the Karplus-Strong |
| 4448 | algorithm. |
| 4449 | |
| 4450 | This is a digital waveguide model, making its |
| 4451 | use possibly subject to patents held by |
| 4452 | Stanford University, Yamaha, and others. |
| 4453 | There exist at least two patents, assigned to |
| 4454 | Stanford, bearing the names of Karplus and/or |
| 4455 | Strong. |
| 4456 | |
| 4457 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4458 | */ |
| 4459 | /***************************************************/ |
| 4460 | |
| 4461 | #if !defined(__PLUCKED_H) |
| 4462 | #define __PLUCKED_H |
| 4463 | |
| 4464 | |
| 4465 | class Plucked : public Instrmnt |
| 4466 | { |
| 4467 | public: |
| 4468 | //! Class constructor, taking the lowest desired playing frequency. |
| 4469 | Plucked(MY_FLOAT lowestFrequency); |
| 4470 | |
| 4471 | //! Class destructor. |
| 4472 | ~Plucked(); |
| 4473 | |
| 4474 | //! Reset and clear all internal state. |
| 4475 | void clear(); |
| 4476 | |
| 4477 | //! Set instrument parameters for a particular frequency. |
| 4478 | virtual void setFrequency(MY_FLOAT frequency); |
| 4479 | |
| 4480 | //! Pluck the string with the given amplitude using the current frequency. |
| 4481 | void pluck(MY_FLOAT amplitude); |
| 4482 | |
| 4483 | //! Start a note with the given frequency and amplitude. |
| 4484 | virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 4485 | |
| 4486 | //! Stop a note with the given amplitude (speed of decay). |
| 4487 | virtual void noteOff(MY_FLOAT amplitude); |
| 4488 | |
| 4489 | //! Compute one output sample. |
| 4490 | virtual MY_FLOAT tick(); |
| 4491 | |
| 4492 | public: // SWAP formerly protected |
| 4493 | DelayA *delayLine; |
| 4494 | OneZero *loopFilter; |
| 4495 | OnePole *pickFilter; |
| 4496 | Noise *noise; |
| 4497 | long length; |
| 4498 | MY_FLOAT loopGain; |
| 4499 | |
| 4500 | }; |
| 4501 | |
| 4502 | #endif |
| 4503 | |
| 4504 | |
| 4505 | |
| 4506 | |
| 4507 | |
| 4508 | /***************************************************/ |
| 4509 | /*! \class Resonate |
| 4510 | \brief STK noise driven formant filter. |
| 4511 | |
| 4512 | This instrument contains a noise source, which |
| 4513 | excites a biquad resonance filter, with volume |
| 4514 | controlled by an ADSR. |
| 4515 | |
| 4516 | Control Change Numbers: |
| 4517 | - Resonance Frequency (0-Nyquist) = 2 |
| 4518 | - Pole Radii = 4 |
| 4519 | - Notch Frequency (0-Nyquist) = 11 |
| 4520 | - Zero Radii = 1 |
| 4521 | - Envelope Gain = 128 |
| 4522 | |
| 4523 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4524 | */ |
| 4525 | /***************************************************/ |
| 4526 | |
| 4527 | #if !defined(__RESONATE_H) |
| 4528 | #define __RESONATE_H |
| 4529 | |
| 4530 | |
| 4531 | class Resonate : public Instrmnt |
| 4532 | { |
| 4533 | public: |
| 4534 | //! Class constructor. |
| 4535 | Resonate(); |
| 4536 | |
| 4537 | //! Class destructor. |
| 4538 | ~Resonate(); |
| 4539 | |
| 4540 | //! Reset and clear all internal state. |
| 4541 | void clear(); |
| 4542 | |
| 4543 | //! Set the filter for a resonance at the given frequency (Hz) and radius. |
| 4544 | void setResonance(MY_FLOAT frequency, MY_FLOAT radius); |
| 4545 | |
| 4546 | //! Set the filter for a notch at the given frequency (Hz) and radius. |
| 4547 | void setNotch(MY_FLOAT frequency, MY_FLOAT radius); |
| 4548 | |
| 4549 | //! Set the filter zero coefficients for contant resonance gain. |
| 4550 | void setEqualGainZeroes(); |
| 4551 | |
| 4552 | //! Initiate the envelope with a key-on event. |
| 4553 | void keyOn(); |
| 4554 | |
| 4555 | //! Signal a key-off event to the envelope. |
| 4556 | void keyOff(); |
| 4557 | |
| 4558 | //! Start a note with the given frequency and amplitude. |
| 4559 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 4560 | |
| 4561 | //! Stop a note with the given amplitude (speed of decay). |
| 4562 | void noteOff(MY_FLOAT amplitude); |
| 4563 | |
| 4564 | //! Compute one output sample. |
| 4565 | MY_FLOAT tick(); |
| 4566 | |
| 4567 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 4568 | virtual void controlChange(int number, MY_FLOAT value); |
| 4569 | |
| 4570 | public: // SWAP formerly protected |
| 4571 | ADSR *adsr; |
| 4572 | BiQuad *filter; |
| 4573 | Noise *noise; |
| 4574 | MY_FLOAT poleFrequency; |
| 4575 | MY_FLOAT poleRadius; |
| 4576 | MY_FLOAT zeroFrequency; |
| 4577 | MY_FLOAT zeroRadius; |
| 4578 | |
| 4579 | }; |
| 4580 | |
| 4581 | #endif |
| 4582 | |
| 4583 | |
| 4584 | |
| 4585 | |
| 4586 | /***************************************************/ |
| 4587 | /*! \class Rhodey |
| 4588 | \brief STK Fender Rhodes electric piano FM |
| 4589 | synthesis instrument. |
| 4590 | |
| 4591 | This class implements two simple FM Pairs |
| 4592 | summed together, also referred to as algorithm |
| 4593 | 5 of the TX81Z. |
| 4594 | |
| 4595 | \code |
| 4596 | Algorithm 5 is : 4->3--\ |
| 4597 | + --> Out |
| 4598 | 2->1--/ |
| 4599 | \endcode |
| 4600 | |
| 4601 | Control Change Numbers: |
| 4602 | - Modulator Index One = 2 |
| 4603 | - Crossfade of Outputs = 4 |
| 4604 | - LFO Speed = 11 |
| 4605 | - LFO Depth = 1 |
| 4606 | - ADSR 2 & 4 Target = 128 |
| 4607 | |
| 4608 | The basic Chowning/Stanford FM patent expired |
| 4609 | in 1995, but there exist follow-on patents, |
| 4610 | mostly assigned to Yamaha. If you are of the |
| 4611 | type who should worry about this (making |
| 4612 | money) worry away. |
| 4613 | |
| 4614 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4615 | */ |
| 4616 | /***************************************************/ |
| 4617 | |
| 4618 | #if !defined(__RHODEY_H) |
| 4619 | #define __RHODEY_H |
| 4620 | |
| 4621 | |
| 4622 | class Rhodey : public FM |
| 4623 | { |
| 4624 | public: |
| 4625 | //! Class constructor. |
| 4626 | Rhodey(); |
| 4627 | |
| 4628 | //! Class destructor. |
| 4629 | ~Rhodey(); |
| 4630 | |
| 4631 | //! Set instrument parameters for a particular frequency. |
| 4632 | void setFrequency(MY_FLOAT frequency); |
| 4633 | |
| 4634 | //! Start a note with the given frequency and amplitude. |
| 4635 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 4636 | void noteOn(MY_FLOAT amplitude) { noteOn(baseFrequency * 0.5, amplitude ); } |
| 4637 | |
| 4638 | //! Compute one output sample. |
| 4639 | MY_FLOAT tick(); |
| 4640 | }; |
| 4641 | |
| 4642 | #endif |
| 4643 | |
| 4644 | |
| 4645 | |
| 4646 | |
| 4647 | /***************************************************/ |
| 4648 | /*! \class SKINI |
| 4649 | \brief STK SKINI parsing class |
| 4650 | |
| 4651 | This class parses SKINI formatted text |
| 4652 | messages. It can be used to parse individual |
| 4653 | messages or it can be passed an entire file. |
| 4654 | The file specification is Perry's and his |
| 4655 | alone, but it's all text so it shouldn't be to |
| 4656 | hard to figure out. |
| 4657 | |
| 4658 | SKINI (Synthesis toolKit Instrument Network |
| 4659 | Interface) is like MIDI, but allows for |
| 4660 | floating-point control changes, note numbers, |
| 4661 | etc. The following example causes a sharp |
| 4662 | middle C to be played with a velocity of 111.132: |
| 4663 | |
| 4664 | \code |
| 4665 | noteOn 60.01 111.13 |
| 4666 | \endcode |
| 4667 | |
| 4668 | \sa \ref skini |
| 4669 | |
| 4670 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4671 | */ |
| 4672 | /***************************************************/ |
| 4673 | |
| 4674 | #if !defined(__SKINI_H) |
| 4675 | #define __SKINI_H |
| 4676 | |
| 4677 | #include <stdio.h> |
| 4678 | |
| 4679 | class SKINI : public Stk |
| 4680 | { |
| 4681 | public: |
| 4682 | //! Default constructor used for parsing messages received externally. |
| 4683 | SKINI(); |
| 4684 | |
| 4685 | //! Overloaded constructor taking a SKINI formatted scorefile. |
| 4686 | SKINI(char *fileName); |
| 4687 | |
| 4688 | //! Class destructor |
| 4689 | ~SKINI(); |
| 4690 | |
| 4691 | //! Attempt to parse the given string, returning the message type. |
| 4692 | /*! |
| 4693 | A type value equal to zero indicates an invalid message. |
| 4694 | */ |
| 4695 | long parseThis(char* aString); |
| 4696 | |
| 4697 | //! Parse the next message (if a file is loaded) and return the message type. |
| 4698 | /*! |
| 4699 | A negative value is returned when the file end is reached. |
| 4700 | */ |
| 4701 | long nextMessage(); |
| 4702 | |
| 4703 | //! Return the current message type. |
| 4704 | long getType() const; |
| 4705 | |
| 4706 | //! Return the current message channel value. |
| 4707 | long getChannel() const; |
| 4708 | |
| 4709 | //! Return the current message delta time value (in seconds). |
| 4710 | MY_FLOAT getDelta() const; |
| 4711 | |
| 4712 | //! Return the current message byte two value. |
| 4713 | MY_FLOAT getByteTwo() const; |
| 4714 | |
| 4715 | //! Return the current message byte three value. |
| 4716 | MY_FLOAT getByteThree() const; |
| 4717 | |
| 4718 | //! Return the current message byte two value (integer). |
| 4719 | long getByteTwoInt() const; |
| 4720 | |
| 4721 | //! Return the current message byte three value (integer). |
| 4722 | long getByteThreeInt() const; |
| 4723 | |
| 4724 | //! Return remainder string after parsing. |
| 4725 | const char* getRemainderString(); |
| 4726 | |
| 4727 | //! Return the message type as a string. |
| 4728 | const char* getMessageTypeString(); |
| 4729 | |
| 4730 | //! Return the SKINI type string for the given type value. |
| 4731 | const char* whatsThisType(long type); |
| 4732 | |
| 4733 | //! Return the SKINI controller string for the given controller number. |
| 4734 | const char* whatsThisController(long number); |
| 4735 | |
| 4736 | public: // SWAP formerly protected |
| 4737 | |
| 4738 | FILE *myFile; |
| 4739 | long messageType; |
| 4740 | char msgTypeString[64]; |
| 4741 | long channel; |
| 4742 | MY_FLOAT deltaTime; |
| 4743 | MY_FLOAT byteTwo; |
| 4744 | MY_FLOAT byteThree; |
| 4745 | long byteTwoInt; |
| 4746 | long byteThreeInt; |
| 4747 | char remainderString[1024]; |
| 4748 | char whatString[1024]; |
| 4749 | }; |
| 4750 | |
| 4751 | static const double Midi2Pitch[129] = { |
| 4752 | 8.18,8.66,9.18,9.72,10.30,10.91,11.56,12.25, |
| 4753 | 12.98,13.75,14.57,15.43,16.35,17.32,18.35,19.45, |
| 4754 | 20.60,21.83,23.12,24.50,25.96,27.50,29.14,30.87, |
| 4755 | 32.70,34.65,36.71,38.89,41.20,43.65,46.25,49.00, |
| 4756 | 51.91,55.00,58.27,61.74,65.41,69.30,73.42,77.78, |
| 4757 | 82.41,87.31,92.50,98.00,103.83,110.00,116.54,123.47, |
| 4758 | 130.81,138.59,146.83,155.56,164.81,174.61,185.00,196.00, |
| 4759 | 207.65,220.00,233.08,246.94,261.63,277.18,293.66,311.13, |
| 4760 | 329.63,349.23,369.99,392.00,415.30,440.00,466.16,493.88, |
| 4761 | 523.25,554.37,587.33,622.25,659.26,698.46,739.99,783.99, |
| 4762 | 830.61,880.00,932.33,987.77,1046.50,1108.73,1174.66,1244.51, |
| 4763 | 1318.51,1396.91,1479.98,1567.98,1661.22,1760.00,1864.66,1975.53, |
| 4764 | 2093.00,2217.46,2349.32,2489.02,2637.02,2793.83,2959.96,3135.96, |
| 4765 | 3322.44,3520.00,3729.31,3951.07,4186.01,4434.92,4698.64,4978.03, |
| 4766 | 5274.04,5587.65,5919.91,6271.93,6644.88,7040.00,7458.62,7902.13, |
| 4767 | 8372.02,8869.84,9397.27,9956.06,10548.08,11175.30,11839.82,12543.85, |
| 4768 | 13289.75}; |
| 4769 | |
| 4770 | #endif |
| 4771 | |
| 4772 | |
| 4773 | |
| 4774 | |
| 4775 | |
| 4776 | |
| 4777 | /***************************************************/ |
| 4778 | /*! \class Saxofony |
| 4779 | \brief STK faux conical bore reed instrument class. |
| 4780 | |
| 4781 | This class implements a "hybrid" digital |
| 4782 | waveguide instrument that can generate a |
| 4783 | variety of wind-like sounds. It has also been |
| 4784 | referred to as the "blowed string" model. The |
| 4785 | waveguide section is essentially that of a |
| 4786 | string, with one rigid and one lossy |
| 4787 | termination. The non-linear function is a |
| 4788 | reed table. The string can be "blown" at any |
| 4789 | point between the terminations, though just as |
| 4790 | with strings, it is impossible to excite the |
| 4791 | system at either end. If the excitation is |
| 4792 | placed at the string mid-point, the sound is |
| 4793 | that of a clarinet. At points closer to the |
| 4794 | "bridge", the sound is closer to that of a |
| 4795 | saxophone. See Scavone (2002) for more details. |
| 4796 | |
| 4797 | This is a digital waveguide model, making its |
| 4798 | use possibly subject to patents held by Stanford |
| 4799 | University, Yamaha, and others. |
| 4800 | |
| 4801 | Control Change Numbers: |
| 4802 | - Reed Stiffness = 2 |
| 4803 | - Reed Aperture = 26 |
| 4804 | - Noise Gain = 4 |
| 4805 | - Blow Position = 11 |
| 4806 | - Vibrato Frequency = 29 |
| 4807 | - Vibrato Gain = 1 |
| 4808 | - Breath Pressure = 128 |
| 4809 | |
| 4810 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 4811 | */ |
| 4812 | /***************************************************/ |
| 4813 | |
| 4814 | #if !defined(__SAXOFONY_H) |
| 4815 | #define __SAXOFONY_H |
| 4816 | |
| 4817 | |
| 4818 | class Saxofony : public Instrmnt |
| 4819 | { |
| 4820 | public: |
| 4821 | //! Class constructor, taking the lowest desired playing frequency. |
| 4822 | Saxofony(MY_FLOAT lowestFrequency); |
| 4823 | |
| 4824 | //! Class destructor. |
| 4825 | ~Saxofony(); |
| 4826 | |
| 4827 | //! Reset and clear all internal state. |
| 4828 | void clear(); |
| 4829 | |
| 4830 | //! Set instrument parameters for a particular frequency. |
| 4831 | void setFrequency(MY_FLOAT frequency); |
| 4832 | |
| 4833 | //! Set the "blowing" position between the air column terminations (0.0 - 1.0). |
| 4834 | void setBlowPosition(MY_FLOAT aPosition); |
| 4835 | |
| 4836 | //! Apply breath pressure to instrument with given amplitude and rate of increase. |
| 4837 | void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate); |
| 4838 | |
| 4839 | //! Decrease breath pressure with given rate of decrease. |
| 4840 | void stopBlowing(MY_FLOAT rate); |
| 4841 | |
| 4842 | //! Start a note with the given frequency and amplitude. |
| 4843 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 4844 | |
| 4845 | //! Stop a note with the given amplitude (speed of decay). |
| 4846 | void noteOff(MY_FLOAT amplitude); |
| 4847 | |
| 4848 | //! Compute one output sample. |
| 4849 | MY_FLOAT tick(); |
| 4850 | |
| 4851 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 4852 | void controlChange(int number, MY_FLOAT value); |
| 4853 | |
| 4854 | public: // SWAP formerly protected |
| 4855 | // chuck |
| 4856 | t_CKFLOAT m_rate; |
| 4857 | t_CKFLOAT m_stiffness; |
| 4858 | t_CKFLOAT m_aperture; |
| 4859 | t_CKFLOAT m_noiseGain; |
| 4860 | t_CKFLOAT m_vibratoGain; |
| 4861 | t_CKFLOAT m_pressure; |
| 4862 | |
| 4863 | DelayL *delays[2]; |
| 4864 | ReedTabl *reedTable; |
| 4865 | OneZero *filter; |
| 4866 | Envelope *envelope; |
| 4867 | Noise *noise; |
| 4868 | WaveLoop *vibrato; |
| 4869 | long length; |
| 4870 | MY_FLOAT outputGain; |
| 4871 | MY_FLOAT noiseGain; |
| 4872 | MY_FLOAT vibratoGain; |
| 4873 | MY_FLOAT position; |
| 4874 | |
| 4875 | }; |
| 4876 | |
| 4877 | #endif |
| 4878 | |
| 4879 | |
| 4880 | |
| 4881 | |
| 4882 | /***************************************************/ |
| 4883 | /*! \class Shakers |
| 4884 | \brief PhISEM and PhOLIES class. |
| 4885 | |
| 4886 | PhISEM (Physically Informed Stochastic Event |
| 4887 | Modeling) is an algorithmic approach for |
| 4888 | simulating collisions of multiple independent |
| 4889 | sound producing objects. This class is a |
| 4890 | meta-model that can simulate a Maraca, Sekere, |
| 4891 | Cabasa, Bamboo Wind Chimes, Water Drops, |
| 4892 | Tambourine, Sleighbells, and a Guiro. |
| 4893 | |
| 4894 | PhOLIES (Physically-Oriented Library of |
| 4895 | Imitated Environmental Sounds) is a similar |
| 4896 | approach for the synthesis of environmental |
| 4897 | sounds. This class implements simulations of |
| 4898 | breaking sticks, crunchy snow (or not), a |
| 4899 | wrench, sandpaper, and more. |
| 4900 | |
| 4901 | Control Change Numbers: |
| 4902 | - Shake Energy = 2 |
| 4903 | - System Decay = 4 |
| 4904 | - Number Of Objects = 11 |
| 4905 | - Resonance Frequency = 1 |
| 4906 | - Shake Energy = 128 |
| 4907 | - Instrument Selection = 1071 |
| 4908 | - Maraca = 0 |
| 4909 | - Cabasa = 1 |
| 4910 | - Sekere = 2 |
| 4911 | - Guiro = 3 |
| 4912 | - Water Drops = 4 |
| 4913 | - Bamboo Chimes = 5 |
| 4914 | - Tambourine = 6 |
| 4915 | - Sleigh Bells = 7 |
| 4916 | - Sticks = 8 |
| 4917 | - Crunch = 9 |
| 4918 | - Wrench = 10 |
| 4919 | - Sand Paper = 11 |
| 4920 | - Coke Can = 12 |
| 4921 | - Next Mug = 13 |
| 4922 | - Penny + Mug = 14 |
| 4923 | - Nickle + Mug = 15 |
| 4924 | - Dime + Mug = 16 |
| 4925 | - Quarter + Mug = 17 |
| 4926 | - Franc + Mug = 18 |
| 4927 | - Peso + Mug = 19 |
| 4928 | - Big Rocks = 20 |
| 4929 | - Little Rocks = 21 |
| 4930 | - Tuned Bamboo Chimes = 22 |
| 4931 | |
| 4932 | by Perry R. Cook, 1996 - 1999. |
| 4933 | */ |
| 4934 | /***************************************************/ |
| 4935 | |
| 4936 | #if !defined(__SHAKERS_H) |
| 4937 | #define __SHAKERS_H |
| 4938 | |
| 4939 | |
| 4940 | #define MAX_FREQS 8 |
| 4941 | #define NUM_INSTR 24 |
| 4942 | |
| 4943 | class Shakers : public Instrmnt |
| 4944 | { |
| 4945 | public: |
| 4946 | //! Class constructor. |
| 4947 | Shakers(); |
| 4948 | |
| 4949 | //! Class destructor. |
| 4950 | ~Shakers(); |
| 4951 | |
| 4952 | //! Start a note with the given instrument and amplitude. |
| 4953 | /*! |
| 4954 | Use the instrument numbers above, converted to frequency values |
| 4955 | as if MIDI note numbers, to select a particular instrument. |
| 4956 | */ |
| 4957 | virtual void ck_noteOn(MY_FLOAT amplitude ); // chuck single arg call |
| 4958 | virtual void noteOn(MY_FLOAT instrument, MY_FLOAT amplitude); |
| 4959 | |
| 4960 | //! Stop a note with the given amplitude (speed of decay). |
| 4961 | virtual void noteOff(MY_FLOAT amplitude); |
| 4962 | |
| 4963 | //! Compute one output sample. |
| 4964 | MY_FLOAT tick(); |
| 4965 | |
| 4966 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 4967 | virtual void controlChange(int number, MY_FLOAT value); |
| 4968 | |
| 4969 | int m_noteNum; // chuck data |
| 4970 | MY_FLOAT freq; |
| 4971 | int setupName(char* instr); |
| 4972 | int setupNum(int inst); |
| 4973 | |
| 4974 | public: // SWAP formerly protected |
| 4975 | // chuck |
| 4976 | t_CKFLOAT m_energy; |
| 4977 | t_CKFLOAT m_decay; |
| 4978 | t_CKFLOAT m_objects; |
| 4979 | |
| 4980 | int setFreqAndReson(int which, MY_FLOAT freq, MY_FLOAT reson); |
| 4981 | void setDecays(MY_FLOAT sndDecay, MY_FLOAT sysDecay); |
| 4982 | void setFinalZs(MY_FLOAT z0, MY_FLOAT z1, MY_FLOAT z2); |
| 4983 | MY_FLOAT wuter_tick(); |
| 4984 | MY_FLOAT tbamb_tick(); |
| 4985 | MY_FLOAT ratchet_tick(); |
| 4986 | |
| 4987 | int instType; |
| 4988 | int ratchetPos, lastRatchetPos; |
| 4989 | MY_FLOAT shakeEnergy; |
| 4990 | MY_FLOAT inputs[MAX_FREQS]; |
| 4991 | MY_FLOAT outputs[MAX_FREQS][2]; |
| 4992 | MY_FLOAT coeffs[MAX_FREQS][2]; |
| 4993 | MY_FLOAT sndLevel; |
| 4994 | MY_FLOAT baseGain; |
| 4995 | MY_FLOAT gains[MAX_FREQS]; |
| 4996 | int nFreqs; |
| 4997 | MY_FLOAT t_center_freqs[MAX_FREQS]; |
| 4998 | MY_FLOAT center_freqs[MAX_FREQS]; |
| 4999 | MY_FLOAT resons[MAX_FREQS]; |
| 5000 | MY_FLOAT freq_rand[MAX_FREQS]; |
| 5001 | int freqalloc[MAX_FREQS]; |
| 5002 | MY_FLOAT soundDecay; |
| 5003 | MY_FLOAT systemDecay; |
| 5004 | MY_FLOAT nObjects; |
| 5005 | MY_FLOAT collLikely; |
| 5006 | MY_FLOAT totalEnergy; |
| 5007 | MY_FLOAT ratchet,ratchetDelta; |
| 5008 | MY_FLOAT finalZ[3]; |
| 5009 | MY_FLOAT finalZCoeffs[3]; |
| 5010 | MY_FLOAT defObjs[NUM_INSTR]; |
| 5011 | MY_FLOAT defDecays[NUM_INSTR]; |
| 5012 | MY_FLOAT decayScale[NUM_INSTR]; |
| 5013 | }; |
| 5014 | |
| 5015 | #endif |
| 5016 | |
| 5017 | |
| 5018 | |
| 5019 | |
| 5020 | /***************************************************/ |
| 5021 | /*! \class Simple |
| 5022 | \brief STK wavetable/noise instrument. |
| 5023 | |
| 5024 | This class combines a looped wave, a |
| 5025 | noise source, a biquad resonance filter, |
| 5026 | a one-pole filter, and an ADSR envelope |
| 5027 | to create some interesting sounds. |
| 5028 | |
| 5029 | Control Change Numbers: |
| 5030 | - Filter Pole Position = 2 |
| 5031 | - Noise/Pitched Cross-Fade = 4 |
| 5032 | - Envelope Rate = 11 |
| 5033 | - Gain = 128 |
| 5034 | |
| 5035 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5036 | */ |
| 5037 | /***************************************************/ |
| 5038 | |
| 5039 | #if !defined(__SIMPLE_H) |
| 5040 | #define __SIMPLE_H |
| 5041 | |
| 5042 | |
| 5043 | class Simple : public Instrmnt |
| 5044 | { |
| 5045 | public: |
| 5046 | //! Class constructor. |
| 5047 | Simple(); |
| 5048 | |
| 5049 | //! Class destructor. |
| 5050 | virtual ~Simple(); |
| 5051 | |
| 5052 | //! Clear internal states. |
| 5053 | void clear(); |
| 5054 | |
| 5055 | //! Set instrument parameters for a particular frequency. |
| 5056 | virtual void setFrequency(MY_FLOAT frequency); |
| 5057 | |
| 5058 | //! Start envelope toward "on" target. |
| 5059 | void keyOn(); |
| 5060 | |
| 5061 | //! Start envelope toward "off" target. |
| 5062 | void keyOff(); |
| 5063 | |
| 5064 | //! Start a note with the given frequency and amplitude. |
| 5065 | virtual void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 5066 | |
| 5067 | //! Stop a note with the given amplitude (speed of decay). |
| 5068 | virtual void noteOff(MY_FLOAT amplitude); |
| 5069 | |
| 5070 | //! Compute one output sample. |
| 5071 | virtual MY_FLOAT tick(); |
| 5072 | |
| 5073 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 5074 | virtual void controlChange(int number, MY_FLOAT value); |
| 5075 | |
| 5076 | public: // SWAP formerly protected |
| 5077 | ADSR *adsr; |
| 5078 | WaveLoop *loop; |
| 5079 | OnePole *filter; |
| 5080 | BiQuad *biquad; |
| 5081 | Noise *noise; |
| 5082 | MY_FLOAT baseFrequency; |
| 5083 | MY_FLOAT loopGain; |
| 5084 | |
| 5085 | }; |
| 5086 | |
| 5087 | #endif |
| 5088 | |
| 5089 | |
| 5090 | |
| 5091 | |
| 5092 | /***************************************************/ |
| 5093 | /*! \class SingWave |
| 5094 | \brief STK "singing" looped soundfile class. |
| 5095 | |
| 5096 | This class contains all that is needed to make |
| 5097 | a pitched musical sound, like a simple voice |
| 5098 | or violin. In general, it will not be used |
| 5099 | alone because of munchkinification effects |
| 5100 | from pitch shifting. It will be used as an |
| 5101 | excitation source for other instruments. |
| 5102 | |
| 5103 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5104 | */ |
| 5105 | /***************************************************/ |
| 5106 | |
| 5107 | #if !defined(__SINGWAVE_H) |
| 5108 | #define __SINGWAVE_H |
| 5109 | |
| 5110 | |
| 5111 | class SingWave : public Stk |
| 5112 | { |
| 5113 | public: |
| 5114 | //! Class constructor taking filename argument. |
| 5115 | /*! |
| 5116 | An StkError will be thrown if the file is not found, its format is |
| 5117 | unknown, or a read error occurs. |
| 5118 | */ |
| 5119 | SingWave(const char *fileName, bool raw=FALSE); |
| 5120 | |
| 5121 | //! Class destructor. |
| 5122 | ~SingWave(); |
| 5123 | |
| 5124 | //! Reset file to beginning. |
| 5125 | void reset(); |
| 5126 | |
| 5127 | //! Normalize the file to a maximum of +-1.0. |
| 5128 | void normalize(); |
| 5129 | |
| 5130 | //! Normalize the file to a maximum of \e +- peak. |
| 5131 | void normalize(MY_FLOAT peak); |
| 5132 | |
| 5133 | //! Set instrument parameters for a particular frequency. |
| 5134 | void setFrequency(MY_FLOAT frequency); |
| 5135 | |
| 5136 | //! Set the vibrato frequency in Hz. |
| 5137 | void setVibratoRate(MY_FLOAT aRate); |
| 5138 | |
| 5139 | //! Set the vibrato gain. |
| 5140 | void setVibratoGain(MY_FLOAT gain); |
| 5141 | |
| 5142 | //! Set the random-ness amount. |
| 5143 | void setRandomGain(MY_FLOAT gain); |
| 5144 | |
| 5145 | //! Set the sweep rate. |
| 5146 | void setSweepRate(MY_FLOAT aRate); |
| 5147 | |
| 5148 | //! Set the gain rate. |
| 5149 | void setGainRate(MY_FLOAT aRate); |
| 5150 | |
| 5151 | //! Set the gain target value. |
| 5152 | void setGainTarget(MY_FLOAT target); |
| 5153 | |
| 5154 | //! Start a note. |
| 5155 | void noteOn(); |
| 5156 | |
| 5157 | //! Stop a note. |
| 5158 | void noteOff(); |
| 5159 | |
| 5160 | //! Return the last output value. |
| 5161 | MY_FLOAT lastOut(); |
| 5162 | |
| 5163 | //! Compute one output sample. |
| 5164 | MY_FLOAT tick(); |
| 5165 | |
| 5166 | public: // SWAP formerly protected |
| 5167 | |
| 5168 | WaveLoop *wave; |
| 5169 | Modulate *modulator; |
| 5170 | Envelope *envelope; |
| 5171 | Envelope *pitchEnvelope; |
| 5172 | MY_FLOAT rate; |
| 5173 | MY_FLOAT sweepRate; |
| 5174 | MY_FLOAT lastOutput; |
| 5175 | MY_FLOAT m_freq; //chuck data |
| 5176 | |
| 5177 | }; |
| 5178 | |
| 5179 | #endif |
| 5180 | |
| 5181 | |
| 5182 | |
| 5183 | |
| 5184 | /***************************************************/ |
| 5185 | /*! \class Sitar |
| 5186 | \brief STK sitar string model class. |
| 5187 | |
| 5188 | This class implements a sitar plucked string |
| 5189 | physical model based on the Karplus-Strong |
| 5190 | algorithm. |
| 5191 | |
| 5192 | This is a digital waveguide model, making its |
| 5193 | use possibly subject to patents held by |
| 5194 | Stanford University, Yamaha, and others. |
| 5195 | There exist at least two patents, assigned to |
| 5196 | Stanford, bearing the names of Karplus and/or |
| 5197 | Strong. |
| 5198 | |
| 5199 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5200 | */ |
| 5201 | /***************************************************/ |
| 5202 | |
| 5203 | #if !defined(__SITAR_H) |
| 5204 | #define __SITAR_H |
| 5205 | |
| 5206 | |
| 5207 | class Sitar : public Instrmnt |
| 5208 | { |
| 5209 | public: |
| 5210 | //! Class constructor, taking the lowest desired playing frequency. |
| 5211 | Sitar(MY_FLOAT lowestFrequency); |
| 5212 | |
| 5213 | //! Class destructor. |
| 5214 | ~Sitar(); |
| 5215 | |
| 5216 | //! Reset and clear all internal state. |
| 5217 | void clear(); |
| 5218 | |
| 5219 | //! Set instrument parameters for a particular frequency. |
| 5220 | void setFrequency(MY_FLOAT frequency); |
| 5221 | |
| 5222 | //! Pluck the string with the given amplitude using the current frequency. |
| 5223 | void pluck(MY_FLOAT amplitude); |
| 5224 | |
| 5225 | //! Start a note with the given frequency and amplitude. |
| 5226 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 5227 | |
| 5228 | //! Stop a note with the given amplitude (speed of decay). |
| 5229 | void noteOff(MY_FLOAT amplitude); |
| 5230 | |
| 5231 | //! Compute one output sample. |
| 5232 | MY_FLOAT tick(); |
| 5233 | |
| 5234 | public: // SWAP formerly protected |
| 5235 | DelayA *delayLine; |
| 5236 | OneZero *loopFilter; |
| 5237 | Noise *noise; |
| 5238 | ADSR *envelope; |
| 5239 | long length; |
| 5240 | MY_FLOAT loopGain; |
| 5241 | MY_FLOAT amGain; |
| 5242 | MY_FLOAT delay; |
| 5243 | MY_FLOAT targetDelay; |
| 5244 | |
| 5245 | }; |
| 5246 | |
| 5247 | #endif |
| 5248 | |
| 5249 | |
| 5250 | |
| 5251 | |
| 5252 | |
| 5253 | /***************************************************/ |
| 5254 | /*! \class Socket |
| 5255 | \brief STK TCP socket client/server class. |
| 5256 | |
| 5257 | This class provides a uniform cross-platform |
| 5258 | TCP socket client or socket server interface. |
| 5259 | Methods are provided for reading or writing |
| 5260 | data buffers to/from connections. This class |
| 5261 | also provides a number of static functions for |
| 5262 | use with external socket descriptors. |
| 5263 | |
| 5264 | The user is responsible for checking the values |
| 5265 | returned by the read/write methods. Values |
| 5266 | less than or equal to zero indicate a closed |
| 5267 | or lost connection or the occurrence of an error. |
| 5268 | |
| 5269 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5270 | */ |
| 5271 | /***************************************************/ |
| 5272 | |
| 5273 | #if !defined(__SOCKET_H) |
| 5274 | #define __SOCKET_H |
| 5275 | |
| 5276 | |
| 5277 | class Socket : public Stk |
| 5278 | { |
| 5279 | public: |
| 5280 | //! Default constructor which creates a local socket server on port 2006 (or the specified port number). |
| 5281 | /*! |
| 5282 | An StkError will be thrown if a socket error occurs during instantiation. |
| 5283 | */ |
| 5284 | Socket( int port = 2006 ); |
| 5285 | |
| 5286 | //! Class constructor which creates a socket client connection to the specified host and port. |
| 5287 | /*! |
| 5288 | An StkError will be thrown if a socket error occurs during instantiation. |
| 5289 | */ |
| 5290 | Socket( int port, const char *hostname ); |
| 5291 | |
| 5292 | //! The class destructor closes the socket instance, breaking any existing connections. |
| 5293 | ~Socket(); |
| 5294 | |
| 5295 | //! Connect a socket client to the specified host and port and returns the resulting socket descriptor. |
| 5296 | /*! |
| 5297 | This method is valid for socket clients only. If it is called for |
| 5298 | a socket server, -1 is returned. If the socket client is already |
| 5299 | connected, that connection is terminated and a new connection is |
| 5300 | attempted. Server connections are made using the accept() method. |
| 5301 | An StkError will be thrown if a socket error occurs during |
| 5302 | instantiation. \sa accept |
| 5303 | */ |
| 5304 | int connect( int port, const char *hostname = "localhost" ); |
| 5305 | |
| 5306 | //! Close this socket. |
| 5307 | void close( void ); |
| 5308 | |
| 5309 | //! Return the server/client socket descriptor. |
| 5310 | int socket( void ) const; |
| 5311 | |
| 5312 | //! Return the server/client port number. |
| 5313 | int port( void ) const; |
| 5314 | |
| 5315 | //! If this is a socket server, extract the first pending connection request from the queue and create a new connection, returning the descriptor for the accepted socket. |
| 5316 | /*! |
| 5317 | If no connection requests are pending and the socket has not |
| 5318 | been set non-blocking, this function will block until a connection |
| 5319 | is present. If an error occurs or this is a socket client, -1 is |
| 5320 | returned. |
| 5321 | */ |
| 5322 | int accept( void ); |
| 5323 | |
| 5324 | //! If enable = false, the socket is set to non-blocking mode. When first created, sockets are by default in blocking mode. |
| 5325 | static void setBlocking( int socket, bool enable ); |
| 5326 | |
| 5327 | //! Close the socket with the given descriptor. |
| 5328 | static void close( int socket ); |
| 5329 | |
| 5330 | //! Returns TRUE is the socket descriptor is valid. |
| 5331 | static bool isValid( int socket ); |
| 5332 | |
| 5333 | //! Write a buffer over the socket connection. Returns the number of bytes written or -1 if an error occurs. |
| 5334 | int writeBuffer(const void *buffer, long bufferSize, int flags = 0); |
| 5335 | |
| 5336 | //! Write a buffer via the specified socket. Returns the number of bytes written or -1 if an error occurs. |
| 5337 | static int writeBuffer(int socket, const void *buffer, long bufferSize, int flags ); |
| 5338 | |
| 5339 | //! Read a buffer from the socket connection, up to length \e bufferSize. Returns the number of bytes read or -1 if an error occurs. |
| 5340 | int readBuffer(void *buffer, long bufferSize, int flags = 0); |
| 5341 | |
| 5342 | //! Read a buffer via the specified socket. Returns the number of bytes read or -1 if an error occurs. |
| 5343 | static int readBuffer(int socket, void *buffer, long bufferSize, int flags ); |
| 5344 | |
| 5345 | public: // SWAP formerly protected |
| 5346 | |
| 5347 | char msg[STK_MSG_BUF_LENGTH]; |
| 5348 | int soket; |
| 5349 | int poort; |
| 5350 | bool server; |
| 5351 | |
| 5352 | }; |
| 5353 | |
| 5354 | #endif // defined(__SOCKET_H) |
| 5355 | |
| 5356 | |
| 5357 | |
| 5358 | |
| 5359 | /***************************************************/ |
| 5360 | /*! \class Vector3D |
| 5361 | \brief STK 3D vector class. |
| 5362 | |
| 5363 | This class implements a three-dimensional vector. |
| 5364 | |
| 5365 | by Perry R. Cook, 1995 - 2002. |
| 5366 | */ |
| 5367 | /***************************************************/ |
| 5368 | |
| 5369 | #if !defined(__VECTOR3D_H) |
| 5370 | #define __VECTOR3D_H |
| 5371 | |
| 5372 | class Vector3D { |
| 5373 | |
| 5374 | public: |
| 5375 | //! Default constructor taking optional initial X, Y, and Z values. |
| 5376 | Vector3D(double initX=0.0, double initY=0.0, double initZ=0.0); |
| 5377 | |
| 5378 | //! Class destructor. |
| 5379 | ~Vector3D(); |
| 5380 | |
| 5381 | //! Get the current X value. |
| 5382 | double getX(); |
| 5383 | |
| 5384 | //! Get the current Y value. |
| 5385 | double getY(); |
| 5386 | |
| 5387 | //! Get the current Z value. |
| 5388 | double getZ(); |
| 5389 | |
| 5390 | //! Calculate the vector length. |
| 5391 | double getLength(); |
| 5392 | |
| 5393 | //! Set the X, Y, and Z values simultaniously. |
| 5394 | void setXYZ(double anX, double aY, double aZ); |
| 5395 | |
| 5396 | //! Set the X value. |
| 5397 | void setX(double aval); |
| 5398 | |
| 5399 | //! Set the Y value. |
| 5400 | void setY(double aval); |
| 5401 | |
| 5402 | //! Set the Z value. |
| 5403 | void setZ(double aval); |
| 5404 | |
| 5405 | public: // SWAP formerly protected |
| 5406 | double myX; |
| 5407 | double myY; |
| 5408 | double myZ; |
| 5409 | }; |
| 5410 | |
| 5411 | #endif |
| 5412 | |
| 5413 | |
| 5414 | |
| 5415 | |
| 5416 | /***************************************************/ |
| 5417 | /*! \class Sphere |
| 5418 | \brief STK sphere class. |
| 5419 | |
| 5420 | This class implements a spherical ball with |
| 5421 | radius, mass, position, and velocity parameters. |
| 5422 | |
| 5423 | by Perry R. Cook, 1995 - 2002. |
| 5424 | */ |
| 5425 | /***************************************************/ |
| 5426 | |
| 5427 | #if !defined(__SPHERE_H) |
| 5428 | #define __SPHERE_H |
| 5429 | |
| 5430 | |
| 5431 | class Sphere |
| 5432 | { |
| 5433 | public: |
| 5434 | //! Constructor taking an initial radius value. |
| 5435 | Sphere(double initRadius); |
| 5436 | |
| 5437 | //! Class destructor. |
| 5438 | ~Sphere(); |
| 5439 | |
| 5440 | //! Set the 3D center position of the sphere. |
| 5441 | void setPosition(double anX, double aY, double aZ); |
| 5442 | |
| 5443 | //! Set the 3D velocity of the sphere. |
| 5444 | void setVelocity(double anX, double aY, double aZ); |
| 5445 | |
| 5446 | //! Set the radius of the sphere. |
| 5447 | void setRadius(double aRadius); |
| 5448 | |
| 5449 | //! Set the mass of the sphere. |
| 5450 | void setMass(double aMass); |
| 5451 | |
| 5452 | //! Get the current position of the sphere as a 3D vector. |
| 5453 | Vector3D* getPosition(); |
| 5454 | |
| 5455 | //! Get the relative position of the given point to the sphere as a 3D vector. |
| 5456 | Vector3D* getRelativePosition(Vector3D *aPosition); |
| 5457 | |
| 5458 | //! Set the velcoity of the sphere as a 3D vector. |
| 5459 | double getVelocity(Vector3D* aVelocity); |
| 5460 | |
| 5461 | //! Returns the distance from the sphere boundary to the given position (< 0 if inside). |
| 5462 | double isInside(Vector3D *aPosition); |
| 5463 | |
| 5464 | //! Get the current sphere radius. |
| 5465 | double getRadius(); |
| 5466 | |
| 5467 | //! Get the current sphere mass. |
| 5468 | double getMass(); |
| 5469 | |
| 5470 | //! Increase the current sphere velocity by the given 3D components. |
| 5471 | void addVelocity(double anX, double aY, double aZ); |
| 5472 | |
| 5473 | //! Move the sphere for the given time increment. |
| 5474 | void tick(double timeIncrement); |
| 5475 | |
| 5476 | public: // SWAP formerly private |
| 5477 | Vector3D *myPosition; |
| 5478 | Vector3D *myVelocity; |
| 5479 | Vector3D workingVector; |
| 5480 | double myRadius; |
| 5481 | double myMass; |
| 5482 | }; |
| 5483 | |
| 5484 | #endif |
| 5485 | |
| 5486 | |
| 5487 | |
| 5488 | |
| 5489 | /***************************************************/ |
| 5490 | /*! \class StifKarp |
| 5491 | \brief STK plucked stiff string instrument. |
| 5492 | |
| 5493 | This class implements a simple plucked string |
| 5494 | algorithm (Karplus Strong) with enhancements |
| 5495 | (Jaffe-Smith, Smith, and others), including |
| 5496 | string stiffness and pluck position controls. |
| 5497 | The stiffness is modeled with allpass filters. |
| 5498 | |
| 5499 | This is a digital waveguide model, making its |
| 5500 | use possibly subject to patents held by |
| 5501 | Stanford University, Yamaha, and others. |
| 5502 | |
| 5503 | Control Change Numbers: |
| 5504 | - Pickup Position = 4 |
| 5505 | - String Sustain = 11 |
| 5506 | - String Stretch = 1 |
| 5507 | |
| 5508 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5509 | */ |
| 5510 | /***************************************************/ |
| 5511 | |
| 5512 | #if !defined(__StifKarp_h) |
| 5513 | #define __StifKarp_h |
| 5514 | |
| 5515 | |
| 5516 | class StifKarp : public Instrmnt |
| 5517 | { |
| 5518 | public: |
| 5519 | //! Class constructor, taking the lowest desired playing frequency. |
| 5520 | StifKarp(MY_FLOAT lowestFrequency); |
| 5521 | |
| 5522 | //! Class destructor. |
| 5523 | ~StifKarp(); |
| 5524 | |
| 5525 | //! Reset and clear all internal state. |
| 5526 | void clear(); |
| 5527 | |
| 5528 | //! Set instrument parameters for a particular frequency. |
| 5529 | void setFrequency(MY_FLOAT frequency); |
| 5530 | |
| 5531 | //! Set the stretch "factor" of the string (0.0 - 1.0). |
| 5532 | void setStretch(MY_FLOAT stretch); |
| 5533 | |
| 5534 | //! Set the pluck or "excitation" position along the string (0.0 - 1.0). |
| 5535 | void setPickupPosition(MY_FLOAT position); |
| 5536 | |
| 5537 | //! Set the base loop gain. |
| 5538 | /*! |
| 5539 | The actual loop gain is set according to the frequency. |
| 5540 | Because of high-frequency loop filter roll-off, higher |
| 5541 | frequency settings have greater loop gains. |
| 5542 | */ |
| 5543 | void setBaseLoopGain(MY_FLOAT aGain); |
| 5544 | |
| 5545 | //! Pluck the string with the given amplitude using the current frequency. |
| 5546 | void pluck(MY_FLOAT amplitude); |
| 5547 | |
| 5548 | //! Start a note with the given frequency and amplitude. |
| 5549 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 5550 | |
| 5551 | //! Stop a note with the given amplitude (speed of decay). |
| 5552 | void noteOff(MY_FLOAT amplitude); |
| 5553 | |
| 5554 | //! Compute one output sample. |
| 5555 | MY_FLOAT tick(); |
| 5556 | |
| 5557 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 5558 | void controlChange(int number, MY_FLOAT value); |
| 5559 | |
| 5560 | public: // SWAP formerly protected |
| 5561 | // chuck |
| 5562 | t_CKFLOAT m_sustain; |
| 5563 | |
| 5564 | DelayA *delayLine; |
| 5565 | DelayL *combDelay; |
| 5566 | OneZero *filter; |
| 5567 | Noise *noise; |
| 5568 | BiQuad *biQuad[4]; |
| 5569 | long length; |
| 5570 | MY_FLOAT loopGain; |
| 5571 | MY_FLOAT baseLoopGain; |
| 5572 | MY_FLOAT lastFrequency; |
| 5573 | MY_FLOAT lastLength; |
| 5574 | MY_FLOAT stretching; |
| 5575 | MY_FLOAT pluckAmplitude; |
| 5576 | MY_FLOAT pickupPosition; |
| 5577 | |
| 5578 | }; |
| 5579 | |
| 5580 | #endif |
| 5581 | |
| 5582 | |
| 5583 | |
| 5584 | |
| 5585 | /***************************************************/ |
| 5586 | /*! \class Table |
| 5587 | \brief STK table lookup class. |
| 5588 | |
| 5589 | This class loads a table of floating-point |
| 5590 | doubles, which are assumed to be in big-endian |
| 5591 | format. Linear interpolation is performed for |
| 5592 | fractional lookup indexes. |
| 5593 | |
| 5594 | An StkError will be thrown if the table file |
| 5595 | is not found. |
| 5596 | |
| 5597 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5598 | */ |
| 5599 | /***************************************************/ |
| 5600 | |
| 5601 | #if !defined(__TABLE_H) |
| 5602 | #define __TABLE_H |
| 5603 | |
| 5604 | |
| 5605 | class Table : public Stk |
| 5606 | { |
| 5607 | public: |
| 5608 | //! Constructor loads the data from \e fileName. |
| 5609 | Table(char *fileName); |
| 5610 | |
| 5611 | //! Class destructor. |
| 5612 | ~Table(); |
| 5613 | |
| 5614 | //! Return the number of elements in the table. |
| 5615 | long getLength() const; |
| 5616 | |
| 5617 | //! Return the last output value. |
| 5618 | MY_FLOAT lastOut() const; |
| 5619 | |
| 5620 | //! Return the table value at position \e index. |
| 5621 | /*! |
| 5622 | Linear interpolation is performed if \e index is |
| 5623 | fractional. |
| 5624 | */ |
| 5625 | MY_FLOAT tick(MY_FLOAT index); |
| 5626 | |
| 5627 | //! Take \e vectorSize index positions and return the corresponding table values in \e vector. |
| 5628 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 5629 | |
| 5630 | public: // SWAP formerly protected |
| 5631 | long length; |
| 5632 | MY_FLOAT *data; |
| 5633 | MY_FLOAT lastOutput; |
| 5634 | |
| 5635 | }; |
| 5636 | |
| 5637 | #endif // defined(__TABLE_H) |
| 5638 | |
| 5639 | |
| 5640 | |
| 5641 | |
| 5642 | /***************************************************/ |
| 5643 | /*! \class WvOut |
| 5644 | \brief STK audio data output base class. |
| 5645 | |
| 5646 | This class provides output support for various |
| 5647 | audio file formats. It also serves as a base |
| 5648 | class for "realtime" streaming subclasses. |
| 5649 | |
| 5650 | WvOut writes samples to an audio file. It |
| 5651 | supports multi-channel data in interleaved |
| 5652 | format. It is important to distinguish the |
| 5653 | tick() methods, which output single samples |
| 5654 | to all channels in a sample frame, from the |
| 5655 | tickFrame() method, which takes a pointer |
| 5656 | to multi-channel sample frame data. |
| 5657 | |
| 5658 | WvOut currently supports WAV, AIFF, AIFC, SND |
| 5659 | (AU), MAT-file (Matlab), and STK RAW file |
| 5660 | formats. Signed integer (8-, 16-, and 32-bit) |
| 5661 | and floating- point (32- and 64-bit) data types |
| 5662 | are supported. STK RAW files use 16-bit |
| 5663 | integers by definition. MAT-files will always |
| 5664 | be written as 64-bit floats. If a data type |
| 5665 | specification does not match the specified file |
| 5666 | type, the data type will automatically be |
| 5667 | modified. Uncompressed data types are not |
| 5668 | supported. |
| 5669 | |
| 5670 | Currently, WvOut is non-interpolating and the |
| 5671 | output rate is always Stk::sampleRate(). |
| 5672 | |
| 5673 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5674 | */ |
| 5675 | /***************************************************/ |
| 5676 | |
| 5677 | #if !defined(__WVOUT_H) |
| 5678 | #define __WVOUT_H |
| 5679 | |
| 5680 | |
| 5681 | #ifndef __DISABLE_WVOUT__ |
| 5682 | #include <stdio.h> |
| 5683 | #ifndef __DISABLE_THREADS__ |
| 5684 | #include "util_thread.h" |
| 5685 | #endif |
| 5686 | |
| 5687 | #define BUFFER_SIZE 1024 // sample frames |
| 5688 | |
| 5689 | class WvOut : public Stk |
| 5690 | { |
| 5691 | public: |
| 5692 | |
| 5693 | typedef unsigned long FILE_TYPE; |
| 5694 | |
| 5695 | static const FILE_TYPE WVOUT_RAW; /*!< STK RAW file type. */ |
| 5696 | static const FILE_TYPE WVOUT_WAV; /*!< WAV file type. */ |
| 5697 | static const FILE_TYPE WVOUT_SND; /*!< SND (AU) file type. */ |
| 5698 | static const FILE_TYPE WVOUT_AIF; /*!< AIFF file type. */ |
| 5699 | static const FILE_TYPE WVOUT_MAT; /*!< Matlab MAT-file type. */ |
| 5700 | |
| 5701 | // chuck: override stdio fwrite/etc. functions |
| 5702 | size_t fwrite(const void * ptr, size_t size, size_t nitems, FILE * stream); |
| 5703 | int fseek(FILE *stream, long offset, int whence); |
| 5704 | int fflush(FILE *stream); |
| 5705 | int fclose(FILE *stream); |
| 5706 | size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream); |
| 5707 | |
| 5708 | //! Default constructor. |
| 5709 | WvOut(); |
| 5710 | |
| 5711 | //! Overloaded constructor used to specify a file name, type, and data format with this object. |
| 5712 | /*! |
| 5713 | An StkError is thrown for invalid argument values or if an error occurs when initializing the output file. |
| 5714 | */ |
| 5715 | WvOut( const char *fileName, unsigned int nChannels = 1, FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT format = STK_SINT16 ); |
| 5716 | |
| 5717 | //! Class destructor. |
| 5718 | virtual ~WvOut(); |
| 5719 | |
| 5720 | //! Create a file of the specified type and name and output samples to it in the given data format. |
| 5721 | /*! |
| 5722 | An StkError is thrown for invalid argument values or if an error occurs when initializing the output file. |
| 5723 | */ |
| 5724 | void openFile( const char *fileName, unsigned int nChannels = 1, \ |
| 5725 | WvOut::FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT = STK_SINT16 ); |
| 5726 | //! If a file is open, write out samples in the queue and then close it. |
| 5727 | void closeFile( void ); |
| 5728 | |
| 5729 | //! Return the number of sample frames output. |
| 5730 | unsigned long getFrames( void ) const; |
| 5731 | |
| 5732 | //! Return the number of seconds of data output. |
| 5733 | MY_FLOAT getTime( void ) const; |
| 5734 | |
| 5735 | //! Output a single sample to all channels in a sample frame. |
| 5736 | /*! |
| 5737 | An StkError is thrown if a file write error occurs. |
| 5738 | */ |
| 5739 | virtual void tick(const MY_FLOAT sample); |
| 5740 | |
| 5741 | //! Output each sample in \e vector to all channels in \e vectorSize sample frames. |
| 5742 | /*! |
| 5743 | An StkError is thrown if a file write error occurs. |
| 5744 | */ |
| 5745 | virtual void tick(const MY_FLOAT *vector, unsigned int vectorSize); |
| 5746 | |
| 5747 | //! Output the \e frameVector of sample frames of the given length. |
| 5748 | /*! |
| 5749 | An StkError is thrown if a file write error occurs. |
| 5750 | */ |
| 5751 | virtual void tickFrame(const MY_FLOAT *frameVector, unsigned int frames = 1); |
| 5752 | |
| 5753 | public: // SWAP formerly protected |
| 5754 | |
| 5755 | // Initialize class variables. |
| 5756 | void init( void ); |
| 5757 | |
| 5758 | // Write data to output file; |
| 5759 | virtual void writeData( unsigned long frames ); |
| 5760 | |
| 5761 | // Write STK RAW file header. |
| 5762 | bool setRawFile( const char *fileName ); |
| 5763 | |
| 5764 | // Write WAV file header. |
| 5765 | bool setWavFile( const char *fileName ); |
| 5766 | |
| 5767 | // Close WAV file, updating the header. |
| 5768 | void closeWavFile( void ); |
| 5769 | |
| 5770 | // Write SND (AU) file header. |
| 5771 | bool setSndFile( const char *fileName ); |
| 5772 | |
| 5773 | // Close SND file, updating the header. |
| 5774 | void closeSndFile( void ); |
| 5775 | |
| 5776 | // Write AIFF file header. |
| 5777 | bool setAifFile( const char *fileName ); |
| 5778 | |
| 5779 | // Close AIFF file, updating the header. |
| 5780 | void closeAifFile( void ); |
| 5781 | |
| 5782 | // Write MAT-file header. |
| 5783 | bool setMatFile( const char *fileName ); |
| 5784 | |
| 5785 | // Close MAT-file, updating the header. |
| 5786 | void closeMatFile( void ); |
| 5787 | |
| 5788 | char msg[STK_MSG_BUF_LENGTH]; |
| 5789 | FILE *fd; |
| 5790 | MY_FLOAT *data; |
| 5791 | FILE_TYPE fileType; |
| 5792 | STK_FORMAT dataType; |
| 5793 | bool byteswap; |
| 5794 | unsigned int channels; |
| 5795 | unsigned long counter; |
| 5796 | unsigned long totalCount; |
| 5797 | // char m_filename[1024]; |
| 5798 | // Chuck_String str_filename; |
| 5799 | // NOTE: all Chuck_Objects needs heap allocation using 'new' |
| 5800 | // since reference counting automatically calls 'delete' |
| 5801 | std::string str_filename; |
| 5802 | // char autoPrefix[1024]; |
| 5803 | // Chuck_String autoPrefix; |
| 5804 | std::string autoPrefix; |
| 5805 | t_CKUINT start; |
| 5806 | t_CKUINT flush; |
| 5807 | t_CKFLOAT fileGain; |
| 5808 | |
| 5809 | // spencer: for data asynch write |
| 5810 | t_CKBOOL asyncIO; |
| 5811 | XWriteThread * asyncWriteThread; |
| 5812 | }; |
| 5813 | #endif // __DISABLED_WVOUT__ |
| 5814 | |
| 5815 | #endif // defined(__WVOUT_H) |
| 5816 | |
| 5817 | |
| 5818 | |
| 5819 | |
| 5820 | /***************************************************/ |
| 5821 | /*! \class TubeBell |
| 5822 | \brief STK tubular bell (orchestral chime) FM |
| 5823 | synthesis instrument. |
| 5824 | |
| 5825 | This class implements two simple FM Pairs |
| 5826 | summed together, also referred to as algorithm |
| 5827 | 5 of the TX81Z. |
| 5828 | |
| 5829 | \code |
| 5830 | Algorithm 5 is : 4->3--\ |
| 5831 | + --> Out |
| 5832 | 2->1--/ |
| 5833 | \endcode |
| 5834 | |
| 5835 | Control Change Numbers: |
| 5836 | - Modulator Index One = 2 |
| 5837 | - Crossfade of Outputs = 4 |
| 5838 | - LFO Speed = 11 |
| 5839 | - LFO Depth = 1 |
| 5840 | - ADSR 2 & 4 Target = 128 |
| 5841 | |
| 5842 | The basic Chowning/Stanford FM patent expired |
| 5843 | in 1995, but there exist follow-on patents, |
| 5844 | mostly assigned to Yamaha. If you are of the |
| 5845 | type who should worry about this (making |
| 5846 | money) worry away. |
| 5847 | |
| 5848 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5849 | */ |
| 5850 | /***************************************************/ |
| 5851 | |
| 5852 | #if !defined(__TUBEBELL_H) |
| 5853 | #define __TUBEBELL_H |
| 5854 | |
| 5855 | |
| 5856 | class TubeBell : public FM |
| 5857 | { |
| 5858 | public: |
| 5859 | //! Class constructor. |
| 5860 | TubeBell(); |
| 5861 | |
| 5862 | //! Class destructor. |
| 5863 | ~TubeBell(); |
| 5864 | |
| 5865 | //! Start a note with the given frequency and amplitude. |
| 5866 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 5867 | void noteOn( MY_FLOAT amplitude) { noteOn(baseFrequency, amplitude); } |
| 5868 | |
| 5869 | //! Compute one output sample. |
| 5870 | MY_FLOAT tick(); |
| 5871 | }; |
| 5872 | |
| 5873 | #endif |
| 5874 | |
| 5875 | |
| 5876 | |
| 5877 | |
| 5878 | /***************************************************/ |
| 5879 | /*! \class TwoPole |
| 5880 | \brief STK two-pole filter class. |
| 5881 | |
| 5882 | This protected Filter subclass implements |
| 5883 | a two-pole digital filter. A method is |
| 5884 | provided for creating a resonance in the |
| 5885 | frequency response while maintaining a nearly |
| 5886 | constant filter gain. |
| 5887 | |
| 5888 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5889 | */ |
| 5890 | /***************************************************/ |
| 5891 | |
| 5892 | #if !defined(__TWOPOLE_H) |
| 5893 | #define __TWOPOLE_H |
| 5894 | |
| 5895 | |
| 5896 | class TwoPole : public FilterStk // formerly protected Filter |
| 5897 | { |
| 5898 | public: |
| 5899 | |
| 5900 | //! Default constructor creates a second-order pass-through filter. |
| 5901 | TwoPole(); |
| 5902 | |
| 5903 | //! Class destructor. |
| 5904 | ~TwoPole(); |
| 5905 | |
| 5906 | //! Clears the internal states of the filter. |
| 5907 | void clear(void); |
| 5908 | |
| 5909 | //! Set the b[0] coefficient value. |
| 5910 | void setB0(MY_FLOAT b0); |
| 5911 | |
| 5912 | //! Set the a[1] coefficient value. |
| 5913 | void setA1(MY_FLOAT a1); |
| 5914 | |
| 5915 | //! Set the a[2] coefficient value. |
| 5916 | void setA2(MY_FLOAT a2); |
| 5917 | |
| 5918 | //! Sets the filter coefficients for a resonance at \e frequency (in Hz). |
| 5919 | /*! |
| 5920 | This method determines the filter coefficients corresponding to |
| 5921 | two complex-conjugate poles with the given \e frequency (in Hz) |
| 5922 | and \e radius from the z-plane origin. If \e normalize is true, |
| 5923 | the coefficients are then normalized to produce unity gain at \e |
| 5924 | frequency (the actual maximum filter gain tends to be slightly |
| 5925 | greater than unity when \e radius is not close to one). The |
| 5926 | resulting filter frequency response has a resonance at the given |
| 5927 | \e frequency. The closer the poles are to the unit-circle (\e |
| 5928 | radius close to one), the narrower the resulting resonance width. |
| 5929 | An unstable filter will result for \e radius >= 1.0. For a better |
| 5930 | resonance filter, use a BiQuad filter. \sa BiQuad filter class |
| 5931 | */ |
| 5932 | void setResonance(MY_FLOAT frequency, MY_FLOAT radius, bool normalize = FALSE); |
| 5933 | |
| 5934 | bool m_resNorm; |
| 5935 | MY_FLOAT m_resFreq; |
| 5936 | MY_FLOAT m_resRad; |
| 5937 | |
| 5938 | void ck_setResNorm( bool n ) { m_resNorm = n; setResonance(m_resFreq, m_resRad, m_resNorm); } |
| 5939 | void ck_setResFreq( MY_FLOAT n ) { m_resFreq = n; setResonance(m_resFreq, m_resRad, m_resNorm); } |
| 5940 | void ck_setResRad( MY_FLOAT n ) { m_resRad = n; setResonance(m_resFreq, m_resRad, m_resNorm); } |
| 5941 | //! Set the filter gain. |
| 5942 | /*! |
| 5943 | The gain is applied at the filter input and does not affect the |
| 5944 | coefficient values. The default gain value is 1.0. |
| 5945 | */ |
| 5946 | void setGain(MY_FLOAT theGain); |
| 5947 | |
| 5948 | //! Return the current filter gain. |
| 5949 | MY_FLOAT getGain(void) const; |
| 5950 | |
| 5951 | //! Return the last computed output value. |
| 5952 | MY_FLOAT lastOut(void) const; |
| 5953 | |
| 5954 | //! Input one sample to the filter and return one output. |
| 5955 | MY_FLOAT tick(MY_FLOAT sample); |
| 5956 | |
| 5957 | //! Input \e vectorSize samples to the filter and return an equal number of outputs in \e vector. |
| 5958 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 5959 | }; |
| 5960 | |
| 5961 | #endif |
| 5962 | |
| 5963 | |
| 5964 | |
| 5965 | |
| 5966 | /***************************************************/ |
| 5967 | /*! \class VoicForm |
| 5968 | \brief Four formant synthesis instrument. |
| 5969 | |
| 5970 | This instrument contains an excitation singing |
| 5971 | wavetable (looping wave with random and |
| 5972 | periodic vibrato, smoothing on frequency, |
| 5973 | etc.), excitation noise, and four sweepable |
| 5974 | complex resonances. |
| 5975 | |
| 5976 | Measured formant data is included, and enough |
| 5977 | data is there to support either parallel or |
| 5978 | cascade synthesis. In the floating point case |
| 5979 | cascade synthesis is the most natural so |
| 5980 | that's what you'll find here. |
| 5981 | |
| 5982 | Control Change Numbers: |
| 5983 | - Voiced/Unvoiced Mix = 2 |
| 5984 | - Vowel/Phoneme Selection = 4 |
| 5985 | - Vibrato Frequency = 11 |
| 5986 | - Vibrato Gain = 1 |
| 5987 | - Loudness (Spectral Tilt) = 128 |
| 5988 | |
| 5989 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 5990 | */ |
| 5991 | /***************************************************/ |
| 5992 | #if !defined(__VOICFORM_H) |
| 5993 | #define __VOICFORM_H |
| 5994 | |
| 5995 | |
| 5996 | class VoicForm : public Instrmnt |
| 5997 | { |
| 5998 | public: |
| 5999 | //! Class constructor, taking the lowest desired playing frequency. |
| 6000 | VoicForm(); |
| 6001 | |
| 6002 | //! Class destructor. |
| 6003 | ~VoicForm(); |
| 6004 | |
| 6005 | //! Reset and clear all internal state. |
| 6006 | void clear(); |
| 6007 | |
| 6008 | //! Set instrument parameters for a particular frequency. |
| 6009 | void setFrequency(MY_FLOAT frequency); |
| 6010 | |
| 6011 | //! Set instrument parameters for the given phoneme. Returns FALSE if phoneme not found. |
| 6012 | bool setPhoneme(const char* phoneme); |
| 6013 | |
| 6014 | //! Set the voiced component gain. |
| 6015 | void setVoiced(MY_FLOAT vGain); |
| 6016 | |
| 6017 | //! Set the unvoiced component gain. |
| 6018 | void setUnVoiced(MY_FLOAT nGain); |
| 6019 | |
| 6020 | //! Set the sweep rate for a particular formant filter (0-3). |
| 6021 | void setFilterSweepRate(int whichOne, MY_FLOAT rate); |
| 6022 | |
| 6023 | //! Set voiced component pitch sweep rate. |
| 6024 | void setPitchSweepRate(MY_FLOAT rate); |
| 6025 | |
| 6026 | //! Start the voice. |
| 6027 | void speak(); |
| 6028 | |
| 6029 | //! Stop the voice. |
| 6030 | void quiet(); |
| 6031 | |
| 6032 | //! Start a note with the given frequency and amplitude. |
| 6033 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 6034 | //! start at current frequency.. |
| 6035 | void noteOn( MY_FLOAT amplitude); |
| 6036 | |
| 6037 | //! Stop a note with the given amplitude (speed of decay). |
| 6038 | void noteOff(MY_FLOAT amplitude); |
| 6039 | |
| 6040 | //! Compute one output sample. |
| 6041 | MY_FLOAT tick(); |
| 6042 | |
| 6043 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 6044 | void controlChange(int number, MY_FLOAT value); |
| 6045 | |
| 6046 | public: // SWAP formerly protected |
| 6047 | int m_phonemeNum; |
| 6048 | SingWave *voiced; |
| 6049 | Noise *noise; |
| 6050 | Envelope *noiseEnv; |
| 6051 | FormSwep *filters[4]; |
| 6052 | OnePole *onepole; |
| 6053 | OneZero *onezero; |
| 6054 | // Chuck_String str_phoneme; // chuck data |
| 6055 | // NOTE: all Chuck_Objects needs heap allocation using 'new' |
| 6056 | // since reference counting automatically calls 'delete' |
| 6057 | std::string str_phoneme; |
| 6058 | }; |
| 6059 | |
| 6060 | #endif |
| 6061 | |
| 6062 | |
| 6063 | |
| 6064 | |
| 6065 | /***************************************************/ |
| 6066 | /*! \class Voicer |
| 6067 | \brief STK voice manager class. |
| 6068 | |
| 6069 | This class can be used to manage a group of |
| 6070 | STK instrument classes. Individual voices can |
| 6071 | be controlled via unique note tags. |
| 6072 | Instrument groups can be controlled by channel |
| 6073 | number. |
| 6074 | |
| 6075 | A previously constructed STK instrument class |
| 6076 | is linked with a voice manager using the |
| 6077 | addInstrument() function. An optional channel |
| 6078 | number argument can be specified to the |
| 6079 | addInstrument() function as well (default |
| 6080 | channel = 0). The voice manager does not |
| 6081 | delete any instrument instances ... it is the |
| 6082 | responsibility of the user to allocate and |
| 6083 | deallocate all instruments. |
| 6084 | |
| 6085 | The tick() function returns the mix of all |
| 6086 | sounding voices. Each noteOn returns a unique |
| 6087 | tag (credits to the NeXT MusicKit), so you can |
| 6088 | send control changes to specific voices within |
| 6089 | an ensemble. Alternately, control changes can |
| 6090 | be sent to all voices on a given channel. |
| 6091 | |
| 6092 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 6093 | */ |
| 6094 | /***************************************************/ |
| 6095 | |
| 6096 | #if !defined(__VOICER_H) |
| 6097 | #define __VOICER_H |
| 6098 | |
| 6099 | |
| 6100 | class Voicer : public Stk |
| 6101 | { |
| 6102 | public: |
| 6103 | //! Class constructor taking the maximum number of instruments to control and an optional note decay time (in seconds). |
| 6104 | Voicer( int maxInstruments, MY_FLOAT decayTime=0.2 ); |
| 6105 | |
| 6106 | //! Class destructor. |
| 6107 | ~Voicer(); |
| 6108 | |
| 6109 | //! Add an instrument with an optional channel number to the voice manager. |
| 6110 | /*! |
| 6111 | A set of instruments can be grouped by channel number and |
| 6112 | controlled via the functions which take a channel number argument. |
| 6113 | */ |
| 6114 | void addInstrument( Instrmnt *instrument, int channel=0 ); |
| 6115 | |
| 6116 | //! Remove the given instrument pointer from the voice manager's control. |
| 6117 | /*! |
| 6118 | It is important that any instruments which are to be deleted by |
| 6119 | the user while the voice manager is running be first removed from |
| 6120 | the manager's control via this function!! |
| 6121 | */ |
| 6122 | void removeInstrument( Instrmnt *instrument ); |
| 6123 | |
| 6124 | //! Initiate a noteOn event with the given note number and amplitude and return a unique note tag. |
| 6125 | /*! |
| 6126 | Send the noteOn message to the first available unused voice. |
| 6127 | If all voices are sounding, the oldest voice is interrupted and |
| 6128 | sent the noteOn message. If the optional channel argument is |
| 6129 | non-zero, only voices on that channel are used. If no voices are |
| 6130 | found for a specified non-zero channel value, the function returns |
| 6131 | -1. The amplitude value should be in the range 0.0 - 128.0. |
| 6132 | */ |
| 6133 | long noteOn( MY_FLOAT noteNumber, MY_FLOAT amplitude, int channel=0 ); |
| 6134 | |
| 6135 | //! Send a noteOff to all voices having the given noteNumber and optional channel (default channel = 0). |
| 6136 | /*! |
| 6137 | The amplitude value should be in the range 0.0 - 128.0. |
| 6138 | */ |
| 6139 | void noteOff( MY_FLOAT noteNumber, MY_FLOAT amplitude, int channel=0 ); |
| 6140 | |
| 6141 | //! Send a noteOff to the voice with the given note tag. |
| 6142 | /*! |
| 6143 | The amplitude value should be in the range 0.0 - 128.0. |
| 6144 | */ |
| 6145 | void noteOff( long tag, MY_FLOAT amplitude ); |
| 6146 | |
| 6147 | //! Send a frequency update message to all voices assigned to the optional channel argument (default channel = 0). |
| 6148 | /*! |
| 6149 | The \e noteNumber argument corresponds to a MIDI note number, though it is a floating-point value and can range beyond the normal 0-127 range. |
| 6150 | */ |
| 6151 | void setFrequency( MY_FLOAT noteNumber, int channel=0 ); |
| 6152 | |
| 6153 | //! Send a frequency update message to the voice with the given note tag. |
| 6154 | /*! |
| 6155 | The \e noteNumber argument corresponds to a MIDI note number, though it is a floating-point value and can range beyond the normal 0-127 range. |
| 6156 | */ |
| 6157 | void setFrequency( long tag, MY_FLOAT noteNumber ); |
| 6158 | |
| 6159 | //! Send a pitchBend message to all voices assigned to the optional channel argument (default channel = 0). |
| 6160 | void pitchBend( MY_FLOAT value, int channel=0 ); |
| 6161 | |
| 6162 | //! Send a pitchBend message to the voice with the given note tag. |
| 6163 | void pitchBend( long tag, MY_FLOAT value ); |
| 6164 | |
| 6165 | //! Send a controlChange to all instruments assigned to the optional channel argument (default channel = 0). |
| 6166 | void controlChange( int number, MY_FLOAT value, int channel=0 ); |
| 6167 | |
| 6168 | //! Send a controlChange to the voice with the given note tag. |
| 6169 | void controlChange( long tag, int number, MY_FLOAT value ); |
| 6170 | |
| 6171 | //! Send a noteOff message to all existing voices. |
| 6172 | void silence( void ); |
| 6173 | |
| 6174 | //! Mix the output for all sounding voices. |
| 6175 | MY_FLOAT tick(); |
| 6176 | |
| 6177 | //! Compute \e vectorSize output mixes and return them in \e vector. |
| 6178 | MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); |
| 6179 | |
| 6180 | //! Return the last output value. |
| 6181 | MY_FLOAT lastOut() const; |
| 6182 | |
| 6183 | //! Return the last left output value. |
| 6184 | MY_FLOAT lastOutLeft() const; |
| 6185 | |
| 6186 | //! Return the last right output value. |
| 6187 | MY_FLOAT lastOutRight() const; |
| 6188 | |
| 6189 | public: // SWAP formerly protected |
| 6190 | |
| 6191 | typedef struct { |
| 6192 | Instrmnt *instrument; |
| 6193 | long tag; |
| 6194 | MY_FLOAT noteNumber; |
| 6195 | MY_FLOAT frequency; |
| 6196 | int sounding; |
| 6197 | int channel; |
| 6198 | } Voice; |
| 6199 | |
| 6200 | int nVoices; |
| 6201 | int maxVoices; |
| 6202 | Voice *voices; |
| 6203 | long tags; |
| 6204 | int muteTime; |
| 6205 | MY_FLOAT lastOutput; |
| 6206 | MY_FLOAT lastOutputLeft; |
| 6207 | MY_FLOAT lastOutputRight; |
| 6208 | }; |
| 6209 | |
| 6210 | #endif |
| 6211 | |
| 6212 | |
| 6213 | |
| 6214 | |
| 6215 | /***************************************************/ |
| 6216 | /*! \class Whistle |
| 6217 | \brief STK police/referee whistle instrument class. |
| 6218 | |
| 6219 | This class implements a hybrid physical/spectral |
| 6220 | model of a police whistle (a la Cook). |
| 6221 | |
| 6222 | Control Change Numbers: |
| 6223 | - Noise Gain = 4 |
| 6224 | - Fipple Modulation Frequency = 11 |
| 6225 | - Fipple Modulation Gain = 1 |
| 6226 | - Blowing Frequency Modulation = 2 |
| 6227 | - Volume = 128 |
| 6228 | |
| 6229 | by Perry R. Cook 1996 - 2002. |
| 6230 | */ |
| 6231 | /***************************************************/ |
| 6232 | |
| 6233 | #if !defined(__WHISTLE_H) |
| 6234 | #define __WHISTLE_H |
| 6235 | |
| 6236 | |
| 6237 | class Whistle : public Instrmnt |
| 6238 | { |
| 6239 | public: |
| 6240 | //! Class constructor. |
| 6241 | Whistle(); |
| 6242 | |
| 6243 | //! Class destructor. |
| 6244 | ~Whistle(); |
| 6245 | |
| 6246 | //! Reset and clear all internal state. |
| 6247 | void clear(); |
| 6248 | |
| 6249 | //! Set instrument parameters for a particular frequency. |
| 6250 | void setFrequency(MY_FLOAT frequency); |
| 6251 | |
| 6252 | //! Apply breath velocity to instrument with given amplitude and rate of increase. |
| 6253 | void startBlowing(MY_FLOAT amplitude, MY_FLOAT rate); |
| 6254 | |
| 6255 | //! Decrease breath velocity with given rate of decrease. |
| 6256 | void stopBlowing(MY_FLOAT rate); |
| 6257 | |
| 6258 | //! Start a note with the given frequency and amplitude. |
| 6259 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 6260 | |
| 6261 | //! Stop a note with the given amplitude (speed of decay). |
| 6262 | void noteOff(MY_FLOAT amplitude); |
| 6263 | |
| 6264 | //! Compute one output sample. |
| 6265 | MY_FLOAT tick(); |
| 6266 | |
| 6267 | //! Perform the control change specified by \e number and \e value (0.0 - 128.0). |
| 6268 | void controlChange(int number, MY_FLOAT value); |
| 6269 | |
| 6270 | public: // SWAP formerly protected |
| 6271 | Vector3D *tempVectorP; |
| 6272 | Vector3D *tempVector; |
| 6273 | OnePole onepole; |
| 6274 | Noise noise; |
| 6275 | Envelope envelope; |
| 6276 | Sphere *can; // Declare a Spherical "can". |
| 6277 | Sphere *pea, *bumper; // One spherical "pea", and a spherical "bumper". |
| 6278 | |
| 6279 | WaveLoop *sine; |
| 6280 | |
| 6281 | MY_FLOAT baseFrequency; |
| 6282 | MY_FLOAT maxPressure; |
| 6283 | MY_FLOAT noiseGain; |
| 6284 | MY_FLOAT fippleFreqMod; |
| 6285 | MY_FLOAT fippleGainMod; |
| 6286 | MY_FLOAT blowFreqMod; |
| 6287 | MY_FLOAT tickSize; |
| 6288 | MY_FLOAT canLoss; |
| 6289 | int subSample, subSampCount; |
| 6290 | }; |
| 6291 | |
| 6292 | #endif |
| 6293 | |
| 6294 | |
| 6295 | |
| 6296 | |
| 6297 | /***************************************************/ |
| 6298 | /*! \class Wurley |
| 6299 | \brief STK Wurlitzer electric piano FM |
| 6300 | synthesis instrument. |
| 6301 | |
| 6302 | This class implements two simple FM Pairs |
| 6303 | summed together, also referred to as algorithm |
| 6304 | 5 of the TX81Z. |
| 6305 | |
| 6306 | \code |
| 6307 | Algorithm 5 is : 4->3--\ |
| 6308 | + --> Out |
| 6309 | 2->1--/ |
| 6310 | \endcode |
| 6311 | |
| 6312 | Control Change Numbers: |
| 6313 | - Modulator Index One = 2 |
| 6314 | - Crossfade of Outputs = 4 |
| 6315 | - LFO Speed = 11 |
| 6316 | - LFO Depth = 1 |
| 6317 | - ADSR 2 & 4 Target = 128 |
| 6318 | |
| 6319 | The basic Chowning/Stanford FM patent expired |
| 6320 | in 1995, but there exist follow-on patents, |
| 6321 | mostly assigned to Yamaha. If you are of the |
| 6322 | type who should worry about this (making |
| 6323 | money) worry away. |
| 6324 | |
| 6325 | by Perry R. Cook and Gary P. Scavone, 1995 - 2002. |
| 6326 | */ |
| 6327 | /***************************************************/ |
| 6328 | |
| 6329 | #if !defined(__WURLEY_H) |
| 6330 | #define __WURLEY_H |
| 6331 | |
| 6332 | |
| 6333 | class Wurley : public FM |
| 6334 | { |
| 6335 | public: |
| 6336 | //! Class constructor. |
| 6337 | Wurley(); |
| 6338 | |
| 6339 | //! Class destructor. |
| 6340 | ~Wurley(); |
| 6341 | |
| 6342 | //! Set instrument parameters for a particular frequency. |
| 6343 | void setFrequency(MY_FLOAT frequency); |
| 6344 | |
| 6345 | //! Start a note with the given frequency and amplitude. |
| 6346 | void noteOn(MY_FLOAT frequency, MY_FLOAT amplitude); |
| 6347 | void noteOn(MY_FLOAT amplitude) { noteOn ( baseFrequency, amplitude ); } |
| 6348 | |
| 6349 | // CHUCK HACK: |
| 6350 | virtual void controlChange( int which, MY_FLOAT value ); |
| 6351 | |
| 6352 | //! Compute one output sample. |
| 6353 | MY_FLOAT tick(); |
| 6354 | }; |
| 6355 | |
| 6356 | #endif |
| 6357 | |
| 6358 | |
| 6359 | |
| 6360 | |
| 6361 | /***************************************************/ |
| 6362 | /*! \class Blit |
| 6363 | \brief STK band-limited impulse train class. |
| 6364 | |
| 6365 | This class generates a band-limited impulse train using a |
| 6366 | closed-form algorithm reported by Stilson and Smith in "Alias-Free |
| 6367 | Digital Synthesis of Classic Analog Waveforms", 1996. The user |
| 6368 | can specify both the fundamental frequency of the impulse train |
| 6369 | and the number of harmonics contained in the resulting signal. |
| 6370 | |
| 6371 | The signal is normalized so that the peak value is +/-1.0. |
| 6372 | |
| 6373 | If nHarmonics is 0, then the signal will contain all harmonics up |
| 6374 | to half the sample rate. Note, however, that this setting may |
| 6375 | produce aliasing in the signal when the frequency is changing (no |
| 6376 | automatic modification of the number of harmonics is performed by |
| 6377 | the setFrequency() function). |
| 6378 | |
| 6379 | Original code by Robin Davies, 2005. |
| 6380 | Revisions by Gary Scavone for STK, 2005. |
| 6381 | */ |
| 6382 | /***************************************************/ |
| 6383 | |
| 6384 | class BLT |
| 6385 | { |
| 6386 | public: |
| 6387 | virtual ~BLT() {} |
| 6388 | |
| 6389 | virtual void setPhase( MY_FLOAT phase ) = 0; |
| 6390 | virtual void setFrequency( MY_FLOAT freq ) = 0; |
| 6391 | virtual void setHarmonics( unsigned int harmonics ) = 0; |
| 6392 | |
| 6393 | t_CKFLOAT getValuePhase() { return m_phase; } |
| 6394 | t_CKFLOAT getValueFreq() { return m_freq; } |
| 6395 | t_CKINT getValueHarmonics() { return m_harmonics; } |
| 6396 | |
| 6397 | public: |
| 6398 | t_CKFLOAT m_phase; |
| 6399 | t_CKFLOAT m_freq; |
| 6400 | t_CKINT m_harmonics; |
| 6401 | }; |
| 6402 | |
| 6403 | #ifndef STK_BLIT_H |
| 6404 | #define STK_BLIT_H |
| 6405 | |
| 6406 | |
| 6407 | class Blit : public BLT |
| 6408 | { |
| 6409 | public: |
| 6410 | //! Default constructor that initializes BLIT frequency to 220 Hz. |
| 6411 | Blit( MY_FLOAT frequency = 220.0 ); |
| 6412 | |
| 6413 | //! Class destructor. |
| 6414 | virtual ~Blit(); |
| 6415 | |
| 6416 | //! Resets the oscillator state and phase to 0. |
| 6417 | void reset(); |
| 6418 | |
| 6419 | //! Set the phase of the signal. |
| 6420 | /*! |
| 6421 | Set the phase of the signal, in the range 0 to 1. |
| 6422 | */ |
| 6423 | virtual void setPhase( MY_FLOAT phase ) { phase_ = CK_ONE_PI * phase; } |
| 6424 | |
| 6425 | //! Get the current phase of the signal. |
| 6426 | /*! |
| 6427 | Get the phase of the signal, in the range [0 to 1.0). |
| 6428 | */ |
| 6429 | MY_FLOAT getPhase() const { return phase_ / CK_ONE_PI; } |
| 6430 | |
| 6431 | //! Set the impulse train rate in terms of a frequency in Hz. |
| 6432 | virtual void setFrequency( MY_FLOAT frequency ); |
| 6433 | |
| 6434 | //! Set the number of harmonics generated in the signal. |
| 6435 | /*! |
| 6436 | This function sets the number of harmonics contained in the |
| 6437 | resulting signal. It is equivalent to (2 * M) + 1 in the BLIT |
| 6438 | algorithm. The default value of 0 sets the algorithm for maximum |
| 6439 | harmonic content (harmonics up to half the sample rate). This |
| 6440 | parameter is not checked against the current sample rate and |
| 6441 | fundamental frequency. Thus, aliasing can result if one or more |
| 6442 | harmonics for a given fundamental frequency exceeds fs / 2. This |
| 6443 | behavior was chosen over the potentially more problematic solution |
| 6444 | of automatically modifying the M parameter, which can produce |
| 6445 | audible clicks in the signal. |
| 6446 | */ |
| 6447 | virtual void setHarmonics( unsigned int nHarmonics = 0 ); |
| 6448 | |
| 6449 | //! Compute one output sample. |
| 6450 | MY_FLOAT tick(); |
| 6451 | |
| 6452 | protected: |
| 6453 | |
| 6454 | void updateHarmonics( void ); |
| 6455 | MY_FLOAT computeSample( void ); |
| 6456 | |
| 6457 | unsigned int nHarmonics_; |
| 6458 | unsigned int m_; |
| 6459 | MY_FLOAT rate_; |
| 6460 | MY_FLOAT phase_; |
| 6461 | MY_FLOAT p_; |
| 6462 | |
| 6463 | }; |
| 6464 | |
| 6465 | #endif |
| 6466 | |
| 6467 | |
| 6468 | |
| 6469 | |
| 6470 | /***************************************************/ |
| 6471 | /*! \class BlitSaw |
| 6472 | \brief STK band-limited sawtooth wave class. |
| 6473 | |
| 6474 | This class generates a band-limited sawtooth waveform using a |
| 6475 | closed-form algorithm reported by Stilson and Smith in "Alias-Free |
| 6476 | Digital Synthesis of Classic Analog Waveforms", 1996. The user |
| 6477 | can specify both the fundamental frequency of the sawtooth and the |
| 6478 | number of harmonics contained in the resulting signal. |
| 6479 | |
| 6480 | If nHarmonics is 0, then the signal will contain all harmonics up |
| 6481 | to half the sample rate. Note, however, that this setting may |
| 6482 | produce aliasing in the signal when the frequency is changing (no |
| 6483 | automatic modification of the number of harmonics is performed by |
| 6484 | the setFrequency() function). |
| 6485 | |
| 6486 | Based on initial code of Robin Davies, 2005. |
| 6487 | Modified algorithm code by Gary Scavone, 2005. |
| 6488 | */ |
| 6489 | /***************************************************/ |
| 6490 | |
| 6491 | #ifndef STK_BLITSAW_H |
| 6492 | #define STK_BLITSAW_H |
| 6493 | |
| 6494 | class BlitSaw : public BLT |
| 6495 | { |
| 6496 | public: |
| 6497 | //! Class constructor. |
| 6498 | BlitSaw( MY_FLOAT frequency = 220.0 ); |
| 6499 | |
| 6500 | //! Class destructor. |
| 6501 | virtual ~BlitSaw(); |
| 6502 | |
| 6503 | //! Resets the oscillator state and phase to 0. |
| 6504 | void reset(); |
| 6505 | |
| 6506 | //! Set the phase of the signal. |
| 6507 | /*! |
| 6508 | Set the phase of the signal, in the range 0 to 1. |
| 6509 | */ |
| 6510 | virtual void setPhase( MY_FLOAT phase ) { phase_ = CK_ONE_PI * phase; } |
| 6511 | |
| 6512 | //! Set the sawtooth oscillator rate in terms of a frequency in Hz. |
| 6513 | virtual void setFrequency( MY_FLOAT frequency ); |
| 6514 | |
| 6515 | //! Set the number of harmonics generated in the signal. |
| 6516 | /*! |
| 6517 | This function sets the number of harmonics contained in the |
| 6518 | resulting signal. It is equivalent to (2 * M) + 1 in the BLIT |
| 6519 | algorithm. The default value of 0 sets the algorithm for maximum |
| 6520 | harmonic content (harmonics up to half the sample rate). This |
| 6521 | parameter is not checked against the current sample rate and |
| 6522 | fundamental frequency. Thus, aliasing can result if one or more |
| 6523 | harmonics for a given fundamental frequency exceeds fs / 2. This |
| 6524 | behavior was chosen over the potentially more problematic solution |
| 6525 | of automatically modifying the M parameter, which can produce |
| 6526 | audible clicks in the signal. |
| 6527 | */ |
| 6528 | virtual void setHarmonics( unsigned int nHarmonics = 0 ); |
| 6529 | |
| 6530 | //! Compute one output sample. |
| 6531 | MY_FLOAT tick(); |
| 6532 | |
| 6533 | protected: |
| 6534 | |
| 6535 | void updateHarmonics( void ); |
| 6536 | MY_FLOAT computeSample( void ); |
| 6537 | |
| 6538 | unsigned int nHarmonics_; |
| 6539 | unsigned int m_; |
| 6540 | MY_FLOAT rate_; |
| 6541 | MY_FLOAT phase_; |
| 6542 | MY_FLOAT p_; |
| 6543 | MY_FLOAT C2_; |
| 6544 | MY_FLOAT a_; |
| 6545 | MY_FLOAT state_; |
| 6546 | |
| 6547 | }; |
| 6548 | |
| 6549 | #endif |
| 6550 | |
| 6551 | |
| 6552 | |
| 6553 | |
| 6554 | /***************************************************/ |
| 6555 | /*! \class BlitSquare |
| 6556 | \brief STK band-limited square wave class. |
| 6557 | |
| 6558 | This class generates a band-limited square wave signal. It is |
| 6559 | derived in part from the approach reported by Stilson and Smith in |
| 6560 | "Alias-Free Digital Synthesis of Classic Analog Waveforms", 1996. |
| 6561 | The algorithm implemented in this class uses a SincM function with |
| 6562 | an even M value to achieve a bipolar bandlimited impulse train. |
| 6563 | This signal is then integrated to achieve a square waveform. The |
| 6564 | integration process has an associated DC offset but that is |
| 6565 | subtracted off the output signal. |
| 6566 | |
| 6567 | The user can specify both the fundamental frequency of the |
| 6568 | waveform and the number of harmonics contained in the resulting |
| 6569 | signal. |
| 6570 | |
| 6571 | If nHarmonics is 0, then the signal will contain all harmonics up |
| 6572 | to half the sample rate. Note, however, that this setting may |
| 6573 | produce aliasing in the signal when the frequency is changing (no |
| 6574 | automatic modification of the number of harmonics is performed by |
| 6575 | the setFrequency() function). |
| 6576 | |
| 6577 | Based on initial code of Robin Davies, 2005. |
| 6578 | Modified algorithm code by Gary Scavone, 2005. |
| 6579 | */ |
| 6580 | /***************************************************/ |
| 6581 | |
| 6582 | #ifndef STK_BLITSQUARE_H |
| 6583 | #define STK_BLITSQUARE_H |
| 6584 | |
| 6585 | class BlitSquare : public BLT |
| 6586 | { |
| 6587 | public: |
| 6588 | //! Default constructor that initializes BLIT frequency to 220 Hz. |
| 6589 | BlitSquare( MY_FLOAT frequency = 220.0 ); |
| 6590 | |
| 6591 | //! Class destructor. |
| 6592 | virtual ~BlitSquare(); |
| 6593 | |
| 6594 | //! Resets the oscillator state and phase to 0. |
| 6595 | void reset(); |
| 6596 | |
| 6597 | //! Set the phase of the signal. |
| 6598 | /*! |
| 6599 | Set the phase of the signal, in the range 0 to 1. |
| 6600 | */ |
| 6601 | virtual void setPhase( MY_FLOAT phase ) { phase_ = CK_ONE_PI * phase; } |
| 6602 | |
| 6603 | //! Get the current phase of the signal. |
| 6604 | /*! |
| 6605 | Get the phase of the signal, in the range [0 to 1.0). |
| 6606 | */ |
| 6607 | MY_FLOAT getPhase() const { return phase_ / CK_ONE_PI; } |
| 6608 | |
| 6609 | //! Set the impulse train rate in terms of a frequency in Hz. |
| 6610 | virtual void setFrequency( MY_FLOAT frequency ); |
| 6611 | |
| 6612 | //! Set the number of harmonics generated in the signal. |
| 6613 | /*! |
| 6614 | This function sets the number of harmonics contained in the |
| 6615 | resulting signal. It is equivalent to (2 * M) + 1 in the BLIT |
| 6616 | algorithm. The default value of 0 sets the algorithm for maximum |
| 6617 | harmonic content (harmonics up to half the sample rate). This |
| 6618 | parameter is not checked against the current sample rate and |
| 6619 | fundamental frequency. Thus, aliasing can result if one or more |
| 6620 | harmonics for a given fundamental frequency exceeds fs / 2. This |
| 6621 | behavior was chosen over the potentially more problematic solution |
| 6622 | of automatically modifying the M parameter, which can produce |
| 6623 | audible clicks in the signal. |
| 6624 | */ |
| 6625 | virtual void setHarmonics( unsigned int nHarmonics = 0 ); |
| 6626 | |
| 6627 | //! Compute one output sample. |
| 6628 | MY_FLOAT tick(); |
| 6629 | |
| 6630 | protected: |
| 6631 | |
| 6632 | void updateHarmonics( void ); |
| 6633 | MY_FLOAT computeSample( void ); |
| 6634 | |
| 6635 | unsigned int nHarmonics_; |
| 6636 | unsigned int m_; |
| 6637 | MY_FLOAT rate_; |
| 6638 | MY_FLOAT phase_; |
| 6639 | MY_FLOAT a_; |
| 6640 | MY_FLOAT p_; |
| 6641 | MY_FLOAT offset_; |
| 6642 | MY_FLOAT m_boutput; |
| 6643 | MY_FLOAT m_output; |
| 6644 | MY_FLOAT dcbState_; |
| 6645 | }; |
| 6646 | |
| 6647 | #endif |
| 6648 | |
| 6649 | |
| 6650 | #ifndef STK_MIDIFILEIN_H |
| 6651 | #define STK_MIDIFILEIN_H |
| 6652 | |
| 6653 | #include <string> |
| 6654 | #include <vector> |
| 6655 | #include <fstream> |
| 6656 | #include <sstream> |
| 6657 | |
| 6658 | namespace stk { |
| 6659 | |
| 6660 | /**********************************************************************/ |
| 6661 | /*! \class MidiFileIn |
| 6662 | \brief A standard MIDI file reading/parsing class. |
| 6663 | |
| 6664 | This class can be used to read events from a standard MIDI file. |
| 6665 | Event bytes are copied to a C++ vector and must be subsequently |
| 6666 | interpreted by the user. The function getNextMidiEvent() skips |
| 6667 | meta and sysex events, returning only MIDI channel messages. |
| 6668 | Event delta-times are returned in the form of "ticks" and a |
| 6669 | function is provided to determine the current "seconds per tick". |
| 6670 | Tempo changes are internally tracked by the class and reflected in |
| 6671 | the values returned by the function getTickSeconds(). |
| 6672 | |
| 6673 | by Gary P. Scavone, 2003 - 2010. |
| 6674 | */ |
| 6675 | /**********************************************************************/ |
| 6676 | |
| 6677 | class MidiFileIn : public Stk |
| 6678 | { |
| 6679 | public: |
| 6680 | //! Default constructor. |
| 6681 | /*! |
| 6682 | If an error occurs while opening or parsing the file header, an |
| 6683 | StkError exception will be thrown. |
| 6684 | */ |
| 6685 | MidiFileIn( std::string fileName ); |
| 6686 | |
| 6687 | //! Class destructor. |
| 6688 | ~MidiFileIn(); |
| 6689 | |
| 6690 | //! Return the MIDI file format (0, 1, or 2). |
| 6691 | int getFileFormat() const; |
| 6692 | |
| 6693 | //! Return the number of tracks in the MIDI file. |
| 6694 | unsigned int getNumberOfTracks() const; |
| 6695 | |
| 6696 | //! Return the MIDI file division value from the file header. |
| 6697 | /*! |
| 6698 | Note that this value must be "parsed" in accordance with the |
| 6699 | MIDI File Specification. In particular, if the MSB is set, the |
| 6700 | file uses time-code representations for delta-time values. |
| 6701 | */ |
| 6702 | int getDivision() const; |
| 6703 | |
| 6704 | //! Move the specified track event reader to the beginning of its track. |
| 6705 | /*! |
| 6706 | The relevant track tempo value is reset as well. If an invalid |
| 6707 | track number is specified, an StkError exception will be thrown. |
| 6708 | */ |
| 6709 | void rewindTrack( unsigned int track = 0 ); |
| 6710 | |
| 6711 | //! Get the current value, in seconds, of delta-time ticks for the specified track. |
| 6712 | /*! |
| 6713 | This value can change as events are read (via "Set Tempo" |
| 6714 | Meta-Events). Therefore, one should call this function after |
| 6715 | every call to getNextEvent() or getNextMidiEvent(). If an |
| 6716 | invalid track number is specified, an StkError exception will be |
| 6717 | thrown. |
| 6718 | */ |
| 6719 | double getTickSeconds( unsigned int track = 0 ); |
| 6720 | |
| 6721 | //! Fill the user-provided vector with the next event in the specified track and return the event delta-time in ticks. |
| 6722 | /*! |
| 6723 | MIDI File events consist of a delta time and a sequence of event |
| 6724 | bytes. This function returns the delta-time value and writes |
| 6725 | the subsequent event bytes directly to the event vector. The |
| 6726 | user must parse the event bytes in accordance with the MIDI File |
| 6727 | Specification. All returned MIDI channel events are complete |
| 6728 | ... a status byte is provided even when running status is used |
| 6729 | in the file. If the track has reached its end, no bytes will be |
| 6730 | written and the event vector size will be zero. If an invalid |
| 6731 | track number is specified or an error occurs while reading the |
| 6732 | file, an StkError exception will be thrown. |
| 6733 | */ |
| 6734 | unsigned long getNextEvent( std::vector<unsigned char> *event, unsigned int track = 0 ); |
| 6735 | |
| 6736 | //! Fill the user-provided vector with the next MIDI channel event in the specified track and return the event delta time in ticks. |
| 6737 | /*! |
| 6738 | All returned MIDI events are complete ... a status byte is |
| 6739 | provided even when running status is used in the file. Meta and |
| 6740 | sysex events in the track are skipped though "Set Tempo" events |
| 6741 | are properly parsed for use by the getTickSeconds() function. |
| 6742 | If the track has reached its end, no bytes will be written and |
| 6743 | the event vector size will be zero. If an invalid track number |
| 6744 | is specified or an error occurs while reading the file, an |
| 6745 | StkError exception will be thrown. |
| 6746 | */ |
| 6747 | unsigned long getNextMidiEvent( std::vector<unsigned char> *midiEvent, unsigned int track = 0 ); |
| 6748 | |
| 6749 | //! ge: get the current BPM (I think) |
| 6750 | /*! |
| 6751 | This value can change as events are read... hmm pretty much |
| 6752 | what it says above for getTickSeconds() |
| 6753 | */ |
| 6754 | double getBPM(); |
| 6755 | |
| 6756 | //! ge & alex & kiran: get the ticks per beat/quarter (TPQ) |
| 6757 | /*! |
| 6758 | this is only valid if NOT using SMPTE time codes |
| 6759 | */ |
| 6760 | double getTPQ(); |
| 6761 | |
| 6762 | protected: |
| 6763 | |
| 6764 | // This protected class function is used for reading variable-length |
| 6765 | // MIDI file values. It is assumed that this function is called with |
| 6766 | // the file read pointer positioned at the start of a |
| 6767 | // variable-length value. The function returns true if the value is |
| 6768 | // successfully parsed. Otherwise, it returns false. |
| 6769 | bool readVariableLength( unsigned long *value ); |
| 6770 | |
| 6771 | std::ifstream file_; |
| 6772 | unsigned int nTracks_; |
| 6773 | int format_; |
| 6774 | int division_; |
| 6775 | bool usingTimeCode_; |
| 6776 | std::vector<double> tickSeconds_; |
| 6777 | std::vector<long> trackPointers_; |
| 6778 | std::vector<long> trackOffsets_; |
| 6779 | std::vector<long> trackLengths_; |
| 6780 | std::vector<char> trackStatus_; |
| 6781 | // ge: |
| 6782 | double bpm_; |
| 6783 | // ge & alex & kiran |
| 6784 | double tpq_; // ticks per quarter | 1.5.3.2 |
| 6785 | |
| 6786 | // This structure and the following variables are used to save and |
| 6787 | // keep track of a format 1 tempo map (and the initial tickSeconds |
| 6788 | // parameter for formats 0 and 2). |
| 6789 | struct TempoChange { |
| 6790 | unsigned long count; |
| 6791 | double tickSeconds; |
| 6792 | }; |
| 6793 | std::vector<TempoChange> tempoEvents_; |
| 6794 | std::vector<unsigned long> trackCounters_; |
| 6795 | std::vector<unsigned int> trackTempoIndex_; |
| 6796 | }; |
| 6797 | |
| 6798 | } // stk namespace |
| 6799 | |
| 6800 | #endif |
| 6801 | |
| 6802 | |
| 6803 | |
| 6804 | /*********************************************************/ |
| 6805 | /* |
| 6806 | Definition of SKINI Message Types and Special Symbols |
| 6807 | Synthesis toolKit Instrument Network Interface |
| 6808 | |
| 6809 | These symbols should have the form __SK_<name>_ |
| 6810 | |
| 6811 | Where <name> is the string used in the SKINI stream. |
| 6812 | |
| 6813 | by Perry R. Cook, 1995 - 2002. |
| 6814 | */ |
| 6815 | /*********************************************************/ |
| 6816 | |
| 6817 | /***** MIDI COMPATIBLE MESSAGES *****/ |
| 6818 | /***** Status Bytes Have Channel=0 **/ |
| 6819 | |
| 6820 | #define NOPE -32767 |
| 6821 | #define YEP 1 |
| 6822 | #define SK_DBL -32766 |
| 6823 | #define SK_INT -32765 |
| 6824 | #define SK_STR -32764 |
| 6825 | |
| 6826 | #define __SK_NoteOff_ 128 |
| 6827 | #define __SK_NoteOn_ 144 |
| 6828 | #define __SK_PolyPressure_ 160 |
| 6829 | #define __SK_ControlChange_ 176 |
| 6830 | #define __SK_ProgramChange_ 192 |
| 6831 | #define __SK_AfterTouch_ 208 |
| 6832 | #define __SK_ChannelPressure_ __SK_AfterTouch_ |
| 6833 | #define __SK_PitchWheel_ 224 |
| 6834 | #define __SK_PitchBend_ __SK_PitchWheel_ |
| 6835 | #define __SK_PitchChange_ 49 |
| 6836 | |
| 6837 | #define __SK_Clock_ 248 |
| 6838 | #define __SK_SongStart_ 250 |
| 6839 | #define __SK_Continue_ 251 |
| 6840 | #define __SK_SongStop_ 252 |
| 6841 | #define __SK_ActiveSensing_ 254 |
| 6842 | #define __SK_SystemReset_ 255 |
| 6843 | |
| 6844 | #define __SK_Volume_ 7 |
| 6845 | #define __SK_ModWheel_ 1 |
| 6846 | #define __SK_Modulation_ __SK_ModWheel_ |
| 6847 | #define __SK_Breath_ 2 |
| 6848 | #define __SK_FootControl_ 4 |
| 6849 | #define __SK_Portamento_ 65 |
| 6850 | #define __SK_Balance_ 8 |
| 6851 | #define __SK_Pan_ 10 |
| 6852 | #define __SK_Sustain_ 64 |
| 6853 | #define __SK_Damper_ __SK_Sustain_ |
| 6854 | #define __SK_Expression_ 11 |
| 6855 | |
| 6856 | #define __SK_AfterTouch_Cont_ 128 |
| 6857 | #define __SK_ModFrequency_ __SK_Expression_ |
| 6858 | |
| 6859 | #define __SK_ProphesyRibbon_ 16 |
| 6860 | #define __SK_ProphesyWheelUp_ 2 |
| 6861 | #define __SK_ProphesyWheelDown_ 3 |
| 6862 | #define __SK_ProphesyPedal_ 18 |
| 6863 | #define __SK_ProphesyKnob1_ 21 |
| 6864 | #define __SK_ProphesyKnob2_ 22 |
| 6865 | |
| 6866 | /*** Instrument Family Specific ***/ |
| 6867 | |
| 6868 | #define __SK_NoiseLevel_ __SK_FootControl_ |
| 6869 | |
| 6870 | #define __SK_PickPosition_ __SK_FootControl_ |
| 6871 | #define __SK_StringDamping_ __SK_Expression_ |
| 6872 | #define __SK_StringDetune_ __SK_ModWheel_ |
| 6873 | #define __SK_BodySize_ __SK_Breath_ |
| 6874 | #define __SK_BowPressure_ __SK_Breath_ |
| 6875 | #define __SK_BowPosition_ __SK_PickPosition_ |
| 6876 | #define __SK_BowBeta_ __SK_BowPosition_ |
| 6877 | |
| 6878 | #define __SK_ReedStiffness_ __SK_Breath_ |
| 6879 | #define __SK_ReedRestPos_ __SK_FootControl_ |
| 6880 | |
| 6881 | #define __SK_FluteEmbouchure_ __SK_Breath_ |
| 6882 | #define __SK_JetDelay_ __SK_FluteEmbouchure_ |
| 6883 | |
| 6884 | #define __SK_LipTension_ __SK_Breath_ |
| 6885 | #define __SK_SlideLength_ __SK_FootControl_ |
| 6886 | |
| 6887 | #define __SK_StrikePosition_ __SK_PickPosition_ |
| 6888 | #define __SK_StickHardness_ __SK_Breath_ |
| 6889 | |
| 6890 | #define __SK_TrillDepth_ 1051 |
| 6891 | #define __SK_TrillSpeed_ 1052 |
| 6892 | #define __SK_StrumSpeed_ __SK_TrillSpeed_ |
| 6893 | #define __SK_RollSpeed_ __SK_TrillSpeed_ |
| 6894 | |
| 6895 | #define __SK_FilterQ_ __SK_Breath_ |
| 6896 | #define __SK_FilterFreq_ 1062 |
| 6897 | #define __SK_FilterSweepRate_ __SK_FootControl_ |
| 6898 | |
| 6899 | #define __SK_ShakerInst_ 1071 |
| 6900 | #define __SK_ShakerEnergy_ __SK_Breath_ |
| 6901 | #define __SK_ShakerDamping_ __SK_ModFrequency_ |
| 6902 | #define __SK_ShakerNumObjects_ __SK_FootControl_ |
| 6903 | |
| 6904 | #define __SK_Strumming_ 1090 |
| 6905 | #define __SK_NotStrumming_ 1091 |
| 6906 | #define __SK_Trilling_ 1092 |
| 6907 | #define __SK_NotTrilling_ 1093 |
| 6908 | #define __SK_Rolling_ __SK_Strumming_ |
| 6909 | #define __SK_NotRolling_ __SK_NotStrumming_ |
| 6910 | |
| 6911 | #define __SK_PlayerSkill_ 2001 |
| 6912 | #define __SK_Chord_ 2002 |
| 6913 | #define __SK_ChordOff_ 2003 |
| 6914 | |
| 6915 | #define __SK_SINGER_FilePath_ 3000 |
| 6916 | #define __SK_SINGER_Frequency_ 3001 |
| 6917 | #define __SK_SINGER_NoteName_ 3002 |
| 6918 | #define __SK_SINGER_Shape_ 3003 |
| 6919 | #define __SK_SINGER_Glot_ 3004 |
| 6920 | #define __SK_SINGER_VoicedUnVoiced_ 3005 |
| 6921 | #define __SK_SINGER_Synthesize_ 3006 |
| 6922 | #define __SK_SINGER_Silence_ 3007 |
| 6923 | #define __SK_SINGER_VibratoAmt_ __SK_ModWheel_ |
| 6924 | #define __SK_SINGER_RndVibAmt_ 3008 |
| 6925 | #define __SK_SINGER_VibFreq_ __SK_Expression_ |
| 6926 | |
| 6927 | |
| 6928 | #define __SK_MaxMsgTypes_ 128 |
| 6929 | |
| 6930 | |
| 6931 | |
| 6932 | |
| 6933 | #endif |