arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
audio_tools::AudioPlayer Class Reference

Implements a simple audio player which supports the following commands: More...

#include <AudioPlayer.h>

Inheritance diagram for audio_tools::AudioPlayer:
audio_tools::AudioBaseInfoDependent

Public Member Functions

 AudioPlayer (AudioPlayer const &)=delete
 
 AudioPlayer (AudioSource &source, AudioPrint &output, AudioDecoder &decoder)
 Construct a new Audio Player object. The processing chain is AudioSource -> Stream -copy> EncodedAudioStream -> VolumeOutput -> Print. More...
 
 AudioPlayer (AudioSource &source, AudioStream &output, AudioDecoder &decoder)
 Construct a new Audio Player object. The processing chain is AudioSource -> Stream -copy> EncodedAudioStream -> VolumeOutput -> Print. More...
 
 AudioPlayer (AudioSource &source, Print &output, AudioDecoder &decoder, AudioBaseInfoDependent *notify=nullptr)
 Construct a new Audio Player object. The processing chain is AudioSource -> Stream -copy> EncodedAudioStream -> VolumeOutput -> Print. More...
 
virtual ~AudioPlayer ()
 Default destructor.
 
virtual AudioBaseInfo audioInfo () override
 
virtual bool begin (int index=0, bool isActive=true)
 (Re)Starts the playing of the music (from the beginning)
 
virtual void copy ()
 Call this method in the loop.
 
virtual void end ()
 
virtual bool isActive ()
 determines if the player is active
 
virtual bool next (int offset=1)
 moves to next file
 
 operator bool ()
 determines if the player is active
 
AudioPlayeroperator= (AudioPlayer const &)=delete
 
virtual void play ()
 starts / resumes the playing of a matching song
 
virtual bool previous (int offset=1)
 moves to previous file
 
virtual void setAudioInfo (AudioBaseInfo info)
 Updates the audio info in the related objects. More...
 
void setAudioSource (AudioSource &source)
 (Re)defines the audio source
 
virtual void setAutoNext (bool next)
 Set move to next.
 
void setDecoder (AudioDecoder &decoder)
 (Re)defines the decoder
 
virtual bool setIndex (int idx)
 moves to selected file
 
virtual void setMetadataCallback (void(*callback)(MetaDataType type, const char *str, int len), ID3TypeSelection sel=SELECT_ID3)
 Defines the medatadata callback.
 
void setNotify (AudioBaseInfoDependent *notify)
 (Re)defines the notify
 
void setOutput (Print &output)
 (Re)defines the output
 
virtual bool setPath (const char *path)
 moves to selected file
 
virtual bool setStream (Stream *input)
 start selected input stream
 
virtual void setVolume (float volume)
 sets the volume - values need to be between 0.0 and 1.0
 
virtual void setVolumeControl (VolumeControl &vc)
 Change the VolumeControl implementation.
 
virtual void stop ()
 halts the playing
 
virtual float volume ()
 Determines the actual volume.
 
- Public Member Functions inherited from audio_tools::AudioBaseInfoDependent
virtual AudioBaseInfo audioInfo ()=0
 
virtual void setAudioInfo (AudioBaseInfo info)=0
 
virtual bool validate (AudioBaseInfo &info)
 

Protected Member Functions

 AudioPlayer ()
 Default constructur only allowed in subclasses.
 

Static Protected Member Functions

static void decodeMetaData (void *obj, void *data, size_t len)
 Callback implementation which writes to metadata.
 

Protected Attributes

bool active = false
 
bool autonext = false
 
StreamCopy copier
 
float current_volume = -1.0
 
bool meta_active = false
 
MetaDataID3 meta_out
 
AudioDecoderp_decoder = nullptr
 
AudioBaseInfoDependentp_final_notify = nullptr
 
AudioPrintp_final_print = nullptr
 
AudioStreamp_final_stream = nullptr
 
Streamp_input_stream = nullptr
 
EncodedAudioStreamp_out_decoding = nullptr
 
AudioSourcep_source = nullptr
 
bool previous_stream = false
 
uint32_t timeout = 0
 
VolumeStream volume_out
 

Detailed Description

Implements a simple audio player which supports the following commands:

Constructor & Destructor Documentation

◆ AudioPlayer() [1/3]

audio_tools::AudioPlayer::AudioPlayer ( AudioSource source,
AudioPrint output,
AudioDecoder decoder 
)
inline

Construct a new Audio Player object. The processing chain is AudioSource -> Stream -copy> EncodedAudioStream -> VolumeOutput -> Print.

Parameters
source
output
decoder

◆ AudioPlayer() [2/3]

audio_tools::AudioPlayer::AudioPlayer ( AudioSource source,
Print output,
AudioDecoder decoder,
AudioBaseInfoDependent notify = nullptr 
)
inline

Construct a new Audio Player object. The processing chain is AudioSource -> Stream -copy> EncodedAudioStream -> VolumeOutput -> Print.

Parameters
source
output
decoder
notify

◆ AudioPlayer() [3/3]

audio_tools::AudioPlayer::AudioPlayer ( AudioSource source,
AudioStream output,
AudioDecoder decoder 
)
inline

Construct a new Audio Player object. The processing chain is AudioSource -> Stream -copy> EncodedAudioStream -> VolumeOutput -> Print.

Parameters
source
output
decoder

Member Function Documentation

◆ audioInfo()

virtual AudioBaseInfo audio_tools::AudioPlayer::audioInfo ( )
inlineoverridevirtual

◆ setAudioInfo()

virtual void audio_tools::AudioPlayer::setAudioInfo ( AudioBaseInfo  info)
inlinevirtual

Updates the audio info in the related objects.

Implements audio_tools::AudioBaseInfoDependent.


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