Skip to content

Commit

Permalink
Merge branch 'v0.12.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dromer committed Sep 20, 2024
2 parents b6bffc0 + dc05838 commit 44708e7
Show file tree
Hide file tree
Showing 25 changed files with 255 additions and 138 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.12.0
current_version = 0.12.1

[bumpversion:file:setup.cfg]

Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
CHANGELOG
=====

0.12.1
-----

Features:

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

Bugfixes

* wwise: allow Bang messages in OnSendMessageCallback()
* Improve `[cos~]` precision.

0.12.0
-----

Expand Down
2 changes: 0 additions & 2 deletions docs/02.getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ To send audio output add a `[dac~]` The number of channels can be configured by

Note that top-level graphs (e.g. `_main.pd`) should not have any `[inlet~]` or `[outlet~]` objects. These are reserved only for abstractions.

> NOTE: Currently if your main patch does not have at least an `adc~` or `dac~` configured signal rate objects will not be evaluated in the graph!
## Exposing Parameters

### Input Parameters
Expand Down
4 changes: 1 addition & 3 deletions docs/03.gen.daisy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ Daisy is an embedded platform for music. It features everything you need for cre

Currently daisy platform is supported for:

* `seed`
* `pod`
* `petal`
* `patch`
* `patch_init`
* `patch_sm`
* `field`

Which can be configured using the `-m` metadata.json `daisy.board` setting:

