Skip to content

Commit

Permalink
first commit of nts1mkii port
Browse files Browse the repository at this point in the history
  • Loading branch information
boochow committed Mar 30, 2024
1 parent 8bf2c30 commit 7f2e6f7
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 31 deletions.
81 changes: 63 additions & 18 deletions changevol.cc
Expand Up @@ -5,28 +5,50 @@
*
*/

#include "usermodfx.h"
#include "unit_modfx.h"

#define k_user_modfx_param_time 0
#define k_user_modfx_param_depth 1

static unit_runtime_desc_t s_runtime_desc;
static int32_t s_params[10];
static float s_depth;
static uint8_t s_time;

void MODFX_INIT(uint32_t platform, uint32_t api)
{
__unit_callback int8_t unit_init(const unit_runtime_desc_t * desc) {
if (!desc)
return k_unit_err_undef;

// Note: make sure the unit is being loaded to the correct platform/module target
if (desc->target != unit_header.target)
return k_unit_err_target;

// Note: check API compatibility with the one this unit was built against
if (!UNIT_API_IS_COMPAT(desc->api))
return k_unit_err_api_version;

// Check compatibility of samplerate with unit, for NTS-1 MKII should be 48000
if (desc->samplerate != 48000)
return k_unit_err_samplerate;

// Check compatibility of frame geometry
if (desc->input_channels != 2 || desc->output_channels != 2) // should be stereo input/output
return k_unit_err_geometry;

// Cache the runtime descriptor for later use
s_runtime_desc = *desc;

s_depth = 1.0f;
s_time = 0.5f;

return k_unit_err_none;
}

void MODFX_PROCESS(const float *main_xn, float *main_yn,
const float *sub_xn, float *sub_yn,
uint32_t frames)
{
const float * mx = main_xn;
float * __restrict my = main_yn;
__unit_callback void unit_render(const float * in, float * out, uint32_t frames) {
const float * mx = in;
float * __restrict my = out;
const float * my_e = my + 2 * frames;

const float *sx = sub_xn;
float * __restrict sy = sub_yn;

float on_off;
if (s_time < 32) {
on_off = 0;
Expand All @@ -41,16 +63,13 @@ void MODFX_PROCESS(const float *main_xn, float *main_yn,
for (; my != my_e; ) {
*(my++) = *(mx++) * s_depth * on_off;
*(my++) = *(mx++) * s_depth * on_off;
*(sy++) = *(sx++) * s_depth * on_off;
*(sy++) = *(sx++) * s_depth * on_off;
}
}


void MODFX_PARAM(uint8_t index, int32_t value)
{
const float valf = q31_to_f32(value);
switch (index) {
__unit_callback void unit_set_param_value(uint8_t id, int32_t value) {
const float valf = param_10bit_to_f32(value);
switch (id) {
case k_user_modfx_param_time:
s_time = clip01f(valf * 0.999) * 128;
break;
Expand All @@ -60,5 +79,31 @@ void MODFX_PARAM(uint8_t index, int32_t value)
default:
break;
}
s_params[id] = value;
}

__unit_callback void unit_teardown() {
}

__unit_callback void unit_reset() {
}

__unit_callback void unit_resume() {
}

__unit_callback void unit_suspend() {
}

__unit_callback int32_t unit_get_param_value(uint8_t id) {
return s_params[id];
}

__unit_callback const char * unit_get_param_str_value(uint8_t id, int32_t value) {
return nullptr;
}

__unit_callback void unit_set_tempo(uint32_t tempo) {
}

__unit_callback void unit_tempo_4ppqn_tick(uint32_t counter) {
}
4 changes: 2 additions & 2 deletions config.mk
Expand Up @@ -2,7 +2,7 @@
# Configuration for Makefile
#

PROJECT := dummy_modfx
PROJECT := mastervol2
PROJECT_TYPE := modfx

##############################################################################
Expand All @@ -13,7 +13,7 @@ PROJECT_TYPE := modfx
UCSRC = header.c

# C++ sources
UCXXSRC = unit.cc
UCXXSRC = changevol.cc

# List ASM source files here
UASMSRC =
Expand Down
22 changes: 11 additions & 11 deletions header.c
Expand Up @@ -43,14 +43,14 @@
// ---- Unit header definition --------------------------------------------------------------------

const __unit_header unit_header_t unit_header = {
.header_size = sizeof(unit_header_t), // Size of this header. Leave as is.
.target = UNIT_TARGET_PLATFORM | k_unit_module_modfx, // Target platform and module pair for this unit
.api = UNIT_API_VERSION, // API version for which unit was built. See runtime.h
.dev_id = 0x0, // Developer ID. See https://github.com/korginc/logue-sdk/blob/master/developer_ids.md
.unit_id = 0x0U, // ID for this unit. Scoped within the context of a given dev_id.
.version = 0x00010000U, // This unit's version: major.minor.patch (major<<16 minor<<8 patch).
.name = "dummy", // Name for this unit, will be displayed on device
.num_params = 3, // Number of valid parameter descriptors. (max. 10)
.header_size = sizeof(unit_header_t),
.target = UNIT_TARGET_PLATFORM | k_unit_module_modfx,
.api = UNIT_API_VERSION,
.dev_id = 0x42636877U, // "Bchw"
.unit_id = 0x04030000, // Product number(03),Unit type(03=ModFX),reserved
.version = 0x00010000U,
.name = "MasterV2",
.num_params = 2,

.params = {
// Format: min, max, center, default, type, frac. bits, frac. mode, <reserved>, name
Expand All @@ -59,13 +59,13 @@ const __unit_header unit_header_t unit_header = {

// Fixed/direct UI parameters
// A knob
{0, 1023, 0, 256, k_unit_param_type_none, 1, 0, 0, {"TIME"}},
{0, 1023, 0, 256, k_unit_param_type_none, 1, 0, 0, {"MODE"}},

// B knob
{0, 1023, 0, 256, k_unit_param_type_none, 1, 0, 0, {"DPTH"}},
{0, 1023, 0, 256, k_unit_param_type_none, 1, 0, 0, {"VOL"}},

// 8 Edit menu parameters
{0, 3, 0, 1, k_unit_param_type_strings, 0, 0, 0, {"PARAM3"}}, // Example of a strings type parameter
{0, 0, 0, 0, k_unit_param_type_none, 0, 0, 0, {""}},
{0, 0, 0, 0, k_unit_param_type_none, 0, 0, 0, {""}},
{0, 0, 0, 0, k_unit_param_type_none, 0, 0, 0, {""}},
{0, 0, 0, 0, k_unit_param_type_none, 0, 0, 0, {""}},
Expand Down

0 comments on commit 7f2e6f7

Please sign in to comment.