|
| 1 | +# Copyright (C) 2026 Wasted Audio |
| 2 | +# |
| 3 | +# This program is free software: you can redistribute it and/or modify |
| 4 | +# it under the terms of the GNU General Public License as published by |
| 5 | +# the Free Software Foundation, either version 3 of the License, or |
| 6 | +# (at your option) any later version. |
| 7 | +# |
| 8 | +# This program is distributed in the hope that it will be useful, |
| 9 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | +# GNU General Public License for more details. |
| 12 | +# |
| 13 | +# You should have received a copy of the GNU General Public License |
| 14 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | + |
| 16 | +from typing import Dict, Optional |
| 17 | +from pathlib import Path |
| 18 | + |
| 19 | +from .HeavyIrObject import HeavyIrObject |
| 20 | +from .HeavyGraph import HeavyGraph |
| 21 | + |
| 22 | +from hvcc.generators.ir2c.SignalNamHeader import ModelNet, load_nam_file |
| 23 | + |
| 24 | + |
| 25 | +class HIrNam(HeavyIrObject): |
| 26 | + """ __nam~f |
| 27 | + """ |
| 28 | + |
| 29 | + def __init__( |
| 30 | + self, |
| 31 | + obj_type: str, |
| 32 | + args: Optional[Dict] = None, |
| 33 | + graph: Optional[HeavyGraph] = None, |
| 34 | + annotations: Optional[Dict] = None |
| 35 | + ) -> None: |
| 36 | + assert obj_type == "__nam~f" |
| 37 | + |
| 38 | + # load the nam file to retrieve the model type |
| 39 | + assert args is not None |
| 40 | + model_net, _, _ = load_nam_file(Path(args["nam"])) |
| 41 | + |
| 42 | + # overload the object type based on the model |
| 43 | + if model_net == ModelNet.Nano: |
| 44 | + obj_type = "__nam_nano~f" |
| 45 | + elif model_net == ModelNet.Feather: |
| 46 | + obj_type = "__nam_feather~f" |
| 47 | + elif model_net == ModelNet.Lite: |
| 48 | + obj_type = "__nam_lite~f" |
| 49 | + elif model_net == ModelNet.Standard: |
| 50 | + obj_type = "__nam_standard~f" |
| 51 | + |
| 52 | + super().__init__(obj_type, args=args, graph=graph, annotations=annotations) |
0 commit comments