tetris/sound-driver/sequencer.h

51 lines
777 B
C
Raw Permalink Normal View History

2024-03-26 15:58:45 +01:00
#ifndef _SEQUENCER_H_
#define _SEQUENCER_H_
2024-03-26 16:47:42 +01:00
#include <stdint.h>
2024-03-26 21:05:48 +01:00
#include <stdbool.h>
2024-03-26 15:58:45 +01:00
#include "psg.h"
typedef enum {
e_L_EndMark = 0,
2024-03-26 23:13:59 +01:00
e_L_1 = 320,
e_L_1_2 = 160,
e_L_1_4 = 80,
e_L_1_8 = 40,
e_L_1_16 = 20,
e_L_1_32 = 10,
2024-03-26 15:58:45 +01:00
} t_noteLength;
typedef struct {
t_octave octave;
t_note note;
t_noteLength length;
2024-03-26 21:05:48 +01:00
bool legato;
2024-03-26 23:13:59 +01:00
bool staccato;
2024-03-26 15:58:45 +01:00
} t_tone;
2024-03-26 22:12:46 +01:00
typedef enum {
2024-03-26 23:21:24 +01:00
e_Init,
2024-03-26 22:12:46 +01:00
e_PlayTone,
e_HoldTone,
2024-03-26 23:13:59 +01:00
e_StaccatoBreak,
e_HoldStaccatoBreak,
2024-03-26 22:12:46 +01:00
e_SeparateTone
} t_sequencerState;
2024-03-26 15:58:45 +01:00
typedef struct {
uint16_t idx;
uint8_t lengthCnt;
2024-03-26 22:12:46 +01:00
t_sequencerState state;
2024-03-26 23:13:59 +01:00
uint8_t pace;
uint8_t amplitude;
2024-03-26 15:58:45 +01:00
uint8_t channel;
2024-03-26 16:47:42 +01:00
const t_tone *tones;
2024-03-26 15:58:45 +01:00
} t_melody;
void sequencerInit();
2024-03-26 23:13:59 +01:00
uint16_t sequencerPlayMelody(t_melody *melody);
2024-03-26 15:58:45 +01:00
#endif // _SEQUENCER_H_