Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6678db4565 | |||
| c646128e10 | |||
| 282462757f | |||
| 9751f1efac |
@ -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 - osc_freq_input - 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;
|
||||
|
||||
@ -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_cYzbYXma, 440.0f, sampleRate);
|
||||
numBytes += cVar_init_f(&cVar_suKVph5y, 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,14 @@ 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_lcgmg3zT_sendMessage);
|
||||
break;
|
||||
}
|
||||
case 0xBDE02A5C: { // osc_freq_input
|
||||
mq_addMessageByTimestamp(&mq, m, 0, &cReceive_VnPTYsLb_sendMessage);
|
||||
break;
|
||||
}
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
@ -125,6 +136,27 @@ int Heavy_temp_a2960967::getParameterInfo(int index, HvParameterInfo *info) {
|
||||
*/
|
||||
|
||||
|
||||
void Heavy_temp_a2960967::cVar_suKVph5y_sendMessage(HeavyContextInterface *_c, int letIn, const HvMessage *m) {
|
||||
sPhasor_k_onMessage(_c, &Context(_c)->sPhasor_cYzbYXma, 0, m);
|
||||
}
|
||||
|
||||
void Heavy_temp_a2960967::cMsg_yxSgDNKY_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_lcgmg3zT_sendMessage(HeavyContextInterface *_c, int letIn, const HvMessage *m) {
|
||||
cMsg_yxSgDNKY_sendMessage(_c, 0, m);
|
||||
}
|
||||
|
||||
void Heavy_temp_a2960967::cReceive_VnPTYsLb_sendMessage(HeavyContextInterface *_c, int letIn, const HvMessage *m) {
|
||||
cVar_onMessage(_c, &Context(_c)->cVar_suKVph5y, 0, m, &cVar_suKVph5y_sendMessage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -171,7 +203,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_cYzbYXma, 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));
|
||||
|
||||
@ -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,14 @@ class Heavy_temp_a2960967 : public HeavyContext {
|
||||
void scheduleMessageForReceiver(hv_uint32_t receiverHash, HvMessage *m) override;
|
||||
|
||||
// static sendMessage functions
|
||||
static void cVar_suKVph5y_sendMessage(HeavyContextInterface *, int, const HvMessage *);
|
||||
static void cMsg_yxSgDNKY_sendMessage(HeavyContextInterface *, int, const HvMessage *);
|
||||
static void cReceive_lcgmg3zT_sendMessage(HeavyContextInterface *, int, const HvMessage *);
|
||||
static void cReceive_VnPTYsLb_sendMessage(HeavyContextInterface *, int, const HvMessage *);
|
||||
|
||||
// objects
|
||||
SignalPhasor sPhasor_dLinxAVa;
|
||||
SignalPhasor sPhasor_cYzbYXma;
|
||||
ControlVar cVar_suKVph5y;
|
||||
};
|
||||
|
||||
#endif // _HEAVY_CONTEXT_TEMP_A2960967_HPP_
|
||||
|
||||
83
test-pico-io/lib/Heavy/HvControlVar.c
Normal file
83
test-pico-io/lib/Heavy/HvControlVar.c
Normal 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;
|
||||
}
|
||||
}
|
||||
43
test-pico-io/lib/Heavy/HvControlVar.h
Normal file
43
test-pico-io/lib/Heavy/HvControlVar.h
Normal 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_
|
||||
@ -10,6 +10,9 @@ I2S i2s(OUTPUT);
|
||||
#define BLOCKSIZE 64 // Heavy block size
|
||||
#define BUFFERSIZE (2 * BLOCKSIZE) // Stereo interleaved
|
||||
|
||||
bool state;
|
||||
int delta;
|
||||
|
||||
int16_t buffer[BUFFERSIZE];
|
||||
|
||||
inline int16_t float_to_i16(float x) {
|
||||
@ -70,9 +73,17 @@ void setup() {
|
||||
while (100);
|
||||
}
|
||||
|
||||
delay(100);
|
||||
delay(2000);
|
||||
hv->sendFloatToReceiver(hv_string_to_hash("osc_freq_input"), 880);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (millis() - delta > 1000) {
|
||||
int freq;
|
||||
if (state) freq = 440;
|
||||
else freq = 880;
|
||||
hv->sendFloatToReceiver(hv_string_to_hash("osc_freq_input"), freq);
|
||||
state = !state;
|
||||
delta = millis();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user