Skip to content

Commit

Permalink
DPF: alternative CV port implementation (#198)
Browse files Browse the repository at this point in the history
* use int/bool tuple for port defs

* union type for int and tuple

* update changelog
  • Loading branch information
dromer authored Sep 18, 2024
1 parent 182af3c commit 6de9b22
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Features:

* Only disable DSP with new `--nodsp` flag
* Use pydantic types to define metadata objects
* DPF: CV flag in portgroups

0.12.0
-----
Expand Down
10 changes: 8 additions & 2 deletions hvcc/generators/c2dpf/templates/portGroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ void {{class_name}}::initAudioPort(bool input, uint32_t index, AudioPort& port)
{%- if meta.port_groups.input|length %}
{%- for group, gConfig in meta.port_groups.input.items() %}
{%- for port, value in gConfig.items() %}
case {{value}}:
case {{value[0] or value}}:
port.name = "Input {{port}} ({{group}})";
port.symbol = "in_{{port|lower}}_{{group|lower}}";
port.groupId = kPortGroup{{group}};
{%- if value[1] is sameas true %}
port.hints = kAudioPortIsCV | kCVPortHasPositiveUnipolarRange | kCVPortHasScaledRange | kCVPortIsOptional;
{%- endif %}
break;
{%- endfor %}
{%- endfor %}
Expand All @@ -38,10 +41,13 @@ void {{class_name}}::initAudioPort(bool input, uint32_t index, AudioPort& port)
{%- if meta.port_groups.output|length %}
{%- for group, gConfig in meta.port_groups.output.items() %}
{%- for port, value in gConfig.items() %}
case {{value}}:
case {{value[0] or value}}:
port.name = "Output {{port}} ({{group}})";
port.symbol = "out_{{port|lower}}_{{group|lower}}";
port.groupId = kPortGroup{{group}};
{%- if value[1] is sameas true %}
port.hints = kAudioPortIsCV | kCVPortHasPositiveUnipolarRange | kCVPortHasScaledRange | kCVPortIsOptional;
{%- endif %}
break;
{%- endfor %}
{%- endfor %}
Expand Down
6 changes: 3 additions & 3 deletions hvcc/generators/types/meta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Literal, List, Optional, Union
from typing import Dict, Literal, List, Optional, Tuple, Union
from pydantic import BaseModel, HttpUrl


Expand All @@ -25,8 +25,8 @@ class DPFUISize(BaseModel):


class DPFPortGroups(BaseModel):
input: Dict[str, Dict[str, int]] = {}
output: Dict[str, Dict[str, int]] = {}
input: Dict[str, Dict[str, Union[int, Tuple[int, bool]]]] = {}
output: Dict[str, Dict[str, Union[int, Tuple[int, bool]]]] = {}


class DPF(BaseModel):
Expand Down

0 comments on commit 6de9b22

Please sign in to comment.