3#ifndef PRINTLINES_ALLOWED
4#define PRINTLINES_ALLOWED 0
7#define INITIAL_PROFILE_ARRAY_LENGTH 8
8#define PROFILE_ARRAY_CHUNK_SIZE 8
10static const char *FNAME =
"kest_context.c";
33 cxt->pages.backstage = NULL;
34 cxt->pages.current_page = NULL;
52 #ifdef KEST_ENABLE_REPRESENTATIONS
53 cxt->state_rep.representer = NULL;
54 cxt->state_rep.representee = cxt;
56 cxt->state_rep_lstub.data = &cxt->state_rep;
57 cxt->state_rep_lstub.next = NULL;
60 #ifdef KEST_USE_FREERTOS
61 cxt->mutex = xSemaphoreCreateMutex();
75 cxt->
main_sequence.view_page = &cxt->pages.main_sequence_view;
108 cxt->pages.backstage = NULL;
109 cxt->pages.current_page = NULL;
209 if (current->data && current->data->id == profile_id)
211 return current->data;
214 current = current->next;
235 if (current->data && current->data->id == effect_id)
237 return current->data;
240 current = current->next;
261 if (!cxt || !pp || !tp)
269 if (
id.effect_id == 0)
271 switch (
id.parameter_id)
338 if (current->data && current->data->id == effect_id)
341 current = current->next;
368 return current->data->id;
371 current = current->next;
380 if (!cxt || !profile)
387 remove(profile->
fname);
391 if (current->data == profile)
394 queue_msg_to_teensy(create_m_message(KEST_MESSAGE_DELETE_PROFILE,
"s", profile->
id));
403 prev->next = current->next;
413 current = current->next;
421 if (!cxt || !sequence)
428 remove(sequence->
fname);
432 if (current->data == sequence)
440 prev->next = current->next;
450 current = current->next;
466 queue_msg_to_teensy(create_m_message(KEST_MESSAGE_REMOVE_TRANSFORMER,
"ss", pid, tid));
481 if (profile && profile->sequence)
483 KEST_PRINTF(
"profile has a sequence. call kest_sequence_activate_at\n");
491 uint16_t
id = profile ? profile->
id : 0;
494 int ret_val = queue_msg_to_teensy(create_m_message(KEST_MESSAGE_SWITCH_PROFILE,
"s",
id));
504 KEST_PRINTF(
"set_active_profile_from_sequence, profile = %p\n", profile);
517 uint16_t
id = profile ? profile->
id : 0;
518 ret_val = queue_msg_to_teensy(create_m_message(KEST_MESSAGE_SWITCH_PROFILE,
"s",
id));
550 KEST_PRINTF(
"Profile %d, stored at %p, ", i, current->data);
555 kest_effect_pll *ct = current->data->pipeline.effects;
562 KEST_PRINTF(
"has name %s, and has %d effects%s", current->data->name ? current->data->name :
"(NULL)", j, (j > 0) ?
", which are\n" :
"\n\n");
564 ct = current->data->pipeline.effects;
572 current = current->next;
591 if (current->data && current->data->view_page)
596 current = current->next;
607 KEST_PRINTF(
"cxt_handle_hw_switch, sw = %d\n", sw);
627 KEST_PRINTF(
"Searching for profile with fname %s...\n", fname);
630 if (current->data && current->data->has_fname)
636 return current->data;
641 current = current->next;
661 current = current->next;
672 #ifdef KEST_USE_FREERTOS
686 #ifdef KEST_USE_FREERTOS
687 if (xSemaphoreTake(cxt->mutex, portMAX_DELAY) != pdTRUE)
702 #ifdef KEST_USE_FREERTOS
703 xSemaphoreGive(cxt->mutex);
723 KEST_PRINTF(
"cxt_get_profile_by_fname(cxt = %p, fname = %s)\n", cxt, fname ? fname :
"(NULL)");
728 kest_profile_pll *current = cxt->
profiles;
730 KEST_PRINTF(
"Searching the list. %s\n", !current ?
"... but it is empty!" :
"");
737 KEST_PRINTF(
"has fname \"%s\".\n", current->data->has_fname ? current->data->fname :
"(NULL)");
743 if (current->data && current->data->has_fname &&
fnames_agree(current->data->fname, fname))
746 return current->data;
749 current = current->next;
761 kest_sequence_pll *current = cxt->
sequences;
765 if (current->data && current->data->has_fname &&
fnames_agree(current->data->fname, fname))
766 return current->data;
768 current = current->next;
802 kest_effect_desc_pll *current = cxt->
effects;
806 if (current->data && current->data->cname && strcmp(current->data->cname, cname) == 0)
807 return current->data;
809 current = current->next;
void kest_free(void *ptr)
void * kest_alloc(size_t size)
int cxt_get_parameter_and_effect_by_id(kest_context *cxt, kest_parameter_id id, kest_parameter **pp, kest_effect **tp)
int kest_context_add_profile(kest_context *cxt)
int kest_cxt_set_output_gain(kest_context *cxt, float gain)
int kest_context_init_ui(kest_context *cxt)
int cxt_save_all_profiles(kest_context *cxt)
int set_working_profile(kest_profile *profile)
void context_print_profiles(kest_context *cxt)
kest_profile * cxt_find_profile(kest_context *cxt, const char *fname)
kest_setting * cxt_get_setting_by_id(kest_context *cxt, uint16_t profile_id, uint16_t effect_id, uint16_t parameter_id)
int set_active_profile(kest_profile *profile)
int cxt_remove_effect(kest_context *cxt, uint16_t pid, uint16_t tid)
int kest_cxt_release_mutex(kest_context *cxt)
kest_parameter * cxt_get_parameter_by_id(kest_context *cxt, uint16_t profile_id, uint16_t effect_id, uint16_t parameter_id)
int kest_cxt_obtain_mutex(kest_context *cxt)
kest_effect * cxt_get_effect_by_id(kest_context *cxt, uint16_t profile_id, uint16_t effect_id)
kest_sequence * cxt_get_sequence_by_fname(kest_context *cxt, const char *fname)
int set_active_profile_from_sequence(kest_profile *profile)
int cxt_effect_id_to_position(kest_context *cxt, uint16_t profile_id, uint16_t effect_id)
int kest_cxt_queue_save_state(kest_context *cxt)
kest_profile * kest_context_add_profile_rp(kest_context *cxt)
kest_effect_desc * kest_cxt_get_effect_desc_from_cname(kest_context *cxt, const char *cname)
int kest_cxt_set_input_gain(kest_context *cxt, float gain)
int cxt_effect_position_to_id(kest_context *cxt, uint16_t profile_id, uint16_t effect_pos)
int cxt_remove_sequence(kest_context *cxt, kest_sequence *sequence)
kest_profile * cxt_get_profile_by_id(kest_context *cxt, uint16_t profile_id)
int kest_init_context(kest_context *cxt)
int cxt_handle_hw_switch(kest_context *cxt, int sw)
kest_profile * cxt_get_profile_by_fname(kest_context *cxt, const char *fname)
int kest_context_init_effect_list(kest_context *cxt)
int cxt_remove_profile(kest_context *cxt, kest_profile *profile)
kest_sequence * kest_context_add_sequence_rp(kest_context *cxt)
int kest_cxt_obtain_mutex_wait_forever(kest_context *cxt)
int cxt_set_all_profiles_left_button_to_main_menu(kest_context *cxt)
int kest_context_init_main_sequence(kest_context *cxt)
kest_profile_pll profile_ll
#define CONTEXT_PROFILE_ID
const char * kest_effect_name(kest_effect *effect)
kest_setting * effect_get_setting(kest_effect *effect, int n)
kest_parameter * effect_get_parameter(kest_effect *effect, int n)
#define ERR_INVALID_TRANSFORMER_ID
#define ERR_MUTEX_UNAVAILABLE
#define ERR_FEATURE_DISABLED
#define ERR_INVALID_PROFILE_ID
kest_expression kest_expression_standard_gain_min
kest_expression kest_expression_standard_gain_max
int fnames_agree(char *a, char *b)
#define MAIN_SEQUENCE_FNAME
#define KEST_FILENAME_LEN
int kest_parameter_trigger_update(kest_parameter *param, float target)
int init_parameter(kest_parameter *param, const char *name, float level, float min, float max)
int kest_profile_remove_effect(kest_profile *profile, uint16_t id)
int init_m_profile(kest_profile *profile)
int kest_profile_save(kest_profile *profile)
void free_profile(kest_profile *profile)
int kest_profile_set_active(kest_profile *profile)
int kest_profile_set_inactive(kest_profile *profile)
#define PROFILE_NAME_MAX_LEN
int queue_representation_list_update(kest_representation_pll *reps)
int kest_sequence_regress(kest_sequence *sequence)
int kest_sequence_activate_at(kest_sequence *sequence, kest_profile *profile)
int init_m_sequence(kest_sequence *sequence)
void free_sequence(kest_sequence *sequence)
int kest_sequence_advance(kest_sequence *sequence)
kest_sequence_pll sequence_ll
void kest_state_representation_update(void *representer, void *representee)
int saved_sequences_loaded
kest_parameter input_gain
kest_sequence main_sequence
int saved_profiles_loaded
kest_effect_desc_pll * effects
kest_profile * working_profile
kest_parameter output_gain
kest_profile * active_profile
struct kest_expression * min_expr
struct kest_expression * max_expr
kest_effect_pll * effects
char fname[KEST_FILENAME_LEN]
char fname[KEST_FILENAME_LEN]