sequencer
This commit is contained in:
parent
9ddb747f16
commit
152f171c66
@ -11,7 +11,7 @@ CFLAGS+= -g3 -ggdb -gdwarf-2
|
||||
|
||||
LDFLAGS=-mmcu=$(MCU) -L $(TOOLCHAIN_PREFIX)/include
|
||||
|
||||
$(ARTIFACT).elf: main.o scheduler.o notes.o psg.o
|
||||
$(ARTIFACT).elf: main.o scheduler.o psg.o sequencer.o
|
||||
$(CC) -o $@ $(LDFLAGS) $^
|
||||
$(OBJDUMP) -D $(ARTIFACT).elf > $(ARTIFACT).txt
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "psg.h"
|
||||
#include "scheduler.h"
|
||||
#include "sequencer.h"
|
||||
|
||||
void __attribute__ ((interrupt (USCIAB0RX_VECTOR))) receive() {
|
||||
if (UC0IFG & UCB0RXIFG) {
|
||||
@ -40,6 +41,7 @@ int main() {
|
||||
schInit();
|
||||
|
||||
psgInit();
|
||||
sequencerInit();
|
||||
|
||||
__enable_interrupt();
|
||||
|
||||
|
0
sound-driver/melody.c
Normal file
0
sound-driver/melody.c
Normal file
8
sound-driver/melody.h
Normal file
8
sound-driver/melody.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef _MELODY_H_
|
||||
#define _MELODY_H_
|
||||
|
||||
|
||||
void melodyInit();
|
||||
|
||||
|
||||
#endif // _MELODY_H_
|
@ -27,14 +27,6 @@ typedef enum {
|
||||
e_Ais,
|
||||
e_H
|
||||
} t_note;
|
||||
|
||||
typedef enum {
|
||||
e_L_1 = 80,
|
||||
e_L_1_2 = 40,
|
||||
e_L_1_4 = 20,
|
||||
e_L_1_8 = 10,
|
||||
e_L_1_16 = 5
|
||||
} t_noteLength;
|
||||
|
||||
|
||||
void psgInit();
|
||||
|
31
sound-driver/sequencer.c
Normal file
31
sound-driver/sequencer.c
Normal file
@ -0,0 +1,31 @@
|
||||
#include "sequencer.h"
|
||||
#include "scheduler.h"
|
||||
#include "psg.h"
|
||||
|
||||
|
||||
void sequencerInit() {
|
||||
}
|
||||
|
||||
void sequencerExec(void *handle) {
|
||||
t_melody *melody = (t_melody*) handle;
|
||||
|
||||
if (melody->lengthCnt == 0) {
|
||||
if (melody->tones[melody->idx].octave == e_O_EndMark) {
|
||||
melody->idx = 0;
|
||||
}
|
||||
|
||||
psgPlayTone(channel, melody->tones[melody->idx].octave, melody->tones[idx].note);
|
||||
|
||||
melody->lengthCnt = melody->tones[melody->idx].length;
|
||||
}
|
||||
|
||||
melody->lengthCnt -= 1;
|
||||
}
|
||||
|
||||
uint8_t sequencerPlayMelody(t_melody *melody) {
|
||||
melody->idx = 0;
|
||||
melody->lengthCnt = 0;
|
||||
schAdd(sequencerExec, (void*) melody, 0, 25);
|
||||
return 0;
|
||||
}
|
||||
|
33
sound-driver/sequencer.h
Normal file
33
sound-driver/sequencer.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef _SEQUENCER_H_
|
||||
#define _SEQUENCER_H_
|
||||
|
||||
|
||||
#include "psg.h"
|
||||
|
||||
typedef enum {
|
||||
e_L_EndMark = 0,
|
||||
e_L_1 = 80,
|
||||
e_L_1_2 = 40,
|
||||
e_L_1_4 = 20,
|
||||
e_L_1_8 = 10,
|
||||
e_L_1_16 = 5
|
||||
} t_noteLength;
|
||||
|
||||
typedef struct {
|
||||
t_octave octave;
|
||||
t_note note;
|
||||
t_noteLength length;
|
||||
} t_tone;
|
||||
|
||||
typedef struct {
|
||||
uint16_t idx;
|
||||
uint8_t lengthCnt;
|
||||
uint8_t channel;
|
||||
t_tone *tones;
|
||||
} t_melody;
|
||||
|
||||
void sequencerInit();
|
||||
uint8_t sequencerPlayMelody(t_melody *melody);
|
||||
|
||||
|
||||
#endif // _SEQUENCER_H_
|
Loading…
x
Reference in New Issue
Block a user