Audaspace: update from upstream

- Changing API for time values from float to double for better precision.
- Fixing minor mistakes in the documentation.
- Fixing minor unnecessary large memory allocation.
This commit is contained in:
Joerg Mueller 2020-05-03 15:25:52 +02:00
parent 2b7d5caae8
commit fe891d581d
68 changed files with 174 additions and 162 deletions

View File

@ -290,14 +290,14 @@ AUD_API AUD_Device* AUD_Device_getCurrent()
return new AUD_Device(device);
}
AUD_API void AUD_seekSynchronizer(AUD_Handle* handle, float time)
AUD_API void AUD_seekSynchronizer(AUD_Handle* handle, double time)
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)
synchronizer->seek(*reinterpret_cast<std::shared_ptr<IHandle>*>(handle), time);
}
AUD_API float AUD_getSynchronizerPosition(AUD_Handle* handle)
AUD_API double AUD_getSynchronizerPosition(AUD_Handle* handle)
{
auto synchronizer = DeviceManager::getDevice()->getSynchronizer();
if(synchronizer)

View File

@ -221,14 +221,14 @@ extern AUD_API AUD_Device* AUD_Device_getCurrent();
* \param handle Playback handle.
* \param time Time in seconds to seek to.
*/
extern AUD_API void AUD_seekSynchronizer(AUD_Handle* handle, float time);
extern AUD_API void AUD_seekSynchronizer(AUD_Handle* handle, double time);
/**
* Returns the current sound scene playback time.
* \param handle Playback handle.
* \return The playback time in seconds.
*/
extern AUD_API float AUD_getSynchronizerPosition(AUD_Handle* handle);
extern AUD_API double AUD_getSynchronizerPosition(AUD_Handle* handle);
/**
* Starts the playback of jack transport if possible.

View File

@ -101,14 +101,14 @@ AUD_API int AUD_DynamicMusic_pause(AUD_DynamicMusic* player)
return (*player)->pause();
}
AUD_API int AUD_DynamicMusic_seek(AUD_DynamicMusic* player, float position)
AUD_API int AUD_DynamicMusic_seek(AUD_DynamicMusic* player, double position)
{
assert(player);
return (*player)->seek(position);
}
AUD_API float AUD_DynamicMusic_getPosition(AUD_DynamicMusic* player)
AUD_API double AUD_DynamicMusic_getPosition(AUD_DynamicMusic* player)
{
assert(player);
@ -141,4 +141,4 @@ AUD_API int AUD_DynamicMusic_stop(AUD_DynamicMusic* player)
assert(player);
return (*player)->stop();
}
}

View File

@ -103,14 +103,14 @@ extern AUD_API int AUD_DynamicMusic_pause(AUD_DynamicMusic* player);
* \param position The new position from which to play back, in seconds.
* \return 0 if the seeking wasn't possible.
*/
extern AUD_API int AUD_DynamicMusic_seek(AUD_DynamicMusic* player, float position);
extern AUD_API int AUD_DynamicMusic_seek(AUD_DynamicMusic* player, double position);
/**
* Retrieves the position of the current scene of a dynamic music player.
* \param player The DynamicMusic object.
* \return The position of the current playing scene.
*/
extern AUD_API float AUD_DynamicMusic_getPosition(AUD_DynamicMusic* player);
extern AUD_API double AUD_DynamicMusic_getPosition(AUD_DynamicMusic* player);
/**
* Retrieves the volume of the current scene of a dynamic music player.
@ -142,4 +142,4 @@ extern AUD_API int AUD_DynamicMusic_stop(AUD_DynamicMusic* player);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -259,13 +259,13 @@ AUD_API int AUD_Handle_setPitch(AUD_Handle* handle, float value)
return (*handle)->setPitch(value);
}
AUD_API float AUD_Handle_getPosition(AUD_Handle* handle)
AUD_API double AUD_Handle_getPosition(AUD_Handle* handle)
{
assert(handle);
return (*handle)->getPosition();
}
AUD_API int AUD_Handle_setPosition(AUD_Handle* handle, float value)
AUD_API int AUD_Handle_setPosition(AUD_Handle* handle, double value)
{
assert(handle);
return (*handle)->seek(value);

View File

@ -211,14 +211,14 @@ extern AUD_API int AUD_Handle_setPitch(AUD_Handle* handle, float value);
* param handle The handle to get the position from.
* return The position of the handle.
*/
extern AUD_API float AUD_Handle_getPosition(AUD_Handle* handle);
extern AUD_API double AUD_Handle_getPosition(AUD_Handle* handle);
/**
* Sets the position of a handle.
* param handle The handle to set the position from.
* param value The new position to set.
*/
extern AUD_API int AUD_Handle_setPosition(AUD_Handle* handle, float value);
extern AUD_API int AUD_Handle_setPosition(AUD_Handle* handle, double value);
/**
* Retrieves the relative of a handle.

View File

@ -41,7 +41,7 @@ AUD_API void AUD_Sequence_free(AUD_Sound* sequence)
delete sequence;
}
AUD_API AUD_SequenceEntry* AUD_Sequence_add(AUD_Sound* sequence, AUD_Sound* sound, float begin, float end, float skip)
AUD_API AUD_SequenceEntry* AUD_Sequence_add(AUD_Sound* sequence, AUD_Sound* sound, double begin, double end, double skip)
{
if(!sound)
return new AUD_SequenceEntry(((Sequence *)sequence->get())->add(AUD_Sound(), begin, end, skip));
@ -160,7 +160,7 @@ AUD_API void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value)
AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, float begin, float end, float skip)
AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, double begin, double end, double skip)
{
(*entry)->move(begin, end, skip);
}

View File

@ -55,7 +55,7 @@ extern AUD_API void AUD_Sequence_free(AUD_Sound* sequence);
* \param skip How much seconds should be skipped at the beginning.
* \return The entry added.
*/
extern AUD_API AUD_SequenceEntry* AUD_Sequence_add(AUD_Sound* sequence, AUD_Sound* sound, float begin, float end, float skip);
extern AUD_API AUD_SequenceEntry* AUD_Sequence_add(AUD_Sound* sequence, AUD_Sound* sound, double begin, double end, double skip);
/**
* Removes an entry from the scene.
@ -167,7 +167,7 @@ extern AUD_API void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float valu
* \param end The new end time or a negative value if unknown.
* \param skip How many seconds to skip at the beginning.
*/
extern AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, float begin, float end, float skip);
extern AUD_API void AUD_SequenceEntry_move(AUD_SequenceEntry* entry, double begin, double end, double skip);
/**
* Writes animation data to a sequenced entry.

View File

@ -175,7 +175,7 @@ static void pauseSound(AUD_Handle* handle)
(*handle)->pause();
}
AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds)
AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, double seconds)
{
auto device = DeviceManager::getDevice();
@ -336,7 +336,7 @@ AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start
}
}
AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start)
AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, double start)
{
try
{

View File

@ -45,7 +45,7 @@ extern AUD_API float* AUD_readSoundBuffer(const char* filename, float low, float
* \param seconds The time in seconds.
* \return The silence handle.
*/
extern AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds);
extern AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, double seconds);
/**
* Reads a sound into a buffer for drawing at a specific sampling rate.
@ -101,7 +101,7 @@ extern AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned in
* \param start The start time of the mixdown in the sound scene.
* \return The read device for the mixdown.
*/
extern AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, float start);
extern AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, double start);
/**
* Initializes audio routines (FFMPEG/JACK if it is enabled).

View File

@ -4,4 +4,5 @@ Device
.. currentmodule:: aud
.. autoclass:: Device
:members:
:noindex:

View File

@ -4,4 +4,5 @@ Handle
.. currentmodule:: aud
.. autoclass:: Handle
:members:
:noindex:

View File

@ -7,6 +7,7 @@ Welcome to audaspace's documentation!
=====================================
.. automodule:: aud
:no-members:
This documentation is valid for both the Python and C bindings of audaspace. If you are looking for installation instructions check the `C++ API documentation <../index.html>`_. As C is not an object oriented language everything is accessible via functions where the first paramter is always the object. For methods these are named as ``AUD_ClassName_method()`` and properties are accessed via ``AUD_ClassName_property_get/set()``. Python users simply ``import aud`` to access the library.
@ -18,7 +19,7 @@ This documentation is valid for both the Python and C bindings of audaspace. If
Classes:
.. toctree::
:maxdepth: 2
:maxdepth: 1
device
sound

View File

@ -4,4 +4,5 @@ Sequence
.. currentmodule:: aud
.. autoclass:: Sequence
:members:
:noindex:

View File

@ -4,4 +4,5 @@ Sequence Entry
.. currentmodule:: aud
.. autoclass:: SequenceEntry
:members:
:noindex:

View File

@ -4,4 +4,5 @@ Sound
.. currentmodule:: aud
.. autoclass:: Sound
:members:
:noindex:

View File

@ -40,7 +40,7 @@ and create a :func:`aud.Sound.sine` signal with a frequency of 440 Hz.
sine = aud.Sound.sine(440)
.. note:: At this point nothing is playing back yet,
:class:`aud.Sound` objects are just descriptions of sounds.
:class:`aud.Sound` objects are just descriptions of sounds.
However instead of a sine wave, we would like to have a square wave
to produce a more retro gaming sound. We could of course use the

View File

@ -228,9 +228,9 @@ PyDoc_STRVAR(M_aud_DynamicMusic_position_doc,
static int
DynamicMusic_set_position(DynamicMusicP* self, PyObject* args, void* nothing)
{
float position;
double position;
if(!PyArg_Parse(args, "f:position", &position))
if(!PyArg_Parse(args, "d:position", &position))
return -1;
try
@ -252,7 +252,7 @@ DynamicMusic_get_position(DynamicMusicP* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getPosition());
return Py_BuildValue("d", (*reinterpret_cast<std::shared_ptr<aud::DynamicMusic>*>(self->dynamicMusic))->getPosition());
}
catch(aud::Exception& e)
{

View File

@ -696,7 +696,7 @@ Handle_get_position(Handle* self, void* nothing)
{
try
{
return Py_BuildValue("f", (*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->getPosition());
return Py_BuildValue("d", (*reinterpret_cast<std::shared_ptr<IHandle>*>(self->handle))->getPosition());
}
catch(Exception& e)
{
@ -708,9 +708,9 @@ Handle_get_position(Handle* self, void* nothing)
static int
Handle_set_position(Handle* self, PyObject* args, void* nothing)
{
float position;
double position;
if(!PyArg_Parse(args, "f:position", &position))
if(!PyArg_Parse(args, "d:position", &position))
return -1;
try

View File

@ -104,11 +104,11 @@ PyDoc_STRVAR(M_aud_Sequence_add_doc,
" :arg sound: The sound this entry should play.\n"
" :type sound: :class:`Sound`\n"
" :arg begin: The start time.\n"
" :type begin: float\n"
" :type begin: double\n"
" :arg end: The end time or a negative value if determined by the sound.\n"
" :type end: float\n"
" :type end: double\n"
" :arg skip: How much seconds should be skipped at the beginning.\n"
" :type skip: float\n"
" :type skip: double\n"
" :return: The entry added.\n"
" :rtype: :class:`SequenceEntry`");
@ -116,13 +116,13 @@ static PyObject *
Sequence_add(Sequence* self, PyObject* args, PyObject* kwds)
{
PyObject* object;
float begin;
float end = -1.0f;
float skip = 0.0f;
double begin;
double end = -1.0;
double skip = 0.0;
static const char* kwlist[] = {"sound", "begin", "end", "skip", nullptr};
if(!PyArg_ParseTupleAndKeywords(args, kwds, "Of|ff:add", const_cast<char**>(kwlist), &object, &begin, &end, &skip))
if(!PyArg_ParseTupleAndKeywords(args, kwds, "Od|dd:add", const_cast<char**>(kwlist), &object, &begin, &end, &skip))
return nullptr;
Sound* sound = checkSound(object);

View File

@ -46,18 +46,18 @@ PyDoc_STRVAR(M_aud_SequenceEntry_move_doc,
".. classmethod:: move()\n\n"
" Moves the entry.\n\n"
" :arg begin: The new start time.\n"
" :type begin: float\n"
" :type begin: double\n"
" :arg end: The new end time or a negative value if unknown.\n"
" :type end: float\n"
" :type end: double\n"
" :arg skip: How many seconds to skip at the beginning.\n"
" :type skip: float\n");
" :type skip: double\n");
static PyObject *
SequenceEntry_move(SequenceEntry* self, PyObject* args)
{
float begin, end, skip;
double begin, end, skip;
if(!PyArg_ParseTuple(args, "fff:move", &begin, &end, &skip))
if(!PyArg_ParseTuple(args, "ddd:move", &begin, &end, &skip))
return nullptr;
try

View File

@ -1394,7 +1394,7 @@ PyDoc_STRVAR(M_aud_Sound_threshold_doc,
" with a amplitude >= threshold to 1, all <= -threshold to -1 and\n"
" all between to 0.\n\n"
" :arg threshold: Threshold value over which an amplitude counts\n"
" non-zero.\n"
" non-zero.\n\n"
":type threshold: float\n"
":return: The created :class:`Sound` object.\n"
":rtype: :class:`Sound`");
@ -1434,7 +1434,8 @@ PyDoc_STRVAR(M_aud_Sound_volume_doc,
" :type volume: float\n"
" :return: The created :class:`Sound` object.\n"
" :rtype: :class:`Sound`\n\n"
" .. note:: Should be in the range [0, 1] to avoid clipping.\n\n"
" .. note::\n\n"
" Should be in the range [0, 1] to avoid clipping.\n\n"
" .. note::\n\n"
" This is a filter function, you might consider using\n"
" :attr:`Handle.volume` instead.");
@ -1475,8 +1476,8 @@ PyDoc_STRVAR(M_aud_Sound_join_doc,
" :return: The created :class:`Sound` object.\n"
" :rtype: :class:`Sound`\n\n"
" .. note::\n\n"
" The two factories have to have the same specifications\n"
" (channels and samplerate).");
" The two factories have to have the same specifications\n"
" (channels and samplerate).");
static PyObject *
Sound_join(Sound* self, PyObject* object)

View File

@ -33,8 +33,8 @@ AUD_NAMESPACE_BEGIN
class AUD_API DefaultSynchronizer : public ISynchronizer
{
public:
virtual void seek(std::shared_ptr<IHandle> handle, float time);
virtual float getPosition(std::shared_ptr<IHandle> handle);
virtual void seek(std::shared_ptr<IHandle> handle, double time);
virtual double getPosition(std::shared_ptr<IHandle> handle);
virtual void play();
virtual void stop();
virtual void setSyncCallback(syncFunction function, void* data);

View File

@ -35,6 +35,9 @@ AUD_NAMESPACE_BEGIN
class AUD_API IDeviceFactory
{
public:
/**
* Destroys the device factory.
*/
virtual ~IDeviceFactory() {}
/**

View File

@ -105,14 +105,14 @@ public:
* - false if the handle is invalid.
* \warning Whether the seek works or not depends on the sound source.
*/
virtual bool seek(float position)=0;
virtual bool seek(double position)=0;
/**
* Retrieves the current playback position of a sound.
* \return The playback position in seconds, or 0.0 if the handle is
* invalid.
*/
virtual float getPosition()=0;
virtual double getPosition()=0;
/**
* Returns the status of a played back sound.

View File

@ -56,14 +56,14 @@ public:
* @param handle The handle that should be synchronized/seeked.
* @param time The absolute time to synchronize to.
*/
virtual void seek(std::shared_ptr<IHandle> handle, float time) = 0;
virtual void seek(std::shared_ptr<IHandle> handle, double time) = 0;
/**
* Retrieves the position of the synchronizer.
* @param handle The handle which is synchronized.
* @return The position in seconds.
*/
virtual float getPosition(std::shared_ptr<IHandle> handle) = 0;
virtual double getPosition(std::shared_ptr<IHandle> handle) = 0;
/**
* Starts the synchronizer playback.

View File

@ -53,8 +53,8 @@ private:
virtual bool stop();
virtual bool getKeep();
virtual bool setKeep(bool keep);
virtual bool seek(float position);
virtual float getPosition();
virtual bool seek(double position);
virtual double getPosition();
virtual Status getStatus();
virtual float getVolume();
virtual bool setVolume(float volume);

View File

@ -180,8 +180,8 @@ protected:
virtual bool stop();
virtual bool getKeep();
virtual bool setKeep(bool keep);
virtual bool seek(float position);
virtual float getPosition();
virtual bool seek(double position);
virtual double getPosition();
virtual Status getStatus();
virtual float getVolume();
virtual bool setVolume(float volume);

View File

@ -40,7 +40,10 @@ class Buffer;
class AUD_API IFileInput
{
public:
virtual ~IFileInput() {};
/**
* Destroys the file input.
*/
virtual ~IFileInput() {}
/**
* Creates a reader for a file to be read.

View File

@ -35,7 +35,7 @@ private:
/**
* The delay in samples.
*/
const float m_delay;
const double m_delay;
// delete copy constructor and operator=
Delay(const Delay&) = delete;
@ -47,12 +47,12 @@ public:
* \param sound The input sound.
* \param delay The desired delay in seconds.
*/
Delay(std::shared_ptr<ISound> sound, float delay = 0);
Delay(std::shared_ptr<ISound> sound, double delay = 0);
/**
* Returns the delay in seconds.
*/
float getDelay() const;
double getDelay() const;
virtual std::shared_ptr<IReader> createReader();
};

