Skip to content

Commit

Permalink
Merge branch 'release/0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer committed Apr 20, 2022
2 parents 950c792 + bb7cc6c commit ff48586
Show file tree
Hide file tree
Showing 77 changed files with 2,062 additions and 674 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.4.0
current_version = 0.5.0

[bumpversion:file:setup.cfg]

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
lfs: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
pip install tox tox-gh-actions
git lfs pull
- name: Run tox
run: |
tox
run: tox
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
CHANGELOG
=====

0.5.0
-----

* c2owl generator
* migrate @owl to @raw
* c2daisy json2daisy integration
* enable control and signal tests
* push f-string usage

0.4.0
-----

Expand Down
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ It has since then been expanded to provide further support for many different pl

* python 3.7 or higher
- `jinja2` (for generator templating)
- `nose2` (for tests, optional)
- `tox` (for tests, optional)

## Installation
hvcc is available from pypi.org and can be installed using python3 pip:
Expand Down Expand Up @@ -81,17 +81,7 @@ It is also possible to pass a list of generators:

`$ hvcc ~/myProject/_main.pd -o ~/Desktop/somewhere/else/ -n mySynth -g unity wwise js`

Available generator options:

* `c`
* `bela`
* `daisy`
* `dpf`
* `fabric`
* `js`
* `pdext`
* `unity`
* `wwise`
A list of available generator options can be found [here](/docs/03.generators.md)

### `-p` Search Paths

Expand Down
7 changes: 7 additions & 0 deletions docs/03.gen.daisy.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Daisy

Daisy is an embedded platform for music. It features everything you need for creating high fidelity audio hardware devices.

