NAP
Public Member Functions | List of all members
PlaybackComponentInstance Class Reference

#include <audio/component/playbackcomponent.h>

Public Member Functions

 PlaybackComponentInstance (EntityInstance &entity, Component &resource)
 
bool init (utility::ErrorState &errorState) override
 
void update (double deltaTime) override
 
int getChannelCount () const override
 
OutputPingetOutputForChannel (int channel) override
 
void start (TimeValue startPosition=0, TimeValue duration=0)
 
void stop ()
 
void setGain (ControllerValue gain)
 
void setChannelGain (int channel, ControllerValue gain)
 
void setStereoPanning (ControllerValue panning)
 
void setFadeInTime (TimeValue time)
 
void setFadeOutTime (TimeValue time)
 
void setPitch (ControllerValue pitch)
 
bool isStereo () const
 
bool isPlaying () const
 
ControllerValue getGain () const
 
ControllerValue getStereoPanning () const
 
ControllerValue getFadeInTime () const
 
ControllerValue getFadeOutTime () const
 
ControllerValue getPitch () const
 
TimeValue getCurrentPlayingTime () const
 
- Public Member Functions inherited from AudioComponentBaseInstance
 AudioComponentBaseInstance (EntityInstance &entity, Component &resource)
 
- Public Member Functions inherited from ComponentInstance
 ComponentInstance (EntityInstance &entity, Component &resource)
 
nap::EntityInstancegetEntityInstance () const
 
nap::ComponentgetComponent () const
 
template<typename T >
T * getComponent () const
 
virtual bool init (utility::ErrorState &errorState)
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 
- Public Member Functions inherited from IMultiChannelOutput
virtual ~IMultiChannelOutput ()=default
 
OutputPintryGetOutputForChannel (unsigned int)
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 
- Protected Member Functions inherited from AudioComponentBaseInstance
NodeManagergetNodeManager ()
 
AudioServicegetAudioService ()
 

Description

Instance of PlaybackComponent. Plays back audio from a nap::audio::AudioBufferResource. Playback can be started on initialization using the AutoPlay property or using the start() method, and is stopped using the stop() method or by specifying the "Duration" property. The component has to be used in combination with an nap::audio::OutputComponent to send the playback to DAC.

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

Constructor & Destructor Documentation

◆ PlaybackComponentInstance()

PlaybackComponentInstance ( EntityInstance entity,
Component resource 
)

Member Function Documentation

◆ getChannelCount()

int getChannelCount ( ) const
overridevirtual

Override this method to specify the number of audio channels output by this object.

Returns
the number of channels this object outputs.

Implements IMultiChannelOutput.

◆ getCurrentPlayingTime()

TimeValue getCurrentPlayingTime ( ) const
Returns
the amount of time the sequencer has been playing since the last call to play().

◆ getFadeInTime()

ControllerValue getFadeInTime ( ) const
Returns
the fade in time in milliseconds used when starting playback

◆ getFadeOutTime()

ControllerValue getFadeOutTime ( ) const
Returns
the fade out time in milliseconds used when stopping playback

◆ getGain()

ControllerValue getGain ( ) const
Returns
the current gain value

◆ getOutputForChannel()

OutputPin* getOutputForChannel ( int  channel)
overridevirtual

To be overridden by descendants.

Parameters
channelchannel index to request the output for
Returns
the output pin that outputs audio data for the specified channel.

Implements IMultiChannelOutput.

◆ getPitch()

ControllerValue getPitch ( ) const
Returns
the pitch as a fraction of the original pitch of the audio material in the buffer.

◆ getStereoPanning()

ControllerValue getStereoPanning ( ) const
Returns
the current stereo panning.

◆ init()

bool init ( utility::ErrorState errorState)
overridevirtual

Initializes this component based on it's resource.

Parameters
errorStatecontains the error when initialization fails.
Returns
if initialization succeeded.

Reimplemented from ComponentInstance.

◆ isPlaying()

bool isPlaying ( ) const
Returns
true when the component is currently playing back audio.

◆ isStereo()

bool isStereo ( ) const
Returns
Tells wether the playback is stereo and consists of two channels of audio.

◆ setChannelGain()

void setChannelGain ( int  channel,
ControllerValue  gain 
)

Sets the gain for a single channel relative to the overall gain. Use this for manual panning with for example non-stereo channel setups.

◆ setFadeInTime()

void setFadeInTime ( TimeValue  time)

Sets the fade in time used in milliseconds when starting playback.

◆ setFadeOutTime()

void setFadeOutTime ( TimeValue  time)

Sets the fade out time used in milliseconds when stopping playback.

◆ setGain()

void setGain ( ControllerValue  gain)

Sets the overall gain of playback.

◆ setPitch()

void setPitch ( ControllerValue  pitch)

Sets the pitch as a fraction of the original pitch of the audio material in the buffer.

◆ setStereoPanning()

void setStereoPanning ( ControllerValue  panning)

Sets the panning for stereo playback: 0 means far left, 0.5 means center and 1.0 means far right. Only applies when there are 2 channels of playback.

◆ start()

void start ( TimeValue  startPosition = 0,
TimeValue  duration = 0 
)
Parameters
startPositionthe start position in the buffer in milliseconds
durationthe total duration of playback in milliseconds. 0 means play untill the end of the buffer

◆ stop()

void stop ( )

Fade out over fade out time and stop playback.

◆ update()

void update ( double  deltaTime)
overridevirtual

Update this component

Parameters
deltaTimethe time in between cooks in seconds

Reimplemented from ComponentInstance.