2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
|
|
|
|
2016-03-19 06:57:51 +13:00
|
|
|
#ifndef TSOUND_INCLUDED
|
|
|
|
#define TSOUND_INCLUDED
|
|
|
|
|
2016-04-14 22:15:09 +12:00
|
|
|
#include <memory>
|
|
|
|
|
2016-03-19 06:57:51 +13:00
|
|
|
#include "tsmartpointer.h"
|
|
|
|
#include "texception.h"
|
|
|
|
#include "tthreadmessage.h"
|
|
|
|
|
|
|
|
#undef DVAPI
|
|
|
|
#undef DVVAR
|
|
|
|
#ifdef TSOUND_EXPORTS
|
|
|
|
#define DVAPI DV_EXPORT_API
|
|
|
|
#define DVVAR DV_EXPORT_VAR
|
|
|
|
#else
|
|
|
|
#define DVAPI DV_IMPORT_API
|
|
|
|
#define DVVAR DV_IMPORT_VAR
|
|
|
|
#endif
|
|
|
|
|
2021-05-21 01:33:22 +12:00
|
|
|
#ifndef _WIN32
|
|
|
|
#define WAVE_FORMAT_PCM 1
|
|
|
|
#endif
|
|
|
|
|
2016-03-19 06:57:51 +13:00
|
|
|
//=========================================================
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
namespace TSound {
|
2016-03-19 06:57:51 +13:00
|
|
|
typedef UCHAR Channel;
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
const int MONO = 0;
|
|
|
|
const int LEFT = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
const int RIGHT = LEFT + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
|
|
|
|
// forward declarations
|
|
|
|
|
|
|
|
class TSoundTrack;
|
|
|
|
class TSoundTransform;
|
|
|
|
|
2016-04-15 17:11:23 +12:00
|
|
|
#ifdef _WIN32
|
2016-03-19 06:57:51 +13:00
|
|
|
template class DVAPI TSmartPointerT<TSoundTrack>;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef TSmartPointerT<TSoundTrack> TSoundTrackP;
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
/*!
|
|
|
|
The class TSoundTrackFormat contains the main features of a TSoundTrack as:
|
|
|
|
sample rate, bit per sample, number of channels and signed or unsigned sample
|
|
|
|
*/
|
2016-06-15 18:43:10 +12:00
|
|
|
class DVAPI TSoundTrackFormat {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
TUINT32 m_sampleRate; // frequenza di campionamento
|
|
|
|
int m_bitPerSample; // numero di bit per campione
|
|
|
|
int m_channelCount; // numero di canali
|
|
|
|
bool m_signedSample;
|
2021-05-20 23:35:12 +12:00
|
|
|
int m_formatType;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TSoundTrackFormat(TUINT32 sampleRate = 0, int bitPerSample = 0,
|
2021-05-20 23:35:12 +12:00
|
|
|
int channelCount = 0, bool signedSample = true,
|
|
|
|
int formatType = WAVE_FORMAT_PCM)
|
2016-06-15 18:43:10 +12:00
|
|
|
: m_sampleRate(sampleRate)
|
|
|
|
, m_bitPerSample(bitPerSample)
|
|
|
|
, m_channelCount(channelCount)
|
2021-05-20 23:35:12 +12:00
|
|
|
, m_signedSample(signedSample)
|
|
|
|
, m_formatType(formatType) {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
~TSoundTrackFormat() {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool operator==(const TSoundTrackFormat &rhs);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool operator!=(const TSoundTrackFormat &rhs);
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
//! \include sound_ex.cpp
|
|
|
|
|
|
|
|
/*!
|
|
|
|
The class TSoundTrack contains all features about a sound track
|
2021-07-08 13:39:28 +12:00
|
|
|
and gives all methods to access to these information
|
2016-03-19 06:57:51 +13:00
|
|
|
*/
|
2016-06-15 18:43:10 +12:00
|
|
|
class DVAPI TSoundTrack : public TSmartObject {
|
|
|
|
DECLARE_CLASS_CODE
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected:
|
2016-06-15 18:43:10 +12:00
|
|
|
TUINT32 m_sampleRate; // frequenza di campionamento
|
|
|
|
int m_sampleSize; // numero di byte per campione
|
|
|
|
int m_bitPerSample; // numero di bit per campione
|
|
|
|
TINT32 m_sampleCount; // numero di campioni
|
|
|
|
int m_channelCount; // numero di canali
|
2021-05-20 23:35:12 +12:00
|
|
|
int m_formatType;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TSoundTrack *m_parent; // nel caso di sotto-traccie
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
UCHAR *m_buffer;
|
|
|
|
bool m_bufferOwner;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TSoundTrack();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TSoundTrack(TUINT32 sampleRate, int bitPerSample, int channelCount,
|
2021-05-20 23:35:12 +12:00
|
|
|
int sampleSize, TINT32 sampleCount, bool isSampleSigned,
|
|
|
|
int formatType);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TSoundTrack(TUINT32 sampleRate, int bitPerSample, int channelCount,
|
|
|
|
int sampleSize, TINT32 sampleCount, UCHAR *buffer,
|
2021-05-20 23:35:12 +12:00
|
|
|
TSoundTrack *parent, int formatType);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
/*!
|
|
|
|
Create a new soundtrack according to the sample rate, bits per sample, number
|
|
|
|
of channels and number of samples specified as inputs.
|
|
|
|
signedSample must be true for tracks whose samples are signed
|
|
|
|
*/
|
|
|
|
static TSoundTrackP create(TUINT32 sampleRate, int bitPerSample,
|
|
|
|
int channelCount, TINT32 sampleCount,
|
2021-05-20 23:35:12 +12:00
|
|
|
bool signedSample = true,
|
|
|
|
int formatType = WAVE_FORMAT_PCM);
|
2016-06-15 18:43:10 +12:00
|
|
|
|
|
|
|
static TSoundTrackP create(TUINT32 sampleRate, int bitPerSample,
|
|
|
|
int channelCount, TINT32 sampleCount, void *buffer,
|
2021-05-20 23:35:12 +12:00
|
|
|
bool signedSample = true,
|
|
|
|
int formatType = WAVE_FORMAT_PCM);
|
2016-06-15 18:43:10 +12:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Create a new soundtrack according to the format and number of samples
|
|
|
|
specified as inputs
|
|
|
|
*/
|
|
|
|
static TSoundTrackP create(const TSoundTrackFormat &format,
|
|
|
|
TINT32 sampleCount);
|
|
|
|
|
|
|
|
static TSoundTrackP create(const TSoundTrackFormat &format,
|
|
|
|
TINT32 sampleCount, void *buffer);
|
|
|
|
|
|
|
|
~TSoundTrack();
|
|
|
|
|
|
|
|
//! Converts from seconds to samples according to the soundtrack sample rate
|
|
|
|
TINT32 secondsToSamples(double sec) const;
|
|
|
|
|
|
|
|
//! Converts from samples to seconds according to the soundtrack sample rate
|
|
|
|
double samplesToSeconds(TINT32 smp) const;
|
|
|
|
|
|
|
|
TUINT32 getSampleRate() const { return m_sampleRate; }
|
|
|
|
int getSampleSize() const { return m_sampleSize; }
|
|
|
|
int getChannelCount() const { return m_channelCount; }
|
|
|
|
int getBitPerSample() const { return m_bitPerSample; }
|
|
|
|
TINT32 getSampleCount() const { return m_sampleCount; }
|
2021-05-20 23:35:12 +12:00
|
|
|
int getFormatType() const { return m_formatType; }
|
2016-06-15 18:43:10 +12:00
|
|
|
|
|
|
|
//! Returns the duration of the soundtrack in seconds.
|
|
|
|
double getDuration() const;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns true if the samples of the soundtrack are signed, false otherwise
|
|
|
|
virtual bool isSampleSigned() const = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns the soundtrack format
|
|
|
|
TSoundTrackFormat getFormat() const;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns a pointer to the samples buffer.
|
|
|
|
const UCHAR *getRawData() const { return m_buffer; };
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setSampleRate(TUINT32 sampleRate) { m_sampleRate = sampleRate; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Clones the soundtrack
|
|
|
|
virtual TSoundTrackP clone() const = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns a soundtrack that contains just the cloned channel
|
|
|
|
virtual TSoundTrackP clone(TSound::Channel chan) const = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns a subtrack for the range [s0, s1], s0 and s1 are samples
|
|
|
|
virtual TSoundTrackP extract(TINT32 s0, TINT32 s1) = 0;
|
|
|
|
|
|
|
|
//! Returns a subtrack for the range [t0, t1], t0 and t1 are seconds
|
|
|
|
TSoundTrackP extract(double t0, double t1);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Copies the all samples of the source soundtrack
|
|
|
|
to the object, starting from dst_s0.
|
|
|
|
dst_s0 is expressed in samples.
|
|
|
|
*/
|
|
|
|
virtual void copy(const TSoundTrackP &src, TINT32 dst_s0) = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Copies the all samples of the source soundtrack
|
|
|
|
to the object, starting from dst_t0.
|
|
|
|
dst_t0 is expressed in seconds.
|
|
|
|
*/
|
|
|
|
void copy(const TSoundTrackP &src, double dst_t0);
|
|
|
|
|
|
|
|
//! Blanks the soundtrack in the given range
|
|
|
|
virtual void blank(TINT32 s0, TINT32 s1) = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Blanks the soundtrack in the given range. Range is expressed in seconds.
|
|
|
|
*/
|
|
|
|
void blank(double t0, double t1);
|
|
|
|
|
|
|
|
/*!
|
2021-07-08 13:39:28 +12:00
|
|
|
Returns a new soundtrack obtained applying the given sound transform
|
2016-06-15 18:43:10 +12:00
|
|
|
to the soundtrack
|
|
|
|
*/
|
|
|
|
virtual TSoundTrackP apply(TSoundTransform *) = 0;
|
|
|
|
|
|
|
|
//! Returns the soundtrack pressure value for the given sample and channel:
|
|
|
|
//! range [-1,1]
|
|
|
|
virtual double getPressure(TINT32 sample, TSound::Channel chan) const = 0;
|
|
|
|
|
|
|
|
//! Returns the soundtrack pressure value for the given time and channel
|
|
|
|
double getPressure(double second, TSound::Channel chan) const;
|
|
|
|
|
|
|
|
//! Returns the soundtrack pressure max and min values in the given sample
|
|
|
|
//! range and channel
|
|
|
|
virtual void getMinMaxPressure(TINT32 s0, TINT32 s1, TSound::Channel chan,
|
|
|
|
double &min, double &max) const = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the soundtrack pressure min and max values in the given range and
|
|
|
|
channel.
|
|
|
|
Range in seconds
|
|
|
|
*/
|
|
|
|
void getMinMaxPressure(double t0, double t1, TSound::Channel chan,
|
|
|
|
double &min, double &max) const;
|
|
|
|
|
|
|
|
//! Returns the soundtrack pressure min and max values for the given channel
|
|
|
|
void getMinMaxPressure(TSound::Channel chan, double &min, double &max) const;
|
|
|
|
|
|
|
|
//! Returns the soundtrack pressure max value in the given sample range and
|
|
|
|
//! channel
|
|
|
|
virtual double getMaxPressure(TINT32 s0, TINT32 s1,
|
|
|
|
TSound::Channel chan) const = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the soundtrack pressure min value in the given range and channel.
|
|
|
|
Range in seconds
|
|
|
|
*/
|
|
|
|
double getMaxPressure(double t0, double t1, TSound::Channel chan) const;
|
|
|
|
|
|
|
|
//! Returns the soundtrack pressure max value for the given channel
|
|
|
|
double getMaxPressure(TSound::Channel chan) const;
|
|
|
|
|
|
|
|
//! Returns the soundtrack pressure max value in the given sample range and
|
|
|
|
//! channel
|
|
|
|
virtual double getMinPressure(TINT32 s0, TINT32 s1,
|
|
|
|
TSound::Channel chan) const = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the soundtrack pressure mix value in the given sample range and channel
|
|
|
|
Range in seconds
|
|
|
|
*/
|
|
|
|
double getMinPressure(double t0, double t1, TSound::Channel chan) const;
|
|
|
|
|
|
|
|
//! Returns the soundtrack pressure min value for the given channel
|
|
|
|
double getMinPressure(TSound::Channel chan) const;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class TSoundDeviceException final : public TException {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
enum Type {
|
2020-04-30 10:46:17 +12:00
|
|
|
NoDevice, // no device found
|
2016-06-15 18:43:10 +12:00
|
|
|
FailedInit, // fallimento del costruttore
|
|
|
|
UnableOpenDevice,
|
|
|
|
UnableCloseDevice,
|
|
|
|
UnablePrepare, // non puo' preparare i blocchi per play o rec
|
|
|
|
UnsupportedFormat, // formato non supportato
|
|
|
|
UnableSetDevice, // non puo' impostare il device richiesto
|
|
|
|
UnableVolume, // non puo' leggere o scrivere il valore del volume
|
|
|
|
NoMixer, // assenza del dispositivo per regolare il volume
|
|
|
|
Busy // indica che il dispositivo gia' sta facendo
|
|
|
|
// un play od una registrazione
|
|
|
|
};
|
|
|
|
|
|
|
|
TSoundDeviceException(Type type, const std::string &msg)
|
|
|
|
: TException(msg), m_type(type) {}
|
|
|
|
TSoundDeviceException(Type type, const std::wstring &msg)
|
|
|
|
: TException(msg), m_type(type) {}
|
|
|
|
|
|
|
|
Type getType() { return m_type; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
private:
|
2016-06-15 18:43:10 +12:00
|
|
|
Type m_type;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
// forward declaration
|
|
|
|
class TSoundInputDeviceImp;
|
|
|
|
|
|
|
|
//! \include sndInDev_ex.cpp
|
|
|
|
/*!
|
|
|
|
The class TSoundInputDevice permits the recording of a new sound track
|
|
|
|
*/
|
2016-06-15 18:43:10 +12:00
|
|
|
class DVAPI TSoundInputDevice {
|
|
|
|
std::shared_ptr<TSoundInputDeviceImp> m_imp;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
enum Source { Mic = 0, LineIn, DigitalIn, CdAudio };
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TSoundInputDevice();
|
|
|
|
~TSoundInputDevice();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
/*!
|
|
|
|
Returns true if on the machine there is an audio card installed correctly
|
|
|
|
*/
|
|
|
|
static bool installed();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns the best format supported near the given parameters
|
|
|
|
TSoundTrackFormat getPreferredFormat(TUINT32 sampleRate, int channelCount,
|
2021-05-20 23:35:12 +12:00
|
|
|
int bitPerSample, int formatType);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns the best format supported near the given format
|
|
|
|
TSoundTrackFormat getPreferredFormat(const TSoundTrackFormat &);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns true if is possible to change volume setting on current input
|
|
|
|
//! interface
|
|
|
|
bool supportsVolume();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Starts the recording of a soundtrack with the given format from the given
|
|
|
|
//! source.
|
|
|
|
void record(const TSoundTrackFormat &format, Source devtype = Mic);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
/*!
|
|
|
|
Starts the recording over the soundtrack st from the given source.
|
|
|
|
If not stopped before, recording ends when the whole soundtrack has been
|
|
|
|
overwritten.
|
|
|
|
*/
|
|
|
|
void record(const TSoundTrackP &st, Source src = Mic);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Stops the recording and returns the result of recording.
|
|
|
|
TSoundTrackP stop();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Return the current value of the volume
|
|
|
|
double getVolume();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Set the value of the volume
|
|
|
|
bool setVolume(double value);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns true if and only if the device is recording
|
|
|
|
bool isRecording();
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
The class TSoundOutputDeviceListener permits to notify to other object
|
|
|
|
if a playback is completed. Use it as base class that needs to know if
|
|
|
|
a playback is ended
|
|
|
|
*/
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
class DVAPI TSoundOutputDeviceListener {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual ~TSoundOutputDeviceListener(){};
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
virtual void onPlayCompleted() = 0;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
class TSoundOutputDeviceImp;
|
|
|
|
//! \include sndOutDev_ex.cpp
|
|
|
|
|
|
|
|
/*!
|
|
|
|
The class TSoundOutputDevice permits the playback of a sound track
|
|
|
|
*/
|
2016-06-15 18:43:10 +12:00
|
|
|
class DVAPI TSoundOutputDevice {
|
|
|
|
std::shared_ptr<TSoundOutputDeviceImp> m_imp;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
TSoundOutputDevice();
|
|
|
|
~TSoundOutputDevice();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
/*!
|
|
|
|
Returns true if on the machine there is an audio card installed correctly
|
|
|
|
*/
|
|
|
|
static bool installed();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns the best format supported near the given parameters
|
|
|
|
TSoundTrackFormat getPreferredFormat(TUINT32 sampleRate, int channelCount,
|
2021-05-20 23:35:12 +12:00
|
|
|
int bitPerSample, int formatType);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns the best format supported near the given format
|
|
|
|
TSoundTrackFormat getPreferredFormat(const TSoundTrackFormat &);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool isFormatSupported(const TSoundTrackFormat &);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2018-05-25 13:28:41 +12:00
|
|
|
#ifndef _WIN32
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns true if is possible to change volume setting on current input
|
|
|
|
//! interface
|
|
|
|
bool supportsVolume();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns the current value of the volume [0,1]
|
|
|
|
double getVolume();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Set the value of volume , between [0,1]
|
|
|
|
bool setVolume(double value);
|
2017-09-22 19:19:10 +12:00
|
|
|
void prepareVolume(double volume);
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Open the device according to the features of soundtrack
|
|
|
|
bool open(const TSoundTrackP &st);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Playback of the sndtrack in the request sample range
|
|
|
|
void play(const TSoundTrackP &st, TINT32 s0, TINT32 s1, bool loop = false,
|
|
|
|
bool scrubbing = false);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Close in the right mode the device
|
|
|
|
bool close();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
/*!Playback of the sndtrack in the request time range.
|
|
|
|
The loop argument permits to set the looping status of player
|
|
|
|
The scrubbing permits to an application to set the mode for the
|
|
|
|
interaction between sound and mouse
|
|
|
|
*/
|
|
|
|
void play(const TSoundTrackP &st, double t0, double t1, bool loop = false,
|
|
|
|
bool scrubbing = false) {
|
|
|
|
play(st, st->secondsToSamples(t0), st->secondsToSamples(t1), loop,
|
|
|
|
scrubbing);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Stop the playback of one or more soundtracks
|
|
|
|
void stop();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns if the device is busy with a playback
|
|
|
|
bool isPlaying() const;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2018-05-25 13:28:41 +12:00
|
|
|
#ifdef _WIN32
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Return true if the playback of all soundtracks is ended.
|
|
|
|
bool isAllQueuedItemsPlayed();
|
2016-03-19 06:57:51 +13:00
|
|
|
#endif
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Returns if the status of player is in looping
|
|
|
|
bool isLooping();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
//! Permits to change the looping status of player
|
|
|
|
void setLooping(bool loop);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void attach(TSoundOutputDeviceListener *listener);
|
|
|
|
void detach(TSoundOutputDeviceListener *listener);
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|