View File

@ -52,7 +52,7 @@ public:
* \param reader The reader to read from.
* \param delay The delay in seconds.
*/
DelayReader(std::shared_ptr<IReader> reader, float delay);
DelayReader(std::shared_ptr<IReader> reader, double delay);
virtual void seek(int position);
virtual int getLength() const;

View File

@ -55,7 +55,7 @@ private:
/**
* Length of the crossfade transition in seconds, used when no custom transition has been set.
*/
float m_fadeTime;
double m_fadeTime;
/**
* Handle to the playback of the current scene.
@ -145,13 +145,13 @@ public:
* Sets the length of the crossfade transition (default 1 second).
* \param seconds The time in seconds.
*/
void setFadeTime(float seconds);
void setFadeTime(double seconds);
/**
* Gets the length of the crossfade transition (default 1 second).
* \return The length of the cressfade transition in seconds.
*/
float getFadeTime();
double getFadeTime();
/**
* Resumes a paused sound.
@ -177,14 +177,14 @@ public:
* - false if the handle is invalid.
* \warning Whether the seek works or not depends on the sound source.
*/
bool seek(float position);
bool seek(double position);
/**
* Retrieves the current playback position of a sound.
* \return The playback position in seconds, or 0.0 if the handle is
* invalid.
*/
float getPosition();
double getPosition();
/**
* Retrieves the volume of the scenes.

View File

@ -43,12 +43,12 @@ private:
/**
* The fading start.
*/
const float m_start;
const double m_start;
/**
* The fading length.
*/
const float m_length;
const double m_length;
// delete copy constructor and operator=
Fader(const Fader&) = delete;
@ -64,7 +64,7 @@ public:
*/
Fader(std::shared_ptr<ISound> sound,
FadeType type = FADE_IN,
float start = 0.0f, float length = 1.0f);
double start = 0, double length = 1);
/**
* Returns the fading type.
@ -74,12 +74,12 @@ public:
/**
* Returns the fading start.
*/
float getStart() const;
double getStart() const;
/**
* Returns the fading length.
*/
float getLength() const;
double getLength() const;
virtual std::shared_ptr<IReader> createReader();
};

