Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/slmml/Oscillator.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 107 - (hide annotations) (download)
Sat May 16 11:22:34 2009 UTC (14 years, 11 months ago) by hikarin
File size: 5212 byte(s)
[ocmml/slmml] * added FCDPCM modulator
1 hikarin 58 /*
2     Copyright (c) 2009, hkrn All rights reserved.
3    
4     Redistribution and use in source and binary forms, with or without
5     modification, are permitted provided that the following conditions are met:
6    
7     Redistributions of source code must retain the above copyright notice, this
8     list of conditions and the following disclaimer. Redistributions in binary
9     form must reproduce the above copyright notice, this list of conditions and
10     the following disclaimer in the documentation and/or other materials
11     provided with the distribution. Neither the name of the hkrn nor
12     the names of its contributors may be used to endorse or promote products
13     derived from this software without specific prior written permission.
14    
15     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18     ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
19     ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25     DAMAGE.
26     */
27    
28     //
29     // $Id$
30     //
31    
32     using System;
33 hikarin 37 using SlMML.Modulators;
34    
35     namespace SlMML
36     {
37     public enum OscillatorForm
38     {
39     Sine,
40     Saw,
41     Triangle,
42     Pulse,
43     Noise,
44     FCPulse,
45     FCTriangle,
46     FCNoise,
47     FCShortNoise,
48     FCDPCM,
49     GBWave,
50     GBLongNoise,
51     GBShortNoise,
52     Max
53     }
54    
55     public class Oscillator
56     {
57     #region ���������������������������������������������������������
58     public Oscillator()
59     {
60 hikarin 107 m_modulators = new IModulator[(int)OscillatorForm.Max];
61 hikarin 37 m_modulators[(int)OscillatorForm.Sine] = new Sine();
62     m_modulators[(int)OscillatorForm.Saw] = new Saw();
63     m_modulators[(int)OscillatorForm.Triangle] = new Triangle();
64     m_modulators[(int)OscillatorForm.Pulse] = new Pulse();
65     m_modulators[(int)OscillatorForm.Noise] = new Noise();
66     m_modulators[(int)OscillatorForm.FCPulse] = new Pulse();
67     m_modulators[(int)OscillatorForm.FCTriangle] = new FCTriangle();
68     m_modulators[(int)OscillatorForm.FCNoise] = new FCNoise();
69 hikarin 43 m_modulators[(int)OscillatorForm.FCShortNoise] = new FCNoise();
70 hikarin 107 m_modulators[(int)OscillatorForm.FCDPCM] = new FCDPCM();
71 hikarin 37 m_modulators[(int)OscillatorForm.GBWave] = new GBWave();
72     m_modulators[(int)OscillatorForm.GBLongNoise] = new GBLongNoise();
73     m_modulators[(int)OscillatorForm.GBShortNoise] = new GBShortNoise();
74     Form = OscillatorForm.Pulse;
75     }
76     #endregion
77    
78     #region ���������������������������
79     public IModulator ModulatorFromForm(OscillatorForm form)
80     {
81     int index = Math.Min(Math.Max((int)form, 0), (int)(OscillatorForm.Max - 1));
82 hikarin 91 return m_modulators[index];
83 hikarin 37 }
84    
85     public void MakeAsLFO()
86     {
87     if (m_modulators[(int)OscillatorForm.Noise] != null)
88     {
89     Noise noise = (Noise)m_modulators[(int)OscillatorForm.Noise];
90     noise.ShouldResetPhase = false;
91     }
92     }
93     #endregion
94    
95     #region ������������������������������
96     public OscillatorForm Form
97     {
98     set
99     {
100     int index = Math.Min(Math.Max((int)value, 0), (int)(OscillatorForm.Max - 1));
101     m_form = (OscillatorForm)index;
102     switch (m_form)
103     {
104     case OscillatorForm.Noise:
105     Noise noise = (Noise)m_modulators[(int)OscillatorForm.Noise];
106     noise.RestoreFrequency();
107     break;
108     case OscillatorForm.FCNoise:
109     FCNoise fcNoise = (FCNoise)m_modulators[(int)OscillatorForm.FCNoise];
110     fcNoise.SetLongMode();
111     break;
112     case OscillatorForm.FCShortNoise:
113     FCNoise fcShortNoise = (FCNoise)m_modulators[(int)OscillatorForm.FCShortNoise];
114     fcShortNoise.SetShortMode();
115     break;
116     default:
117     break;
118     }
119     }
120     get
121     {
122     return m_form;
123     }
124     }
125    
126     public IModulator CurrentModulator
127     {
128     get
129     {
130     return m_modulators[(int)Form];
131     }
132     }
133     #endregion
134    
135     #region ���������������������������
136 hikarin 107 IModulator[] m_modulators;
137 hikarin 37 OscillatorForm m_form;
138     #endregion
139     }
140     }

Properties

Name Value
svn:keywords Id

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26