Skip to content

Commit

Permalink
daisy midiin; dpf fix midiout
Browse files Browse the repository at this point in the history
  • Loading branch information
dromer committed Nov 21, 2023
1 parent 2d13883 commit ac6ada1
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 43 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Next Release
* Objects: `[bang~]`
* Documentation fixes/additions
* Daisy: ability to set samplerate and blocksize
* Daisy: adding midirealtimein, polytouchin/out
* Daisy: adding midirealtimein, polytouchin/out, midiin (midiout WIP)
* DPF: enum for UI parameter IDs
* DPF bugfixes: correct input PortGroup names; correct UI slider updates
* DPF bugfixes: correct input PortGroup names; correct UI slider updates; midiout reimplementation
* Cleanup: remove deprecated build.json

0.9.0
Expand Down
3 changes: 2 additions & 1 deletion hvcc/generators/c2daisy/c2daisy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"__hv_pgmout",
"__hv_touchout",
"__hv_bendout",
"__hv_midiout"
"__hv_midiout",
"__hv_midioutport"
}


Expand Down
46 changes: 26 additions & 20 deletions hvcc/generators/c2daisy/templates/HeavyDaisy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ FIFO<FixedCapStr<64>, 64> event_log;
{% elif usb_midi %}
daisy::MidiUsbHandler midiusb;
{% endif %}
// int midiOutCount;
// uint8_t* midiOutData;
void CallbackWriteIn(Heavy_{{patch_name}}& hv);
void LoopWriteIn(Heavy_{{patch_name}}& hv);
void CallbackWriteOut();
Expand Down Expand Up @@ -97,6 +99,12 @@ DaisyHvParamOut DaisyOutputParameters[DaisyNumOutputParameters] = {
// Typical Switch case for Message Type.
void HandleMidiMessage(MidiEvent m)
{
for (int i = 0; i <= 2; ++i) {
hv.sendMessageToReceiverV(HV_HASH_MIDIIN, 0, "ff",
(float) m.data[i],
(float) m.channel);
}

switch(m.type)
{
case SystemRealTime: {
Expand Down Expand Up @@ -399,26 +407,24 @@ void HandleMidiSend(uint32_t sendHash, const HvMessage *m)
HandleMidiOut(midiData, numElements);
break;
}
case HV_HASH_MIDIOUT: // __hv_midiout
{
const uint8_t numElements = m->numElements;
uint8_t midiData[numElements];
if (numElements <=4 )
{
for (int i = 0; i < numElements; ++i)
{
midiData[i] = hv_msg_getFloat(m, i);
}
}
else
{
// we do not support sysex yet
break;
}

HandleMidiOut(midiData, numElements);
break;
}
// not functional yet
// case HV_HASH_MIDIOUT: // __hv_midiout
// {
// if (midiOutCount == 0 ) {
// uint8_t midiOutData[3];
// }

// midiOutData[midiOutCount] = hv_msg_getFloat(m, 0);

// if (midiOutCount < 2) {
// midiOutCount++;
// break;
// }

// HandleMidiOut(midiOutData, 3);
// midiOutCount = 0;
// break;
// }
default:
break;
}
Expand Down
4 changes: 4 additions & 0 deletions hvcc/generators/c2dpf/templates/HeavyDPF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ class {{class_name}} : public Plugin
double nextClockTick;
double sampleAtCycleStart;

// midi out buffer
int midiOutCount;
MidiEvent midiOutEvent;

// heavy context
HeavyContextInterface *_context;

Expand Down
32 changes: 12 additions & 20 deletions hvcc/generators/c2dpf/templates/HeavyDPF_MIDI_Output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,30 +100,22 @@ void {{class_name}}::handleMidiSend(uint32_t sendHash, const HvMessage *m)
}
case HV_HASH_MIDIOUT: // __hv_midiout
{
const uint8_t numElements = m->numElements;
if (numElements <=4 )
{
for (int i = 0; i < numElements; ++i)
{
midiSendEvent.data[i] = hv_msg_getFloat(m, i);
}
}
else
{
printf("> we do not support sysex yet \n");
break;
if (midiOutCount == 0) {
midiOutEvent.frame = 0;
midiOutEvent.dataExt = nullptr;
// we don't support sysex
midiOutEvent.size = 4;
}

// unsigned char* rawData = new unsigned char;
// for (int i = 0; i < numElements; ++i) {
// rawData[i] = (uint8_t) hv_msg_getFloat(m, i);
// printf("> data: %d \n", rawData[i]);
// }
midiOutEvent.data[midiOutCount] = hv_msg_getFloat(m, 0);

midiSendEvent.size = numElements;
// midiSendEvent.dataExt = (const uint8_t *) rawData;
if (midiOutCount < 3) {
midiOutCount++;
break;
}

writeMidiEvent(midiSendEvent);
writeMidiEvent(midiOutEvent);
midiOutCount = 0;
break;
}
default:
Expand Down

0 comments on commit ac6ada1

Please sign in to comment.