Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: overall level and level over time #201

Merged
merged 14 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/201.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feat: overall level and level over time
1 change: 1 addition & 0 deletions doc/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This section describes how to use Python to interact programmatically with PyAns
signal_processing
spectral_processing
spectrogram_processing
standard_levels
sound_composer
sound_power
psychoacoustics
Expand Down
10 changes: 10 additions & 0 deletions doc/source/api/standard_levels.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Standard levels
---------------

.. module:: ansys.sound.core.standard_levels

.. autosummary::
:toctree: _autosummary

OverallLevel
LevelOverTime
2 changes: 2 additions & 0 deletions src/ansys/sound/core/_pyansys_sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from ansys.dpf.core import FieldsContainer
import numpy as np

REFERENCE_ACOUSTIC_PRESSURE = 2e-5


class PyAnsysSound:
"""
Expand Down
36 changes: 36 additions & 0 deletions src/ansys/sound/core/standard_levels/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Standard level classes.

Helper classes related to the computation of standard levels.
"""

from ._standard_levels_parent import StandardLevelsParent
from .level_over_time import LevelOverTime
from .overall_level import OverallLevel

__all__ = (
"StandardLevelsParent",
"OverallLevel",
"LevelOverTime",
)
35 changes: 35 additions & 0 deletions src/ansys/sound/core/standard_levels/_standard_levels_parent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Standard levels parent class."""
from .._pyansys_sound import PyAnsysSound

DICT_SCALE = {"dB": 0, "RMS": 1}
DICT_FREQUENCY_WEIGHTING = {"": 0, "A": 1, "B": 2, "C": 3}


class StandardLevelsParent(PyAnsysSound):
"""
Abstract base class for standard level calculations.

This is the base class for all standard level classes and should not be used as is.
"""
Loading
Loading