5 Commits

Author SHA1 Message Date
Damien Goutte-Gattat 20284b203e Fix man pages. 1 year ago
Damien Goutte-Gattat 1fd64bcf45 Merge branch 'develop' 1 year ago
Damien Goutte-Gattat bfdb46ed63 Update project location. 2 years ago
Damien Goutte-Gattat c2fde9639f kmxtool: Add a --local-control option 5 years ago
Damien Goutte-Gattat f68921a31f Add a midi_set_controller function 5 years ago
  1. 2
      AUTHORS
  2. 7
      README.md
  3. 4
      man/asysex.1.in
  4. 10
      man/kmxtool.1.in
  5. 18
      src/kmxtool.c
  6. 33
      src/midi.c
  7. 6
      src/midi.h

2
AUTHORS

@ -1 +1 @@
Damien Goutte-Gattat
Damien Goutte-Gattat <dgouttegattat@incenp.org>

7
README.md

@ -110,8 +110,5 @@ License, version 3 or higher. The full license is included in the
Homepage and contact
--------------------
The project homepage, where release tarballs may be found, is located at
<http://www.incenp.org/dvlpt/kmxtool.html>. The repository containing
the latest source code is available at <git://git.incenp.org/kmxtool.git>.
To contact the author, use the following address:
Damien Goutte-Gattat <dgouttegattat@incenp.org>
<http://www.incenp.org/dvlpt/kmxtool.html>. The repository with the
latest source code is available at <https://git.incenp.org/damien/kmxtool>.

4
man/asysex.1.in

@ -1,4 +1,4 @@
.TH ASYSEX 02/04/2012 "asysex"
.TH ASYSEX 1 2012-04-03 "asysex @PACKAGE_VERSION@"
.SH NAME
asysex - A SysEx Utility
@ -84,7 +84,7 @@ F7 # End of SysEx message
.SH REPORTING BUGS
.PP
Report bugs to
.MT dgouttegattat@incenp.org
.MT @PACKAGE_BUGREPORT@
Damien Goutte-Gattat
.ME .

10
man/kmxtool.1.in

@ -1,4 +1,4 @@
.TH ASYSEX 31/01/2013 "kmxtool"
.TH KMXTOOL 1 2016-11-13 "kmxtool @PACKAGE_VERSION@"
.SH NAME
kmxtool - KORG microX Utility
@ -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
@ -97,7 +103,7 @@ format, and prints the dumped data in that format.
.SH REPORTING BUGS
.PP
Report bugs to
.MT dgouttegattat@incenp.org
.MT @PACKAGE_BUGREPORT@
Damien Goutte-Gattat
.ME .

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