~ubuntu-branches/ubuntu/breezy/muse/breezy

« back to all changes in this revision

Viewing changes to synti/stklib/JCRev.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2004-02-07 15:18:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040207151822-es27xxkzbcxkebjm
Tags: 0.6.3-1
* New upstream version.
* Added patches:
  + [10_alsa_init_fix] New, from upstream CVS.
    Initialize direction variable when setting Alsa parameters.
  + [10_canvas_translation_fix] New, from upstream CVS.
    Do not translate tooltips twice in canvas popup.
  + [10_checkbox_fix] New, from upstream CVS.
    Use proper set/test methods on metronome checkboxes.
  + [10_html_doc_cleanup] New.
    Fix links and HTML errors in documentation.
  + [20_allow_system_timer] New.
    The new upstream version fails by default if the real-time clock
    could not be accessed (usually the case when not running suid-root).
    This patch reverts the old behaviour of falling back to the more
    inaccurate system timer.
* Updated patches:
  + [11_PIC_fixes_fixup] Rediffed.
* Removed patches:
  + [20_no_atomic_asm] Merged upstream.
* debian/compat: Splice out debhelper compatibility level from rules file.
* debian/control: Build-depend on latest jack release by default.
  Closes: #228788
* debian/control: Bump standards version.
* debian/control: Use auto-generated debconf dependency via misc:Depends.
* debian/control: Minor tweaks to the long description.
* debian/control: Tighten fluidsynth build dependency to sane version.
* debian/muse.doc-base: New. Register HTML documentation with doc-base.
* debian/templates: Tiny rewording, and typo fix.
* debian/templates, debian/po/*: Switch to po-debconf for translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************/  
2
 
/*  JVRev Reverb Subclass                  */
3
 
/*  by Tim Stilson, 1998                   */
4
 
/*    based on CLM JCRev                   */
5
 
/*  Integrated into STK by Gary Scavone    */
6
 
/*                                         */
7
 
/*  This is based on some of the famous    */
8
 
/*  Stanford CCRMA reverbs (NRev, KipRev)  */
9
 
/*  all based on the Chowning/Moorer/      */
10
 
/*  Schroeder reverberators, which use     */
11
 
/*  networks of simple allpass and comb    */
12
 
/*  delay filters.  This particular        */
13
 
/*  arrangement consists of 3 allpass      */
14
 
/*  filters in series, followed by 4 comb  */
15
 
/*  filters in parallel, an optional       */
16
 
/*  lowpass filter, and two decorrelation  */
17
 
/*  delay lines in parallel at the output. */
18
 
/*******************************************/
19
 
 
20
 
#include "JCRev.h"
21
 
 
22
 
//#define LOWPASS
23
 
 
24
 
JCRev :: JCRev(MY_FLOAT T60)
25
 
{
26
 
  /* These are the values from CLM's JCRev.ins ... I found that the
27
 
         impulse response sounded better with the shorter delay lengths.
28
 
         --Gary Scavone, 2/1998
29
 
         int lens[9] = {4799,4999,5399,5801,1051,337,113,573,487};
30
 
   */
31
 
  int lens[9] = {1777,1847,1993,2137,389,127,43,211,179};
32
 
  int val, i;
33
 
 
34
 
  if (SRATE < 44100.0) {
35
 
    double srscale = SRATE / 44100.0;
36
 
    for (i=0; i<9; i++) {
37
 
      val = (int) floor(srscale * lens[i]);
38
 
      if ((val & 1) == 0) val++;
39
 
      while (!this->isprime(val)) val += 2;
40
 
      lens[i] = val;
41
 
    }
42
 
  }
43
 
 
44
 
  for (i=0; i<3; i++)
45
 
        {
46
 
          APdelayLine[i] = new DLineN(lens[i+4] + 2);
47
 
          APdelayLine[i]->setDelay(lens[i+4]);
48
 
        }
49
 
  for (i=0; i<4; i++)
50
 
        {
51
 
          CdelayLine[i] = new DLineN(lens[i] + 2);
52
 
          CdelayLine[i]->setDelay(lens[i]);
53
 
          combCoeff[i] = pow(10,(-3 * lens[i] / (T60 * SRATE)));
54
 
          //      printf("combCoeff[%d] = %f\n", i, combCoeff[i]);
55
 
        }
56
 
  outLdelayLine = new DLineN(lens[7] + 2);
57
 
  outLdelayLine->setDelay(lens[7]);
58
 
  outRdelayLine = new DLineN(lens[8] + 2);
59
 
  outRdelayLine->setDelay(lens[8]);
60
 
  allPassCoeff = 0.7;
61
 
  effectMix = 0.3;
62
 
  this->clear();
63
 
}
64
 
 
65
 
