Mercurial > hg > beaglert
comparison include/RTAudio.h @ 5:09f03ac40fcc
API improvements and cleanups. Now all common audio command-line options can be parsed automatically.
author | andrewm |
---|---|
date | Sat, 08 Nov 2014 16:16:55 +0100 |
parents | 8a575ba3ab52 |
children | a6beeba3a648 |
comparison
equal
deleted
inserted
replaced
4:f34c63568523 | 5:09f03ac40fcc |
---|---|
23 #define CODEC_I2C_ADDRESS 0x18 // Address of TLV320AIC3104 codec | 23 #define CODEC_I2C_ADDRESS 0x18 // Address of TLV320AIC3104 codec |
24 #else | 24 #else |
25 #define CODEC_I2C_ADDRESS 0x1B // Address of TLV320AIC3106 codec | 25 #define CODEC_I2C_ADDRESS 0x1B // Address of TLV320AIC3106 codec |
26 #endif | 26 #endif |
27 | 27 |
28 // Default volume levels | |
29 #define DEFAULT_DAC_LEVEL 0.0 | |
30 #define DEFAULT_ADC_LEVEL -6.0 | |
31 #define DEFAULT_HP_LEVEL -6.0 | |
32 | |
28 enum { | 33 enum { |
29 kAmplifierMutePin = 61 // P8-26 controls amplifier mute | 34 kAmplifierMutePin = 61 // P8-26 controls amplifier mute |
30 }; | 35 }; |
36 | |
37 // Structure which contains initialisation parameters for the | |
38 // real-time audio system | |
39 typedef struct { | |
40 // These items might be adjusted by the user: | |
41 int periodSize; // Number of (matrix) frames per period; audio is twice this | |
42 int beginMuted; // Whether to begin with the speakers muted | |
43 float dacLevel; // Level for the audio DAC output | |
44 float adcLevel; // Level for the audio ADC input | |
45 float headphoneLevel; // Level for the headphone output | |
46 int useMatrix; // Whether to enable the ADC and DAC | |
47 int verbose; // Whether to use verbose logging | |
48 | |
49 // These items are hardware-dependent and should only be changed | |
50 // to run on different hardware | |
51 int codecI2CAddress; // Where the codec can be found on the I2C bus | |
52 int ampMutePin; // Pin where amplifier mute can be found | |
53 } RTAudioSettings; | |
31 | 54 |
32 typedef void* AuxiliaryTask; // Opaque data type to keep track of aux tasks | 55 typedef void* AuxiliaryTask; // Opaque data type to keep track of aux tasks |
33 | 56 |
34 // Flag that indicates when the audio will stop; can be read or | 57 // Flag that indicates when the audio will stop; can be read or |
35 // set by other components which should end at the same time as the audio | 58 // set by other components which should end at the same time as the audio |
36 extern bool gShouldStop; | 59 extern bool gShouldStop; |
37 | 60 |
38 int initAudio(int periodSize, int useMatrix, void *userData, | 61 // Command-line settings |
39 int codecI2CAddress = CODEC_I2C_ADDRESS, int ampMutePin = kAmplifierMutePin); | 62 void BeagleRT_defaultSettings(RTAudioSettings *settings); |
40 int startAudio(); | 63 int BeagleRT_getopt_long(int argc, char *argv[], const char *customShortOptions, |
41 void stopAudio(); | 64 const struct option *customLongOptions, RTAudioSettings *settings); |
42 void cleanupAudio(); | 65 void BeagleRT_usage(); |
43 | 66 |
67 // Basic audio control functions: init, start, stop and clean up | |
68 int BeagleRT_initAudio(RTAudioSettings *settings, void *userData); | |
69 int BeagleRT_startAudio(); | |
70 void BeagleRT_stopAudio(); | |
71 void BeagleRT_cleanupAudio(); | |
72 | |
73 // Volume/level controls | |
74 // These return 0 on success | |
75 | |
76 // Set the level of the DAC; affects all outputs (headphone, line, speaker) | |
77 // 0dB is the maximum, -63.5dB is the minimum; 0.5dB steps | |
78 int BeagleRT_setDACLevel(float decibels); | |
79 | |
80 // Set the level of the ADC | |
81 // 0dB is the maximum, -12dB is the minimum; 1.5dB steps | |
82 int BeagleRT_setADCLevel(float decibels); | |
83 | |
84 // Set the level of the onboard headphone amplifier; affects headphone | |
85 // output only (not line out or speaker) | |
86 // 0dB is the maximum, -63.5dB is the minimum; 0.5dB steps | |
87 int BeagleRT_setHeadphoneLevel(float decibels); | |
88 | |
89 // Mute or unmute the onboard speaker amplifiers | |
90 // mute == 0 means unmute; otherwise mute | |
91 // Returns 0 on success | |
92 int BeagleRT_muteSpeakers(int mute); | |
93 | |
94 // Functions for creating auxiliary tasks | |
44 AuxiliaryTask createAuxiliaryTaskLoop(void (*functionToCall)(void), int priority, const char *name); | 95 AuxiliaryTask createAuxiliaryTaskLoop(void (*functionToCall)(void), int priority, const char *name); |
45 void scheduleAuxiliaryTask(AuxiliaryTask task); | 96 void scheduleAuxiliaryTask(AuxiliaryTask task); |
46 | 97 |
47 void setVerboseLevel(int level); | 98 void setVerboseLevel(int level); |
48 | 99 |