This Generator is typically it is used in combination with [pd2dsy](https://github.com/electro-smith/pd2dsy).

Currently daisy platform is supported for:

* `field`
* `seed`
* `pod`
* `petal`
Expand All @@ -16,3 +21,5 @@ Which can be configured using the `-m` metadata.json `daisy.board` setting:
}
}
```

However one can also create custom board layouts. See the pd2dsy documentation for more information.
22 changes: 22 additions & 0 deletions docs/03.gen.owl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# OWL

The main project output for this generator can be found in `<output_dir>/owl/`.

## implementation

This generator uses some separate "raw" code paths to link the DSP graph. Instead of `@hv_param` currently `@raw` and `@raw_param` are used.

Legacy `@owl` and `@owl_param` are still functional for backwards compatibility.

It currently also overloads `HvMessage.c` and `HvUtils.h` with some different optimizations for this target.

Relevant files:

* custom interpreter: `hvcc/interpreters/pd2hv/pdowl.py`
* generator: `hvcc/generators/c2owl/c2owl.py`
* custom deps:
* `hvcc/generators/c2owl/deps/HvMessage.c`
* `hvcc/generators/c2owl/deps/HvUtils.h`
* templates:
* `hvcc/generators/c2owl/templates/HeavyOwl.hpp`
* `hvcc/generators/c2owl/templates/HeavyOwlConstants.h`
File renamed without changes.
3 changes: 2 additions & 1 deletion docs/03.generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ HVCC supports a number of dedicated generators that can help to wrap the heavy c
* [DPF](03.gen.dpf.md)
* [Fabric](03.gen.fabric.md)
* [Javascript](03.gen.javascript.md)
* [OWL](03.gen.owl.md)
* `Pdext`
* [Wwise](03.gen.wwise.md)
* [Unity](03.gen.unity.md)
* [Unity](03.gen.unity.md)
18 changes: 15 additions & 3 deletions hvcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from hvcc.generators.c2js import c2js
from hvcc.generators.c2daisy import c2daisy
from hvcc.generators.c2dpf import c2dpf
from hvcc.generators.c2owl import c2owl
from hvcc.generators.c2pdext import c2pdext
from hvcc.generators.c2wwise import c2wwise
from hvcc.generators.c2unity import c2unity
Expand Down Expand Up @@ -75,8 +76,8 @@ def check_extern_name_conflicts(extern_type, extern_list, results):
for j, u in enumerate(extern_list[i + 1:]):
if v[0].upper() == u[0].upper():
add_error(results,
"Conflicting {0} names '{1}' and '{2}', make sure that "
"capital letters are not the only difference.".format(extern_type, v[0], u[0]))
f"Conflicting {extern_type} names '{v[0]}' and '{u[0]}', make sure that "
"capital letters are not the only difference.")


def generate_extern_info(hvir, results):
Expand Down Expand Up @@ -181,10 +182,11 @@ def compile_dataflow(in_path, out_dir, patch_name=None, patch_meta_file=None,
if list(results.values())[0]["notifs"].get("has_error", False):
return results

subst_name = re.sub(r'\W', '_', patch_name)
results["hv2ir"] = hv2ir.hv2ir.compile(
hv_file=os.path.join(list(results.values())[0]["out_dir"], list(results.values())[0]["out_file"]),
# ensure that the ir filename has no funky characters in it
ir_file=os.path.join(out_dir, "ir", re.sub("\W", "_", patch_name) + ".heavy.ir.json"),
ir_file=os.path.join(out_dir, "ir", f"{subst_name}.heavy.ir.json"),
patch_name=patch_name,
verbose=verbose)

Expand Down Expand Up @@ -310,6 +312,16 @@ def compile_dataflow(in_path, out_dir, patch_name=None, patch_meta_file=None,
copyright=copyright,
verbose=verbose)

if "owl" in generators:
if verbose:
print("--> Generating OWL plugin")
results["c2owl"] = c2owl.c2owl.compile(
c_src_dir=c_src_dir,
out_dir=os.path.join(out_dir, "Source"),
patch_name=patch_name,
copyright=copyright,
verbose=verbose)

if "pdext" in generators:
if verbose:
print("--> Generating Pd external")
Expand Down
6 changes: 3 additions & 3 deletions hvcc/core/hv2ir/BufferPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def num_buffers(self, connection_type=None):
elif connection_type in self.pool:
return sum(len(v) for v in self.pool[connection_type].values())
else:
raise HeavyException("Unknown connection type: \"{0}\"".format(connection_type))
raise HeavyException(f"Unknown connection type: \"{connection_type}\"")

def get_buffer(self, connection_type, count=1, excludeSet=None):
""" Returns a currently unused buffer. The buffer can be assigned a retain count. An optional
Expand Down Expand Up @@ -71,7 +71,7 @@ def retain_buffer(self, b, count=1):
v.remove(b)
pool[k + count].append(b)
return k + count # return the new retain count
raise HeavyException("{0} not found in BufferPool!".format(b))
raise HeavyException(f"{b} not found in BufferPool!")

def release_buffer(self, b, count=1):
""" Reduces the retain count of the buffer. Returns the new count.
Expand All @@ -88,7 +88,7 @@ def release_buffer(self, b, count=1):
v.remove(b)
pool[k - count].append(b)
return k - count # return the new retain count
raise HeavyException("{0} not found in BufferPool!".format(b))
raise HeavyException(f"{b} not found in BufferPool!")

def __repr__(self):
return self.pool["~f>"].__repr__() + self.pool["~i>"].__repr__()
5 changes: 1 addition & 4 deletions hvcc/core/hv2ir/Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,4 @@ def __hash__(self):
return self.__hash

def __repr__(self):
return "[{0}:{1}] {4} [{2}:{3}]".format(
self.from_object, self.outlet_index,
self.to_object, self.inlet_index,
self.type)
return f"[{self.from_object}:{self.outlet_index}] {self.type} [{self.to_object}:{self.inlet_index}]"
2 changes: 1 addition & 1 deletion hvcc/core/hv2ir/HIrConvolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def reduce(self):
self.args["table_id"] = table_obj.id
return ({self}, [])
else:
self.add_error("Cannot find table named \"{0}\" for object {1}.".format(self.args["table"], self))
self.add_error(f"Cannot find table named \"{self.args['table']}\" for object {self}.")
4 changes: 2 additions & 2 deletions hvcc/core/hv2ir/HIrInlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ def _resolved_outlet_type(self, outlet_index=0):
return list(connection_type_set)[0]
else:
raise HeavyException(
"{0} has multiple incident connections of differing type. "
"The outlet type cannot be explicitly resolved.".format(self))
f"{self} has multiple incident connections of differing type. "
"The outlet type cannot be explicitly resolved.")
2 changes: 1 addition & 1 deletion hvcc/core/hv2ir/HIrReceive.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ def __init__(self, obj_type, args=None, graph=None, annotations=None):
if args["extern"]:
# externed receivers must contain only alphanumeric characters or underscores,
# so that the names can be easily and transparently turned into code
if re.search("\W", args["name"]):
if re.search(r"\W", args["name"]):
self.add_error("Parameter and Event names may only contain"
f"alphanumeric characters or underscore: '{args['name']}'")
4 changes: 2 additions & 2 deletions hvcc/core/hv2ir/HIrSend.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, obj_type, args=None, graph=None, annotations=None):
if args["extern"]:
# output parameters must contain only alphanumeric characters or underscores,
# so that the names can be easily and transparently turned into code
if re.search("\W", args["name"]):
if re.search(r"\W", args["name"]):
self.add_error(f"Parameter and Event names may only contain \
alphanumeric characters or underscore: '{args['name']}'")

Expand All @@ -39,5 +39,5 @@ def get_ir_control_list(self):
"extern": self.args["extern"],
"hash": self.args["hash"],
"display": self.args["name"],
"name": (("_" + self.args["name"]) if re.match("\d", self.args["name"]) else self.args["name"])
"name": ((f"_{self.args['name']}") if re.match(r"\d", self.args["name"]) else self.args["name"])
}]
2 changes: 1 addition & 1 deletion hvcc/core/hv2ir/HIrTabhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def reduce(self):
self.args["table_id"] = table_obj.id
return ({self}, [])
else:
self.add_error("Can't find table with name \"{0}\".".format(self.args["table"]))
self.add_error(f"Can't find table with name \"{self.args['table']}\".")
2 changes: 1 addition & 1 deletion hvcc/core/hv2ir/HIrTabread.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def reduce(self):
self.args["table_id"] = table_obj.id
return ({self}, [])
else:
self.add_error("Cannot find table named \"{0}\" for object {1}.".format(self.args["table"], self))
self.add_error(f"Cannot find table named \"{self.args['table']}\" for object {self}.")
2 changes: 1 addition & 1 deletion hvcc/core/hv2ir/HIrTabwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def reduce(self):
self.args["table_id"] = table_obj.id
return ({self}, [])
else:
self.add_error("Can't find table with name \"{0}\".".format(self.args["table"]))
self.add_error(f"Can't find table with name \"{self.args['table']}\".")
5 changes: 2 additions & 3 deletions hvcc/core/hv2ir/HLangBinop.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ def reduce(self):
if "m" in fmt:
self.add_error(
"A binary operator cannot have both a signal and control "
"connection to the same inlet: {0}".format(fmt))
f"connection to the same inlet: {fmt}")
else:
self.add_error(
"Unknown inlet configuration: {0}".format(fmt))
self.add_error(f"Unknown inlet configuration: {fmt}")
2 changes: 1 addition & 1 deletion hvcc/core/hv2ir/HLangBiquad.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def reduce(self):
return {x}, self.get_connection_move_list(x)

else:
raise HeavyException("Unsupported connection format to biquad: {0}".format(fmt))
raise HeavyException(f"Unsupported connection format to biquad: {fmt}")
4 changes: 2 additions & 2 deletions hvcc/core/hv2ir/HLangIf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# # TODO(mhroth): implement this
# x = HeavyParser.graph_from_file("./hvlib/if~i.hv.json")
# else:
# raise HeavyException("Unhandled connection configuration to object [if]: {0}".format(
# self._get_connection_format(self.inlet_connections)))
# fmt = self._get_connection_format(self.inlet_connections)
# raise HeavyException(f"Unhandled connection configuration to object [if]: {fmt}")

# return ({x}, self.get_connection_move_list(x))
2 changes: 1 addition & 1 deletion hvcc/core/hv2ir/HLangReceive.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def reduce(self):

else:
fmt = self._get_connection_format(self.outlet_connections)
self.add_error("Unknown outlet configuration: {0}".format(fmt))
self.add_error(f"Unknown outlet configuration: {fmt}")
4 changes: 2 additions & 2 deletions hvcc/core/hv2ir/HLangSend.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, obj_type, args, graph, annotations=None):
def reduce(self):
if self.has_inlet_connection_format("c"):
ir_args = dict(self.args)
ir_args["hash"] = "0x{0:X}".format(HeavyLangObject.get_hash(ir_args["name"]))
ir_args["hash"] = f"0x{HeavyLangObject.get_hash(ir_args['name']):X}"
x = HIrSend("__send", ir_args, annotations=self.annotations)
return ({x}, self.get_connection_move_list(x))

Expand All @@ -49,4 +49,4 @@ def reduce(self):

else:
fmt = self._get_connection_format(self.inlet_connections)
self.add_error("Unknown inlet configuration: {0}".format(fmt))
self.add_error(f"Unknown inlet configuration: {fmt}")
2 changes: 1 addition & 1 deletion hvcc/core/hv2ir/HLangTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, obj_type, args, graph, annotations=None):
if self.args["extern"]:
# externed tables must contain only alphanumeric characters or underscores,
# so that the names can be easily and transparently turned into code
if re.search("\W", args["name"]):
if re.search(r"\W", args["name"]):
self.add_error("Table names may only contain alphanumeric characters"
f"or underscore: '{args['name']}'")

Expand Down
6 changes: 3 additions & 3 deletions hvcc/core/hv2ir/HLangUnop.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ def reduce(self):
x = HeavyIrObject(self.type) # is this correct? no idea what x is otherwise
return ({HeavyIrObject("__cast~if", {})}, self.get_connection_move_list(x))
elif self.has_inlet_connection_format("f"):
ir_type = "__{0}~f".format(self.type)
ir_type = f"__{self.type}~f"
assert ir_type in HLangUnop.__HEAVY_DICT[self.type]
x = HeavyIrObject(ir_type)
return ({x}, self.get_connection_move_list(x, "~f>"))
elif self.has_inlet_connection_format("i"):
ir_type = "__{0}~i".format(self.type)
ir_type = f"__{self.type}~i"
assert ir_type in HLangUnop.__HEAVY_DICT[self.type]
x = HeavyIrObject(ir_type)
return ({x}, self.get_connection_move_list(x, "~i>"))
elif self.has_inlet_connection_format("c"):
ir_type = "__{0}".format(self.type)
ir_type = f"__{self.type}"
assert ir_type in HLangUnop.__HEAVY_DICT[self.type]
x = HeavyIrObject(ir_type)
return ({x}, self.get_connection_move_list(x, "-->"))
Expand Down
4 changes: 1 addition & 3 deletions hvcc/core/hv2ir/HLangVario.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def __init__(self, obj_type, args, graph, annotations=None):
def reduce(self):
var_obj = self.graph.resolve_object_for_name(self.name, "var")
if var_obj is None:
raise HeavyException("No corresponding \"var\" object found for object {0} in file {1}".format(
self,
self.graph.file))
raise HeavyException(f"No corresponding \"var\" object found for object {self} in file {self.graph.file}")

if self.has_inlet_connection_format("f") and self.has_outlet_connection_format("_"):
x = HeavyIrObject("__varwrite~f", {"var_id": var_obj.id})
Expand Down
Loading

0 comments on commit ff48586

Please sign in to comment.