View File

@ -49,12 +49,12 @@ private:
/**
* The fading start.
*/
const float m_start;
const double m_start;
/**
* The fading length.
*/
const float m_length;
const double m_length;
// delete copy constructor and operator=
FaderReader(const FaderReader&) = delete;
@ -69,7 +69,7 @@ public:
* \param length How long fading should last in seconds.
*/
FaderReader(std::shared_ptr<IReader> reader, FadeType type,
float start,float length);
double start,double length);
virtual void read(int& length, bool& eos, sample_t* buffer);
};

View File

@ -35,12 +35,12 @@ private:
/**
* The start time.
*/
const float m_start;
const double m_start;
/**
* The end time.
*/
const float m_end;
const double m_end;
// delete copy constructor and operator=
Limiter(const Limiter&) = delete;
@ -55,17 +55,17 @@ public:
* play to the end.
*/
Limiter(std::shared_ptr<ISound> sound,
float start = 0, float end = -1);
double start = 0, double end = -1);
/**
* Returns the start time.
*/
float getStart() const;
double getStart() const;
/**
* Returns the end time.
*/
float getEnd() const;
double getEnd() const;
virtual std::shared_ptr<IReader> createReader();
};

View File

@ -35,12 +35,12 @@ private:
/**
* The start sample: inclusive.
*/
const float m_start;
const double m_start;
/**
* The end sample: exlusive.
*/
const float m_end;
const double m_end;
// delete copy constructor and operator=
LimiterReader(const LimiterReader&) = delete;
@ -54,7 +54,7 @@ public:
* \param end The desired end time (sample exklusive), a negative value
* signals that it should play to the end.
*/
LimiterReader(std::shared_ptr<IReader> reader, float start = 0, float end = -1);
LimiterReader(std::shared_ptr<IReader> reader, double start = 0, double end = -1);
virtual void seek(int position);
virtual int getLength() const;

