Skip to content

Commit

Permalink
Merge branch 'v0.6.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
dromer committed Jan 9, 2023
2 parents 56cdfe6 + ef40e87 commit 0c495d7
Show file tree
Hide file tree
Showing 55 changed files with 1,862 additions and 216 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.6.2
current_version = 0.6.3

[bumpversion:file:setup.cfg]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- uses: actions/checkout@v3
with:
lfs: true
submodules: true
- name: Initialize lfs
run: git lfs pull
- name: Set up Python ${{ matrix.python-version }}
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tests/src/midifile"]
path = tests/src/midifile
url = https://github.com/craigsapp/midifile.git
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG
=====

0.6.3
-----

* add polytouchin and polytouchout
* add tests for midi input objects
* bugfixes for midi objects bendin, ctlin, notein, pgmin, pgmout, touchin

0.6.2
-----

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

* python 3.7 or higher
- `jinja2` (for generator templating)
- `importlib_resources` (for reading static resources)
- `json2daisy` (for daisy integration)
- `tox` (for tests, optional)
- `clang/clang++` (for building tests, optional)

## Installation
hvcc is available from pypi.org and can be installed using python3 pip:
Expand Down
22 changes: 13 additions & 9 deletions docs/04.midi.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The following Pd objects are mapped to their corresponding heavy parameter and i
| ----------------- | ------------------- | ---------- |
| [notein] | __hv_notein | 0x67E37CA3 |
| [ctlin] | __hv_ctlin | 0x41BE0f9C |
| [polytouchin] | __hv_polytouchin | 0xBC530F59 |
| [pgmin] | __hv_pgmin | 0x2E1EA03D |
| [touchin] | __hv_touchin | 0x553925BD |
| [bendin] | __hv_bendin | 0x3083F0F7 |
Expand All @@ -25,15 +26,16 @@ The following Pd objects are mapped to their corresponding heavy parameter and i

The same principle applies for sending MIDI data out of the heavy context. If you add a [noteout] object there'll be a corresponding sendhook callback with a message containing the MIDI data sent by the patch.

| Pd object | heavy sendhook | heavy hash |
| --------- | ---------------- |------------|
| [noteout] | __hv_noteout | 0xD1D4AC2 |
| [ctlout] | __hv_ctlout | 0xE5e2A040 |
| [pgmout] | __hv_pgmout | 0x8753E39E |
| [touchout] | __hv_touchout | 0x476D4387 |
| [bendout] | __hv_bendout | 0xE8458013 |
| [midiout] | __hv_midiout | 0x6511DE55 |
| [midiout] | __hv_midioutport | 0x165707E4 |
| Pd object | heavy sendhook | heavy hash |
| ------------- | ----------------- |------------|
| [noteout] | __hv_noteout | 0xD1D4AC2 |
| [ctlout] | __hv_ctlout | 0xE5e2A040 |
| [polytouchout] | __hv_polytouchout | 0xD5ACA9D1 |
| [pgmout] | __hv_pgmout | 0x8753E39E |
| [touchout] | __hv_touchout | 0x476D4387 |
| [bendout] | __hv_bendout | 0xE8458013 |
| [midiout] | __hv_midiout | 0x6511DE55 |
| [midiout] | __hv_midioutport | 0x165707E4 |

## Note!

Expand All @@ -43,6 +45,8 @@ The same principle applies for sending MIDI data out of the heavy context. If yo

`* It is generally the users responsibility to convert to and from the MIDI byte data to the float values used by heavy.`

`* The [ctlin] object is currently unable to match CC message 0. One can of course still filter for this message in the patch itself.`

Some framework targets like [DPF](03.gen.dpf.md) already have implementations available. However, if you're integrating the C/C++ code on a custom platform then you'll need to provide your own conversion process.

Here's the `DPF` implementation as an example.
Expand Down
2 changes: 2 additions & 0 deletions docs/09.supported_vanilla_objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ pgmout
pd
pipe
poly
polytouchin
polytouchout
pow
powtodb
print
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 @@ -39,8 +39,6 @@ oscformat
oscparse
plot
pointer
polytouchin
polytouchout
realtime
savepanel
savestate
Expand Down
54 changes: 29 additions & 25 deletions hvcc/core/hv2ir/HLangNoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,32 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os
import random

