-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHat.hpp
37 lines (32 loc) · 808 Bytes
/
Hat.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// Created by theo on 1/23/22.
//
#ifndef SNOOZEQUENCER_HAT_HPP
#define SNOOZEQUENCER_HAT_HPP
#include "SineOscillator.h"
#include "SignalGenerator.h"
#include "AdsrEnvelope.h"
#include "ExponentialDecayEnvelope.h"
#include "NoiseOscillator.h"
class Hat : public SignalGenerator {
private:
NoiseOscillator* noise;
ExponentialDecayEnvelope* env;
public:
Hat(float sr) {
noise = NoiseOscillator::create(sr);
noise->setFrequency(1000);
env = ExponentialDecayEnvelope::create(sr);
env->setDecay(.1);
}
void trigger() {
env->trigger();
}
using SignalGenerator::generate;
float generate() {
float ev = env->generate();
float n = noise->generate();
return (n * .5) * ev;
}
};
#endif //SNOOZEQUENCER_HAT_HPP