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