vsdk  7.1.1
Vsdk::Audio::Producer::File

Reads a 16-bit Little-Endian PCM audio file and sends its bytes up a Pipeline. More...

Inheritance diagram for Vsdk::Audio::Producer::File:
Vsdk::Audio::ProducerModuleImpl< File > Vsdk::Audio::ProducerModule

Public Member Functions

 File (std::string path)
 Constructs a default audio file reader. More...
 
 File (std::string path, int sampleRate, int channelCount, std::size_t bufferSize)
 
bool open () override
 
bool run () override
 
bool close () override
 
void setFilePath (std::string path)
 
void setSampleRate (int sampleRate)
 
void setChannelCount (int channelCount)
 
void setBufferSize (std::size_t bufferSize)
 
void setRealTimeStreamingEnabled (bool enabled)
 Enables real time streaming of the file at a rate of sample rate × channel count bytes per second. More...
 
void setAccelerationRate (double rate)
 Sets acceleration rate. Cannot be less than 1.0. More...
 
- Public Member Functions inherited from Vsdk::Audio::ProducerModule
virtual ~ProducerModule ()=0
 
auto subscribeFirst (AudioCallback c) -> Iterator
 Subscribes as first in the list of audio buffer receivers for this producer. More...
 
auto subscribeLast (AudioCallback c) -> Iterator
 Subscribes as last in the list of audio buffer receivers for this producer. More...
 
void unsubscribe (Iterator it)
 Unsubscribes from this producer audio buffer dispatch list. More...
 
virtual bool start ()
 
virtual bool stop ()
 
virtual bool resume ()
 Non-blocking call. More...
 
auto lastError () const -> std::string const &
 

Additional Inherited Members

- Public Types inherited from Vsdk::Audio::ProducerModule
using Iterator = details::Iterator< decltype(_subscribers)>
 Iterator pointing to a subscriber of this producer. More...
 
- Static Public Member Functions inherited from Vsdk::Audio::ProducerModuleImpl< File >
static auto make (Args &&... args) -> std::shared_ptr< File >
 
- Protected Member Functions inherited from Vsdk::Audio::ProducerModuleImpl< File >
 ProducerModuleImpl ()=default
 
- Protected Member Functions inherited from Vsdk::Audio::ProducerModule
 ProducerModule ()=default
 
template<typename... Args>
void setLastError (char const *fmt, Args &&... args)
 
void setLastError (std::string error)
 
void dispatchBuffer (Buffer buffer, bool last)
 
template<typename T >
void dispatchAudio (T &&data, int sampleRate, int channelCount, bool isLast)
 

Detailed Description

Reads a 16-bit Little-Endian PCM audio file and sends its bytes up a Pipeline.

Constructor & Destructor Documentation

◆ File() [1/2]

File::File ( std::string  path)
explicit

Constructs a default audio file reader.

Sets:

  • sample rate to 16kHz,
  • channel count to 1
  • buffer size to 2048
  • real time streaming is disabled

◆ File() [2/2]

File::File ( std::string  path,
int  sampleRate,
int  channelCount,
std::size_t  bufferSize 
)
explicit
Parameters
bufferSize0 means reading the whole file in one go

Member Function Documentation

◆ open()

bool File::open ( )
overridevirtual
Note
Does nothing by default to support devices like buffers.

Reimplemented from Vsdk::Audio::ProducerModule.

◆ run()

bool File::run ( )
overridevirtual
Note
Blocking call
Warning
Do not override if you do not support synchronous operations!

Reimplemented from Vsdk::Audio::ProducerModule.

◆ close()

bool File::close ( )
overridevirtual
Note
Does nothing by default to support devices like buffers.

Reimplemented from Vsdk::Audio::ProducerModule.

◆ setFilePath()

void File::setFilePath ( std::string  path)
Exceptions
Vsdk::Exceptionif producer is open and has not been closed yet or if path is not a valid file path

◆ setSampleRate()

void File::setSampleRate ( int  sampleRate)
Exceptions
Vsdk::Exceptionif producer is open and has not been closed yet or if sampleRate value is invalid

◆ setChannelCount()

void File::setChannelCount ( int  channelCount)
Exceptions
Vsdk::Exceptionif producer is open ans has not been closed yet or if channelCount value is invalid

◆ setBufferSize()

void File::setBufferSize ( std::size_t  bufferSize)
Parameters
bufferSizeZero means reading the whole file in one buffer (beware)
Exceptions
Vsdk::Exceptionif producer is open ans has not been closed yet or if channelCount value is invalid

◆ setRealTimeStreamingEnabled()

void File::setRealTimeStreamingEnabled ( bool  enabled)

Enables real time streaming of the file at a rate of sample rate × channel count bytes per second.

Warning
Streaming is made synchronously during the call to run()!

◆ setAccelerationRate()

void File::setAccelerationRate ( double  rate)

Sets acceleration rate. Cannot be less than 1.0.