This repository has been archived by the owner on May 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
SamdAudio.h
executable file
·66 lines (49 loc) · 1.5 KB
/
SamdAudio.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
59
60
61
62
63
64
65
66
/*
* Copyright Theo Meyer (c) 2016
*
* Audio library for Arduino Zero.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of either the GNU General Public License version 2
* or the GNU Lesser General Public License version 2.1, both as
* published by the Free Software Foundation.
*/
#ifndef SAMDAUDIO_H
#define SAMDAUDIO_H
#include "Arduino.h"
#include "Print.h"
#include <SdFat.h>
extern SdFat SD;
class SamdAudio{
public:
SamdAudio(){};
void begin(uint32_t sampleRate);
void play(const char *fname, uint8_t channel) ;
//void play(const char *fname) ;
void stopChannel(uint8_t c);
void loopChannel(uint8_t c, bool loopEnable);
bool isPlaying(uint8_t c);
void setGain(uint8_t v);
void gainUp();
void gainDown();
void setChannelVolume(uint8_t c, uint8_t v);
void end();
void criticalON();
void criticalOFF();
private:
void dacConfigure(void);
//The first timer is used to feed the DAC with data every 1/sampleRate sec
void configurePlayerTimer(uint32_t sampleRate);
bool syncPlayerTimer(void);
void resetPlayerTimer(void);
void enablePlayerTimer(void);
void disablePlayerTimer(void);
//the second timer is used to read audio data from the SD card every 15.6ms
void configureReaderTimer();
void enableReaderTimer();
void disableReaderTimer();
void updaterConfigure();
bool alonePlaying(uint8_t channel);
bool someonePlaying();
};
#endif //SAMDAUDIO_H