added a number input and a loadbang for setting the dsp on 1, compiled the patch

This commit is contained in:
2025-12-02 18:40:32 +01:00
parent e2d27cdcff
commit 9751f1efac
5 changed files with 164 additions and 4 deletions

View File

@ -1,5 +1,10 @@
#N canvas 827 239 734 565 12;
#X obj 226 158 osc~ 440;
#X obj 226 223 dac~;
#X obj 392 165 loadbang;
#X msg 392 189 \; pd dsp 1;
#X floatatom 226 121 5 0 0 0 - - - 0;
#X connect 0 0 1 0;
#X connect 0 0 1 1;
#X connect 2 0 3 0;
#X connect 4 0 0 0;

View File

@ -83,8 +83,11 @@ extern "C" {
Heavy_temp_a2960967::Heavy_temp_a2960967(double sampleRate, int poolKb, int inQueueKb, int outQueueKb)
: HeavyContext(sampleRate, poolKb, inQueueKb, outQueueKb) {
numBytes += sPhasor_k_init(&sPhasor_dLinxAVa, 440.0f, sampleRate);
numBytes += sPhasor_k_init(&sPhasor_t0xipsEt, 440.0f, sampleRate);
numBytes += cVar_init_f(&cVar_AeJUniP3, 0.0f);
// schedule a message to trigger all loadbangs via the __hv_init receiver
scheduleMessageForReceiver(0xCE5CC65B, msg_initWithBang(HV_MESSAGE_ON_STACK(1), 0));
}
Heavy_temp_a2960967::~Heavy_temp_a2960967() {
@ -97,6 +100,10 @@ HvTable *Heavy_temp_a2960967::getTableForHash(hv_uint32_t tableHash) {
void Heavy_temp_a2960967::scheduleMessageForReceiver(hv_uint32_t receiverHash, HvMessage *m) {
switch (receiverHash) {
case 0xCE5CC65B: { // __hv_init
mq_addMessageByTimestamp(&mq, m, 0, &cReceive_wS26lFsz_sendMessage);
break;
}
default: return;
}
}
@ -125,6 +132,23 @@ int Heavy_temp_a2960967::getParameterInfo(int index, HvParameterInfo *info) {
*/
void Heavy_temp_a2960967::cVar_AeJUniP3_sendMessage(HeavyContextInterface *_c, int letIn, const HvMessage *m) {
sPhasor_k_onMessage(_c, &Context(_c)->sPhasor_t0xipsEt, 0, m);
}
void Heavy_temp_a2960967::cMsg_YmvBriBK_sendMessage(HeavyContextInterface *_c, int letIn, const HvMessage *const n) {
HvMessage *m = nullptr;
m = HV_MESSAGE_ON_STACK(3);
msg_init(m, 3, msg_getTimestamp(n));
msg_setSymbol(m, 0, "pd");
msg_setSymbol(m, 1, "dsp");
msg_setFloat(m, 2, 1.0f);
}
void Heavy_temp_a2960967::cReceive_wS26lFsz_sendMessage(HeavyContextInterface *_c, int letIn, const HvMessage *m) {
cMsg_YmvBriBK_sendMessage(_c, 0, m);
}
@ -171,7 +195,7 @@ int Heavy_temp_a2960967::process(float **inputBuffers, float **outputBuffers, in
__hv_zero_f(VOf(O1));
// process all signal functions
__hv_phasor_k_f(&sPhasor_dLinxAVa, VOf(Bf0));
__hv_phasor_k_f(&sPhasor_t0xipsEt, VOf(Bf0));
__hv_var_k_f(VOf(Bf1), 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f);
__hv_sub_f(VIf(Bf0), VIf(Bf1), VOf(Bf1));
__hv_abs_f(VIf(Bf1), VOf(Bf1));
@ -186,8 +210,8 @@ int Heavy_temp_a2960967::process(float **inputBuffers, float **outputBuffers, in
__hv_var_k_f(VOf(Bf4), -0.166666666666667f, -0.166666666666667f, -0.166666666666667f, -0.166666666666667f, -0.166666666666667f, -0.166666666666667f, -0.166666666666667f, -0.166666666666667f);
__hv_fma_f(VIf(Bf2), VIf(Bf4), VIf(Bf1), VOf(Bf1));
__hv_fma_f(VIf(Bf0), VIf(Bf3), VIf(Bf1), VOf(Bf1));
__hv_add_f(VIf(Bf1), VIf(O0), VOf(O0));
__hv_add_f(VIf(Bf1), VIf(O1), VOf(O1));
__hv_add_f(VIf(Bf1), VIf(O0), VOf(O0));
// save output vars to output buffer
__hv_store_f(outputBuffers[0]+n, VIf(O0));

View File

@ -37,6 +37,7 @@
#include "HeavyContext.hpp"
#include "HvSignalPhasor.h"
#include "HvSignalVar.h"
#include "HvControlVar.h"
#include "HvMath.h"
class Heavy_temp_a2960967 : public HeavyContext {
@ -60,9 +61,13 @@ class Heavy_temp_a2960967 : public HeavyContext {
void scheduleMessageForReceiver(hv_uint32_t receiverHash, HvMessage *m) override;
// static sendMessage functions
static void cVar_AeJUniP3_sendMessage(HeavyContextInterface *, int, const HvMessage *);
static void cMsg_YmvBriBK_sendMessage(HeavyContextInterface *, int, const HvMessage *);
static void cReceive_wS26lFsz_sendMessage(HeavyContextInterface *, int, const HvMessage *);
// objects
SignalPhasor sPhasor_dLinxAVa;
SignalPhasor sPhasor_t0xipsEt;
ControlVar cVar_AeJUniP3;
};
#endif // _HEAVY_CONTEXT_TEMP_A2960967_HPP_

View File

@ -0,0 +1,83 @@
/**
* Copyright (c) 2014-2018 Enzien Audio Ltd.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "HvControlVar.h"
hv_size_t cVar_init_f(ControlVar *o, float k) {
o->e.type = HV_MSG_FLOAT;
o->e.data.f = k;
return 0;
}
hv_size_t cVar_init_s(ControlVar *o, const char *s) {
o->e.type = HV_MSG_HASH;
o->e.data.h = hv_string_to_hash(s);
return 0;
}
void cVar_free(ControlVar *o) {
// nothing to do
}
void cVar_onMessage(HeavyContextInterface *_c, ControlVar *o, int letIn, const HvMessage *m,
void (*sendMessage)(HeavyContextInterface *, int, const HvMessage *)) {
switch (letIn) {
case 0: {
switch (msg_getType(m,0)) {
case HV_MSG_BANG: {
HvMessage *n = HV_MESSAGE_ON_STACK(1);
if (o->e.type == HV_MSG_FLOAT) msg_initWithFloat(n, msg_getTimestamp(m), o->e.data.f);
else if (o->e.type == HV_MSG_HASH) msg_initWithHash(n, msg_getTimestamp(m), o->e.data.h);
else return;
sendMessage(_c, 0, n);
break;
}
case HV_MSG_FLOAT: {
o->e.type = HV_MSG_FLOAT;
o->e.data.f = msg_getFloat(m,0);
sendMessage(_c, 0, m);
break;
}
case HV_MSG_SYMBOL:
case HV_MSG_HASH: {
o->e.type = HV_MSG_HASH;
o->e.data.h = msg_getHash(m,0);
sendMessage(_c, 0, m);
break;
}
default: return;
}
break;
}
case 1: {
switch (msg_getType(m,0)) {
case HV_MSG_FLOAT: {
o->e.type = HV_MSG_FLOAT;
o->e.data.f = msg_getFloat(m,0);
break;
}
case HV_MSG_SYMBOL:
case HV_MSG_HASH: {
o->e.type = HV_MSG_HASH;
o->e.data.h = msg_getHash(m,0);
break;
}
default: break;
}
}
default: return;
}
}

View File

@ -0,0 +1,43 @@
/**
* Copyright (c) 2014-2018 Enzien Audio Ltd.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _HEAVY_CONTROL_VAR_H_
#define _HEAVY_CONTROL_VAR_H_
#include "HvHeavyInternal.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ControlVar {
Element e; // type is only ever HV_MSG_FLOAT or HV_MSG_HASH
} ControlVar;
hv_size_t cVar_init_f(ControlVar *o, float k);
hv_size_t cVar_init_s(ControlVar *o, const char *s);
void cVar_free(ControlVar *o);
void cVar_onMessage(HeavyContextInterface *_c, ControlVar *o, int letIn, const HvMessage *m,
void (*sendMessage)(HeavyContextInterface *, int, const HvMessage *));
#ifdef __cplusplus
} // extern "C"
#endif
#endif // _HEAVY_CONTROL_VAR_H_