synththing/src/utils/envelope.h

42 lines
873 B
C
Raw Normal View History

2019-10-30 20:09:28 -04:00
/*
* Filename: envelope.h
*
* Description:
*
*
* Version:
* Created: Wed Oct 30 17:15:02 2019
* Revision: None
* Author: Rachel Fae Fox (foxiepaws),fox@foxiepa.ws
*
*/
#ifndef _H_ENVELOPE
#define _H_ENVELOPE
#include <stdbool.h>
#include "../common.h"
typedef enum EnvState {_e_off,_e_attack, _e_attackrelease, _e_decay, _e_sustain,_e_release, _e_finished} EnvState;
2019-10-30 20:09:28 -04:00
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;
float level;
2019-10-30 20:09:28 -04:00
bool gate;
2019-10-31 18:59:57 -04:00
unsigned long t;
EnvState envstate;
bool ar;
bool sustain;
float(*process)(struct Envelope *,EngineState *);
2019-10-30 20:09:28 -04:00
} Envelope;
float envelope_process(Envelope *self, EngineState *t);
Envelope* envelope_new();
#endif