36 using namespace Nsound;
54 y <<
play(0.5, 50.0, 0.25)
55 <<
play(0.5, 50.0, 0.50)
56 <<
play(0.5, 50.0, 0.75)
57 <<
play(0.5, 50.0, 1.0);
68 return play(duration, frequency, 1.0);
84 float64 fdec = 0.025 * (v * v + 0.1072);
90 << sin.
drawLine(duration - fdec, 0.0, 0.0);
93 << sin.
drawLine(duration - 0.32, 0.0, 0.0);
95 Buffer kcps = (4.3333 * kcps1 + kcps2) * frequency;
98 << sin.
drawLine(duration - 0.04, 0.0, 0.0);
101 << sin.
drawLine(duration - 0.0005, 0.0, 0.0);
105 << sin.
drawLine(duration - 0.15, 1.0, 1.0);
109 a1.
limit(-0.25, 0.25);
111 Buffer freq = kcps * (0.5 + klpf2);
115 a1 = tone.filter(a1, freq);
119 tone.makeKernel(500.0);
121 a2 -= tone.filter(a2);
123 freq = 4.0 * (klpf + klpf2) * kcps;
127 a1 = lpf.
filter(kamp * a1, freq);
129 a2 = lpf.
filter(kamp * a2, kcps);
AudioStream filter(const AudioStream &x)
void limit(float64 min, float64 max)
Limits the Buffer to min and max.
AudioStream play()
Plays a demo for this instrument.
DrumBD01(const float64 &sample_rate)
Creates a Drum.
virtual float64 generate(const float64 &frequency)
This is a real-time method for the wavetable oscillator.
Buffer drawDecay(const float64 &duration, const float64 &alpha=2.0 *M_PI) const
This method draws an exponential curve that decays from 1.0 to 0.0 over the duration.
A class for filtering audio in the frequecy domain.
void normalize()
Multiplies the Buffer by a constant gain so the peak sample has magnitude 1.0.
The Nsound Instrument baseclass. All Nsound instruments extend this class.
A Buffer for storing audio samples.
Buffer whiteNoise(const float64 &duration) const
This method generates noise from a uniform distribution.
Buffer getSqrt() const
Taks the square root of each sample in a copy of this Buffer.
Buffer drawLine(const float64 &duration, const float64 &litude_start, const float64 &litude_finish) const
This method draws a linear line beteween 2 points.