Created
October 16, 2010 00:18
-
-
Save ldunn/629198 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| namespace NetSFX | |
| { | |
| class Params | |
| { | |
| enum e_WaveType { Square, Saw, Sine, Noise }; | |
| #region Private properties | |
| public bool dirty = false; // Checks whether properties have changed, to determine whether to use cached sound | |
| private e_WaveType m_waveType = WaveType.Square; // Shape of wave | |
| private double m_masterVol = 0.5; // Master volume from 0 to 1 | |
| private double m_attackTime = 0; // Envelope attack time from 0 to 1 | |
| private double m_sustainTime = 0; // Length of envelope sustain from 0 to 1 | |
| private double m_sustainPunch = 0; // Optional tilting of envelope for more punch, from 0 to 1 | |
| private double m_releaseTime = 0; // Envelope release time, 0 to 1 | |
| private double m_startFreq = 0; // Base frequency of the sound, 0 to 1 | |
| private double m_minFreq = 0; // If sliding, this prevents super-low horrible notes, 0 to 1 | |
| private double m_slide = 0; // Slides up or down (-1 to 1) | |
| private double m_slideDelta = 0; // Accelerates or decelerates the slide (-1 to 1) | |
| private double m_vibratoDepth = 0; // Amount of vibrato (0 to 1) | |
| private double m_vibratoSpeed = 0; // Vibrato frequency (0 to 1) | |
| private double m_changeAmount = 0; // Change in note (-1 to 1) | |
| private double m_changeSpeed = 0; // Speed of change, will only happen once (0 to 1) | |
| private double m_squareDuty = 0; // Changes the up:down ratio on a square wave, changing the timbre (0 to 1) | |
| private double m_dutySweep = 0; // Sweeps the duty up or down (-1 to 1) | |
| private double m_repeatSpeed = 0; //Speed of note repeating - resets certain variables (0 to 1) | |
| private double m_phaserOffset = 0; // Offset a copy of the wave by a small margin, changing the timbre (-1 to 1) | |
| private double m_phaserSweep = 0; // Sweeps phaser up or down (-1 to 1) | |
| private double m_lpFilterCutoff = 0; // Frequency at which the low-pass filter starts attenuating higher frequencies (0 to 1) | |
| private double m_lpFilterCutoffSweep = 0; // Sweeps cutoff up or down (-1 to 1) | |
| private double m_lpFilterResonance = 0; //Changes the attenuation for the low-pass filter, changing the timbre (0 to 1) | |
| private double m_hpFilterCutoff = 0; // Frequency at which the high-pass filter starts attenuating lower frequencies (0 to 1) | |
| private double m_hpFilterCutoffSweep = 0; // Sweeps cutoff up or down (-1 to 1) | |
| #endregion | |
| #region Getters and Setters | |
| public e_WaveType WaveType | |
| { | |
| get | |
| { | |
| return m_waveType; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_waveType = value; | |
| } | |
| } | |
| public double MasterVolume | |
| { | |
| get | |
| { | |
| return m_masterVol; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_masterVol = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double AttackTime | |
| { | |
| get | |
| { | |
| return m_attackTime; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_attackTime = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double SustainTime | |
| { | |
| get | |
| { | |
| return m_sustainTime; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_sustainTime = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double SustainPunch | |
| { | |
| get | |
| { | |
| return m_sustainPunch; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_sustainPunch = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double ReleaseTime | |
| { | |
| get | |
| { | |
| return m_releaseTime; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_releaseTime = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double StartFreq | |
| { | |
| get | |
| { | |
| return m_startFreq; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_startFreq = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double MinFreq | |
| { | |
| get | |
| { | |
| return m_minFreq; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_minFreq = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double Slide | |
| { | |
| get | |
| { | |
| return m_slide; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_slide = value > 1 || value < -1 ? 0 : value; | |
| } | |
| } | |
| public double SlideDelta | |
| { | |
| get | |
| { | |
| return m_slideDelta; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_slideDelta = value > 1 || value < -1 ? 0 : value; | |
| } | |
| } | |
| public double VibratoDepth | |
| { | |
| get | |
| { | |
| return m_vibratoDepth; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_vibratoDepth = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double VibratoSpeed | |
| { | |
| get | |
| { | |
| return m_vibratoSpeed; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_vibratoSpeed = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double ChangeAmount | |
| { | |
| get | |
| { | |
| return m_changeAmount; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_changeAmount = value > 1 || value < -1 ? 0 : value; | |
| } | |
| } | |
| public double ChangeSpeed | |
| { | |
| get | |
| { | |
| return m_changeSpeed; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_changeSpeed = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double SquareDuty | |
| { | |
| get | |
| { | |
| return m_squareDuty; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_squareDuty = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double DutySweep | |
| { | |
| get | |
| { | |
| return m_dutySweep; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_dutySweep = value > 1 || value < -1 ? 0 : value; | |
| } | |
| } | |
| public double RepeatSpeed | |
| { | |
| get | |
| { | |
| return m_repeatSpeed; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_repeatSpeed = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double PhaserOffset | |
| { | |
| get | |
| { | |
| return m_phaserOffset; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_phaserOffset = value > 1 || value < -1 ? 0 : value; | |
| } | |
| } | |
| public double PhaserSweep | |
| { | |
| get | |
| { | |
| return m_phaserSweep; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_phaserSweep = value > 1 || value < -1 ? 0 : value; | |
| } | |
| } | |
| public double LPFilterCutoff | |
| { | |
| get | |
| { | |
| return m_lpFilterCutoff; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_lpFilterCutoff = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double LPFilterCutoffSweep | |
| { | |
| get | |
| { | |
| return m_lpFilterCutoffSweep; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_lpFilterCutoffSweep = value > 1 || value < -1 ? 0 : value; | |
| } | |
| } | |
| public double LPFilterResonance | |
| { | |
| get | |
| { | |
| return m_lpFilterResonance; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_lpFilterResonance = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double HPFilterCutoff | |
| { | |
| get | |
| { | |
| return m_hpFilterCutoff; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_hpFilterCutoff = value > 1 || value < 0 ? 0 : value; | |
| } | |
| } | |
| public double HPFilterCutoffSweep | |
| { | |
| get | |
| { | |
| return m_hpFilterCutoffSweep; | |
| } | |
| set | |
| { | |
| dirty = true; | |
| m_hpFilterCutoffSweep = value > 1 || value < -1 ? 0 : value; | |
| } | |
| } | |
| #endregion | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment