LIDL Soundboard  1.9.0
A simple soundboard, yet better than EXP Soundboard forsenE
CustomPlayer Class Reference

The CustomPlayer class, inherits QObject to access signals and slots.*. More...

#include <CustomPlayer.h>

Inheritance diagram for CustomPlayer:
Inheritance graph
Collaboration diagram for CustomPlayer:
Collaboration graph

Public Slots

void PlayNext ()
 PlayNext PlayNext function is called whenever the shortcut, or play button, is pressed. More...
 
void Stop ()
 Stop all the channels of this player. More...
 

Signals

void ErrorPlaying (QString)
 ErrorPlaying Signal to tell the main UI (via the proxy set up in the SoundWrapper class) that an error happened playing the sound <sound name>=""> (will be displayed in status bar). More...
 
void NowPlaying (QString)
 NowPlaying Signal to tell the main UI (via the proxy set up in the SoundWrapper class) to display now playing sound <soundName> in the status bar. More...
 
void holdPTT (int duration)
 holdPTT Signal to tell the main UI (via the proxy set up in the SoundWrapper class) to hold ptt for the duration. More...
 

Public Member Functions

 CustomPlayer (QObject *parent=nullptr)
 CustomPlayer Default contructor, used by the default constructor of SoundWrapper. More...
 
 CustomPlayer (QVector< LIDL::SoundFile * > soundlist, LIDL::Playback playMode=LIDL::Playback::Singleton, QObject *parent=nullptr)
 CustomPlayer Overloaded constructor, doesn't serve any purpose at the moment. More...
 
void SetOutputDevice (int index)
 SetOutputDevice Sets the main output device of the player. More...
 
void SetVACDevice (int index)
 SetVACDevice Sets the VAC output device of the player. More...
 
int GetOutputDevice ()
 GetOutputDevice. More...
 
int GetVACDevice ()
 GetVACDevice. More...
 
void SetPlaylist (QVector< LIDL::SoundFile * > soundList)
 SetPlaylist Set the playlist of the CustomPlayer. More...
 
void SetPlaybackMode (LIDL::Playback playMode)
 SetPlaybackMode Sets the playback mode of the CustomPlayer. More...
 
 ~CustomPlayer ()
 Destructor. More...
 

Private Member Functions

double PlayAt (int index)
 PlayAt Will play the song at the specified index. More...
 
void resetShouldPlay ()
 resetShouldPlay will reset the _shouldPlay boolean to true; More...
 

Private Attributes

QVector< LIDL::SoundFile * > _soundList
 
LIDL::Playback _playMode
 
int _index
 
QVector< unsigned long > _mainChannel
 
QVector< unsigned long > _vacChannel
 
unsigned long _mainOutputDevice
 
unsigned long _VACOutputDevice
 
QTimer * _timerShouldPlay
 
QTimer * _timerSequentialAutoPlay
 
bool _shouldPlay
 

Detailed Description

The CustomPlayer class, inherits QObject to access signals and slots.*.

This player uses bass library as a backend to deal with audio streams. It also uses some bass extensions (namely bassflac.h) to deal with the flac format. It uses ssl protocol for streaming over https, so installer includes openssl dll to allow it.

Constructor & Destructor Documentation

◆ CustomPlayer() [1/2]

CustomPlayer::CustomPlayer ( QObject *  parent = nullptr)
explicit

CustomPlayer Default contructor, used by the default constructor of SoundWrapper.

Parameters
parentnullptr as usual.

References _index, _mainOutputDevice, _shouldPlay, _timerSequentialAutoPlay, _timerShouldPlay, _VACOutputDevice, PlayNext(), and resetShouldPlay().

Here is the call graph for this function:

◆ CustomPlayer() [2/2]

CustomPlayer::CustomPlayer ( QVector< LIDL::SoundFile * >  soundlist,
LIDL::Playback  playMode = LIDL::Playback::Singleton,
QObject *  parent = nullptr 
)

CustomPlayer Overloaded constructor, doesn't serve any purpose at the moment.

Will probably use it to add a "preview" sound button latter.

Parameters
soundlistThe soundlist, should only contain one file if used for preview
playModeDefault to singleton because if used to preview a sound, it will only contain ONE sound.
parentnullptr as usual.

References _index, _playMode, and _soundList.

◆ ~CustomPlayer()

CustomPlayer::~CustomPlayer ( )

Destructor.

References _soundList.

Member Function Documentation