JCRev :: ~JCRev()
66
 
{
67
 
    delete APdelayLine[0];
68
 
    delete APdelayLine[1];
69
 
    delete APdelayLine[2];
70
 
    delete CdelayLine[0];
71
 
    delete CdelayLine[1];
72
 
    delete CdelayLine[2];
73
 
    delete CdelayLine[3];
74
 
    delete outLdelayLine;
75
 
    delete outRdelayLine;
76
 
}
77
 
 
78
 
void JCRev :: clear()
79
 
{
80
 
  APdelayLine[0]->clear();
81
 
  APdelayLine[1]->clear();
82
 
  APdelayLine[2]->clear();
83
 
  CdelayLine[0]->clear();
84
 
  CdelayLine[1]->clear();
85
 
  CdelayLine[2]->clear();
86
 
  CdelayLine[3]->clear();
87
 
  outRdelayLine->clear();
88
 
  outLdelayLine->clear();
89
 
  lastOutL = 0.0;
90
 
  lastOutR = 0.0;
91
 
  combsum1=0.0;
92
 
  combsum2=0.0;
93
 
  combsum=0.0;
94
 
}
95
 
 
96
 
void JCRev :: setEffectMix(MY_FLOAT mix)
97
 
{
98
 
  effectMix = mix;
99
 
}
100
 
 
101
 
MY_FLOAT JCRev :: lastOutput()
102
 
{
103
 
  return (lastOutL + lastOutR) * 0.5;
104
 
}
105
 
 
106
 
MY_FLOAT JCRev :: lastOutputL()
107
 
{
108
 
  return lastOutL;
109
 
}
110
 
 
111
 
MY_FLOAT JCRev :: lastOutputR()
112
 
{
113
 
  return lastOutR;
114
 
}
115
 
 
116
 
MY_FLOAT JCRev :: tick(MY_FLOAT input)
117
 
{
118
 
  MY_FLOAT temp,temp0,temp1,temp2,temp3,temp4,temp5,temp6;
119
 
  MY_FLOAT filtout;
120
 
 
121
 
  temp = APdelayLine[0]->lastOut();
122
 
  temp0 = allPassCoeff * temp;
123
 
  temp0 += input;
124
 
  APdelayLine[0]->tick(temp0);
125
 
  temp0 = -(allPassCoeff * temp0) + temp;
126
 
    
127
 
  temp = APdelayLine[1]->lastOut();
128
 
  temp1 = allPassCoeff * temp;
129
 
  temp1 += temp0;
130
 
  APdelayLine[1]->tick(temp1);
131
 
  temp1 = -(allPassCoeff * temp1) + temp;
132
 
    
133
 
  temp = APdelayLine[2]->lastOut();
134
 
  temp2 = allPassCoeff * temp;
135
 
  temp2 += temp1;
136
 
  APdelayLine[2]->tick(temp2);
137
 
  temp2 = -(allPassCoeff * temp2) + temp;
138
 
    
139
 
  temp3 = temp2 + (combCoeff[0] * CdelayLine[0]->lastOut());
140
 
  temp4 = temp2 + (combCoeff[1] * CdelayLine[1]->lastOut());
141
 
  temp5 = temp2 + (combCoeff[2] * CdelayLine[2]->lastOut());
142
 
  temp6 = temp2 + (combCoeff[3] * CdelayLine[3]->lastOut());
143
 
 
144
 
  CdelayLine[0]->tick(temp3);
145
 
  CdelayLine[1]->tick(temp4);
146
 
  CdelayLine[2]->tick(temp5);
147
 
  CdelayLine[3]->tick(temp6);
148
 
 
149
 
#ifdef LOWPASS
150
 
  combsum2=combsum1;    
151
 
  combsum1=combsum;     
152
 
  combsum = temp3+temp4+temp5+temp6;
153
 
  filtout= 0.5*combsum1+0.25*(combsum+combsum2);
154
 
#else
155
 
  filtout = temp3+temp4+temp5+temp6;
156
 
#endif
157
 
 
158
 
  lastOutL = effectMix * (outLdelayLine->tick(filtout));
159
 
  lastOutR = effectMix * (outRdelayLine->tick(filtout));
160
 
  temp = (1.0 - effectMix) * input;
161
 
  lastOutL += temp;
162
 
  lastOutR += temp;
163
 
    
164
 
  return (lastOutL + lastOutR) * 0.5;
165
 
 
166
 
}