vapoursynth-atools 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vapoursynth_atools-0.1.1/CMakeLists.txt +39 -0
- vapoursynth_atools-0.1.1/PKG-INFO +485 -0
- vapoursynth_atools-0.1.1/README.md +21 -0
- vapoursynth_atools-0.1.1/atools/.gitattributes +1 -0
- vapoursynth_atools-0.1.1/atools/.gitignore +32 -0
- vapoursynth_atools-0.1.1/atools/CMakeLists.txt +120 -0
- vapoursynth_atools-0.1.1/atools/LICENSE +21 -0
- vapoursynth_atools-0.1.1/atools/README.md +449 -0
- vapoursynth_atools-0.1.1/atools/include/vapoursynth/COPYING.LESSER +502 -0
- vapoursynth_atools-0.1.1/atools/include/vapoursynth/VSConstants4.h +94 -0
- vapoursynth_atools-0.1.1/atools/include/vapoursynth/VSHelper4.h +217 -0
- vapoursynth_atools-0.1.1/atools/include/vapoursynth/VSScript4.h +109 -0
- vapoursynth_atools-0.1.1/atools/include/vapoursynth/VapourSynth4.h +514 -0
- vapoursynth_atools-0.1.1/atools/src/common/offset.cpp +118 -0
- vapoursynth_atools-0.1.1/atools/src/common/offset.hpp +60 -0
- vapoursynth_atools-0.1.1/atools/src/common/overflow.cpp +83 -0
- vapoursynth_atools-0.1.1/atools/src/common/overflow.hpp +220 -0
- vapoursynth_atools-0.1.1/atools/src/common/peak.cpp +96 -0
- vapoursynth_atools-0.1.1/atools/src/common/peak.hpp +153 -0
- vapoursynth_atools-0.1.1/atools/src/common/sampletype.cpp +148 -0
- vapoursynth_atools-0.1.1/atools/src/common/sampletype.hpp +38 -0
- vapoursynth_atools-0.1.1/atools/src/common/transition.cpp +114 -0
- vapoursynth_atools-0.1.1/atools/src/common/transition.hpp +84 -0
- vapoursynth_atools-0.1.1/atools/src/config.hpp +13 -0
- vapoursynth_atools-0.1.1/atools/src/convert.cpp +394 -0
- vapoursynth_atools-0.1.1/atools/src/convert.hpp +52 -0
- vapoursynth_atools-0.1.1/atools/src/crossfade.cpp +522 -0
- vapoursynth_atools-0.1.1/atools/src/crossfade.hpp +79 -0
- vapoursynth_atools-0.1.1/atools/src/delay.cpp +414 -0
- vapoursynth_atools-0.1.1/atools/src/delay.hpp +75 -0
- vapoursynth_atools-0.1.1/atools/src/fade.cpp +245 -0
- vapoursynth_atools-0.1.1/atools/src/fade.hpp +80 -0
- vapoursynth_atools-0.1.1/atools/src/fadein.cpp +132 -0
- vapoursynth_atools-0.1.1/atools/src/fadein.hpp +7 -0
- vapoursynth_atools-0.1.1/atools/src/fadeout.cpp +132 -0
- vapoursynth_atools-0.1.1/atools/src/fadeout.hpp +7 -0
- vapoursynth_atools-0.1.1/atools/src/findpeak.cpp +70 -0
- vapoursynth_atools-0.1.1/atools/src/findpeak.hpp +7 -0
- vapoursynth_atools-0.1.1/atools/src/mix.cpp +803 -0
- vapoursynth_atools-0.1.1/atools/src/mix.hpp +118 -0
- vapoursynth_atools-0.1.1/atools/src/normalize.cpp +331 -0
- vapoursynth_atools-0.1.1/atools/src/normalize.hpp +58 -0
- vapoursynth_atools-0.1.1/atools/src/plugin.cpp +41 -0
- vapoursynth_atools-0.1.1/atools/src/setsamples.cpp +318 -0
- vapoursynth_atools-0.1.1/atools/src/setsamples.hpp +61 -0
- vapoursynth_atools-0.1.1/atools/src/sinetone.cpp +325 -0
- vapoursynth_atools-0.1.1/atools/src/sinetone.hpp +51 -0
- vapoursynth_atools-0.1.1/atools/src/utils/array.hpp +37 -0
- vapoursynth_atools-0.1.1/atools/src/utils/debug.hpp +8 -0
- vapoursynth_atools-0.1.1/atools/src/utils/map.hpp +48 -0
- vapoursynth_atools-0.1.1/atools/src/utils/number.hpp +62 -0
- vapoursynth_atools-0.1.1/atools/src/utils/sample.cpp +13 -0
- vapoursynth_atools-0.1.1/atools/src/utils/sample.hpp +119 -0
- vapoursynth_atools-0.1.1/atools/src/utils/string.cpp +21 -0
- vapoursynth_atools-0.1.1/atools/src/utils/string.hpp +11 -0
- vapoursynth_atools-0.1.1/atools/src/utils/vector.hpp +31 -0
- vapoursynth_atools-0.1.1/atools/src/vsmap/vsmap.cpp +383 -0
- vapoursynth_atools-0.1.1/atools/src/vsmap/vsmap.hpp +40 -0
- vapoursynth_atools-0.1.1/atools/src/vsmap/vsmap_common.cpp +151 -0
- vapoursynth_atools-0.1.1/atools/src/vsmap/vsmap_common.hpp +106 -0
- vapoursynth_atools-0.1.1/atools/src/vsutils/audio.cpp +163 -0
- vapoursynth_atools-0.1.1/atools/src/vsutils/audio.hpp +38 -0
- vapoursynth_atools-0.1.1/atools/src/vsutils/bitshift.hpp +26 -0
- vapoursynth_atools-0.1.1/pyproject.toml +83 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.18)
|
|
2
|
+
project(ATools_Package)
|
|
3
|
+
|
|
4
|
+
# === C++ Standard & Options ===
|
|
5
|
+
if(SKBUILD_PROJECT_VERSION)
|
|
6
|
+
set(VCS_TAG "v${SKBUILD_PROJECT_VERSION}" CACHE STRING "Version from scikit-build-core")
|
|
7
|
+
endif()
|
|
8
|
+
|
|
9
|
+
# === Dependencies ===
|
|
10
|
+
set(SUBMODULE_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/atools")
|
|
11
|
+
|
|
12
|
+
file(READ "${SUBMODULE_SRC_DIR}/CMakeLists.txt" SUBMODULE_CMAKE_CONTENT)
|
|
13
|
+
string(REPLACE "\${CMAKE_SOURCE_DIR}" "\${SUBMODULE_SRC_DIR}" MODIFIED_CMAKE_CONTENT "${SUBMODULE_CMAKE_CONTENT}")
|
|
14
|
+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/atools_generated/CMakeLists.txt" "${MODIFIED_CMAKE_CONTENT}")
|
|
15
|
+
|
|
16
|
+
# === Patch Submodule Type Mismatch ===
|
|
17
|
+
if(EXISTS "${SUBMODULE_SRC_DIR}/src/crossfade.cpp")
|
|
18
|
+
file(READ "${SUBMODULE_SRC_DIR}/src/crossfade.cpp" CROSSFADE_CONTENT)
|
|
19
|
+
if(CROSSFADE_CONTENT MATCHES "std::max\\(fadeSamples, 0LL\\)")
|
|
20
|
+
string(
|
|
21
|
+
REPLACE "std::max(fadeSamples, 0LL)"
|
|
22
|
+
"std::max<int64_t>(fadeSamples, 0)"
|
|
23
|
+
MODIFIED_CROSSFADE
|
|
24
|
+
"${CROSSFADE_CONTENT}"
|
|
25
|
+
)
|
|
26
|
+
file(WRITE "${SUBMODULE_SRC_DIR}/src/crossfade.cpp" "${MODIFIED_CROSSFADE}")
|
|
27
|
+
endif()
|
|
28
|
+
endif()
|
|
29
|
+
|
|
30
|
+
# === Target Definition & Configuration ===
|
|
31
|
+
add_subdirectory(
|
|
32
|
+
"${CMAKE_CURRENT_BINARY_DIR}/atools_generated"
|
|
33
|
+
"${CMAKE_CURRENT_BINARY_DIR}/atools_build"
|
|
34
|
+
EXCLUDE_FROM_ALL
|
|
35
|
+
)
|
|
36
|
+
add_custom_target(build_atools ALL DEPENDS AudioTools)
|
|
37
|
+
|
|
38
|
+
# === Packaging & Installation ===
|
|
39
|
+
install(TARGETS AudioTools RUNTIME DESTINATION . LIBRARY DESTINATION .)
|
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vapoursynth-atools
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Basic audio functions for VapourSynth
|
|
5
|
+
Author: ropagr
|
|
6
|
+
Maintainer-Email: =?utf-8?b?VmFyZMOr?= <ichunjo.le.terrible@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: atools/LICENSE
|
|
9
|
+
Project-URL: Source Code, https://github.com/ropagr/VS-AudioTools
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/ropagr/VS-AudioTools/issues
|
|
11
|
+
Project-URL: Repository, https://github.com/Jaded-Encoding-Thaumaturgy/vs-wheels
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Requires-Dist: vapoursynth>=75
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# VapourSynth ATools
|
|
17
|
+
|
|
18
|
+
This package contains the [VS-AudioTools](https://github.com/ropagr/VS-AudioTools) VapourSynth plugin.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install vapoursynth-atools
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Building from source
|
|
27
|
+
|
|
28
|
+
```powershell
|
|
29
|
+
uv build --package vapoursynth-atools
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
Detailed parameter information from the parent project follows.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
# VS-AudioTools
|
|
38
|
+
Some basic audio functions for VapourSynth.
|
|
39
|
+
|
|
40
|
+
[Convert](#convert)
|
|
41
|
+
[Crossfade](#crossfade)
|
|
42
|
+
[Delay](#delay)
|
|
43
|
+
[FadeIn](#fadein)
|
|
44
|
+
[FadeOut](#fadeout)
|
|
45
|
+
[FindPeak](#findpeak)
|
|
46
|
+
[Mix](#mix)
|
|
47
|
+
[Normalize](#normalize)
|
|
48
|
+
[SineTone](#sinetone)
|
|
49
|
+
|
|
50
|
+
[Overflow handling](#overflow-handling)
|
|
51
|
+
|
|
52
|
+
[Build from source](#build-from-source)
|
|
53
|
+
[License](#license)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## Convert
|
|
58
|
+
Convert the sample type.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
atools.Convert(clip: vs.AudioNode,
|
|
62
|
+
sample_type: str,
|
|
63
|
+
overflow: str = 'error',
|
|
64
|
+
overflow_log: str = 'once'
|
|
65
|
+
) -> vs.AudioNode
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
*clip* - input audio clip
|
|
69
|
+
|
|
70
|
+
*sample_type* - sample type of the output clip
|
|
71
|
+
```text
|
|
72
|
+
'i16' - integer 16-bit
|
|
73
|
+
'i24' - integer 24-bit
|
|
74
|
+
'i32' - integer 32-bit
|
|
75
|
+
'f32' - float 32-bit
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
*overflow* - sample overflow handling; default: 'error' - see [explanation below](#overflow-handling)
|
|
79
|
+
|
|
80
|
+
*overflow_log* - sample overflow logging; default: 'once' - see [explanation below](#overflow-handling)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## Crossfade
|
|
84
|
+
|
|
85
|
+
Crossfade two audio clips.
|
|
86
|
+
The output clip has the length: len(clip1) + len(clip2) - crossfade_samples
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
atools.Crossfade(clip1: vs.AudioNode,
|
|
90
|
+
clip2: vs.AudioNode,
|
|
91
|
+
samples: int = 0,
|
|
92
|
+
seconds: float = 0.0,
|
|
93
|
+
type: str = 'cubic',
|
|
94
|
+
overflow: str = 'error',
|
|
95
|
+
overflow_log: str = 'once'
|
|
96
|
+
) -> vs.AudioNode
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
*clip1* - first audio clip
|
|
100
|
+
|
|
101
|
+
*clip2* - second audio clip (same format as clip1)
|
|
102
|
+
|
|
103
|
+
*samples* - crossfade length in samples
|
|
104
|
+
|
|
105
|
+
*seconds* - crossfade length in seconds
|
|
106
|
+
|
|
107
|
+
*type* - fade transition type
|
|
108
|
+
```text
|
|
109
|
+
'linear' - linear transition
|
|
110
|
+
'cubic' - cubic transition (Cubic Hermite spline)
|
|
111
|
+
'sine' - sine transition
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
*overflow* - sample overflow handling; default: 'error' - see [explanation below](#overflow-handling)
|
|
115
|
+
|
|
116
|
+
*overflow_log* - sample overflow logging; default: 'once' - see [explanation below](#overflow-handling)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
## Delay
|
|
120
|
+
|
|
121
|
+
Delay (or shift) an audio clip. The output length stays the same.
|
|
122
|
+
This effect could be also achieved with scripting.
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
atools.Delay(clip: vs.AudioNode,
|
|
126
|
+
samples: int = 0,
|
|
127
|
+
seconds: float = 0.0,
|
|
128
|
+
channels: list[int] = None,
|
|
129
|
+
overflow: str = 'error',
|
|
130
|
+
overflow_log: str = 'once'
|
|
131
|
+
) -> vs.AudioNode
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
*clip* - input audio clip
|
|
135
|
+
|
|
136
|
+
*samples* - delay length in samples
|
|
137
|
+
|
|
138
|
+
*seconds* - delay length in seconds
|
|
139
|
+
|
|
140
|
+
*channels* - list of channels to delay; default: None (all channels)
|
|
141
|
+
|
|
142
|
+
*overflow* - sample overflow handling; default: 'error' - see [explanation below](#overflow-handling)
|
|
143
|
+
|
|
144
|
+
*overflow_log* - sample overflow logging; default: 'once' - see [explanation below](#overflow-handling)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
## FadeIn
|
|
148
|
+
|
|
149
|
+
Fade in an audio clip.
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
atools.FadeIn(clip: vs.AudioNode,
|
|
153
|
+
samples: int = 0,
|
|
154
|
+
seconds: float = 0.0,
|
|
155
|
+
start_sample: int = 0,
|
|
156
|
+
start_second: float = 0.0,
|
|
157
|
+
channels: list[int] = None,
|
|
158
|
+
type: str = 'cubic',
|
|
159
|
+
overflow: str = 'error',
|
|
160
|
+
overflow_log: str = 'once'
|
|
161
|
+
) -> vs.AudioNode
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
*clip* - input audio clip
|
|
165
|
+
|
|
166
|
+
*samples* - fade in length in samples
|
|
167
|
+
|
|
168
|
+
*seconds* - fade in length in seconds
|
|
169
|
+
|
|
170
|
+
*start_sample* - sample to start fading in
|
|
171
|
+
|
|
172
|
+
*start_second* - second to start fading in
|
|
173
|
+
|
|
174
|
+
*channels* - list of channels to fade in; default: None (all channels)
|
|
175
|
+
|
|
176
|
+
*type* - fade transition type
|
|
177
|
+
```text
|
|
178
|
+
'linear' - linear transition
|
|
179
|
+
'cubic' - cubic transition (Cubic Hermite spline)
|
|
180
|
+
'sine' - sine transition
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
*overflow* - sample overflow handling; default: 'error' - see [explanation below](#overflow-handling)
|
|
184
|
+
|
|
185
|
+
*overflow_log* - sample overflow logging; default: 'once' - see [explanation below](#overflow-handling)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
## FadeOut
|
|
189
|
+
|
|
190
|
+
Fade out an audio clip.
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
atools.FadeOut(clip: vs.AudioNode,
|
|
194
|
+
samples: int = 0,
|
|
195
|
+
seconds: float = 0.0,
|
|
196
|
+
end_sample: int = len(clip),
|
|
197
|
+
end_second: float = to_seconds(len(clip)),
|
|
198
|
+
channels: list[int] = None,
|
|
199
|
+
type: str = 'cubic',
|
|
200
|
+
overflow: str = 'error',
|
|
201
|
+
overflow_log: str = 'once'
|
|
202
|
+
) -> vs.AudioNode
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
*clip* - input audio clip
|
|
206
|
+
|
|
207
|
+
*samples* - fade out length in samples
|
|
208
|
+
|
|
209
|
+
*seconds* - fade out length in seconds
|
|
210
|
+
|
|
211
|
+
*end_sample* - sample to end fading out (exclusive!)
|
|
212
|
+
|
|
213
|
+
*end_second* - second to end fading out (exclusive!)
|
|
214
|
+
|
|
215
|
+
*channels* - list of channels to fade out; default: None (all channels)
|
|
216
|
+
|
|
217
|
+
*type* - fade transition type
|
|
218
|
+
```text
|
|
219
|
+
'linear' - linear transition
|
|
220
|
+
'cubic' - cubic transition (Cubic Hermite spline)
|
|
221
|
+
'sine' - sine transition
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
*overflow* - sample overflow handling; default: 'error' - see [explanation below](#overflow-handling)
|
|
225
|
+
|
|
226
|
+
*overflow_log* - sample overflow logging; default: 'once' - see [explanation below](#overflow-handling)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
## FindPeak
|
|
230
|
+
|
|
231
|
+
Return the peak value of all audio samples. This function is not an audio filter.
|
|
232
|
+
|
|
233
|
+
**Note**: Calling this function will read all audio frames in advance, which is a blocking process
|
|
234
|
+
and can take a while to complete depending on the audio length.
|
|
235
|
+
|
|
236
|
+
```python
|
|
237
|
+
atools.FindPeak(clip: vs.AudioNode,
|
|
238
|
+
normalize: bool = True,
|
|
239
|
+
channels: list[int] = None
|
|
240
|
+
) -> float
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
*clip* - input audio clip
|
|
244
|
+
|
|
245
|
+
*normalize* - if True returns a normalized peak value between 0 and 1,
|
|
246
|
+
otherwise returns the exact peak sample value; default: True
|
|
247
|
+
|
|
248
|
+
*channels* - list of channels to read; default: None (all channels)
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
## Mix
|
|
252
|
+
|
|
253
|
+
Mix two audio clips together. Optionally fade in / fade out clip2 respectively clip1 depending on the offset of clip2 and extend_start / extend_end.
|
|
254
|
+
This is a convenience function and can also be achieved with existing functions and scripting.
|
|
255
|
+
|
|
256
|
+
**Note**: This function is prone to overflowing. Please see the section about how to [handle overflows](#overflow-handling).
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
atools.Mix(clip1: vs.AudioNode,
|
|
260
|
+
clip2: vs.AudioNode,
|
|
261
|
+
clip2_offset_samples: int = 0,
|
|
262
|
+
clip2_offset_seconds: float = 0.0,
|
|
263
|
+
clip1_gain: float = 1.0,
|
|
264
|
+
clip2_gain: float = 1.0,
|
|
265
|
+
relative_gain: bool = False,
|
|
266
|
+
fadein_samples: int = 0,
|
|
267
|
+
fadein_seconds: float = 0.0,
|
|
268
|
+
fadeout_samples: int = 0,
|
|
269
|
+
fadeout_seconds: float = 0.0,
|
|
270
|
+
fade_type: str = 'cubic',
|
|
271
|
+
extend_start: bool = False,
|
|
272
|
+
extend_end: bool = False,
|
|
273
|
+
channels: list[int] = None,
|
|
274
|
+
overflow: str = 'error',
|
|
275
|
+
overflow_log: str = 'once'
|
|
276
|
+
) -> vs.AudioNode
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
*clip1* - base input audio clip
|
|
280
|
+
|
|
281
|
+
*clip2* - audio clip to mix into clip1 (same format as clip1)
|
|
282
|
+
|
|
283
|
+
*clip2_offset_samples* - sample position (relative to clip1) of where to mix clip2 into clip1;
|
|
284
|
+
can be negative
|
|
285
|
+
|
|
286
|
+
*clip2_offset_seconds* - time in seconds (relative to clip1) of where to mix clip2 into clip1;
|
|
287
|
+
can be negative
|
|
288
|
+
|
|
289
|
+
*clip1_gain* - apply gain to clip1
|
|
290
|
+
|
|
291
|
+
*clip2_gain* - apply gain to clip2
|
|
292
|
+
|
|
293
|
+
*relative_gain* - if true clip1_gain and clip2_gain are relative values and the absolute gains will add up to 1;
|
|
294
|
+
e.g. if clip1_gain is 1 and clip2_gain is 4 then the absolute gain for clip1 will be 0.2 and for clip2 will be 0.8;
|
|
295
|
+
this can be used to prevent overflowing, but should not be used if you want to call Mix more than once, because it lowers the overall volume every time you call Mix;
|
|
296
|
+
default: False
|
|
297
|
+
|
|
298
|
+
*fadein_samples* - fade in length in samples; fade in clip2 if clip2 starts after clip1, otherwise clip1
|
|
299
|
+
|
|
300
|
+
*fadein_seconds* - fade in length in seconds; fade in clip2 if clip2 starts after clip1, otherwise clip1
|
|
301
|
+
|
|
302
|
+
*fadeout_samples* - fade out length in samples; fade out clip2 if clip2 ends before clip1, otherwise clip1
|
|
303
|
+
|
|
304
|
+
*fadeout_seconds* - fade out length in seconds; fade out clip2 if clip2 ends before clip1, otherwise clip1
|
|
305
|
+
|
|
306
|
+
*fade_type* - fade transition type
|
|
307
|
+
```text
|
|
308
|
+
'linear' - linear transition
|
|
309
|
+
'cubic' - cubic transition (Cubic Hermite spline)
|
|
310
|
+
'sine' - sine transition
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
*extend_start* - if the start of clip2 is outside of clip1 (negative clip2_offset) you can choose
|
|
314
|
+
to extend the start of clip1 to match the start of clip2, which increases
|
|
315
|
+
the output length; default: False
|
|
316
|
+
|
|
317
|
+
*extend_end* - if the end of clip2 is outside of clip1 you can choose to extend the end of clip1
|
|
318
|
+
to match the end of clip2, which increases the output length; default: False
|
|
319
|
+
|
|
320
|
+
*channels* - list of channels of clip2 to mix in; default: None (all channels)
|
|
321
|
+
|
|
322
|
+
*overflow* - sample overflow handling; default: 'error' - see [explanation below](#overflow-handling)
|
|
323
|
+
|
|
324
|
+
*overflow_log* - sample overflow logging; default: 'once' - see [explanation below](#overflow-handling)
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
## Normalize
|
|
328
|
+
|
|
329
|
+
Simple peak normalization.
|
|
330
|
+
Applies a gain to the input clip to match the desired normalized peak value.
|
|
331
|
+
|
|
332
|
+
**Note**: Calling this function will read all audio frames in advance, which is a blocking process
|
|
333
|
+
and can take a while to complete depending on the audio length.
|
|
334
|
+
|
|
335
|
+
```python
|
|
336
|
+
atools.Normalize(clip: vs.AudioNode,
|
|
337
|
+
peak: float = 1.0,
|
|
338
|
+
lower_only: bool = False,
|
|
339
|
+
channels: list[int] = None,
|
|
340
|
+
overflow: str = 'error',
|
|
341
|
+
overflow_log: str = 'once'
|
|
342
|
+
) -> vs.AudioNode
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
*clip* - input audio clip
|
|
346
|
+
|
|
347
|
+
*peak* - normalized peak value to scale the audio to; default: 1.0
|
|
348
|
+
|
|
349
|
+
*lower_only* - only reduce the volume to match the desired peak value; default: False
|
|
350
|
+
|
|
351
|
+
*channels* - list of channels to normalize; default: None (all channels)
|
|
352
|
+
|
|
353
|
+
*overflow* - sample overflow handling; default: 'error' - see [explanation below](#overflow-handling)
|
|
354
|
+
|
|
355
|
+
*overflow_log* - sample overflow logging; default: 'once' - see [explanation below](#overflow-handling)
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
## SineTone
|
|
359
|
+
|
|
360
|
+
Create a constant beeping tone clip.
|
|
361
|
+
|
|
362
|
+
```python
|
|
363
|
+
atools.SineTone(clip: vs.AudioNode = None,
|
|
364
|
+
samples: int = 10 * sample_rate
|
|
365
|
+
seconds: float = 10.0,
|
|
366
|
+
sample_rate: int = 44100,
|
|
367
|
+
sample_type: str = 'i16',
|
|
368
|
+
freq: float = 500.0,
|
|
369
|
+
amp: float = 1.0,
|
|
370
|
+
channels: list[int] = [vs.FRONT_LEFT, vs.FRONT_RIGHT],
|
|
371
|
+
overflow: str = 'error',
|
|
372
|
+
overflow_log: str = 'once'
|
|
373
|
+
) -> vs.AudioNode
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
*clip* - use audio format from this clip; values can be overwritten with the parameters below
|
|
377
|
+
|
|
378
|
+
*samples* - audio length in samples
|
|
379
|
+
|
|
380
|
+
*seconds* - audio length in seconds
|
|
381
|
+
|
|
382
|
+
*sample_rate* - sample rate of the output clip
|
|
383
|
+
|
|
384
|
+
*sample_type* - sample type of the output clip
|
|
385
|
+
```text
|
|
386
|
+
'i16' - integer 16-bit
|
|
387
|
+
'i24' - integer 24-bit
|
|
388
|
+
'i32' - integer 32-bit
|
|
389
|
+
'f32' - float 32-bit
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
*freq* - frequency of the sine tone
|
|
393
|
+
|
|
394
|
+
*amp* - amplitude of the sine tone
|
|
395
|
+
|
|
396
|
+
*channels* - channels for the channel layout; default: [vs.FRONT_LEFT, vs.FRONT_RIGHT]
|
|
397
|
+
|
|
398
|
+
*overflow* - sample overflow handling; default: 'error' - see [explanation below](#overflow-handling)
|
|
399
|
+
|
|
400
|
+
*overflow_log* - sample overflow logging; default: 'once' - see [explanation below](#overflow-handling)
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
## Overflow handling
|
|
404
|
+
|
|
405
|
+
All functions have an 'overflow' parameter that determines how to handle overflows,
|
|
406
|
+
and an 'overflow_log' parameter that determines how to log overflows.
|
|
407
|
+
|
|
408
|
+
*overflow* - sample overflow handling; default: 'error'
|
|
409
|
+
```text
|
|
410
|
+
'error' - raise an error (default)
|
|
411
|
+
'clip' - clip overflowing samples (all types)
|
|
412
|
+
'clip_int' - clip overflowing samples for integer output sample types
|
|
413
|
+
keep overflowing samples for float output sample types
|
|
414
|
+
'keep_float' - keep overflowing samples for float output sample types
|
|
415
|
+
raise an error if output sample type is not float
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
To properly handle overflows the clip should be converted to a float sample type first ('f32'), if not already.
|
|
419
|
+
|
|
420
|
+
⚠️ Overflowing samples of integer output sample types are always clipped (disruptive), or they raise an error
|
|
421
|
+
|
|
422
|
+
Use `overflow='keep_float'` for float output sample types to leave overflowing samples unchanged.
|
|
423
|
+
Then call a scaling function like `atools.Normalize` or `std.AudioGain` that scales the peak sample value below or to equal 1.0 (see [Example](#example))
|
|
424
|
+
|
|
425
|
+
*overflow_log* - sample overflow logging; default: 'once'
|
|
426
|
+
```text
|
|
427
|
+
'all' - log all sample overflows (not recommended, this can be a lot)
|
|
428
|
+
'once' - log only the first sample overflow (default)
|
|
429
|
+
'none' - do not log any sample overflows
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**Note**: a summary of all overflowing samples will be logged at the end of each function (if any)
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
### Example
|
|
436
|
+
|
|
437
|
+
```python
|
|
438
|
+
import vapoursynth as vs
|
|
439
|
+
|
|
440
|
+
# load audio (integer or float sample type)
|
|
441
|
+
|
|
442
|
+
# e.g. create a new integer sample type clip
|
|
443
|
+
audio = vs.core.atools.SineTone(sample_type='i24')
|
|
444
|
+
|
|
445
|
+
# convert sample type to 32-bit float
|
|
446
|
+
audio = vs.core.atools.Convert(audio, sample_type='f32')
|
|
447
|
+
|
|
448
|
+
# process audio
|
|
449
|
+
|
|
450
|
+
# make the audio overflow
|
|
451
|
+
audio = vs.core.std.AudioGain(audio, 1.2)
|
|
452
|
+
|
|
453
|
+
# apply FadeIn and FadeOut to the overflowing clip
|
|
454
|
+
# keep overflowing samples with 'keep_float'
|
|
455
|
+
audio = vs.core.atools.FadeIn(audio, seconds=2.0, overflow='keep_float')
|
|
456
|
+
audio = vs.core.atools.FadeOut(audio, seconds=2.0, overflow='keep_float')
|
|
457
|
+
|
|
458
|
+
# fix overflows
|
|
459
|
+
|
|
460
|
+
# scale peak to 1.0 with Normalize
|
|
461
|
+
audio = vs.core.atools.Normalize(audio)
|
|
462
|
+
|
|
463
|
+
# convert sample type back to integer if needed
|
|
464
|
+
audio = vs.core.atools.Convert(audio, sample_type='i24')
|
|
465
|
+
|
|
466
|
+
# Note: Normalize and Convert would both raise an error if any overflow would occur
|
|
467
|
+
# on their output samples, since the default value for overflow is 'error'
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
## Dependencies
|
|
471
|
+
None
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
## Build from source
|
|
475
|
+
Use cmake to configure your preferred build system and run it.
|
|
476
|
+
e.g. cmake with Ninja:
|
|
477
|
+
```sh
|
|
478
|
+
cmake -G Ninja -B ./build-ninja -DCMAKE_BUILD_TYPE=Release
|
|
479
|
+
|
|
480
|
+
ninja -C ./build-ninja
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
## License
|
|
485
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# VapourSynth ATools
|
|
2
|
+
|
|
3
|
+
This package contains the [VS-AudioTools](https://github.com/ropagr/VS-AudioTools) VapourSynth plugin.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install vapoursynth-atools
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Building from source
|
|
12
|
+
|
|
13
|
+
```powershell
|
|
14
|
+
uv build --package vapoursynth-atools
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
Detailed parameter information from the parent project follows.
|
|
20
|
+
|
|
21
|
+
---
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Prerequisites
|
|
2
|
+
*.d
|
|
3
|
+
|
|
4
|
+
# Compiled Object files
|
|
5
|
+
*.slo
|
|
6
|
+
*.lo
|
|
7
|
+
*.o
|
|
8
|
+
*.obj
|
|
9
|
+
|
|
10
|
+
# Precompiled Headers
|
|
11
|
+
*.gch
|
|
12
|
+
*.pch
|
|
13
|
+
|
|
14
|
+
# Compiled Dynamic libraries
|
|
15
|
+
*.so
|
|
16
|
+
*.dylib
|
|
17
|
+
*.dll
|
|
18
|
+
|
|
19
|
+
# Fortran module files
|
|
20
|
+
*.mod
|
|
21
|
+
*.smod
|
|
22
|
+
|
|
23
|
+
# Compiled Static libraries
|
|
24
|
+
*.lai
|
|
25
|
+
*.la
|
|
26
|
+
*.a
|
|
27
|
+
*.lib
|
|
28
|
+
|
|
29
|
+
# Executables
|
|
30
|
+
*.exe
|
|
31
|
+
*.out
|
|
32
|
+
*.app
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.18)
|
|
2
|
+
|
|
3
|
+
project(
|
|
4
|
+
VS-AudioTools
|
|
5
|
+
DESCRIPTION "basic audio functions for VapourSynth"
|
|
6
|
+
VERSION 0.1.0
|
|
7
|
+
LANGUAGES CXX
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
add_library(AudioTools SHARED
|
|
11
|
+
${CMAKE_SOURCE_DIR}/src/plugin.cpp
|
|
12
|
+
${CMAKE_SOURCE_DIR}/src/config.hpp
|
|
13
|
+
${CMAKE_SOURCE_DIR}/src/convert.cpp
|
|
14
|
+
${CMAKE_SOURCE_DIR}/src/convert.hpp
|
|
15
|
+
${CMAKE_SOURCE_DIR}/src/crossfade.cpp
|
|
16
|
+
${CMAKE_SOURCE_DIR}/src/crossfade.hpp
|
|
17
|
+
${CMAKE_SOURCE_DIR}/src/delay.cpp
|
|
18
|
+
${CMAKE_SOURCE_DIR}/src/delay.hpp
|
|
19
|
+
${CMAKE_SOURCE_DIR}/src/fade.cpp
|
|
20
|
+
${CMAKE_SOURCE_DIR}/src/fade.hpp
|
|
21
|
+
${CMAKE_SOURCE_DIR}/src/fadein.cpp
|
|
22
|
+
${CMAKE_SOURCE_DIR}/src/fadein.hpp
|
|
23
|
+
${CMAKE_SOURCE_DIR}/src/fadeout.cpp
|
|
24
|
+
${CMAKE_SOURCE_DIR}/src/fadeout.hpp
|
|
25
|
+
${CMAKE_SOURCE_DIR}/src/findpeak.cpp
|
|
26
|
+
${CMAKE_SOURCE_DIR}/src/findpeak.hpp
|
|
27
|
+
${CMAKE_SOURCE_DIR}/src/mix.cpp
|
|
28
|
+
${CMAKE_SOURCE_DIR}/src/mix.hpp
|
|
29
|
+
${CMAKE_SOURCE_DIR}/src/normalize.cpp
|
|
30
|
+
${CMAKE_SOURCE_DIR}/src/normalize.hpp
|
|
31
|
+
${CMAKE_SOURCE_DIR}/src/setsamples.cpp
|
|
32
|
+
${CMAKE_SOURCE_DIR}/src/setsamples.hpp
|
|
33
|
+
${CMAKE_SOURCE_DIR}/src/sinetone.cpp
|
|
34
|
+
${CMAKE_SOURCE_DIR}/src/sinetone.hpp
|
|
35
|
+
${CMAKE_SOURCE_DIR}/src/common/offset.cpp
|
|
36
|
+
${CMAKE_SOURCE_DIR}/src/common/offset.hpp
|
|
37
|
+
${CMAKE_SOURCE_DIR}/src/common/overflow.cpp
|
|
38
|
+
${CMAKE_SOURCE_DIR}/src/common/overflow.hpp
|
|
39
|
+
${CMAKE_SOURCE_DIR}/src/common/peak.cpp
|
|
40
|
+
${CMAKE_SOURCE_DIR}/src/common/peak.hpp
|
|
41
|
+
${CMAKE_SOURCE_DIR}/src/common/sampletype.cpp
|
|
42
|
+
${CMAKE_SOURCE_DIR}/src/common/sampletype.hpp
|
|
43
|
+
${CMAKE_SOURCE_DIR}/src/common/transition.cpp
|
|
44
|
+
${CMAKE_SOURCE_DIR}/src/common/transition.hpp
|
|
45
|
+
${CMAKE_SOURCE_DIR}/src/utils/array.hpp
|
|
46
|
+
${CMAKE_SOURCE_DIR}/src/utils/debug.hpp
|
|
47
|
+
${CMAKE_SOURCE_DIR}/src/utils/map.hpp
|
|
48
|
+
${CMAKE_SOURCE_DIR}/src/utils/number.hpp
|
|
49
|
+
${CMAKE_SOURCE_DIR}/src/utils/sample.cpp
|
|
50
|
+
${CMAKE_SOURCE_DIR}/src/utils/sample.hpp
|
|
51
|
+
${CMAKE_SOURCE_DIR}/src/utils/string.cpp
|
|
52
|
+
${CMAKE_SOURCE_DIR}/src/utils/string.hpp
|
|
53
|
+
${CMAKE_SOURCE_DIR}/src/utils/vector.hpp
|
|
54
|
+
${CMAKE_SOURCE_DIR}/src/vsmap/vsmap.cpp
|
|
55
|
+
${CMAKE_SOURCE_DIR}/src/vsmap/vsmap.hpp
|
|
56
|
+
${CMAKE_SOURCE_DIR}/src/vsmap/vsmap_common.cpp
|
|
57
|
+
${CMAKE_SOURCE_DIR}/src/vsmap/vsmap_common.hpp
|
|
58
|
+
${CMAKE_SOURCE_DIR}/src/vsutils/audio.cpp
|
|
59
|
+
${CMAKE_SOURCE_DIR}/src/vsutils/audio.hpp
|
|
60
|
+
${CMAKE_SOURCE_DIR}/src/vsutils/bitshift.hpp
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
target_include_directories(AudioTools
|
|
64
|
+
PRIVATE ${CMAKE_SOURCE_DIR}/include/vapoursynth
|
|
65
|
+
${CMAKE_SOURCE_DIR}/src
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
target_compile_features(AudioTools PRIVATE cxx_std_20)
|
|
69
|
+
|
|
70
|
+
target_link_libraries(AudioTools)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
74
|
+
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
|
75
|
+
set(IS_CLANG_GCC OFF)
|
|
76
|
+
set(IS_CLANG_MSVC ON)
|
|
77
|
+
elseif (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
|
|
78
|
+
set(IS_CLANG_GCC ON)
|
|
79
|
+
set(IS_CLANG_MSVC OFF)
|
|
80
|
+
endif()
|
|
81
|
+
endif()
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
target_compile_options(AudioTools
|
|
85
|
+
PRIVATE
|
|
86
|
+
# C++ debug flags for GCC and Clang (GCC-style)
|
|
87
|
+
$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:CXX>,$<OR:$<CXX_COMPILER_ID:GNU>,$<BOOL:${IS_CLANG_GCC}>>>:
|
|
88
|
+
-g -O0 -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-unused-variable>
|
|
89
|
+
|
|
90
|
+
# C++ release flags for GCC and Clang (GCC-style)
|
|
91
|
+
$<$<AND:$<CONFIG:Release>,$<COMPILE_LANGUAGE:CXX>,$<OR:$<CXX_COMPILER_ID:GNU>,$<BOOL:${IS_CLANG_GCC}>>>:
|
|
92
|
+
-O2 -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-unused-variable>
|
|
93
|
+
|
|
94
|
+
# C++ debug flags for MSVC and Clang (MSVC-style)
|
|
95
|
+
$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:CXX>,$<OR:$<CXX_COMPILER_ID:MSVC>,$<BOOL:${IS_CLANG_MSVC}>>>:
|
|
96
|
+
/W4 /wd4100 /wd4702 /Zc:__cplusplus>
|
|
97
|
+
|
|
98
|
+
# C++ release flags for MSVC and Clang (MSVC-style)
|
|
99
|
+
$<$<AND:$<CONFIG:Release>,$<COMPILE_LANGUAGE:CXX>,$<OR:$<CXX_COMPILER_ID:MSVC>,$<BOOL:${IS_CLANG_MSVC}>>>:
|
|
100
|
+
/W4 /wd4100 /wd4702 /Zc:__cplusplus>
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if (WIN32)
|
|
105
|
+
target_link_options(AudioTools
|
|
106
|
+
PRIVATE
|
|
107
|
+
# C++ flags for GCC and Clang (GCC-style) on Windows
|
|
108
|
+
$<$<AND:$<LINK_LANGUAGE:CXX>,$<OR:$<CXX_COMPILER_ID:GNU>,$<BOOL:${IS_CLANG_GCC}>>>:
|
|
109
|
+
-static -static-libstdc++ -s>
|
|
110
|
+
)
|
|
111
|
+
else()
|
|
112
|
+
target_link_options(AudioTools
|
|
113
|
+
PRIVATE
|
|
114
|
+
# C++ flags for GCC on non-Windows systems
|
|
115
|
+
$<$<LINK_LANG_AND_ID:CXX,GNU>:-s>
|
|
116
|
+
)
|
|
117
|
+
endif()
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
set_target_properties(AudioTools PROPERTIES PREFIX "")
|