KORG microX utility.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

197 lines
6.1 KiB

/*
* kmxtool - KORG microX utility
* Copyright (C) 2012 Damien Goutte-Gattat
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <getopt.h>
#include <err.h>
#include <microx.h>
/* Globals. */
static midi_io_t *midi = NULL;
/* Help and informations about the program. */
static void
usage(int status)
{
puts("\
Usage: kmxtool [options]\n\
Send/receive data to/from a connected microX synthesizer.\n");
puts("Options:\n\
-h, --help Display this help message.\n\
-v, --version Display the version message.\n\
");
puts("\
-p, --port PORT Specify MIDI port to use.\n\
");
printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
exit(status);
}
static void
info(void)
{
printf("\
kmxtool %s\n\
Copyright (C) 2012 Damien Goutte-Gattat\n\
\n\
This program is released under the GNU General Public License.\n\
See the COPYING file or <http://www.gnu.org/licenses/gpl.html>.\n\
", VERSION);
exit(EXIT_SUCCESS);
}
/* Helper functions. */
static void
cleanup(void)
{
if ( midi ) {
midi_close(midi);
midi = NULL;
}
}
static void
print_microx_status(struct kmx_microx_status *s)
{
static char *modes[] = { "COMBI PLAY", "COMBI EDIT", "PROG PLAY",
"PROG EDIT", "MULTI", "GLOBAL" };
static char *clock[] = { "Internal", "Ext-MIDI", "Ext-USB", "AUTO" };
static char *flter[] = { "All", "Odd", "Even" };
static char *yesno[] = { "No", "Yes" };
static char *bnkmp[] = { "KORG", "GM" };
printf("Global channel: %d\n", s->global_channel);
printf("Active mode: %s\n",
s->active_mode == DEMO ? "DEMO" : modes[s->active_mode]);
printf("Status of Global mode:\n");
printf(" Local Control: %s\n", yesno[s->global.local_control]);
printf(" Clock Source: %s\n", clock[s->global.clock_source]);
printf(" Bank Map: %s\n", bnkmp[s->global.bank_map]);
printf(" Memorize Mode on Power On: %s\n", yesno[s->global.memorize_mode]);
printf(" Rec. Ext.Realtime Command: %s\n", yesno[s->global.rec_ext_rt_cmd]);
printf(" Enable Program Change: %s\n", yesno[s->global.prgm_change]);
printf(" Enable Bank Change: %s\n", yesno[s->global.bank_change]);
printf(" Enable Combination Change: %s\n", yesno[s->global.comb_change]);
printf(" Enable Control Change: %s\n", yesno[s->global.ctrl_change]);
printf(" Enable Aftertouch: %s\n", yesno[s->global.aftertouch]);
printf(" Note filter: %s\n", flter[s->global.note_filter]);
printf(" Protected Memory:\n");
printf(" Program: %s\n", yesno[s->global.protected_memory.program]);
printf(" Bank: %s\n", yesno[s->global.protected_memory.bank]);
printf(" Multi: %s\n", yesno[s->global.protected_memory.multi]);
printf(" Drums: %s\n", yesno[s->global.protected_memory.drum]);
printf(" Arpeggio Patterns: %s\n", yesno[s->global.protected_memory.arpeggio]);
printf(" Ext.Controllers: %s\n", yesno[s->global.protected_memory.ext_ctrl]);
printf("Status of Program mode:\n");
printf(" Current Bank: %c\n", 'A' + s->program.current_bank);
printf(" Current Program: %d\n", s->program.current_program);
printf("Status of Combination mode:\n");
printf(" Current Bank: %c\n", 'A' + s->combination.current_bank);
printf(" Current Combination: %d\n", s->combination.current_combination);
printf("Status of Multi mode:\n");
printf(" Current Multi: %d\n", s->multi.current_multi);
printf(" Control Track: %d\n", s->multi.control_track + 1);
printf("Status of Ext.Controllers:\n");
printf(" Ext.Controllers Enabled: %s\n", yesno[s->ext_ctrl.enabled]);
printf(" Current Controller: %d\n", s->ext_ctrl.current);
}
/* Main function. */
int
main(int argc, char **argv)
{
char c, *port;
int e;
struct kmx_microx_version version;
struct kmx_microx_status status;
struct option options[] = {
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'v' },
{ "port", 1, NULL, 'p' },
{ NULL, 0, NULL, 0 }
};
setprogname(argv[0]);
setlocale(LC_ALL, "");
atexit(cleanup);
port = DEFAULT_MIDI_PORT;
while ( (c = getopt_long(argc, argv, "hvp:", options, NULL)) != -1 ) {
switch ( c ) {
case 'h':
usage(EXIT_SUCCESS);
break;
case '?':
usage(EXIT_FAILURE);
break;
case 'v':
info();
break;
case 'p':
port = optarg;
break;
}
}
if ( ! (midi = midi_open(port)) )
errx(EXIT_FAILURE, "cannot open MIDI port %s", port);
if ( (e = kmx_microx_identify(midi, &version)) < 0 )
errx(EXIT_FAILURE, "cannot identify microX device: %s",
kmx_microx_error(midi, e));
printf("%s: KORG microX synthesizer, version %02d.%02d.%02d.%02d\n",
port, version.major, version.minor, version.release, version.build);
if ( (e = kmx_microx_query_status(midi, &status)) < 0 )
errx(EXIT_FAILURE, "cannot query microX status: %s",
kmx_microx_error(midi, e));
print_microx_status(&status);
return EXIT_SUCCESS;
}