miniDSP
A small C library for audio DSP
Loading...
Searching...
No Matches
minidsp.h
Go to the documentation of this file.
1
27#ifndef MINIDSP_H
28#define MINIDSP_H
29
30/* Version macros — injected by Makefile via -D flags.
31 * Defaults here allow the header to compile standalone. */
32#ifndef MINIDSP_VERSION_MAJOR
33#define MINIDSP_VERSION_MAJOR 0
34#endif
35#ifndef MINIDSP_VERSION_MINOR
36#define MINIDSP_VERSION_MINOR 0
37#endif
38#ifndef MINIDSP_VERSION_PATCH
39#define MINIDSP_VERSION_PATCH 0
40#endif
41#ifndef MINIDSP_VERSION
42#define MINIDSP_VERSION "0.0.0"
43#endif
44
45#include <stdio.h>
46#include <string.h>
47#include <stdlib.h>
48#include <math.h>
49#include <stdbool.h>
50
51/* -----------------------------------------------------------------------
52 * Error handling
53 * -----------------------------------------------------------------------*/
54
67
78typedef void (*MD_ErrorHandler)(MD_ErrorCode code,
79 const char *func_name,
80 const char *message);
81
107
108/* M_PI is not guaranteed by the C standard. Define it if the system didn't. */
109#ifndef M_PI
110#define M_PI 3.14159265358979323846
111#endif
112#include <float.h>
113#include <complex.h>
114#include <fftw3.h>
115
116/* -----------------------------------------------------------------------
117 * Basic signal measurement functions
118 * -----------------------------------------------------------------------*/
119
124double MD_dot(const double *a, const double *b, unsigned N);
125
133double MD_entropy(const double *a, unsigned N, bool clip);
134
136double MD_energy(const double *a, unsigned N);
137
139double MD_power(const double *a, unsigned N);
140
142double MD_power_db(const double *a, unsigned N);
143
144/* -----------------------------------------------------------------------
145 * Signal analysis
146 * -----------------------------------------------------------------------*/
147
170double MD_rms(const double *a, unsigned N);
171
198double MD_zero_crossing_rate(const double *a, unsigned N);
199
228void MD_autocorrelation(const double *a, unsigned N,
229 double *out, unsigned max_lag);
230
259void MD_peak_detect(const double *a, unsigned N, double threshold,
260 unsigned min_distance, unsigned *peaks_out,
261 unsigned *num_peaks_out);
262
292double MD_f0_autocorrelation(const double *signal, unsigned N,
293 double sample_rate,
294 double min_freq_hz, double max_freq_hz);
295
328double MD_f0_fft(const double *signal, unsigned N,
329 double sample_rate,
330 double min_freq_hz, double max_freq_hz);
331
357void MD_mix(const double *a, const double *b, double *out,
358 unsigned N, double w_a, double w_b);
359
360/* -----------------------------------------------------------------------
361 * Simple effects
362 * -----------------------------------------------------------------------*/
363
390void MD_delay_echo(const double *in, double *out, unsigned N,
391 unsigned delay_samples, double feedback,
392 double dry, double wet);
393
420void MD_tremolo(const double *in, double *out, unsigned N,
421 double rate_hz, double depth, double sample_rate);
422
448void MD_comb_reverb(const double *in, double *out, unsigned N,
449 unsigned delay_samples, double feedback,
450 double dry, double wet);
451
452/* -----------------------------------------------------------------------
453 * FIR filters / convolution
454 * -----------------------------------------------------------------------*/
455
461unsigned MD_convolution_num_samples(unsigned signal_len, unsigned kernel_len);
462
476void MD_convolution_time(const double *signal, unsigned signal_len,
477 const double *kernel, unsigned kernel_len,
478 double *out);
479
492void MD_moving_average(const double *signal, unsigned signal_len,
493 unsigned window_len, double *out);
494
508void MD_fir_filter(const double *signal, unsigned signal_len,
509 const double *coeffs, unsigned num_taps,
510 double *out);
511
524void MD_convolution_fft_ola(const double *signal, unsigned signal_len,
525 const double *kernel, unsigned kernel_len,
526 double *out);
527
553void MD_design_lowpass_fir(double *coeffs, unsigned num_taps,
554 double cutoff_freq, double sample_rate,
555 double kaiser_beta);
556
557/* -----------------------------------------------------------------------
558 * Signal scaling and conditioning
559 * -----------------------------------------------------------------------*/
560
565double MD_scale(double in,
566 double oldmin, double oldmax,
567 double newmin, double newmax);
568
570void MD_scale_vec(double *in, double *out, unsigned N,
571 double oldmin, double oldmax,
572 double newmin, double newmax);
573
579void MD_fit_within_range(double *in, double *out, unsigned N,
580 double newmin, double newmax);
581
586void MD_adjust_dblevel(const double *in, double *out,
587 unsigned N, double dblevel);
588
589/* -----------------------------------------------------------------------
590 * FFT / Spectrum Analysis
591 * -----------------------------------------------------------------------*/
592
633void MD_magnitude_spectrum(const double *signal, unsigned N, double *mag_out);
634
681void MD_power_spectral_density(const double *signal, unsigned N, double *psd_out);
682
727void MD_phase_spectrum(const double *signal, unsigned N, double *phase_out);
728
753unsigned MD_stft_num_frames(unsigned signal_len, unsigned N, unsigned hop);
754
810void MD_stft(const double *signal, unsigned signal_len,
811 unsigned N, unsigned hop,
812 double *mag_out);
813
838void MD_mel_filterbank(unsigned N, double sample_rate,
839 unsigned num_mels,
840 double min_freq_hz, double max_freq_hz,
841 double *filterbank_out);
842
861void MD_mel_energies(const double *signal, unsigned N,
862 double sample_rate, unsigned num_mels,
863 double min_freq_hz, double max_freq_hz,
864 double *mel_out);
865
889void MD_mfcc(const double *signal, unsigned N,
890 double sample_rate,
891 unsigned num_mels, unsigned num_coeffs,
892 double min_freq_hz, double max_freq_hz,
893 double *mfcc_out);
894
895/* -----------------------------------------------------------------------
896 * FFT-based filtering
897 * -----------------------------------------------------------------------*/
898
936void MD_lowpass_brickwall(double *signal, unsigned len,
937 double cutoff_hz, double sample_rate);
938
939/* -----------------------------------------------------------------------
940 * Math utilities
941 * -----------------------------------------------------------------------*/
942
959double MD_bessel_i0(double x);
960
978double MD_sinc(double x);
979
980/* -----------------------------------------------------------------------
981 * Window generation
982 * -----------------------------------------------------------------------*/
983
988void MD_Gen_Hann_Win(double *out, unsigned n);
989
994void MD_Gen_Hamming_Win(double *out, unsigned n);
995
1000void MD_Gen_Blackman_Win(double *out, unsigned n);
1001
1006void MD_Gen_Rect_Win(double *out, unsigned n);
1007
1030void MD_Gen_Kaiser_Win(double *out, unsigned n, double beta);
1031
1032/* -----------------------------------------------------------------------
1033 * Signal generators
1034 * -----------------------------------------------------------------------*/
1035
1057void MD_sine_wave(double *output, unsigned N, double amplitude,
1058 double freq, double sample_rate);
1059
1083void MD_white_noise(double *output, unsigned N, double amplitude,
1084 unsigned seed);
1085
1109void MD_impulse(double *output, unsigned N, double amplitude, unsigned position);
1110
1140void MD_chirp_linear(double *output, unsigned N, double amplitude,
1141 double f_start, double f_end, double sample_rate);
1142
1175void MD_chirp_log(double *output, unsigned N, double amplitude,
1176 double f_start, double f_end, double sample_rate);
1177
1209void MD_square_wave(double *output, unsigned N, double amplitude,
1210 double freq, double sample_rate);
1211
1239void MD_sawtooth_wave(double *output, unsigned N, double amplitude,
1240 double freq, double sample_rate);
1241
1304void MD_shepard_tone(double *output, unsigned N, double amplitude,
1305 double base_freq, double sample_rate,
1306 double rate_octaves_per_sec, unsigned num_octaves);
1307
1308/* -----------------------------------------------------------------------
1309 * DTMF tone detection and generation
1310 * -----------------------------------------------------------------------
1311 *
1312 * Dual-Tone Multi-Frequency (DTMF) signalling encodes each keypad
1313 * button as a pair of sinusoids -- one from a low-frequency "row" group
1314 * and one from a high-frequency "column" group:
1315 *
1316 * 1209 Hz 1336 Hz 1477 Hz 1633 Hz
1317 * 697 Hz 1 2 3 A
1318 * 770 Hz 4 5 6 B
1319 * 852 Hz 7 8 9 C
1320 * 941 Hz * 0 # D
1321 *
1322 * Detection uses frame-based FFT magnitude analysis with a state machine
1323 * that enforces ITU-T Q.24 minimum timing constraints (40 ms tone-on,
1324 * 40 ms inter-digit pause).
1325 */
1326
1328typedef struct {
1329 char digit;
1330 double start_s;
1331 double end_s;
1332} MD_DTMFTone;
1333
1371unsigned MD_dtmf_detect(const double *signal, unsigned signal_len,
1372 double sample_rate,
1373 MD_DTMFTone *tones_out, unsigned max_tones);
1374
1404void MD_dtmf_generate(double *output, const char *digits,
1405 double sample_rate,
1406 unsigned tone_ms, unsigned pause_ms);
1407
1424unsigned MD_dtmf_signal_length(unsigned num_digits, double sample_rate,
1425 unsigned tone_ms, unsigned pause_ms);
1426
1427/* -----------------------------------------------------------------------
1428 * Resource cleanup
1429 * -----------------------------------------------------------------------*/
1430
1432void MD_shutdown(void);
1433
1434/* -----------------------------------------------------------------------
1435 * Generalized Cross-Correlation (GCC) for delay estimation
1436 * -----------------------------------------------------------------------
1437 *
1438 * Given two microphone signals that captured the same sound source,
1439 * GCC-PHAT estimates how many samples one signal is delayed relative
1440 * to the other. This is the basis of acoustic source localisation.
1441 *
1442 * The algorithm:
1443 * 1. FFT both signals.
1444 * 2. Multiply one spectrum by the conjugate of the other (cross-spectrum).
1445 * 3. Apply a weighting (PHAT normalises by magnitude, sharpening the peak).
1446 * 4. Inverse-FFT back to the time domain.
1447 * 5. The position of the peak tells you the delay in samples.
1448 */
1449
1455
1466void MD_get_multiple_delays(const double **sigs, unsigned M, unsigned N,
1467 unsigned margin, int weightfunc,
1468 int *outdelays);
1469
1482int MD_get_delay(const double *siga, const double *sigb, unsigned N,
1483 double *ent, unsigned margin, int weightfunc);
1484
1495void MD_gcc(const double *siga, const double *sigb, unsigned N,
1496 double *lagvals, int weightfunc);
1497
1498/* -----------------------------------------------------------------------
1499 * Spectrogram text art
1500 * -----------------------------------------------------------------------*/
1501
1528unsigned MD_spectrogram_text(double *output, unsigned max_len,
1529 const char *text,
1530 double freq_lo, double freq_hi,
1531 double duration_sec, double sample_rate);
1532
1533/* -----------------------------------------------------------------------
1534 * Audio steganography
1535 * -----------------------------------------------------------------------*/
1536
1538#define MD_STEG_LSB 0
1540#define MD_STEG_FREQ_BAND 1
1556#define MD_STEG_SPECTEXT 2
1557
1559#define MD_STEG_TYPE_TEXT 0
1561#define MD_STEG_TYPE_BINARY 1
1562
1571unsigned MD_steg_capacity(unsigned signal_len, double sample_rate, int method);
1572
1610unsigned MD_steg_encode(const double *host, double *output,
1611 unsigned signal_len, double sample_rate,
1612 const char *message, int method);
1613
1635unsigned MD_steg_decode(const double *stego, unsigned signal_len,
1636 double sample_rate,
1637 char *message_out, unsigned max_msg_len,
1638 int method);
1639
1665unsigned MD_steg_encode_bytes(const double *host, double *output,
1666 unsigned signal_len, double sample_rate,
1667 const unsigned char *data, unsigned data_len,
1668 int method);
1669
1691unsigned MD_steg_decode_bytes(const double *stego, unsigned signal_len,
1692 double sample_rate,
1693 unsigned char *data_out, unsigned max_len,
1694 int method);
1695
1724int MD_steg_detect(const double *signal, unsigned signal_len,
1725 double sample_rate, int *payload_type_out);
1726
1727/* -----------------------------------------------------------------------
1728 * Sample rate conversion
1729 * -----------------------------------------------------------------------*/
1730
1746unsigned MD_resample_output_len(unsigned input_len,
1747 double in_rate, double out_rate);
1748
1778unsigned MD_resample(const double *input, unsigned input_len,
1779 double *output, unsigned max_output_len,
1780 double in_rate, double out_rate,
1781 unsigned num_zero_crossings, double kaiser_beta);
1782
1783/* -----------------------------------------------------------------------
1784 * Voice Activity Detection (VAD)
1785 * -----------------------------------------------------------------------*/
1786
1789#define MD_VAD_FEAT_ENERGY 0
1790#define MD_VAD_FEAT_ZCR 1
1791#define MD_VAD_FEAT_SPECTRAL_ENTROPY 2
1792#define MD_VAD_FEAT_SPECTRAL_FLATNESS 3
1793#define MD_VAD_FEAT_BAND_ENERGY_RATIO 4
1794#define MD_VAD_NUM_FEATURES 5
1796
1812
1828
1864
1882void MD_vad_init(MD_vad_state *state, const MD_vad_params *params);
1883
1906void MD_vad_calibrate(MD_vad_state *state, const double *signal,
1907 unsigned N, double sample_rate);
1908
1941int MD_vad_process_frame(MD_vad_state *state, const double *signal,
1942 unsigned N, double sample_rate,
1943 double *score_out, double *features_out);
1944
1945#endif /* MINIDSP_H */
void MD_Gen_Kaiser_Win(double *out, unsigned n, double beta)
Generate a Kaiser window of length n with shape parameter beta.
void MD_chirp_linear(double *output, unsigned N, double amplitude, double f_start, double f_end, double sample_rate)
Generate a linear chirp (swept sine with linearly increasing frequency).
#define MD_VAD_NUM_FEATURES
Total number of features.
Definition minidsp.h:1794
double MD_power(const double *a, unsigned N)
Compute signal power: energy divided by the number of samples.
unsigned MD_steg_capacity(unsigned signal_len, double sample_rate, int method)
Compute the maximum message length (in bytes) that can be hidden.
unsigned MD_steg_encode_bytes(const double *host, double *output, unsigned signal_len, double sample_rate, const unsigned char *data, unsigned data_len, int method)
Encode arbitrary binary data into a host audio signal.
void MD_power_spectral_density(const double *signal, unsigned N, double *psd_out)
Compute the power spectral density (PSD) of a real-valued signal.
unsigned MD_dtmf_detect(const double *signal, unsigned signal_len, double sample_rate, MD_DTMFTone *tones_out, unsigned max_tones)
Detect DTMF tones in an audio signal.
MD_ErrorCode
Error codes reported by miniDSP when a precondition is violated.
Definition minidsp.h:61
@ MD_ERR_INVALID_SIZE
A size or count argument is invalid (e.g.
Definition minidsp.h:63
@ MD_ERR_INVALID_RANGE
A range or bound is invalid (e.g.
Definition minidsp.h:64
@ MD_ERR_ALLOC_FAILED
A memory allocation failed.
Definition minidsp.h:65
@ MD_ERR_NULL_POINTER
A required pointer argument is NULL.
Definition minidsp.h:62
void MD_vad_default_params(MD_vad_params *params)
Populate a VAD params struct with optimized defaults.
void MD_white_noise(double *output, unsigned N, double amplitude, unsigned seed)
Generate Gaussian white noise.
unsigned MD_resample_output_len(unsigned input_len, double in_rate, double out_rate)
Compute the output buffer size needed for resampling.
void MD_dtmf_generate(double *output, const char *digits, double sample_rate, unsigned tone_ms, unsigned pause_ms)
Generate a DTMF tone sequence.
void MD_sine_wave(double *output, unsigned N, double amplitude, double freq, double sample_rate)
Generate a sine wave.
unsigned MD_steg_decode_bytes(const double *stego, unsigned signal_len, double sample_rate, unsigned char *data_out, unsigned max_len, int method)
Decode binary data from a stego audio signal.
void MD_impulse(double *output, unsigned N, double amplitude, unsigned position)
Generate a discrete impulse (Kronecker delta).
void MD_Gen_Blackman_Win(double *out, unsigned n)
Generate a Blackman window of length n.
double MD_zero_crossing_rate(const double *a, unsigned N)
Compute the zero-crossing rate of a signal.
void MD_scale_vec(double *in, double *out, unsigned N, double oldmin, double oldmax, double newmin, double newmax)
Map every element of a vector from one range to another.
void MD_mel_energies(const double *signal, unsigned N, double sample_rate, unsigned num_mels, double min_freq_hz, double max_freq_hz, double *mel_out)
Compute mel-band energies from a single frame.
void MD_mfcc(const double *signal, unsigned N, double sample_rate, unsigned num_mels, unsigned num_coeffs, double min_freq_hz, double max_freq_hz, double *mfcc_out)
Compute mel-frequency cepstral coefficients (MFCCs) from a single frame.
void MD_shepard_tone(double *output, unsigned N, double amplitude, double base_freq, double sample_rate, double rate_octaves_per_sec, unsigned num_octaves)
Generate a Shepard tone — the auditory illusion of endlessly rising or falling pitch.
void MD_Gen_Hamming_Win(double *out, unsigned n)
Generate a Hamming window of length n.
void MD_phase_spectrum(const double *signal, unsigned N, double *phase_out)
Compute the one-sided phase spectrum of a real signal.
unsigned MD_steg_decode(const double *stego, unsigned signal_len, double sample_rate, char *message_out, unsigned max_msg_len, int method)
Decode a secret message from a stego audio signal.
void MD_convolution_fft_ola(const double *signal, unsigned signal_len, const double *kernel, unsigned kernel_len, double *out)
Full linear convolution using FFT overlap-add (offline).
double MD_f0_fft(const double *signal, unsigned N, double sample_rate, double min_freq_hz, double max_freq_hz)
Estimate the fundamental frequency (F0) using FFT peak picking.
int MD_vad_process_frame(MD_vad_state *state, const double *signal, unsigned N, double sample_rate, double *score_out, double *features_out)
Process one audio frame and return a binary speech decision.
MD_GCC_WEIGHTING_TYPE
Weighting types for Generalized Cross-Correlation.
Definition minidsp.h:1451
@ SIMP
Simple 1/N weighting (basic cross-correlation).
Definition minidsp.h:1452
@ PHAT
Phase Transform weighting (sharper peaks, more robust to noise).
Definition minidsp.h:1453
double MD_bessel_i0(double x)
Zeroth-order modified Bessel function of the first kind, .
void MD_tremolo(const double *in, double *out, unsigned N, double rate_hz, double depth, double sample_rate)
Tremolo effect (amplitude modulation by a sinusoidal LFO).
unsigned MD_convolution_num_samples(unsigned signal_len, unsigned kernel_len)
Compute the output length of a full linear convolution.
Definition minidsp_fir.c:18
unsigned MD_spectrogram_text(double *output, unsigned max_len, const char *text, double freq_lo, double freq_hi, double duration_sec, double sample_rate)
Synthesise audio that displays readable text in a spectrogram.
double MD_scale(double in, double oldmin, double oldmax, double newmin, double newmax)
Map a single value from one range to another.
void(* MD_ErrorHandler)(MD_ErrorCode code, const char *func_name, const char *message)
Signature for a user-installed error handler.
Definition minidsp.h:78
void MD_Gen_Hann_Win(double *out, unsigned n)
Generate a Hanning (Hann) window of length n.
double MD_energy(const double *a, unsigned N)
Compute signal energy: sum of squared samples.
unsigned MD_resample(const double *input, unsigned input_len, double *output, unsigned max_output_len, double in_rate, double out_rate, unsigned num_zero_crossings, double kaiser_beta)
Resample a signal from one sample rate to another using polyphase sinc interpolation.
void MD_stft(const double *signal, unsigned signal_len, unsigned N, unsigned hop, double *mag_out)
Compute the Short-Time Fourier Transform (STFT) of a real-valued signal.
void MD_design_lowpass_fir(double *coeffs, unsigned num_taps, double cutoff_freq, double sample_rate, double kaiser_beta)
Design a Kaiser-windowed sinc lowpass FIR filter.
Definition minidsp_fir.c:88
void MD_peak_detect(const double *a, unsigned N, double threshold, unsigned min_distance, unsigned *peaks_out, unsigned *num_peaks_out)
Detect peaks (local maxima) in a signal.
unsigned MD_dtmf_signal_length(unsigned num_digits, double sample_rate, unsigned tone_ms, unsigned pause_ms)
Calculate the number of samples needed for MD_dtmf_generate().
unsigned MD_steg_encode(const double *host, double *output, unsigned signal_len, double sample_rate, const char *message, int method)
Encode a secret message into a host audio signal.
void MD_mix(const double *a, const double *b, double *out, unsigned N, double w_a, double w_b)
Mix (weighted sum) two signals.
double MD_entropy(const double *a, unsigned N, bool clip)
Compute the normalized entropy of a distribution.
int MD_steg_detect(const double *signal, unsigned signal_len, double sample_rate, int *payload_type_out)
Detect which steganography method (if any) was used to encode a signal.
double MD_f0_autocorrelation(const double *signal, unsigned N, double sample_rate, double min_freq_hz, double max_freq_hz)
Estimate the fundamental frequency (F0) using autocorrelation.
double MD_sinc(double x)
Normalized sinc function: .
void MD_lowpass_brickwall(double *signal, unsigned len, double cutoff_hz, double sample_rate)
Apply a brickwall lowpass filter to a signal in-place.
void MD_fir_filter(const double *signal, unsigned signal_len, const double *coeffs, unsigned num_taps, double *out)
Apply a causal FIR filter with arbitrary coefficients.
Definition minidsp_fir.c:68
void MD_shutdown(void)
Free all internally cached FFT plans and buffers.
double MD_power_db(const double *a, unsigned N)
Compute signal power in decibels: 10 * log10(power).
void MD_gcc(const double *siga, const double *sigb, unsigned N, double *lagvals, int weightfunc)
Compute the full generalized cross-correlation between two signals.
void MD_convolution_time(const double *signal, unsigned signal_len, const double *kernel, unsigned kernel_len, double *out)
Time-domain full linear convolution (direct sum-of-products).
Definition minidsp_fir.c:25
void MD_set_error_handler(MD_ErrorHandler handler)
Install a custom error handler.
void MD_get_multiple_delays(const double **sigs, unsigned M, unsigned N, unsigned margin, int weightfunc, int *outdelays)
Estimate delays between a reference signal and M-1 other signals.
void MD_delay_echo(const double *in, double *out, unsigned N, unsigned delay_samples, double feedback, double dry, double wet)
Delay line / echo effect using a circular buffer with feedback.
double MD_dot(const double *a, const double *b, unsigned N)
Compute the dot product of two vectors.
void MD_Gen_Rect_Win(double *out, unsigned n)
Generate a rectangular window of length n (all ones).
void MD_sawtooth_wave(double *output, unsigned N, double amplitude, double freq, double sample_rate)
Generate a sawtooth wave.
void MD_moving_average(const double *signal, unsigned signal_len, unsigned window_len, double *out)
Causal moving-average FIR filter with zero-padded startup.
Definition minidsp_fir.c:48
void MD_magnitude_spectrum(const double *signal, unsigned N, double *mag_out)
Compute the magnitude spectrum of a real-valued signal.
void MD_mel_filterbank(unsigned N, double sample_rate, unsigned num_mels, double min_freq_hz, double max_freq_hz, double *filterbank_out)
Build a mel-spaced triangular filterbank matrix.
void MD_comb_reverb(const double *in, double *out, unsigned N, unsigned delay_samples, double feedback, double dry, double wet)
Comb-filter reverb (feedback comb filter with dry/wet mix).
void MD_vad_calibrate(MD_vad_state *state, const double *signal, unsigned N, double sample_rate)
Feed a known-silence frame to seed the adaptive normalization.
void MD_autocorrelation(const double *a, unsigned N, double *out, unsigned max_lag)
Compute the normalised autocorrelation of a signal.
unsigned MD_stft_num_frames(unsigned signal_len, unsigned N, unsigned hop)
Compute the number of STFT frames for the given signal length and parameters.
void MD_fit_within_range(double *in, double *out, unsigned N, double newmin, double newmax)
Fit values within [newmin, newmax].
void MD_vad_init(MD_vad_state *state, const MD_vad_params *params)
Initialize VAD state from params.
double MD_rms(const double *a, unsigned N)
Compute the root mean square (RMS) of a signal.
void MD_square_wave(double *output, unsigned N, double amplitude, double freq, double sample_rate)
Generate a square wave.
int MD_get_delay(const double *siga, const double *sigb, unsigned N, double *ent, unsigned margin, int weightfunc)
Estimate the delay between two signals.
void MD_adjust_dblevel(const double *in, double *out, unsigned N, double dblevel)
Automatic Gain Control: scale a signal so its power matches the requested dB level,...
void MD_chirp_log(double *output, unsigned N, double amplitude, double f_start, double f_end, double sample_rate)
Generate a logarithmic chirp (swept sine with exponentially increasing frequency).
A single detected DTMF tone with timing information.
Definition minidsp.h:1328
char digit
Decoded digit: '0'–'9', 'A'–'D', '*', or '#'.
Definition minidsp.h:1329
double end_s
Tone offset time in seconds.
Definition minidsp.h:1331
double start_s
Tone onset time in seconds.
Definition minidsp.h:1330
Parameters for the VAD detector.
Definition minidsp.h:1803
double threshold
Decision threshold (0.0–1.0).
Definition minidsp.h:1805
double weights[MD_VAD_NUM_FEATURES]
Per-feature weights for scoring.
Definition minidsp.h:1804
double band_high_hz
Upper bound of speech band (Hz).
Definition minidsp.h:1810
unsigned onset_frames
Consecutive above-threshold frames before speech.
Definition minidsp.h:1806
double band_low_hz
Lower bound of speech band (Hz).
Definition minidsp.h:1809
double adaptation_rate
EMA rate for min/max tracking (0.0–1.0).
Definition minidsp.h:1808
unsigned hangover_frames
Extra speech frames after score drops.
Definition minidsp.h:1807
Internal state for the VAD detector.
Definition minidsp.h:1819
unsigned onset_counter
Consecutive above-threshold count.
Definition minidsp.h:1823
double feat_max[MD_VAD_NUM_FEATURES]
EMA-tracked feature maximums.
Definition minidsp.h:1822
MD_vad_params params
Copy of caller params.
Definition minidsp.h:1820
int current_decision
Current speech decision (0 or 1).
Definition minidsp.h:1825
double feat_min[MD_VAD_NUM_FEATURES]
EMA-tracked feature minimums.
Definition minidsp.h:1821
unsigned hangover_counter
Remaining hangover frames.
Definition minidsp.h:1824
unsigned frames_processed
Total frames seen.
Definition minidsp.h:1826