EIE4-FYP/demo/audio

142 lines
1.7 KiB
Plaintext

#include <generated/csr.h>
#include <stdint.h>
#pragma once
#ifdef CSR_AUDIO_BASE
// Function Definition
void reset_audio(void);
void set_wave(uint32_t osc, uint32_t wave);
void set_freq(uint32_t osc, uint32_t freq);
void audio(uint32_t osc, uint32_t wave, uint32_t freq);
void timed_freq(uint32_t osc, uint32_t freq, unsigned int duration_ms);
// Waves
enum wave_t : uint32_t {
WAVE_SAWTOOTH,
WAVE_SQUARE,
WAVE_TRIANGLE,
WAVE_SINE
};
// Notes
enum note_t : uint32_t {
NONE = 0,
C0 = 16,
C0S = 17,
D0 = 18,
D0S = 19,
E0 = 21,
F0 = 22,
F0S = 23,
G0 = 25,
G0S = 26,
A0 = 28,
A0S = 29,
B0 = 31,
C1 = 33,
C1S = 35,
D1 = 37,
D1S = 39,
E1 = 41,
F1 = 44,
F1S = 46,
G1 = 49,
G1S = 52,
A1 = 55,
A1S = 58,
B1 = 62,
C2 = 65,
C2S = 69,
D2 = 73,
D2S = 78,
E2 = 82,
F2 = 87,
F2S = 93,
G2 = 98,
G2S = 104,
A2 = 110,
A2S = 117,
B2 = 123,
C3 = 131,
C3S = 139,
D3 = 147,
D3S = 156,
E3 = 165,
F3 = 175,
F3S = 185,
G3 = 196,
G3S = 208,
A3 = 220,
A3S = 233,
B3 = 247,
C4 = 262,
C4S = 277,
D4 = 294,
D4S = 311,
E4 = 330,
F4 = 349,
F4S = 370,
G4 = 392,
G4S = 415,
A4 = 440,
A4S = 466,
B4 = 494,
C5 = 523,
C5S = 554,
D5 = 587,
D5S = 622,
E5 = 659,
F5 = 698,
F5S = 740,
G5 = 784,
G5S = 831,
A5 = 880,
A5S = 932,
B5 = 988,
C6 = 1047,
C6S = 1109,
D6 = 1175,
D6S = 1245,
E6 = 1319,
F6 = 1397,
F6S = 1480,
G6 = 1568,
G6S = 1661,
A6 = 1760,
A6S = 1865,
B6 = 1976,
C7 = 2093,
C7S = 2217,
D7 = 2349,
D7S = 2489,
E7 = 2637,
F7 = 2794,
F7S = 2960,
G7 = 3136,
G7S = 3322,
A7 = 3520,
A7S = 3729,
B7 = 3951,
C8 = 4186,
C8S = 4436,
D8 = 4699,
D8S = 4978,
E8 = 5274,
F8 = 5588,
F8S = 5920,
G8 = 6272,
G8S = 6645,
A8 = 7040,
A8S = 7459,
B8 = 7902,
};
#endif