Skip to content

Commit

Permalink
Merge branch 'develop' into feature/cos_improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
dromer committed Sep 20, 2024
2 parents 06bb65a + eaebd0a commit 63167ee
Show file tree
Hide file tree
Showing 42 changed files with 340 additions and 147 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.11.0
current_version = 0.12.0

[bumpversion:file:setup.cfg]

Expand Down
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,30 @@ CHANGELOG
Next Release
-----

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()

0.12.0
-----

* Core: parse remote/send messages
* Core: MIDI i/o added to memoryPool
* Core: support `[else/knob]` as `[float]`
* Daisy: set heavy context after hw.init()
* OWL: add Polytouchin and Polytouchout
* JS: webmidi input
* Bugfix: MIDI out objects in output Paremeters
* Docs: add instructions for loading custom samples in JS
* Small Bugfixes:
* MIDI out objects in output Paremeters
* JS: AudioWorklet fillTableWithFloatBuffer

0.11.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
31 changes: 31 additions & 0 deletions docs/03.gen.javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,34 @@ The JS target supports [exposing event and parameter](02.getting_started#exposin
```

Note: these are calls directly to the `AudioLib` so make sure to include `.audiolib` when sending events or messages.

## Loading Custom Samples

If you have a table that is externed, using the `@hv_param` annotation, it can be used to load audio files from the web page. The table will be resized to fit this sample data.

`[table array1 100 @hv_table]`

The webAudioContext can load any url, but typically this will be a local path. Modify your html using the following:

```js
// Sample loading
function loadAudio(url) {
var rq = new XMLHttpRequest();
rq.open("GET", url, true);
rq.responseType = "arraybuffer";
rq.send();

rq.onload = function() {
var audioData = rq.response;
loader.webAudioContext.decodeAudioData(audioData, function(buffer){
loader.fillTableWithFloatBuffer("array1", buffer.getChannelData(0));
});
}
}
```

This can then be called from a user action or any other mechanism that works for you:

```html
<button style="padding: 10px;" type="button" id="loadButton" onclick="loadAudio('custom_sample.wav');">Load Audio</button>
```
3 changes: 3 additions & 0 deletions docs/09.supported_vanilla_objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ del
delay
div
exp
else/knob
f
float
floatatom
Expand Down Expand Up @@ -129,6 +130,7 @@ biquad~
bp~
catch~
clip~
complex-mod~
cos~
cpole~
czero_rev~
Expand All @@ -142,6 +144,7 @@ delwrite~
env~
exp~
ftom~
hilbert~
hip~
inlet~
line~
Expand Down
2 changes: 0 additions & 2 deletions docs/10.unsupported_vanilla_objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@ value
block~
bob~
bonk~
complex-mod~
expr~
fexpr~
fft~
framp~
hilbert~
ifft~
log~
loop~
Expand Down
Binary file removed docs/img/docs_archives.png
Binary file not shown.
Binary file removed docs/img/docs_fabric_audiopool.png
Binary file not shown.
Binary file removed docs/img/docs_fabric_oneshot.png
Binary file not shown.
Binary file removed docs/img/docs_fabric_params.png
Binary file not shown.
Binary file removed docs/img/docs_fabric_patches.png
Binary file not shown.
Binary file removed docs/img/docs_fabric_uploader.png
Binary file not shown.
Binary file removed docs/img/docs_new_patch.png
Binary file not shown.
Binary file removed docs/img/docs_targets.png
Binary file not shown.
Binary file removed docs/img/docs_tokens_adddelete.png
Binary file not shown.
Binary file removed docs/img/docs_tokens_userprofile.png
Binary file not shown.
Binary file removed docs/img/docs_tokens_usersettings.png
Binary file not shown.
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
Loading

0 comments on commit 63167ee

Please sign in to comment.