View File

@ -151,7 +151,7 @@ public:
* \param skip How much seconds should be skipped at the beginning.
* \return The entry added.
*/
std::shared_ptr<SequenceEntry> add(std::shared_ptr<ISound> sound, float begin, float end, float skip);
std::shared_ptr<SequenceEntry> add(std::shared_ptr<ISound> sound, double begin, double end, double skip);
/**
* Removes an entry from the scene.

View File

@ -203,7 +203,7 @@ public:
* \param skip How much seconds should be skipped at the beginning.
* \return The entry added.
*/
std::shared_ptr<SequenceEntry> add(std::shared_ptr<ISound> sound, float begin, float end, float skip);
std::shared_ptr<SequenceEntry> add(std::shared_ptr<ISound> sound, double begin, double end, double skip);
/**
* Removes an entry from the scene.

View File

@ -55,13 +55,13 @@ private:
std::shared_ptr<ISound> m_sound;
/// The begin time.
float m_begin;
double m_begin;
/// The end time.
float m_end;
double m_end;
/// How many seconds are skipped at the beginning.
float m_skip;
double m_skip;
/// Whether the entry is muted.
bool m_muted;
@ -124,7 +124,7 @@ public:
* \param skip How much seconds should be skipped at the beginning.
* \param id The ID of the entry.
*/
SequenceEntry(std::shared_ptr<ISound> sound, float begin, float end, float skip, int id);
SequenceEntry(std::shared_ptr<ISound> sound, double begin, double end, double skip, int id);
virtual ~SequenceEntry();
/**
@ -155,7 +155,7 @@ public:
* \param end The new end time or a negative value if unknown.
* \param skip How many seconds to skip at the beginning.
*/
void move(float begin, float end, float skip);
void move(double begin, double end, double skip);
/**
* Retrieves the muting state of the entry.

View File

@ -292,7 +292,7 @@ void JackDevice::stopPlayback()
m_nextState = JackTransportStopped;
}
void JackDevice::seekPlayback(float time)
void JackDevice::seekPlayback(double time)
{
if(time >= 0.0f)
AUD_jack_transport_locate(m_client, time * m_specs.rate);
@ -304,11 +304,11 @@ void JackDevice::setSyncCallback(ISynchronizer::syncFunction sync, void* data)
m_syncFuncData = data;
}
float JackDevice::getPlaybackPosition()
double JackDevice::getPlaybackPosition()
{
jack_position_t position;
AUD_jack_transport_query(m_client, &position);
return position.frame / (float) m_specs.rate;
return position.frame / (double) m_specs.rate;
}
bool JackDevice::doesPlayback()

View File

@ -174,7 +174,7 @@ public:
* Seeks jack transport playback.
* \param time The time to seek to.
*/
void seekPlayback(float time);
void seekPlayback(double time);
/**
* Sets the sync callback for jack transport playback.
@ -187,7 +187,7 @@ public:
* Retrieves the jack transport playback time.
* \return The current time position.
*/
float getPlaybackPosition();
double getPlaybackPosition();
/**
* Returns whether jack transport plays back.

View File

@ -25,12 +25,12 @@ JackSynchronizer::JackSynchronizer(JackDevice* device) :
{
}
void JackSynchronizer::seek(std::shared_ptr<IHandle> handle, float time)
void JackSynchronizer::seek(std::shared_ptr<IHandle> handle, double time)
{
m_device->seekPlayback(time);
}
float JackSynchronizer::getPosition(std::shared_ptr<IHandle> handle)
double JackSynchronizer::getPosition(std::shared_ptr<IHandle> handle)
{
return m_device->getPlaybackPosition();
}

View File

@ -48,8 +48,8 @@ public:
*/
JackSynchronizer(JackDevice* device);
virtual void seek(std::shared_ptr<IHandle> handle, float time);
virtual float getPosition(std::shared_ptr<IHandle> handle);
virtual void seek(std::shared_ptr<IHandle> handle, double time);
virtual double getPosition(std::shared_ptr<IHandle> handle);
virtual void play();
virtual void stop();
virtual void setSyncCallback(syncFunction function, void* data);