from .HeavyLangObject import HeavyLangObject
from .HeavyParser import HeavyParser


class HLangNoise(HeavyLangObject):
""" Handles the HeavyLang "noise" object.
"""

def __init__(self, obj_type, args, graph, annotations=None):
assert obj_type == "noise"
HeavyLangObject.__init__(self, "noise", args, graph,
num_inlets=1,
num_outlets=1,
annotations=annotations)

def reduce(self):
seed = int(random.uniform(1, 2147483647)) # assign a random 32-bit seed
noise_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "./hvlib/noise.hv.json")
x = HeavyParser.graph_from_file(noise_path, graph_args={"seed": seed})
x.reduce()
# TODO(mhroth): deal with control input
return ({x}, self.get_connection_move_list(x))

# moved to HeavyParser.py because of circular dependency


# import os
# import random

# from .HeavyLangObject import HeavyLangObject
# from .HeavyParser import HeavyParser


# class HLangNoise(HeavyLangObject):
# """ Handles the HeavyLang "noise" object.
# """

# def __init__(self, obj_type, args, graph, annotations=None):
# assert obj_type == "noise"
# HeavyLangObject.__init__(self, "noise", args, graph,
# num_inlets=1,
# num_outlets=1,
# annotations=annotations)

# def reduce(self):
# seed = int(random.uniform(1, 2147483647)) # assign a random 32-bit seed
# noise_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "./hvlib/noise.hv.json")
# x = HeavyParser.graph_from_file(noise_path, graph_args={"seed": seed})
# x.reduce()
# # TODO(mhroth): deal with control input
# return ({x}, self.get_connection_move_list(x))
28 changes: 23 additions & 5 deletions hvcc/core/hv2ir/HeavyParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import json
import random
import os

from .HIrConvolution import HIrConvolution
Expand All @@ -29,13 +30,15 @@
from .HLangAdc import HLangAdc
from .HLangBinop import HLangBinop
from .HLangBiquad import HLangBiquad
from .HLangDac import HLangDac
from .HLangDelay import HLangDelay
# from .HLangIf import HLangIf
# from .HLangIf import HLangIf # circular import. moved here
from .HeavyException import HeavyException
from .HeavyIrObject import HeavyIrObject
from .HeavyLangObject import HeavyLangObject
from .HLangLine import HLangLine
from .HLangMessage import HLangMessage
# from .HLangNoise import HLangNoise # circular import. moved here
from .HLangPhasor import HLangPhasor
from .HLangPrint import HLangPrint
from .HLangReceive import HLangReceive
Expand Down Expand Up @@ -223,10 +226,25 @@ def reduce(self):
return ({x}, self.get_connection_move_list(x))


# NOTE(mhroth): these imports are at the end of the file in order to prevent
# circular import errors
from .HLangDac import HLangDac
from .HLangNoise import HLangNoise
class HLangNoise(HeavyLangObject):
""" Handles the HeavyLang "noise" object.
"""

def __init__(self, obj_type, args, graph, annotations=None):
assert obj_type == "noise"
HeavyLangObject.__init__(self, "noise", args, graph,
num_inlets=1,
num_outlets=1,
annotations=annotations)

def reduce(self):
seed = int(random.uniform(1, 2147483647)) # assign a random 32-bit seed
noise_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "./hvlib/noise.hv.json")
x = HeavyParser.graph_from_file(noise_path, graph_args={"seed": seed})
x.reduce()
# TODO(mhroth): deal with control input
return ({x}, self.get_connection_move_list(x))


# A list of all of the HeavyLang objects and the classes
# that will translate them into HeavyIR objects.
Expand Down
23 changes: 23 additions & 0 deletions hvcc/generators/c2dpf/templates/HeavyDPF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#define HV_HASH_NOTEIN 0x67E37CA3
#define HV_HASH_CTLIN 0x41BE0f9C
#define HV_HASH_POLYTOUCHIN 0xBC530F59
#define HV_HASH_PGMIN 0x2E1EA03D
#define HV_HASH_TOUCHIN 0x553925BD
#define HV_HASH_BENDIN 0x3083F0F7
Expand All @@ -17,6 +18,7 @@

