File size: 1,255 Bytes
22da9a9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 |
from pydantic import BaseModel
import yaml
class FrequencyConfig(BaseModel):
min: int
max: int
n_bins: int
class AcousticalConstantsConfig(BaseModel):
sound_speed: float
air_density: float
atmospheric_pressure: int
reference_pressure: float
measurement_distance: float
directivity_factor: int
class Config(BaseModel):
default_loudspeaker_cfg: str
frequency: FrequencyConfig
acoustical_constants: AcousticalConstantsConfig
def load_config(yaml_path: str) -> Config:
with open(yaml_path, "r") as file:
data = yaml.safe_load(file)
return Config(**data)
class ElectricalConfig(BaseModel):
input_voltage: float
coil_resistance: float
coil_inductance: float
class MechanicalConfig(BaseModel):
mass: float
compliance: float
resistance: float
class AcousticalConfig(BaseModel):
effective_diameter: float
class LoudspeakerConfig(BaseModel):
electrical: ElectricalConfig
electromechanical_factor: float
mechanical: MechanicalConfig
acoustical: AcousticalConfig
def load_loudspeaker_config(yaml_path: str) -> LoudspeakerConfig:
with open(yaml_path, "r") as file:
data = yaml.safe_load(file)
return LoudspeakerConfig(**data)
|