FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nRF52Audio/ChainedSDWavFile.h at master · JakeS0ft/nRF52Audio · GitHub
JakeS0ft
nRF52Audio
Repository navigation
Code
Issues
1
(1)
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nRF52Audio
/
ChainedSDWavFile.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
175 lines (148 loc) · 4.74 KB
Breadcrumbs
nRF52Audio
/
ChainedSDWavFile.h
Copy path
File metadata and controls
175 lines (148 loc) · 4.74 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
*****************************************************************************
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************
*/
/*
* ChainedSDWavFile.h
*
* Created on: Oct 31, 2019
* Author: JakeSoft
*/
#
ifndef
_CHAINEDSDWAVFILE_H_
#
define
_CHAINEDSDWAVFILE_H_
#
include
"
ISDWavFile.h
"
#
include
"
SDWavFile.h
"
#
define
NUM_CHAINED_FILES
2
/*
*
* This class allows for seamless (gapless) transition between two wav files.
* The first file is played until it ends, then the second file starts
* right after the first is done. The second file can be optionally looped by
* calling the SetLooping() method.
* NOTE: It is not recommend to mix files with different sample rates in a chain.
*/
class
ChainedSDWavFile
:
public
ISDWavFile
{
public:
/*
*
* Constructor.
* Args:
* aFilePath - First file to play
* aNextFilePath - File to play when the first file is done
*/
ChainedSDWavFile
(
const
char
* aFilePath,
const
char
* aNextFilePath);
/*
*
* Descturctor.
*/
~ChainedSDWavFile
();
/*
*
* Fetch the underlying file handle.
* NOTE: Fetches the handle of the current file being played.
* If first file has finished playback, then this will return
* the file handle for the second file.
*/
File&
GetFileHandle
();
/*
*
* Fetch basic file header.
* NOTE: Fetches the file header of the curent file being played.
*/
const
tWavFileHeader&
GetHeader
();
/*
*
* Fetch header for the data block
*/
const
tWavDataHeader&
GetDataHeader
();
/*
*
* Close the files.
*/
virtual
void
Close
();
/*
*
* Force the file's read pointer to the start of the data block
*/
virtual
bool
SeekStartOfData
();
/*
*
* Fetch how many bytes are available to be read before
* the read pointer reaches the end of the file.
* NOTE: This is not accurate until less then 32768 bytes
* are available in the file.
*
* Returns: Number of bytes left to be read
*/
virtual
int
Available
();
/*
*
* Fetch the sound data as 16-bit samples
* Args:
* apBuffer - Pointer to buffer to fill with data
* aNumSamples - How many samples to read
* Returns: Number of samples filled
*/
virtual
int
Fetch16BitSamples
(
int16_t
* apBuffer,
int
aNumSamples);
/*
*
* Set the output volume. This can be used to adjust the
* relative volume of each file when multiple files are played
* at the same time.
*
* Args:
* aVolume - Any value between 1.0 (max) and 0.0 (mute)
*/
virtual
void
SetVolume
(
float
aVolume);
/*
*
* Enable/Disable looping. When looping is enabled and the end of file is
* reached, the read pointer will automatically reset to the start of
* the data block. This has the effect of simulating a wav file that
* never runs out of data.
*
* Args:
* aLoopingEnable - TRUE = Do looping, FALSE = Play once, no looping
*/
virtual
void
SetLooping
(
bool
aLoopingEnable);
/*
*
* Sets the paused flag. See IsPaused().
*/
virtual
void
Pause
();
/*
*
* Check if this file is paused.
*
* Return: TRUE if paused, FALSE otherwise
*/
virtual
bool
IsPaused
();
/*
*
* Clears the paused flag. See IsPaused().
*/
virtual
void
UnPause
();
/*
*
* Check if file has run out of data.
* NOTE: This will always be false if looping is enabled.
* Returns: TRUE if file has run out of data, FALSE otherwise.
*/
virtual
bool
IsEnded
();
/*
*
* Enable/Disable the De-pop algorithm.
* The De-pop alogrithm attempts to eliminate pops that can occur when
* a file first starts or when playback loops from the end to the start.
* When looping is enabled, it is recommended that both start and end
* de-pop be enabled.
* Args:
* aStart - TRUE= Enable for start of file, FALSE = disabled
* aEnd - TRUE = Enable for end of file, FALSE = disabled
*/
virtual
void
SetDePop
(
bool
aStart,
bool
aEnd);
/*
*
* Skips samples. All read pointers are advanced.
* Args:
* aNumSamples - Number of 16-bit samples to skip.
*/
virtual
void
Skip16BitSamples
(
int
aNumSamples);
protected:
SDWavFile* mpFiles[
NUM_CHAINED_FILES
];
int
mFileIndex
;
};
#
endif
/*
_CHAINEDSDWAVFILE_H_
*/
Back
|
FazBrowse Home
|
New Git URL