Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raw grid ops #275

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/bees/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,16 @@ CSRCS += \
$(APP_DIR)/src/ops/op_hid_word.c \
$(APP_DIR)/src/ops/op_history.c \
$(APP_DIR)/src/ops/op_is.c \
$(APP_DIR)/src/ops/op_life.c \
$(APP_DIR)/src/ops/op_iter.c \
$(APP_DIR)/src/ops/op_life_classic.c \
$(APP_DIR)/src/ops/op_life_raw.c \
$(APP_DIR)/src/ops/op_list2.c \
$(APP_DIR)/src/ops/op_list8.c \
$(APP_DIR)/src/ops/op_list16.c \
$(APP_DIR)/src/ops/op_logic.c \
$(APP_DIR)/src/ops/op_mem0d.c \
$(APP_DIR)/src/ops/op_mem1d.c \
$(APP_DIR)/src/ops/op_mem2d.c \
$(APP_DIR)/src/ops/op_metro.c \
$(APP_DIR)/src/ops/op_midi_cc.c \
$(APP_DIR)/src/ops/op_midi_out_note.c \
Expand All @@ -73,6 +78,7 @@ CSRCS += \
$(APP_DIR)/src/ops/op_mod.c \
$(APP_DIR)/src/ops/op_mul.c \
$(APP_DIR)/src/ops/op_monome_arc.c \
$(APP_DIR)/src/ops/op_monome_grid_classic.c \
$(APP_DIR)/src/ops/op_monome_grid_raw.c \
$(APP_DIR)/src/ops/op_preset.c \
$(APP_DIR)/src/ops/op_random.c \
Expand Down
52 changes: 44 additions & 8 deletions apps/bees/src/op.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,21 @@ const op_id_t userOpTypes[NUM_USER_OP_TYPES] = {
eOpDivr,
eOpFade,
eOpGate,
eOpMonomeGridRaw, // "grid"
eOpMonomeGridClassic, // "grid"
eOpMonomeGridRaw, // "gridraw"
eOpHid,
eOpHistory,
eOpIs,
eOpLife,
eOpIter,
eOpLifeClassic,
eOpLifeRaw,
eOpList2,
eOpList8,
eOpList16,
eOpLogic,
eOpMem0d,
eOpMem1d,
eOpMem2d,
eOpMetro,
eOpMidiCC,
eOpMidiNote,
Expand Down Expand Up @@ -103,9 +109,9 @@ const op_desc_t op_registry[numOpClasses] = {
.deinit = NULL
}, {
.name = "GRID",
.size = sizeof(op_mgrid_raw_t),
.init = &op_mgrid_raw_init,
.deinit = &op_mgrid_raw_deinit
.size = sizeof(op_mgrid_classic_t),
.init = &op_mgrid_classic_init,
.deinit = &op_mgrid_classic_deinit
}, {
.name = "MIDINOTE",
.size = sizeof(op_midi_note_t),
Expand Down Expand Up @@ -198,9 +204,9 @@ const op_desc_t op_registry[numOpClasses] = {
.deinit = NULL
}, {
.name = "LIFE",
.size = sizeof(op_life_t),
.init = &op_life_init,
.deinit = &op_life_deinit
.size = sizeof(op_life_classic_t),
.init = &op_life_classic_init,
.deinit = &op_life_classic_deinit
}, {
.name = "HISTORY",
.size = sizeof(op_history_t),
Expand Down Expand Up @@ -331,6 +337,36 @@ const op_desc_t op_registry[numOpClasses] = {
.size = sizeof(op_param_t),
.init = &op_param_init,
.deinit = NULL
}, {
.name = "MEM0D",
.size = sizeof(op_mem0d_t),
.init = &op_mem0d_init,
.deinit = NULL
}, {
.name = "MEM1D",
.size = sizeof(op_mem1d_t),
.init = &op_mem1d_init,
.deinit = NULL
}, {
.name = "MEM2D",
.size = sizeof(op_mem2d_t),
.init = &op_mem2d_init,
.deinit = NULL
}, {
.name = "ITER",
.size = sizeof(op_iter_t),
.init = &op_iter_init,
.deinit = NULL
}, {
.name = "GRIDRAW",
.size = sizeof(op_mgrid_raw_t),
.init = &op_mgrid_raw_init,
.deinit = &op_mgrid_raw_deinit
}, {
.name = "LIFERAW",
.size = sizeof(op_life_raw_t),
.init = &op_life_raw_init,
.deinit = NULL
}
};

Expand Down
12 changes: 9 additions & 3 deletions apps/bees/src/op.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define OP_OUTS_MAX 32

// const array of user-creatable operator types
#define NUM_USER_OP_TYPES 47
#define NUM_USER_OP_TYPES 53

EXTERN_C_BEGIN

Expand All @@ -48,7 +48,7 @@ typedef enum {
eOpAdd,
eOpMul,
eOpGate,
eOpMonomeGridRaw,
eOpMonomeGridClassic,
eOpMidiNote,
eOpAdc,
eOpMetro,
Expand All @@ -67,7 +67,7 @@ typedef enum {
eOpIs,
eOpLogic,
eOpList2,
eOpLife,
eOpLifeClassic,
eOpHistory,
eOpBignum,
eOpScreen,
Expand All @@ -94,6 +94,12 @@ typedef enum {
eOpBars8,
eOpMidiOutCC,
eOpParam,
eOpMem0d,
eOpMem1d,
eOpMem2d,
eOpIter,
eOpMonomeGridRaw,
eOpLifeRaw,
// eOpMidiBend,
// eOpMidiTouch,
numOpClasses // dummy/count
Expand Down
10 changes: 8 additions & 2 deletions apps/bees/src/op_derived.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,27 @@
#include "ops/op_hid_word.h"
#include "ops/op_history.h"
#include "ops/op_is.h"
#include "ops/op_life.h"
#include "ops/op_iter.h"
#include "ops/op_life_classic.h"
#include "ops/op_life_raw.h"
#include "ops/op_list2.h"
#include "ops/op_list8.h"
#include "ops/op_list16.h"
#include "ops/op_logic.h"
#include "ops/op_mem0d.h"
#include "ops/op_mem1d.h"
#include "ops/op_mem2d.h"
#include "ops/op_metro.h"
#include "ops/op_midi_cc.h"
#include "ops/op_midi_note.h"
#include "ops/op_midi_out_cc.h"
#include "ops/op_midi_out_note.h"
#include "ops/op_mod.h"
#include "ops/op_monome_arc.h"
#include "ops/op_monome_grid_classic.h"
#include "ops/op_monome_grid_raw.h"
#include "ops/op_mul.h"
#include "ops/op_param.h"
#include "ops/op_preset.h"
#include "ops/op_serial.h"
#include "ops/op_shl.h"
Expand All @@ -62,7 +69,6 @@
#include "ops/op_timer.h"
#include "ops/op_tog.h"
#include "ops/op_ww.h"
#include "ops/op_param.h"

// let's keep this list alphabetical so we can easily see whether something is included.

Expand Down
96 changes: 96 additions & 0 deletions apps/bees/src/ops/op_iter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "net_protected.h"
#include "op_iter.h"

//-------------------------------------------------
//---- static func declare
static void op_iter_in_times(op_iter_t* iter, const io_t v);
static void op_iter_in_val(op_iter_t* iter, const io_t v);
static void op_iter_in_stop(op_iter_t* iter, const io_t v);

// pickle / unpickle
static u8* op_iter_pickle(op_iter_t* op, u8* dst);
static const u8* op_iter_unpickle(op_iter_t* op, const u8* src);

//-------------------------------------------------
//---- static vars
static const char* op_iter_instring = "TIMES\0 VAL\0 STOP\0 ";
static const char* op_iter_outstring = "IDX\0 VAL\0 DONE\0 ";
static const char* op_iter_opstring = "ITER";

static op_in_fn op_iter_in_fn[3] = {
(op_in_fn)&op_iter_in_times,
(op_in_fn)&op_iter_in_val,
(op_in_fn)&op_iter_in_stop
};

//-------------------------------------------------
//---- external func define
void op_iter_init(void* mem) {
op_iter_t* iter = (op_iter_t*)mem;
iter->super.numInputs = 3;
iter->super.numOutputs = 3;
iter->outs[0] = -1;
iter->outs[1] = -1;
iter->outs[2] = -1;

iter->super.in_fn = op_iter_in_fn;
iter->super.in_val = iter->in_val;
iter->super.pickle = (op_pickle_fn) (&op_iter_pickle);
iter->super.unpickle = (op_unpickle_fn) (&op_iter_unpickle);

iter->super.out = iter->outs;
iter->super.opString = op_iter_opstring;
iter->super.inString = op_iter_instring;
iter->super.outString = op_iter_outstring;
iter->super.type = eOpIter;

iter->in_val[0] = &(iter->times);
iter->in_val[1] = &(iter->val);
iter->in_val[2] = &(iter->stop);

iter->times = 0;
iter->val = 0;
iter->stop = 0;

}

//-------------------------------------------------
//---- static func define

static void op_iter_in_times(op_iter_t* iter, const io_t v) {
if (v >= 0 && v <= 16)
iter->times = v;
}

static void op_iter_in_val(op_iter_t* iter, const io_t v) {
u8 i = 0;
iter->val = v;
iter->stop = 0;
for (i=0; i < iter->times; i++) {
if ( iter->stop == 1)
return;
net_activate(iter->outs[0], i, iter);
net_activate(iter->outs[1], iter->val, iter);
}
net_activate(iter->outs[2], 1, iter);
}

static void op_iter_in_stop(op_iter_t* iter, const io_t v) {
iter->stop = 1;
}


// pickle / unpickle
u8* op_iter_pickle(op_iter_t* op, u8* dst) {
dst = pickle_io(op->times, dst);
dst = pickle_io(op->val, dst);
dst = pickle_io(op->stop, dst);
return dst;
}

const u8* op_iter_unpickle(op_iter_t* op, const u8* src) {
src = unpickle_io(src, &(op->times));
src = unpickle_io(src, &(op->val));
src = unpickle_io(src, &(op->stop));
return src;
}
19 changes: 19 additions & 0 deletions apps/bees/src/ops/op_iter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _op_iter_H_
#define _op_iter_H_

#include "types.h"
#include "op.h"
#include "op_math.h"

//--- op_iter_t : iterition
typedef struct op_iter_struct {
op_t super;
volatile io_t times;
volatile io_t val;
volatile io_t stop;
volatile io_t * in_val[3]; // a, b, btrig
op_out_t outs[3];
} op_iter_t;
void op_iter_init(void* mem);

#endif // header guard
Loading