[SCM] calf/master: + Organ: remove DC offset from "for-display" versions of waveforms

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


The following commit has been merged in the master branch:
commit 6672d5c296437de4af76f5f36ff9cfe2bafc519e
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Thu May 15 21:14:59 2008 +0000

    + Organ: remove DC offset from "for-display" versions of waveforms
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@177 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/osc.h b/src/calf/osc.h
index e3d9915..0e6e991 100644
--- a/src/calf/osc.h
+++ b/src/calf/osc.h
@@ -166,6 +166,12 @@ struct waveform_oscillator: public simple_oscillator
 
 static inline void normalize_waveform(float *table, unsigned int size)
 {
+    float dc = 0;
+    for (unsigned int i = 0; i < size; i++)
+        dc += table[i];
+    dc /= size;
+    for (unsigned int i = 0; i < size; i++)
+        table[i] -= dc;
     float thismax = 0;
     for (unsigned int i = 0; i < size; i++)
         thismax = std::max(thismax, fabs(table[i]));
diff --git a/src/organ.cpp b/src/organ.cpp
index 82f32c4..c021f4a 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -542,29 +542,36 @@ organ_voice_base::organ_voice_base(organ_parameters *_parameters)
         
         for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
             tmp[i] = (i < (ORGAN_WAVE_SIZE / 2)) ? 1 : -1;
+        normalize_waveform(tmp, ORGAN_WAVE_SIZE);
         smoothen(bl, tmp);
         waves[wave_ssqr].make(bl, tmp);
         
         for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
             tmp[i] = -1 + (i * 2.0 / ORGAN_WAVE_SIZE);
+        normalize_waveform(tmp, ORGAN_WAVE_SIZE);
         smoothen(bl, tmp);
         waves[wave_ssaw].make(bl, tmp);
 
         for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
             tmp[i] = (i < (ORGAN_WAVE_SIZE / 16)) ? 1 : 0;
+        normalize_waveform(tmp, ORGAN_WAVE_SIZE);
         smoothen(bl, tmp);
         waves[wave_spls].make(bl, tmp);
         for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
             tmp[i] = i < (ORGAN_WAVE_SIZE / 1.5) ? sin(i * 1.5 * 2 * M_PI / ORGAN_WAVE_SIZE) : 0;
+        normalize_waveform(tmp, ORGAN_WAVE_SIZE);
         waves[wave_sinepl05].make(bl, tmp);
         for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
             tmp[i] = i < (ORGAN_WAVE_SIZE / 1.5) ? (i < ORGAN_WAVE_SIZE / 3 ? -1 : +1) : 0;
+        normalize_waveform(tmp, ORGAN_WAVE_SIZE);
         waves[wave_sqr05].make(bl, tmp);
         for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
             tmp[i] = sin(i * M_PI / ORGAN_WAVE_SIZE);
+        normalize_waveform(tmp, ORGAN_WAVE_SIZE);
         waves[wave_halfsin].make(bl, tmp);
         for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
             tmp[i] = sin(i * 3 * M_PI / ORGAN_WAVE_SIZE);
+        normalize_waveform(tmp, ORGAN_WAVE_SIZE);
         waves[wave_clvg].make(bl, tmp);
         for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
         {

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list