Browse Source

Merge branch 'develop'

master
parent
commit
1fd64bcf45
  1. 6
      man/kmxtool.1.in
  2. 18
      src/kmxtool.c
  3. 33
      src/midi.c
  4. 6
      src/midi.h

6
man/kmxtool.1.in

@ -15,6 +15,8 @@ kmxtool - KORG microX Utility
.IR id ]
.RB [ \-l | --load-data
.IR id ]
.RB [ \-c | --local-control
.IR on | off ]
.YS
.SH DESCRIPTION
@ -57,6 +59,10 @@ Dump the specified memory slot to standard output.
.BR -l ", " --load-data " " \fIid\fR
Load data read from standard input to the specified
memory slot.
.TP
.BR -c ", " --local-control " " \fIon\fR " | " \fIoff\fR
Enable or disable the Local Control setting on the
synthesizer.
.SH MEMORY SLOT NAMES
.PP

18
src/kmxtool.c

@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <getopt.h>
#include <err.h>
@ -34,6 +35,7 @@
#define MODE_DATA_DUMP 0x1
#define MODE_DATA_LOAD 0x2
#define MODE_PROGRAM_LIST 0x4
#define MODE_SET_LOCAL_CTRL 0x8
/* Globals. */
@ -68,6 +70,8 @@ Send/receive data to/from a connected microX synthesizer.\n");
-d, --dump-data ID Dump the specified slot.\n\
-l, --load-data ID Load data read from standard\n\
input into the specified slot.\n\
-c, --local-control on|off\n\
Enable or disable Local Control.\n\
");
printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
@ -231,6 +235,7 @@ main(int argc, char **argv)
{ "dump-data", 1, NULL, 'd' },
{ "load-data", 1, NULL, 'l' },
{ "list-programs", 0, NULL, 'L' },
{ "local-control", 1, NULL, 'c' },
{ NULL, 0, NULL, 0 }
};
@ -241,7 +246,7 @@ main(int argc, char **argv)
port = param = NULL;
mode = MODE_STATUS;
while ( (c = getopt_long(argc, argv, "hvp:sd:l:L",
while ( (c = getopt_long(argc, argv, "hvp:sd:l:Lc",
options, NULL)) != -1 ) {
switch ( c ) {
case 'h':
@ -277,6 +282,11 @@ main(int argc, char **argv)
case 'L':
mode = MODE_PROGRAM_LIST;
break;
case 'c':
mode = MODE_SET_LOCAL_CTRL;
param = optarg;
break;
}
}
@ -350,6 +360,12 @@ main(int argc, char **argv)
else if ( mode == MODE_PROGRAM_LIST ) {
do_list_programs(midi);
}
else if ( mode == MODE_SET_LOCAL_CTRL ) {
unsigned char value;
value = strncmp(param, "on", 2) == 0 ? 0x7F : 0x00;
midi_set_controller(midi, channel, 0x7A, value);
}
return EXIT_SUCCESS;
}

33
src/midi.c

@ -615,6 +615,39 @@ midi_change_program(midi_io_t *midi,
return midi_write(midi, msg, sizeof(msg)) == sizeof(msg) ? 0 : -1;
}
/**
* Set a MIDI controller to a specified value.
* This function emits a Control Change message to set a MIDI
* controller to a specified value.
*
* @param[in] midi The MIDI port to write to.
* @param[in] channel The MIDI channel to write to.
* @param[in] controller The controller number to assign.
* @param[in] value The value to assign to the controller.
*
* @return
* - 0 if the message was successfully sent;
* - -1 if an error occured.
*/
int
midi_set_controller(midi_io_t *midi,
unsigned char channel,
unsigned char controller,
unsigned char value)
{
unsigned char msg[] = { 0xB0, /* Control change */
0x00, /* Controller */
0x00, /* Value */ };
assert(midi != NULL);
msg[0] |= (channel & 0x0F);
msg[1] |= (controller & 0x7F);
msg[2] |= (value & 0x7F);
return midi_write(midi, msg, sizeof(msg)) == sizeof(msg) ? 0 : -1;
}
/**
* General MIDI patches.
* This array contains the names of the standard GM patches.

6
src/midi.h

@ -56,6 +56,12 @@ midi_change_program(midi_io_t *,
unsigned short,
unsigned char);
int
midi_set_controller(midi_io_t *,
unsigned char,
unsigned char,
unsigned char);
char **
midi_get_ports(void);

Loading…
Cancel
Save