-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathsonic_experimental.h
48 lines (40 loc) · 1.55 KB
/
sonic_experimental.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
/* Sonic library
Copyright 2010
Bill Cox
This file is part of the Sonic Library.
This file is licensed under the Apache 2.0 license.
*/
/*
This is a stripped down version of sonic, to help it fit in micro-controllers.
Only mono speedup remains. All buffers are allocated statically.
*/
#ifdef __cplusplus
extern "C" {
#endif
/* Use a minimum pitch of 80 to reduce buffer sizes. Set it back to 65 if you
have the room in memory and find it sounds better. */
#define SONIC_MIN_PITCH 65
#define SONIC_MAX_PITCH 400
#define SONIC_MIN_SAMPLE_RATE 8000
#define SONIC_MAX_SAMPLE_RATE 96000
/* These are used to down-sample some inputs to improve speed */
#define SONIC_AMDF_FREQ 4000
/* This is the number of samples in the buffer size passed to Sonic. */
#define SONIC_INPUT_SAMPLES 80
/* Initialize Sonic. */
void sonicInit(float speed, int sampleRate);
/* Write input samples to the stream. numSamples must be <= SONIC_INPUT_SAMPLES
*/
void sonicWriteShortToStream(short *samples, int numSamples);
/* Use this to read 16-bit data out of the stream. Sometimes no data will
be available, and zero is returned, which is not an error condition. */
int sonicReadShortFromStream(short *samples, int maxSamples);
/* Force the sonic stream to generate output using whatever data it currently
has. No extra delay will be added to the output, but flushing in the middle
of words could introduce distortion. */
void sonicFlushStream(void);
/* Return the number of samples in the output buffer */
int sonicSamplesAvailable(void);
#ifdef __cplusplus
}
#endif