42 using namespace Nsound;
53 const Buffer * custom_envelope)
55 sample_rate_(sample_rate),
56 envelope_generator_(NULL)
69 if(custom_envelope == NULL
72 M_THROW(
"custom_envelope->getLength() must equal "
81 * (1.0 + envelope_noise * gen.
whiteNoise(1.0)));
89 * (1.0 + envelope_noise * gen.
whiteNoise(1.0)));
99 * (1.0 + envelope_noise * gen.
whiteNoise(1.0)));
108 * (1.0 + envelope_noise * gen.
whiteNoise(1.0)));
117 * (1.0 + envelope_noise * gen.
whiteNoise(1.0)));
126 * (1.0 + envelope_noise * gen.
whiteNoise(1.0)));
135 * (1.0 + envelope_noise * gen.
whiteNoise(1.0)));
144 * (1.0 + envelope_noise * gen.
whiteNoise(1.0)));
159 * (1.0 + envelope_noise * gen.
whiteNoise(1.0)));
168 * (1.0 + envelope_noise * gen.
whiteNoise(1.0)));
178 sample_rate_(gran.sample_rate_),
179 envelope_generator_(NULL)
195 const float64 & grain_frequency,
196 const float64 & waves_per_grain,
197 const float64 & grains_per_second)
205 for(
float64 last_g_time = 0.0, current_time = 0.0, next_grain_time = 0.0;
206 current_time < duration;
207 current_time += time_step)
210 if(next_grain_time - current_time < time_step)
212 float64 g_duration = waves_per_grain / grain_frequency;
216 grain << sin.
generate(g_duration, grain_frequency)
221 last_g_time = current_time;
224 next_grain_time = last_g_time + (1.0 / grains_per_second);
234 const Buffer & grain_frequency,
235 const Buffer & waves_per_grain,
236 const Buffer & grains_per_second)
const
252 for(
float64 last_g_time = 0.0, current_time = 0.0, next_grain_time = 0.0;
253 current_time < duration;
254 current_time += time_step)
258 grains_per_second[gps_index++ % gps_length];
261 if(next_grain_time - current_time < time_step)
263 float64 g_frequency = grain_frequency[gf_index++ % gf_length];
264 float64 wpg = waves_per_grain[wpg_index++ % wpg_length];
266 float64 g_duration = wpg / g_frequency;
269 sin.
generate(g_duration,g_frequency)
274 last_g_time = current_time;
277 next_grain_time = last_g_time + (1.0 / gps);
Generator * envelope_generator_
Buffer drawFatGaussian(const float64 &duration, const float64 &pass_band_percent=0.01) const
This method draws a standard Gaussian curve over duration seconds, with a specified pass band...
Nsound::Buffer generate(const float64 &duration, const float64 &grain_frequency, const float64 &waves_per_grain, const float64 &grains_per_second)
Buffer drawGaussian(const float64 &duration, const float64 &mu, const float64 &sigma, const boolean &normalize=true) const
This method draws a Gaussian curve over duration seconds.
uint32 getLength() const
Returns the number of samples in the Buffer.
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 Buffer for storing audio samples.
Buffer whiteNoise(const float64 &duration) const
This method generates noise from a uniform distribution.
void add(const Buffer &buffer, uint32 offset=0, uint32 n_samples=0)
This method adds buffer to *this.
Buffer getReverse() const
Reverses the samples in a copy of this Buffer.
A class the provides draw utilities and a wavetable oscillator.
Nsound::Granulator & operator=(const Nsound::Granulator &rhs)
Assignment operator.