#define HV_HASH_NOTEOUT 0xD1D4AC2
#define HV_HASH_CTLOUT 0xE5e2A040
#define HV_HASH_POLYTOUCHOUT 0xD5ACA9D1
#define HV_HASH_PGMOUT 0x8753E39E
#define HV_HASH_TOUCHOUT 0x476D4387
#define HV_HASH_BENDOUT 0xE8458013
Expand Down Expand Up @@ -270,6 +272,13 @@ void {{class_name}}::handleMidiInput(uint32_t frames, const MidiEvent* midiEvent
(float) channel);
break;
}
case 0xA0: { // polyphonic aftertouch
_context->sendMessageToReceiverV(HV_HASH_POLYTOUCHIN, 1000.0*midiEvents->frame/getSampleRate(), "fff",
(float) data2, // pressure
(float) data1, // note
(float) channel);
break;
}
case 0xB0: { // control change
_context->sendMessageToReceiverV(HV_HASH_CTLIN, 1000.0*midiEvents->frame/getSampleRate(), "fff",
(float) data2, // value
Expand Down Expand Up @@ -348,6 +357,20 @@ void {{class_name}}::handleMidiSend(uint32_t sendHash, const HvMessage *m)
writeMidiEvent(midiSendEvent);
break;
}
case HV_HASH_POLYTOUCHOUT:
{
uint8_t value = hv_msg_getFloat(m, 0);
uint8_t note = hv_msg_getFloat(m, 1);
uint8_t ch = hv_msg_getFloat(m, 2);

midiSendEvent.size = 3;
midiSendEvent.data[0] = 0xA0 | ch; // send Poly Aftertouch
midiSendEvent.data[1] = note;
midiSendEvent.data[2] = value;

writeMidiEvent(midiSendEvent);
break;
}
case HV_HASH_PGMOUT:
{
uint8_t pgm = hv_msg_getFloat(m, 0);
Expand Down
63 changes: 38 additions & 25 deletions hvcc/interpreters/pd2hv/libs/pd/bendin.pd
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
#N canvas 342 171 276 327 10;
#X obj 148 141 outlet;
#X obj 91 74 unpack f f;
#X text 165 74 bend channel;
#X obj 31 40 r __hv_bendin;
#X obj 31 261 outlet;
#X obj 124 167 loadbang;
#X obj 124 213 == 0;
#X obj 31 173 route \$1;
#X obj 124 191 i \$1;
#X msg 31 147 \$2 \$1;
#X obj 91 235 spigot;
#X msg 91 208 \$1;
#X obj 148 108 + 1;
#X connect 1 1 12 0;
#X connect 3 0 1 0;
#X connect 3 0 9 0;
#X connect 5 0 8 0;
#N canvas 114 229 459 438 10;
#X obj 209 337 outlet;
#X obj 152 76 unpack f f;
#X obj 152 47 r __hv_bendin;
#X obj 50 307 outlet;
#X obj 83 104 loadbang;
#X obj 83 174 == 0;
#X obj 83 128 i \$1;
#X obj 50 266 spigot;
#X obj 209 101 + 1;
#X obj 209 236 spigot;
#X obj 215 175 ==;
#X obj 152 237 spigot;
#X obj 215 200 t f f;
#X obj 209 313 max 1;
#X text 226 78 bend value and channel/port;
#X obj 83 197 t f f;
#X obj 150 270 spigot;
#X connect 1 0 11 0;
#X connect 1 0 7 0;
#X connect 1 1 8 0;
#X connect 2 0 1 0;
#X connect 4 0 6 0;
#X connect 5 0 15 0;
#X connect 6 0 5 0;
#X connect 6 0 10 1;
#X connect 7 0 4 0;
#X connect 7 1 11 0;
#X connect 8 0 6 0;
#X connect 9 0 7 0;
#X connect 10 0 4 0;
#X connect 11 0 10 0;
#X connect 12 0 0 0;
#X connect 7 0 3 0;
#X connect 8 0 10 0;
#X connect 8 0 16 0;
#X connect 8 0 9 0;
#X connect 9 0 13 0;
#X connect 10 0 12 0;
#X connect 11 0 3 0;
#X connect 12 0 11 1;
#X connect 12 1 9 1;
#X connect 13 0 0 0;
#X connect 15 0 7 1;
#X connect 15 1 16 1;
#X connect 16 0 13 0;
Loading

0 comments on commit 0c495d7

Please sign in to comment.