-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGooya.h
executable file
·148 lines (111 loc) · 3.27 KB
/
Gooya.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//
// Created by Evixar Inc.
// Copyright © 2018 Evixar Inc. All rights reserved.
//
#ifndef __GOOYA_H__
#define __GOOYA_H__
#ifndef GOOYA_CPU
#define GOOYA_CPU (0)
#endif
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/i2s.h"
#include <vector>
//for SD
#include <SD.h>
//codec
#if !defined(GOOYA_CODEC_WM8731) && !defined(GOOYA_CODEC_AK4951)
#define GOOYA_CODEC_WM8731
#endif
#ifdef GOOYA_CODEC_WM8731
#include "WM8731.h"
#endif
#ifdef GOOYA_CODEC_AK4951
#include "AK4951.h"
#endif
#include "I2SMaster.h"
#ifndef GOOYA_RECORD_BUFFER_COUNT
#define GOOYA_RECORD_BUFFER_COUNT (2)
#endif
#ifndef GOOYA_PLAY_BUFFER_COUNT
#define GOOYA_PLAY_BUFFER_COUNT (2)
#endif
using namespace std;
//callback
typedef void (* GOOYA_AUDIOCALLBACK)(const float* input, float* output, int8_t chs, int32_t frames);
#define GOOYARECORDER_MICIN 0
#define GOOYARECORDER_LINEIN 1
class GooyaRecorder
{
public:
GooyaRecorder();
void start(int devid, int sample_rate, File& file, bool stereo=false, bool float32=false);
void stop();
private:
I2SMaster i2s;
WM8731 codec;
File* file;
bool stereo;
bool float32;
xQueueHandle queue;
int32_t pos;
int32_t chunk_count;
int16_t signal[DMA_AUDIO_FRAMES*AUDIO_CHANNELS*GOOYA_RECORD_BUFFER_COUNT];
void inputcallback(int16_t* input, int8_t chs, int32_t frames);
static void _inputcallback(int16_t* input, int8_t chs, int32_t frames, void* param);
bool running;
TaskHandle_t recorder_task;
void recorder_task_function();
static void _recorder_task_function(void* param);
};
class GooyaPlayer
{
public:
GooyaPlayer();
void start(int sample_rate, File& file, int headphonelevel=-24, bool stereo=false, bool float32=false);
void stop();
private:
I2SMaster i2s;
WM8731 codec;
bool stereo;
bool float32;
File* file;
xQueueHandle queue;
int16_t signal[DMA_AUDIO_FRAMES*AUDIO_CHANNELS*GOOYA_PLAY_BUFFER_COUNT];
void outputcallback(int16_t* output, int8_t chs, int32_t frames);
static void _outputcallback(int16_t* output, int8_t chs, int32_t frames, void* param);
bool running;
TaskHandle_t player_task;
void player_task_function();
static void _player_task_function(void* param);
};
class GooyaEffect
{
public:
GooyaEffect();
void start(int devid, int sample_rate, GOOYA_AUDIOCALLBACK callback, int headphonelevel=-24);
void stop();
private:
I2SMaster i2s;
WM8731 codec;
xQueueHandle inputqueue;
xQueueHandle outputqueue;
int32_t pos;
int32_t chunk_count;
//std::vector<int16_t> signal;//byte size of DMA_AUDIO_FRAMES*AUDIO_CHANNELS*GOOYA_RECORD_BUFFER_COUNT;
int16_t signal[DMA_AUDIO_FRAMES*AUDIO_CHANNELS*GOOYA_RECORD_BUFFER_COUNT];
void inputcallback(int16_t* output, int8_t chs, int32_t frames);
static void _inputcallback(int16_t* output, int8_t chs, int32_t frames, void* param);
void outputcallback(int16_t* output, int8_t chs, int32_t frames);
static void _outputcallback(int16_t* output, int8_t chs, int32_t frames, void* param);
GOOYA_AUDIOCALLBACK callback;
bool running;
TaskHandle_t effect_task;
void effect_task_function();
static void _effect_task_function(void* param);
};
/*
class GooyaAnalyzer
class GooyaGenerator
*/
#endif