Processing Module / 処理モジュール¶
The wandas.processing module contains audio operations for temporal, spectral,
cepstral, statistical, filter, and effect processing. Each operation's numerical
contract is generated from its Google-style docstring.
wandas.processingは時間領域、スペクトル、ケプストラム、統計、filter、effectのaudio
operationを提供します。各operationの数値契約はGoogle style docstringから生成されます。
wandas.processing
¶
Audio time series processing operations.
This module provides audio processing operations for time series data.
Attributes¶
__all__ = ['apply_channel_factors', 'AudioOperation', 'ChannelIndependentAudioOperation', 'create_operation', 'get_operation', 'register_lazy_operation', 'register_operation', 'Astype', 'Cepstrum', 'Lifter', 'SpectralEnvelope', 'SpectrogramCepstrum', 'AWeighting', 'HighPassFilter', 'LowPassFilter', 'CSD', 'Coherence', 'CoherenceFromCSD', 'FFT', 'IFFT', 'ISTFT', 'NOctSpectrum', 'NOctSynthesis', 'STFT', 'SpectrogramCSD', 'TransferFunction', 'TransferFunctionFromCSD', 'Welch', 'ReSampling', 'RmsTrend', 'SoundLevel', 'Trim', 'AddWithSNR', 'HpssHarmonic', 'HpssPercussive', 'ABS', 'ChannelDifference', 'Mean', 'Power', 'Sum', 'LoudnessZwst', 'LoudnessZwtv', 'RoughnessDw', 'RoughnessDwSpec', 'SharpnessDin', 'SharpnessDinSt']
module-attribute
¶
Classes¶
AudioOperation
¶
Bases: Generic[InputArrayType, OutputArrayType]
Base class for numerical audio operations.
Subclasses may depend on relationships between channels. The default lazy
execution graph therefore passes the complete channel-first tensor to the
eager :meth:_process kernel as one whole-frame operation.
Use :class:ChannelIndependentAudioOperation instead when every output
channel depends only on the corresponding input channel.
Source code in wandas/processing/base.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
Attributes¶
name
class-attribute
¶
pure = pure
instance-attribute
¶
sampling_rate
property
¶
Sampling rate captured at operation construction time.
params
property
¶
Return a read-only defensive snapshot of operation parameters.
Functions¶
__init_subclass__(**kwargs)
¶
Ensure subclass process overrides keep the base input contract.
Source code in wandas/processing/base.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
__init__(sampling_rate, *, pure=True, **params)
¶
Initialize AudioOperation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
pure
|
bool
|
bool, default=True. Whether the operation is pure (deterministic with no side effects). When True, Dask can cache results for identical inputs. Set to False only if the operation has side effects or is non-deterministic. |
True
|
**params
|
Any
|
Any. Operation-specific parameters |
{}
|
Source code in wandas/processing/base.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
to_params()
¶
Return operation parameters used for lineage and display.
Source code in wandas/processing/base.py
270 271 272 | |
validate_params()
¶
Validate parameters (raises exception if invalid)
Source code in wandas/processing/base.py
282 283 | |
get_metadata_updates()
¶
Get metadata updates to apply after processing.
This method allows operations to specify how metadata should be updated after processing. By default, no metadata is updated.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
Dictionary of metadata updates. Can include: - 'sampling_rate': New sampling rate (float) - Other metadata keys as needed |
Examples:
Return empty dict for operations that don't change metadata:
>>> return {}
Return new sampling rate for operations that resample:
>>> return {"sampling_rate": self.target_sr}
Notes
This method is called by the framework after processing to update the frame metadata. Subclasses should override this method if they need to update metadata (e.g., changing sampling rate).
Design principle: Operations should use parameters provided at initialization (via init). All necessary information should be available as instance variables.
Source code in wandas/processing/base.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
get_display_name()
¶
Get display name for the operation for use in channel labels.
Returns _display if the subclass sets it, otherwise None
(which tells the framework to fall back to the name class
variable). Subclasses with dynamic display names can still
override this method.
Source code in wandas/processing/base.py
320 321 322 323 324 325 326 327 328 329 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after operation.
The default returns input_shape unchanged, which is correct for the majority of operations (filters, effects, weighting, etc.). Subclasses that alter the shape (e.g. FFT, STFT, resampling) must override this method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
tuple. Input data shape |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[int, ...]
|
Output data shape |
Source code in wandas/processing/base.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Calculate output dtype metadata after operation.
Source code in wandas/processing/base.py
369 370 371 | |
process(data, *inputs)
¶
Execute operation lazily on Frame-internal channel-first Dask arrays.
data must be the lazy array held by a Frame, with a leading channel
axis such as (channels, samples). Direct 1-D lazy input is not part
of this API; use a Frame operation or reshape direct lazy inputs to add
a channel axis before calling process(). Multi-input operations
pass additional channel-first Dask arrays through *inputs.
Source code in wandas/processing/base.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
ChannelIndependentAudioOperation
¶
Bases: AudioOperation[InputArrayType, OutputArrayType]
Base class for operations whose channels are numerically independent.
For every supported input, a conforming operation satisfies the semantic equivalence
op(all_channels) == concatenate(op(channel) for channel in each_channel).
Subclasses must preserve this independence when overriding :meth:_process.
The kernel must also accept a complete multi-channel tensor because graph
construction can conservatively use whole-frame execution.
The class expresses numerical semantics, not a public scheduler, chunk, or task-topology guarantee. The current implementation may evaluate eligible unary, channel-axis-preserving inputs independently by channel. Unknown or zero channel counts, runtime inputs, and channel-axis-changing outputs use the whole-frame graph without changing the subclass contract.
Cross-channel algorithms, such as common-mode removal, must subclass
:class:AudioOperation instead.
Source code in wandas/processing/base.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | |
Astype
¶
Bases: ChannelIndependentAudioOperation[Any, Any]
Convert a raw Frame tensor to a supported real or complex floating dtype.
The eager kernel is channel-independent, preserves shape, and never mutates
its input. :meth:process builds a lazy Dask graph whose dtype metadata is
the exact selected target before computation. Real or integer inputs can
produce float32/float64; complex inputs can produce complex64/complex128.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
Sampling rate in Hz. It is preserved and does not affect the numerical cast. |
required |
dtype
|
DTypeLike
|
Supported target NumPy dtype or equivalent dtype-like value. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If dtype is not understood by NumPy. |
ValueError
|
If the target is unsupported or :meth: |
Source code in wandas/processing/conversion.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
Attributes¶
name = 'astype'
class-attribute
instance-attribute
¶
dtype
property
¶
Return the canonical target dtype name.
Functions¶
__init__(sampling_rate, dtype)
¶
Initialize a dtype conversion with a canonical target dtype.
Source code in wandas/processing/conversion.py
127 128 129 | |
validate_params()
¶
Reject unsupported target representations at construction time.
Source code in wandas/processing/conversion.py
136 137 138 139 140 141 142 143 144 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return exact output metadata after validating the source domain.
Source code in wandas/processing/conversion.py
146 147 148 149 150 151 152 153 | |
AddWithSNR
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Addition operation considering SNR
Source code in wandas/processing/effects.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
Attributes¶
name = 'add_with_snr'
class-attribute
instance-attribute
¶
snr
property
¶
Signal-to-noise ratio captured at operation construction time.
Functions¶
__init__(sampling_rate, snr=1.0)
¶
Initialize addition operation considering SNR
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
snr
|
float
|
float. Signal-to-noise ratio (dB) |
1.0
|
Source code in wandas/processing/effects.py
309 310 311 312 313 314 315 316 317 318 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Promote SNR mixing to at least float32 precision.
Source code in wandas/processing/effects.py
325 326 327 | |
HpssHarmonic
¶
Bases: _HpssBase
HPSS Harmonic operation
Source code in wandas/processing/effects.py
88 89 90 91 92 93 | |
HpssPercussive
¶
Bases: _HpssBase
HPSS Percussive operation
Source code in wandas/processing/effects.py
96 97 98 99 100 101 | |
AWeighting
¶
Bases: ChannelIndependentAudioOperation[NDArrayReal, NDArrayReal]
Apply the implemented digital A-frequency-weighting curve.
The output is a linear waveform. This operation does not calculate RMS, convert to dB, or establish sound-level-meter conformance.
Source code in wandas/processing/filters.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
Attributes¶
name = 'a_weighting'
class-attribute
instance-attribute
¶
Functions¶
__init__(sampling_rate)
¶
Initialize A-weighting filter
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
Source code in wandas/processing/filters.py
243 244 245 246 247 248 249 250 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/filters.py
254 255 | |
HighPassFilter
¶
Bases: _ButterworthFilter
High-pass filter operation
Source code in wandas/processing/filters.py
117 118 119 120 121 122 | |
LowPassFilter
¶
Bases: _ButterworthFilter
Low-pass filter operation
Source code in wandas/processing/filters.py
125 126 127 128 129 130 | |
ABS
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Absolute value operation
Source code in wandas/processing/stats.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
Attributes¶
name = 'abs'
class-attribute
instance-attribute
¶
Functions¶
__init__(sampling_rate)
¶
Initialize absolute value operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
Source code in wandas/processing/stats.py
19 20 21 22 23 24 25 26 | |
process(data, *inputs)
¶
Source code in wandas/processing/stats.py
28 29 30 | |
ChannelDifference
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Channel difference calculation operation
Source code in wandas/processing/stats.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
Attributes¶
name = 'channel_difference'
class-attribute
instance-attribute
¶
other_channel
property
¶
Other channel index captured at operation construction time.
Functions¶
__init__(sampling_rate, other_channel=0)
¶
Initialize channel difference calculation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
other_channel
|
int
|
int. Channel to calculate difference with, default is 0 |
0
|
Source code in wandas/processing/stats.py
90 91 92 93 94 95 96 97 98 | |
process(data, *inputs)
¶
Source code in wandas/processing/stats.py
105 106 107 108 109 110 | |
Mean
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Mean calculation
Source code in wandas/processing/stats.py
74 75 76 77 78 79 80 81 | |
Power
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Power operation
Source code in wandas/processing/stats.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
Attributes¶
name = 'power'
class-attribute
instance-attribute
¶
exponent
property
¶
Exponent captured at operation construction time.
exp
property
¶
Backward-compatible read-only alias for the captured exponent.
Functions¶
__init__(sampling_rate, exponent)
¶
Initialize power operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
exponent
|
float
|
float. Power exponent |
required |
Source code in wandas/processing/stats.py
39 40 41 42 43 44 45 46 47 | |
process(data, *inputs)
¶
Source code in wandas/processing/stats.py
59 60 61 | |
Sum
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Sum calculation
Source code in wandas/processing/stats.py
64 65 66 67 68 69 70 71 | |
ReSampling
¶
Bases: ChannelIndependentAudioOperation[NDArrayReal, NDArrayReal]
Resampling operation
Source code in wandas/processing/temporal.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
Attributes¶
name = 'resampling'
class-attribute
instance-attribute
¶
target_sr
property
¶
Target sampling rate captured at operation construction time.
Functions¶
__init__(sampling_rate, target_sr)
¶
Initialize a resampling operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
Source sampling rate in Hz. |
required |
target_sr
|
float
|
Target sampling rate in Hz. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in wandas/processing/temporal.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 | |
get_metadata_updates()
¶
Update sampling rate to target sampling rate.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
Metadata updates with the new sampling rate. |
Notes
Resampling always produces output at target_sr, regardless of the
input sampling rate.
Source code in wandas/processing/temporal.py
469 470 471 472 473 474 475 476 477 478 479 480 | |
calculate_output_shape(input_shape)
¶
Calculate the output data shape after the operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
Input data shape. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
tuple[int, ...]: Output data shape. |
Source code in wandas/processing/temporal.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return resampling output dtype metadata.
Source code in wandas/processing/temporal.py
517 518 519 | |
RmsTrend
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Windowed linear RMS or reference-relative RMS amplitude level.
The operation accepts arrays shaped (channels, samples) and returns
(channels, frames) using centered, zero-padded windows. dB=False
returns RMS in the input unit. dB=True returns
20 * log10(max(RMS / ref, 1e-12)), bounded below by -240 dB, with one
scalar reference shared across channels or one reference per channel.
Applying Aw changes the frequency weighting before RMS; it does not
establish instrument conformance. The operation is lazy when used through
a Frame and preserves the input dtype contract by returning floating data.
Source code in wandas/processing/temporal.py
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 | |
Attributes¶
name = 'rms_trend'
class-attribute
instance-attribute
¶
frame_length
property
¶
Frame length captured at operation construction time.
hop_length
property
¶
Hop length captured at operation construction time.
dB
property
¶
Whether output is converted to decibels.
Aw
property
¶
Whether A-weighting is applied before RMS calculation.
ref
property
¶
Reference values captured at operation construction time.
Functions¶
__init__(sampling_rate, frame_length=2048, hop_length=512, ref=1.0, dB=False, Aw=False, *, _calibration_scale=1.0)
¶
Initialize a centered windowed RMS operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
Input sampling rate in Hz. |
required |
frame_length
|
int
|
Window length in samples. Defaults to 2048. |
2048
|
hop_length
|
int
|
Distance between output frames in samples. Defaults to
512. The output sampling rate is |
512
|
ref
|
list[float] | float
|
Positive finite amplitude reference, either one scalar or one
value per channel. For Pa input, |
1.0
|
dB
|
bool
|
If True, return reference-relative amplitude level instead of linear RMS amplitude. |
False
|
Aw
|
bool
|
If True, apply the implemented digital A-weighting filter before RMS calculation. |
False
|
_calibration_scale
|
list[float] | float | NDArrayReal
|
Positive internal amplitude scale supplied by calibrated Frame execution. It is not a public recipe parameter. |
1.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the sampling or window parameters are invalid, or if a reference or calibration scale is not finite and positive. |
Source code in wandas/processing/temporal.py
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | |
get_metadata_updates()
¶
Return metadata updates for the frame-rate change.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A mapping containing |
Source code in wandas/processing/temporal.py
753 754 755 756 757 758 759 760 761 762 | |
calculate_output_shape(input_shape)
¶
Calculate the centered, zero-padded output shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
Input shape whose last dimension contains samples;
the usual Frame shape is |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
The input leading dimensions followed by the number of centered
windows, so a two-dimensional input returns |
Raises:
| Type | Description |
|---|---|
ValueError
|
If dB output uses a reference or calibration scale that cannot be broadcast to the input channel count. |
Source code in wandas/processing/temporal.py
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return RMS trend output dtype metadata.
Source code in wandas/processing/temporal.py
860 861 862 | |
SoundLevel
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Frequency- and exponentially time-weighted RMS or level.
The operation applies A, C, or flat Z frequency weighting, smooths squared
samples with a 125 ms (Fast) or 1 s (Slow) first-order exponential filter,
and returns either the square root (linear RMS) or
10 * log10(max(smoothed_power / ref**2, 1e-20)), bounded below by
-200 dB. The result is dB SPL only for pressure in Pa with ref=2e-5.
The implementation is not a claim of complete IEC/JIS sound-level-meter
conformance. Input and output arrays have the same (channels, samples)
shape; Frame execution remains lazy and preserves the input sampling rate.
Source code in wandas/processing/temporal.py
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 | |
Attributes¶
name = 'sound_level'
class-attribute
instance-attribute
¶
ref
property
¶
Reference values captured at operation construction time.
freq_weighting
property
¶
Frequency weighting captured at operation construction time.
time_weighting
property
¶
Time weighting captured at operation construction time.
dB
property
¶
Whether output is converted to decibels.
time_constant
property
¶
Return the RC time constant in seconds.
Functions¶
__init__(sampling_rate, ref=1.0, freq_weighting='Z', time_weighting='Fast', dB=False, *, _calibration_scale=1.0)
¶
Initialize a frequency- and time-weighted level operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
Input sampling rate in Hz. |
required |
ref
|
list[float] | float | NDArrayReal
|
Positive finite amplitude reference, either one scalar or one
value per channel. For Pa input, |
1.0
|
freq_weighting
|
str | None
|
Implemented frequency curve: |
'Z'
|
time_weighting
|
str
|
Exponential time constant: |
'Fast'
|
dB
|
bool
|
If True, return |
False
|
_calibration_scale
|
list[float] | float | NDArrayReal
|
Positive internal amplitude scale supplied by calibrated Frame execution. It is not a public recipe parameter. |
1.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the sampling rate, reference, calibration scale, frequency curve, or time weighting is invalid. |
Source code in wandas/processing/temporal.py
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 | |
get_display_name()
¶
Get display name for the operation for use in channel labels.
Source code in wandas/processing/temporal.py
997 998 999 1000 1001 1002 1003 | |
calculate_output_shape(input_shape)
¶
Validate channel-wise configuration and preserve input shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
Input shape, normally |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
The unchanged input shape. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a per-channel reference or calibration scale cannot be broadcast to the input channel count. |
Source code in wandas/processing/temporal.py
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return sound level output dtype metadata.
Source code in wandas/processing/temporal.py
1118 1119 1120 | |
Trim
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Deprecated array-level trimming operation.
Use :meth:wandas.frames.channel.ChannelFrame.trim for structural
time-range selection.
Source code in wandas/processing/temporal.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | |
Attributes¶
name = 'trim'
class-attribute
instance-attribute
¶
start
property
¶
Start time captured at operation construction time.
end
property
¶
End time captured at operation construction time.
start_sample
property
¶
Start sample index derived from the captured start time.
end_sample
property
¶
End sample index derived from the captured end time.
Functions¶
__init__(sampling_rate, start, end)
¶
Source code in wandas/processing/temporal.py
532 533 534 535 536 537 538 539 540 541 542 543 | |
calculate_output_shape(input_shape)
¶
Return the legacy array-slice output shape.
Source code in wandas/processing/temporal.py
565 566 567 568 569 | |
Functions¶
create_operation(name, sampling_rate, **params)
¶
Create operation instance from name and parameters
Source code in wandas/processing/base.py
729 730 731 732 | |
get_operation(name)
¶
Resolve and return a registered AudioOperation class by name.
Source code in wandas/processing/base.py
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 | |
register_lazy_operation(name, module_name, *, attribute_name)
¶
Register a lazy operation provider using an explicit module attribute.
Registration stores module_name and the required keyword-only
attribute_name without importing the module. The referenced class must
expose a non-blank name equal to name when it is resolved. Only the
exact same provider declaration may be registered more than once.
Source code in wandas/processing/base.py
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | |
register_operation(operation_class)
¶
Register a concrete eager AudioOperation class.
The class's name is its single provider key. Re-registering the exact
same class object is idempotent; another class or a lazy provider owning the
same name is rejected.
Source code in wandas/processing/base.py
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | |
apply_channel_factors(data, factors)
¶
Multiply channel-first data by one factor per channel without computing it.
Source code in wandas/processing/calibration.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
__getattr__(name)
¶
Source code in wandas/processing/__init__.py
113 114 115 116 117 118 119 120 | |
wandas.processing.temporal
¶
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
MIN_SOUND_LEVEL_POWER_RATIO = 1e-20
module-attribute
¶
MAX_RESAMPLING_FACTOR = 1000000
module-attribute
¶
Classes¶
ReSampling
¶
Bases: ChannelIndependentAudioOperation[NDArrayReal, NDArrayReal]
Resampling operation
Source code in wandas/processing/temporal.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
Attributes¶
name = 'resampling'
class-attribute
instance-attribute
¶
target_sr
property
¶
Target sampling rate captured at operation construction time.
Functions¶
__init__(sampling_rate, target_sr)
¶
Initialize a resampling operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
Source sampling rate in Hz. |
required |
target_sr
|
float
|
Target sampling rate in Hz. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in wandas/processing/temporal.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 | |
get_metadata_updates()
¶
Update sampling rate to target sampling rate.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
Metadata updates with the new sampling rate. |
Notes
Resampling always produces output at target_sr, regardless of the
input sampling rate.
Source code in wandas/processing/temporal.py
469 470 471 472 473 474 475 476 477 478 479 480 | |
calculate_output_shape(input_shape)
¶
Calculate the output data shape after the operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
Input data shape. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
tuple[int, ...]: Output data shape. |
Source code in wandas/processing/temporal.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return resampling output dtype metadata.
Source code in wandas/processing/temporal.py
517 518 519 | |
Trim
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Deprecated array-level trimming operation.
Use :meth:wandas.frames.channel.ChannelFrame.trim for structural
time-range selection.
Source code in wandas/processing/temporal.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | |
Attributes¶
name = 'trim'
class-attribute
instance-attribute
¶
start
property
¶
Start time captured at operation construction time.
end
property
¶
End time captured at operation construction time.
start_sample
property
¶
Start sample index derived from the captured start time.
end_sample
property
¶
End sample index derived from the captured end time.
Functions¶
__init__(sampling_rate, start, end)
¶
Source code in wandas/processing/temporal.py
532 533 534 535 536 537 538 539 540 541 542 543 | |
calculate_output_shape(input_shape)
¶
Return the legacy array-slice output shape.
Source code in wandas/processing/temporal.py
565 566 567 568 569 | |
FixLength
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Operation to adjust signal length to a specified length.
Source code in wandas/processing/temporal.py
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | |
Attributes¶
name = 'fix_length'
class-attribute
instance-attribute
¶
target_length
property
¶
Target length captured at operation construction time.
Functions¶
__init__(sampling_rate, length=None, duration=None)
¶
Initialize an operation that pads or truncates a signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
Input sampling rate in Hz. |
required |
length
|
int | None
|
Target number of samples. Provide either |
None
|
duration
|
float | None
|
Target duration in seconds. It is converted to samples
using |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither |
Source code in wandas/processing/temporal.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | |
calculate_output_shape(input_shape)
¶
Return the input shape with its sample axis set to target length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
Input array shape with samples on the last axis. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
Shape with the same leading dimensions and |
Source code in wandas/processing/temporal.py
611 612 613 614 615 616 617 618 619 620 621 | |
RmsTrend
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Windowed linear RMS or reference-relative RMS amplitude level.
The operation accepts arrays shaped (channels, samples) and returns
(channels, frames) using centered, zero-padded windows. dB=False
returns RMS in the input unit. dB=True returns
20 * log10(max(RMS / ref, 1e-12)), bounded below by -240 dB, with one
scalar reference shared across channels or one reference per channel.
Applying Aw changes the frequency weighting before RMS; it does not
establish instrument conformance. The operation is lazy when used through
a Frame and preserves the input dtype contract by returning floating data.
Source code in wandas/processing/temporal.py
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 | |
Attributes¶
name = 'rms_trend'
class-attribute
instance-attribute
¶
frame_length
property
¶
Frame length captured at operation construction time.
hop_length
property
¶
Hop length captured at operation construction time.
dB
property
¶
Whether output is converted to decibels.
Aw
property
¶
Whether A-weighting is applied before RMS calculation.
ref
property
¶
Reference values captured at operation construction time.
Functions¶
__init__(sampling_rate, frame_length=2048, hop_length=512, ref=1.0, dB=False, Aw=False, *, _calibration_scale=1.0)
¶
Initialize a centered windowed RMS operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
Input sampling rate in Hz. |
required |
frame_length
|
int
|
Window length in samples. Defaults to 2048. |
2048
|
hop_length
|
int
|
Distance between output frames in samples. Defaults to
512. The output sampling rate is |
512
|
ref
|
list[float] | float
|
Positive finite amplitude reference, either one scalar or one
value per channel. For Pa input, |
1.0
|
dB
|
bool
|
If True, return reference-relative amplitude level instead of linear RMS amplitude. |
False
|
Aw
|
bool
|
If True, apply the implemented digital A-weighting filter before RMS calculation. |
False
|
_calibration_scale
|
list[float] | float | NDArrayReal
|
Positive internal amplitude scale supplied by calibrated Frame execution. It is not a public recipe parameter. |
1.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the sampling or window parameters are invalid, or if a reference or calibration scale is not finite and positive. |
Source code in wandas/processing/temporal.py
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | |
get_metadata_updates()
¶
Return metadata updates for the frame-rate change.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A mapping containing |
Source code in wandas/processing/temporal.py
753 754 755 756 757 758 759 760 761 762 | |
calculate_output_shape(input_shape)
¶
Calculate the centered, zero-padded output shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
Input shape whose last dimension contains samples;
the usual Frame shape is |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
The input leading dimensions followed by the number of centered
windows, so a two-dimensional input returns |
Raises:
| Type | Description |
|---|---|
ValueError
|
If dB output uses a reference or calibration scale that cannot be broadcast to the input channel count. |
Source code in wandas/processing/temporal.py
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return RMS trend output dtype metadata.
Source code in wandas/processing/temporal.py
860 861 862 | |
SoundLevel
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Frequency- and exponentially time-weighted RMS or level.
The operation applies A, C, or flat Z frequency weighting, smooths squared
samples with a 125 ms (Fast) or 1 s (Slow) first-order exponential filter,
and returns either the square root (linear RMS) or
10 * log10(max(smoothed_power / ref**2, 1e-20)), bounded below by
-200 dB. The result is dB SPL only for pressure in Pa with ref=2e-5.
The implementation is not a claim of complete IEC/JIS sound-level-meter
conformance. Input and output arrays have the same (channels, samples)
shape; Frame execution remains lazy and preserves the input sampling rate.
Source code in wandas/processing/temporal.py
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 | |
Attributes¶
name = 'sound_level'
class-attribute
instance-attribute
¶
ref
property
¶
Reference values captured at operation construction time.
freq_weighting
property
¶
Frequency weighting captured at operation construction time.
time_weighting
property
¶
Time weighting captured at operation construction time.
dB
property
¶
Whether output is converted to decibels.
time_constant
property
¶
Return the RC time constant in seconds.
Functions¶
__init__(sampling_rate, ref=1.0, freq_weighting='Z', time_weighting='Fast', dB=False, *, _calibration_scale=1.0)
¶
Initialize a frequency- and time-weighted level operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
Input sampling rate in Hz. |
required |
ref
|
list[float] | float | NDArrayReal
|
Positive finite amplitude reference, either one scalar or one
value per channel. For Pa input, |
1.0
|
freq_weighting
|
str | None
|
Implemented frequency curve: |
'Z'
|
time_weighting
|
str
|
Exponential time constant: |
'Fast'
|
dB
|
bool
|
If True, return |
False
|
_calibration_scale
|
list[float] | float | NDArrayReal
|
Positive internal amplitude scale supplied by calibrated Frame execution. It is not a public recipe parameter. |
1.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the sampling rate, reference, calibration scale, frequency curve, or time weighting is invalid. |
Source code in wandas/processing/temporal.py
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 | |
get_display_name()
¶
Get display name for the operation for use in channel labels.
Source code in wandas/processing/temporal.py
997 998 999 1000 1001 1002 1003 | |
calculate_output_shape(input_shape)
¶
Validate channel-wise configuration and preserve input shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
Input shape, normally |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
The unchanged input shape. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a per-channel reference or calibration scale cannot be broadcast to the input channel count. |
Source code in wandas/processing/temporal.py
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return sound level output dtype metadata.
Source code in wandas/processing/temporal.py
1118 1119 1120 | |
Functions¶
wandas.processing.spectral
¶
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
FFT
¶
Bases: AudioOperation[NDArrayReal, NDArrayComplex]
One-sided, coherent-gain-normalized peak-amplitude FFT.
The input is truncated to n_fft; the selected window spans the
remaining min(len(x), n_fft) samples and is applied before zero-padding
to n_fft. The coherent gain is taken from that same window, so a short
input keeps its amplitude. DC and Nyquist bins retain their real-FFT
scaling; every other positive-frequency bin is doubled. The complex result
therefore has the same physical unit as the input, and an on-bin sinusoid's
magnitude is its peak amplitude.
Source code in wandas/processing/spectral.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
Attributes¶
name = 'fft'
class-attribute
instance-attribute
¶
n_fft
property
¶
FFT size captured at operation construction time.
window
property
¶
Window name captured at operation construction time.
Functions¶
__init__(sampling_rate, n_fft=None, window='hann')
¶
Initialize FFT operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
n_fft
|
int | None
|
int, optional. FFT size, default is None (determined by input size) |
None
|
window
|
str
|
str, optional. Window function type, default is 'hann' |
'hann'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If n_fft is not a positive integer |
Source code in wandas/processing/spectral.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after the operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
tuple. Input data shape (channels, samples). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[int, ...]
|
Output data shape (channels, freqs). |
Source code in wandas/processing/spectral.py
322 323 324 325 326 327 328 329 330 331 332 333 334 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
338 339 | |
IFFT
¶
Bases: AudioOperation[NDArrayComplex, NDArrayReal]
Inverse of Wandas' one-sided peak-amplitude FFT normalization.
For a spectrum produced by :class:FFT with matching n_fft,
window and win_length, the result is the analysed samples
multiplied by that analysis window and zero-padded to n_fft. A boxcar
window therefore reconstructs the prepared input exactly; tapered windows
intentionally reconstruct the windowed waveform rather than guessing
samples discarded by the analysis window.
Source code in wandas/processing/spectral.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | |
Attributes¶
name = 'ifft'
class-attribute
instance-attribute
¶
win_length
property
¶
Analysis window length captured at operation construction time.
n_fft
property
¶
IFFT size captured at operation construction time.
window
property
¶
Window name captured at operation construction time.
Functions¶
__init__(sampling_rate, n_fft=None, window='hann', win_length=None)
¶
Initialize IFFT operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
n_fft
|
int | None
|
Optional[int], optional. IFFT size, default is None (determined based on input size) |
None
|
window
|
str
|
str, optional. Window function type, default is 'hann' |
'hann'
|
win_length
|
int | None
|
Optional[int], optional. Length of the analysis window whose coherent gain is undone, default is None (the IFFT size) |
None
|
Source code in wandas/processing/spectral.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
tuple. Input data shape (channels, freqs) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[int, ...]
|
Output data shape (channels, samples) |
Source code in wandas/processing/spectral.py
444 445 446 447 448 449 450 451 452 453 454 455 456 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
460 461 | |
STFT
¶
Bases: AudioOperation[NDArrayReal, NDArrayComplex]
One-sided peak-amplitude Short-Time Fourier Transform.
Each frame uses SciPy's coherent-gain magnitude scaling, with non-DC and non-Nyquist positive-frequency bins doubled. Values retain the input physical unit.
Source code in wandas/processing/spectral.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | |
Attributes¶
name = 'stft'
class-attribute
instance-attribute
¶
n_fft
property
¶
FFT size captured at operation construction time.
detrend
property
¶
Per-frame trend removal captured at operation construction time.
win_length
property
¶
Window length captured at operation construction time.
hop_length
property
¶
Hop length captured at operation construction time.
window
property
¶
Window name captured at operation construction time.
frame_time_origin
property
¶
First actual frame center relative to the input start, in seconds.
SciPy's padding-dependent minimum frame index is determined without computing signal samples. This derived domain state is not a Recipe parameter or a second copy of the window/hop configuration.
Functions¶
__init__(sampling_rate, n_fft=2048, hop_length=None, win_length=None, window='hann', *, allow_sparse=False, detrend=None)
¶
Initialize STFT operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
n_fft
|
int
|
int. FFT size, default is 2048 |
2048
|
hop_length
|
int | None
|
int, optional. Number of samples between frames. Default is win_length // 4 |
None
|
win_length
|
int | None
|
int, optional. Window length. Default is n_fft |
None
|
window
|
str
|
str. Window type, default is 'hann' |
'hann'
|
allow_sparse
|
bool
|
Permit gaps between windows when hop_length exceeds win_length. |
False
|
detrend
|
str | None
|
None, |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If n_fft is not positive, win_length > n_fft, or hop_length is invalid |
Source code in wandas/processing/spectral.py
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
tuple. Input data shape |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[int, ...]
|
Output data shape |
Source code in wandas/processing/spectral.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
619 620 | |
ISTFT
¶
Bases: AudioOperation[NDArrayComplex, NDArrayReal]
Inverse Short-Time Fourier Transform operation
Source code in wandas/processing/spectral.py
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | |
Attributes¶
name = 'istft'
class-attribute
instance-attribute
¶
n_fft
property
¶
FFT size captured at operation construction time.
win_length
property
¶
Window length captured at operation construction time.
hop_length
property
¶
Hop length captured at operation construction time.
window
property
¶
Window name captured at operation construction time.
length
property
¶
Output length captured at operation construction time.
Functions¶
__init__(sampling_rate, n_fft=2048, hop_length=None, win_length=None, window='hann', length=None)
¶
Initialize ISTFT operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
n_fft
|
int
|
int. FFT size, default is 2048 |
2048
|
hop_length
|
int | None
|
int, optional. Number of samples between frames. Default is win_length // 4 |
None
|
win_length
|
int | None
|
int, optional. Window length. Default is n_fft |
None
|
window
|
str
|
str. Window type, default is 'hann' |
'hann'
|
length
|
int | None
|
int, optional. Length of output signal. Default is None (determined from input) |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If n_fft is not positive, win_length > n_fft, or hop_length is invalid |
Source code in wandas/processing/spectral.py
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after ISTFT operation.
Uses the SciPy ShortTimeFFT calculation formula to compute the expected output length based on the input spectrogram dimensions and output range parameters (k0, k1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
tuple. Input spectrogram shape (channels, n_freqs, n_frames) where n_freqs = n_fft // 2 + 1 and n_frames is the number of time frames. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[int, ...]
|
Output shape (channels, output_samples) where output_samples is the reconstructed signal length determined by the output range [k0, k1). |
Notes
The calculation follows SciPy's ShortTimeFFT.istft() implementation. When k1 is None (default), the maximum reconstructible signal length is computed as:
.. math::
q_{max} = n_{frames} + p_{min}
k_{max} = (q_{max} - 1) \cdot hop + m_{num} - m_{num_mid}
The output length is then:
.. math::
output_samples = k_1 - k_0
where k0 defaults to 0 and k1 defaults to k_max.
Parameters that affect the calculation: - n_frames: number of time frames in the STFT - p_min: minimum frame index (ShortTimeFFT property) - hop: hop length (samples between frames) - m_num: window length - m_num_mid: window midpoint position - length: optional length override (if set, limits output)
References
- SciPy ShortTimeFFT.istft:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.ShortTimeFFT.istft.html - SciPy Source: https://github.com/scipy/scipy/blob/main/scipy/signal/_short_time_fft.py
Source code in wandas/processing/spectral.py
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
793 794 | |
process(data, *inputs)
¶
Execute ISTFT on Frame-internal channel-first spectrogram data.
Source code in wandas/processing/spectral.py
824 825 826 827 | |
Welch
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Welch-averaged one-sided peak-amplitude spectrum.
Segment power spectra are averaged with scaling="spectrum" and then
converted to peak amplitude. Values retain the input physical unit; they
are neither power spectral density nor expressed per hertz. For an on-bin
sine wave with peak amplitude A, the corresponding bin is approximately
A.
Internally, this uses scipy.signal.welch with scaling="spectrum"
and converts the power spectrum to amplitude spectrum:
- DC component (f=0): A = sqrt(P)
- positive non-Nyquist components: A = sqrt(2*P)
Source code in wandas/processing/spectral.py
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | |
Attributes¶
name = 'welch'
class-attribute
instance-attribute
¶
n_fft
property
¶
FFT size captured at operation construction time.
win_length
property
¶
Window length captured at operation construction time.
hop_length
property
¶
Hop length captured at operation construction time.
window
property
¶
Window name captured at operation construction time.
average
property
¶
Averaging method captured at operation construction time.
detrend
property
¶
Detrend method captured at operation construction time.
noverlap
property
¶
Overlap captured at operation construction time.
Functions¶
__init__(sampling_rate, n_fft=2048, hop_length=None, win_length=None, window='hann', average='mean', detrend='constant')
¶
Initialize Welch operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
n_fft
|
int
|
int, optional. FFT size, default is 2048 |
2048
|
hop_length
|
int | None
|
int, optional. Number of samples between frames. Default is win_length // 4 |
None
|
win_length
|
int | None
|
int, optional. Window length. Default is n_fft |
None
|
window
|
str
|
str, optional. Window function type, default is 'hann' |
'hann'
|
average
|
str
|
str, optional. Averaging method, default is 'mean' |
'mean'
|
detrend
|
str
|
str, optional. Detrend method, default is 'constant' |
'constant'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If n_fft, win_length, or hop_length are invalid |
Source code in wandas/processing/spectral.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
tuple[int, ...]
|
tuple. Input data shape (channels, samples) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[int, ...]
|
Output data shape (channels, freqs) |
Source code in wandas/processing/spectral.py
927 928 929 930 931 932 933 934 935 936 937 938 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
940 941 | |
NOctSpectrum
¶
Bases: _NOctBase, ChannelIndependentAudioOperation[NDArrayReal, NDArrayReal]
N-octave spectrum operation
Source code in wandas/processing/spectral.py
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | |
Attributes¶
name = 'noct_spectrum'
class-attribute
instance-attribute
¶
Functions¶
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Keep the input precision; MoSQITo computes in float64.
Source code in wandas/processing/spectral.py
1099 1100 1101 | |
NOctSynthesis
¶
Bases: _NOctBase
N-octave synthesis operation using an explicit original FFT size.
n_fft is required because a one-sided spectrum's bin count cannot
distinguish an odd FFT size from the adjacent even size. The value is
captured in the operation configuration and is used to construct the
canonical real-FFT frequency grid.
The input is Wandas' one-sided peak-amplitude spectrum. MoSQITo sums the
squared bins of an RMS spectrum in each band, so every bin except DC and
Nyquist is divided by sqrt(2), and every bin by the square root of the
analysis window's equivalent noise bandwidth in bins,
n_fft * sum(w**2) / sum(w)**2. w is the win_length-sample
window that produced the spectrum.
Source code in wandas/processing/spectral.py
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 | |
Attributes¶
name = 'noct_synthesis'
class-attribute
instance-attribute
¶
n_fft
property
¶
Return the source FFT size captured by this operation.
window
property
¶
Analysis window of the source spectrum.
win_length
property
¶
Analysis window length of the source spectrum, in samples.
Functions¶
__init__(sampling_rate, fmin, fmax, n=3, G=10, fr=1000, *, n_fft, window='hann', win_length=None)
¶
Initialize N-octave synthesis with the source spectrum's FFT size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
Sampling rate in Hz. The public synthesis Frame method requires 48000 Hz. |
required |
fmin
|
float
|
Lower frequency bound in Hz. |
required |
fmax
|
float
|
Upper frequency bound in Hz. |
required |
n
|
int
|
Number of bands per octave. |
3
|
G
|
int
|
Exact center-frequency ratio convention, either 2 or 10. |
10
|
fr
|
int
|
Reference frequency in Hz. |
1000
|
n_fft
|
int
|
Positive integer FFT size that produced the complete one-sided input spectrum. |
required |
window
|
str
|
Analysis window that produced the input spectrum. |
'hann'
|
win_length
|
int | None
|
Length of that window in samples. Default is |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Source code in wandas/processing/spectral.py
1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 | |
validate_params()
¶
Validate common N-octave parameters and the explicit FFT size.
Source code in wandas/processing/spectral.py
1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 | |
calculate_output_shape(input_shape)
¶
Count the bands MoSQITo synthesizes.
MoSQITo drops the top bands whose upper edge fc * 2**(1 / (2 * n))
exceeds half its sampling rate, 2 * max(freqs). It skips the drop
when the only such band is the first one.
Source code in wandas/processing/spectral.py
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Keep the input precision; MoSQITo computes in float64.
Source code in wandas/processing/spectral.py
1267 1268 1269 | |
Coherence
¶
Bases: _CrossSpectralBase
Coherence estimation operation
Source code in wandas/processing/spectral.py
1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 | |
CSD
¶
Bases: _ScaledCrossSpectralBase
Cross-spectral density estimation operation
Source code in wandas/processing/spectral.py
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 | |
TransferFunction
¶
Bases: _ScaledCrossSpectralBase
Transfer function estimation operation
Source code in wandas/processing/spectral.py
1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 | |
TransferFunctionFromCSD
¶
Bases: _CrossSpectralDerivation
Canonical H_out_in = P_out_in / P_in_in from an existing CSD matrix.
Source code in wandas/processing/spectral.py
1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 | |
Attributes¶
name = 'transfer_function_from_csd'
class-attribute
instance-attribute
¶
Functions¶
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
1586 1587 | |
CoherenceFromCSD
¶
Bases: _CrossSpectralDerivation
Magnitude-squared coherence from an existing CSD matrix.
Source code in wandas/processing/spectral.py
1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 | |
Attributes¶
name = 'coherence_from_csd'
class-attribute
instance-attribute
¶
Functions¶
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
1603 1604 | |
SpectrogramCSD
¶
Bases: AudioOperation[NDArrayComplex, NDArrayComplex]
Every P_out_in averaged over the frames of an amplitude-normalized STFT.
The input is (channel, frequency, time) as produced by :class:STFT.
Undoing its coherent-gain scaling gives SciPy's csd scaling for the same
window and segments: scaling="spectrum" divides
mean(conj(X_in) * X_out) by two in the doubled bins, and
scaling="density" also multiplies by sum(w)**2 / (fs * sum(w**2)).
Frames are averaged with the mean and are not detrended.
Source code in wandas/processing/spectral.py
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 | |
Attributes¶
name = 'spectrogram_csd'
class-attribute
instance-attribute
¶
n_fft
property
¶
FFT size captured at operation construction time.
win_length
property
¶
Window length captured at operation construction time.
window
property
¶
Window name captured at operation construction time.
scaling
property
¶
CSD scaling captured at operation construction time.
Functions¶
__init__(sampling_rate, n_fft=2048, win_length=None, window='hann', scaling='spectrum')
¶
Source code in wandas/processing/spectral.py
1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 | |
calculate_output_shape(input_shape)
¶
Source code in wandas/processing/spectral.py
1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
1684 1685 1686 1687 1688 1689 1690 1691 1692 | |
Functions¶
noct_spectrum(*args, **kwargs)
¶
Source code in wandas/processing/spectral.py
30 31 | |
noct_synthesis(*args, **kwargs)
¶
Source code in wandas/processing/spectral.py
34 35 | |
noct_band_labels(f_exact, f_nom)
¶
Return one center-frequency label per band that MoSQITo computes.
MoSQITo computes a band for every exact center frequency between fmin
and fmax, but its nominal labels cover only its fixed tables (25 Hz to
20 kHz for 1/3 octave, 31.5 Hz to 16 kHz for octave). A band with a
nominal label keeps it; a band outside the table is labelled with its
exact center frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f_exact
|
Any
|
Exact center frequencies returned by MoSQITo. |
required |
f_nom
|
Any
|
Nominal center frequencies returned by MoSQITo, a contiguous
run of the bands in |
required |
Returns:
| Type | Description |
|---|---|
NDArrayReal
|
Labels with the same length as |
Source code in wandas/processing/spectral.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
validate_noct_recipe_params(params)
¶
Validate portable N-octave parameters without importing MoSQITo.
Source code in wandas/processing/spectral.py
93 94 95 96 | |
validate_stft_recipe_params(params)
¶
Validate sparse opt-in before constructing a portable STFT graph.
Source code in wandas/processing/spectral.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
wandas.processing.cepstral
¶
Real-cepstrum analysis, liftering, and spectral-envelope reconstruction.
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
DEFAULT_LOG_FLOOR = 1e-12
module-attribute
¶
__all__ = ['DEFAULT_LOG_FLOOR', 'Cepstrum', 'Lifter', 'SpectralEnvelope', 'SpectrogramCepstrum']
module-attribute
¶
Classes¶
Cepstrum
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Calculate a normalized real cepstrum.
The operation windows the first min(len(x), n_fft) samples of each
channel, zero-pads them to n_fft, calculates the one-sided FFT using the
same amplitude normalization as :class:wandas.processing.spectral.FFT,
applies a positive floor, and returns irfft(log(magnitude)). Processing
is lazy when called through :meth:AudioOperation.process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate in Hz. |
required |
n_fft
|
int | None
|
int, optional. FFT size. |
None
|
window
|
str
|
str, default="hann". SciPy window name applied before the FFT. |
'hann'
|
floor
|
float
|
float, default=1e-12. Positive finite floor applied to normalized magnitudes before |
DEFAULT_LOG_FLOOR
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Source code in wandas/processing/cepstral.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
Attributes¶
name = 'cepstrum'
class-attribute
instance-attribute
¶
n_fft
property
¶
Return the configured FFT size, or None for input length.
window
property
¶
Return the configured analysis-window name.
floor
property
¶
Return the positive log-magnitude floor.
Functions¶
__init__(sampling_rate, n_fft=None, window='hann', floor=DEFAULT_LOG_FLOOR)
¶
Source code in wandas/processing/cepstral.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
calculate_output_shape(input_shape)
¶
Return (..., n_fft) without evaluating input data.
Source code in wandas/processing/cepstral.py
155 156 157 158 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return the real dtype matching the input precision.
Source code in wandas/processing/cepstral.py
162 163 164 165 166 167 168 | |
SpectrogramCepstrum
¶
Bases: AudioOperation[NDArrayComplex, NDArrayReal]
Calculate a real cepstrum independently at every STFT time frame.
Input data is a normalized one-sided spectrum shaped
(channel, frequency, time). The operation discards phase, applies a
positive log floor, and performs irfft along the frequency axis. The
result is shaped (channel, quefrency, time).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate in Hz. |
required |
n_fft
|
int
|
int. FFT size used to create the input spectrogram. |
required |
floor
|
float
|
float, default=1e-12. Positive finite floor applied to magnitude before |
DEFAULT_LOG_FLOOR
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Source code in wandas/processing/cepstral.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |
Attributes¶
name = 'spectrogram_cepstrum'
class-attribute
instance-attribute
¶
n_fft
property
¶
Return the FFT size of the input spectrogram.
floor
property
¶
Return the positive log-magnitude floor.
Functions¶
__init__(sampling_rate, n_fft, floor=DEFAULT_LOG_FLOOR)
¶
Source code in wandas/processing/cepstral.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
calculate_output_shape(input_shape)
¶
Replace the frequency axis with a complete quefrency axis.
Source code in wandas/processing/cepstral.py
306 307 308 309 310 311 312 313 314 315 316 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return the real dtype matching the input precision.
Source code in wandas/processing/cepstral.py
320 321 322 323 324 325 326 | |
Lifter
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Keep low- or high-quefrency real-cepstrum coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate in Hz; its reciprocal is the quefrency-bin spacing. |
required |
cutoff
|
float
|
float. Positive quefrency boundary in seconds. The represented bin and its circularly mirrored negative-quefrency bins are included in low mode. |
required |
mode
|
Literal['low', 'high']
|
{"low", "high"}, default="low". |
'low'
|
axis
|
int
|
int, default=-1. Non-channel quefrency axis. |
-1
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If the cutoff is non-positive, non-finite, smaller than one bin, or
overlaps the mirrored half of the concrete cepstrum; or if |
Source code in wandas/processing/cepstral.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | |
Attributes¶
name = 'lifter'
class-attribute
instance-attribute
¶
cutoff
property
¶
Return the quefrency cutoff in seconds.
mode
property
¶
Return the selected low- or high-quefrency mode.
axis
property
¶
Return the configured quefrency axis.
Functions¶
__init__(sampling_rate, cutoff, mode='low', *, axis=-1)
¶
Source code in wandas/processing/cepstral.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Preserve a real floating input dtype.
Source code in wandas/processing/cepstral.py
411 412 413 414 415 416 417 | |
calculate_output_shape(input_shape)
¶
Validate the cutoff against the known cepstrum length.
Source code in wandas/processing/cepstral.py
419 420 421 422 423 | |
SpectralEnvelope
¶
Bases: AudioOperation[NDArrayReal, NDArrayComplex]
Reconstruct a normalized one-sided spectral envelope.
The input must be a complete, circularly symmetric real cepstrum. The
operation calculates exp(real(rfft(cepstrum))) and returns complex data
with zero phase so it can be represented by SpectralFrame. Processing is
lazy through :meth:AudioOperation.process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate in Hz. |
required |
axis
|
int
|
int, default=-1. Non-channel quefrency axis. |
-1
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Source code in wandas/processing/cepstral.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
Attributes¶
name = 'spectral_envelope'
class-attribute
instance-attribute
¶
axis
property
¶
Return the configured quefrency axis.
Functions¶
__init__(sampling_rate, *, axis=-1)
¶
Source code in wandas/processing/cepstral.py
485 486 487 488 489 490 | |
calculate_output_shape(input_shape)
¶
Replace the quefrency axis with its one-sided frequency axis.
Source code in wandas/processing/cepstral.py
497 498 499 500 501 502 503 504 505 506 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return the complex dtype matching the input precision.
Source code in wandas/processing/cepstral.py
510 511 512 513 514 515 516 | |
Functions¶
wandas.processing.conversion
¶
Explicit numerical representation conversions.
Attributes¶
__all__ = ['Astype']
module-attribute
¶
Classes¶
Astype
¶
Bases: ChannelIndependentAudioOperation[Any, Any]
Convert a raw Frame tensor to a supported real or complex floating dtype.
The eager kernel is channel-independent, preserves shape, and never mutates
its input. :meth:process builds a lazy Dask graph whose dtype metadata is
the exact selected target before computation. Real or integer inputs can
produce float32/float64; complex inputs can produce complex64/complex128.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
Sampling rate in Hz. It is preserved and does not affect the numerical cast. |
required |
dtype
|
DTypeLike
|
Supported target NumPy dtype or equivalent dtype-like value. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If dtype is not understood by NumPy. |
ValueError
|
If the target is unsupported or :meth: |
Source code in wandas/processing/conversion.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
Attributes¶
name = 'astype'
class-attribute
instance-attribute
¶
dtype
property
¶
Return the canonical target dtype name.
Functions¶
__init__(sampling_rate, dtype)
¶
Initialize a dtype conversion with a canonical target dtype.
Source code in wandas/processing/conversion.py
127 128 129 | |
validate_params()
¶
Reject unsupported target representations at construction time.
Source code in wandas/processing/conversion.py
136 137 138 139 140 141 142 143 144 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return exact output metadata after validating the source domain.
Source code in wandas/processing/conversion.py
146 147 148 149 150 151 152 153 | |
Functions¶
integer_arithmetic_as_float64(*operands)
¶
Return arithmetic operands cast to float64 when NumPy would compute in an integer dtype.
Array operands are cast lazily; scalars are returned unchanged. Operands whose promoted dtype is already floating or complex are returned as given, so integer arithmetic cannot wrap around and other dtypes are unaffected.
Source code in wandas/processing/conversion.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
wandas.processing.stats
¶
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
ABS
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Absolute value operation
Source code in wandas/processing/stats.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
Attributes¶
name = 'abs'
class-attribute
instance-attribute
¶
Functions¶
__init__(sampling_rate)
¶
Initialize absolute value operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
Source code in wandas/processing/stats.py
19 20 21 22 23 24 25 26 | |
process(data, *inputs)
¶
Source code in wandas/processing/stats.py
28 29 30 | |
Power
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Power operation
Source code in wandas/processing/stats.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
Attributes¶
name = 'power'
class-attribute
instance-attribute
¶
exponent
property
¶
Exponent captured at operation construction time.
exp
property
¶
Backward-compatible read-only alias for the captured exponent.
Functions¶
__init__(sampling_rate, exponent)
¶
Initialize power operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
exponent
|
float
|
float. Power exponent |
required |
Source code in wandas/processing/stats.py
39 40 41 42 43 44 45 46 47 | |
process(data, *inputs)
¶
Source code in wandas/processing/stats.py
59 60 61 | |
Sum
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Sum calculation
Source code in wandas/processing/stats.py
64 65 66 67 68 69 70 71 | |
Mean
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Mean calculation
Source code in wandas/processing/stats.py
74 75 76 77 78 79 80 81 | |
ChannelDifference
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Channel difference calculation operation
Source code in wandas/processing/stats.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
Attributes¶
name = 'channel_difference'
class-attribute
instance-attribute
¶
other_channel
property
¶
Other channel index captured at operation construction time.
Functions¶
__init__(sampling_rate, other_channel=0)
¶
Initialize channel difference calculation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
other_channel
|
int
|
int. Channel to calculate difference with, default is 0 |
0
|
Source code in wandas/processing/stats.py
90 91 92 93 94 95 96 97 98 | |
process(data, *inputs)
¶
Source code in wandas/processing/stats.py
105 106 107 108 109 110 | |
Functions¶
wandas.processing.filters
¶
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
HighPassFilter
¶
Bases: _ButterworthFilter
High-pass filter operation
Source code in wandas/processing/filters.py
117 118 119 120 121 122 | |
LowPassFilter
¶
Bases: _ButterworthFilter
Low-pass filter operation
Source code in wandas/processing/filters.py
125 126 127 128 129 130 | |
BandPassFilter
¶
Bases: _ButterworthFilter
Band-pass filter operation
Source code in wandas/processing/filters.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
Attributes¶
name = 'bandpass_filter'
class-attribute
instance-attribute
¶
low_cutoff
property
¶
Lower cutoff frequency captured at operation construction time.
high_cutoff
property
¶
Higher cutoff frequency captured at operation construction time.
Functions¶
__init__(sampling_rate, low_cutoff, high_cutoff, order=4)
¶
Initialize band-pass filter
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
low_cutoff
|
float
|
float. Lower cutoff frequency (Hz). Must be between 0 and Nyquist frequency. |
required |
high_cutoff
|
float
|
float. Higher cutoff frequency (Hz). Must be between 0 and Nyquist frequency and greater than low_cutoff. |
required |
order
|
int
|
int, optional. Order of the Butterworth prototype, default is 4.
The resulting band-pass filter has order |
4
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If either cutoff frequency is not within valid range (0 < cutoff < Nyquist), or if low_cutoff >= high_cutoff |
Source code in wandas/processing/filters.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
validate_params()
¶
Validate parameters
Source code in wandas/processing/filters.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
AWeighting
¶
Bases: ChannelIndependentAudioOperation[NDArrayReal, NDArrayReal]
Apply the implemented digital A-frequency-weighting curve.
The output is a linear waveform. This operation does not calculate RMS, convert to dB, or establish sound-level-meter conformance.
Source code in wandas/processing/filters.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
Attributes¶
name = 'a_weighting'
class-attribute
instance-attribute
¶
Functions¶
__init__(sampling_rate)
¶
Initialize A-weighting filter
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
Source code in wandas/processing/filters.py
243 244 245 246 247 248 249 250 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/filters.py
254 255 | |
Functions¶
wandas.processing.effects
¶
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
HpssHarmonic
¶
Bases: _HpssBase
HPSS Harmonic operation
Source code in wandas/processing/effects.py
88 89 90 91 92 93 | |
HpssPercussive
¶
Bases: _HpssBase
HPSS Percussive operation
Source code in wandas/processing/effects.py
96 97 98 99 100 101 | |
Normalize
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Signal normalization operation.
Source code in wandas/processing/effects.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
Attributes¶
name = 'normalize'
class-attribute
instance-attribute
¶
norm
property
¶
Norm captured at operation construction time.
axis
property
¶
Axis captured at operation construction time.
threshold
property
¶
Threshold captured at operation construction time.
fill
property
¶
Fill behavior captured at operation construction time.
Functions¶
__init__(sampling_rate, norm=np.inf, axis=-1, threshold=None, fill=None)
¶
Initialize normalization operation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
norm
|
float | None
|
float or np.inf, default=np.inf. Norm type. Supported values: - np.inf: Maximum absolute value normalization - -np.inf: Minimum absolute value normalization - 0: Pseudo L0 normalization (divide by number of non-zero elements) - float: Lp norm - None: No normalization |
inf
|
axis
|
int | None
|
int or None, default=-1. Axis along which to normalize. - -1: Normalize along time axis (each channel independently) - None: Global normalization across all axes - int: Normalize along specified axis |
-1
|
threshold
|
float | None
|
float or None, optional. Threshold below which values are considered zero. If None, no threshold is applied. |
None
|
fill
|
bool | None
|
bool or None, optional. Value to fill when the norm is zero. If None, the zero vector remains zero. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If norm parameter is invalid or threshold is negative |
Source code in wandas/processing/effects.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return normalization output dtype metadata.
Source code in wandas/processing/effects.py
254 255 256 | |
RemoveDC
¶
Bases: ChannelIndependentAudioOperation[NDArrayReal, NDArrayReal]
Remove DC component (DC offset) from the signal.
This operation removes the DC component by subtracting the mean value from each channel, centering the signal around zero.
Source code in wandas/processing/effects.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
Attributes¶
name = 'remove_dc'
class-attribute
instance-attribute
¶
Functions¶
__init__(sampling_rate)
¶
Initialize DC removal operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
Source code in wandas/processing/effects.py
269 270 271 272 273 274 275 276 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/effects.py
278 279 280 281 | |
AddWithSNR
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Addition operation considering SNR
Source code in wandas/processing/effects.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
Attributes¶
name = 'add_with_snr'
class-attribute
instance-attribute
¶
snr
property
¶
Signal-to-noise ratio captured at operation construction time.
Functions¶
__init__(sampling_rate, snr=1.0)
¶
Initialize addition operation considering SNR
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_rate
|
float
|
float. Sampling rate (Hz) |
required |
snr
|
float
|
float. Signal-to-noise ratio (dB) |
1.0
|
Source code in wandas/processing/effects.py
309 310 311 312 313 314 315 316 317 318 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Promote SNR mixing to at least float32 precision.
Source code in wandas/processing/effects.py
325 326 327 | |
Fade
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Fade operation using a Tukey (tapered cosine) window.
This operation applies symmetric fade-in and fade-out with the same duration. The Tukey window alpha parameter is computed from the fade duration so that the tapered portion equals the requested fade length at each end.
Source code in wandas/processing/effects.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | |
Attributes¶
name = 'fade'
class-attribute
instance-attribute
¶
fade_ms
property
¶
Fade duration captured at operation construction time.
Functions¶
__init__(sampling_rate, fade_ms=50)
¶
Source code in wandas/processing/effects.py
357 358 359 | |
validate_params()
¶
Source code in wandas/processing/effects.py
366 367 368 | |
calculate_tukey_alpha(fade_len, n_samples)
staticmethod
¶
Calculate Tukey window alpha parameter from fade length.
The alpha parameter determines what fraction of the window is tapered. For symmetric fade-in/fade-out, alpha = 2 * fade_len / n_samples ensures that each side's taper has exactly fade_len samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fade_len
|
int
|
int. Desired fade length in samples for each end (in and out). |
required |
n_samples
|
int
|
int. Total number of samples in the signal. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Alpha parameter for scipy.signal.windows.tukey, clamped to [0, 1]. |
Examples:
>>> Fade.calculate_tukey_alpha(fade_len=20, n_samples=200)
0.2
>>> Fade.calculate_tukey_alpha(fade_len=100, n_samples=100)
1.0
Source code in wandas/processing/effects.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/effects.py
399 400 401 402 403 | |