44 lines
894 B
C
44 lines
894 B
C
/*
|
|
* Filename: envelope.h
|
|
*
|
|
* Description:
|
|
*
|
|
*
|
|
* Version:
|
|
* Created: Wed Oct 30 17:15:02 2019
|
|
* Revision: None
|
|
* Author: Rachel Fae Fox (foxiepaws),fox@foxiepa.ws
|
|
*
|
|
*/
|
|
#include "../common.h"
|
|
#ifndef _H_ENVELOPE
|
|
#define _H_ENVELOPE
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
|
|
typedef struct Envelope {
|
|
// these values are in samples.
|
|
unsigned int attack;
|
|
unsigned int decay;
|
|
unsigned int release;
|
|
float sustain_level;
|
|
float max_level;
|
|
float min_level;
|
|
bool gate;
|
|
float(*process)(struct Envelope *,EngineState *);
|
|
|
|
} Envelope;
|
|
|
|
float envelope_process(Envelope *self, EngineState *t) {
|
|
return self->gate ? self->max_level : self-> min_level;
|
|
}
|
|
Envelope* envelope_new() {
|
|
Envelope *e = malloc(sizeof(Envelope));
|
|
e->process = envelope_process;
|
|
e->max_level = 1.0f;
|
|
e->min_level = 0.0f;
|
|
return e;
|
|
}
|
|
|
|
#endif
|