```json
{
"daisy": {
"board": "seed"
"board": "pod"
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions examples/dpf/dpf_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"midi_input": 1,
"midi_output": 0,
"plugin_formats": [
"lv2_dsp",
"vst",
"lv2_sep",
"vst2",
"jack"
]
}
}
}
23 changes: 17 additions & 6 deletions hvcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from hvcc.generators.c2pdext import c2pdext
from hvcc.generators.c2wwise import c2wwise
from hvcc.generators.c2unity import c2unity
from hvcc.generators.types.meta import Meta


class Colours:
Expand Down Expand Up @@ -209,11 +210,12 @@ def compile_dataflow(
search_paths: Optional[List] = None,
generators: Optional[List] = None,
verbose: bool = False,
copyright: Optional[str] = None
copyright: Optional[str] = None,
nodsp: Optional[bool] = False
) -> OrderedDict:

results: OrderedDict = OrderedDict() # default value, empty dictionary
patch_meta = {}
patch_meta = Meta()

# basic error checking on input
if os.path.isfile(in_path):
Expand All @@ -230,11 +232,12 @@ def compile_dataflow(
if os.path.isfile(patch_meta_file):
with open(patch_meta_file) as json_file:
try:
patch_meta = json.load(json_file)
patch_meta_json = json.load(json_file)
patch_meta = Meta(**patch_meta_json)
except Exception as e:
return add_error(results, f"Unable to open json_file: {e}")

patch_name = patch_meta.get("name", patch_name)
patch_name = patch_meta.name or patch_name
generators = ["c"] if generators is None else [x.lower() for x in generators]

if in_path.endswith((".pd")):
Expand Down Expand Up @@ -273,7 +276,8 @@ def compile_dataflow(
static_dir=os.path.join(os.path.dirname(__file__), "generators/ir2c/static"),
output_dir=c_src_dir,
externs=externs,
copyright=copyright)
copyright=copyright,
nodsp=nodsp)

# check for errors
if results["ir2c"]["notifs"].get("has_error", False):
Expand Down Expand Up @@ -401,6 +405,11 @@ def main() -> bool:
"--results_path",
help="Write results dictionary to the given path as a JSON-formatted string."
" Target directory will be created if it does not exist.")
parser.add_argument(
"--nodsp",
action='store_true',
help="Disable DSP. Run as control-only patch."
)
parser.add_argument(
"-v",
"--verbose",
Expand All @@ -420,7 +429,9 @@ def main() -> bool:
search_paths=args.search_paths,
generators=args.gen,
verbose=args.verbose,
copyright=args.copyright)
copyright=args.copyright,
nodsp=args.nodsp
)

errorCount = 0
for r in list(results.values()):
Expand Down
42 changes: 17 additions & 25 deletions hvcc/generators/c2daisy/c2daisy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import time
import json2daisy # type: ignore

from typing import Dict, Optional
from typing import Any, Dict, Optional

from ..copyright import copyright_manager
from ..types.meta import Meta, Daisy
from . import parameters


Expand All @@ -33,7 +34,7 @@ def compile(
out_dir: str,
externs: Dict,
patch_name: Optional[str] = None,
patch_meta: Optional[Dict] = None,
patch_meta: Meta = Meta(),
num_input_channels: int = 0,
num_output_channels: int = 0,
copyright: Optional[str] = None,
Expand All @@ -44,17 +45,10 @@ def compile(

out_dir = os.path.join(out_dir, "daisy")

if patch_meta:
patch_name = patch_meta.get("name", patch_name)
daisy_meta = patch_meta.get("daisy", {})
else:
daisy_meta = {}

board = daisy_meta.get("board", "pod")
daisy_meta: Daisy = patch_meta.daisy
board = daisy_meta.board

copyright_c = copyright_manager.get_copyright_for_c(copyright)
# copyright_plist = copyright or u"Copyright {0} Enzien Audio, Ltd." \
# " All Rights Reserved.".format(datetime.datetime.now().year)

try:
# ensure that the output directory does not exist
Expand All @@ -69,8 +63,8 @@ def compile(
source_dir = os.path.join(out_dir, "source")
shutil.copytree(c_src_dir, source_dir)

if daisy_meta.get('board_file'):
header, board_info = json2daisy.generate_header_from_file(daisy_meta['board_file'])
if daisy_meta.board_file is not None:
header, board_info = json2daisy.generate_header_from_file(daisy_meta.board_file)
else:
header, board_info = json2daisy.generate_header_from_name(board)

Expand All @@ -87,12 +81,12 @@ def compile(
component_glue['num_output_channels'] = num_output_channels
component_glue['has_midi'] = board_info['has_midi']
component_glue['displayprocess'] = board_info['displayprocess']
component_glue['debug_printing'] = daisy_meta.get('debug_printing', False)
component_glue['usb_midi'] = daisy_meta.get('usb_midi', False)
component_glue['debug_printing'] = daisy_meta.debug_printing
component_glue['usb_midi'] = daisy_meta.usb_midi
component_glue['pool_sizes_kb'] = externs["memoryPoolSizesKb"]

# samplerate
samplerate = daisy_meta.get('samplerate', 48000)
samplerate = daisy_meta.samplerate
if samplerate >= 96000:
component_glue['samplerate'] = 96000
elif samplerate >= 48000:
Expand All @@ -105,8 +99,8 @@ def compile(
component_glue['samplerate'] = 8000

# blocksize
blocksize = daisy_meta.get('blocksize')
if blocksize:
blocksize = daisy_meta.blocksize
if blocksize is not None:
component_glue['blocksize'] = max(min(256, blocksize), 1)
else:
component_glue['blocksize'] = None
Expand All @@ -125,20 +119,18 @@ def compile(
with open(daisy_cpp_path, 'w') as f:
f.write(rendered_cpp)

makefile_replacements = {'name': patch_name}
makefile_replacements['linker_script'] = daisy_meta.get('linker_script', '')
if makefile_replacements['linker_script'] != '':
makefile_replacements['linker_script'] = daisy_meta["linker_script"]
makefile_replacements: Dict[str, Any] = {'name': patch_name}
makefile_replacements['linker_script'] = daisy_meta.linker_script

# libdaisy path
path = daisy_meta.get('libdaisy_path', 2)
path = daisy_meta.libdaisy_path
if isinstance(path, int):
makefile_replacements['libdaisy_path'] = f'{"../" * path}libdaisy'
elif isinstance(path, str):
makefile_replacements['libdaisy_path'] = path

makefile_replacements['bootloader'] = daisy_meta.get('bootloader', '')
makefile_replacements['debug_printing'] = daisy_meta.get('debug_printing', False)
makefile_replacements['bootloader'] = daisy_meta.bootloader
makefile_replacements['debug_printing'] = daisy_meta.debug_printing

rendered_makefile = env.get_template('Makefile').render(makefile_replacements)
with open(os.path.join(source_dir, "Makefile"), "w") as f:
Expand Down
26 changes: 13 additions & 13 deletions hvcc/generators/c2daisy/templates/HeavyDaisy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ Heavy_{{patch_name}}* hv;

void audiocallback(daisy::AudioHandle::InputBuffer in, daisy::AudioHandle::OutputBuffer out, size_t size);
static void sendHook(HeavyContextInterface *c, const char *receiverName, uint32_t receiverHash, const HvMessage * m);
{% if debug_printing %}
{% if debug_printing is sameas true %}
static void printHook(HeavyContextInterface *c, const char *printLabel, const char *msgString, const HvMessage *m);
/** FIFO to hold messages as we're ready to print them */
FIFO<FixedCapStr<64>, 64> event_log;
{% elif usb_midi %}
{% elif usb_midi is sameas true %}
daisy::MidiUsbHandler midiusb;
{% endif %}
// int midiOutCount;
Expand Down Expand Up @@ -95,7 +95,7 @@ DaisyHvParamOut DaisyOutputParameters[DaisyNumOutputParameters] = {
};
{% endif %}

{% if has_midi or usb_midi %}
{% if (has_midi is sameas true) or (usb_midi is sameas true) %}
// Typical Switch case for Message Type.
void HandleMidiMessage(MidiEvent m)
{
Expand Down Expand Up @@ -208,19 +208,19 @@ int main(void)
{% if blocksize %}
hardware.SetAudioBlockSize({{blocksize}});
{% endif %}
{% if has_midi %}
{% if has_midi is sameas true %}
MidiUartHandler::Config midi_config;
hardware.midi.Init(midi_config);
hardware.midi.StartReceive();
{% endif %}
{% if not debug_printing and usb_midi %}
{% if (debug_printing is not sameas true) and (usb_midi is sameas true) %}
MidiUsbHandler::Config midiusb_config;
midiusb.Init(midiusb_config);
midiusb.StartReceive();
{% endif %}

hardware.StartAudio(audiocallback);
{% if debug_printing %}
{% if debug_printing is sameas true %}
hardware.som.StartLog();
hv->setPrintHook(printHook);

Expand All @@ -243,7 +243,7 @@ int main(void)
HandleMidiMessage(hardware.midi.PopEvent());
}
{% endif %}
{% if not debug_printing and usb_midi %}
{% if (debug_printing is not sameas true) and (usb_midi is sameas true) %}
midiusb.Listen();
while(midiusb.HasEvents())
{
Expand All @@ -258,7 +258,7 @@ int main(void)
LoopWriteOut();
{% endif %}

{% if debug_printing %}
{% if debug_printing is sameas true %}
/** Now separately, every 5ms we'll print the top message in our queue if there is one */
if(now - log_time > 5)
{
Expand Down Expand Up @@ -297,13 +297,13 @@ void audiocallback(daisy::AudioHandle::InputBuffer in, daisy::AudioHandle::Outpu
hardware.PostProcess();
}

{% if has_midi or usb_midi %}
{% if (has_midi is sameas true) or (usb_midi is sameas true) %}
void HandleMidiOut(uint8_t *midiData, const uint8_t numElements)
{
{% if has_midi %}
{% if has_midi is sameas true %}
hardware.midi.SendMessage(midiData, numElements);
{% endif %}
{% if not debug_printing and usb_midi %}
{% if (debug_printing is not sameas true) and (usb_midi is sameas true) %}
midiusb.SendMessage(midiData, numElements);
{% endif %}
}
Expand Down Expand Up @@ -448,12 +448,12 @@ static void sendHook(HeavyContextInterface *c, const char *receiverName, uint32_
}
}
{% endif %}
{% if has_midi or usb_midi %}
{% if (has_midi is sameas true) or (usb_midi is sameas true) %}
HandleMidiSend(receiverHash, m);
{% endif %}
}

{% if debug_printing %}
{% if debug_printing is sameas true %}
/** Receives messages from the PD [print] object and writes them to the serial console.
*
*/
Expand Down
8 changes: 4 additions & 4 deletions hvcc/generators/c2daisy/templates/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ TARGET = HeavyDaisy_{{name}}
# Library Locations
LIBDAISY_DIR = {{libdaisy_path}}

{% if linker_script != '' %}
{%- if linker_script != '' %}
LDSCRIPT = {{linker_script}}
{% endif %}
{%- endif %}

{% if bootloader != '' %}
{% if bootloader != None %}
APP_TYPE = {{bootloader}}
{% endif %}

{% if debug_printing %}
{% if debug_printing is sameas true %}
LDFLAGS += -u _printf_float
{% endif %}

Expand Down
Loading

0 comments on commit 44708e7

Please sign in to comment.