Async  0.18.0
Public Types | Public Member Functions | List of all members
Async::AudioRecorder Class Reference

A class for recording raw audio to a file. More...

#include <AsyncAudioRecorder.h>

Inheritance diagram for Async::AudioRecorder:
Async::AudioSink

Public Types

enum  Format { FMT_AUTO, FMT_RAW, FMT_WAV }
 

Public Member Functions

 AudioRecorder (const std::string &filename, AudioRecorder::Format fmt=FMT_AUTO, int sample_rate=INTERNAL_SAMPLE_RATE)
 Default constuctor. More...
 
 ~AudioRecorder (void)
 Destructor. More...
 
bool initialize (void)
 Initialize the recorder. More...
 
void setMaxRecordingTime (unsigned time_ms)
 Set the maximum length of this recording. More...
 
virtual int writeSamples (const float *samples, int count)
 Write samples into this audio sink. More...
 
virtual void flushSamples (void)
 Tell the sink to flush the previously written samples. More...
 
- Public Member Functions inherited from Async::AudioSink
 AudioSink (void)
 Default constuctor. More...
 
virtual ~AudioSink (void)
 Destructor. More...
 
bool registerSource (AudioSource *source)
 Register an audio source to provide samples to this sink. More...
 
void unregisterSource (void)
 Unregister the previously registered audio source. More...
 
bool isRegistered (void) const
 Check if an audio source has been registered. More...
 
AudioSourcesource (void) const
 Get the registered audio source. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Async::AudioSink
void sourceResumeOutput (void)
 Tell the source that we are ready to accept more samples. More...
 
void sourceAllSamplesFlushed (void)
 Tell the source that all samples have been flushed. More...
 
bool setHandler (AudioSink *handler)
 Setup another sink to handle the incoming audio. More...
 
void clearHandler (void)
 Clear a handler that was previously setup with setHandler. More...
 
AudioSinkhandler (void) const
 

Detailed Description

A class for recording raw audio to a file.

Author
Tobias Blomberg / SM0SVX
Date
2005-08-29

Use this class to stream audio into a file. The audio is stored in raw format, only samples no header.

Definition at line 118 of file AsyncAudioRecorder.h.

Member Enumeration Documentation

Enumerator
FMT_AUTO 
FMT_RAW 
FMT_WAV 

Definition at line 121 of file AsyncAudioRecorder.h.

Constructor & Destructor Documentation

Async::AudioRecorder::AudioRecorder ( const std::string &  filename,
AudioRecorder::Format  fmt = FMT_AUTO,
int  sample_rate = INTERNAL_SAMPLE_RATE 
)
explicit

Default constuctor.

Parameters
filenameThe name of the file to record audio to
fmtThe file format (
See Also
Format)
Parameters
sample_rateThe sample rate (defaults to INTERNAL_SAMPLE_RATE)
Async::AudioRecorder::~AudioRecorder ( void  )

Destructor.

Member Function Documentation

virtual void Async::AudioRecorder::flushSamples ( void  )
virtual

Tell the sink to flush the previously written samples.

This function is used to tell the sink to flush previously written samples. When done flushing, the sink should call the sourceAllSamplesFlushed function. This function is normally only called from a connected source object.

Reimplemented from Async::AudioSink.

bool Async::AudioRecorder::initialize ( void  )

Initialize the recorder.

Returns
Return true if the initialization was successful
void Async::AudioRecorder::setMaxRecordingTime ( unsigned  time_ms)

Set the maximum length of this recording.

Parameters
time_msThe maximum time in milliseconds

Use this function to set the maximum time for a recording. When the limit has been reached, any incoming samples will be thrown away. The sampling rate given in the constructor call is used to calculate the time. Setting the time to 0 will allow the file to grow indefinetly.

virtual int Async::AudioRecorder::writeSamples ( const float *  samples,
int  count 
)
virtual

Write samples into this audio sink.

Parameters
samplesThe buffer containing the samples
countThe number of samples in the buffer
Returns
Returns the number of samples that has been taken care of

This function is used to write audio into this audio sink. If it returns 0, no more samples should be written until the resumeOutput function in the source have been called. This function is normally only called from a connected source object.

Reimplemented from Async::AudioSink.


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