Unified · Split
| @@ -63,9 +63,9 @@ ellpset(EllSect es[], float *xnorm) · 62 unmodified lines | ||
| 63 | 63 | float |
| 64 | 64 | ellipse(float sig, int nsects, EllSect es[], float xnorm) |
| 65 | 65 | { |
| 66 | − register int i; | |
| 67 | − register float y0; | |
| 68 | − register EllSect *s; | |
| 66 | + /* register */ int i; | |
| 67 | + /* register */ float y0; | |
| 68 | + /* register */ EllSect *s; | |
| 69 | 69 | |
| 70 | 70 | for (i = 0; i < nsects; i++) { |
| 71 | 71 | s = &es[i]; |
| @@ -125,7 +125,7 @@ void Stk :: setRawwavePath( std::string path ) · 124 unmodified lines | ||
| 125 | 125 | |
| 126 | 126 | void Stk :: swap16(unsigned char *ptr) |
| 127 | 127 | { |
| 128 | − register unsigned char val; | |
| 128 | + /* register */ unsigned char val; | |
| 129 | 129 | |
| 130 | 130 | // Swap 1st and 2nd bytes |
| 131 | 131 | val = *(ptr); |
| @@ -135,7 +135,7 @@ void Stk :: swap16(unsigned char *ptr) · 3 unmodified lines | ||
| 135 | 135 | |
| 136 | 136 | void Stk :: swap32(unsigned char *ptr) |
| 137 | 137 | { |
| 138 | − register unsigned char val; | |
| 138 | + /* register */ unsigned char val; | |
| 139 | 139 | |
| 140 | 140 | // Swap 1st and 4th bytes |
| 141 | 141 | val = *(ptr); |
| @@ -151,7 +151,7 @@ void Stk :: swap32(unsigned char *ptr) · 9 unmodified lines | ||
| 151 | 151 | |
| 152 | 152 | void Stk :: swap64(unsigned char *ptr) |
| 153 | 153 | { |
| 154 | − register unsigned char val; | |
| 154 | + /* register */ unsigned char val; | |
| 155 | 155 | |
| 156 | 156 | // Swap 1st and 8th bytes |
| 157 | 157 | val = *(ptr); |
| @@ -0,0 +1,93 @@ | ||
| 1 | +# Range (unit generator) | |
| 2 | + |- (inheritance) Range -> UGen -> Object | |
| 3 | + | |
| 4 | + | |
| 5 | + `Range` is a UGen that maps an input range to an output range. It currently supports linear mapping between ranges as well as clipping. | |
| 6 | + This is particularly useful for LFOs where the useful parameter values don't center around one. | |
| 7 | + | |
| 8 | + You can define ranges in terms of min/max values: | |
| 9 | + | |
| 10 | + ``` | |
| 11 | + // Use scaler to make an easy vibrato | |
| 12 | +SinOsc lfo => Range r => blackhole; | |
| 13 | +SinOsc tone => dac; | |
| 14 | + | |
| 15 | +3 => lfo.freq; | |
| 16 | + | |
| 17 | +// Modulate frequency +- 10Hz around A440 | |
| 18 | +(-1, 1, 430, 450) => r.range | |
| 19 | + | |
| 20 | +while(10::ms => now) { | |
| 21 | + r.last() => tone.freq; | |
| 22 | +} | |
| 23 | +``` | |
| 24 | + | |
| 25 | +...or by defining a range center value and a radius size: | |
| 26 | + | |
| 27 | +``` | |
| 28 | +// Use scaler to make an easy vibrato | |
| 29 | +SinOsc lfo => Range r => blackhole; | |
| 30 | +SinOsc tone => dac; | |
| 31 | + | |
| 32 | +// Help reveals all secrets | |
| 33 | +Range.help(); | |
| 34 | + | |
| 35 | +3 => lfo.freq; | |
| 36 | +// Modulate frequency +- 10Hz around A440 | |
| 37 | +(0, 1, 440, 10) => r.radius; | |
| 38 | + | |
| 39 | +while(10::ms => now) { | |
| 40 | + r.last() => tone.freq; | |
| 41 | +} | |
| 42 | +``` | |
| 43 | + | |
| 44 | +## Range Functions | |
| 45 | + | |
| 46 | +* `int clip( int val );` | |
| 47 | + | |
| 48 | + Set Range's clipping mode. Accepted values are: 0 (no clipping), 1 (hard clipping). Defaults to 0 | |
| 49 | +* `int clip();` | |
| 50 | + | |
| 51 | + Get clip state. | |
| 52 | +* `float inCenter();` | |
| 53 | + | |
| 54 | + Get input center. | |
| 55 | +* `float inMax();` | |
| 56 | + | |
| 57 | + Get input max. | |
| 58 | +* `float inMin();` | |
| 59 | + | |
| 60 | + Get input min. | |
| 61 | +* `float inRad();` | |
| 62 | + | |
| 63 | + Get input radius. | |
| 64 | +* `void inRadius( float center, float radius );` | |
| 65 | + | |
| 66 | + Set the expected input radius. | |
| 67 | +* `void inRange( float min, float max );` | |
| 68 | + | |
| 69 | + Set the expected input range. | |
| 70 | +* `float outCenter();` | |
| 71 | + | |
| 72 | + Get output center. | |
| 73 | +* `float outMax();` | |
| 74 | + | |
| 75 | + Get output max. | |
| 76 | +* `float outMin();` | |
| 77 | + | |
| 78 | + Get output min. | |
| 79 | +* `float outRad();` | |
| 80 | + | |
| 81 | + Get output radius. | |
| 82 | +* `void outRadius( float center, float radius );` | |
| 83 | + | |
| 84 | + Set the output radius. | |
| 85 | +* `void outRange( float min, float max );` | |
| 86 | + | |
| 87 | + Set the output range. | |
| 88 | +* `void radius( float inCenter, float inRadius, float outCenter, float outRadius );` | |
| 89 | + | |
| 90 | + Set the expected input range and desired output range in terms of a center with a radius. | |
| 91 | +* `void range( float inMin, float inMax, float outMin, float outMax );` | |
| 92 | + | |
| 93 | + Set the expected input range and desired output range. | |
| @@ -0,0 +1,17 @@ | ||
| 1 | +// Use Range to make an easy vibrato | |
| 2 | +SinOsc lfo => Range r => blackhole; | |
| 3 | +SinOsc tone => dac; | |
| 4 | + | |
| 5 | +// Help reveals all secrets | |
| 6 | +Range.help(); | |
| 7 | + | |
| 8 | +3 => lfo.freq; | |
| 9 | +// Modulate frequency +- 10Hz around A440 | |
| 10 | +(0, 1, 440, 10) => r.radius; | |
| 11 | + | |
| 12 | +// This is equivalent to the above line, but sets the input/output range specifically | |
| 13 | +// (-1, 1, 430, 450) => r.range | |
| 14 | + | |
| 15 | +while(10::ms => now) { | |
| 16 | + r.last() => tone.freq; | |
| 17 | +} | |
| @@ -0,0 +1,91 @@ | ||
| 1 | +SinOsc sin => Range scale => blackhole; | |
| 2 | +sin => Gain g => blackhole; | |
| 3 | + | |
| 4 | +(-1, 1, 0, 2) => scale.range; | |
| 5 | +validate(1.0); | |
| 6 | +validateRange(-1, 1, 0, 2); | |
| 7 | +validateRadius(0, 1, 1, 1); | |
| 8 | + | |
| 9 | +(0, 1, 1, 1 ) => scale.radius; | |
| 10 | +validate(1.0); | |
| 11 | +validateRange(-1, 1, 0, 2); | |
| 12 | +validateRadius(0, 1, 1, 1); | |
| 13 | + | |
| 14 | +(-1, 1) => scale.inRange; | |
| 15 | +validate(1.0); | |
| 16 | +validateRange(-1, 1, 0, 2); | |
| 17 | +validateRadius(0, 1, 1, 1); | |
| 18 | + | |
| 19 | +(0, 2) => scale.outRange; | |
| 20 | +validate(1.0); | |
| 21 | +validateRange(-1, 1, 0, 2); | |
| 22 | +validateRadius(0, 1, 1, 1); | |
| 23 | + | |
| 24 | +(0, 1) => scale.inRadius; | |
| 25 | +validate(1.0); | |
| 26 | +validateRange(-1, 1, 0, 2); | |
| 27 | +validateRadius(0, 1, 1, 1); | |
| 28 | + | |
| 29 | +(1, 1) => scale.outRadius; | |
| 30 | +validate(1.0); | |
| 31 | +validateRange(-1, 1, 0, 2); | |
| 32 | +validateRadius(0, 1, 1, 1); | |
| 33 | + | |
| 34 | +// test exceeding clip bounds | |
| 35 | +2 => sin.gain; | |
| 36 | +validate(1.0); | |
| 37 | +validateRange(-1, 1, 0, 2); | |
| 38 | +validateRadius(0, 1, 1, 1); | |
| 39 | + | |
| 40 | +// test with hard clipping | |
| 41 | +1 => scale.clip; | |
| 42 | +validateClip(1.0, 0, 2); | |
| 43 | + | |
| 44 | +fun void validate(float offset) { | |
| 45 | + now + 1::second => time later; | |
| 46 | + while(now < later) { | |
| 47 | +1::samp => now; | |
| 48 | + (g.last()) + offset => float want; | |
| 49 | + if (!within(scale.last(), want, 0.001)) { | |
| 50 | + <<< "FAILURE, in = ", g.last(), "got = ", scale.last(), "want = ", want >>>; | |
| 51 | + } | |
| 52 | + } | |
| 53 | +} | |
| 54 | + | |
| 55 | +fun void validateClip(float offset, float min, float max) { | |
| 56 | + now + 1::second => time later; | |
| 57 | + while(now < later) { | |
| 58 | + 1::samp => now; | |
| 59 | + (g.last()) + offset => float want; | |
| 60 | + Math.max(want, min) => want; | |
| 61 | + Math.min(want, max) => want; | |
| 62 | + if (!within(scale.last(), want, 0.001)) { | |
| 63 | + <<< "FAILURE, in = ", g.last(), "got = ", scale.last(), "want = ", want >>>; | |
| 64 | + } | |
| 65 | + } | |
| 66 | +} | |
| 67 | + | |
| 68 | + | |
| 69 | +// check that two floats are within err of each other | |
| 70 | +fun int within(float a, float b, float err) { | |
| 71 | + Math.fabs(a - b) => float result; | |
| 72 | + | |
| 73 | + if (result < err) { | |
| 74 | + return true; | |
| 75 | + } | |
| 76 | + return false; | |
| 77 | +} | |
| 78 | + | |
| 79 | +fun void validateRange(float inMin, float inMax, float outMin, float outMax) { | |
| 80 | + if (!within(scale.inMin(), inMin, 0.001)) <<< "inMin FAILURE", scale.inMin(), inMin >>>; | |
| 81 | + if (!within(scale.inMax(), inMax, 0.001)) <<< "inMax FAILURE", scale.inMax(), inMax >>>; | |
| 82 | + if (!within(scale.outMin(), outMin, 0.001)) <<< "outMin FAILURE", scale.outMin(), outMin >>>; | |
| 83 | + if (!within(scale.outMax(), outMax, 0.001)) <<< "outMax FAILURE", scale.outMax(), outMax >>>; | |
| 84 | +} | |
| 85 | + | |
| 86 | +fun void validateRadius(float inCenter, float inRadius, float outCenter, float outRadius) { | |
| 87 | + if (!within(scale.inCenter(), inCenter, 0.001)) <<< "inCenter FAILURE", scale.inCenter(), inCenter >>>; | |
| 88 | + if (!within(scale.inRad(), inRadius, 0.001)) <<< "inRadius FAILURE", scale.inRad(), inRadius >>>; | |
| 89 | + if (!within(scale.outCenter(), outCenter, 0.001)) <<< "outCenter FAILURE", scale.outCenter(), outCenter >>>; | |
| 90 | + if (!within(scale.outRad(), outRadius, 0.001)) <<< "outRadius FAILURE", scale.outRad(), outRadius >>>; | |
| 91 | +} | |
| @@ -0,0 +1,462 @@ | ||
| 1 | +//----------------------------------------------------------------------------- | |
| 2 | +// name: Range.cpp | |
| 3 | +// desc: Scale an input signal from one number range to another. | |
| 4 | +// This is useful for things such as making LFOs that drive | |
| 5 | +// parameters that are do not fall under the output range of | |
| 6 | +// most oscillators, like vibrato. | |
| 7 | +// | |
| 8 | +// example: | |
| 9 | +// // Use range to make an easy vibrato | |
| 10 | +// SinOsc lfo = > Range r = > blackhole; | |
| 11 | +// SinOsc tone = > dac; | |
| 12 | +// | |
| 13 | +// // Help reveals all secrets | |
| 14 | +// Range.help(); | |
| 15 | +// | |
| 16 | +// 3 = > lfo.freq; | |
| 17 | +// (0, 1, 440, 10) = > r.radius; | |
| 18 | +// | |
| 19 | +// while (10::ms = > now) { | |
| 20 | +// r.last() = > tone.freq; | |
| 21 | +// } | |
| 22 | +// | |
| 23 | +// authors: Nick Shaheed (nshaheed@ccrma.stanford.edu) | |
| 24 | +// date: Winter 2022 | |
| 25 | +// | |
| 26 | +//----------------------------------------------------------------------------- | |
| 27 | + | |
| 28 | +// this should align with the correct versions of these ChucK files | |
| 29 | +#include "chuck_dl.h" | |
| 30 | +#include "chuck_def.h" | |
| 31 | + | |
| 32 | +// general includes | |
| 33 | +#include <stdio.h> | |
| 34 | +#include <limits.h> | |
| 35 | + | |
| 36 | +// declaration of chugin constructor | |
| 37 | +CK_DLL_CTOR(range_ctor); | |
| 38 | +// declaration of chugin desctructor | |
| 39 | +CK_DLL_DTOR(range_dtor); | |
| 40 | + | |
| 41 | +// getters and setters | |
| 42 | +CK_DLL_MFUN(range_setInRange); | |
| 43 | +CK_DLL_MFUN(range_setInRadius); | |
| 44 | +CK_DLL_MFUN(range_setOutRange); | |
| 45 | +CK_DLL_MFUN(range_setOutRadius); | |
| 46 | +CK_DLL_MFUN(range_setRange); | |
| 47 | +CK_DLL_MFUN(range_setRadius); | |
| 48 | + | |
| 49 | +CK_DLL_MFUN(range_getInMin); | |
| 50 | +CK_DLL_MFUN(range_getInMax); | |
| 51 | +CK_DLL_MFUN(range_getOutMin); | |
| 52 | +CK_DLL_MFUN(range_getOutMax); | |
| 53 | +CK_DLL_MFUN(range_getInCenter); | |
| 54 | +CK_DLL_MFUN(range_getInRadius); | |
| 55 | +CK_DLL_MFUN(range_getOutCenter); | |
| 56 | +CK_DLL_MFUN(range_getOutRadius); | |
| 57 | + | |
| 58 | +CK_DLL_MFUN(range_setClip); | |
| 59 | +CK_DLL_MFUN(range_getClip); | |
| 60 | + | |
| 61 | +// for Chugins extending UGen, this is mono synthesis function for 1 sample | |
| 62 | +CK_DLL_TICK(range_tick); | |
| 63 | + | |
| 64 | +// this is a special offset reserved for Chugin internal data | |
| 65 | +t_CKINT range_data_offset = 0; | |
| 66 | + | |
| 67 | +class Range | |
| 68 | +{ | |
| 69 | +public: | |
| 70 | + // constructor | |
| 71 | + Range( t_CKFLOAT fs) | |
| 72 | + { | |
| 73 | + m_param = 0; | |
| 74 | + m_in_min = -1; | |
| 75 | + m_in_max = 1; | |
| 76 | + m_out_min = 0; | |
| 77 | + m_out_max = 1; | |
| 78 | + m_clip = 0; | |
| 79 | + } | |
| 80 | + | |
| 81 | + // for Chugins extending UGen | |
| 82 | + SAMPLE tick( SAMPLE in ) | |
| 83 | + { | |
| 84 | + SAMPLE out = (in - m_in_min) / (m_in_max - m_in_min); | |
| 85 | + out = out * (m_out_max - m_out_min) + m_out_min; | |
| 86 | + | |
| 87 | + if (!m_clip) return out; | |
| 88 | + | |
| 89 | + // hard clipping - nothing past the limits allowed. | |
| 90 | + if (out < m_out_min) out = m_out_min; | |
| 91 | + if (out > m_out_max) out = m_out_max; | |
| 92 | + | |
| 93 | + // default: this passes whatever input is patched into Chugin | |
| 94 | + return out; | |
| 95 | + } | |
| 96 | + | |
| 97 | + t_CKVOID setInRange( t_CKFLOAT in_min, t_CKFLOAT in_max ) { | |
| 98 | + m_in_min = in_min; | |
| 99 | + m_in_max = in_max; | |
| 100 | + } | |
| 101 | + | |
| 102 | + t_CKVOID setInRadius( t_CKFLOAT in_center, t_CKFLOAT in_radius ) { | |
| 103 | + m_in_min = in_center - in_radius; | |
| 104 | + m_in_max = in_center + in_radius; | |
| 105 | + } | |
| 106 | + | |
| 107 | + t_CKVOID setOutRange( t_CKFLOAT out_min, t_CKFLOAT out_max ) { | |
| 108 | + m_out_min = out_min; | |
| 109 | + m_out_max = out_max; | |
| 110 | + } | |
| 111 | + | |
| 112 | + t_CKVOID setOutRadius( t_CKFLOAT out_center, t_CKFLOAT out_radius ) { | |
| 113 | + m_out_min = out_center - out_radius; | |
| 114 | + m_out_max = out_center + out_radius; | |
| 115 | + } | |
| 116 | + | |
| 117 | + t_CKVOID setRange( t_CKFLOAT in_min, t_CKFLOAT in_max, t_CKFLOAT out_min, t_CKFLOAT out_max ) { | |
| 118 | + m_in_min = in_min; | |
| 119 | + m_in_max = in_max; | |
| 120 | + m_out_min = out_min; | |
| 121 | + m_out_max = out_max; | |
| 122 | + } | |
| 123 | + | |
| 124 | + t_CKVOID setRadius(t_CKFLOAT in_center, t_CKFLOAT in_radius, t_CKFLOAT out_center, t_CKFLOAT out_radius) { | |
| 125 | + m_in_min = in_center - in_radius; | |
| 126 | + m_in_max = in_center + in_radius; | |
| 127 | + m_out_min = out_center - out_radius; | |
| 128 | + m_out_max = out_center + out_radius; | |
| 129 | + } | |
| 130 | + | |
| 131 | + t_CKINT setClip(t_CKINT val) | |
| 132 | + { | |
| 133 | + m_clip = val; | |
| 134 | + return val; | |
| 135 | + } | |
| 136 | + | |
| 137 | + t_CKINT getClip() | |
| 138 | + { | |
| 139 | + return m_clip; | |
| 140 | + } | |
| 141 | + | |
| 142 | + // get parameter example | |
| 143 | + t_CKFLOAT getInMin() { return m_in_min; } | |
| 144 | + t_CKFLOAT getInMax() { return m_in_max; } | |
| 145 | + t_CKFLOAT getOutMin() { return m_out_min; } | |
| 146 | + t_CKFLOAT getOutMax() { return m_out_max; } | |
| 147 | + | |
| 148 | + t_CKFLOAT getInCenter() { return (m_in_min + m_in_max) / 2; } | |
| 149 | + t_CKFLOAT getInRadius() { return (m_in_max - m_in_min) / 2; } | |
| 150 | + t_CKFLOAT getOutCenter() { return (m_out_min + m_out_max) / 2; } | |
| 151 | + t_CKFLOAT getOutRadius() { return (m_out_max - m_out_min) / 2; } | |
| 152 | + | |
| 153 | + | |
| 154 | +private: | |
| 155 | + // instance data | |
| 156 | + t_CKFLOAT m_param; | |
| 157 | + t_CKFLOAT m_in_min, m_in_max, m_out_min, m_out_max; | |
| 158 | + t_CKINT m_clip; | |
| 159 | +}; | |
| 160 | + | |
| 161 | + | |
| 162 | +// query function: chuck calls this when loading the Chugin | |
| 163 | +// NOTE: developer will need to modify this function to | |
| 164 | +// add additional functions to this Chugin | |
| 165 | +CK_DLL_QUERY( Range ) | |
| 166 | +{ | |
| 167 | + // hmm, don't change this... | |
| 168 | + QUERY->setname(QUERY, "Range"); | |
| 169 | + | |
| 170 | + // begin the class definition | |
| 171 | + // can change the second argument to extend a different ChucK class | |
| 172 | + QUERY->begin_class(QUERY, "Range", "UGen"); | |
| 173 | + | |
| 174 | + // register the constructor (probably no need to change) | |
| 175 | + QUERY->add_ctor(QUERY, range_ctor); | |
| 176 | + // register the destructor (probably no need to change) | |
| 177 | + QUERY->add_dtor(QUERY, range_dtor); | |
| 178 | + | |
| 179 | + // for UGen's only: add tick function | |
| 180 | + QUERY->add_ugen_func(QUERY, range_tick, NULL, 1, 1); | |
| 181 | + | |
| 182 | + // NOTE: if this is to be a UGen with more than 1 channel, | |
| 183 | + // e.g., a multichannel UGen -- will need to use add_ugen_funcf() | |
| 184 | + // and declare a tickf function using CK_DLL_TICKF | |
| 185 | + | |
| 186 | + QUERY->add_mfun(QUERY, range_setInRange, "void", "inRange"); | |
| 187 | + QUERY->add_arg(QUERY, "float", "min"); | |
| 188 | + QUERY->add_arg(QUERY, "float", "max"); | |
| 189 | + QUERY->doc_func(QUERY, "Set the expected input range."); | |
| 190 | + | |
| 191 | + QUERY->add_mfun(QUERY, range_setInRadius, "void", "inRadius"); | |
| 192 | + QUERY->add_arg(QUERY, "float", "center"); | |
| 193 | + QUERY->add_arg(QUERY, "float", "radius"); | |
| 194 | + QUERY->doc_func(QUERY, "Set the expected input radius."); | |
| 195 | + | |
| 196 | + QUERY->add_mfun(QUERY, range_setOutRange, "void", "outRange"); | |
| 197 | + QUERY->add_arg(QUERY, "float", "min"); | |
| 198 | + QUERY->add_arg(QUERY, "float", "max"); | |
| 199 | + QUERY->doc_func(QUERY, "Set the output range."); | |
| 200 | + | |
| 201 | + QUERY->add_mfun(QUERY, range_setOutRadius, "void", "outRadius"); | |
| 202 | + QUERY->add_arg(QUERY, "float", "center"); | |
| 203 | + QUERY->add_arg(QUERY, "float", "radius"); | |
| 204 | + QUERY->doc_func(QUERY, "Set the output radius."); | |
| 205 | + | |
| 206 | + QUERY->add_mfun(QUERY, range_setRange, "void", "range"); | |
| 207 | + QUERY->add_arg(QUERY, "float", "inMin"); | |
| 208 | + QUERY->add_arg(QUERY, "float", "inMax"); | |
| 209 | + QUERY->add_arg(QUERY, "float", "outMin"); | |
| 210 | + QUERY->add_arg(QUERY, "float", "outMax"); | |
| 211 | + QUERY->doc_func(QUERY, "Set the expected input range and desired output range."); | |
| 212 | + | |
| 213 | + QUERY->add_mfun(QUERY, range_setRadius, "void", "radius"); | |
| 214 | + QUERY->add_arg(QUERY, "float", "inCenter"); | |
| 215 | + QUERY->add_arg(QUERY, "float", "inRadius"); | |
| 216 | + QUERY->add_arg(QUERY, "float", "outCenter"); | |
| 217 | + QUERY->add_arg(QUERY, "float", "outRadius"); | |
| 218 | + QUERY->doc_func(QUERY, "Set the expected input range and desired output range in terms of a center with a radius."); | |
| 219 | + | |
| 220 | + QUERY->add_mfun(QUERY, range_getInMin, "float", "inMin"); | |
| 221 | + QUERY->doc_func(QUERY, "Get input min."); | |
| 222 | + | |
| 223 | + QUERY->add_mfun(QUERY, range_getInMax, "float", "inMax"); | |
| 224 | + QUERY->doc_func(QUERY, "Get input max."); | |
| 225 | + | |
| 226 | + QUERY->add_mfun(QUERY, range_getOutMin, "float", "outMin"); | |
| 227 | + QUERY->doc_func(QUERY, "Get output min."); | |
| 228 | + | |
| 229 | + QUERY->add_mfun(QUERY, range_getOutMax, "float", "outMax"); | |
| 230 | + QUERY->doc_func(QUERY, "Get output max."); | |
| 231 | + | |
| 232 | + QUERY->add_mfun(QUERY, range_getInCenter, "float", "inCenter"); | |
| 233 | + QUERY->doc_func(QUERY, "Get input center."); | |
| 234 | + | |
| 235 | + QUERY->add_mfun(QUERY, range_getInRadius, "float", "inRad"); | |
| 236 | + QUERY->doc_func(QUERY, "Get input radius."); | |
| 237 | + | |
| 238 | + QUERY->add_mfun(QUERY, range_getOutCenter, "float", "outCenter"); | |
| 239 | + QUERY->doc_func(QUERY, "Get output center."); | |
| 240 | + | |
| 241 | + QUERY->add_mfun(QUERY, range_getOutRadius, "float", "outRad"); | |
| 242 | + QUERY->doc_func(QUERY, "Get output radius."); | |
| 243 | + | |
| 244 | + QUERY->add_mfun(QUERY, range_setClip, "int", "clip"); | |
| 245 | + QUERY->add_arg(QUERY, "int", "val"); | |
| 246 | + QUERY->doc_func(QUERY, "Set Range's clipping mode. Accepted values are: 0 (no clipping), 1 (hard clipping). Defaults to 0"); | |
| 247 | + | |
| 248 | + QUERY->add_mfun(QUERY, range_getClip, "int", "clip"); | |
| 249 | + QUERY->doc_func(QUERY, "Get clip state."); | |
| 250 | + | |
| 251 | + | |
| 252 | + // this reserves a variable in the ChucK internal class to store | |
| 253 | + // referene to the c++ class we defined above | |
| 254 | + range_data_offset = QUERY->add_mvar(QUERY, "int", "@s_data", false); | |
| 255 | + | |
| 256 | + // end the class definition | |
| 257 | + // IMPORTANT: this MUST be called! | |
| 258 | + QUERY->end_class(QUERY); | |
| 259 | + | |
| 260 | + // wasn't that a breeze? | |
| 261 | + return TRUE; | |
| 262 | +} | |
| 263 | + | |
| 264 | + | |
| 265 | +// implementation for the constructor | |
| 266 | +CK_DLL_CTOR(range_ctor) | |
| 267 | +{ | |
| 268 | + // get the offset where we'll store our internal c++ class pointer | |
| 269 | + OBJ_MEMBER_INT(SELF, range_data_offset) = 0; | |
| 270 | + | |
| 271 | + // instantiate our internal c++ class representation | |
| 272 | + Range * s_obj = new Range(API->vm->get_srate(API, SHRED)); | |
| 273 | + | |
| 274 | + // store the pointer in the ChucK object member | |
| 275 | + OBJ_MEMBER_INT(SELF, range_data_offset) = (t_CKINT) s_obj; | |
| 276 | +} | |
| 277 | + | |
| 278 | + | |
| 279 | +// implementation for the destructor | |
| 280 | +CK_DLL_DTOR(range_dtor) | |
| 281 | +{ | |
| 282 | + // get our c++ class pointer | |
| 283 | + Range * s_obj = (Range *) OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 284 | + // check it | |
| 285 | + if( s_obj ) | |
| 286 | + { | |
| 287 | + // clean up | |
| 288 | + delete s_obj; | |
| 289 | + OBJ_MEMBER_INT(SELF, range_data_offset) = 0; | |
| 290 | + s_obj = NULL; | |
| 291 | + } | |
| 292 | +} | |
| 293 | + | |
| 294 | + | |
| 295 | +// implementation for tick function | |
| 296 | +CK_DLL_TICK(range_tick) | |
| 297 | +{ | |
| 298 | + // get our c++ class pointer | |
| 299 | + Range * s_obj = (Range *) OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 300 | + | |
| 301 | + // invoke our tick function; store in the magical out variable | |
| 302 | + if(s_obj) *out = s_obj->tick(in); | |
| 303 | + | |
| 304 | + // yes | |
| 305 | + return TRUE; | |
| 306 | +} | |
| 307 | + | |
| 308 | +CK_DLL_MFUN(range_setInRange) | |
| 309 | +{ | |
| 310 | + // get our c++ class pointer | |
| 311 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 312 | + | |
| 313 | + t_CKFLOAT inMin = GET_NEXT_FLOAT(ARGS); | |
| 314 | + t_CKFLOAT inMax = GET_NEXT_FLOAT(ARGS); | |
| 315 | + | |
| 316 | + // set the return value | |
| 317 | + s_obj->setInRange(inMin, inMax); | |
| 318 | +} | |
| 319 | + | |
| 320 | +CK_DLL_MFUN(range_setInRadius) | |
| 321 | +{ | |
| 322 | + // get our c++ class pointer | |
| 323 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 324 | + | |
| 325 | + t_CKFLOAT inCenter = GET_NEXT_FLOAT(ARGS); | |
| 326 | + t_CKFLOAT inRadius = GET_NEXT_FLOAT(ARGS); | |
| 327 | + | |
| 328 | + // set the return value | |
| 329 | + s_obj->setInRadius(inCenter, inRadius); | |
| 330 | +} | |
| 331 | + | |
| 332 | +CK_DLL_MFUN(range_setOutRange) | |
| 333 | +{ | |
| 334 | + // get our c++ class pointer | |
| 335 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 336 | + | |
| 337 | + t_CKFLOAT outMin = GET_NEXT_FLOAT(ARGS); | |
| 338 | + t_CKFLOAT outMax = GET_NEXT_FLOAT(ARGS); | |
| 339 | + | |
| 340 | + // set the return value | |
| 341 | + s_obj->setOutRange(outMin, outMax); | |
| 342 | +} | |
| 343 | + | |
| 344 | +CK_DLL_MFUN(range_setOutRadius) | |
| 345 | +{ | |
| 346 | + // get our c++ class pointer | |
| 347 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 348 | + | |
| 349 | + t_CKFLOAT outCenter = GET_NEXT_FLOAT(ARGS); | |
| 350 | + t_CKFLOAT outRadius = GET_NEXT_FLOAT(ARGS); | |
| 351 | + | |
| 352 | + // set the return value | |
| 353 | + s_obj->setOutRadius(outCenter, outRadius); | |
| 354 | +} | |
| 355 | + | |
| 356 | +CK_DLL_MFUN(range_setRange) | |
| 357 | +{ | |
| 358 | + // get our c++ class pointer | |
| 359 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 360 | + | |
| 361 | + t_CKFLOAT inMin = GET_NEXT_FLOAT(ARGS); | |
| 362 | + t_CKFLOAT inMax = GET_NEXT_FLOAT(ARGS); | |
| 363 | + t_CKFLOAT outMin = GET_NEXT_FLOAT(ARGS); | |
| 364 | + t_CKFLOAT outMax = GET_NEXT_FLOAT(ARGS); | |
| 365 | + | |
| 366 | + // set the return value | |
| 367 | + s_obj->setRange(inMin, inMax, outMin, outMax); | |
| 368 | +} | |
| 369 | + | |
| 370 | +CK_DLL_MFUN(range_setRadius) | |
| 371 | +{ | |
| 372 | + // get our c++ class pointer | |
| 373 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 374 | + | |
| 375 | + t_CKFLOAT inCenter = GET_NEXT_FLOAT(ARGS); | |
| 376 | + t_CKFLOAT inRadius = GET_NEXT_FLOAT(ARGS); | |
| 377 | + t_CKFLOAT outCenter = GET_NEXT_FLOAT(ARGS); | |
| 378 | + t_CKFLOAT outRadius = GET_NEXT_FLOAT(ARGS); | |
| 379 | + | |
| 380 | + // set the return value | |
| 381 | + s_obj->setRadius(inCenter, inRadius, outCenter, outRadius); | |
| 382 | +} | |
| 383 | + | |
| 384 | +CK_DLL_MFUN(range_getInMin) | |
| 385 | +{ | |
| 386 | + // get our c++ class pointer | |
| 387 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 388 | + // set the return value | |
| 389 | + RETURN->v_float = s_obj->getInMin(); | |
| 390 | +} | |
| 391 | + | |
| 392 | +CK_DLL_MFUN(range_getInMax) | |
| 393 | +{ | |
| 394 | + // get our c++ class pointer | |
| 395 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 396 | + // set the return value | |
| 397 | + RETURN->v_float = s_obj->getInMax(); | |
| 398 | +} | |
| 399 | + | |
| 400 | +CK_DLL_MFUN(range_getOutMin) | |
| 401 | +{ | |
| 402 | + // get our c++ class pointer | |
| 403 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 404 | + // set the return value | |
| 405 | + RETURN->v_float = s_obj->getOutMin(); | |
| 406 | +} | |
| 407 | + | |
| 408 | +CK_DLL_MFUN(range_getOutMax) | |
| 409 | +{ | |
| 410 | + // get our c++ class pointer | |
| 411 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 412 | + // set the return value | |
| 413 | + RETURN->v_float = s_obj->getOutMax(); | |
| 414 | +} | |
| 415 | + | |
| 416 | +CK_DLL_MFUN(range_getInCenter) | |
| 417 | +{ | |
| 418 | + // get our c++ class pointer | |
| 419 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 420 | + // set the return value | |
| 421 | + RETURN->v_float = s_obj->getInCenter(); | |
| 422 | +} | |
| 423 | + | |
| 424 | +CK_DLL_MFUN(range_getInRadius) | |
| 425 | +{ | |
| 426 | + // get our c++ class pointer | |
| 427 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 428 | + // set the return value | |
| 429 | + RETURN->v_float = s_obj->getInRadius(); | |
| 430 | +} | |
| 431 | + | |
| 432 | +CK_DLL_MFUN(range_getOutCenter) | |
| 433 | +{ | |
| 434 | + // get our c++ class pointer | |
| 435 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 436 | + // set the return value | |
| 437 | + RETURN->v_float = s_obj->getOutCenter(); | |
| 438 | +} | |
| 439 | + | |
| 440 | +CK_DLL_MFUN(range_getOutRadius) | |
| 441 | +{ | |
| 442 | + // get our c++ class pointer | |
| 443 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 444 | + // set the return value | |
| 445 | + RETURN->v_float = s_obj->getOutRadius(); | |
| 446 | +} | |
| 447 | + | |
| 448 | +CK_DLL_MFUN(range_setClip) | |
| 449 | +{ | |
| 450 | + // get our c++ class pointer | |
| 451 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 452 | + // set the return value | |
| 453 | + RETURN->v_int = s_obj->setClip(GET_NEXT_INT(ARGS)); | |
| 454 | +} | |
| 455 | + | |
| 456 | +CK_DLL_MFUN(range_getClip) | |
| 457 | +{ | |
| 458 | + // get our c++ class pointer | |
| 459 | + Range* s_obj = (Range*)OBJ_MEMBER_INT(SELF, range_data_offset); | |
| 460 | + // set the return value | |
| 461 | + RETURN->v_int = s_obj->getClip(); | |
| 462 | +} | |
| @@ -0,0 +1,117 @@ | ||
| 1 | +# Microsoft Developer Studio Project File - Name="Range" - Package Owner=<4> | |
| 2 | +# Microsoft Developer Studio Generated Build File, Format Version 6.00 | |
| 3 | +# ** DO NOT EDIT ** | |
| 4 | + | |
| 5 | +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 | |
| 6 | + | |
| 7 | +CFG=Range - Win32 Debug | |
| 8 | +!MESSAGE This is not a valid makefile. To build this project using NMAKE, | |
| 9 | +!MESSAGE use the Export Makefile command and run | |
| 10 | +!MESSAGE | |
| 11 | +!MESSAGE NMAKE /f "Range.mak". | |
| 12 | +!MESSAGE | |
| 13 | +!MESSAGE You can specify a configuration when running NMAKE | |
| 14 | +!MESSAGE by defining the macro CFG on the command line. For example: | |
| 15 | +!MESSAGE | |
| 16 | +!MESSAGE NMAKE /f "Range.mak" CFG="Range - Win32 Debug" | |
| 17 | +!MESSAGE | |
| 18 | +!MESSAGE Possible choices for configuration are: | |
| 19 | +!MESSAGE | |
| 20 | +!MESSAGE "Range - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") | |
| 21 | +!MESSAGE "Range - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") | |
| 22 | +!MESSAGE | |
| 23 | + | |
| 24 | +# Begin Project | |
| 25 | +# PROP AllowPerConfigDependencies 0 | |
| 26 | +# PROP Scc_ProjName "" | |
| 27 | +# PROP Scc_LocalPath "" | |
| 28 | +CPP=cl.exe | |
| 29 | +MTL=midl.exe | |
| 30 | +RSC=rc.exe | |
| 31 | + | |
| 32 | +!IF "$(CFG)" == "Range - Win32 Release" | |
| 33 | + | |
| 34 | +# PROP BASE Use_MFC 0 | |
| 35 | +# PROP BASE Use_Debug_Libraries 0 | |
| 36 | +# PROP BASE Output_Dir "Release" | |
| 37 | +# PROP BASE Intermediate_Dir "Release" | |
| 38 | +# PROP BASE Target_Dir "" | |
| 39 | +# PROP Use_MFC 0 | |
| 40 | +# PROP Use_Debug_Libraries 0 | |
| 41 | +# PROP Output_Dir "Release" | |
| 42 | +# PROP Intermediate_Dir "Release" | |
| 43 | +# PROP Ignore_Export_Lib 0 | |
| 44 | +# PROP Target_Dir "" | |
| 45 | +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SCALER_EXPORTS" /Yu"stdafx.h" /FD /c | |
| 46 | +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\chuck\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "__PLATFORM_WIN32__" /D "__WINDOWS_DS__" /FD /c | |
| 47 | +# SUBTRACT CPP /YX /Yc /Yu | |
| 48 | +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | |
| 49 | +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | |
| 50 | +# ADD BASE RSC /l 0x409 /d "NDEBUG" | |
| 51 | +# ADD RSC /l 0x409 /d "NDEBUG" | |
| 52 | +BSC32=bscmake.exe | |
| 53 | +# ADD BASE BSC32 /nologo | |
| 54 | +# ADD BSC32 /nologo | |
| 55 | +LINK32=link.exe | |
| 56 | +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 | |
| 57 | +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/Range.chug" | |
| 58 | + | |
| 59 | +!ELSEIF "$(CFG)" == "Range - Win32 Debug" | |
| 60 | + | |
| 61 | +# PROP BASE Use_MFC 0 | |
| 62 | +# PROP BASE Use_Debug_Libraries 1 | |
| 63 | +# PROP BASE Output_Dir "Debug" | |
| 64 | +# PROP BASE Intermediate_Dir "Debug" | |
| 65 | +# PROP BASE Target_Dir "" | |
| 66 | +# PROP Use_MFC 0 | |
| 67 | +# PROP Use_Debug_Libraries 1 | |
| 68 | +# PROP Output_Dir "Debug" | |
| 69 | +# PROP Intermediate_Dir "Debug" | |
| 70 | +# PROP Ignore_Export_Lib 0 | |
| 71 | +# PROP Target_Dir "" | |
| 72 | +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SCALER_EXPORTS" /Yu"stdafx.h" /FD /GZ /c | |
| 73 | +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\chuck\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "__PLATFORM_WIN32__" /D "__WINDOWS_DS__" /FD /GZ /c | |
| 74 | +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 | |
| 75 | +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 | |
| 76 | +# ADD BASE RSC /l 0x409 /d "_DEBUG" | |
| 77 | +# ADD RSC /l 0x409 /d "_DEBUG" | |
| 78 | +BSC32=bscmake.exe | |
| 79 | +# ADD BASE BSC32 /nologo | |
| 80 | +# ADD BSC32 /nologo | |
| 81 | +LINK32=link.exe | |
| 82 | +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept | |
| 83 | +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/Range.chug" /pdbtype:sept | |
| 84 | + | |
| 85 | +!ENDIF | |
| 86 | + | |
| 87 | +# Begin Target | |
| 88 | + | |
| 89 | +# Name "Range - Win32 Release" | |
| 90 | +# Name "Range - Win32 Debug" | |
| 91 | +# Begin Group "Source Files" | |
| 92 | + | |
| 93 | +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" | |
| 94 | +# Begin Source File | |
| 95 | + | |
| 96 | +SOURCE=.\Range.cpp | |
| 97 | + | |
| 98 | +!IF "$(CFG)" == "Range - Win32 Release" | |
| 99 | + | |
| 100 | +!ELSEIF "$(CFG)" == "Range - Win32 Debug" | |
| 101 | + | |
| 102 | +# ADD CPP /D "__WINDOWS_DS__" | |
| 103 | + | |
| 104 | +!ENDIF | |
| 105 | + | |
| 106 | +# End Source File | |
| 107 | +# End Group | |
| 108 | +# Begin Group "Header Files" | |
| 109 | + | |
| 110 | +# PROP Default_Filter "h;hpp;hxx;hm;inl" | |
| 111 | +# End Group | |
| 112 | +# Begin Group "Resource Files" | |
| 113 | + | |
| 114 | +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" | |
| 115 | +# End Group | |
| 116 | +# End Target | |
| 117 | +# End Project | |
| @@ -0,0 +1,29 @@ | ||
| 1 | +Microsoft Developer Studio Workspace File, Format Version 6.00 | |
| 2 | +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! | |
| 3 | + | |
| 4 | +############################################################################### | |
| 5 | + | |
| 6 | +Project: "Range"=.\Range.dsp - Package Owner=<4> | |
| 7 | + | |
| 8 | +Package=<5> | |
| 9 | +{{{ | |
| 10 | +}}} | |
| 11 | + | |
| 12 | +Package=<4> | |
| 13 | +{{{ | |
| 14 | +}}} | |
| 15 | + | |
| 16 | +############################################################################### | |
| 17 | + | |
| 18 | +Global: | |
| 19 | + | |
| 20 | +Package=<5> | |
| 21 | +{{{ | |
| 22 | +}}} | |
| 23 | + | |
| 24 | +Package=<3> | |
| 25 | +{{{ | |
| 26 | +}}} | |
| 27 | + | |
| 28 | +############################################################################### | |
| 29 | + | |
| @@ -0,0 +1,77 @@ | ||
| 1 | +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
| 2 | + <ItemGroup> | |
| 3 | + <ProjectConfiguration Include="Debug|Win32"> | |
| 4 | + <Configuration>Debug</Configuration> | |
| 5 | + <Platform>Win32</Platform> | |
| 6 | + </ProjectConfiguration> | |
| 7 | + <ProjectConfiguration Include="Release|Win32"> | |
| 8 | + <Configuration>Release</Configuration> | |
| 9 | + <Platform>Win32</Platform> | |
| 10 | + </ProjectConfiguration> | |
| 11 | + </ItemGroup> | |
| 12 | + <PropertyGroup Label="Globals"> | |
| 13 | + <ProjectGuid>{C2BC72BF-43A2-4AC3-94E7-D7ACEEEC8C37}</ProjectGuid> | |
| 14 | + </PropertyGroup> | |
| 15 | + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | |
| 16 | + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | |
| 17 | + <ConfigurationType>DynamicLibrary</ConfigurationType> | |
| 18 | + <UseDebugLibraries>true</UseDebugLibraries> | |
| 19 | + <CharacterSet>Unicode</CharacterSet> | |
| 20 | + <PlatformToolset>v143</PlatformToolset> | |
| 21 | + </PropertyGroup> | |
| 22 | + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | |
| 23 | + <ConfigurationType>DynamicLibrary</ConfigurationType> | |
| 24 | + <UseDebugLibraries>false</UseDebugLibraries> | |
| 25 | + <WholeProgramOptimization>true</WholeProgramOptimization> | |
| 26 | + <CharacterSet>Unicode</CharacterSet> | |
| 27 | + <PlatformToolset>v143</PlatformToolset> | |
| 28 | + </PropertyGroup> | |
| 29 | + <Import Project="$(VCTargetsPath)/Microsoft.Cpp.props" /> | |
| 30 | + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |
| 31 | + <LinkIncremental>true</LinkIncremental> | |
| 32 | + <TargetExt>.chug</TargetExt> | |
| 33 | + <IncludePath>../chuck/include;$(IncludePath)</IncludePath> | |
| 34 | + </PropertyGroup> | |
| 35 | + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |
| 36 | + <LinkIncremental>false</LinkIncremental> | |
| 37 | + <TargetExt>.chug</TargetExt> | |
| 38 | + <IncludePath>../chuck/include;$(IncludePath)</IncludePath> | |
| 39 | + </PropertyGroup> | |
| 40 | + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |
| 41 | + <ClCompile> | |
| 42 | + <PrecompiledHeader> | |
| 43 | + </PrecompiledHeader> | |
| 44 | + <WarningLevel>Level3</WarningLevel> | |
| 45 | + <Optimization>Disabled</Optimization> | |
| 46 | + <PreprocessorDefinitions>WIN32;__PLATFORM_WIN32__;__WINDOWS_DS__;_DEBUG;_WINDOWS;_USRDLL;SCALER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
| 47 | + </ClCompile> | |
| 48 | + <Link> | |
| 49 | + <SubSystem>Windows</SubSystem> | |
| 50 | + <GenerateDebugInformation>true</GenerateDebugInformation> | |
| 51 | + </Link> | |
| 52 | + </ItemDefinitionGroup> | |
| 53 | + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |
| 54 | + <ClCompile> | |
| 55 | + <WarningLevel>Level3</WarningLevel> | |
| 56 | + <PrecompiledHeader> | |
| 57 | + </PrecompiledHeader> | |
| 58 | + <Optimization>MaxSpeed</Optimization> | |
| 59 | + <FunctionLevelLinking>true</FunctionLevelLinking> | |
| 60 | + <IntrinsicFunctions>true</IntrinsicFunctions> | |
| 61 | + <PreprocessorDefinitions>WIN32;__PLATFORM_WIN32__;__WINDOWS_DS__;NDEBUG;_WINDOWS;_USRDLL;SCALER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
| 62 | + </ClCompile> | |
| 63 | + <Link> | |
| 64 | + <SubSystem>Windows</SubSystem> | |
| 65 | + <GenerateDebugInformation>true</GenerateDebugInformation> | |
| 66 | + <EnableCOMDATFolding>true</EnableCOMDATFolding> | |
| 67 | + <OptimizeReferences>true</OptimizeReferences> | |
| 68 | + </Link> | |
| 69 | + </ItemDefinitionGroup> | |
| 70 | + <ItemGroup> | |
| 71 | + <ClCompile Include="Range.cpp" /> | |
| 72 | + </ItemGroup> | |
| 73 | + <ItemGroup> | |
| 74 | + <ClInclude Include="Range.h" /> | |
| 75 | + </ItemGroup> | |
| 76 | + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Targets" /> | |
| 77 | +</Project> | |
| @@ -0,0 +1,111 @@ | ||
| 1 | + | |
| 2 | +# chugin name | |
| 3 | +CHUGIN_NAME=Range | |
| 4 | + | |
| 5 | +# all of the c/cpp files that compose this chugin | |
| 6 | +C_MODULES= | |
| 7 | +CXX_MODULES=Range.cpp | |
| 8 | + | |
| 9 | +# where the chuck headers are | |
| 10 | +CK_SRC_PATH?=../chuck/include/ | |
| 11 | + | |
| 12 | + | |
| 13 | +# ---------------------------------------------------------------------------- # | |
| 14 | +# you won't generally need to change anything below this line for a new chugin # | |
| 15 | +# ---------------------------------------------------------------------------- # | |
| 16 | + | |
| 17 | +# default target: print usage message and quit | |
| 18 | +current: | |
| 19 | + @echo "[chuck build]: please use one of the following configurations:" | |
| 20 | + @echo " make linux, make osx, or make win32" | |
| 21 | + | |
| 22 | +ifneq ($(CK_TARGET),) | |
| 23 | +.DEFAULT_GOAL:=$(CK_TARGET) | |
| 24 | +ifeq ($(MAKECMDGOALS),) | |
| 25 | +MAKECMDGOALS:=$(.DEFAULT_GOAL) | |
| 26 | +endif | |
| 27 | +endif | |
| 28 | + | |
| 29 | +.PHONY: osx linux linux-oss linux-jack linux-alsa win32 | |
| 30 | +osx linux linux-oss linux-jack linux-alsa: all | |
| 31 | + | |
| 32 | +win32: | |
| 33 | + make -f makefile.win32 | |
| 34 | + | |
| 35 | +CC=gcc | |
| 36 | +CXX=gcc | |
| 37 | +LD=g++ | |
| 38 | + | |
| 39 | +CHUGIN_PATH=/usr/local/lib/chuck | |
| 40 | + | |
| 41 | +ifneq (,$(strip $(filter osx bin-dist-osx,$(MAKECMDGOALS)))) | |
| 42 | +include makefile.osx | |
| 43 | +endif | |
| 44 | + | |
| 45 | +ifneq (,$(strip $(filter linux,$(MAKECMDGOALS)))) | |
| 46 | +include makefile.linux | |
| 47 | +endif | |
| 48 | + | |
| 49 | +ifneq (,$(strip $(filter linux-oss,$(MAKECMDGOALS)))) | |
| 50 | +include makefile.linux | |
| 51 | +endif | |
| 52 | + | |
| 53 | +ifneq (,$(strip $(filter linux-jack,$(MAKECMDGOALS)))) | |
| 54 | +include makefile.linux | |
| 55 | +endif | |
| 56 | + | |
| 57 | +ifneq (,$(strip $(filter linux-alsa,$(MAKECMDGOALS)))) | |
| 58 | +include makefile.linux | |
| 59 | +endif | |
| 60 | + | |
| 61 | +ifneq ($(CHUCK_DEBUG),) | |
| 62 | +FLAGS+= -g | |
| 63 | +else | |
| 64 | +FLAGS+= -O3 | |
| 65 | +endif | |
| 66 | + | |
| 67 | +ifneq ($(CHUCK_STRICT),) | |
| 68 | +FLAGS+= -Werror | |
| 69 | +endif | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | +# default: build a dynamic chugin | |
| 74 | +CK_CHUGIN_STATIC?=0 | |
| 75 | + | |
| 76 | +ifeq ($(CK_CHUGIN_STATIC),0) | |
| 77 | +SUFFIX=.chug | |
| 78 | +else | |
| 79 | +SUFFIX=.schug | |
| 80 | +FLAGS+= -D__CK_DLL_STATIC__ | |
| 81 | +endif | |
| 82 | + | |
| 83 | +C_OBJECTS=$(addsuffix .o,$(basename $(C_MODULES))) | |
| 84 | +CXX_OBJECTS=$(addsuffix .o,$(basename $(CXX_MODULES))) | |
| 85 | + | |
| 86 | +CHUG=$(addsuffix $(SUFFIX),$(CHUGIN_NAME)) | |
| 87 | + | |
| 88 | +all: $(CHUG) | |
| 89 | + | |
| 90 | +$(CHUG): $(C_OBJECTS) $(CXX_OBJECTS) | |
| 91 | +ifeq ($(CK_CHUGIN_STATIC),0) | |
| 92 | + $(LD) $(LDFLAGS) -o $@ $^ | |
| 93 | +else | |
| 94 | + ar rv $@ $^ | |
| 95 | + ranlib $@ | |
| 96 | +endif | |
| 97 | + | |
| 98 | +$(C_OBJECTS): %.o: %.c | |
| 99 | + $(CC) $(FLAGS) -c -o $@ $< | |
| 100 | + | |
| 101 | +$(CXX_OBJECTS): %.o: %.cpp $(CK_SRC_PATH)/chuck_dl.h | |
| 102 | + $(CXX) $(FLAGS) -c -o $@ $< | |
| 103 | + | |
| 104 | +install: $(CHUG) | |
| 105 | + mkdir -p $(CHUGIN_PATH) | |
| 106 | + cp $^ $(CHUGIN_PATH) | |
| 107 | + chmod 755 $(CHUGIN_PATH)/$(CHUG) | |
| 108 | + | |
| 109 | +clean: | |
| 110 | + rm -rf $(C_OBJECTS) $(CXX_OBJECTS) $(CHUG) Release Debug | |
| 111 | + | |
| @@ -0,0 +1,8 @@ | ||
| 1 | + | |
| 2 | +CHUGIN_PATH=/usr/local/lib/chuck | |
| 3 | + | |
| 4 | +FLAGS=-D__LINUX_ALSA__ -D__PLATFORM_LINUX__ -I$(CK_SRC_PATH) -fPIC | |
| 5 | +LDFLAGS=-shared -lstdc++ | |
| 6 | + | |
| 7 | +LD=gcc | |
| 8 | +CXX=g++ | |
| @@ -0,0 +1,9 @@ | ||
| 1 | + | |
| 2 | +ARCHS?=x86_64 | |
| 3 | +ARCHOPTS=$(addprefix -arch ,$(ARCHS)) | |
| 4 | + | |
| 5 | +FLAGS+=-mmacosx-version-min=10.9 -D__MACOSX_CORE__ -I$(CK_SRC_PATH) $(ARCHOPTS) -fPIC | |
| 6 | +LDFLAGS+=-mmacosx-version-min=10.9 -shared -lc++ $(ARCHOPTS) | |
| 7 | + | |
| 8 | +LD=clang++ | |
| 9 | +CXX=clang++ | |
| @@ -0,0 +1,18 @@ | ||
| 1 | +MSBUILD=msbuild.exe | |
| 2 | + | |
| 3 | +ifneq (,$(CHUCK_DEBUG)) | |
| 4 | +CONFIG=Debug | |
| 5 | +CHUG_BIN=Debug/Scaler.chug | |
| 6 | +else | |
| 7 | +CONFIG=Release | |
| 8 | +CHUG_BIN=Release/Scaler.chug | |
| 9 | +endif | |
| 10 | + | |
| 11 | +default: $(CHUG_BIN) | |
| 12 | + | |
| 13 | +$(CHUG_BIN): | |
| 14 | + $(MSBUILD) /p:Configuration=$(CONFIG) | |
| 15 | + | |
| 16 | +clean: | |
| 17 | + $(MSBUILD) /p:Configuration=$(CONFIG) /t:Clean | |
| 18 | + | |