vsdk 8.1.0
 
Loading...
Searching...
No Matches
Vsdk::Audio::Producer::File

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

#include <File.hpp>

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.
 
 File (std::string path, int sampleRate, int channelCount, std::size_t bufferSize)
 
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.
 
void setAccelerationRate (double rate)
 Sets acceleration rate. Cannot be less than 1.0.
 
- Public Member Functions inherited from Vsdk::Audio::ProducerModuleImpl< File >
 ProducerModuleImpl ()=default
 
- Public Member Functions inherited from Vsdk::Audio::ProducerModule
 ProducerModule ()
 
 ProducerModule (ProducerModule &&)
 
ProducerModuleoperator= (ProducerModule &&)
 
virtual ~ProducerModule ()=0
 
 ProducerModule (ProducerModule const &)=delete
 
ProducerModuleoperator= (ProducerModule const &)=delete
 
auto subscribeFirst (AudioCallback c) -> Iterator
 Subscribes as first in the list of audio buffer receivers for this producer.
 
auto subscribeLast (AudioCallback c) -> Iterator
 Subscribes as last in the list of audio buffer receivers for this producer.
 
void unsubscribe (Iterator it) noexcept
 Unsubscribes from this producer audio buffer dispatch list.
 
auto lastError () const -> std::string
 
auto state () const -> State
 
bool isOpened () const
 
bool isRunning () const
 
bool isStarted () const
 
bool isPaused () const
 
bool isIdle () const
 
bool isClosed () const
 
bool open () noexcept
 Attempts to open the underlying resource(s) of the producer.
 
bool run () noexcept
 
bool start () noexcept
 
bool pause () noexcept
 Attempts to pause a started producer.
 
bool resume () noexcept
 Attempts to resume a paused producer.
 
bool stop () noexcept
 Attempts to stop a started producer.
 
bool close () noexcept
 

Protected Member Functions

void openImpl () override
 
void runImpl () override
 
void closeImpl () override
 
- Protected Member Functions inherited from Vsdk::Audio::ProducerModule
virtual void openImpl ()
 
virtual void runImpl ()
 
virtual void startImpl ()
 
virtual void pauseImpl ()
 
virtual void resumeImpl ()
 
virtual void stopImpl ()
 
virtual void closeImpl ()
 
void dispatchBuffer (Buffer buffer, bool last)
 
template<typename T >
void dispatchAudio (T &&data, int sampleRate, int channelCount, bool isLast)
 

Additional Inherited Members

- Public Types inherited from Vsdk::Audio::ProducerModule
enum class  State {
  Closed , Opened , Running , Started ,
  Paused , Idle
}
 
using Iterator = details::Iterator< decltype(_subscribers)>
 Iterator pointing to a subscriber of this producer.
 
- Static Public Member Functions inherited from Vsdk::Audio::ProducerModuleImpl< File >
static auto make (Args &&... args) -> std::shared_ptr< File >
 
- Protected Attributes inherited from Vsdk::Audio::ProducerModule
std::atomic< State_state
 

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

◆ setFilePath()

void File::setFilePath ( std::string  path)
Exceptions
Vsdk::Exceptionif producer is opened or if path is not a valid file path

◆ setSampleRate()

void File::setSampleRate ( int  sampleRate)
Exceptions
Vsdk::Exceptionif producer is opened 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 opened 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.

◆ openImpl()

void File::openImpl ( )
overrideprotectedvirtual

Reimplemented from Vsdk::Audio::ProducerModule.

◆ runImpl()

void File::runImpl ( )
overrideprotectedvirtual

Reimplemented from Vsdk::Audio::ProducerModule.

◆ closeImpl()

void File::closeImpl ( )
overrideprotectedvirtual

Reimplemented from Vsdk::Audio::ProducerModule.