| 1 |
/* |
| 2 |
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 |
* (C) 2025 Vladimir Sadovnikov <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of lsp-runtime-lib |
| 6 |
* Created on: 24 окт. 2022 г. |
| 7 |
* |
| 8 |
* lsp-runtime-lib is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* lsp-runtime-lib is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public License |
| 19 |
* along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef LSP_PLUG_IN_FMT_LSPC_UTIL_AUDIO_H_ |
| 23 |
#define LSP_PLUG_IN_FMT_LSPC_UTIL_AUDIO_H_ |
| 24 |
|
| 25 |
#include <lsp-plug.in/runtime/version.h> |
| 26 |
|
| 27 |
#include <lsp-plug.in/common/status.h> |
| 28 |
#include <lsp-plug.in/fmt/lspc/File.h> |
| 29 |
#include <lsp-plug.in/fmt/lspc/IAudioFormatSelector.h> |
| 30 |
#include <lsp-plug.in/mm/IInAudioStream.h> |
| 31 |
#include <lsp-plug.in/mm/IOutAudioStream.h> |
| 32 |
#include <lsp-plug.in/io/Path.h> |
| 33 |
#include <lsp-plug.in/runtime/LSPString.h> |
| 34 |
|
| 35 |
namespace lsp |
| 36 |
{ |
| 37 |
namespace lspc |
| 38 |
{ |
| 39 |
/** |
| 40 |
* Write audio file as a dedicated chunk to the LSPC file |
| 41 |
* @param chunk_id pointer to store allocated chunk identifier, can be NULL |
| 42 |
* @param file the LSPC file to write the chunk |
| 43 |
* @param path path to file to write |
| 44 |
* @param selector audio format selector, default one will be used if none provided |
| 45 |
* @param buf_size size of buffer for I/O operations |
| 46 |
* @return status of operation |
| 47 |
*/ |
| 48 |
LSP_RUNTIME_LIB_PUBLIC |
| 49 |
status_t write_audio( |
| 50 |
chunk_id_t *chunk_id, File *file, |
| 51 |
const char *path, IAudioFormatSelector *selector = NULL, size_t buf_size = 0x1000); |
| 52 |
|
| 53 |
LSP_RUNTIME_LIB_PUBLIC |
| 54 |
status_t write_audio( |
| 55 |
chunk_id_t *chunk_id, File *file, |
| 56 |
const io::Path *path, IAudioFormatSelector *selector = NULL, size_t buf_size = 0x1000); |
| 57 |
|
| 58 |
LSP_RUNTIME_LIB_PUBLIC |
| 59 |
status_t write_audio( |
| 60 |
chunk_id_t *chunk_id, File *file, |
| 61 |
const LSPString *path, IAudioFormatSelector *selector = NULL, size_t buf_size = 0x1000); |
| 62 |
|
| 63 |
/** |
| 64 |
* Write audio entry from memory to the LSPC file |
| 65 |
* @param chunk_id pointer to store allocated chunk identifier, can be NULL |
| 66 |
* @param file the LSPC file to write the chunk |
| 67 |
* @param frames pointer to the array with packed frames |
| 68 |
* @param params audio parameters |
| 69 |
* @return status of operation |
| 70 |
*/ |
| 71 |
LSP_RUNTIME_LIB_PUBLIC |
| 72 |
status_t write_audio( |
| 73 |
chunk_id_t *chunk_id, File *file, |
| 74 |
const float *frames, const audio_parameters_t *params); |
| 75 |
|
| 76 |
/** |
| 77 |
* Write audio file as a dedicated chunk to the LSPC file |
| 78 |
* @param chunk_id pointer to store allocated chunk identifier, can be NULL |
| 79 |
* @param file the LSPC file to write the chunk |
| 80 |
* @param is audio input stream to read data |
| 81 |
* @param selector audio format selector, default one will be used if none provided |
| 82 |
* @param buf_size size of buffer for I/O operations |
| 83 |
* @return status of operation |
| 84 |
*/ |
| 85 |
LSP_RUNTIME_LIB_PUBLIC |
| 86 |
status_t write_audio( |
| 87 |
chunk_id_t *chunk_id, File *file, |
| 88 |
mm::IInAudioStream *is, IAudioFormatSelector *selector = NULL, size_t buf_size = 0x1000); |
| 89 |
|
| 90 |
|
| 91 |
/** |
| 92 |
* Read audio entry from LSPC file to other file |
| 93 |
* @param chunk_id chunk identifier |
| 94 |
* @param file the LSPC file to read the chunk |
| 95 |
* @param path path to destination file |
| 96 |
* @param format output audio format (@see mm::IOutAudioStream specificaion) |
| 97 |
* @param codec output audio codec (@see mm::IOutAudioStream specificaion) |
| 98 |
* @param buf_size size of buffer of I/O operations |
| 99 |
* @return status of operation |
| 100 |
*/ |
| 101 |
LSP_RUNTIME_LIB_PUBLIC |
| 102 |
status_t read_audio( |
| 103 |
chunk_id_t chunk_id, File *file, |
| 104 |
const char *path, size_t format, size_t codec, size_t buf_size = 0x1000); |
| 105 |
|
| 106 |
LSP_RUNTIME_LIB_PUBLIC |
| 107 |
status_t read_audio( |
| 108 |
chunk_id_t chunk_id, File *file, |
| 109 |
const LSPString *path, size_t format, size_t codec, size_t buf_size = 0x1000); |
| 110 |
|
| 111 |
LSP_RUNTIME_LIB_PUBLIC |
| 112 |
status_t read_audio( |
| 113 |
chunk_id_t chunk_id, File *file, |
| 114 |
const io::Path *path, size_t format, size_t codec, size_t buf_size = 0x1000); |
| 115 |
|
| 116 |
/** |
| 117 |
* Read audio entry to the memory buffer |
| 118 |
* @param chunk_id chunk identifier |
| 119 |
* @param file the LSPC file to read the chunk |
| 120 |
* @param frames pointer to store audio frames converted to f32 sample format, should be free()'d by caller |
| 121 |
* @param params audio parameters stored in the chunk |
| 122 |
* @return status of operation |
| 123 |
*/ |
| 124 |
LSP_RUNTIME_LIB_PUBLIC |
| 125 |
status_t read_audio( |
| 126 |
chunk_id_t chunk_id, File *file, |
| 127 |
float **frames, audio_parameters_t *params); |
| 128 |
|
| 129 |
/** |
| 130 |
* Read audio entry to the output audio stream |
| 131 |
* @param chunk_id chunk identifier |
| 132 |
* @param file the LSPC file to read the chunk |
| 133 |
* @param os pointer to the stream to commit sample data |
| 134 |
* @param params audio parameters stored in the chunk |
| 135 |
* @param buf_size size of buffer of I/O operations |
| 136 |
* @return status of operation |
| 137 |
*/ |
| 138 |
LSP_RUNTIME_LIB_PUBLIC |
| 139 |
status_t read_audio( |
| 140 |
chunk_id_t chunk_id, File *file, |
| 141 |
mm::IOutAudioStream *os, audio_parameters_t *params, size_t buf_size = 0x1000); |
| 142 |
|
| 143 |
/** |
| 144 |
* Read audio entry and return the pointer to the multimedia input stream |
| 145 |
* @param chunk_id chunk identifier |
| 146 |
* @param file the LSPC file to read the chunk |
| 147 |
* @param is pointer to store the multimedia audio stream |
| 148 |
* @return status of operation |
| 149 |
*/ |
| 150 |
LSP_RUNTIME_LIB_PUBLIC |
| 151 |
status_t read_audio(chunk_id_t chunk_id, File *file, mm::IInAudioStream **is); |
| 152 |
|
| 153 |
} /* namespace lspc */ |
| 154 |
} /* namespace lsp */ |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
#endif /* LSP_PLUG_IN_FMT_LSPC_UTIL_AUDIO_H_ */ |