~ubuntu-branches/ubuntu/raring/muse/raring-proposed

« back to all changes in this revision

Viewing changes to synti/stklib/ModalBar.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
 
/*
3
 
  ModalBar SubClass of Modal4 Instrument
4
 
  by Perry R. Cook, 1999-2000
5
 
 
6
 
  Controls:    CONTROL1 = stickHardness
7
 
               CONTROL2 = strikePosition
8
 
               CONTROL3 = Mode Presets
9
 
*/
10
 
/*******************************************/
11
 
 
12
 
#include "ModalBar.h"
13
 
#include "SKINI11.msg"
14
 
 
15
 
ModalBar :: ModalBar() : Modal4()
16
 
{
17
 
  // Concatenate the STK RAWWAVE_PATH to the rawwave file
18
 
  char file[128];
19
 
  strcpy(file, RAWWAVE_PATH);
20
 
  wave = new RawWvIn(strcat(file,"rawwaves/marmstk1.raw"),"oneshot");
21
 
  wave->setRate((MY_FLOAT) 0.5);  /*  normal stick  */
22
 
 
23
 
  this->setRatioAndReson(0, (MY_FLOAT) 1.00,(MY_FLOAT) 0.9996);  /*  Set all       132.0  */
24
 
  this->setRatioAndReson(1, (MY_FLOAT) 3.99,(MY_FLOAT) 0.9994);  /*  of our        523.0  */
25
 
  this->setRatioAndReson(2,(MY_FLOAT) 10.65,(MY_FLOAT) 0.9994);  /*  default       1405.0 */
26
 
  this->setRatioAndReson(3,-(MY_FLOAT) 2443.0,(MY_FLOAT) 0.999);  /*  resonances    2443.0 */
27
 
  this->setFiltGain(0,(MY_FLOAT) 0.04);               /*  and        */
28
 
  this->setFiltGain(1,(MY_FLOAT) 0.01);               /*  gains      */
29
 
  this->setFiltGain(2,(MY_FLOAT) 0.01);               /*  for each   */
30
 
  this->setFiltGain(3,(MY_FLOAT) 0.008);              /*  resonance  */
31
 
  directGain = (MY_FLOAT) 0.1;
32
 
}  
33
 
 
34
 
ModalBar :: ~ModalBar()
35
 
{
36
 
  delete wave;
37
 
}  
38
 
 
39
 
void ModalBar :: setStickHardness(MY_FLOAT hardness)
40
 
{
41
 
  stickHardness = hardness;
42
 
  wave->setRate((MY_FLOAT) (0.25 * (MY_FLOAT)  pow(4.0,stickHardness)));
43
 
  masterGain = (MY_FLOAT) 0.1 + ((MY_FLOAT) 1.8 * stickHardness);
44
 
}
45
 
 
46
 
void ModalBar :: setStrikePosition(MY_FLOAT position)
47
 
{
48
 
  MY_FLOAT temp,temp2;
49
 
  temp2 = position * PI;
50
 
  strikePosition = position;             /*  Hack only first three modes */
51
 
  temp = (MY_FLOAT)  sin(temp2);                                       
52
 
  this->setFiltGain(0,(MY_FLOAT) 0.12 * temp);      /*  1st mode function of pos.   */
53
 
  temp = (MY_FLOAT)  sin(0.05 + (3.9 * temp2));
54
 
  this->setFiltGain(1,(MY_FLOAT) -0.03 * temp);     /*  2nd mode function of pos.   */
55
 
  temp = (MY_FLOAT)  sin(-0.05 + (11 * temp2));
56
 
  this->setFiltGain(2,(MY_FLOAT) 0.11 * temp);      /*  3rd mode function of pos.   */
57
 
}
58
 
 
59
 
void ModalBar :: setModalPreset(int which)
60
 
