Binaural Analysis
This section provides an overview of the binaural analysis tools available in Soundscapy. It includes a brief description of each tool, as well as information on how to access and use them.
Binaural
Bases: Signal
Binaural signal class for analysis of binaural signals. A signal consisting of 2D samples (array) and a sampling frequency (fs).
Subclasses the Signal class from python acoustics. Also adds attributes for the recording name. Adds the ability to do binaural analysis using the acoustics, scikit-maad and mosqito libraries. Optimised for batch processing with analysis settings predefined in a yaml file and passed to the class via the AnalysisSettings class.
See Also
acoustics.Signal : Base class for binaural signal
calibrate_to
calibrate_to(decibel, inplace=False)
Calibrate two channel signal to predefined Leq/dB levels.
PARAMETER | DESCRIPTION |
---|---|
decibel |
Value(s) to calibrate to in dB (Leq) Can also handle np.ndarray and pd.Series of length 2. If only one value is passed, will calibrate both channels to the same value.
TYPE:
|
inplace |
Whether to perform inplace or not, by default False
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Binaural
|
Calibrated Binaural signal |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If decibel is not a (float, int) or a list or tuple of length 2. |
See Also
acoustics.Signal.calibrate_to : Base method for calibration. Cannot handle 2ch calibration
Source code in soundscapy/analysis/_Binaural.py
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
from_wav
classmethod
from_wav(filename, calibrate_to=None, normalize=False)
Load a wav file and return a Binaural object
Overrides the Signal.from_wav method to return a Binaural object instead of a Signal object.
PARAMETER | DESCRIPTION |
---|---|
filename |
Filename of wav file to load
TYPE:
|
calibrate_to |
Value(s) to calibrate to in dB (Leq) Can also handle np.ndarray and pd.Series of length 2. If only one value is passed, will calibrate both channels to the same value.
TYPE:
|
normalize |
Whether to normalize the signal, by default False
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Binaural
|
Binaural signal object of wav recording |
See Also
acoustics.Signal.from_wav : Base method for loading wav files
Source code in soundscapy/analysis/_Binaural.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 111 112 113 114 115 116 117 118 119 |
|
maad_metric
maad_metric(metric, channel=('Left', 'Right'), as_df=True, verbose=False, analysis_settings=None, func_args={})
Run a metric from the scikit-maad library
Currently only supports running all of the alpha indices at once.
PARAMETER | DESCRIPTION |
---|---|
metric |
The metric to run
TYPE:
|
channel |
Which channels to process, by default None
TYPE:
|
as_df |
Whether to return a dataframe or not, by default True If True, returns a MultiIndex Dataframe with ("Recording", "Channel") as the index.
TYPE:
|
verbose |
Whether to print status updates, by default False
TYPE:
|
analysis_settings |
Settings for analysis, by default None Any settings given here will override those in the other options. Can pass any args or *kwargs to the underlying python acoustics method.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict or DataFrame
|
Dictionary of results if as_df is False, otherwise a pandas DataFrame |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If metric name is not recognised. |
Source code in soundscapy/analysis/_Binaural.py
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 |
|
mosqito_metric
mosqito_metric(metric, statistics=(5, 10, 50, 90, 95, 'avg', 'max', 'min', 'kurt', 'skew'), label=None, channel=('Left', 'Right'), as_df=True, return_time_series=False, parallel=True, verbose=False, analysis_settings=None, func_args={})
Run a metric from the mosqito library
PARAMETER | DESCRIPTION |
---|---|
metric |
TYPE:
|
statistics |
List of level statistics to calculate (e.g. L_5, L_90, etc.), by default (5, 10, 50, 90, 95, "avg", "max", "min", "kurt", "skew")
TYPE:
|
label |
Label to use for the metric, by default None If None, will pull from default label for that metric given in sq_metrics.DEFAULT_LABELS
TYPE:
|
channel |
Which channels to process, by default ("Left", "Right")
TYPE:
|
as_df |
Whether to return a dataframe or not, by default True If True, returns a MultiIndex Dataframe with ("Recording", "Channel") as the index.
TYPE:
|
return_time_series |
Whether to return the time series of the metric, by default False Cannot return time series if as_df is True
TYPE:
|
parallel |
Whether to run the channels in parallel, by default True If False, will run each channel sequentially. If being run as part of a larger parallel analysis (e.g. processing many recordings at once), this will automatically be set to False.
TYPE:
|
verbose |
Whether to print status updates, by default False
TYPE:
|
analysis_settings |
Settings for analysis, by default None Any settings given here will override those in the other options. Can pass any args or *kwargs to the underlying python acoustics method.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict or DataFrame
|
Dictionary of results if as_df is False, otherwise a pandas DataFrame |
See Also
binaural.mosqito_metric_2ch : Method for running metrics on 2 channels binaural.mosqito_metric_1ch : Method for running metrics on 1 channel
Source code in soundscapy/analysis/_Binaural.py
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 |
|
process_all_metrics
process_all_metrics(analysis_settings, parallel=True, verbose=False)
Run all metrics specified in the AnalysisSettings object
PARAMETER | DESCRIPTION |
---|---|
analysis_settings |
Analysis settings object
TYPE:
|
parallel |
Whether to run the channels in parallel for
TYPE:
|
verbose |
Whether to print status updates, by default False
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
MultiIndex Dataframe of results. Index includes "Recording" and "Channel" with a column for each metric. |
Source code in soundscapy/analysis/_Binaural.py
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 |
|
pyacoustics_metric
pyacoustics_metric(metric, statistics=(5, 10, 50, 90, 95, 'avg', 'max', 'min', 'kurt', 'skew'), label=None, channel=('Left', 'Right'), as_df=True, return_time_series=False, verbose=False, analysis_settings=None, func_args={})
Run a metric from the python acoustics library
PARAMETER | DESCRIPTION |
---|---|
metric |
The metric to run.
TYPE:
|
statistics |
List of level statistics to calulate (e.g. L_5, L_90, etc.), by default ( 5, 10, 50, 90, 95, "avg", "max", "min", "kurt", "skew", )
TYPE:
|
label |
Label to use for the metric, by default None If None, will pull from default label for that metric given in sq_metrics.DEFAULT_LABELS
TYPE:
|
channel |
Which channels to process, by default None If None, will process both channels
TYPE:
|
as_df |
Whether to return a dataframe or not, by default True If True, returns a MultiIndex Dataframe with ("Recording", "Channel") as the index.
TYPE:
|
return_time_series |
Whether to return the time series of the metric, by default False Cannot return time series if as_df is True
TYPE:
|
verbose |
Whether to print status updates, by default False
TYPE:
|
analysis_settings |
Settings for analysis, by default None Any settings given here will override those in the other options. Can pass any args or *kwargs to the underlying python acoustics method.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict or DataFrame
|
Dictionary of results if as_df is False, otherwise a pandas DataFrame |
See Also
metrics.pyacoustics_metric acoustics.standards_iso_tr_25417_2007.equivalent_sound_pressure_level : Base method for Leq calculation acoustics.standards.iec_61672_1_2013.sound_exposure_level : Base method for SEL calculation acoustics.standards.iec_61672_1_2013.time_weighted_sound_level : Base method for Leq level time series calculation
Source code in soundscapy/analysis/_Binaural.py
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 |
|
AnalysisSettings
AnalysisSettings(data, run_stats=True, force_run_all=False, filepath=None)
Bases: dict
Dict of settings for analysis methods. Each library has a dict of metrics, each of which has a dict of settings.
Source code in soundscapy/analysis/_AnalysisSettings.py
31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
default
classmethod
default(run_stats=True, force_run_all=False)
Generate a default settings object.
PARAMETER | DESCRIPTION |
---|---|
run_stats |
whether to include all stats listed or just return the main metric, by default True This can simplify the results dataframe if you only want the main metric. For example, rather than including L_5, L_50, etc. will only include LEq
TYPE:
|
force_run_all |
whether to force all metrics to run regardless of what is set in their options, by default False Use Cautiously. This can be useful if you want to run all metrics, but don't want to change the yaml file. Warning: If both mosqito:loudness_zwtv and mosqito:sharpness_din_from_loudness are present in the settings file, this will result in the loudness calc being run twice.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AnalysisSettings
|
AnalysisSettings object |
Source code in soundscapy/analysis/_AnalysisSettings.py
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 |
|
from_yaml
classmethod
from_yaml(filename, run_stats=True, force_run_all=False)
Generate a settings object from a yaml file.
PARAMETER | DESCRIPTION |
---|---|
filename |
filename of the yaml file
TYPE:
|
run_stats |
whether to include all stats listed or just return the main metric, by default True This can simplify the results dataframe if you only want the main metric. For example, rather than including L_5, L_50, etc. will only include LEq
TYPE:
|
force_run_all |
whether to force all metrics to run regardless of what is set in their options, by default False Use Cautiously. This can be useful if you want to run all metrics, but don't want to change the yaml file. Warning: If both mosqito:loudness_zwtv and mosqitsharpness_din_from_loudness are present in the settings file, this will result in the loudness calc being run twice.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AnalysisSettings
|
AnalysisSettings object |
Source code in soundscapy/analysis/_AnalysisSettings.py
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 70 71 |
|
parse_maad_all_alpha_indices
parse_maad_all_alpha_indices(metric)
Generate relevant settings for the maad all_alpha_indices methods.
PARAMETER | DESCRIPTION |
---|---|
metric |
metric to prepare for
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
run
|
Whether to run the metric
TYPE:
|
channel
|
channel(s) to run the metric on
TYPE:
|
Source code in soundscapy/analysis/_AnalysisSettings.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
parse_mosqito
parse_mosqito(metric)
Generate relevant settings for a mosqito metric.
PARAMETER | DESCRIPTION |
---|---|
metric |
metric to prepare for
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
run
|
Whether to run the metric
TYPE:
|
channel
|
channel(s) to run the metric on
TYPE:
|
statistics
|
statistics to run the metric on. If run_stats is False, will only return the main statistic
TYPE:
|
label
|
label to use for the metric
TYPE:
|
func_args
|
arguments to pass to the underlying metric function from MoSQITo
TYPE:
|
Source code in soundscapy/analysis/_AnalysisSettings.py
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 |
|
parse_pyacoustics
parse_pyacoustics(metric)
Generate relevant settings for a pyacoustics metric.
PARAMETER | DESCRIPTION |
---|---|
metric |
metric to prepare for
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
run
|
Whether to run the metric
TYPE:
|
channel
|
channel(s) to run the metric on
TYPE:
|
statistics
|
statistics to run the metric on. If run_stats is False, will only return the main statistic
TYPE:
|
label
|
label to use for the metric
TYPE:
|
func_args
|
arguments to pass to the underlying metric function from python acoustics
TYPE:
|
Source code in soundscapy/analysis/_AnalysisSettings.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
reload
reload()
Reload the settings from the yaml file.
Source code in soundscapy/analysis/_AnalysisSettings.py
107 108 109 |
|
to_yaml
to_yaml(filename)
Save settings to a yaml file.
PARAMETER | DESCRIPTION |
---|---|
filename |
filename of the yaml file
TYPE:
|
Source code in soundscapy/analysis/_AnalysisSettings.py
111 112 113 114 115 116 117 118 119 120 |
|
get_default_yaml
get_default_yaml(save_as='default_settings.yaml')
Retrieves the default settings for analysis from the GitHub repository and saves them to a file.
PARAMETER | DESCRIPTION |
---|---|
save_as |
The name of the file to save the default settings to. Defaults to "default_settings.yaml".
TYPE:
|
Source code in soundscapy/analysis/_AnalysisSettings.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
Binaural Metrics
add_results
add_results(results_df, metric_results)
Add results to MultiIndex dataframe
PARAMETER | DESCRIPTION |
---|---|
results_df |
MultiIndex dataframe to add results to
TYPE:
|
metric_results |
MultiIndex dataframe of results to add
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
Index includes "Recording" and "Channel" with a column for each index. |
Source code in soundscapy/analysis/binaural.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
|
maad_metric_2ch
maad_metric_2ch(b, metric, channel_names=('Left', 'Right'), as_df=False, verbose=False, func_args={})
Run a metric from the scikit-maad library (or suite of indices) on a binaural signal.
Currently only supports running all the alpha indices at once.
PARAMETER | DESCRIPTION |
---|---|
b |
Binaural signal to calculate the alpha indices for
TYPE:
|
metric |
Metric to calculate
TYPE:
|
channel_names |
Custom names for the channels, by default ("Left", "Right").
TYPE:
|
as_df |
Whether to return a pandas DataFrame, by default False If True, returns a MultiIndex Dataframe with ("Recording", "Channel") as the index.
TYPE:
|
verbose |
Whether to print status updates, by default False
TYPE:
|
func_args |
Additional arguments to pass to the metric function, by default {}
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict or DataFrame
|
Dictionary of results if as_df is False, otherwise a pandas DataFrame |
See Also
scikit-maad library
sq_metrics.maad_metric_1ch
Source code in soundscapy/analysis/binaural.py
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 |
|
mosqito_metric_2ch
mosqito_metric_2ch(b, metric, statistics=(5, 10, 50, 90, 95, 'avg', 'max', 'min', 'kurt', 'skew'), label=None, channel_names=('Left', 'Right'), as_df=False, return_time_series=False, parallel=True, verbose=False, func_args={})
function for calculating metrics from Mosqito.
PARAMETER | DESCRIPTION |
---|---|
b |
Binaural signal to calculate the sound quality indices for
TYPE:
|
metric |
TYPE:
|
statistics |
List of level statistics to calculate (e.g. L_5, L_90, etc.), by default (5, 10, 50, 90, 95, "avg", "max", "min", "kurt", "skew")
TYPE:
|
label |
Label to use for the metric in the results dictionary, by default None If None, will pull from default label for that metric given in DEFAULT_LABELS
TYPE:
|
channel_names |
Custom names for the channels, by default ("Left", "Right")
TYPE:
|
as_df |
Whether to return a pandas DataFrame, by default False If True, returns a MultiIndex Dataframe with ("Recording", "Channel") as the index.
TYPE:
|
return_time_series |
Whether to return the time series of the metric, by default False
Only works for metrics that return a time series array.
Cannot be returned in a dataframe. Will raise a warning if both
TYPE:
|
parallel |
Whether to run the channels in parallel, by default True If False, will run each channel sequentially. If being run as part of a larger parallel analysis (e.g. processing many recordings at once), this will automatically be set to False.
TYPE:
|
verbose |
Whether to print status updates, by default False
TYPE:
|
func_args |
Additional arguments to pass to the metric function, by default {}
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict or DataFrame
|
Dictionary of results if as_df is False, otherwise a pandas DataFrame |
Source code in soundscapy/analysis/binaural.py
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 |
|
prep_multiindex_df
prep_multiindex_df(dictionary, label='Leq', incl_metric=True)
df help to prepare a MultiIndex dataframe from a dictionary of results
PARAMETER | DESCRIPTION |
---|---|
dictionary |
Dict of results with recording name as key, channels {"Left", "Right"} as second key, and Leq metric as value
TYPE:
|
label |
Name of metric included, by default "Leq"
TYPE:
|
incl_metric |
Whether to include the metric value in the resulting dataframe, by default True If False, will only set up the DataFrame with the proper MultiIndex
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
Index includes "Recording" and "Channel" with a column for each index if |
Source code in soundscapy/analysis/binaural.py
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 |
|
process_all_metrics
process_all_metrics(b, analysis_settings, parallel=True, verbose=False)
Loop through all metrics included in analysis_settings
and add results to results_df
PARAMETER | DESCRIPTION |
---|---|
b |
Binaural signal to process
TYPE:
|
analysis_settings |
Settings for analysis, including
TYPE:
|
parallel |
Whether to run the channels in parallel for
TYPE:
|
verbose |
Whether to print status updates, by default False
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
MultiIndex DataFrame with results from all metrics for one Binaural recording |
Source code in soundscapy/analysis/binaural.py
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 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 |
|
pyacoustics_metric_2ch
pyacoustics_metric_2ch(b, metric, statistics=(5, 10, 50, 90, 95, 'avg', 'max', 'min', 'kurt', 'skew'), label=None, channel_names=('Left', 'Right'), as_df=False, return_time_series=False, verbose=False, func_args={})
Run a metric from the python acoustics library on a Binaural object.
PARAMETER | DESCRIPTION |
---|---|
b |
Binaural signal to calculate the metric for
TYPE:
|
metric |
The metric to run
TYPE:
|
statistics |
List of level statistics to calculate (e.g. L_5, L_90, etc), by default (5, 10, 50, 90, 95, "avg", "max", "min", "kurt", "skew")
TYPE:
|
label |
Label to use for the metric in the results dictionary, by default None If None, will pull from default label for that metric given in DEFAULT_LABELS
TYPE:
|
channel_names |
Custom names for the channels, by default ("Left", "Right")
TYPE:
|
as_df |
Whether to return a pandas DataFrame, by default False If True, returns a MultiIndex Dataframe with ("Recording", "Channel") as the index.
TYPE:
|
return_time_series |
Whether to return the time series of the metric, by default False Cannot return time series if as_df is True
TYPE:
|
verbose |
Whether to print status updates, by default False
TYPE:
|
func_args |
Arguments to pass to the metric function, by default {}
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict or DataFrame
|
Dictionary of results if as_df is False, otherwise a pandas DataFrame |
See Also
sq_metrics.pyacoustics_metric_1ch
Source code in soundscapy/analysis/binaural.py
23 24 25 26 27 28 29 30 31 32 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 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 |
|
maad_metric_1ch
maad_metric_1ch(s, metric, as_df=False, verbose=False, func_args={})
Run a metric from the scikit-maad library (or suite of indices) on a single channel signal.
Currently only supports running all of the alpha indices at once.
PARAMETER | DESCRIPTION |
---|---|
s |
Single channel signal to calculate the alpha indices for
TYPE:
|
metric |
Metric to calculate
TYPE:
|
as_df |
Whether to return a pandas DataFrame, by default False If True, returns a MultiIndex Dataframe with ("Recording", "Channel") as the index.
TYPE:
|
verbose |
Whether to print status updates, by default False
TYPE:
|
**func_args |
Additional keyword arguments to pass to the metric function, by default {}
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict or DataFrame
|
Dictionary of results if as_df is False, otherwise a pandas DataFrame |
See Also
maad.features.all_spectral_alpha_indices maad.features.all_temporal_alpha_indices
Source code in soundscapy/analysis/metrics.py
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 |
|
mosqito_metric_1ch
mosqito_metric_1ch(s, metric, statistics=(5, 10, 50, 90, 95, 'avg', 'max', 'min', 'kurt', 'skew'), label=None, as_df=False, return_time_series=False, func_args={})
Calculating a metric and accompanying statistics from Mosqito.
PARAMETER | DESCRIPTION |
---|---|
s |
Single channel signal to calculate the sound quality indices for
TYPE:
|
metric |
TYPE:
|
statistics |
List of level statistics to calculate (e.g. L_5, L_90, etc.), by default (5, 10, 50, 90, 95, "avg", "max", "min", "kurt", "skew")
TYPE:
|
label |
Label to use for the metric in the results dictionary, by default None If None, will pull from default label for that metric given in DEFAULT_LABELS
TYPE:
|
as_df |
Return the results as a dataframe, by default False
TYPE:
|
return_time_series |
Return the time series array of the metric, by default False
Only works for metrics that return a time series array.
Cannot be returned in a dataframe. Will raise a warning if both
TYPE:
|
verbose |
Whether to print status updates, by default False
TYPE:
|
**func_args |
Additional keyword arguments to pass to the metric function, by default {}
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
dictionary of the calculated statistics. key is metric name + statistic (e.g. LZeq_5, LZeq_90, etc) value is the calculated statistic |
RAISES | DESCRIPTION |
---|---|
ValueError
|
Signal must be single channel. Can be a slice of a multichannel signal. |
ValueError
|
Metric is not recognized. Must be one of {"loudness_zwtv", "sharpness_din_from_loudness", "sharpness_din_perseg", "roughness_dw"} |
Warning
|
|
See Also
mosqito.sq_metrics.loudness_zwtv : MoSQito Loudness calculation mosqito.sq_metrics.roughness_dw : MoSQito Roughness calculation mosqito.sq_metrics.sharpness_din_from_loudness : MoSQito Sharpness calculation
Source code in soundscapy/analysis/metrics.py
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 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 |
|
pyacoustics_metric_1ch
pyacoustics_metric_1ch(s, metric, statistics=(5, 10, 50, 90, 95, 'avg', 'max', 'min', 'kurt', 'skew'), label=None, as_df=False, return_time_series=False, verbose=False, func_args={})
Run a metric from the pyacoustics library on a single channel object.
PARAMETER | DESCRIPTION |
---|---|
s |
Single channel signal to calculate the metric for
TYPE:
|
metric |
The metric to run
TYPE:
|
statistics |
List of level statistics to calculate (e.g. L_5, L_90, etc), by default (5, 10, 50, 90, 95, "avg", "max", "min", "kurt", "skew")
TYPE:
|
label |
Label to use for the metric in the results dictionary, by default None If None, will pull from default label for that metric given in DEFAULT_LABELS
TYPE:
|
as_df |
Whether to return a pandas DataFrame, by default False If True, returns a MultiIndex Dataframe with ("Recording", "Channel") as the index.
TYPE:
|
return_time_series |
Whether to return the time series of the metric, by default False Cannot return time series if as_df is True
TYPE:
|
verbose |
Whether to print status updates, by default False
TYPE:
|
**func_args |
Additional keyword arguments to pass to the metric function, by default {}
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
dictionary of the calculated statistics. key is metric name + statistic (e.g. LZeq_5, LZeq_90, etc) value is the calculated statistic |
RAISES | DESCRIPTION |
---|---|
ValueError
|
Metric must be one of {"LZeq", "Leq", "LAeq", "LCeq", "SEL"} |
See Also
acoustics
Source code in soundscapy/analysis/metrics.py
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 |
|
Parallel Processing
load_analyse_binaural
load_analyse_binaural(wav_file, levels, analysis_settings, verbose=True)
Load and analyse binaural file
PARAMETER | DESCRIPTION |
---|---|
wav_file |
Path to wav file
TYPE:
|
levels |
List of levels to analyse
TYPE:
|
analysis_settings |
Analysis settings
TYPE:
|
verbose |
Print progress, by default True
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
results
|
Dictionary with results
TYPE:
|
Source code in soundscapy/analysis/parallel_processing.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
parallel_process
parallel_process(wav_files, results_df, levels, analysis_settings, verbose=True)
Parallel processing of binaural files
PARAMETER | DESCRIPTION |
---|---|
wav_files |
List of wav files
TYPE:
|
results_df |
Results dataframe
TYPE:
|
levels |
Dictionary with levels
TYPE:
|
analysis_settings |
Analysis settings
TYPE:
|
verbose |
Print progress, by default True
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
results_df
|
Results dataframe
TYPE:
|
Source code in soundscapy/analysis/parallel_processing.py
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|