Skip to content

Commit

Permalink
Merge branch 'release/0.13.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
dromer committed Feb 19, 2025
2 parents ac87fbf + 471d367 commit 7eb3a41
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 72 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.13.1
current_version = 0.13.3

[bumpversion:file:pyproject.toml]
search = {current_version}
Expand Down
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
**.dll filter=lfs diff=lfs merge=lfs -text
**.wav filter=lfs diff=lfs merge=lfs -textx

# never include repository configurations in exports
.git* export-ignore
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
CHANGELOG
=====

0.13.3
-----

Bugfixes:

* Daisy: add ScopedIrqBlocker to several functions. Should fix midi input issues and potentially others.
* Daisy: use FIFO to buffer midi TX messages and call them in the main loop instead of during process()
* JS: Ignore windows batch if inside of MingW environment

0.13.2
-----

Bugfixes:

* Incorrect use of new extern formatting in ir2c and c2js templates

0.13.1
-----

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Heavy Compiler Collection (hvcc)

[![Build Status](https://github.com/Wasted-Audio/hvcc/actions/workflows/build.yml/badge.svg)](https://github.com/Wasted-Audio/hvcc/actions)
[![Build Status](https://github.com/Wasted-Audio/hvcc/actions/workflows/ci.yml/badge.svg)](https://github.com/Wasted-Audio/hvcc/actions)
[![pypi](https://img.shields.io/pypi/v/hvcc.svg)](https://pypi.python.org/pypi/hvcc)
[![python](https://img.shields.io/pypi/pyversions/hvcc.svg)](https://pypi.python.org/pypi/hvcc)

Expand Down
2 changes: 1 addition & 1 deletion docs/02.getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ This list will be continuously epanded to document differences in object behavio
* Heavy does not accept arguments and control connections to: `[rzero~]`, `[rzero_rev~]`, `[czero~]`, `[czero_rev~]`. In Heavy, these objects accept only signal inputs. Arguments and control connections are ignored.
* On the `[select]` object it is currently not possible to set the arguments via the right inlet (internally a hardcoded switch_case is used).
* Heavy supports remote/send messages, however empty messages are currently removed. So the typical `[; bla 1(` multiline message needs to contain at least something on the first line: `[_; bla 1(`.
* Remote/send messages with `sinesum` argument to fill tables are not supported.
* Remote/send messages with `sinesum` or `const` arguments to initialize table values are not supported.
* `[metro]` and `[timer]` objects do not accept tempo messages or unit arguments.
* `[snapshot~]` does not respond within the same control flow as it executes in signal context. Its output happens on the next audio cycle, so additional care for this control flow needs to be taken into account if you depend on synchronous execution. It also doesn't accept `[set(` messages.
* Certain filters are sensitive to ‘blowing up’ at very low or very high cutoff frequencies and/or resonances, due to the filter coefficients not being perfectly represented with a finite number of bits. While Pure data natively uses 64 bits, platforms like `OWL` and `Daisy` that use 32 bit float are more sensitive to this. For example, the Pure data `[bp~]` filter is implemented with a biquad which is prone to fail or distort with cutoff frequencies less than around 200 Hz (at 48kHz sample rate).
Expand Down
42 changes: 35 additions & 7 deletions hvcc/generators/c2daisy/templates/HeavyDaisy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define SAMPLE_RATE {{samplerate}}.f

{% if has_midi or usb_midi %}
{% if (has_midi is sameas true) or (usb_midi is sameas true) %}
#define HV_HASH_NOTEIN 0x67E37CA3
#define HV_HASH_CTLIN 0x41BE0f9C
#define HV_HASH_POLYTOUCHIN 0xBC530F59
Expand All @@ -31,6 +31,8 @@
#define MIDI_RT_STOP 0xFC
#define MIDI_RT_ACTIVESENSE 0xFE
#define MIDI_RT_RESET 0xFF

#define MIDI_OUT_FIFO_SIZE 128
{% endif %}

using namespace daisy;
Expand All @@ -48,6 +50,9 @@ FIFO<FixedCapStr<64>, 64> event_log;
{% elif usb_midi is sameas true %}
daisy::MidiUsbHandler midiusb;
{% endif %}
{% if (has_midi is sameas true) or (usb_midi is sameas true) %}
FIFO<uint8_t, MIDI_OUT_FIFO_SIZE> midi_tx_fifo;
{% endif %}
// int midiOutCount;
// uint8_t* midiOutData;
void CallbackWriteIn(Heavy_{{patch_name}}* hv);
Expand Down Expand Up @@ -99,6 +104,8 @@ DaisyHvParamOut DaisyOutputParameters[DaisyNumOutputParameters] = {
// Typical Switch case for Message Type.
void HandleMidiMessage(MidiEvent m)
{
ScopedIrqBlocker block; //< Disables interrupts while in scope

for (int i = 0; i <= 2; ++i) {
hv->sendMessageToReceiverV(HV_HASH_MIDIIN, 0, "ff",
(float) m.data[i],
Expand Down Expand Up @@ -258,6 +265,26 @@ int main(void)
LoopWriteOut();
{% endif %}

{% if (has_midi is sameas true) or (usb_midi is sameas true) %}
uint8_t midiData[MIDI_OUT_FIFO_SIZE];
size_t numElements = 0;

while(!midi_tx_fifo.IsEmpty() && numElements < MIDI_OUT_FIFO_SIZE)
{
midiData[numElements++] = midi_tx_fifo.PopFront();
}

if(numElements > 0)
{
{% if has_midi is sameas true %}
hardware.midi.SendMessage(midiData, numElements);
{% endif %}
{% if (debug_printing is not sameas true) and (usb_midi is sameas true) %}
midiusb.SendMessage(midiData, numElements);
{% endif %}
}
{% endif %}

{% 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 @@ -300,12 +327,9 @@ void audiocallback(daisy::AudioHandle::InputBuffer in, daisy::AudioHandle::Outpu
{% if (has_midi is sameas true) or (usb_midi is sameas true) %}
void HandleMidiOut(uint8_t *midiData, const uint8_t numElements)
{
{% if has_midi is sameas true %}
hardware.midi.SendMessage(midiData, numElements);
{% endif %}
{% if (debug_printing is not sameas true) and (usb_midi is sameas true) %}
midiusb.SendMessage(midiData, numElements);
{% endif %}
for (int i = 0; i < numElements; i++) {
midi_tx_fifo.PushBack(midiData[i]);
}
}

void HandleMidiSend(uint32_t sendHash, const HvMessage *m)
Expand Down Expand Up @@ -476,6 +500,8 @@ static void printHook(HeavyContextInterface *c, const char *printLabel, const ch
*/
void LoopWriteIn(Heavy_{{patch_name}}* hv)
{
ScopedIrqBlocker block; //< Disables interrupts while in scope

{% for param in loop_write_in %}
{% if param.bool %}
if ({{param.process}})
Expand Down Expand Up @@ -505,6 +531,8 @@ void CallbackWriteIn(Heavy_{{patch_name}}* hv)
*
*/
void LoopWriteOut() {
ScopedIrqBlocker block; //< Disables interrupts while in scope

{% for param in loop_write_out %}
{% if param.bool %}
if ({{param.value}})
Expand Down
3 changes: 2 additions & 1 deletion hvcc/generators/c2js/c2js.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def run_emscripten(
"""Run the emcc command to compile C source files to a javascript library.
"""

if os.name == 'nt':
# Detect Windows OS, but ignore if running in MingW
if os.name == 'nt' and os.environ.get('MSYSTEM') is None:
emcc_path = which("emcc.bat")
else:
emcc_path = which("emcc")
Expand Down
16 changes: 8 additions & 8 deletions hvcc/generators/c2js/template/hv_worklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,25 @@ class {{name}}_AudioLibWorklet extends AudioWorkletProcessor {
}

var parameterInHashes = {
{%- for k,v in externs.parameters.in %}
{%- for k,v in externs.parameters.inParam %}
"{{v.display}}": {{v.hash}}, // {{v.display}}
{%- endfor %}
};

var parameterOutHashes = {
{%- for k,v in externs.parameters.out %}
{%- for k,v in externs.parameters.outParam %}
"{{v.display}}": {{v.hash}}, // {{v.display}}
{%- endfor %}
};

var eventInHashes = {
{%- for k,v in externs.events.in %}
{%- for k,v in externs.events.inEvent %}
"{{v.display}}": {{v.hash}}, // {{v.display}}
{%- endfor %}
};

var eventOutHashes = {
{%- for k,v in externs.events.out %}
{%- for k,v in externs.events.outEvent %}
"{{v.display}}": {{v.hash}}, // {{v.display}}
{%- endfor %}
};
Expand All @@ -216,22 +216,22 @@ function sendMidiIn(hv_context, message) {
var channel = message[0] & 0x0F;
var data1 = message[1];
var data2 = message[2];

// all events to [midiin]
for (var i = 1; i <= 2; i++) {
_hv_sendMessageToReceiverFF(hv_context, HV_HASH_MIDIIN, 0,
message[i],
channel
);
}

// realtime events to [midirealtimein]
if (MIDI_REALTIME.includes(message[0])) {
_hv_sendMessageToReceiverFF(hv_context, HV_HASH_MIDIREALTIMEIN, 0,
message[0]
);
}

switch(command) {
case 0x80: // note off
_hv_sendMessageToReceiverFFF(hv_context, HV_HASH_NOTEIN, 0,
Expand Down Expand Up @@ -335,7 +335,7 @@ function sendMidiOut(sendName, msg) {
]
case "__hv_midiout":
let firstByte = _hv_msg_getFloat(msg, 0);
return (firstByte === 192 || firstByte === 208) ?
return (firstByte === 192 || firstByte === 208) ?
[_hv_msg_getFloat(msg, 0), _hv_msg_getFloat(msg, 1)] :
[_hv_msg_getFloat(msg, 0), _hv_msg_getFloat(msg, 1), _hv_msg_getFloat(msg, 2)];
default:
Expand Down
16 changes: 8 additions & 8 deletions hvcc/generators/c2js/template/hv_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,25 +168,25 @@ var {{name}}_AudioLib = function(options) {
}

var parameterInHashes = {
{%- for k,v in externs.parameters.in %}
{%- for k,v in externs.parameters.inParam %}
"{{v.display}}": {{v.hash}}, // {{v.display}}
{%- endfor %}
};

var parameterOutHashes = {
{%- for k,v in externs.parameters.out %}
{%- for k,v in externs.parameters.outParam %}
"{{v.display}}": {{v.hash}}, // {{v.display}}
{%- endfor %}
};

var eventInHashes = {
{%- for k,v in externs.events.in %}
{%- for k,v in externs.events.inEvent %}
"{{v.display}}": {{v.hash}}, // {{v.display}}
{%- endfor %}
};

var eventOutHashes = {
{%- for k,v in externs.events.out %}
{%- for k,v in externs.events.outEvent %}
"{{v.display}}": {{v.hash}}, // {{v.display}}
{%- endfor %}
};
Expand Down Expand Up @@ -319,22 +319,22 @@ function sendMidiIn(hv_context, message) {
var channel = message[0] & 0x0F;
var data1 = message[1];
var data2 = message[2];

// all events to [midiin]
for (var i = 1; i <= 2; i++) {
_hv_sendMessageToReceiverFF(hv_context, HV_HASH_MIDIIN, 0,
message[i],
channel
);
}

// realtime events to [midirealtimein]
if (MIDI_REALTIME.includes(message[0])) {
_hv_sendMessageToReceiverFF(hv_context, HV_HASH_MIDIREALTIMEIN, 0,
message[0]
);
}

switch(command) {
case 0x80: // note off
_hv_sendMessageToReceiverFFF(hv_context, HV_HASH_NOTEIN, 0,
Expand Down Expand Up @@ -438,7 +438,7 @@ function sendMidiOut(sendName, msg) {
]
case "__hv_midiout":
let firstByte = _hv_msg_getFloat(msg, 0);
return (firstByte === 192 || firstByte === 208) ?
return (firstByte === 192 || firstByte === 208) ?
[_hv_msg_getFloat(msg, 0), _hv_msg_getFloat(msg, 1)] :
[_hv_msg_getFloat(msg, 0), _hv_msg_getFloat(msg, 1), _hv_msg_getFloat(msg, 2)];
default:
Expand Down
3 changes: 2 additions & 1 deletion hvcc/generators/c2pdext/templates/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ common.sources += $(wildcard pdext/*.cpp)
# all extra files to be included in binary distribution of the library
#datafiles = helloworld-help.pd helloworld-meta.pd README.md

include Makefile.pdlibbuilder
PDLIBBUILDER_DIR=.
include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder
8 changes: 4 additions & 4 deletions hvcc/generators/ir2c/templates/Heavy_NAME.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ extern "C" {
#pragma mark - Heavy Context
#endif

{% if externs.parameters.in|length > 0 -%}
{% if externs.parameters.inParam|length > 0 -%}
typedef enum {
{%- for k,v in externs.parameters.inParam %}
HV_{{name|upper}}_PARAM_IN_{{k|upper}} = {{v.hash}}, // {{v.display}}
{%- endfor %}
} Hv_{{name}}_ParameterIn;
{% endif -%}

{% if externs.parameters.out|length > 0 %}
{% if externs.parameters.outParam|length > 0 %}
typedef enum {
{%- for k,v in externs.parameters.outParam %}
HV_{{name|upper}}_PARAM_OUT_{{k|upper}} = {{v.hash}}, // {{v.display}}
{%- endfor %}
} Hv_{{name}}_ParameterOut;
{% endif -%}

{% if externs.events.in|length > 0 %}
{% if externs.events.inEvent|length > 0 %}
typedef enum {
{%- for k,v in externs.events.inEvent %}
HV_{{name|upper}}_EVENT_IN_{{k|upper}} = {{v.hash}}, // {{v.display}}
{%- endfor %}
} Hv_{{name}}_EventIn;
{% endif -%}

{% if externs.events.out|length > 0 %}
{% if externs.events.outEvent|length > 0 %}
typedef enum {
{%- for k,v in externs.events.outEvent %}
HV_{{name|upper}}_EVENT_OUT_{{k|upper}} = {{v.hash}}, // {{v.display}}
Expand Down
2 changes: 1 addition & 1 deletion hvcc/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.13.1"
VERSION = "0.13.3"
Loading

0 comments on commit 7eb3a41

Please sign in to comment.