-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio.h
61 lines (54 loc) · 1.38 KB
/
audio.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
#ifndef AUDIO_H
#define AUDIO_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
#include <termios.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <stdbool.h>
#include "../portaudio/include/portaudio.h"
// macos specific
#include <CoreAudio/CoreAudio.h>
// SETUP
float startTimeInSeconds = 0;
int sampleRate = 48000;
short bitDepth = 24;
PaStream *stream;
int frames = 256;
bool isRecording;
AudioDeviceID currentDefaultMacOSInputDevice;
AudioDeviceID currentDefaultMacOSOutputDevice;
typedef struct
{
FILE *file;
size_t dataSize; // not including header
float currentAmplitudeLevel;
bool recordEnabled;
} WavFile;
typedef struct
{
WavFile *tracks;
int trackCount;
int playbackPosition; // Current playback position in the buffer
} Recorder;
Recorder recorder = {NULL, 0, 0}; // Initializer ensures tracks is NULL
// functions
void initAudio();
void cleanupAudio();
void onStop();
void onStart(const uint32_t *inputTrackRecordEnabledStates, bool isRecordingFromUI);
void onRewind();
void onFastForward();
void onRtz();
float getCurrentStartTimeInSeconds();
int getInputTrackCount();
float getCurrentAmplitude(unsigned int index);
void onSetInputTrackRecordEnabled(unsigned int index, bool state);
int bounceTracks(const uint32_t *tracksToBounce, char *selectedPath);
#endif