voice.h 574 Bytes
Newer Older
Jacob Vosmaer's avatar
Jacob Vosmaer committed
1 2
#ifndef VOICE_H
#define VOICE_H
Jacob Vosmaer's avatar
Jacob Vosmaer committed
3

Jacob Vosmaer's avatar
Jacob Vosmaer committed
4 5
#include <stdint.h>

6 7
enum { NUM_SEMITONES = 12 };

Jacob Vosmaer's avatar
Jacob Vosmaer committed
8
enum { NUM_VOICES = 7, MAX_VOICES = 8 };
Jacob Vosmaer's avatar
Jacob Vosmaer committed
9

Jacob Vosmaer's avatar
Jacob Vosmaer committed
10
#define for_each_voice(var) for (uint8_t var = 0; var < NUM_VOICES; var++)
Jacob Vosmaer's avatar
Jacob Vosmaer committed
11

Jacob Vosmaer's avatar
Jacob Vosmaer committed
12
struct gate {
13 14 15 16
	volatile uint8_t *port;
	uint8_t mask;
};

Jacob Vosmaer's avatar
Jacob Vosmaer committed
17
struct dac {
18
	uint8_t channel;
19
	// Offset to get a consistent "zero" on each CV output
20
	uint16_t offset;
21
	// This number corresponds to a 1V increase at the respective CV output.
22
	uint16_t scale;
23 24
};

Jacob Vosmaer's avatar
Jacob Vosmaer committed
25 26
struct gate *gate(uint8_t v);
struct dac *dac(uint8_t v);
27

28 29
int16_t dac_semitone_offset(uint8_t semitone);

Jacob Vosmaer's avatar
Jacob Vosmaer committed
30
#endif