◆ ErrorPlaying

void CustomPlayer::ErrorPlaying ( QString  )
signal

ErrorPlaying Signal to tell the main UI (via the proxy set up in the SoundWrapper class) that an error happened playing the sound <sound name>=""> (will be displayed in status bar).

Referenced by PlayNext(), and SoundWrapper::SoundWrapper().

Here is the caller graph for this function:

◆ GetOutputDevice()

int CustomPlayer::GetOutputDevice ( )

GetOutputDevice.

Returns
The index of the main output device.

References _mainOutputDevice.

Referenced by SoundWrapper::getMainDevice(), and SoundWrapper::SoundWrapper().

Here is the caller graph for this function:

◆ GetVACDevice()

int CustomPlayer::GetVACDevice ( )

GetVACDevice.

Returns
The index of the VAC output device.

References _VACOutputDevice.

Referenced by SoundWrapper::getVacDevice(), and SoundWrapper::SoundWrapper().

Here is the caller graph for this function:

◆ holdPTT

void CustomPlayer::holdPTT ( int  duration)
signal

holdPTT Signal to tell the main UI (via the proxy set up in the SoundWrapper class) to hold ptt for the duration.

Parameters
duration

Referenced by PlayAt(), and SoundWrapper::SoundWrapper().

Here is the caller graph for this function:

◆ NowPlaying

void CustomPlayer::NowPlaying ( QString  )
signal

NowPlaying Signal to tell the main UI (via the proxy set up in the SoundWrapper class) to display now playing sound <soundName> in the status bar.

Referenced by PlayNext(), and SoundWrapper::SoundWrapper().

Here is the caller graph for this function:

◆ PlayAt()

double CustomPlayer::PlayAt ( int  index)
private

PlayAt Will play the song at the specified index.

Will play the next sound in line (_soundlist.at(index) ) if and only if one of the output is valid.

If the file is remote, it will play it in streaming, so a few seconds to cache it are to be expected. Remote files will use a QThread to check on the channel state repeatedly until the status is playing, and then it will send the signal to auto-hold PTT. If the remote file is .ogg, the duration is somehow flawed by -1 second, so we manually add a second for ogg or flacs files.

If the file is local, it will just play it and won't use a QThread to start auto-holding push to talk since it is instantly played.

It will also starts a QTimer::singleShot to pop_front the arrays containing the channel indexes.

Parameters
index
Returns
The duration of the sound in seconds, account for ogg/flac glitch.

References _mainChannel, _mainOutputDevice, _soundList, _vacChannel, _VACOutputDevice, BASS_ATTRIB_VOL, BASS_ChannelBytes2Seconds(), BASS_ChannelGetLength(), BASS_ChannelIsActive(), BASS_ChannelPlay(), BASS_ChannelSetAttribute(), BASS_ChannelSetDevice(), BASS_ChannelSetFX(), BASS_FX_DX8_CHORUS, BASS_FX_DX8_COMPRESSOR, BASS_FX_DX8_DISTORTION, BASS_FX_DX8_ECHO, BASS_FX_DX8_FLANGER, BASS_FX_DX8_GARGLE, BASS_FXSetParameters(), BASS_Init(), BASS_POS_BYTE, BASS_STREAM_AUTOFREE, BASS_STREAM_PRESCAN, BASS_StreamCreateFile(), BASS_StreamCreateURL(), LIDL::CHORUS, LIDL::COMPRESSOR, LIDL::DISTORTION, LIDL::ECHO, LIDL::FLANGER, LIDL::GARGLE, and holdPTT().

Referenced by PlayNext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PlayNext

void CustomPlayer::PlayNext ( )
slot

PlayNext PlayNext function is called whenever the shortcut, or play button, is pressed.

It will either play the same sound over and over again (Singleton, Singleton Cancer) Or cycle through the files in the wrapper (Sequential, Sequential Auto)

References _index, _mainOutputDevice, _playMode, _shouldPlay, _soundList, _timerSequentialAutoPlay, _timerShouldPlay, _VACOutputDevice, LIDL::Auto, LIDL::AutoLoop, LIDL::Cancer, ErrorPlaying(), NowPlaying(), PlayAt(), LIDL::Sequential, and LIDL::Singleton.

Referenced by CustomPlayer(), and SoundWrapper::Play().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetShouldPlay()

void CustomPlayer::resetShouldPlay ( )
private

resetShouldPlay will reset the _shouldPlay boolean to true;

