[SCM] calf/master: + Code cleanups, added comments (in a highly unlikely case someone wanted to take over, fork or join the project)

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:37:25 UTC 2013


The following commit has been merged in the master branch:
commit 4a918477f47a28eaa365089fad3d295482b1955b
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Fri Jul 18 12:14:20 2008 +0000

    + Code cleanups, added comments (in a highly unlikely case someone wanted to take over, fork or join the project)
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@236 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/biquad.h b/src/calf/biquad.h
index 0e1c049..8853408 100644
--- a/src/calf/biquad.h
+++ b/src/calf/biquad.h
@@ -62,7 +62,7 @@ public:
      */
     inline void set_lp_rbj(float fc, float q, float sr, float gain = 1.0)
     {
-        float omega=(float)(2*PI*fc/sr);
+        float omega=(float)(2*M_PI*fc/sr);
         float sn=sin(omega);
         float cs=cos(omega);
         float alpha=(float)(sn/(2*q));
@@ -81,7 +81,7 @@ public:
     // from how it looks, it perhaps uses bilinear transform - but who knows :)
     inline void set_lp_zoelzer(float fc, float q, float odsr, float gain=1.0)
     {
-        Coeff omega=(Coeff)(PI*fc*odsr);
+        Coeff omega=(Coeff)(M_PI*fc*odsr);
         Coeff omega2=omega*omega;
         Coeff K=omega*(1+omega2*omega2*Coeff(1.0/1.45));
         Coeff KK=K*K;
@@ -96,7 +96,7 @@ public:
 
     void set_hp_rbj(float fc, float q, float esr, float gain=1.0)
     {
-        Coeff omega=(float)(2*PI*fc/esr);
+        Coeff omega=(float)(2*M_PI*fc/esr);
 		Coeff sn=sin(omega);
 		Coeff cs=cos(omega);
         Coeff alpha=(float)(sn/(2*q));
@@ -113,7 +113,7 @@ public:
     // this replaces sin/cos with polynomial approximation
     void set_hp_rbj_optimized(float fc, float q, float esr, float gain=1.0)
     {
-        Coeff omega=(float)(2*PI*fc/esr);
+        Coeff omega=(float)(2*M_PI*fc/esr);
 		Coeff sn=omega+omega*omega*omega*(1.0/6.0)+omega*omega*omega*omega*omega*(1.0/120);
 		Coeff cs=1-omega*omega*(1.0/2.0)+omega*omega*omega*omega*(1.0/24);
         Coeff alpha=(float)(sn/(2*q));
@@ -130,7 +130,7 @@ public:
     // rbj's bandpass
     void set_bp_rbj(double fc, double q, double esr, double gain=1.0)
     {
-        float omega=(float)(2*PI*fc/esr);
+        float omega=(float)(2*M_PI*fc/esr);
         float sn=sin(omega);
         float cs=cos(omega);
         float alpha=(float)(sn/(2*q));
@@ -147,7 +147,7 @@ public:
     // rbj's bandreject
     void set_br_rbj(double fc, double q, double esr, double gain=1.0)
     {
-        float omega=(float)(2*PI*fc/esr);
+        float omega=(float)(2*M_PI*fc/esr);
         float sn=sin(omega);
         float cs=cos(omega);
         float alpha=(float)(sn/(2*q));
@@ -161,28 +161,28 @@ public:
         b2 =  (Coeff)((1 - alpha)*inv);
     }
     // this is mine (and, I guess, it sucks/doesn't work)
-	void set_allpass(float freq, float pole_r, float sr)
-	{
-		float a=prewarp(freq, sr);
-		float q=pole_r;
-		set_bilinear(a*a+q*q, -2.0f*a, 1, a*a+q*q, 2.0f*a, 1);
-	}
-    // prewarping for bilinear transform, maps given digital frequency to analog counterpart for analog filter design
-	float prewarp(float freq, float sr)
-	{
-		if (freq>sr*0.49) freq=(float)(sr*0.49);
-		return (float)(tan(3.1415926*freq/sr));
-	}
-    // set digital filter parameters based on given analog filter parameters
-	void set_bilinear(float aa0, float aa1, float aa2, float ab0, float ab1, float ab2)
-	{
-		float q=(float)(1.0/(ab0+ab1+ab2));
-		a0 = (aa0+aa1+aa2)*q;
-		a1 = 2*(aa0-aa2)*q;
-		a2 = (aa0-aa1+aa2)*q;
-		b1 = 2*(ab0-ab2)*q;
-		b2 = (ab0-ab1+ab2)*q;
-	}
+    void set_allpass(float freq, float pole_r, float sr)
+    {
+            float a=prewarp(freq, sr);
+            float q=pole_r;
+            set_bilinear(a*a+q*q, -2.0f*a, 1, a*a+q*q, 2.0f*a, 1);
+    }
+    /// prewarping for bilinear transform, maps given digital frequency to analog counterpart for analog filter design
+    float prewarp(float freq, float sr)
+    {
+            if (freq>sr*0.49) freq=(float)(sr*0.49);
+            return (float)(tan(M_PI*freq/sr));
+    }
+    /// set digital filter parameters based on given analog filter parameters
+    void set_bilinear(float aa0, float aa1, float aa2, float ab0, float ab1, float ab2)
+    {
+            float q=(float)(1.0/(ab0+ab1+ab2));
+            a0 = (aa0+aa1+aa2)*q;
+            a1 = 2*(aa0-aa2)*q;
+            a2 = (aa0-aa1+aa2)*q;
+            b1 = 2*(ab0-ab2)*q;
+            b2 = (ab0-ab1+ab2)*q;
+    }
     
     template<class U>
     inline void copy_coeffs(const biquad<U> &src)
diff --git a/src/calf/fft.h b/src/calf/fft.h
index 7272f18..5cb50d5 100644
--- a/src/calf/fft.h
+++ b/src/calf/fft.h
@@ -49,7 +49,7 @@ public:
             scramble[i]=v;
         }
         int N90 = N >> 2;
-        T divN = 2 * PI / N;
+        T divN = 2 * M_PI / N;
         // use symmetry
         for (int i=0; i<N90; i++)
         {
diff --git a/src/calf/modules_synths.h b/src/calf/modules_synths.h
index a54275d..0194661 100644
--- a/src/calf/modules_synths.h
+++ b/src/calf/modules_synths.h
@@ -73,6 +73,8 @@ public:
     static void generate_waves();
     void set_sample_rate(uint32_t sr);
     void delayed_note_on();
+    /// Handle MIDI Note On message (does not immediately trigger a note, as it must start on
+    /// boundary of step_size samples).
     void note_on(int note, int vel)
     {
         queue_note_on = note;
@@ -80,15 +82,17 @@ public:
         queue_vel = vel / 127.f;
         stack.push(note);
     }
+    /// Handle MIDI Note Off message
     void note_off(int note, int vel)
     {
         stack.pop(note);
+        // If releasing the currently played note, try to get another one from note stack.
         if (note == last_key) {
             if (stack.count())
             {
                 last_key = note = stack.nth(stack.count() - 1);
                 start_freq = freq;
-                target_freq = freq = 440 * pow(2.0, (note - 69) / 12.0);
+                target_freq = freq = note_to_hz(note);
                 set_frequency();
                 if (!(legato & 1)) {
                     envelope.note_on();
@@ -101,16 +105,20 @@ public:
             envelope.note_off();
         }
     }
+    /// Handle pitch bend message.
     inline void pitch_bend(int value)
     {
         pitchbend = pow(2.0, value / 8192.0);
     }
+    /// Update oscillator frequency based on base frequency, detune amount, pitch bend scaling factor and sample rate.
     inline void set_frequency()
     {
         osc1.set_freq(freq * (2 - detune) * pitchbend, srate);
         osc2.set_freq(freq * (detune)  * pitchbend * xpose, srate);
     }
+    /// Handle control change messages.
     void control_change(int controller, int value);
+    /// Update variables from control ports.
     void params_changed() {
         float sf = 0.001f;
         envelope.set(*params[par_attack] * sf, *params[par_decay] * sf, min(0.999f, *params[par_sustain]), *params[par_release] * sf, srate / step_size);
@@ -128,6 +136,7 @@ public:
     }
     void activate();
     void deactivate() {}
+    /// Hard-knee 2:1 reducation outside range [-0.75, +0.75]
     inline float softclip(float wave) const
     {
         float abswave = fabs(wave);
@@ -140,16 +149,25 @@ public:
         }
         return wave;
     }
+    /// Run oscillators and two filters in series to produce mono output samples.
     void calculate_buffer_ser();
+    /// Run oscillators and just one filter to produce mono output samples.
     void calculate_buffer_single();
+    /// Run oscillators and two filters (one per channel) to produce stereo output samples.
     void calculate_buffer_stereo();
+    /// Retrieve filter graph (which is 'live' so it cannot be generated by get_static_graph), or fall back to get_static_graph.
     bool get_graph(int index, int subindex, float *data, int points, cairo_t *context);
+    /// Retrieve waveform graph (which does not need information about synth state)
     static bool get_static_graph(int index, int subindex, float value, float *data, int points, cairo_t *context);
+    /// @retval true if the filter 1 is to be used for the left channel and filter 2 for the right channel
+    /// @retval false if filters are to be connected in series and sent (mono) to both channels
     inline bool is_stereo_filter() const
     {
         return filter_type == flt_2lp12 || filter_type == flt_2bp6;
     }
+    /// Calculate control signals and produce step_size samples of output.
     void calculate_step();
+    /// Main processing function
     uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
         if (!running && queue_note_on == -1)
             return 0;
diff --git a/src/calf/onepole.h b/src/calf/onepole.h
index 790b318..bb1c196 100644
--- a/src/calf/onepole.h
+++ b/src/calf/onepole.h
@@ -42,10 +42,10 @@ public:
     {
         //   x   x
         //  x+1 x-1
-		Coeff x = tan (PI * fc / (2 * sr));
+        Coeff x = tan (M_PI * fc / (2 * sr));
         Coeff q = 1/(1+x);
-		a0 = a1 = x*q;
-		b1 = (x-1)*q;
+	a0 = a1 = x*q;
+	b1 = (x-1)*q;
     }
     
     /// Set coefficients for an allpass filter
@@ -53,9 +53,9 @@ public:
     {
         // x-1  x+1
         // x+1  x-1
-		Coeff x = tan (PI * fc / (2 * sr));
-		Coeff q = 1/(1+x);
-		b1 = a0 = (x-1)*q;
+	Coeff x = tan (M_PI * fc / (2 * sr));
+	Coeff q = 1/(1+x);
+	b1 = a0 = (x-1)*q;
         a1 = 1;
     }
     
@@ -65,9 +65,9 @@ public:
     {
         // x-1  x+1
         // x+1  x-1
-		Coeff x = tan (w);
-		Coeff q = 1/(1+x);
-		b1 = a0 = (x-1)*q;
+	Coeff x = tan (w);
+	Coeff q = 1/(1+x);
+	b1 = a0 = (x-1)*q;
         a1 = 1;
     }
     
@@ -76,11 +76,11 @@ public:
     {
         //   x   -x
         //  x+1  x-1
-		Coeff x = tan (PI * fc / (2 * sr));
-		Coeff q = 1/(1+x);
-		a0 = q;
+	Coeff x = tan (M_PI * fc / (2 * sr));
+	Coeff q = 1/(1+x);
+	a0 = q;
         a1 = -a0;
-		b1 = (x-1)*q;
+	b1 = (x-1)*q;
     }
     
     /// Process one sample
diff --git a/src/calf/osc.h b/src/calf/osc.h
index b87b90e..1b12ec1 100644
--- a/src/calf/osc.h
+++ b/src/calf/osc.h
@@ -28,15 +28,22 @@
 namespace synth
 {
 
-/// Very simple, non-bandlimited saw oscillator. Should not be used for anything
-/// else than testing/prototyping.
+/** Very simple, non-bandlimited saw oscillator. Should not be used for anything
+ *  else than testing/prototyping. Unless get() function is replaced with something
+ * with "proper" oscillator code, as the frequency setting function is fine.
+ */
 struct simple_oscillator
 {
-    uint32_t phase, phasedelta;
+    /// Phase (from 0 to 0xFFFFFFFF)
+    uint32_t phase;
+    /// Per-sample phase delta (phase increment), equal to 2^32*freq/sr.
+    uint32_t phasedelta;
+    /// Reset oscillator phase to zero.
     void reset()
     {
         phase = 0;
     }
+    /// Set phase delta based on oscillator frequency and sample rate.
     void set_freq(float freq, float sr)
     {
         phasedelta = (int)(freq * 65536.0 * 256.0 * 16.0 / sr) << 4;
@@ -49,6 +56,11 @@ struct simple_oscillator
     }
 };
 
+/**
+ * FFT-based bandlimiting helper class. Allows conversion between time and frequency domains and generating brickwall filtered
+ * versions of a waveform given a pre-computed spectrum.
+ * Waveform size must be a power of two, and template argument SIZE_BITS is log2 of waveform size.
+ */
 template<int SIZE_BITS>
 struct bandlimiter
 {
@@ -61,6 +73,7 @@ struct bandlimiter
     
     std::complex<float> spectrum[SIZE];
     
+    /// Import time domain waveform and calculate spectrum from it
     void compute_spectrum(float input[SIZE])
     {
         dsp::fft<float, SIZE_BITS> &fft = get_fft();
@@ -71,6 +84,7 @@ struct bandlimiter
         delete []data;
     }
     
+    /// Generate the waveform from the contained spectrum.
     void compute_waveform(float output[SIZE])
     {
         dsp::fft<float, SIZE_BITS> &fft = get_fft();
@@ -87,7 +101,7 @@ struct bandlimiter
         spectrum[0] = 0.f;
     }
     
-    /// very basic bandlimiting (brickwall filter)
+    /// Very basic bandlimiting (brickwall filter)
     /// might need to be improved much in future!
     void make_waveform(float output[SIZE], int cutoff, bool foldover = false)
     {
@@ -95,9 +109,15 @@ struct bandlimiter
         vector<std::complex<float> > new_spec, iffted;
         new_spec.resize(SIZE);
         iffted.resize(SIZE);
-        for (int i = 0; i < cutoff; i++)
+        // Copy original harmonics up to cutoff point
+        new_spec[0] = spectrum[0];
+        for (int i = 1; i < cutoff; i++)
             new_spec[i] = spectrum[i], 
-            new_spec[SIZE - 1 - i] = spectrum[SIZE - 1 - i];
+            new_spec[SIZE - i] = spectrum[SIZE - i];
+        // Fill the rest with zeros, optionally folding over harmonics over the
+        // cutoff point into the lower octaves while halving the amplitude.
+        // (I think it is almost nice for bell type waveforms when the original
+        // waveform has few widely spread harmonics)
         if (foldover)
         {
             std::complex<float> half(0.5);
@@ -116,6 +136,7 @@ struct bandlimiter
                 new_spec[i] = 0.f,
                 new_spec[SIZE - 1 - i] = 0.f;
         }
+        // convert back to time domain (IFFT) and extract only real part
         fft.calculate(new_spec.data(), iffted.data(), true);
         for (int i = 0; i < SIZE; i++)
             output[i] = iffted[i].real();
@@ -132,6 +153,8 @@ struct waveform_family: public map<uint32_t, float *>
     using map<uint32_t, float *>::lower_bound;
     float original[SIZE];
     
+    /// Fill the family using specified bandlimiter and original waveform. Optionally apply foldover. 
+    /// Does not produce harmonics over specified limit (limit = (SIZE / 2) / min_number_of_harmonics)
     void make(bandlimiter<SIZE_BITS> &bl, float input[SIZE], bool foldover = false, uint32_t limit = SIZE / 2)
     {
         memcpy(original, input, sizeof(original));
@@ -139,6 +162,8 @@ struct waveform_family: public map<uint32_t, float *>
         make_from_spectrum(bl, foldover);
     }
     
+    /// Fill the family using specified bandlimiter and spectrum contained within. Optionally apply foldover. 
+    /// Does not produce harmonics over specified limit (limit = (SIZE / 2) / min_number_of_harmonics)
     void make_from_spectrum(bandlimiter<SIZE_BITS> &bl, bool foldover = false, uint32_t limit = SIZE / 2)
     {
         bl.remove_dc();
@@ -153,6 +178,7 @@ struct waveform_family: public map<uint32_t, float *>
         }
     }
     
+    /// Retrieve waveform pointer suitable for specified phase_delta
     inline float *get_level(uint32_t phase_delta)
     {
         iterator i = upper_bound(phase_delta);
@@ -161,6 +187,7 @@ struct waveform_family: public map<uint32_t, float *>
         // printf("Level = %08x\n", i->first);
         return i->second;
     }
+    /// Destructor, deletes the waveforms and removes them from the map.
     ~waveform_family()
     {
         for (iterator i = begin(); i != end(); i++)
@@ -169,6 +196,12 @@ struct waveform_family: public map<uint32_t, float *>
     }
 };
 
+/**
+ * Simple table-based lerping oscillator. Uses waveform of size 2^SIZE_BITS.
+ * Combine with waveform_family if bandlimited waveforms are needed. Because
+ * of linear interpolation, it's usually a good idea to use large tables
+ * (2048-4096 points), otherwise aliasing may be produced.
+ */
 template<int SIZE_BITS>
 struct waveform_oscillator: public simple_oscillator
 {
@@ -183,6 +216,7 @@ struct waveform_oscillator: public simple_oscillator
     }
 };
 
+/// Simple stupid inline function to normalize a waveform (by removing DC offset and ensuring max absolute value of 1).
 static inline void normalize_waveform(float *table, unsigned int size)
 {
     float dc = 0;
@@ -196,8 +230,9 @@ static inline void normalize_waveform(float *table, unsigned int size)
         thismax = std::max(thismax, fabs(table[i]));
     if (thismax < 0.000001f)
         return;
+    double divv = 1.0 / thismax;
     for (unsigned int i = 0; i < size; i++)
-        table[i] /= thismax;
+        table[i] *= divv;
 }
 
 
diff --git a/src/calf/primitives.h b/src/calf/primitives.h
index a7143bf..4e9823f 100644
--- a/src/calf/primitives.h
+++ b/src/calf/primitives.h
@@ -29,21 +29,34 @@ namespace dsp {
 
 using namespace std;
 
+/// Set a float to zero
 inline void zero(float &v) {
     v = 0;
 };
 
+/// Set a double to zero
 inline void zero(double &v) {
     v = 0;
 };
 
+/// Set 64-bit unsigned integer value to zero
+inline void zero(uint64_t &v) { v = 0; };
+/// Set 32-bit unsigned integer value to zero
 inline void zero(uint32_t &v) { v = 0; };
+/// Set 16-bit unsigned integer value to zero
 inline void zero(uint16_t &v) { v = 0; };
+/// Set 8-bit unsigned integer value to zero
 inline void zero(uint8_t &v) { v = 0; };
+/// Set 64-bit signed integer value to zero
+inline void zero(int64_t &v) { v = 0; };
+/// Set 32-bit signed integer value to zero
 inline void zero(int32_t &v) { v = 0; };
+/// Set 16-bit signed integer value to zero
 inline void zero(int16_t &v) { v = 0; };
+/// Set 8-bit signed integer value to zero
 inline void zero(int8_t &v) { v = 0; };
 
+/// Set array (buffer or anything similar) to vector of zeroes
 template<class T>
 void zero(T *data, unsigned int size) {
     T value;
@@ -52,8 +65,6 @@ void zero(T *data, unsigned int size) {
         *data++ = value;
 }
 
-const double PI = 4.0 * atan(1.0);
-    
 template<class T = float>struct stereo_sample {
     T left;
     T right;
@@ -137,21 +148,25 @@ template<class T = float>struct stereo_sample {
     }
 };
 
+/// Multiply constant by stereo_value
 template<class T>
 inline stereo_sample<T> operator*(const T &value, const stereo_sample<T> &value2) {
     return stereo_sample<T>(value2.left*value, value2.right*value);
 }
 
+/// Add constant to stereo_value
 template<class T>
 inline stereo_sample<T> operator+(const T &value, const stereo_sample<T> &value2) {
     return stereo_sample<T>(value2.left+value, value2.right+value);
 }
 
+/// Subtract stereo_value from constant (yields stereo_value of course)
 template<class T>
 inline stereo_sample<T> operator-(const T &value, const stereo_sample<T> &value2) {
     return stereo_sample<T>(value-value2.left, value-value2.right);
 }
 
+/// Shift value right by 'bits' bits (multiply by 2^-bits)
 template<typename T>
 inline stereo_sample<T> shr(stereo_sample<T> v, int bits = 1) {
     v.left = shr(v.left, bits);
@@ -159,37 +174,44 @@ inline stereo_sample<T> shr(stereo_sample<T> v, int bits = 1) {
     return v;
 }
 
+/// Set a stereo_sample<T> value to zero
 template<typename T> 
 inline void zero(stereo_sample<T> &v) {
     dsp::zero(v.left);
     dsp::zero(v.right);
 }
 
+/// 'Small value' for integer and other types
 template<typename T>
 inline T small_value() {
     return 0;
 }
 
+/// 'Small value' for floats (2^-24) - used for primitive underrun prevention. The value is pretty much arbitrary (allowing for 24-bit signals normalized to 1.0).
 template<>
 inline float small_value<float>() {
     return (1.0/16777216.0); // allows for 2^-24, should be enough for 24-bit DACs at least :)
 }
 
+/// 'Small value' for doubles (2^-24) - used for primitive underrun prevention. The value is pretty much arbitrary.
 template<>
 inline double small_value<double>() {
     return (1.0/16777216.0);
 }
 
+/// Convert a single value to single value = do nothing :) (but it's a generic with specialisation for stereo_sample)
 template<typename T> 
 inline float mono(T v) {
     return v;
 }
 
+/// Convert a stereo_sample to single value by averaging two channels
 template<typename T> 
 inline T mono(stereo_sample<T> v) {
     return shr(v.left+v.right);
 }
 
+/// Clip a value to [min, max]
 template<typename T> 
 inline T clip(T value, T min, T max) {
     if (value < min) return min;
@@ -197,35 +219,41 @@ inline T clip(T value, T min, T max) {
     return value;
 }
 
+/// Clip a double to [-1.0, +1.0]
 inline double clip11(double value) {
     double a = fabs(value);
     if (a<=1) return value;
     return (a<0) ? -1.0 : 1.0;
 }
 
+/// Clip a float to [-1.0f, +1.0f]
 inline float clip11(float value) {
     float a = fabsf(value);
     if (a<=1) return value;
     return (a<0) ? -1.0f : 1.0f;
 }
 
+/// Clip a double to [0.0, +1.0]
 inline double clip01(double value) {
     double a = fabs(value-0.5);
     if (a<=0.5) return value;
     return (a<0) ? -0.0 : 1.0;
 }
 
+/// Clip a float to [0.0f, +1.0f]
 inline float clip01(float value) {
     float a = fabsf(value-0.5f);
     if (a<=0.5f) return value;
     return (a<0) ? -0.0f : 1.0f;
 }
 
+// Linear interpolation (mix-way between v1 and v2).
 template<typename T, typename U>
 inline T lerp(T v1, T v2, U mix) {
     return v1+(v2-v1)*mix;
 }
 
+// Linear interpolation for stereo values (mix-way between v1 and v2).
 template<typename T>
 inline stereo_sample<T> lerp(stereo_sample<T> &v1, stereo_sample<T> &v2, float mix) {
     return stereo_sample<T>(v1.left+(v2.left-v1.left)*mix, v1.right+(v2.right-v1.right)*mix);
@@ -423,6 +451,12 @@ inline int fastf2i_drm(float f)
 	return v;
 }
 
+/// Convert MIDI note to frequency in Hz.
+inline float note_to_hz(double note)
+{
+    return 440 * pow(2.0, (note - 69) / 12.0);
+}
+
 };
 
 #endif
diff --git a/src/main_win.cpp b/src/main_win.cpp
index 9b4902d..82e2853 100644
--- a/src/main_win.cpp
+++ b/src/main_win.cpp
@@ -168,7 +168,6 @@ gui_button_pressed(GtkWidget *button, main_window::plugin_strip *strip)
 static gboolean
 extra_button_pressed(GtkWidget *button, main_window::plugin_strip *strip)
 {
-    GtkButton *tb = GTK_BUTTON(button);
     strip->main_win->owner->remove_plugin(strip->plugin);
     return TRUE;
 }
diff --git a/src/monosynth.cpp b/src/monosynth.cpp
index 7f29502..9af5dca 100644
--- a/src/monosynth.cpp
+++ b/src/monosynth.cpp
@@ -274,7 +274,7 @@ void monosynth_audio_module::generate_waves()
 
     // XXXKF sure this is a waste of space, this will be fixed some day by better bandlimiter
     for (int i = 0 ; i < S; i++)
-        data[i] = (float)sin(i * PI / HS);
+        data[i] = (float)sin(i * M_PI / HS);
     waves[wave_sine].make(bl, data);
 
     for (int i = 0 ; i < QS; i++) {
@@ -304,43 +304,43 @@ void monosynth_audio_module::generate_waves()
     for (int i = 0; i < S; i++) {
         if (i < QS3) {
             float p = i * 1.0 / QS3;
-            data[i] = sin(PI * p * p * p);
+            data[i] = sin(M_PI * p * p * p);
         } else {
             float p = (i - QS3 * 1.0) / QS;
-            data[i] = -0.5 * sin(3 * PI * p * p);
+            data[i] = -0.5 * sin(3 * M_PI * p * p);
         }
     }
     waves[wave_test1].make(bl, data);
     for (int i = 0; i < S; i++) {
-        data[i] = exp(-i * 1.0 / HS) * sin(i * PI / HS) * cos(2 * PI * i / HS);
+        data[i] = exp(-i * 1.0 / HS) * sin(i * M_PI / HS) * cos(2 * M_PI * i / HS);
     }
     normalize_waveform(data, S);
     waves[wave_test2].make(bl, data);
     for (int i = 0; i < S; i++) {
         //int ii = (i < HS) ? i : S - i;
         int ii = HS;
-        data[i] = (ii * 1.0 / HS) * sin(i * 3 * PI / HS + 2 * PI * sin(PI / 4 + i * 4 * PI / HS)) * sin(i * 5 * PI / HS + 2 * PI * sin(PI / 8 + i * 6 * PI / HS));
+        data[i] = (ii * 1.0 / HS) * sin(i * 3 * M_PI / HS + 2 * M_PI * sin(M_PI / 4 + i * 4 * M_PI / HS)) * sin(i * 5 * M_PI / HS + 2 * M_PI * sin(M_PI / 8 + i * 6 * M_PI / HS));
     }
     waves[wave_test3].make(bl, data);
     for (int i = 0; i < S; i++) {
-        data[i] = sin(i * 2 * PI / HS + sin(i * 2 * PI / HS + 0.5 * PI * sin(i * 18 * PI / HS)) * sin(i * 1 * PI / HS + 0.5 * PI * sin(i * 11 * PI / HS)));
+        data[i] = sin(i * 2 * M_PI / HS + sin(i * 2 * M_PI / HS + 0.5 * M_PI * sin(i * 18 * M_PI / HS)) * sin(i * 1 * M_PI / HS + 0.5 * M_PI * sin(i * 11 * M_PI / HS)));
     }
     waves[wave_test4].make(bl, data);
     for (int i = 0; i < S; i++) {
-        data[i] = sin(i * 2 * PI / HS + 0.2 * PI * sin(i * 13 * PI / HS) + 0.1 * PI * sin(i * 37 * PI / HS)) * sin(i * PI / HS + 0.2 * PI * sin(i * 15 * PI / HS));
+        data[i] = sin(i * 2 * M_PI / HS + 0.2 * M_PI * sin(i * 13 * M_PI / HS) + 0.1 * M_PI * sin(i * 37 * M_PI / HS)) * sin(i * M_PI / HS + 0.2 * M_PI * sin(i * 15 * M_PI / HS));
     }
     waves[wave_test5].make(bl, data);
     for (int i = 0; i < S; i++) {
         if (i < HS)
-            data[i] = sin(i * 2 * PI / HS);
+            data[i] = sin(i * 2 * M_PI / HS);
         else
         if (i < 3 * S / 4)
-            data[i] = sin(i * 4 * PI / HS);
+            data[i] = sin(i * 4 * M_PI / HS);
         else
         if (i < 7 * S / 8)
-            data[i] = sin(i * 8 * PI / HS);
+            data[i] = sin(i * 8 * M_PI / HS);
         else
-            data[i] = sin(i * 8 * PI / HS) * (S - i) / (S / 8);
+            data[i] = sin(i * 8 * M_PI / HS) * (S - i) / (S / 8);
     }
     waves[wave_test6].make(bl, data);
     for (int i = 0; i < S; i++) {
@@ -384,7 +384,7 @@ bool monosynth_audio_module::get_graph(int index, int subindex, float *data, int
         for (int i = 0; i < points; i++)
         {
             typedef complex<double> cfloat;
-            double freq = 20.0 * pow (20000.0 / 20.0, i * 1.0 / points) * PI / srate;
+            double freq = 20.0 * pow (20000.0 / 20.0, i * 1.0 / points) * M_PI / srate;
             cfloat z = 1.0 / exp(cfloat(0.0, freq));
             
             biquad<float> &f = subindex ? filter2 : filter;

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list