Processing Module / 処理モジュール¶
The wandas.processing module provides various processing capabilities for audio data.
wandas.processing モジュールは、オーディオデータに対する様々な処理機能を提供します。
Base Processing / 基本処理¶
Provides basic processing operations. 基本的な処理操作を提供します。
wandas.processing.base
¶
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
InputArrayType = TypeVar('InputArrayType', NDArrayReal, NDArrayComplex)
module-attribute
¶
OutputArrayType = TypeVar('OutputArrayType', NDArrayReal, NDArrayComplex)
module-attribute
¶
Classes¶
AudioOperation
¶
Bases: Generic[InputArrayType, OutputArrayType]
Numerical Dask operation with an operation-owned config snapshot.
Source code in wandas/processing/base.py
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 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 | |
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
178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
__init__(sampling_rate, *, pure=True, **params)
¶
Initialize AudioOperation.
Parameters¶
sampling_rate : float Sampling rate (Hz) pure : 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. **params : Any Operation-specific parameters
Source code in wandas/processing/base.py
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 | |
to_params()
¶
Return operation parameters used for lineage and display.
Source code in wandas/processing/base.py
234 235 236 | |
validate_params()
¶
Validate parameters (raises exception if invalid)
Source code in wandas/processing/base.py
246 247 | |
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¶
dict 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
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 | |
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
288 289 290 291 292 293 294 295 296 297 | |
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¶
input_shape : tuple Input data shape
Returns¶
tuple Output data shape
Source code in wandas/processing/base.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Calculate output dtype metadata after operation.
Source code in wandas/processing/base.py
341 342 343 | |
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
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |
Functions¶
register_operation(operation_class)
¶
Register a new operation type
Source code in wandas/processing/base.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | |
register_lazy_operation(name, module_name)
¶
Register an operation that can be loaded from module_name on demand.
Source code in wandas/processing/base.py
474 475 476 | |
get_operation(name)
¶
Get operation class by name
Source code in wandas/processing/base.py
479 480 481 482 483 484 485 | |
create_operation(name, sampling_rate, **params)
¶
Create operation instance from name and parameters
Source code in wandas/processing/base.py
488 489 490 491 | |
Effects / エフェクト¶
Provides audio effect processing. オーディオエフェクト処理を提供します。
wandas.processing.effects
¶
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
HpssHarmonic
¶
Bases: _HpssBase
HPSS Harmonic operation
Source code in wandas/processing/effects.py
82 83 84 85 86 87 | |
HpssPercussive
¶
Bases: _HpssBase
HPSS Percussive operation
Source code in wandas/processing/effects.py
90 91 92 93 94 95 | |
Normalize
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Signal normalization operation.
Source code in wandas/processing/effects.py
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 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 | |
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¶
sampling_rate : float Sampling rate (Hz) norm : 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 axis : 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 threshold : float or None, optional Threshold below which values are considered zero. If None, no threshold is applied. fill : bool or None, optional Value to fill when the norm is zero. If None, the zero vector remains zero.
Raises¶
ValueError If norm parameter is invalid or threshold is negative
Source code in wandas/processing/effects.py
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 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return normalization output dtype metadata.
Source code in wandas/processing/effects.py
224 225 226 | |
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
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 | |
Attributes¶
name = 'remove_dc'
class-attribute
instance-attribute
¶
Functions¶
__init__(sampling_rate)
¶
Initialize DC removal operation.
Parameters¶
sampling_rate : float Sampling rate (Hz)
Source code in wandas/processing/effects.py
239 240 241 242 243 244 245 246 247 248 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/effects.py
250 251 252 253 | |
AddWithSNR
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Addition operation considering SNR
Source code in wandas/processing/effects.py
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 | |
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¶
sampling_rate : float Sampling rate (Hz) snr : float Signal-to-noise ratio (dB)
Source code in wandas/processing/effects.py
285 286 287 288 289 290 291 292 293 294 295 296 297 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Promote SNR mixing to at least float32 precision.
Source code in wandas/processing/effects.py
304 305 306 | |
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
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 | |
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
336 337 338 | |
validate_params()
¶
Source code in wandas/processing/effects.py
345 346 347 | |
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¶
fade_len : int Desired fade length in samples for each end (in and out). n_samples : int Total number of samples in the signal.
Returns¶
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
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 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/effects.py
382 383 384 385 386 | |
Functions¶
Modules¶
Filters / フィルター¶
Provides various audio filter processing. 様々なオーディオフィルター処理を提供します。
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
96 97 98 99 100 101 | |
LowPassFilter
¶
Bases: _ButterworthFilter
Low-pass filter operation
Source code in wandas/processing/filters.py
104 105 106 107 108 109 | |
BandPassFilter
¶
Bases: _ButterworthFilter
Band-pass filter operation
Source code in wandas/processing/filters.py
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 | |
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¶
sampling_rate : float Sampling rate (Hz) low_cutoff : float Lower cutoff frequency (Hz). Must be between 0 and Nyquist frequency. high_cutoff : float Higher cutoff frequency (Hz). Must be between 0 and Nyquist frequency and greater than low_cutoff. order : int, optional Filter order, default is 4
Raises¶
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
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 | |
validate_params()
¶
Validate parameters
Source code in wandas/processing/filters.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
AWeighting
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
A-weighting filter operation
Source code in wandas/processing/filters.py
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 | |
Attributes¶
name = 'a_weighting'
class-attribute
instance-attribute
¶
Functions¶
__init__(sampling_rate)
¶
Initialize A-weighting filter
Parameters¶
sampling_rate : float Sampling rate (Hz)
Source code in wandas/processing/filters.py
199 200 201 202 203 204 205 206 207 208 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/filters.py
210 211 | |
Functions¶
Spectral Processing / スペクトル処理¶
Provides spectral analysis and processing capabilities. スペクトル解析と処理機能を提供します。
wandas.processing.spectral
¶
Attributes¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
FFT
¶
Bases: AudioOperation[NDArrayReal, NDArrayComplex]
FFT (Fast Fourier Transform) operation
Source code in wandas/processing/spectral.py
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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
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¶
sampling_rate : float Sampling rate (Hz) n_fft : int, optional FFT size, default is None (determined by input size) window : str, optional Window function type, default is 'hann'
Raises¶
ValueError If n_fft is not a positive integer
Source code in wandas/processing/spectral.py
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 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after the operation.
Parameters¶
input_shape : tuple Input data shape (channels, samples).
Returns¶
tuple Output data shape (channels, freqs).
Source code in wandas/processing/spectral.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
249 250 | |
IFFT
¶
Bases: AudioOperation[NDArrayComplex, NDArrayReal]
IFFT (Inverse Fast Fourier Transform) operation
Source code in wandas/processing/spectral.py
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 = 'ifft'
class-attribute
instance-attribute
¶
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')
¶
Initialize IFFT operation
Parameters¶
sampling_rate : float Sampling rate (Hz) n_fft : Optional[int], optional IFFT size, default is None (determined based on input size) window : str, optional Window function type, default is 'hann'
Source code in wandas/processing/spectral.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after operation
Parameters¶
input_shape : tuple Input data shape (channels, freqs)
Returns¶
tuple Output data shape (channels, samples)
Source code in wandas/processing/spectral.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
323 324 | |
STFT
¶
Bases: AudioOperation[NDArrayReal, NDArrayComplex]
Short-Time Fourier Transform operation
Source code in wandas/processing/spectral.py
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 462 463 464 465 466 467 | |
Attributes¶
name = 'stft'
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.
Functions¶
__init__(sampling_rate, n_fft=2048, hop_length=None, win_length=None, window='hann')
¶
Initialize STFT operation
Parameters¶
sampling_rate : float Sampling rate (Hz) n_fft : int FFT size, default is 2048 hop_length : int, optional Number of samples between frames. Default is win_length // 4 win_length : int, optional Window length. Default is n_fft window : str Window type, default is 'hann'
Raises¶
ValueError If n_fft is not positive, win_length > n_fft, or hop_length is invalid
Source code in wandas/processing/spectral.py
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 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after operation
Parameters¶
input_shape : tuple Input data shape
Returns¶
tuple Output data shape
Source code in wandas/processing/spectral.py
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
447 448 | |
ISTFT
¶
Bases: AudioOperation[NDArrayComplex, NDArrayReal]
Inverse Short-Time Fourier Transform operation
Source code in wandas/processing/spectral.py
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 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 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | |
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¶
sampling_rate : float Sampling rate (Hz) n_fft : int FFT size, default is 2048 hop_length : int, optional Number of samples between frames. Default is win_length // 4 win_length : int, optional Window length. Default is n_fft window : str Window type, default is 'hann' length : int, optional Length of output signal. Default is None (determined from input)
Raises¶
ValueError If n_fft is not positive, win_length > n_fft, or hop_length is invalid
Source code in wandas/processing/spectral.py
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 | |
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¶
input_shape : 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.
Returns¶
tuple 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
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 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
630 631 | |
process(data, *inputs)
¶
Execute ISTFT on Frame-internal channel-first spectrogram data.
Source code in wandas/processing/spectral.py
661 662 663 664 | |
Welch
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Welch method for power spectral density estimation.
Computes the one-sided amplitude spectrum using Welch's method for consistency with FFT and STFT methods. For a sine wave with amplitude A, the peak value at its frequency will be approximately A.
Notes¶
Internally uses scipy.signal.welch with scaling='spectrum' and converts the power spectrum to amplitude spectrum: - DC component (f=0): A = sqrt(P) - AC components (f>0): A = sqrt(2*P)
Source code in wandas/processing/spectral.py
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 | |
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¶
sampling_rate : float Sampling rate (Hz) n_fft : int, optional FFT size, default is 2048 hop_length : int, optional Number of samples between frames. Default is win_length // 4 win_length : int, optional Window length. Default is n_fft window : str, optional Window function type, default is 'hann' average : str, optional Averaging method, default is 'mean' detrend : str, optional Detrend method, default is 'constant'
Raises¶
ValueError If n_fft, win_length, or hop_length are invalid
Source code in wandas/processing/spectral.py
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 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after operation
Parameters¶
input_shape : tuple Input data shape (channels, samples)
Returns¶
tuple Output data shape (channels, freqs)
Source code in wandas/processing/spectral.py
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Source code in wandas/processing/spectral.py
785 786 | |
NOctSpectrum
¶
Bases: _NOctBase
N-octave spectrum operation
Source code in wandas/processing/spectral.py
887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 | |
NOctSynthesis
¶
Bases: _NOctBase
Octave synthesis operation
Source code in wandas/processing/spectral.py
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 | |
Coherence
¶
Bases: _CrossSpectralBase
Coherence estimation operation
Source code in wandas/processing/spectral.py
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 | |
CSD
¶
Bases: _ScaledCrossSpectralBase
Cross-spectral density estimation operation
Source code in wandas/processing/spectral.py
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 | |
TransferFunction
¶
Bases: _ScaledCrossSpectralBase
Transfer function estimation operation
Source code in wandas/processing/spectral.py
1115 1116 1117 1118 1119 1120 1121 1122 1123 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 | |
Functions¶
noct_spectrum(*args, **kwargs)
¶
Source code in wandas/processing/spectral.py
16 17 | |
noct_synthesis(*args, **kwargs)
¶
Source code in wandas/processing/spectral.py
20 21 | |
Cepstral Processing / ケプストラム処理¶
Provides real-cepstrum analysis, symmetric liftering, and spectral-envelope reconstruction. Most users should use the typed Frame methods described in the cepstral analysis guide. 実ケプストラム解析、対称リフタリング、スペクトル包絡再構成を提供します。通常は ケプストラム解析ガイドの型付きFrameメソッドを利用してください。
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 each channel, 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¶
sampling_rate : float
Sampling rate in Hz.
n_fft : int, optional
FFT size. None uses the input sample count. A smaller value truncates
the input and a larger value zero-pads it.
window : str, default="hann"
SciPy window name applied before the FFT.
floor : float, default=1e-12
Positive finite floor applied to normalized magnitudes before log.
Raises¶
TypeError
If n_fft is not an integer or window is not a non-empty string.
ValueError
If n_fft or floor is not positive and finite.
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 199 200 201 202 203 | |
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
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 | |
calculate_output_shape(input_shape)
¶
Return (..., n_fft) without evaluating input data.
Source code in wandas/processing/cepstral.py
162 163 164 165 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return NumPy FFT's real output dtype.
Source code in wandas/processing/cepstral.py
167 168 169 170 171 172 173 | |
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¶
sampling_rate : float
Sampling rate in Hz.
n_fft : int
FFT size used to create the input spectrogram.
floor : float, default=1e-12
Positive finite floor applied to magnitude before log.
Raises¶
TypeError
If n_fft is not an integer or floor is not real.
ValueError
If n_fft or floor is not positive, or input shape disagrees
with the FFT size.
Source code in wandas/processing/cepstral.py
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 | |
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
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 | |
calculate_output_shape(input_shape)
¶
Replace the frequency axis with a complete quefrency axis.
Source code in wandas/processing/cepstral.py
276 277 278 279 280 281 282 283 284 285 286 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return NumPy FFT's real output dtype.
Source code in wandas/processing/cepstral.py
288 289 290 291 292 293 294 | |
Lifter
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Keep low- or high-quefrency real-cepstrum coefficients.
Parameters¶
sampling_rate : float
Sampling rate in Hz; its reciprocal is the quefrency-bin spacing.
cutoff : float
Positive quefrency boundary in seconds. The represented bin and its
circularly mirrored negative-quefrency bins are included in low mode.
mode : {"low", "high"}, default="low"
"low" keeps the smooth spectral-envelope region. "high" keeps
the complementary fine structure.
axis : int, default=-1
Non-channel quefrency axis. CepstrogramFrame uses -2.
Raises¶
TypeError
If cutoff is not a real number or axis is not an integer.
ValueError
If the cutoff is non-positive, non-finite, smaller than one bin, or
overlaps the mirrored half of the concrete cepstrum; or if mode is
unknown or axis does not identify a non-channel input axis.
Source code in wandas/processing/cepstral.py
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 426 427 428 429 430 431 432 433 434 435 436 437 | |
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
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 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Preserve a real floating input dtype.
Source code in wandas/processing/cepstral.py
387 388 389 390 391 392 393 | |
calculate_output_shape(input_shape)
¶
Validate the cutoff against the known cepstrum length.
Source code in wandas/processing/cepstral.py
395 396 397 398 399 | |
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¶
sampling_rate : float
Sampling rate in Hz.
axis : int, default=-1
Non-channel quefrency axis. CepstrogramFrame uses -2.
Raises¶
TypeError
If axis is not an integer or concrete input is complex-valued.
ValueError
If axis is invalid or concrete coefficients are not circularly
symmetric.
Source code in wandas/processing/cepstral.py
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 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 | |
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
467 468 469 470 471 472 | |
calculate_output_shape(input_shape)
¶
Replace the quefrency axis with its one-sided frequency axis.
Source code in wandas/processing/cepstral.py
479 480 481 482 483 484 485 486 487 488 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return the complex dtype used by SpectralFrame.
Source code in wandas/processing/cepstral.py
490 491 492 493 494 495 496 | |
Functions¶
Statistical Processing / 統計処理¶
Provides statistical analysis functions for audio data. オーディオデータの統計分析機能を提供します。
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
12 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¶
sampling_rate : float Sampling rate (Hz)
Source code in wandas/processing/stats.py
18 19 20 21 22 23 24 25 26 27 | |
process(data, *inputs)
¶
Source code in wandas/processing/stats.py
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 62 63 | |
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¶
sampling_rate : float Sampling rate (Hz) exponent : float Power exponent
Source code in wandas/processing/stats.py
39 40 41 42 43 44 45 46 47 48 49 50 | |
process(data, *inputs)
¶
Source code in wandas/processing/stats.py
62 63 | |
Sum
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Sum calculation
Source code in wandas/processing/stats.py
66 67 68 69 70 71 72 73 | |
Mean
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Mean calculation
Source code in wandas/processing/stats.py
76 77 78 79 80 81 82 83 | |
ChannelDifference
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Channel difference calculation operation
Source code in wandas/processing/stats.py
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 | |
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¶
sampling_rate : float Sampling rate (Hz) other_channel : int Channel to calculate difference with, default is 0
Source code in wandas/processing/stats.py
92 93 94 95 96 97 98 99 100 101 102 103 | |
process(data, *inputs)
¶
Source code in wandas/processing/stats.py
110 111 112 113 114 | |
Functions¶
Temporal Processing / 時間領域処理¶
Provides time-domain processing capabilities. 時間領域の処理機能を提供します。
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: AudioOperation[NDArrayReal, NDArrayReal]
Resampling operation
Source code in wandas/processing/temporal.py
53 54 55 56 57 58 59 60 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 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 | |
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 resampling operation
Parameters¶
sampling_rate : float Sampling rate (Hz) target_sampling_rate : float Target sampling rate (Hz)
Raises¶
ValueError If sampling_rate or target_sr is not positive
Source code in wandas/processing/temporal.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
get_metadata_updates()
¶
Update sampling rate to target sampling rate.
Returns¶
dict Metadata updates with new sampling rate
Notes¶
Resampling always produces output at target_sr, regardless of input sampling rate. All necessary parameters are provided at initialization.
Source code in wandas/processing/temporal.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after operation
Parameters¶
input_shape : tuple Input data shape
Returns¶
tuple Output data shape
Source code in wandas/processing/temporal.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return resampling output dtype metadata.
Source code in wandas/processing/temporal.py
139 140 141 | |
Trim
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Trimming operation
Source code in wandas/processing/temporal.py
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 | |
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)
¶
Initialize trimming operation
Parameters¶
sampling_rate : float Sampling rate (Hz) start : float Start time for trimming (seconds) end : float End time for trimming (seconds)
Source code in wandas/processing/temporal.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after operation
Parameters¶
input_shape : tuple Input data shape
Returns¶
tuple Output data shape
Source code in wandas/processing/temporal.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
FixLength
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Operation to adjust signal length to a specified length.
Source code in wandas/processing/temporal.py
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 | |
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 fix length operation
Parameters¶
sampling_rate : float Sampling rate (Hz) length : Optional[int] Target length for fixing duration : Optional[float] Target length for fixing
Source code in wandas/processing/temporal.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after operation
Parameters¶
input_shape : tuple Input data shape
Returns¶
tuple Output data shape
Source code in wandas/processing/temporal.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
RmsTrend
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
RMS calculation
Source code in wandas/processing/temporal.py
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 = '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)
¶
Initialize RMS calculation
Parameters¶
sampling_rate : float Sampling rate (Hz) frame_length : int Frame length, default is 2048 hop_length : int Hop length, default is 512 ref : Union[list[float], float] Reference value(s) for dB calculation dB : bool Whether to convert to decibels Aw : bool Whether to apply A-weighting before RMS calculation
Source code in wandas/processing/temporal.py
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 | |
get_metadata_updates()
¶
Update sampling rate based on hop length.
Returns¶
dict Metadata updates with new sampling rate based on hop length
Notes¶
The output sampling rate is determined by downsampling the input by hop_length. All necessary parameters are provided at initialization.
Source code in wandas/processing/temporal.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
calculate_output_shape(input_shape)
¶
Calculate output data shape after operation
Parameters¶
input_shape : tuple Input data shape (channels, samples)
Returns¶
tuple Output data shape (channels, frames)
Source code in wandas/processing/temporal.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return RMS trend output dtype metadata.
Source code in wandas/processing/temporal.py
423 424 425 | |
SoundLevel
¶
Bases: AudioOperation[NDArrayReal, NDArrayReal]
Time-weighted RMS or sound level with frequency and time weighting.
Source code in wandas/processing/temporal.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 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 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 | |
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)
¶
Source code in wandas/processing/temporal.py
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 | |
get_display_name()
¶
Get display name for the operation for use in channel labels.
Source code in wandas/processing/temporal.py
520 521 522 523 524 525 526 | |
calculate_output_dtype(input_dtype, *input_dtypes)
¶
Return sound level output dtype metadata.
Source code in wandas/processing/temporal.py
570 571 572 | |