View File

@ -269,7 +269,7 @@ bool OpenALDevice::OpenALHandle::setKeep(bool keep)
return true;
}
bool OpenALDevice::OpenALHandle::seek(float position)
bool OpenALDevice::OpenALHandle::seek(double position)
{
if(!m_status)
return false;
@ -335,7 +335,7 @@ bool OpenALDevice::OpenALHandle::seek(float position)
return true;
}
float OpenALDevice::OpenALHandle::getPosition()
double OpenALDevice::OpenALHandle::getPosition()
{
if(!m_status)
return false;

View File

@ -126,8 +126,8 @@ private:
virtual bool stop();
virtual bool getKeep();
virtual bool setKeep(bool keep);
virtual bool seek(float position);
virtual float getPosition();
virtual bool seek(double position);
virtual double getPosition();
virtual Status getStatus();
virtual float getVolume();
virtual bool setVolume(float volume);

View File

@ -19,12 +19,12 @@
AUD_NAMESPACE_BEGIN
void DefaultSynchronizer::seek(std::shared_ptr<IHandle> handle, float time)
void DefaultSynchronizer::seek(std::shared_ptr<IHandle> handle, double time)
{
handle->seek(time);
}
float DefaultSynchronizer::getPosition(std::shared_ptr<IHandle> handle)
double DefaultSynchronizer::getPosition(std::shared_ptr<IHandle> handle)
{
return handle->getPosition();
}

View File

@ -52,12 +52,12 @@ bool NULLDevice::NULLHandle::setKeep(bool keep)
return false;
}
bool NULLDevice::NULLHandle::seek(float position)
bool NULLDevice::NULLHandle::seek(double position)
{
return false;
}
float NULLDevice::NULLHandle::getPosition()
double NULLDevice::NULLHandle::getPosition()
{
return std::numeric_limits<float>::quiet_NaN();
}

