-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudio.h
More file actions
51 lines (42 loc) · 1.23 KB
/
audio.h
File metadata and controls
51 lines (42 loc) · 1.23 KB
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
#ifndef ArduboyAudio_h
#define ArduboyAudio_h
#include <Arduino.h>
#include <EEPROM.h>
#include <avr/pgmspace.h>
#include <avr/power.h>
#define AVAILABLE_TIMERS 2
#define TUNE_OP_PLAYNOTE 0x90 /* play a note: low nibble is generator #, note is next byte */
#define TUNE_OP_STOPNOTE 0x80 /* stop a note: low nibble is generator # */
#define TUNE_OP_RESTART 0xe0 /* restart the score from the beginning */
#define TUNE_OP_STOP 0xf0 /* stop playing */
class ArduboyAudio
{
public:
void setup();
void on();
void off();
void save_on_off();
bool enabled();
void tone(uint8_t channel, unsigned int frequency, unsigned long duration);
protected:
bool audio_enabled;
};
class ArduboyTunes
{
public:
// Playtune Functions
void initChannel(byte pin); // assign a timer to an output pin
void playScore(const byte *score); // start playing a polyphonic score
void stopScore(); // stop playing the score
void delay(unsigned msec); // delay in milliseconds
void closeChannels(); // stop all timers
bool playing();
void tone(unsigned int frequency, unsigned long duration);
// called via interrupt
void static step();
void static soundOutput();
private:
void static playNote (byte chan, byte note);
void static stopNote (byte chan);
};
#endif