libnjb: dumpeax.c

libnjb 2.2.7

dumpeax.c
#include "common.h"
int main(int argc, char **argv)
{
njb_t njbs[NJB_MAX_DEVICES], *njb;
extern char *optarg;
int opt;
int i, n, debug;
njb_eax_t *eax;
debug = 0;
while ((opt = getopt(argc, argv, "D:")) != -1) {
switch (opt) {
case 'D':
debug = atoi(optarg);
break;
default:
fprintf(stderr, "usage: dumpeax [ -D debuglvl ]\n");
return 1;
}
}
if (debug)
NJB_Set_Debug(debug);
if (NJB_Discover(njbs, 0, &n) == -1) {
fprintf(stderr, "could not locate any jukeboxes\n");
exit(1);
}
if (n == 0) {
fprintf(stderr, "no NJB devices found\n");
return 0;
}
njb = njbs;
if (NJB_Open(njb) == -1) {
NJB_Error_Dump(njb, stderr);
return 1;
}
if (NJB_Capture(njb) == -1) {
NJB_Error_Dump(njb, stderr);
return 1;
}
NJB_Reset_Get_EAX_Type (njb);
while ((eax = NJB_Get_EAX_Type (njb)) != NULL) {
printf("------------------------------------------\n");
printf("Effect number: %04X\n", eax->number);
printf("Effect name: %s\n", eax->name);
printf("Effect group %d\n", eax->group);
if (eax->exclusive != 0x00) {
printf("Effect is exclusive\n");
}
if (eax->type == NJB_EAX_FIXED_OPTION_CONTROL) {
printf("Effect has fixed options:\n");
printf(" Current selection: %d\n", eax->current_value);
for(i = 0; i < eax->max_value - eax->min_value + 1; i++) {
printf(" %d. %s\n", eax->min_value+i, eax->option_names[i]);
}
}
if (eax->type == NJB_EAX_SLIDER_CONTROL) {
printf("Effect is a slider:\n");
printf(" Current value: %d\n", eax->current_value);
printf(" Min value: %d\n", eax->min_value);
printf(" Max value %d\n", eax->max_value);
}
NJB_Destroy_EAX_Type (eax);
}
/* Dump any pending errors */
NJB_Error_Dump(njb, stderr);
NJB_Release(njb);
NJB_Close(njb);
return 0;
}
NJB_Discover
int NJB_Discover(njb_t *njbs, int limit, int *n)
Definition: procedure.c:108
NJB_Open
int NJB_Open(njb_t *njb)
Definition: procedure.c:130
NJB_Close
void NJB_Close(njb_t *njb)
Definition: procedure.c:184
njb_eax_struct::number
u_int16_t number
Definition: libnjb.h:350
njb_struct
Definition: libnjb.h:182
NJB_Get_EAX_Type
njb_eax_t * NJB_Get_EAX_Type(njb_t *njb)
Definition: procedure.c:1952
NJB_Destroy_EAX_Type
void NJB_Destroy_EAX_Type(njb_eax_t *eax)
Definition: procedure.c:1978
njb_eax_struct::name
char * name
Definition: libnjb.h:351
njb_eax_struct::exclusive
u_int8_t exclusive
Definition: libnjb.h:352
njb_eax_struct
Definition: libnjb.h:349
NJB_Reset_Get_EAX_Type
void NJB_Reset_Get_EAX_Type(njb_t *njb)
Definition: procedure.c:1915
NJB_Capture
int NJB_Capture(njb_t *njb)
Definition: procedure.c:223
njb_eax_struct::group
u_int8_t group
Definition: libnjb.h:360
njb_eax_struct::type
njb_eax_control_t type
Definition: libnjb.h:366
NJB_MAX_DEVICES
#define NJB_MAX_DEVICES
Definition: libnjb.h:60
njb_eax_struct::max_value
int16_t max_value
Definition: libnjb.h:384
NJB_Set_Debug
void NJB_Set_Debug(int debug_flags)
Definition: procedure.c:2819
NJB_Error_Dump
void NJB_Error_Dump(njb_t *njb, FILE *fp)
Definition: njb_error.c:418
NJB_Release
int NJB_Release(njb_t *njb)
Definition: procedure.c:266
njb_eax_struct::min_value
int16_t min_value
Definition: libnjb.h:379
njb_eax_struct::option_names
char ** option_names
Definition: libnjb.h:388
njb_eax_struct::current_value
int16_t current_value
Definition: libnjb.h:374