Classified ads
Public Slots | Signals | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
AudioSource Class Reference

opposite of audiosink. More...

#include <audiosource.h>

Inheritance diagram for AudioSource:
Inheritance graph
[legend]
Collaboration diagram for AudioSource:
Collaboration graph
[legend]

Public Slots

void processCapturedAudio ()
 
void inputStatusChanged (QAudio::State aState)
 

Signals

void frameCaptured (const QByteArray &aFrame, quint32 aSeqNo, float aVolumeLevel)
 
void audioMaxLevel (float aMaxVolume)
 

Public Member Functions

 AudioSource (Model &aModel)
 
 ~AudioSource ()
 
quint32 getCurrentSeqNo () const
 
void stopCapturing ()
 

Protected Member Functions

virtual qint64 writeData (const char *data, qint64 maxSize)
 
virtual qint64 readData (char *data, qint64 maxSize)
 
virtual bool open (OpenMode mode)
 
virtual bool isSequential () const
 
void timerEvent (QTimerEvent *event)
 

Private Attributes

QAudioFormat iFormat
 
QAudioInput * iAudioInput
 
QByteArray iAudioBuffer
 
quint32 iSeqNo
 
bool iNeedsToRun
 
ModeliModel
 
int iTimerId
 

Detailed Description

opposite of audiosink.

Class for capturing audio. This class provides 16-bit PCM digital audio in 8kHz sample rate in pieces of 480 samples, each exactly 60ms long. Output format is in floating point numbers in range [0,1].

Constructor & Destructor Documentation

◆ AudioSource()

AudioSource::AudioSource ( Model aModel)

Constructor.

◆ ~AudioSource()

AudioSource::~AudioSource ( )

Member Function Documentation

◆ audioMaxLevel

void AudioSource::audioMaxLevel ( float  aMaxVolume)
signal

This is actually average audio volume, in range [0,1]

◆ frameCaptured

void AudioSource::frameCaptured ( const QByteArray &  aFrame,
quint32  aSeqNo,
float  aVolumeLevel 
)
signal

Emitted when complete audio frame is ready to be processed

Parameters
aFrameis the audio data. Content of the byte array is floats in range [-1,1]
aSeqNosequence number of the captured frame, it will sequentially increase as time passes
aVolumeLevelcalculated average volume level of frame ; will be used by audio mixer

◆ getCurrentSeqNo()

quint32 AudioSource::getCurrentSeqNo ( ) const
inline

getter-method for next sequence number

◆ inputStatusChanged

void AudioSource::inputStatusChanged ( QAudio::State  aState)
slot

Input status changed

◆ isSequential()

virtual bool AudioSource::isSequential ( ) const
inlineprotectedvirtual

◆ open()

virtual bool AudioSource::open ( OpenMode  mode)
protectedvirtual

method for opening QIODevice: sets the open mode that's about it.

◆ processCapturedAudio

void AudioSource::processCapturedAudio ( )
slot

Method called by timer every now and then that does processing of captured data

◆ readData()

virtual qint64 AudioSource::readData ( char *  data,
qint64  maxSize 
)
protectedvirtual

From QIODevice: in current implementation this method does nothing, audio is processed internally and this QIODevice implementation does not allow reading.

Returns
0 always

◆ stopCapturing()

void AudioSource::stopCapturing ( )

method for stopping capture

◆ timerEvent()

void AudioSource::timerEvent ( QTimerEvent *  event)
protected

From QObject. Used for forwarding audio from buffer.

◆ writeData()

virtual qint64 AudioSource::writeData ( const char *  data,
qint64  maxSize 
)
protectedvirtual

From QIODevice: method where audio data will be written from actual audio source: this class AudioSource inherits QIODevice and will offer itself as data sink of iAudioInput

Parameters
dataaudio data
maxSizemax data size to be written
Returns
number of bytes actually written

Member Data Documentation

◆ iAudioBuffer

QByteArray AudioSource::iAudioBuffer
private

◆ iAudioInput

QAudioInput* AudioSource::iAudioInput
private

◆ iFormat

QAudioFormat AudioSource::iFormat
private

◆ iModel

Model& AudioSource::iModel
private

◆ iNeedsToRun

bool AudioSource::iNeedsToRun
private

◆ iSeqNo

quint32 AudioSource::iSeqNo
private

◆ iTimerId

int AudioSource::iTimerId
private

The documentation for this class was generated from the following file: