NAP
Public Member Functions | List of all members
AudioService Class Referencefinal

#include <audio/service/audioservice.h>

Public Member Functions

 AudioService (ServiceConfiguration *configuration)
 
 ~AudioService ()=default
 
bool init (nap::utility::ErrorState &errorState) override
 
void shutdown () override
 
NodeManagergetNodeManager ()
 
void onAudioCallback (float **inputBuffer, float **outputBuffer, unsigned long framesPerBuffer)
 
void enqueueTask (TaskQueue::Task task)
 
- Public Member Functions inherited from Service
UNPREFIXED_MODULE_NAME_INPUTCASE Service (ServiceConfiguration *configuration)
 
virtual void getDependentServices (std::vector< rtti::TypeInfo > &dependencies) override
 
virtual void update (double deltaTime) override
 
 Service (ServiceConfiguration *configuration)
 
virtual ~Service ()
 
CoregetCore ()
 
const CoregetCore () const
 
std::string getTypeName () const
 
const ModulegetModule () const
 
 Service (Service &)=delete
 
Serviceoperator= (const Service &)=delete
 
 Service (Service &&)=delete
 
Serviceoperator= (Service &&)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from Service
virtual void registerObjectCreators (rtti::Factory &factory)
 
virtual void getDependentServices (std::vector< rtti::TypeInfo > &dependencies)
 
virtual void created ()
 
virtual void preUpdate (double deltaTime)
 
virtual void update (double deltaTime)
 
virtual void postUpdate (double deltaTime)
 
virtual void preShutdown ()
 
virtual void preResourcesLoaded ()
 
virtual void postResourcesLoaded ()
 
template<typename SERVICE_CONFIG >
SERVICE_CONFIG * getConfiguration ()
 
template<typename SERVICE_CONFIG >
const SERVICE_CONFIG * getConfiguration () const
 
std::string getIniFilePath () const
 
std::string getIniFilePath (const std::string &appendix) const
 

Description

Service that provides audio input and output processing directly for hardware audio devices. Provides static methods to poll the current system for available audio devices using portaudio.

Inheritance diagram for AudioService:
[legend]
Collaboration diagram for AudioService:
[legend]

Constructor & Destructor Documentation

◆ AudioService()

AudioService ( ServiceConfiguration configuration)

◆ ~AudioService()

~AudioService ( )
default

Member Function Documentation

◆ enqueueTask()

void enqueueTask ( TaskQueue::Task  task)

Enqueue a task to be executed within the process() method for thread safety

◆ getNodeManager()

NodeManager& getNodeManager ( )
Returns
the audio node manager owned by the audio service. The node manager contains a node system that performs all the DSP.

◆ init()

bool init ( nap::utility::ErrorState errorState)
overridevirtual

Initializes portaudio.

Reimplemented from Service.

◆ onAudioCallback()

void onAudioCallback ( float **  inputBuffer,
float **  outputBuffer,
unsigned long  framesPerBuffer 
)

This function is typically called by a hardware callback from the device to perform all the audio processing. It performs memory management and processes a lockfree event queue before it invokes the NodeManager::process() to process audio.

Parameters
inputBufferan array of float arrays, representing one sample buffer for every channel
outputBufferan array of float arrays, representing one sample buffer for every channel
framesPerBufferthe number of samples that has to be processed per channel

◆ shutdown()

void shutdown ( )
overridevirtual

Called on shutdown of the service. Closes portaudio stream and shuts down portaudio.

Reimplemented from Service.