It will stop all the timers and allows playing sounds again. (The _shouldPlay boolean isn't used if the playback mode is Singleton Cancer).

References _shouldPlay, and _timerShouldPlay.

Referenced by CustomPlayer(), and Stop().

Here is the caller graph for this function:

◆ SetOutputDevice()

void CustomPlayer::SetOutputDevice ( int  index)

SetOutputDevice Sets the main output device of the player.

Parameters
indexDevice index.

References _mainOutputDevice.

Referenced by SoundWrapper::OutputDeviceChanged(), and SoundWrapper::setPlayerMainOutput().

Here is the caller graph for this function:

◆ SetPlaybackMode()

void CustomPlayer::SetPlaybackMode ( LIDL::Playback  playMode)

SetPlaybackMode Sets the playback mode of the CustomPlayer.

Parameters
playModeOne of playback mode defined in EnumsAndStructs.h

References _playMode.

Referenced by SoundWrapper::SoundWrapper().

Here is the caller graph for this function:

◆ SetPlaylist()

void CustomPlayer::SetPlaylist ( QVector< LIDL::SoundFile * >  soundList)

SetPlaylist Set the playlist of the CustomPlayer.

Will attempt to clear the existing soundlist pointers if it exists.

Parameters
soundListThe soundlist to be set.

References _soundList.

Referenced by SoundWrapper::SoundWrapper().

Here is the caller graph for this function:

◆ SetVACDevice()

void CustomPlayer::SetVACDevice ( int  index)

SetVACDevice Sets the VAC output device of the player.

Parameters
indexDevice index.

References _VACOutputDevice.

Referenced by SoundWrapper::setPlayerVACOutput(), and SoundWrapper::VACDeviceChanged().

Here is the caller graph for this function:

◆ Stop

void CustomPlayer::Stop ( )
slot

Stop all the channels of this player.

Iterates through channels and calls BASS_ChannelStop() on them. BASS_ChannelStop will not crash the soundword if channel isn't valid. (Which could be the case if the iteration starts and somehow the vector is popped_front right at the same time.) It should not happen tho, as stop it called, it means the sound is still playing.

References _mainChannel, _timerSequentialAutoPlay, _vacChannel, BASS_ChannelStop(), and resetShouldPlay().

Referenced by SoundWrapper::Stop().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _index

int CustomPlayer::_index
private

The index of the next song to be played.

Referenced by CustomPlayer(), and PlayNext().

◆ _mainChannel

QVector<unsigned long> CustomPlayer::_mainChannel
private

The array containing the handles to the channels being played.

Referenced by PlayAt(), and Stop().

◆ _mainOutputDevice

unsigned long CustomPlayer::_mainOutputDevice
private

The index of the main output device.

Referenced by CustomPlayer(), GetOutputDevice(), PlayAt(), PlayNext(), and SetOutputDevice().

◆ _playMode

LIDL::Playback CustomPlayer::_playMode
private

Playmode, either Singleton, Singleton Cancer, Sequential, Sequential auto.

Referenced by CustomPlayer(), PlayNext(), and SetPlaybackMode().

◆ _shouldPlay

bool CustomPlayer::_shouldPlay
private

Boolean to know whether this player is allowed to play next song or not.

Referenced by CustomPlayer(), PlayNext(), and resetShouldPlay().

◆ _soundList

QVector<LIDL::SoundFile*> CustomPlayer::_soundList
private

Vector containing the soundlist.

Referenced by CustomPlayer(), PlayAt(), PlayNext(), SetPlaylist(), and ~CustomPlayer().

◆ _timerSequentialAutoPlay

QTimer* CustomPlayer::_timerSequentialAutoPlay
private

Timer to know when to auto-play next song.

Referenced by CustomPlayer(), PlayNext(), and Stop().

◆ _timerShouldPlay

QTimer* CustomPlayer::_timerShouldPlay
private

Timer to reset the _shouldPlay boolean (calls the resetShouldPlay method).

Referenced by CustomPlayer(), PlayNext(), and resetShouldPlay().

◆ _vacChannel

QVector<unsigned long> CustomPlayer::_vacChannel
private

Referenced by PlayAt(), and Stop().

◆ _VACOutputDevice

unsigned long CustomPlayer::_VACOutputDevice
private

The index of the main output device.

Referenced by CustomPlayer(), GetVACDevice(), PlayAt(), PlayNext(), and SetVACDevice().


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