Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extern/audaspace/include/file')
-rw-r--r--extern/audaspace/include/file/File.h74
-rw-r--r--extern/audaspace/include/file/FileManager.h95
-rw-r--r--extern/audaspace/include/file/FileWriter.h78
-rw-r--r--extern/audaspace/include/file/IFileInput.h60
-rw-r--r--extern/audaspace/include/file/IFileOutput.h52
-rw-r--r--extern/audaspace/include/file/IWriter.h89
6 files changed, 448 insertions, 0 deletions
diff --git a/extern/audaspace/include/file/File.h b/extern/audaspace/include/file/File.h
new file mode 100644
index 00000000000..24745a757e8
--- /dev/null
+++ b/extern/audaspace/include/file/File.h
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file File.h
+ * @ingroup file
+ * The File class.
+ */
+
+#include "ISound.h"
+
+#include <string>
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class Buffer;
+
+/**
+ * The File sound tries to read a sound file via all available file inputs
+ * that have been registered in the FileManager class.
+ */
+class AUD_API File : public ISound
+{
+private:
+ /**
+ * The filename of the sound source file.
+ */
+ std::string m_filename;
+
+ /**
+ * The buffer to read from.
+ */
+ std::shared_ptr<Buffer> m_buffer;
+
+ // delete copy constructor and operator=
+ File(const File&) = delete;
+ File& operator=(const File&) = delete;
+
+public:
+ /**
+ * Creates a new sound.
+ * The file is read from the file system using the given path.
+ * \param filename The sound file path.
+ */
+ File(std::string filename);
+
+ /**
+ * Creates a new sound.
+ * The file is read from memory using the supplied buffer.
+ * \param buffer The buffer to read from.
+ * \param size The size of the buffer.
+ */
+ File(const data_t* buffer, int size);
+
+ virtual std::shared_ptr<IReader> createReader();
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/file/FileManager.h b/extern/audaspace/include/file/FileManager.h
new file mode 100644
index 00000000000..03943ea8ae0
--- /dev/null
+++ b/extern/audaspace/include/file/FileManager.h
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file FileManager.h
+ * @ingroup file
+ * The FileManager class.
+ */
+
+#include "respec/Specification.h"
+#include "IWriter.h"
+
+#include <list>
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class IFileInput;
+class IFileOutput;
+class IReader;
+class Buffer;
+
+/**
+ * The FileManager manages all file input and output plugins.
+ */
+class AUD_API FileManager
+{
+private:
+ static std::list<std::shared_ptr<IFileInput>>& inputs();
+ static std::list<std::shared_ptr<IFileOutput>>& outputs();
+
+ // delete copy constructor and operator=
+ FileManager(const FileManager&) = delete;
+ FileManager& operator=(const FileManager&) = delete;
+ FileManager() = delete;
+
+public:
+ /**
+ * Registers a file input used to create an IReader to read from a file.
+ * @param input The IFileInput to register.
+ */
+ static void registerInput(std::shared_ptr<IFileInput> input);
+
+ /**
+ * Registers a file output used to create an IWriter to write to a file.
+ * @param output The IFileOutput to register.
+ */
+ static void registerOutput(std::shared_ptr<IFileOutput> output);
+
+ /**
+ * Creates a file reader for the given filename if a registed IFileInput is able to read it.
+ * @param filename The path to the file.
+ * @return The reader created.
+ * @exception Exception If no file input can read the file an exception is thrown.
+ */
+ static std::shared_ptr<IReader> createReader(std::string filename);
+
+ /**
+ * Creates a file reader for the given buffer if a registed IFileInput is able to read it.
+ * @param buffer The buffer to read the file from.
+ * @return The reader created.
+ * @exception Exception If no file input can read the file an exception is thrown.
+ */
+ static std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer);
+
+ /**
+ * Creates a file writer that writes a sound to the given file path.
+ * Existing files will be overwritten.
+ * @param filename The file path to write to.
+ * @param specs The output specification.
+ * @param format The container format for the file.
+ * @param codec The codec used inside the container.
+ * @param bitrate The bitrate to write with.
+ * @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<IWriter> createWriter(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
new file mode 100644
index 00000000000..dac842f2a8f
--- /dev/null
+++ b/extern/audaspace/include/file/FileWriter.h
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file FileWriter.h
+ * @ingroup file
+ * The FileWriter class.
+ */
+
+#include "respec/Specification.h"
+#include "file/IWriter.h"
+
+#include <string>
+#include <vector>
+#include <memory>
+
+AUD_NAMESPACE_BEGIN
+
+class IReader;
+
+/**
+ * The FileWriter class is able to create IWriter classes as well as write readers to them.
+ */
+class AUD_API FileWriter
+{
+private:
+ // hide default constructor, copy constructor and operator=
+ FileWriter() = delete;
+ FileWriter(const FileWriter&) = delete;
+ FileWriter& operator=(const FileWriter&) = delete;
+
+public:
+ /**
+ * Creates a new IWriter.
+ * \param filename The file to write to.
+ * \param specs The file's audio specification.
+ * \param format The file's container format.
+ * \param codec The codec used for encoding the audio data.
+ * \param bitrate The bitrate for encoding.
+ * \return The writer to write data to.
+ */
+ static std::shared_ptr<IWriter> createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate);
+
+ /**
+ * Writes a reader to a writer.
+ * \param reader The reader to read from.
+ * \param writer The writer to write to.
+ * \param length How many samples should be transferred.
+ * \param buffersize How many samples should be transferred at once.
+ */
+ static void writeReader(std::shared_ptr<IReader> reader, std::shared_ptr<IWriter> writer, unsigned int length, unsigned int buffersize);
+
+ /**
+ * Writes a reader to several writers.
+ * \param reader The reader to read from.
+ * \param writers The writers to write to.
+ * \param length How many samples should be transferred.
+ * \param buffersize How many samples should be transferred at once.
+ */
+ static void writeReader(std::shared_ptr<IReader> reader, std::vector<std::shared_ptr<IWriter> >& writers, unsigned int length, unsigned int buffersize);
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/file/IFileInput.h b/extern/audaspace/include/file/IFileInput.h
new file mode 100644
index 00000000000..bb016a88602
--- /dev/null
+++ b/extern/audaspace/include/file/IFileInput.h
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file IFileInput.h
+ * @ingroup file
+ * The IFileInput interface.
+ */
+
+#include "Audaspace.h"
+
+#include <memory>
+#include <string>
+
+AUD_NAMESPACE_BEGIN
+
+class IReader;
+class Buffer;
+
+/**
+ * @interface IFileInput
+ * The IFileInput interface represents a file input plugin that can create file
+ * input readers from filenames or buffers.
+ */
+class AUD_API IFileInput
+{
+public:
+ /**
+ * Creates a reader for a file to be read.
+ * \param filename Path to the file to be read.
+ * \return The reader that reads the file.
+ * \exception Exception Thrown if the file specified cannot be read.
+ */
+ virtual std::shared_ptr<IReader> createReader(std::string filename)=0;
+
+ /**
+ * Creates a reader for a file to be read from memory.
+ * \param buffer The in-memory file buffer.
+ * \return The reader that reads the file.
+ * \exception Exception Thrown if the file specified cannot be read.
+ */
+ virtual std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer)=0;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/file/IFileOutput.h b/extern/audaspace/include/file/IFileOutput.h
new file mode 100644
index 00000000000..5a6efacfe94
--- /dev/null
+++ b/extern/audaspace/include/file/IFileOutput.h
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file IFileOutput.h
+ * @ingroup file
+ * The IFileOutput interface.
+ */
+
+#include "file/IWriter.h"
+#include "respec/Specification.h"
+
+#include <memory>
+#include <string>
+
+AUD_NAMESPACE_BEGIN
+
+/**
+ * @interface IFileOutput
+ * The IFileOutput interface represents a file output plugin that can write files.
+ */
+class AUD_API IFileOutput
+{
+public:
+ /**
+ * Creates a new file writer.
+ * \param filename The path to the file to be written.
+ * \param specs The file's audio specification.
+ * \param format The file's container format.
+ * \param codec The codec used for encoding the audio data.
+ * \param bitrate The bitrate for encoding.
+ * \exception Exception Thrown if the file specified cannot be written.
+ */
+ virtual std::shared_ptr<IWriter> createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate)=0;
+};
+
+AUD_NAMESPACE_END
diff --git a/extern/audaspace/include/file/IWriter.h b/extern/audaspace/include/file/IWriter.h
new file mode 100644
index 00000000000..96decdda391
--- /dev/null
+++ b/extern/audaspace/include/file/IWriter.h
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright 2009-2016 Jörg Müller
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#pragma once
+
+/**
+ * @file IWriter.h
+ * @ingroup file
+ * Defines the IWriter interface as well as Container and Codec types.
+ */
+
+#include "respec/Specification.h"
+
+AUD_NAMESPACE_BEGIN
+
+/// Container formats for writers.
+enum Container
+{
+ CONTAINER_INVALID = 0,
+ CONTAINER_AC3,
+ CONTAINER_FLAC,
+ CONTAINER_MATROSKA,
+ CONTAINER_MP2,
+ CONTAINER_MP3,
+ CONTAINER_OGG,
+ CONTAINER_WAV
+};
+
+/// Audio codecs for writers.
+enum Codec
+{
+ CODEC_INVALID = 0,
+ CODEC_AAC,
+ CODEC_AC3,
+ CODEC_FLAC,
+ CODEC_MP2,
+ CODEC_MP3,
+ CODEC_PCM,
+ CODEC_VORBIS,
+ CODEC_OPUS
+};
+
+/**
+ * @interface IWriter
+ * This class represents a sound sink where audio data can be written to.
+ */
+class AUD_API IWriter
+{
+public:
+ /**
+ * Destroys the writer.
+ */
+ virtual ~IWriter() {}
+
+ /**
+ * Returns how many samples have been written so far.
+ * \return The writing position as sample count. May be negative if unknown.
+ */
+ virtual int getPosition() const=0;
+
+ /**
+ * Returns the specification of the audio data being written into the sink.
+ * \return The DeviceSpecs structure.
+ * \note Regardless of the format the input still has to be float!
+ */
+ virtual DeviceSpecs getSpecs() const=0;
+
+ /**
+ * Request to write the next length samples out into the sink.
+ * \param length The count of samples to write.
+ * \param buffer The pointer to the buffer containing the data.
+ */
+ virtual void write(unsigned int length, sample_t* buffer)=0;
+};
+
+AUD_NAMESPACE_END