From 79707c2ae835c359ef4c9b39c04a5cf810592155 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Thu, 29 Feb 2024 12:08:00 +0100 Subject: [PATCH] Extern: update Audaspace to latest version No behavior changes, but no need to have a local modification that sets JOS resampler quality to Medium This basically contains two PRs that got accepted upstream: - https://github.com/audaspace/audaspace/pull/19 - https://github.com/audaspace/audaspace/pull/20 Pull Request: https://projects.blender.org/blender/blender/pulls/118896 --- extern/audaspace/README.blender | 4 +-- extern/audaspace/bindings/C/AUD_Sound.cpp | 12 ++++++--- extern/audaspace/bindings/C/AUD_Sound.h | 4 +-- extern/audaspace/bindings/C/AUD_Special.cpp | 14 +++++----- extern/audaspace/bindings/C/AUD_Special.h | 10 ++++--- extern/audaspace/bindings/C/AUD_Types.h | 9 +++++++ extern/audaspace/bindings/python/PySound.cpp | 25 ++++++------------ extern/audaspace/include/Exception.h | 8 +++--- .../audaspace/include/devices/DeviceManager.h | 6 ++--- .../include/devices/IDeviceFactory.h | 2 +- .../include/devices/SoftwareDevice.h | 8 +++--- extern/audaspace/include/file/File.h | 2 +- extern/audaspace/include/file/FileManager.h | 6 ++--- extern/audaspace/include/file/FileWriter.h | 2 +- extern/audaspace/include/file/IFileInput.h | 4 +-- extern/audaspace/include/file/IFileOutput.h | 2 +- extern/audaspace/include/respec/JOSResample.h | 4 ++- .../include/respec/JOSResampleReader.h | 26 +++++++------------ .../audaspace/include/respec/Specification.h | 9 +++++++ extern/audaspace/include/sequence/Sequence.h | 5 ++-- .../include/sequence/SequenceReader.h | 4 +-- .../plugins/coreaudio/CoreAudioDevice.cpp | 2 +- extern/audaspace/plugins/ffmpeg/FFMPEG.cpp | 6 ++--- extern/audaspace/plugins/ffmpeg/FFMPEG.h | 6 ++--- .../audaspace/plugins/ffmpeg/FFMPEGReader.cpp | 2 +- .../audaspace/plugins/ffmpeg/FFMPEGReader.h | 2 +- .../audaspace/plugins/ffmpeg/FFMPEGWriter.cpp | 2 +- .../audaspace/plugins/ffmpeg/FFMPEGWriter.h | 2 +- extern/audaspace/plugins/jack/JackDevice.cpp | 4 +-- extern/audaspace/plugins/jack/JackDevice.h | 2 +- .../audaspace/plugins/libsndfile/SndFile.cpp | 6 ++--- extern/audaspace/plugins/libsndfile/SndFile.h | 6 ++--- .../plugins/libsndfile/SndFileReader.cpp | 2 +- .../plugins/libsndfile/SndFileReader.h | 2 +- .../plugins/libsndfile/SndFileWriter.cpp | 2 +- .../plugins/libsndfile/SndFileWriter.h | 2 +- .../audaspace/plugins/openal/OpenALDevice.cpp | 8 +++--- .../audaspace/plugins/openal/OpenALDevice.h | 2 +- .../plugins/pulseaudio/PulseAudioDevice.cpp | 4 +-- .../plugins/pulseaudio/PulseAudioDevice.h | 2 +- extern/audaspace/plugins/sdl/SDLDevice.cpp | 2 +- .../audaspace/plugins/wasapi/WASAPIDevice.cpp | 2 +- extern/audaspace/src/Exception.cpp | 8 +++--- .../audaspace/src/devices/DeviceManager.cpp | 6 ++--- extern/audaspace/src/devices/NULLDevice.cpp | 2 +- .../audaspace/src/devices/SoftwareDevice.cpp | 14 ++++++---- extern/audaspace/src/file/File.cpp | 2 +- extern/audaspace/src/file/FileManager.cpp | 6 ++--- extern/audaspace/src/file/FileWriter.cpp | 2 +- extern/audaspace/src/respec/JOSResample.cpp | 7 +++-- .../src/respec/JOSResampleReader.cpp | 8 +++--- extern/audaspace/src/sequence/Sequence.cpp | 4 +-- .../audaspace/src/sequence/SequenceReader.cpp | 2 +- release/license/THIRD-PARTY-LICENSES.txt | 4 +-- source/blender/blenkernel/intern/sound.cc | 3 ++- source/blender/editors/sound/sound_ops.cc | 2 ++ 56 files changed, 162 insertions(+), 142 deletions(-) diff --git a/extern/audaspace/README.blender b/extern/audaspace/README.blender index a60fb218d9f..ce0dfc10a17 100644 --- a/extern/audaspace/README.blender +++ b/extern/audaspace/README.blender @@ -1,5 +1,5 @@ Project: Audaspace URL: https://github.com/audaspace/audaspace License: Apache 2.0 -Upstream version: 1.4+ (0d18fe7, 2024 Jan 2) -Local modifications: JOSResampleReader default quality set to MEDIUM +Upstream version: 1.4+ (ae29ce2, 2024 Feb 26) +Local modifications: none diff --git a/extern/audaspace/bindings/C/AUD_Sound.cpp b/extern/audaspace/bindings/C/AUD_Sound.cpp index dbedd0045b5..06ed6de6693 100644 --- a/extern/audaspace/bindings/C/AUD_Sound.cpp +++ b/extern/audaspace/bindings/C/AUD_Sound.cpp @@ -560,7 +560,7 @@ AUD_API AUD_Sound* AUD_Sound_rechannel(AUD_Sound* sound, AUD_Channels channels) } } -AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, bool high_quality) +AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, AUD_ResampleQuality quality) { assert(sound); @@ -570,10 +570,14 @@ AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, boo specs.channels = CHANNELS_INVALID; specs.rate = rate; specs.format = FORMAT_INVALID; - if(high_quality) - return new AUD_Sound(new JOSResample(*sound, specs)); - else + if (quality == AUD_RESAMPLE_QUALITY_FASTEST) + { return new AUD_Sound(new LinearResample(*sound, specs)); + } + else + { + return new AUD_Sound(new JOSResample(*sound, specs, static_cast(quality))); + } } catch(Exception&) { diff --git a/extern/audaspace/bindings/C/AUD_Sound.h b/extern/audaspace/bindings/C/AUD_Sound.h index dd4fad85122..e8a41e8ae7b 100644 --- a/extern/audaspace/bindings/C/AUD_Sound.h +++ b/extern/audaspace/bindings/C/AUD_Sound.h @@ -300,10 +300,10 @@ extern AUD_API AUD_Sound* AUD_Sound_rechannel(AUD_Sound* sound, AUD_Channels cha * Resamples the sound. * \param sound The sound to resample. * \param rate The new sample rate. - * \param high_quality When true use a higher quality but slower resampler. + * \param quality Resampling quality vs performance choice. * \return The resampled sound. */ -extern AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, bool high_quality); +extern AUD_API AUD_Sound* AUD_Sound_resample(AUD_Sound* sound, AUD_SampleRate rate, AUD_ResampleQuality quality); /** * Reverses a sound. Make sure the sound source can be reversed. diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp b/extern/audaspace/bindings/C/AUD_Special.cpp index a5ecb7a6dc0..0e94f80ccda 100644 --- a/extern/audaspace/bindings/C/AUD_Special.cpp +++ b/extern/audaspace/bindings/C/AUD_Special.cpp @@ -270,14 +270,14 @@ AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, int sampl return length; } -AUD_API int AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate, void(*callback)(float, void*), void* data, char* error, size_t errorsize) +AUD_API int AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate, AUD_ResampleQuality quality, void(*callback)(float, void*), void* data, char* error, size_t errorsize) { try { Sequence* f = dynamic_cast(sound->get()); f->setSpecs(convCToSpec(specs.specs)); - std::shared_ptr reader = f->createQualityReader(); + std::shared_ptr reader = f->createQualityReader(static_cast(quality)); reader->seek(start); std::shared_ptr writer = FileWriter::createWriter(filename, convCToDSpec(specs), static_cast(format), static_cast(codec), bitrate); FileWriter::writeReader(reader, writer, length, buffersize, callback, data); @@ -295,7 +295,7 @@ AUD_API int AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int lengt } } -AUD_API int AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate, void(*callback)(float, void*), void* data, char* error, size_t errorsize) +AUD_API int AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate, AUD_ResampleQuality quality, void(*callback)(float, void*), void* data, char* error, size_t errorsize) { try { @@ -329,7 +329,7 @@ AUD_API int AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsign writers.push_back(FileWriter::createWriter(stream.str(), convCToDSpec(specs), static_cast(format), static_cast(codec), bitrate)); } - std::shared_ptr reader = f->createQualityReader(); + std::shared_ptr reader = f->createQualityReader(static_cast(quality)); reader->seek(start); FileWriter::writeReader(reader, writers, length, buffersize, callback, data); @@ -346,19 +346,19 @@ AUD_API int AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsign } } -AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, double start) +AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, float volume, AUD_ResampleQuality quality, double start) { try { ReadDevice* device = new ReadDevice(convCToDSpec(specs)); - device->setQuality(true); + device->setQuality(static_cast(quality)); device->setVolume(volume); Sequence* f = dynamic_cast(sequencer->get()); f->setSpecs(convCToSpec(specs.specs)); - AUD_Handle handle = device->play(f->createQualityReader()); + AUD_Handle handle = device->play(f->createQualityReader(static_cast(quality))); if(handle.get()) { handle->seek(start); diff --git a/extern/audaspace/bindings/C/AUD_Special.h b/extern/audaspace/bindings/C/AUD_Special.h index f9a239acd61..72139e956a1 100644 --- a/extern/audaspace/bindings/C/AUD_Special.h +++ b/extern/audaspace/bindings/C/AUD_Special.h @@ -69,6 +69,7 @@ extern AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, in * \param format The file's container format. * \param codec The codec used for encoding the audio data. * \param bitrate The bitrate for encoding. + * \param quality The resampling quality. * \param callback A callback function that is called periodically during mixdown, reporting progress if length > 0. Can be NULL. * \param data Pass through parameter that is passed to the callback. * \param error String buffer to copy the error message to in case of failure. @@ -78,7 +79,7 @@ extern AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, int length, in extern AUD_API int AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, - AUD_Codec codec, unsigned int bitrate, + AUD_Codec codec, unsigned int bitrate, AUD_ResampleQuality quality, void(*callback)(float, void*), void* data, char* error, size_t errorsize); /** @@ -92,6 +93,7 @@ extern AUD_API int AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned in * \param format The file's container format. * \param codec The codec used for encoding the audio data. * \param bitrate The bitrate for encoding. + * \param quality The resampling quality. * \param callback A callback function that is called periodically during mixdown, reporting progress if length > 0. Can be NULL. * \param data Pass through parameter that is passed to the callback. * \param error String buffer to copy the error message to in case of failure. @@ -101,7 +103,7 @@ extern AUD_API int AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned in extern AUD_API int AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, unsigned int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, AUD_Container format, - AUD_Codec codec, unsigned int bitrate, + AUD_Codec codec, unsigned int bitrate, AUD_ResampleQuality quality, void(*callback)(float, void*), void* data, char* error, size_t errorsize); /** @@ -109,10 +111,12 @@ extern AUD_API int AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, * \param specs Output audio specifications. * \param sequencer The sound scene to mix down. * \param volume The overall mixdown volume. + * \param quality The resampling quality. * \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, double start); +extern AUD_API AUD_Device* AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound* sequencer, + float volume, AUD_ResampleQuality quality, double start); /** * Initializes audio routines (FFMPEG/JACK if it is enabled). diff --git a/extern/audaspace/bindings/C/AUD_Types.h b/extern/audaspace/bindings/C/AUD_Types.h index 0f95366bc27..f0f4e66851c 100644 --- a/extern/audaspace/bindings/C/AUD_Types.h +++ b/extern/audaspace/bindings/C/AUD_Types.h @@ -119,6 +119,15 @@ typedef enum AUD_CHANNELS_SURROUND71 = 8 /// 7.1 surround sound. } AUD_Channels; +/// Resampling algorithm and quality. +typedef enum +{ + AUD_RESAMPLE_QUALITY_FASTEST = 0, /// Linear resample, very fast but lowest quality. + AUD_RESAMPLE_QUALITY_LOW = 1, /// JOS resample at low quality preset. + AUD_RESAMPLE_QUALITY_MEDIUM = 2, /// JOS resample at medium quality preset. + AUD_RESAMPLE_QUALITY_HIGH = 3 /// JOS resample at high quality preset. +} AUD_ResampleQuality; + /** * The sample rate tells how many samples are played back within one second. * Some exotic formats may use other sample rates than provided here. diff --git a/extern/audaspace/bindings/python/PySound.cpp b/extern/audaspace/bindings/python/PySound.cpp index 7ac7e1bfe52..740db485a45 100644 --- a/extern/audaspace/bindings/python/PySound.cpp +++ b/extern/audaspace/bindings/python/PySound.cpp @@ -1269,12 +1269,12 @@ Sound_rechannel(Sound* self, PyObject* args) } PyDoc_STRVAR(M_aud_Sound_resample_doc, - ".. method:: resample(rate, high_quality)\n\n" + ".. method:: resample(rate, quality)\n\n" " Resamples the sound.\n\n" " :arg rate: The new sample rate.\n" " :type rate: double\n" - " :arg high_quality: When true use a higher quality but slower resampler.\n" - " :type high_quality: bool\n" + " :arg quality: Resampler performance vs quality choice (0=fastest, 3=slowest).\n" + " :type quality: int\n" " :return: The created :class:`Sound` object.\n" " :rtype: :class:`Sound`"); @@ -1282,20 +1282,11 @@ static PyObject * Sound_resample(Sound* self, PyObject* args) { double rate; - PyObject* high_qualityo; - bool high_quality = false; + int quality = 0; - if(!PyArg_ParseTuple(args, "d|O:resample", &rate, &high_qualityo)) + if(!PyArg_ParseTuple(args, "d|i:resample", &rate, &quality)) return nullptr; - if(!PyBool_Check(high_qualityo)) - { - PyErr_SetString(PyExc_TypeError, "high_quality is not a boolean!"); - return nullptr; - } - - high_quality = high_qualityo == Py_True; - PyTypeObject* type = Py_TYPE(self); Sound* parent = (Sound*)type->tp_alloc(type, 0); @@ -1307,10 +1298,10 @@ Sound_resample(Sound* self, PyObject* args) specs.channels = CHANNELS_INVALID; specs.rate = rate; specs.format = FORMAT_INVALID; - if(high_quality) - parent->sound = new std::shared_ptr(new JOSResample(*reinterpret_cast*>(self->sound), specs)); - else + if (quality == int(ResampleQuality::FASTEST)) parent->sound = new std::shared_ptr(new LinearResample(*reinterpret_cast*>(self->sound), specs)); + else + parent->sound = new std::shared_ptr(new JOSResample(*reinterpret_cast*>(self->sound), specs, static_cast(quality))); } catch(Exception& e) { diff --git a/extern/audaspace/include/Exception.h b/extern/audaspace/include/Exception.h index b102bfade63..2a505d7965d 100644 --- a/extern/audaspace/include/Exception.h +++ b/extern/audaspace/include/Exception.h @@ -69,7 +69,7 @@ protected: * @param file The source code file in which the exception was thrown. * @param line The source code line from which the exception was thrown. */ - Exception(std::string message, std::string file, int line); + Exception(const std::string &message, const std::string &file, int line); public: /** * Destroys the object. @@ -120,7 +120,7 @@ public: * @param file The source code file in which the exception was thrown. * @param line The source code line from which the exception was thrown. */ - FileException(std::string message, std::string file, int line); + FileException(const std::string &message, const std::string &file, int line); /** * Copy constructor. @@ -145,7 +145,7 @@ public: * @param file The source code file in which the exception was thrown. * @param line The source code line from which the exception was thrown. */ - DeviceException(std::string message, std::string file, int line); + DeviceException(const std::string &message, const std::string &file, int line); /** * Copy constructor. @@ -171,7 +171,7 @@ public: * @param file The source code file in which the exception was thrown. * @param line The source code line from which the exception was thrown. */ - StateException(std::string message, std::string file, int line); + StateException(const std::string &message, const std::string &file, int line); /** * Copy constructor. diff --git a/extern/audaspace/include/devices/DeviceManager.h b/extern/audaspace/include/devices/DeviceManager.h index fa84025478f..85d1d1f4139 100644 --- a/extern/audaspace/include/devices/DeviceManager.h +++ b/extern/audaspace/include/devices/DeviceManager.h @@ -62,14 +62,14 @@ public: * @param name A representative name for the device. * @param factory The factory that creates the device. */ - static void registerDevice(std::string name, std::shared_ptr factory); + static void registerDevice(const std::string &name, std::shared_ptr factory); /** * Returns the factory for a specific device. * @param name The representative name of the device. * @return The factory if it was found, or nullptr otherwise. */ - static std::shared_ptr getDeviceFactory(std::string name); + static std::shared_ptr getDeviceFactory(const std::string &name); /** * Returns the default device based on the priorities of the registered factories. @@ -92,7 +92,7 @@ public: * If a device is currently being handled it will be released. * @param name The representative name of the device. */ - static void openDevice(std::string name); + static void openDevice(const std::string &name); /** * Opens the default device which will then be handled by the manager. diff --git a/extern/audaspace/include/devices/IDeviceFactory.h b/extern/audaspace/include/devices/IDeviceFactory.h index c0769fa8015..82e4a90f6e6 100644 --- a/extern/audaspace/include/devices/IDeviceFactory.h +++ b/extern/audaspace/include/devices/IDeviceFactory.h @@ -71,7 +71,7 @@ public: * Sets a name for the device. * \param name The internal name for the device. */ - virtual void setName(std::string name)=0; + virtual void setName(const std::string &name)=0; }; AUD_NAMESPACE_END diff --git a/extern/audaspace/include/devices/SoftwareDevice.h b/extern/audaspace/include/devices/SoftwareDevice.h index c3af5cfd902..6fe956cac02 100644 --- a/extern/audaspace/include/devices/SoftwareDevice.h +++ b/extern/audaspace/include/devices/SoftwareDevice.h @@ -231,9 +231,9 @@ protected: std::shared_ptr m_mixer; /** - * Whether to do high or low quality resampling. + * Resampling quality. */ - bool m_quality; + ResampleQuality m_quality; /** * Initializes member variables. @@ -347,9 +347,9 @@ public: /** * Sets the resampling quality. - * \param quality Low (false) or high (true) quality. + * \param quality Resampling quality vs performance setting. */ - void setQuality(bool quality); + void setQuality(ResampleQuality quality); virtual DeviceSpecs getSpecs() const; virtual std::shared_ptr play(std::shared_ptr reader, bool keep = false); diff --git a/extern/audaspace/include/file/File.h b/extern/audaspace/include/file/File.h index ac490acba38..b2171b64c89 100644 --- a/extern/audaspace/include/file/File.h +++ b/extern/audaspace/include/file/File.h @@ -69,7 +69,7 @@ public: * \param filename The sound file path. * \param stream The index of the audio stream within the file if it contains multiple audio streams. */ - File(std::string filename, int stream = 0); + File(const std::string &filename, int stream = 0); /** * Creates a new sound. diff --git a/extern/audaspace/include/file/FileManager.h b/extern/audaspace/include/file/FileManager.h index e19eef65b1c..b1e11076a90 100644 --- a/extern/audaspace/include/file/FileManager.h +++ b/extern/audaspace/include/file/FileManager.h @@ -72,7 +72,7 @@ public: * @return The reader created. * @exception Exception If no file input can read the file an exception is thrown. */ - static std::shared_ptr createReader(std::string filename, int stream = 0); + static std::shared_ptr createReader(const std::string &filename, int stream = 0); /** * Creates a file reader for the given buffer if a registed IFileInput is able to read it. @@ -89,7 +89,7 @@ public: * \return A vector with as many streams as there are in the file. * \exception Exception Thrown if the file specified cannot be read. */ - static std::vector queryStreams(std::string filename); + static std::vector queryStreams(const std::string &filename); /** * Queries the streams of a sound file. @@ -110,7 +110,7 @@ public: * @return A writer that creates the file. * @exception Exception If no file output can write the file with the given specification an exception is thrown. */ - static std::shared_ptr createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); + static std::shared_ptr createWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); }; AUD_NAMESPACE_END diff --git a/extern/audaspace/include/file/FileWriter.h b/extern/audaspace/include/file/FileWriter.h index 13619d4de71..923c7dcb59c 100644 --- a/extern/audaspace/include/file/FileWriter.h +++ b/extern/audaspace/include/file/FileWriter.h @@ -54,7 +54,7 @@ public: * \param bitrate The bitrate for encoding. * \return The writer to write data to. */ - static std::shared_ptr createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); + static std::shared_ptr createWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); /** * Writes a reader to a writer. diff --git a/extern/audaspace/include/file/IFileInput.h b/extern/audaspace/include/file/IFileInput.h index 4a3fe446852..3d44a6536bc 100644 --- a/extern/audaspace/include/file/IFileInput.h +++ b/extern/audaspace/include/file/IFileInput.h @@ -54,7 +54,7 @@ public: * \return The reader that reads the file. * \exception Exception Thrown if the file specified cannot be read. */ - virtual std::shared_ptr createReader(std::string filename, int stream = 0)=0; + virtual std::shared_ptr createReader(const std::string &filename, int stream = 0)=0; /** * Creates a reader for a file to be read from memory. @@ -71,7 +71,7 @@ public: * \return A vector with as many streams as there are in the file. * \exception Exception Thrown if the file specified cannot be read. */ - virtual std::vector queryStreams(std::string filename)=0; + virtual std::vector queryStreams(const std::string &filename)=0; /** * Queries the streams of a sound file. diff --git a/extern/audaspace/include/file/IFileOutput.h b/extern/audaspace/include/file/IFileOutput.h index 5a6efacfe94..8f35eda3d77 100644 --- a/extern/audaspace/include/file/IFileOutput.h +++ b/extern/audaspace/include/file/IFileOutput.h @@ -46,7 +46,7 @@ public: * \param bitrate The bitrate for encoding. * \exception Exception Thrown if the file specified cannot be written. */ - virtual std::shared_ptr createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate)=0; + virtual std::shared_ptr createWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate)=0; }; AUD_NAMESPACE_END diff --git a/extern/audaspace/include/respec/JOSResample.h b/extern/audaspace/include/respec/JOSResample.h index b1f4d757c3c..7cc36e14f24 100644 --- a/extern/audaspace/include/respec/JOSResample.h +++ b/extern/audaspace/include/respec/JOSResample.h @@ -36,13 +36,15 @@ private: JOSResample(const JOSResample&) = delete; JOSResample& operator=(const JOSResample&) = delete; + ResampleQuality m_quality; + public: /** * Creates a new sound. * \param sound The input sound. * \param specs The target specifications. */ - JOSResample(std::shared_ptr sound, DeviceSpecs specs); + JOSResample(std::shared_ptr sound, DeviceSpecs specs, ResampleQuality quality = ResampleQuality::HIGH); virtual std::shared_ptr createReader(); }; diff --git a/extern/audaspace/include/respec/JOSResampleReader.h b/extern/audaspace/include/respec/JOSResampleReader.h index aae28354280..d628ae7f1b2 100644 --- a/extern/audaspace/include/respec/JOSResampleReader.h +++ b/extern/audaspace/include/respec/JOSResampleReader.h @@ -36,39 +36,39 @@ private: typedef void (JOSResampleReader::*resample_f)(double target_factor, int length, sample_t* buffer); /** - * The half filter length for Quality::HIGH setting. + * The half filter length for HIGH quality setting. */ static const int m_len_high; /** - * The half filter length for Quality::MEDIUM setting. + * The half filter length for MEDIUM quality setting. */ static const int m_len_medium; /** - * The half filter length for Quality::LOW setting. + * The half filter length for LOW quality setting. */ static const int m_len_low; /** - * The filter sample step size for Quality::HIGH setting. + * The filter sample step size for HIGH quality setting. */ static const int m_L_high; /** - * The filter sample step size for Quality::MEDIUM setting. + * The filter sample step size for MEDIUM quality setting. */ static const int m_L_medium; /** - * The filter sample step size for Quality::LOW setting. + * The filter sample step size for LOW quality setting. */ static const int m_L_low; /** - * The filter coefficients for Quality::HIGH setting. + * The filter coefficients for HIGH quality setting. */ static const float m_coeff_high[]; /** - * The filter coefficients for Quality::MEDIUM setting. + * The filter coefficients for MEDIUM quality setting. */ static const float m_coeff_medium[]; /** - * The filter coefficients for Quality::LOW setting. + * The filter coefficients for LOW quality setting. */ static const float m_coeff_low[]; @@ -152,19 +152,13 @@ private: void AUD_LOCAL resample(double target_factor, int length, sample_t* buffer); public: - enum class Quality - { - LOW = 0, - MEDIUM, - HIGH, - }; /** * Creates a resampling reader. * \param reader The reader to mix. * \param rate The target sampling rate. */ - JOSResampleReader(std::shared_ptr reader, SampleRate rate, Quality = Quality::MEDIUM); + JOSResampleReader(std::shared_ptr reader, SampleRate rate, ResampleQuality quality = ResampleQuality::HIGH); virtual void seek(int position); virtual int getLength() const; diff --git a/extern/audaspace/include/respec/Specification.h b/extern/audaspace/include/respec/Specification.h index efcbb4cabce..fef32710918 100644 --- a/extern/audaspace/include/respec/Specification.h +++ b/extern/audaspace/include/respec/Specification.h @@ -83,6 +83,15 @@ enum Channel CHANNEL_MAX }; +/// Resampling algorithm and quality. +enum class ResampleQuality +{ + FASTEST = 0, /// Linear resample, very fast but lowest quality. + LOW, /// JOS resample at low quality preset. + MEDIUM, /// JOS resample at medium quality preset. + HIGH /// JOS resample at high quality preset. +}; + /** * The sample rate tells how many samples are played back within one second. * Some exotic formats may use other sample rates than provided here. diff --git a/extern/audaspace/include/sequence/Sequence.h b/extern/audaspace/include/sequence/Sequence.h index de14fd9fa38..03ec7376f16 100644 --- a/extern/audaspace/include/sequence/Sequence.h +++ b/extern/audaspace/include/sequence/Sequence.h @@ -160,10 +160,11 @@ public: void remove(std::shared_ptr entry); /** - * Creates a new reader with high quality resampling. + * Creates a new reader with indicated resampling quality. + * \param quality The resampling quality. * \return The new reader. */ - std::shared_ptr createQualityReader(); + std::shared_ptr createQualityReader(ResampleQuality quality); virtual std::shared_ptr createReader(); }; diff --git a/extern/audaspace/include/sequence/SequenceReader.h b/extern/audaspace/include/sequence/SequenceReader.h index 196d969e102..4ad5c99498c 100644 --- a/extern/audaspace/include/sequence/SequenceReader.h +++ b/extern/audaspace/include/sequence/SequenceReader.h @@ -74,9 +74,9 @@ public: /** * Creates a resampling reader. * \param sequence The sequence data. - * \param quality Whether a high quality resample should be used for resampling. + * \param quality Resampling quality vs performance option. */ - SequenceReader(std::shared_ptr sequence, bool quality = false); + SequenceReader(std::shared_ptr sequence, ResampleQuality quality = ResampleQuality::FASTEST); /** * Destroys the reader. diff --git a/extern/audaspace/plugins/coreaudio/CoreAudioDevice.cpp b/extern/audaspace/plugins/coreaudio/CoreAudioDevice.cpp index 113ceccad60..cbb7c133fea 100644 --- a/extern/audaspace/plugins/coreaudio/CoreAudioDevice.cpp +++ b/extern/audaspace/plugins/coreaudio/CoreAudioDevice.cpp @@ -210,7 +210,7 @@ public: m_buffersize = buffersize; } - virtual void setName(std::string name) + virtual void setName(const std::string &name) { } }; diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEG.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEG.cpp index 07c0fee691a..d9bfe0b50c4 100644 --- a/extern/audaspace/plugins/ffmpeg/FFMPEG.cpp +++ b/extern/audaspace/plugins/ffmpeg/FFMPEG.cpp @@ -35,7 +35,7 @@ void FFMPEG::registerPlugin() FileManager::registerOutput(plugin); } -std::shared_ptr FFMPEG::createReader(std::string filename, int stream) +std::shared_ptr FFMPEG::createReader(const std::string &filename, int stream) { return std::shared_ptr(new FFMPEGReader(filename, stream)); } @@ -45,7 +45,7 @@ std::shared_ptr FFMPEG::createReader(std::shared_ptr buffer, in return std::shared_ptr(new FFMPEGReader(buffer, stream)); } -std::vector FFMPEG::queryStreams(std::string filename) +std::vector FFMPEG::queryStreams(const std::string &filename) { return FFMPEGReader(filename).queryStreams(); } @@ -55,7 +55,7 @@ std::vector FFMPEG::queryStreams(std::shared_ptr buffer) return FFMPEGReader(buffer).queryStreams(); } -std::shared_ptr FFMPEG::createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) +std::shared_ptr FFMPEG::createWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) { return std::shared_ptr(new FFMPEGWriter(filename, specs, format, codec, bitrate)); } diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEG.h b/extern/audaspace/plugins/ffmpeg/FFMPEG.h index fb40ba05573..974e3350b2d 100644 --- a/extern/audaspace/plugins/ffmpeg/FFMPEG.h +++ b/extern/audaspace/plugins/ffmpeg/FFMPEG.h @@ -52,11 +52,11 @@ public: */ static void registerPlugin(); - virtual std::shared_ptr createReader(std::string filename, int stream = 0); + virtual std::shared_ptr createReader(const std::string &filename, int stream = 0); virtual std::shared_ptr createReader(std::shared_ptr buffer, int stream = 0); - virtual std::vector queryStreams(std::string filename); + virtual std::vector queryStreams(const std::string &filename); virtual std::vector queryStreams(std::shared_ptr buffer); - virtual std::shared_ptr createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); + virtual std::shared_ptr createWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); }; AUD_NAMESPACE_END diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp index 5035ed05be5..c0e16d6a887 100644 --- a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp +++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp @@ -239,7 +239,7 @@ void FFMPEGReader::init(int stream) m_specs.rate = (SampleRate) m_codecCtx->sample_rate; } -FFMPEGReader::FFMPEGReader(std::string filename, int stream) : +FFMPEGReader::FFMPEGReader(const std::string &filename, int stream) : m_pkgbuf(), m_formatCtx(nullptr), m_codecCtx(nullptr), diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h index ca0e8b024aa..dc8c292c0ed 100644 --- a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h +++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h @@ -154,7 +154,7 @@ public: * \exception Exception Thrown if the file specified does not exist or * cannot be read with ffmpeg. */ - FFMPEGReader(std::string filename, int stream = 0); + FFMPEGReader(const std::string &filename, int stream = 0); /** * Creates a new reader. diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp index ae6558ccfa5..9cadfe9c092 100644 --- a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp +++ b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp @@ -158,7 +158,7 @@ void FFMPEGWriter::close() #endif } -FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) : +FFMPEGWriter::FFMPEGWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) : m_position(0), m_specs(specs), m_formatCtx(nullptr), diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h index c22f479d83c..7e39d8cb92b 100644 --- a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h +++ b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.h @@ -135,7 +135,7 @@ public: * \exception Exception Thrown if the file specified does not exist or * cannot be read with ffmpeg. */ - FFMPEGWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); + FFMPEGWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); /** * Destroys the writer and closes the file. diff --git a/extern/audaspace/plugins/jack/JackDevice.cpp b/extern/audaspace/plugins/jack/JackDevice.cpp index 32874fd1315..e949d9e64e9 100644 --- a/extern/audaspace/plugins/jack/JackDevice.cpp +++ b/extern/audaspace/plugins/jack/JackDevice.cpp @@ -162,7 +162,7 @@ void JackDevice::jack_shutdown(void* data) device->m_valid = false; } -JackDevice::JackDevice(std::string name, DeviceSpecs specs, int buffersize) : +JackDevice::JackDevice(const std::string &name, DeviceSpecs specs, int buffersize) : m_synchronizer(this) { if(specs.channels == CHANNELS_INVALID) @@ -358,7 +358,7 @@ public: m_buffersize = buffersize; } - virtual void setName(std::string name) + virtual void setName(const std::string &name) { m_name = name; } diff --git a/extern/audaspace/plugins/jack/JackDevice.h b/extern/audaspace/plugins/jack/JackDevice.h index 4e6b1f5d12c..7fd1e062846 100644 --- a/extern/audaspace/plugins/jack/JackDevice.h +++ b/extern/audaspace/plugins/jack/JackDevice.h @@ -151,7 +151,7 @@ public: * \param buffersize The size of the internal buffer. * \exception Exception Thrown if the audio device cannot be opened. */ - JackDevice(std::string name, DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE); + JackDevice(const std::string &name, DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE); /** * Closes the JACK client. diff --git a/extern/audaspace/plugins/libsndfile/SndFile.cpp b/extern/audaspace/plugins/libsndfile/SndFile.cpp index 39335de9a1a..851af888511 100644 --- a/extern/audaspace/plugins/libsndfile/SndFile.cpp +++ b/extern/audaspace/plugins/libsndfile/SndFile.cpp @@ -32,7 +32,7 @@ void SndFile::registerPlugin() FileManager::registerOutput(plugin); } -std::shared_ptr SndFile::createReader(std::string filename, int stream) +std::shared_ptr SndFile::createReader(const std::string &filename, int stream) { return std::shared_ptr(new SndFileReader(filename)); } @@ -42,7 +42,7 @@ std::shared_ptr SndFile::createReader(std::shared_ptr buffer, i return std::shared_ptr(new SndFileReader(buffer)); } -std::vector SndFile::queryStreams(std::string filename) +std::vector SndFile::queryStreams(const std::string &filename) { return SndFileReader(filename).queryStreams(); } @@ -52,7 +52,7 @@ std::vector SndFile::queryStreams(std::shared_ptr buffer) return SndFileReader(buffer).queryStreams(); } -std::shared_ptr SndFile::createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) +std::shared_ptr SndFile::createWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) { return std::shared_ptr(new SndFileWriter(filename, specs, format, codec, bitrate)); } diff --git a/extern/audaspace/plugins/libsndfile/SndFile.h b/extern/audaspace/plugins/libsndfile/SndFile.h index 10a7391180f..ccd49b24882 100644 --- a/extern/audaspace/plugins/libsndfile/SndFile.h +++ b/extern/audaspace/plugins/libsndfile/SndFile.h @@ -52,11 +52,11 @@ public: */ static void registerPlugin(); - virtual std::shared_ptr createReader(std::string filename, int stream = 0); + virtual std::shared_ptr createReader(const std::string &filename, int stream = 0); virtual std::shared_ptr createReader(std::shared_ptr buffer, int stream = 0); - virtual std::vector queryStreams(std::string filename); + virtual std::vector queryStreams(const std::string &filename); virtual std::vector queryStreams(std::shared_ptr buffer); - virtual std::shared_ptr createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); + virtual std::shared_ptr createWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); }; AUD_NAMESPACE_END diff --git a/extern/audaspace/plugins/libsndfile/SndFileReader.cpp b/extern/audaspace/plugins/libsndfile/SndFileReader.cpp index 21c733d8117..f141adb43a5 100644 --- a/extern/audaspace/plugins/libsndfile/SndFileReader.cpp +++ b/extern/audaspace/plugins/libsndfile/SndFileReader.cpp @@ -71,7 +71,7 @@ sf_count_t SndFileReader::vio_tell(void* user_data) return reader->m_memoffset; } -SndFileReader::SndFileReader(std::string filename) : +SndFileReader::SndFileReader(const std::string &filename) : m_position(0) { SF_INFO sfinfo; diff --git a/extern/audaspace/plugins/libsndfile/SndFileReader.h b/extern/audaspace/plugins/libsndfile/SndFileReader.h index b4158d9091a..bd2f766e088 100644 --- a/extern/audaspace/plugins/libsndfile/SndFileReader.h +++ b/extern/audaspace/plugins/libsndfile/SndFileReader.h @@ -103,7 +103,7 @@ public: * \exception Exception Thrown if the file specified does not exist or * cannot be read with libsndfile. */ - SndFileReader(std::string filename); + SndFileReader(const std::string &filename); /** * Creates a new reader. diff --git a/extern/audaspace/plugins/libsndfile/SndFileWriter.cpp b/extern/audaspace/plugins/libsndfile/SndFileWriter.cpp index d2ab117132d..e1a57d289de 100644 --- a/extern/audaspace/plugins/libsndfile/SndFileWriter.cpp +++ b/extern/audaspace/plugins/libsndfile/SndFileWriter.cpp @@ -21,7 +21,7 @@ AUD_NAMESPACE_BEGIN -SndFileWriter::SndFileWriter(std::string filename, DeviceSpecs specs, +SndFileWriter::SndFileWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) : m_position(0), m_specs(specs) { diff --git a/extern/audaspace/plugins/libsndfile/SndFileWriter.h b/extern/audaspace/plugins/libsndfile/SndFileWriter.h index 75d761f5163..c4e4fad627c 100644 --- a/extern/audaspace/plugins/libsndfile/SndFileWriter.h +++ b/extern/audaspace/plugins/libsndfile/SndFileWriter.h @@ -69,7 +69,7 @@ public: * \exception Exception Thrown if the file specified cannot be written * with libsndfile. */ - SndFileWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); + SndFileWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate); /** * Destroys the writer and closes the file. diff --git a/extern/audaspace/plugins/openal/OpenALDevice.cpp b/extern/audaspace/plugins/openal/OpenALDevice.cpp index 536ec4ccb1b..2e9c9d63631 100644 --- a/extern/audaspace/plugins/openal/OpenALDevice.cpp +++ b/extern/audaspace/plugins/openal/OpenALDevice.cpp @@ -1131,7 +1131,7 @@ void OpenALDevice::updateStreams() /**************************** IDevice Code ************************************/ /******************************************************************************/ -OpenALDevice::OpenALDevice(DeviceSpecs specs, int buffersize, std::string name) : +OpenALDevice::OpenALDevice(DeviceSpecs specs, int buffersize, const std::string &name) : m_name(name), m_playing(false), m_buffersize(buffersize) { // cannot determine how many channels or which format OpenAL uses, but @@ -1561,7 +1561,7 @@ private: std::string m_name; public: - OpenALDeviceFactory(std::string name = "") : + OpenALDeviceFactory(const std::string &name = "") : m_buffersize(AUD_DEFAULT_BUFFER_SIZE), m_name(name) { @@ -1590,7 +1590,7 @@ public: m_buffersize = buffersize; } - virtual void setName(std::string name) + virtual void setName(const std::string &name) { } }; @@ -1599,7 +1599,7 @@ void OpenALDevice::registerPlugin() { auto names = OpenALDevice::getDeviceNames(); DeviceManager::registerDevice("OpenAL", std::shared_ptr(new OpenALDeviceFactory)); - for(std::string &name : names) + for(const std::string &name : names) { DeviceManager::registerDevice("OpenAL - " + name, std::shared_ptr(new OpenALDeviceFactory(name))); } diff --git a/extern/audaspace/plugins/openal/OpenALDevice.h b/extern/audaspace/plugins/openal/OpenALDevice.h index b6ba5456d85..f16851d12eb 100644 --- a/extern/audaspace/plugins/openal/OpenALDevice.h +++ b/extern/audaspace/plugins/openal/OpenALDevice.h @@ -269,7 +269,7 @@ public: * \note The buffersize will be multiplicated by three for this device. * \exception DeviceException Thrown if the audio device cannot be opened. */ - OpenALDevice(DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE, std::string name = ""); + OpenALDevice(DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE, const std::string &name = ""); virtual ~OpenALDevice(); diff --git a/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.cpp b/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.cpp index d2de89977a9..a018e9e4cf2 100644 --- a/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.cpp +++ b/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.cpp @@ -121,7 +121,7 @@ void PulseAudioDevice::playing(bool playing) AUD_pa_threaded_mainloop_unlock(m_mainloop); } -PulseAudioDevice::PulseAudioDevice(std::string name, DeviceSpecs specs, int buffersize) : +PulseAudioDevice::PulseAudioDevice(const std::string &name, DeviceSpecs specs, int buffersize) : m_synchronizer(this), m_playback(false), m_state(PA_CONTEXT_UNCONNECTED), @@ -321,7 +321,7 @@ public: m_buffersize = buffersize; } - virtual void setName(std::string name) + virtual void setName(const std::string &name) { m_name = name; } diff --git a/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.h b/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.h index 57359110633..23306168173 100644 --- a/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.h +++ b/extern/audaspace/plugins/pulseaudio/PulseAudioDevice.h @@ -128,7 +128,7 @@ public: * \note The specification really used for opening the device may differ. * \exception Exception Thrown if the audio device cannot be opened. */ - PulseAudioDevice(std::string name, DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE); + PulseAudioDevice(const std::string &name, DeviceSpecs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE); /** * Closes the PulseAudio audio device. diff --git a/extern/audaspace/plugins/sdl/SDLDevice.cpp b/extern/audaspace/plugins/sdl/SDLDevice.cpp index 8d7a605fa36..55bddb5fb30 100644 --- a/extern/audaspace/plugins/sdl/SDLDevice.cpp +++ b/extern/audaspace/plugins/sdl/SDLDevice.cpp @@ -157,7 +157,7 @@ public: m_buffersize = buffersize; } - virtual void setName(std::string name) + virtual void setName(const std::string &name) { } }; diff --git a/extern/audaspace/plugins/wasapi/WASAPIDevice.cpp b/extern/audaspace/plugins/wasapi/WASAPIDevice.cpp index cbf35520c3d..3beb962e2b7 100644 --- a/extern/audaspace/plugins/wasapi/WASAPIDevice.cpp +++ b/extern/audaspace/plugins/wasapi/WASAPIDevice.cpp @@ -458,7 +458,7 @@ public: m_buffersize = buffersize; } - virtual void setName(std::string name) + virtual void setName(const std::string &name) { } }; diff --git a/extern/audaspace/src/Exception.cpp b/extern/audaspace/src/Exception.cpp index 1c31cb29555..bd2a1f5d6e4 100644 --- a/extern/audaspace/src/Exception.cpp +++ b/extern/audaspace/src/Exception.cpp @@ -25,7 +25,7 @@ Exception::Exception(const Exception& exception) : { } -Exception::Exception(std::string message, std::string file, int line) : +Exception::Exception(const std::string &message, const std::string &file, int line) : m_message(message), m_file(file), m_line(line) @@ -65,7 +65,7 @@ int Exception::getLine() const return m_line; } -FileException::FileException(std::string message, std::string file, int line) : +FileException::FileException(const std::string &message, const std::string &file, int line) : Exception(message, file, line) { } @@ -79,7 +79,7 @@ FileException::~FileException() AUD_NOEXCEPT { } -DeviceException::DeviceException(std::string message, std::string file, int line) : +DeviceException::DeviceException(const std::string &message, const std::string &file, int line) : Exception(message, file, line) { } @@ -93,7 +93,7 @@ DeviceException::~DeviceException() AUD_NOEXCEPT { } -StateException::StateException(std::string message, std::string file, int line) : +StateException::StateException(const std::string &message, const std::string &file, int line) : Exception(message, file, line) { } diff --git a/extern/audaspace/src/devices/DeviceManager.cpp b/extern/audaspace/src/devices/DeviceManager.cpp index 304f8b49f70..74c374568c4 100644 --- a/extern/audaspace/src/devices/DeviceManager.cpp +++ b/extern/audaspace/src/devices/DeviceManager.cpp @@ -28,12 +28,12 @@ AUD_NAMESPACE_BEGIN std::unordered_map> DeviceManager::m_factories; std::shared_ptr DeviceManager::m_device; -void DeviceManager::registerDevice(std::string name, std::shared_ptr factory) +void DeviceManager::registerDevice(const std::string &name, std::shared_ptr factory) { m_factories[name] = factory; } -std::shared_ptr DeviceManager::getDeviceFactory(std::string name) +std::shared_ptr DeviceManager::getDeviceFactory(const std::string &name) { auto it = m_factories.find(name); @@ -66,7 +66,7 @@ void DeviceManager::setDevice(std::shared_ptr device) m_device = device; } -void DeviceManager::openDevice(std::string name) +void DeviceManager::openDevice(const std::string &name) { setDevice(getDeviceFactory(name)->openDevice()); } diff --git a/extern/audaspace/src/devices/NULLDevice.cpp b/extern/audaspace/src/devices/NULLDevice.cpp index fa8e457dbd2..c90dfff6d75 100644 --- a/extern/audaspace/src/devices/NULLDevice.cpp +++ b/extern/audaspace/src/devices/NULLDevice.cpp @@ -180,7 +180,7 @@ public: { } - virtual void setName(std::string name) + virtual void setName(const std::string &name) { } }; diff --git a/extern/audaspace/src/devices/SoftwareDevice.cpp b/extern/audaspace/src/devices/SoftwareDevice.cpp index e11b49a0967..f9ad6f767d3 100644 --- a/extern/audaspace/src/devices/SoftwareDevice.cpp +++ b/extern/audaspace/src/devices/SoftwareDevice.cpp @@ -718,7 +718,7 @@ void SoftwareDevice::create() m_doppler_factor = 1.0f; m_distance_model = DISTANCE_MODEL_INVERSE_CLAMPED; m_flags = 0; - m_quality = false; + m_quality = ResampleQuality::FASTEST; } void SoftwareDevice::destroy() @@ -829,7 +829,7 @@ void SoftwareDevice::setPanning(IHandle* handle, float pan) h->m_user_pan = pan; } -void SoftwareDevice::setQuality(bool quality) +void SoftwareDevice::setQuality(ResampleQuality quality) { m_quality = quality; } @@ -886,10 +886,14 @@ std::shared_ptr SoftwareDevice::play(std::shared_ptr reader, b std::shared_ptr resampler; // resample - if(m_quality) - resampler = std::shared_ptr(new JOSResampleReader(reader, m_specs.rate)); - else + if (m_quality == ResampleQuality::FASTEST) + { resampler = std::shared_ptr(new LinearResampleReader(reader, m_specs.rate)); + } + else + { + resampler = std::shared_ptr(new JOSResampleReader(reader, m_specs.rate, m_quality)); + } reader = std::shared_ptr(resampler); // rechannel diff --git a/extern/audaspace/src/file/File.cpp b/extern/audaspace/src/file/File.cpp index 5d4bae482d6..6900ec81ce1 100644 --- a/extern/audaspace/src/file/File.cpp +++ b/extern/audaspace/src/file/File.cpp @@ -23,7 +23,7 @@ AUD_NAMESPACE_BEGIN -File::File(std::string filename, int stream) : +File::File(const std::string &filename, int stream) : m_filename(filename), m_stream(stream) { } diff --git a/extern/audaspace/src/file/FileManager.cpp b/extern/audaspace/src/file/FileManager.cpp index 7cbc0318f8c..44ede9baef0 100644 --- a/extern/audaspace/src/file/FileManager.cpp +++ b/extern/audaspace/src/file/FileManager.cpp @@ -43,7 +43,7 @@ void FileManager::registerOutput(std::shared_ptr output) outputs().push_back(output); } -std::shared_ptr FileManager::createReader(std::string filename, int stream) +std::shared_ptr FileManager::createReader(const std::string &filename, int stream) { for(std::shared_ptr input : inputs()) { @@ -71,7 +71,7 @@ std::shared_ptr FileManager::createReader(std::shared_ptr buffe AUD_THROW(FileException, "The file couldn't be read with any installed file reader."); } -std::vector FileManager::queryStreams(std::string filename) +std::vector FileManager::queryStreams(const std::string &filename) { for(std::shared_ptr input : inputs()) { @@ -99,7 +99,7 @@ std::vector FileManager::queryStreams(std::shared_ptr buffer AUD_THROW(FileException, "The file couldn't be read with any installed file reader."); } -std::shared_ptr FileManager::createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) +std::shared_ptr FileManager::createWriter(const std::string &filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) { for(std::shared_ptr output : outputs()) { diff --git a/extern/audaspace/src/file/FileWriter.cpp b/extern/audaspace/src/file/FileWriter.cpp index b28bbc5329d..32aa5264b4a 100644 --- a/extern/audaspace/src/file/FileWriter.cpp +++ b/extern/audaspace/src/file/FileWriter.cpp @@ -22,7 +22,7 @@ AUD_NAMESPACE_BEGIN -std::shared_ptr FileWriter::createWriter(std::string filename,DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) +std::shared_ptr FileWriter::createWriter(const std::string &filename,DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate) { return FileManager::createWriter(filename, specs, format, codec, bitrate); } diff --git a/extern/audaspace/src/respec/JOSResample.cpp b/extern/audaspace/src/respec/JOSResample.cpp index fae116d057a..774cdf7cee4 100644 --- a/extern/audaspace/src/respec/JOSResample.cpp +++ b/extern/audaspace/src/respec/JOSResample.cpp @@ -19,15 +19,14 @@ AUD_NAMESPACE_BEGIN -JOSResample::JOSResample(std::shared_ptr sound, - DeviceSpecs specs) : - SpecsChanger(sound, specs) +JOSResample::JOSResample(std::shared_ptr sound, DeviceSpecs specs, ResampleQuality quality) : + SpecsChanger(sound, specs), m_quality(quality) { } std::shared_ptr JOSResample::createReader() { - return std::shared_ptr(new JOSResampleReader(getReader(), m_specs.rate)); + return std::shared_ptr(new JOSResampleReader(getReader(), m_specs.rate, m_quality)); } AUD_NAMESPACE_END diff --git a/extern/audaspace/src/respec/JOSResampleReader.cpp b/extern/audaspace/src/respec/JOSResampleReader.cpp index a4321bd3a19..1fc00f62f73 100644 --- a/extern/audaspace/src/respec/JOSResampleReader.cpp +++ b/extern/audaspace/src/respec/JOSResampleReader.cpp @@ -45,7 +45,7 @@ static inline int lrint_impl(double x) AUD_NAMESPACE_BEGIN -JOSResampleReader::JOSResampleReader(std::shared_ptr reader, SampleRate rate, Quality quality) : +JOSResampleReader::JOSResampleReader(std::shared_ptr reader, SampleRate rate, ResampleQuality quality) : ResampleReader(reader, rate), m_channels(CHANNELS_INVALID), m_n(0), @@ -55,17 +55,17 @@ JOSResampleReader::JOSResampleReader(std::shared_ptr reader, SampleRate { switch(quality) { - case Quality::LOW: + case ResampleQuality::LOW: m_len = m_len_low; m_L = m_L_low; m_coeff = m_coeff_low; break; - case Quality::MEDIUM: + case ResampleQuality::MEDIUM: m_len = m_len_medium; m_L = m_L_medium; m_coeff = m_coeff_medium; break; - case Quality::HIGH: + case ResampleQuality::HIGH: m_len = m_len_high; m_L = m_L_high; m_coeff = m_coeff_high; diff --git a/extern/audaspace/src/sequence/Sequence.cpp b/extern/audaspace/src/sequence/Sequence.cpp index 3beb225d4ee..e5411d099e1 100644 --- a/extern/audaspace/src/sequence/Sequence.cpp +++ b/extern/audaspace/src/sequence/Sequence.cpp @@ -100,9 +100,9 @@ void Sequence::remove(std::shared_ptr entry) m_sequence->remove(entry); } -std::shared_ptr Sequence::createQualityReader() +std::shared_ptr Sequence::createQualityReader(ResampleQuality quality) { - return std::shared_ptr(new SequenceReader(m_sequence, true)); + return std::shared_ptr(new SequenceReader(m_sequence, quality)); } std::shared_ptr Sequence::createReader() diff --git a/extern/audaspace/src/sequence/SequenceReader.cpp b/extern/audaspace/src/sequence/SequenceReader.cpp index c903e8ef42e..535ed7e8406 100644 --- a/extern/audaspace/src/sequence/SequenceReader.cpp +++ b/extern/audaspace/src/sequence/SequenceReader.cpp @@ -25,7 +25,7 @@ AUD_NAMESPACE_BEGIN -SequenceReader::SequenceReader(std::shared_ptr sequence, bool quality) : +SequenceReader::SequenceReader(std::shared_ptr sequence, ResampleQuality quality) : m_position(0), m_device(sequence->m_specs), m_sequence(sequence), m_status(0), m_entry_status(0) { m_device.setQuality(quality); diff --git a/release/license/THIRD-PARTY-LICENSES.txt b/release/license/THIRD-PARTY-LICENSES.txt index ef00fc9d31a..337807f80eb 100644 --- a/release/license/THIRD-PARTY-LICENSES.txt +++ b/release/license/THIRD-PARTY-LICENSES.txt @@ -19,7 +19,7 @@ PERFORMANCE OF THIS SOFTWARE. ------ -** Audaspace; version 1.3.0 -- https://audaspace.github.io/ +** Audaspace; version 1.4+ (ae29ce2) -- https://audaspace.github.io/ ** Cuda Wrangler; version cbf465b -- https://github.com/CudaWrangler/cuew ** Draco; version 1.3.6 -- https://google.github.io/draco/ ** Embree; version 4.1.0 -- https://github.com/embree/embree @@ -244,7 +244,7 @@ See the License for the specific language governing permissions and limitations under the License. * For Audaspace see also this required NOTICE: - Copyright © 2009-2020 Jörg Müller. All rights reserved. + Copyright © 2009-2023 Jörg Müller. All rights reserved. * For Cuda Wrangler see also this required NOTICE: Copyright 2011-2014 Blender Foundation * For Draco see also this required NOTICE: diff --git a/source/blender/blenkernel/intern/sound.cc b/source/blender/blenkernel/intern/sound.cc index e677bca6e0e..50ec2c9e611 100644 --- a/source/blender/blenkernel/intern/sound.cc +++ b/source/blender/blenkernel/intern/sound.cc @@ -599,7 +599,8 @@ void BKE_sound_load(Main *bmain, bSound *sound) AUD_Device *BKE_sound_mixdown(const Scene *scene, AUD_DeviceSpecs specs, int start, float volume) { sound_verify_evaluated_id(&scene->id); - return AUD_openMixdownDevice(specs, scene->sound_scene, volume, start / FPS); + return AUD_openMixdownDevice( + specs, scene->sound_scene, volume, AUD_RESAMPLE_QUALITY_MEDIUM, start / FPS); } void BKE_sound_create_scene(Scene *scene) diff --git a/source/blender/editors/sound/sound_ops.cc b/source/blender/editors/sound/sound_ops.cc index 1f7d0dcbc07..b8a63271db9 100644 --- a/source/blender/editors/sound/sound_ops.cc +++ b/source/blender/editors/sound/sound_ops.cc @@ -370,6 +370,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) container, codec, bitrate, + AUD_RESAMPLE_QUALITY_MEDIUM, nullptr, nullptr, error_message, @@ -385,6 +386,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) container, codec, bitrate, + AUD_RESAMPLE_QUALITY_MEDIUM, nullptr, nullptr, error_message,