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

« back to all changes in this revision

Viewing changes to synti/stklib/Brass.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
 
/*  Waveguide Brass Instrument Model ala  */
3
 
/*  Cook (TBone, HosePlayer)              */
4
 
/*  by Perry R. Cook, 1995-96             */
5
 
/*                                        */
6
 
/*  This is a waveguide model, and thus   */
7
 
/*  relates to various Stanford Univ.     */
8
 
/*  and possibly Yamaha and other patents.*/
9
 
/*                                        */
10
 
/*   Controls:    CONTROL1 = lipTension   */
11
 
/*                CONTROL2 = slideLength  */
12
 
/*                CONTROL3 = vibFreq      */
13
 
/*                MOD_WHEEL= vibAmt       */
14
 
/******************************************/
15
 
 
16
 
#include "Brass.h"
17
 
#include "SKINI11.msg"
18
 
 
19
 
Brass :: Brass(MY_FLOAT lowestFreq)
20
 
{
21
 
  length = (long) (SRATE / lowestFreq + 1);
22
 
  delayLine = new DLineA(length);
23
 
  lipFilter = new LipFilt;
24
 
  dcBlock = new DCBlock;
25
 
  adsr = new ADSR;
26
 
  adsr->setAllTimes((MY_FLOAT) 0.005, (MY_FLOAT) 0.001, (MY_FLOAT) 1.0, (MY_FLOAT) 0.010);
27
 
 
28
 
  // Concatenate the STK RAWWAVE_PATH to the rawwave file
29
 
  char file[128];
30
 
  strcpy(file, RAWWAVE_PATH);
31
 
  vibr = new RawWvIn(strcat(file,"rawwaves/sinewave.raw"),"looping");
32
 
  this->clear();
33
 
 
34
 
  vibr->setFreq((MY_FLOAT)  6.137);
35
 
  vibrGain = (MY_FLOAT)  0.05;            /* breath periodic vibrato component  */
36
 
 
37
 
        maxPressure = (MY_FLOAT) 0.0;
38
 
}
39
 
 
40
 
Brass :: ~Brass()
41
 
{
42
 
  delete delayLine;
43
 
  delete lipFilter;
44
 
  delete dcBlock;
45
 
  delete adsr;
46
 
  delete vibr;
47
 
}
48
 
 
49
 
void Brass :: clear()
50
 
{
51
 
  delayLine->clear();
52
 
  lipFilter->clear();
53
 
  dcBlock->clear();
54
 
}
55
 
 
56
 
void Brass :: setFreq(MY_FLOAT frequency)
57
 
{
58
 
  slideTarget = (SRATE / frequency * (MY_FLOAT) 2.0) + (MY_FLOAT) 3.0;
59
 
  /* fudge correction for filter delays */
60
 
  delayLine->setDelay(slideTarget);   /*  we'll play a harmonic  */
61
 
  lipTarget = frequency;
62
 
  lipFilter->setFreq(frequency);
63
 
}
64
 
 
65
 
void Brass :: setLip(MY_FLOAT frequency)
66
 
{
67
 
  lipFilter->setFreq(frequency);
68
 
}
69
 
 
70
 
void Brass :: startBlowing(MY_FLOAT amplitude,MY_FLOAT rate)
71
 
{
72
 
  adsr->setAttackRate(rate);
73
 
  maxPressure = amplitude;
74
 
  adsr->keyOn();
75
 
}
76
 
 
77
 
void Brass :: stopBlowing(MY_FLOAT rate)
78
 
{
79
 
  adsr->setReleaseRate(rate);
80
 
  adsr->keyOff();
81
 
}
82
 
 
83
 
void Brass :: noteOn(MY_FLOAT freq, MY_FLOAT amp)
84
 
{
85
 
  this->setFreq(freq);
86
 
  this->startBlowing(amp, amp * (MY_FLOAT) 0.001);
87
 
#if defined(_debug_)        
88
 
  printf("Brass : NoteOn: Freq=%lf Amp=%lf\n",freq,amp);
89
 
#endif    
90
 
}
91
 
 
92
 
void Brass :: noteOff(MY_FLOAT amp)
93
 
{
94
 
  this->stopBlowing(amp * (MY_FLOAT) 0.005);
95
 
#if defined(_debug_)        
96
 
  printf("Brass : NoteOff: Amp=%lf\n",amp);
97
 
#endif    
98
 
}
99
 
 
100
 
MY_FLOAT Brass :: tick()
101
 
{
102
 
  MY_FLOAT breathPressure;
103
 
 
104
 
  breathPressure = maxPressure * adsr->tick();
105
 
  breathPressure += vibrGain * vibr->tick();
106
 
  lastOutput = delayLine->tick(                                 /* bore delay  */
107
 
               dcBlock->tick(                                   /* block DC    */
108
 
               lipFilter->tick((MY_FLOAT) 0.3 * breathPressure, /* mouth input */
109
 
                     (MY_FLOAT) 0.85 * delayLine->lastOut()))); /* and bore reflection */
110
 
  return lastOutput;
111
 
}
112
 
 
113
 
void Brass :: controlChange(int number, MY_FLOAT value)
114
 
{
115
 
  MY_FLOAT temp;
116
 
#if defined(_debug_)        
117
 
  printf("Brass : ControlChange: Number=%i Value=%f\n",number,value);
118
 
#endif    
119
 
  if (number == __SK_LipTension_)       {
120
 
    temp = lipTarget * (MY_FLOAT) pow(4.0,(2.0*value*NORM_7) - 1.0);
121
 
    this->setLip(temp);
122
 
  }
123
 
  else if (number == __SK_SlideLength_)
124
 
    delayLine->setDelay(slideTarget * ((MY_FLOAT) 0.5 + (value * NORM_7)));  
125
 
  else if (number == __SK_ModFrequency_)
126
 
                vibr->setFreq((value * NORM_7 * (MY_FLOAT) 12.0));
127
 
  else if (number == __SK_ModWheel_ )
128
 
                vibrGain = (value * NORM_7 * (MY_FLOAT) 0.4);
129
 
  else if (number == __SK_AfterTouch_Cont_)
130
 
    adsr->setTarget(value * NORM_7);
131
 
  else    {        
132
 
    printf("Brass : Undefined Control Number!!\n");
133
 
  }  
134
 
}