PortAudio 2.0
audio_analyzer.h
Go to the documentation of this file.
1
2/*
3 * PortAudio Portable Real-Time Audio Library
4 * Latest Version at: http://www.portaudio.com
5 *
6 * Copyright (c) 1999-2010 Phil Burk and Ross Bencina
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files
10 * (the "Software"), to deal in the Software without restriction,
11 * including without limitation the rights to use, copy, modify, merge,
12 * publish, distribute, sublicense, and/or sell copies of the Software,
13 * and to permit persons to whom the Software is furnished to do so,
14 * subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
24 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28/*
29 * The text above constitutes the entire PortAudio license; however,
30 * the PortAudio community also makes the following non-binding requests:
31 *
32 * Any person wishing to distribute modifications to the Software is
33 * requested to send the modifications to the original developer so that
34 * they can be incorporated into the canonical version. It is also
35 * requested that these non-binding requests be included along with the
36 * license above.
37 */
38
39#ifndef _AUDIO_ANALYZER_H
40#define _AUDIO_ANALYZER_H
41
42#include "biquad_filter.h"
43
44#define MATH_PI (3.141592653589793238462643)
45#define MATH_TWO_PI (2.0 * MATH_PI)
46
54
65
74
88
89
90/*================================================================*/
91/*================= General DSP Tools ============================*/
92/*================================================================*/
97double PaQa_GetNthFrequency( double baseFrequency, int index );
98
99void PaQa_EraseBuffer( float *buffer, int numFrames, int samplesPerFrame );
100
101void PaQa_MixSine( PaQaSineGenerator *generator, float *buffer, int numSamples, int stride );
102
103void PaQa_WriteSine( float *buffer, int numSamples, int stride,
104 double frequency, double amplitude );
105
109void PaQa_GenerateCrack( float *buffer, int numSamples, int stride );
110
111double PaQa_ComputePhaseDifference( double phase1, double phase2 );
112
116double PaQa_MeasureArea( float *buffer, int numFrames, int stride );
117
121double PaQa_MeasureCrossingSlope( float *buffer, int numFrames );
122
123
127void PaQa_SetupSineGenerator( PaQaSineGenerator *generator, double frequency, double amplitude, double frameRate );
128
129/*================================================================*/
130/*================= Recordings ===================================*/
131/*================================================================*/
135 int PaQa_InitializeRecording( PaQaRecording *recording, int maxSamples, int sampleRate );
136
140 void PaQa_TerminateRecording( PaQaRecording *recording );
141
145void PaQa_FilterRecording( PaQaRecording *input, PaQaRecording *output, BiquadFilter *filter );
146
147
148int PaQa_SaveRecordingToWaveFile( PaQaRecording *recording, const char *filename );
149
153int PaQa_WriteRecording( PaQaRecording *recording, float *buffer, int numSamples, int stride );
154
156int PaQa_WriteSilence( PaQaRecording *recording, int numSamples );
157
158int PaQa_RecordFreeze( PaQaRecording *recording, int numSamples );
159
160double PaQa_CorrelateSine( PaQaRecording *recording, double frequency, double frameRate,
161 int startFrame, int numSamples, double *phasePtr );
162
163double PaQa_FindFirstMatch( PaQaRecording *recording, float *buffer, int numSamples, double tolerance );
164
170 double frequency, double frameRate,
171 int startFrame, int numFrames );
172
173double PaQa_MeasureRootMeanSquare( float *buffer, int numFrames );
174
179double PaQa_CompareAmplitudes( PaQaRecording *recording, int startAt, float *buffer, int numSamples );
180
185int PaQa_AnalyseRecording( PaQaRecording *recording, PaQaTestTone *testTone, PaQaAnalysisResult *analysisResult );
186
187#endif /* _AUDIO_ANALYZER_H */
struct PaQaSineGenerator_s PaQaSineGenerator
void PaQa_EraseBuffer(float *buffer, int numFrames, int samplesPerFrame)
Definition audio_analyzer.c:58
double PaQa_MeasureSineAmplitudeBySlope(PaQaRecording *recording, double frequency, double frameRate, int startFrame, int numFrames)
Definition audio_analyzer.c:287
struct PaQaRecording_s PaQaRecording
double PaQa_MeasureCrossingSlope(float *buffer, int numFrames)
Definition audio_analyzer.c:251
void PaQa_MixSine(PaQaSineGenerator *generator, float *buffer, int numSamples, int stride)
Definition audio_analyzer.c:78
double PaQa_CompareAmplitudes(PaQaRecording *recording, int startAt, float *buffer, int numSamples)
Definition audio_analyzer.c:447
int PaQa_RecordFreeze(PaQaRecording *recording, int numSamples)
Definition audio_analyzer.c:181
void PaQa_SetupSineGenerator(PaQaSineGenerator *generator, double frequency, double amplitude, double frameRate)
Definition audio_analyzer.c:69
int PaQa_AnalyseRecording(PaQaRecording *recording, PaQaTestTone *testTone, PaQaAnalysisResult *analysisResult)
Definition audio_analyzer.c:685
int PaQa_WriteSilence(PaQaRecording *recording, int numSamples)
Definition audio_analyzer.c:160
void PaQa_TerminateRecording(PaQaRecording *recording)
Definition audio_analyzer.c:127
int PaQa_WriteRecording(PaQaRecording *recording, float *buffer, int numSamples, int stride)
Definition audio_analyzer.c:138
struct PaQaTestTone_s PaQaTestTone
void PaQa_FilterRecording(PaQaRecording *input, PaQaRecording *output, BiquadFilter *filter)
Definition audio_analyzer.c:340
double PaQa_MeasureArea(float *buffer, int numFrames, int stride)
Definition audio_analyzer.c:414
double PaQa_FindFirstMatch(PaQaRecording *recording, float *buffer, int numSamples, double tolerance)
Definition audio_analyzer.c:352
int PaQa_InitializeRecording(PaQaRecording *recording, int maxSamples, int sampleRate)
Definition audio_analyzer.c:114
double PaQa_GetNthFrequency(double baseFrequency, int index)
Definition audio_analyzer.c:51
void PaQa_GenerateCrack(float *buffer, int numSamples, int stride)
double PaQa_ComputePhaseDifference(double phase1, double phase2)
Definition audio_analyzer.c:463
struct PaQaAnalysisResult_s PaQaAnalysisResult
double PaQa_MeasureRootMeanSquare(float *buffer, int numFrames)
Definition audio_analyzer.c:428
int PaQa_SaveRecordingToWaveFile(PaQaRecording *recording, const char *filename)
Definition audio_analyzer.c:206
void PaQa_WriteSine(float *buffer, int numSamples, int stride, double frequency, double amplitude)
double PaQa_CorrelateSine(PaQaRecording *recording, double frequency, double frameRate, int startFrame, int numSamples, double *phasePtr)
Definition audio_analyzer.c:299
char buffer[NUM_BYTES]
Definition recplay.c:26
Definition biquad_filter.h:15
Definition audio_analyzer.h:76
double amplitudeRatio
Definition audio_analyzer.h:80
double droppedFramesPosition
Definition audio_analyzer.h:84
double addedFramesPosition
Definition audio_analyzer.h:86
double latency
Definition audio_analyzer.h:79
double popPosition
Definition audio_analyzer.h:82
double popAmplitude
Definition audio_analyzer.h:81
double numDroppedFrames
Definition audio_analyzer.h:83
double numAddedFrames
Definition audio_analyzer.h:85
int valid
Definition audio_analyzer.h:77
Definition audio_analyzer.h:57
float * buffer
Definition audio_analyzer.h:60
int sampleRate
Definition audio_analyzer.h:63
int numFrames
Definition audio_analyzer.h:62
int maxFrames
Definition audio_analyzer.h:59
Definition audio_analyzer.h:48
double phase
Definition audio_analyzer.h:49
double phaseIncrement
Definition audio_analyzer.h:50
double amplitude
Definition audio_analyzer.h:52
double frequency
Definition audio_analyzer.h:51
Definition audio_analyzer.h:67
int startDelay
Definition audio_analyzer.h:69
double sampleRate
Definition audio_analyzer.h:70
int samplesPerFrame
Definition audio_analyzer.h:68
double amplitude
Definition audio_analyzer.h:72
double frequency
Definition audio_analyzer.h:71