10. Seq16 Scheme Functions
10.1. Seq16 Scheme Loader
The top-level scheme loader is called s9_load_seq16
.
<<seq16_function_declarations>>=
void s9_load_seq16(void);
<<seq16_functions>>=
<<seq16_scheme_functions>>
static S9_PRIM seq16_primitives[] = {
<<seq16_scheme_entries>>
{NULL}
};
void s9_load_seq16(void)
{
monolith_scheme_add_primitives("monolith",
seq16_primitives);
}
10.2. Create Seq16 Page
A new seq16 page is created with monolith:seq16-new
.
<<seq16_scheme_entries>>=
{
"monolith:seq16-new",
pp_seq16_new, 1, 1,
{S9_T_STRING, S9_T_ANY, S9_T_ANY}
},
<<seq16_scheme_functions>>=
static s9_cell pp_seq16_new(s9_cell x)
{
const char *str;
monolith_d *m;
monolith_dict *dict;
monolith_page *pg;
int rc;
m = monolith_data_get();
dict = monolith_dict_get(m);
str = monolith_scheme_string(s9_car(x));
rc = monolith_dict_newpage(dict, &pg, str, strlen(str));
if (!rc) {
return monolith_scheme_error(
"Could not create seq16 page (maybe it already exists?)",
s9_car(x));
}
page_seq16(pg);
return S9_UNSPECIFIC;
}
10.3. Reset
Will wait until the next trigger for the reset
<<seq16_scheme_entries>>=
{
"monolith:seq16-reset",
pp_seq16_reset, 1, 1,
{S9_T_STRING, S9_T_ANY, S9_T_ANY}
},
<<seq16_scheme_functions>>=
static s9_cell pp_seq16_reset(s9_cell x)
{
const char *str;
monolith_d *m;
monolith_dict *dict;
monolith_page *pg;
page_seq16_d *seq;
int rc;
m = monolith_data_get();
dict = monolith_dict_get(m);
str = monolith_scheme_string(s9_car(x));
rc = monolith_dict_lookup(dict, &pg, str, strlen(str));
if (!rc) {
return monolith_scheme_error(
"Could not find seq16 page",
s9_car(x));
}
seq = monolith_page_data_get(pg);
seq->reset = 1;
return S9_UNSPECIFIC;
}
10.4. Set Value
Sets sequence to be a particular value. Should be in range 0-8.
<<seq16_scheme_entries>>=
{
"monolith:seq16-valset",
pp_seq16_valset, 3, 3,
{S9_T_STRING, S9_T_INTEGER, S9_T_ANY}
},
<<seq16_scheme_functions>>=
static s9_cell pp_seq16_valset(s9_cell x)
{
const char *str;
monolith_d *m;
monolith_dict *dict;
monolith_page *pg;
page_seq16_d *seq;
int rc;
int pos, val;
m = monolith_data_get();
dict = monolith_dict_get(m);
str = monolith_scheme_string(s9_car(x));
rc = monolith_dict_lookup(dict, &pg, str, strlen(str));
if (!rc) {
return monolith_scheme_error(
"Could not find seq16 page",
s9_car(x));
}
x = s9_cdr(x);
pos = monolith_scheme_integer(NULL, s9_car(x));
if (pos < 0 || pos >= 16) {
return monolith_scheme_error(
"position out of range:",
s9_car(x));
}
x = s9_cdr(x);
val = monolith_scheme_integer(NULL, s9_car(x));
if (val < 0 || val >= 8) {
return monolith_scheme_error(
"value out of range:",
s9_car(x));
}
seq = monolith_page_data_get(pg);
seq16_valset(seq, pos, val);
return S9_UNSPECIFIC;
}
10.5. Set playhead state
<<seq16_scheme_entries>>=
{
"monolith:seq16-playhead",
pp_seq16_playhead, 2, 2,
{S9_T_STRING, S9_T_INTEGER, S9_T_ANY}
},
<<seq16_scheme_functions>>=
static s9_cell pp_seq16_playhead(s9_cell x)
{
const char *str;
monolith_d *m;
monolith_dict *dict;
monolith_page *pg;
page_seq16_d *seq;
int rc;
int state;
m = monolith_data_get();
dict = monolith_dict_get(m);
str = monolith_scheme_string(s9_car(x));
rc = monolith_dict_lookup(dict, &pg, str, strlen(str));
if (!rc) {
return monolith_scheme_error(
"Could not find seq16 page",
s9_car(x));
}
x = s9_cdr(x);
state = monolith_scheme_integer(NULL, s9_car(x));
seq = monolith_page_data_get(pg);
seq->playhead = state;
return S9_UNSPECIFIC;
}
10.6. Set Size
<<seq16_scheme_entries>>=
{
"monolith:seq16-patsize",
pp_seq16_patsize, 2, 2,
{S9_T_STRING, S9_T_INTEGER, S9_T_ANY}
},
<<seq16_scheme_functions>>=
static s9_cell pp_seq16_patsize(s9_cell x)
{
const char *str;
monolith_d *m;
monolith_dict *dict;
monolith_page *pg;
page_seq16_d *seq;
int rc;
int patsize;
m = monolith_data_get();
dict = monolith_dict_get(m);
str = monolith_scheme_string(s9_car(x));
rc = monolith_dict_lookup(dict, &pg, str, strlen(str));
if (!rc) {
return monolith_scheme_error(
"Could not find seq16 page",
s9_car(x));
}
x = s9_cdr(x);
patsize = monolith_scheme_integer(NULL, s9_car(x));
if (patsize <= 0 || patsize >= 16) {
return monolith_scheme_error(
"Pattern size out of range:",
s9_car(x));
}
seq = monolith_page_data_get(pg);
seq->size = patsize;
return S9_UNSPECIFIC;
}
prev | home | next