forked from rsta2/circle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoundshell.h
146 lines (121 loc) · 3.46 KB
/
soundshell.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
//
// soundshell.h
//
// Circle - A C++ bare metal environment for Raspberry Pi
// Copyright (C) 2017-2023 R. Stange <[email protected]>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _soundshell_h
#define _soundshell_h
#include <circle/input/console.h>
#include <circle/usb/usbhcidevice.h>
#include <circle/sound/soundbasedevice.h>
#include <circle/interrupt.h>
#include <circle/i2cmaster.h>
#include <circle/screen.h>
#include <circle/string.h>
#include <circle/types.h>
#include "config.h"
#include "oscillator.h"
#include "vumeter.h"
#ifdef USE_VCHIQ_SOUND
#include <vc4/sound/vchiqsoundbasedevice.h>
#endif
#define SOUNDSHELL_MAX_LINE 500
class CSoundShell
{
public:
CSoundShell (CConsole *pConsole, CInterruptSystem *pInterrupt,
CI2CMaster *pI2CMaster,
#ifdef USE_VCHIQ_SOUND
CVCHIQDevice *pVCHIQ,
#endif
CScreenDevice *pScreen, CUSBHCIDevice *pUSBHCI = 0);
~CSoundShell (void);
void Run (void);
private:
boolean Start (void);
boolean Cancel (void);
boolean Mode (void);
boolean Enable (void);
boolean Disable (void);
boolean ControlInfo (void);
boolean SetControl (void);
boolean Oscillator (void);
boolean VUMeter (void);
boolean Delay (void);
boolean Help (void);
int GetNumber (const char *pName, int nMinimum, int nMaximum, boolean bOptional = FALSE);
private:
void ReadLine (void);
boolean GetToken (CString *pString);
void UnGetToken (const CString &rString);
static int ConvertNumber (const CString &rString);
#define INVALID_NUMBER ((int) 0x80000000)
struct TStringMapping
{
const char *pString;
unsigned nID;
};
static unsigned ConvertString (const CString &rString, const TStringMapping *pMap);
CSoundController::TChannel ConvertChannel (const CString &rString);
void Print (const char *pFormat, ...);
private:
void ProcessSound (void);
void WriteSoundData (unsigned nFrames);
void GetSoundData (void *pBuffer, unsigned nFrames);
void ReadSoundData (void);
enum TMode
{
ModeOutput,
ModeInput,
ModeInputOutput,
ModeUnknown
};
enum TClockMode
{
ClockModeMaster,
ClockModeSlave,
ClockModeUnknown
};
private:
CConsole *m_pConsole;
CInterruptSystem *m_pInterrupt;
CI2CMaster *m_pI2CMaster;
#ifdef USE_VCHIQ_SOUND
CVCHIQDevice *m_pVCHIQ;
#endif
CScreenDevice *m_pScreen;
CUSBHCIDevice *m_pUSBHCI;
boolean m_bContinue;
unsigned m_nMode;
boolean m_bI2SDevice[2];
CSoundBaseDevice *m_pSound[2];
COscillator m_VCO[WRITE_CHANNELS];
CVUMeter *m_pVUMeter[WRITE_CHANNELS];
unsigned m_nLastTicks;
char m_LineBuffer[SOUNDSHELL_MAX_LINE+1];
boolean m_bFirstToken;
CString m_UnGetToken;
char *m_pSavePtr;
static const char HelpMsg[];
static const TStringMapping s_ModeMap[];
static const TStringMapping s_ClockModeMap[];
static const TStringMapping s_JackMap[];
static const TStringMapping s_ChannelMap[];
static const TStringMapping s_ControlMap[];
static const TStringMapping s_WaveformMap[];
};
#endif