View File

@ -347,7 +347,7 @@ bool SoftwareDevice::SoftwareHandle::setKeep(bool keep)
return true;
}
bool SoftwareDevice::SoftwareHandle::seek(float position)
bool SoftwareDevice::SoftwareHandle::seek(double position)
{
if(!m_status)
return false;
@ -366,7 +366,7 @@ bool SoftwareDevice::SoftwareHandle::seek(float position)
return true;
}
float SoftwareDevice::SoftwareHandle::getPosition()
double SoftwareDevice::SoftwareHandle::getPosition()
{
if(!m_status)
return false;
@ -376,7 +376,7 @@ float SoftwareDevice::SoftwareHandle::getPosition()
if(!m_status)
return 0.0f;
float position = m_reader->getPosition() / (float)m_device->m_specs.rate;
double position = m_reader->getPosition() / (double)m_device->m_specs.rate;
return position;
}

View File

@ -19,13 +19,13 @@
AUD_NAMESPACE_BEGIN
Delay::Delay(std::shared_ptr<ISound> sound, float delay) :
Delay::Delay(std::shared_ptr<ISound> sound, double delay) :
Effect(sound),
m_delay(delay)
{
}
float Delay::getDelay() const
double Delay::getDelay() const
{
return m_delay;
}

View File

@ -20,7 +20,7 @@
AUD_NAMESPACE_BEGIN
DelayReader::DelayReader(std::shared_ptr<IReader> reader, float delay) :
DelayReader::DelayReader(std::shared_ptr<IReader> reader, double delay) :
EffectReader(reader),
m_delay(int((SampleRate)delay * reader->getSpecs().rate)),
m_remdelay(int((SampleRate)delay * reader->getSpecs().rate))

View File

@ -133,14 +133,14 @@ bool DynamicMusic::addTransition(int init, int end, std::shared_ptr<ISound> soun
return false;
}
void DynamicMusic::setFadeTime(float seconds)
void DynamicMusic::setFadeTime(double seconds)
{
m_device->lock();
m_fadeTime = seconds;
m_device->unlock();
}
float DynamicMusic::getFadeTime()
double DynamicMusic::getFadeTime()
{
return m_fadeTime;
}
@ -169,7 +169,7 @@ bool DynamicMusic::pause()
return result || resultTrans;
}
bool DynamicMusic::seek(float position)
bool DynamicMusic::seek(double position)
{
bool result = false;
@ -183,9 +183,9 @@ bool DynamicMusic::seek(float position)
return result;
}
float DynamicMusic::getPosition()
double DynamicMusic::getPosition()
{
float result = 0.0f;
double result = 0.0f;
if(m_currentHandle != nullptr)
result = m_currentHandle->getPosition();

View File

@ -18,7 +18,7 @@
AUD_NAMESPACE_BEGIN
Fader::Fader(std::shared_ptr<ISound> sound, FadeType type, float start, float length) :
Fader::Fader(std::shared_ptr<ISound> sound, FadeType type, double start, double length) :
Effect(sound),
m_type(type),
m_start(start),
@ -31,12 +31,12 @@ FadeType Fader::getType() const
return m_type;
}
float Fader::getStart() const
double Fader::getStart() const
{
return m_start;
}
float Fader::getLength() const
double Fader::getLength() const
{
return m_length;
}

View File

