29 lines
460 B
C
29 lines
460 B
C
#ifndef NOTE_H
|
|
#define NOTE_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
typedef enum {
|
|
WAVE_NONE,
|
|
WAVE_SINE,
|
|
WAVE_SQUARE,
|
|
WAVE_SAW,
|
|
WAVE_TRIANGLE
|
|
} Waveform;
|
|
|
|
typedef struct {
|
|
uint8_t id;
|
|
float phase;
|
|
float freq;
|
|
float gain;
|
|
float attack_ms;
|
|
float release_ms;
|
|
bool is_playing;
|
|
Waveform form;
|
|
} Note;
|
|
|
|
void play_note(Note *note, float *buffer, unsigned int buffer_size, float sample_rate);
|
|
|
|
#endif // NOTE_H
|