Audio

Audio — Library for audio-related tests

Functions

Types and Values

struct audio_signal

Includes

#include <igt_audio.h>

Description

This library contains helpers for audio-related tests. More specifically, it allows generating additions of sine signals as well as detecting them.

Functions

audio_signal_init ()

struct audio_signal *
audio_signal_init (int channels,
                   int sampling_rate);

Allocate and initialize an audio signal structure with the given parameters.

Parameters

channels

The number of channels to use for the signal

 

sampling_rate

The sampling rate to use for the signal

 

Returns

A newly-allocated audio signal structure


audio_signal_add_frequency ()

int
audio_signal_add_frequency (struct audio_signal *signal,
                            int frequency);

Add a frequency to the signal.

Parameters

signal

The target signal structure

 

frequency

The frequency to add to the signal

 

Returns

An integer equal to zero for success and negative for failure


audio_signal_synthesize ()

void
audio_signal_synthesize (struct audio_signal *signal);

Free the resources allocated by audio_signal_synthesize and remove the previously-added frequencies.

Parameters

signal

The target signal structure

 

audio_signal_clean ()

void
audio_signal_clean (struct audio_signal *signal);

audio_signal_fill ()

void
audio_signal_fill (struct audio_signal *signal,
                   short *buffer,
                   int frames);

Fill the requested number of frames to the target buffer with the audio signal data (in interleaved S16_LE format), at the requested sampling rate and number of channels.

Parameters

signal

The target signal structure

 

buffer

The target buffer to fill

 

frames

The number of frames to fill

 

audio_signal_detect ()

bool
audio_signal_detect (struct audio_signal *signal,
                     int channels,
                     int sampling_rate,
                     short *buffer,
                     int frames);

Detect that the frequencies specified in signal , and only those, are present in the input data. The input data's format is required to be S16_LE.

Parameters

signal

The target signal structure

 

channels

The input data's number of channels

 

sampling_rate

The input data's sampling rate

 

buffer

The input data's buffer

 

frames

The input data's number of frames

 

Returns

A boolean indicating whether the detection was successful

Types and Values

struct audio_signal

struct audio_signal;