@ -20,7 +20,7 @@
AUD_NAMESPACE_BEGIN
FaderReader::FaderReader(std::shared_ptr<IReader> reader, FadeType type, float start,float length) :
FaderReader::FaderReader(std::shared_ptr<IReader> reader, FadeType type, double start, double length) :
EffectReader(reader),
m_type(type),
m_start(start),
@ -36,14 +36,14 @@ void FaderReader::read(int& length, bool& eos, sample_t* buffer)
m_reader->read(length, eos, buffer);
if((position + length) / (float)specs.rate <= m_start)
if((position + length) / specs.rate <= m_start)
{
if(m_type != FADE_OUT)
{
std::memset(buffer, 0, length * samplesize);
}
}
else if(position / (float)specs.rate >= m_start+m_length)
else if(position / specs.rate >= m_start+m_length)
{
if(m_type == FADE_OUT)
{
@ -58,7 +58,7 @@ void FaderReader::read(int& length, bool& eos, sample_t* buffer)
{
if(i % specs.channels == 0)
{
volume = (((position+i)/(float)specs.rate)-m_start) / m_length;
volume = float((((position + i) / specs.rate) - m_start) / m_length);
if(volume > 1.0f)
volume = 1.0f;
else if(volume < 0.0f)

View File

@ -20,19 +20,19 @@
AUD_NAMESPACE_BEGIN
Limiter::Limiter(std::shared_ptr<ISound> sound,
float start, float end) :
double start, double end) :
Effect(sound),
m_start(start),
m_end(end)
{
}
float Limiter::getStart() const
double Limiter::getStart() const
{
return m_start;
}
float Limiter::getEnd() const
double Limiter::getEnd() const
{
return m_end;
}

View File

@ -21,7 +21,7 @@
AUD_NAMESPACE_BEGIN
LimiterReader::LimiterReader(std::shared_ptr<IReader> reader, float start, float end) :
LimiterReader::LimiterReader(std::shared_ptr<IReader> reader, double start, double end) :
EffectReader(reader),
m_start(start),
m_end(end)

View File

@ -16,9 +16,9 @@
#include "respec/ChannelMapperReader.h"
#include <algorithm>
#include <cmath>
#include <limits>
#include <algorithm>
AUD_NAMESPACE_BEGIN

View File

@ -66,11 +66,11 @@ void Mixer::setSpecs(Specs specs)
void Mixer::clear(int length)
{
m_buffer.assureSize(length * m_specs.channels * AUD_SAMPLE_SIZE(m_specs));
m_buffer.assureSize(length * AUD_SAMPLE_SIZE(m_specs));
m_length = length;
std::memset(m_buffer.getBuffer(), 0, length * m_specs.channels * AUD_SAMPLE_SIZE(m_specs));
std::memset(m_buffer.getBuffer(), 0, length * AUD_SAMPLE_SIZE(m_specs));
}
void Mixer::mix(sample_t* buffer, int start, int length, float volume)

View File

@ -90,7 +90,7 @@ AnimateableProperty* Sequence::getAnimProperty(AnimateablePropertyType type)
return m_sequence->getAnimProperty(type);
}
std::shared_ptr<SequenceEntry> Sequence::add(std::shared_ptr<ISound> sound, float begin, float end, float skip)
std::shared_ptr<SequenceEntry> Sequence::add(std::shared_ptr<ISound> sound, double begin, double end, double skip)
{
return m_sequence->add(sound, begin, end, skip);
}

View File

@ -149,7 +149,7 @@ AnimateableProperty* SequenceData::getAnimProperty(AnimateablePropertyType type)
}
}
std::shared_ptr<SequenceEntry> SequenceData::add(std::shared_ptr<ISound> sound, float begin, float end, float skip)
std::shared_ptr<SequenceEntry> SequenceData::add(std::shared_ptr<ISound> sound, double begin, double end, double skip)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);

View File

@ -22,7 +22,7 @@
AUD_NAMESPACE_BEGIN
SequenceEntry::SequenceEntry(std::shared_ptr<ISound> sound, float begin, float end, float skip, int id) :
SequenceEntry::SequenceEntry(std::shared_ptr<ISound> sound, double begin, double end, double skip, int id) :
m_status(0),
m_pos_status(1),
m_sound_status(0),
@ -84,7 +84,7 @@ void SequenceEntry::setSound(std::shared_ptr<ISound> sound)
}
}
void SequenceEntry::move(float begin, float end, float skip)
void SequenceEntry::move(double begin, double end, double skip)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);

View File

@ -57,7 +57,7 @@ void SequenceHandle::start()
m_valid = m_handle.get();
}
bool SequenceHandle::updatePosition(float position)
bool SequenceHandle::updatePosition(double position)
{
std::lock_guard<ILockable> lock(*m_entry);
@ -140,7 +140,7 @@ void SequenceHandle::stop()
m_3dhandle = nullptr;
}
void SequenceHandle::update(float position, float frame, float fps)
void SequenceHandle::update(double position, float frame, float fps)
{
if(m_sound_status != m_entry->m_sound_status)
{
@ -229,7 +229,7 @@ void SequenceHandle::update(float position, float frame, float fps)
m_handle->setVolume(0);
}
bool SequenceHandle::seek(float position)
bool SequenceHandle::seek(double position)
{
if(!m_valid)
// sound not valid, aborting
@ -240,7 +240,7 @@ bool SequenceHandle::seek(float position)
return false;
std::lock_guard<ILockable> lock(*m_entry);
float seekpos = position - m_entry->m_begin;
double seekpos = position - m_entry->m_begin;
if(seekpos < 0)
seekpos = 0;
seekpos += m_entry->m_skip;

View File

@ -71,7 +71,7 @@ private:
* \param position Current playback position in seconds.
* \return Whether the handle is valid.
*/
bool updatePosition(float position);
bool updatePosition(double position);
public:
/**
@ -104,14 +104,14 @@ public:
* \param frame The current frame during playback.
* \param fps The animation frames per second.
*/
void update(float position, float frame, float fps);
void update(double position, float frame, float fps);
/**
* Seeks the handle to a specific time position.
* \param position The time to seek to.
* \return Whether the handle is valid.
*/
bool seek(float position);
bool seek(double position);
};
AUD_NAMESPACE_END

View File

@ -49,7 +49,7 @@ void SequenceReader::seek(int position)
for(auto& handle : m_handles)
{
handle->seek(position / m_sequence->m_specs.rate);
handle->seek(position / (double)m_sequence->m_specs.rate);
}
}
@ -150,13 +150,12 @@ void SequenceReader::read(int& length, bool& eos, sample_t* buffer)
Specs specs = m_sequence->m_specs;
int pos = 0;
float time = float(m_position) / float(specs.rate);
double time = double(m_position) / double(specs.rate);
float volume, frame;
int len, cfra;
Vector3 v, v2;
Quaternion q;
while(pos < length)
{
frame = time * m_sequence->m_fps;
@ -187,7 +186,7 @@ void SequenceReader::read(int& length, bool& eos, sample_t* buffer)
m_device.read(reinterpret_cast<data_t*>(buffer + specs.channels * pos), len);
pos += len;
time += float(len) / float(specs.rate);
time += double(len) / double(specs.rate);
}
m_position += length;

