-
Notifications
You must be signed in to change notification settings - Fork 1
/
midi2wave.h
58 lines (45 loc) · 1.02 KB
/
midi2wave.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Midi2Wave
*
* Playback controller
*
* Load MIDI events into the global variable
*/
#ifndef __MIDI2WAVE_H__
#define __MIDI2WAVE_H__
#include "sequence.h"
#define MAX_NOTE 128
#define KEYBUF_SIZE 5
#define SINE_SAMPLE_SIZE 256
#define PIANO(key) (key?(pow(1.0594630943592952645618252949463,key+1-32-49+24)*440):0)
#define NOTE_NUMBER(index) pgm_read_byte_near(notes+index)
#define NOTE_DELAY(index) (pgm_read_word_near(params+index)>>4)
#define NOTE_VEL(index) (pgm_read_word_near(params+index)&15)
unsigned char volatile active_keys[KEYBUF_SIZE];
unsigned char volatile key_vels[MAX_NOTE];
volatile char note_count = 0;
// The current length in milliseconds
int event_length = 0;
// The primary key
char key = 61;
/*
* Setup
*
* Initialize stuff
*/
void setupMidi();
/*
* Render wave buffer
*
* Generate the wave buffer with current notes
*/
void renderWaveBuffer();
/*
* Load next event
*
* Load the next midi note/chord
* Updates the next delay variable
* Updates LEDs
*/
void loadNextEvent();
#endif