{
61
 
  /* presets:
62
 
   * first line:  relative modal frequencies (negative number is
63
 
   *              a fixed mode that doesn't scale with frequency
64
 
   * second line: resonances of the modes
65
 
   * third line:  mode volumes
66
 
   * fourth line: stickHardness, strikePosition, and direct stick
67
 
   *              gain (mixed directly into the output
68
 
   */
69
 
  int i, temp;
70
 
  MY_FLOAT presets[9][4][4] = { 
71
 
    {{1.0, 3.99, 10.65, -2443},         // Marimba
72
 
     {0.9996, 0.9994, 0.9994, 0.999},
73
 
     {0.04, 0.01, 0.01, 0.008},
74
 
     {0.429688, 0.445312, 0.093750}},
75
 
    {{1.0, 2.01, 3.9, 14.37},           // Vibraphone
76
 
     {0.99995, 0.99991, 0.99992, 0.9999},       
77
 
     {0.025, 0.015, 0.015, 0.015 },
78
 
     {0.390625,0.570312,0.078125}},
79
 
    {{1.0, 4.08, 6.669, -3725.0},               // Agogo 
80
 
     {0.999, 0.999, 0.999, 0.999},      
81
 
     {0.06, 0.05, 0.03, 0.02},
82
 
     {0.609375,0.359375,0.140625}},
83
 
    {{1.0, 2.777, 7.378, 15.377},               // Wood1
84
 
     {0.996, 0.994, 0.994, 0.99},       
85
 
     {0.04, 0.01, 0.01, 0.008},
86
 
     {0.460938,0.375000,0.046875}},
87
 
    {{1.0, 2.777, 7.378, 15.377},               // Reso
88
 
     {0.99996, 0.99994, 0.99994, 0.9999},       
89
 
     {0.02, 0.005, 0.005, 0.004},
90
 
     {0.453125,0.250000,0.101562}},
91
 
    {{1.0, 1.777, 2.378, 3.377},                // Wood2
92
 
     {0.996, 0.994, 0.994, 0.99},       
93
 
     {0.04, 0.01, 0.01, 0.008},
94
 
     {0.312500,0.445312,0.109375}},
95
 
    {{1.0, 1.004, 1.013, 2.377},                // Beats
96
 
     {0.9999, 0.9999, 0.9999, 0.999},   
97
 
     {0.02, 0.005, 0.005, 0.004},
98
 
     {0.398438,0.296875,0.070312}},
99
 
    {{1.0, 4.0, -1320.0, -3960.0},              // 2Fix
100
 
     {0.9996, 0.999, 0.9994, 0.999},    
101
 
     {0.04, 0.01, 0.01, 0.008},
102
 
     {0.453125,0.453125,0.070312}},
103
 
    {{1.0, 1.217, 1.475, 1.729},                // Clump
104
 
     {0.999, 0.999, 0.999, 0.999},      
105
 
     {0.03, 0.03, 0.03, 0.03 },
106
 
     {0.390625,0.570312,0.078125}},
107
 
  };
108
 
 
109
 
  temp = (which % 9);
110
 
  for (i=0; i<4; i++)   {
111
 
    this->setRatioAndReson(i, presets[temp][0][i], presets[temp][1][i]);
112
 
    this->setFiltGain(i,presets[temp][2][i]);
113
 
  }
114
 
  this->setStickHardness(presets[temp][3][0]);
115
 
  this->setStrikePosition(presets[temp][3][1]);
116
 
  directGain = presets[temp][3][2];
117
 
 
118
 
  if (temp == 1) // vibraphone
119
 
    vibrGain = 0.2;
120
 
  else
121
 
    vibrGain = 0.0;
122
 
}
123
 
 
124
 
void ModalBar :: controlChange(int number, MY_FLOAT value)
125
 
{
126
 
#if defined(_debug_)        
127
 
  printf("ModalBar : ControlChange: Number=%i Value=%f\n",number,value);
128
 
#endif    
129
 
  if (number == __SK_StickHardness_)
130
 
    this->setStickHardness(value * NORM_7);
131
 
  else if (number == __SK_StrikePosition_)
132
 
    this->setStrikePosition(value * NORM_7);
133
 
  else if (number == __SK_ProphesyRibbon_)
134
 
                this->setModalPreset((int) value);
135
 
  else if (number == __SK_ModWheel_)
136
 
    directGain = value * NORM_7;
137
 
  else if (number == __SK_AfterTouch_Cont_)     
138
 
    envelope->setTarget(value * NORM_7);
139
 
  else if (number == __SK_ModFrequency_)
140
 
    vibr->setFreq(value * NORM_7 * 12.0);
141
 
  else if (number == 1024)      {       //  HACKED Poop message
142
 
    printf("StickHard=%f   StrikePos=%f   directGain=%f\n",
143
 
           stickHardness, strikePosition, directGain);
144
 
  }
145
 
  else    {
146
 
    printf("ModalBar : Undefined Control Number!!\n");
147
 
  }    
148
 
}
149