View File

@ -164,7 +164,7 @@ void BKE_sound_stop_scene(struct Scene *scene);
void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene);
float BKE_sound_sync_scene(struct Scene *scene);
double BKE_sound_sync_scene(struct Scene *scene);
int BKE_sound_scene_playing(struct Scene *scene);
@ -180,10 +180,10 @@ float BKE_sound_get_length(struct Main *bmain, struct bSound *sound);
char **BKE_sound_get_device_names(void);
typedef void (*SoundJackSyncCallback)(struct Main *bmain, int mode, float time);
typedef void (*SoundJackSyncCallback)(struct Main *bmain, int mode, double time);
void BKE_sound_jack_sync_callback_set(SoundJackSyncCallback callback);
void BKE_sound_jack_scene_update(struct Scene *scene, int mode, float time);
void BKE_sound_jack_scene_update(struct Scene *scene, int mode, double time);
/* Dependency graph evaluation. */

View File

@ -751,12 +751,12 @@ static void sound_start_play_scene(Scene *scene)
}
}
static float get_cur_time(Scene *scene)
static double get_cur_time(Scene *scene)
{
/* We divide by the current framelen to take into account time remapping.
* Otherwise we will get the wrong starting time which will break A/V sync.
* See T74111 for further details. */
return FRA2TIME((CFRA + SUBFRA) / scene->r.framelen);
return FRA2TIME((CFRA + SUBFRA) / (double)scene->r.framelen);
}
void BKE_sound_play_scene(Scene *scene)
@ -764,7 +764,7 @@ void BKE_sound_play_scene(Scene *scene)
sound_verify_evaluated_id(&scene->id);
AUD_Status status;
const float cur_time = get_cur_time(scene);
const double cur_time = get_cur_time(scene);
AUD_Device_lock(sound_device);
@ -811,8 +811,8 @@ void BKE_sound_seek_scene(Main *bmain, Scene *scene)
bScreen *screen;
int animation_playing;
const float one_frame = (float)(1.0 / FPS);
const float cur_time = FRA2TIME(CFRA);
const double one_frame = 1.0 / FPS;
const double cur_time = FRA2TIME(CFRA);
AUD_Device_lock(sound_device);
@ -869,7 +869,7 @@ void BKE_sound_seek_scene(Main *bmain, Scene *scene)
AUD_Device_unlock(sound_device);
}
float BKE_sound_sync_scene(Scene *scene)
double BKE_sound_sync_scene(Scene *scene)
{
sound_verify_evaluated_id(&scene->id);
@ -1230,7 +1230,7 @@ void BKE_sound_stop_scene(Scene *UNUSED(scene))
void BKE_sound_seek_scene(Main *UNUSED(bmain), Scene *UNUSED(scene))
{
}
float BKE_sound_sync_scene(Scene *UNUSED(scene))
double BKE_sound_sync_scene(Scene *UNUSED(scene))
{
return NAN_FLT;
}
@ -1341,7 +1341,7 @@ void BKE_sound_jack_sync_callback_set(SoundJackSyncCallback callback)
#endif
}
void BKE_sound_jack_scene_update(Scene *scene, int mode, float time)
void BKE_sound_jack_scene_update(Scene *scene, int mode, double time)
{
sound_verify_evaluated_id(&scene->id);

View File

@ -4388,7 +4388,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
wmWindow *window;
ScrArea *area;
int sync;
float time;
double time;
/* sync, don't sync, or follow scene setting */
if (sad->flag & ANIMPLAY_FLAG_SYNC) {
@ -4411,7 +4411,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
}
else if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false &&
isfinite(time = BKE_sound_sync_scene(scene_eval))) {
double newfra = (double)time * FPS;
double newfra = time * FPS;
/* give some space here to avoid jumps */
if (newfra + 0.5 > scene->r.cfra && newfra - 0.5 < scene->r.cfra) {

View File

@ -3170,9 +3170,9 @@ void wm_event_do_handlers(bContext *C)
}
if (is_playing_sound == 0) {
const float time = BKE_sound_sync_scene(scene_eval);
const double time = BKE_sound_sync_scene(scene_eval);
if (isfinite(time)) {
int ncfra = time * (float)FPS + 0.5f;
int ncfra = time * FPS + 0.5;
if (ncfra != scene->r.cfra) {
scene->r.cfra = ncfra;
ED_update_for_newframe(CTX_data_main(C), depsgraph);

View File

@ -199,7 +199,7 @@ void WM_init_opengl(Main *bmain)
opengl_is_init = true;
}
static void sound_jack_sync_callback(Main *bmain, int mode, float time)
static void sound_jack_sync_callback(Main *bmain, int mode, double time)
{
/* Ugly: Blender doesn't like it when the animation is played back during rendering. */
if (G.is_rendering) {