1
/* LIBGIMP - The GIMP Library
2
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
1
/* GIMP - The GNU Image Manipulation Program
2
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
5
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
5
* Copyright (C) 2004-2007 Michael Natterer <mitch@gimp.org>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the
19
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
22
#include "config.h"
24
#define _GNU_SOURCE /* the ALSA headers need this */
27
28
#include <string.h>
162
166
GIMP_MODULE_ABI_VERSION,
163
167
N_("MIDI event controller"),
164
168
"Michael Natterer <mitch@gimp.org>",
166
"(c) 2004, released under the GPL",
170
"(c) 2004-2007, released under the GPL",
253
255
_("The MIDI channel to read events from. Set to -1 for reading from all MIDI channels."),
257
GIMP_MODULE_PARAM_SERIALIZE));
257
GIMP_CONFIG_PARAM_FLAGS));
259
259
controller_class->name = _("MIDI");
260
260
controller_class->help_id = "gimp-controller-midi";
261
controller_class->stock_id = GIMP_STOCK_CONTROLLER_MIDI;
262
263
controller_class->get_n_events = midi_get_n_events;
263
264
controller_class->get_event_name = midi_get_event_name;
379
380
if (! midi_events[event_id].blurb)
381
382
if (event_id <= 127)
382
midi_events[event_id].blurb = g_strdup_printf ("Note %02x on",
383
midi_events[event_id].blurb = g_strdup_printf (_("Note %02x on"),
384
385
else if (event_id <= 255)
385
midi_events[event_id].blurb = g_strdup_printf ("Note %02x off",
386
midi_events[event_id].blurb = g_strdup_printf (_("Note %02x off"),
387
388
else if (event_id <= 383)
388
midi_events[event_id].blurb = g_strdup_printf ("Controller %03d",
389
midi_events[event_id].blurb = g_strdup_printf (_("Controller %03d"),
442
443
if (! g_ascii_strcasecmp (midi->device, "alsa"))
444
GAlsaSource *event_source;
445
GSource *event_source;
449
450
ret = snd_seq_open (&midi->sequencer, "default",
450
451
SND_SEQ_OPEN_INPUT, 0);
453
snd_seq_set_client_name (midi->sequencer, "The GIMP");
454
snd_seq_set_client_name (midi->sequencer, _("GIMP"));
454
455
ret = snd_seq_create_simple_port (midi->sequencer,
455
"The GIMP midi controller",
456
_("GIMP MIDI Input Controller"),
456
457
SND_SEQ_PORT_CAP_WRITE |
457
458
SND_SEQ_PORT_CAP_SUBS_WRITE,
458
459
SND_SEQ_PORT_TYPE_APPLICATION);
484
485
g_object_set (midi, "state", state, NULL);
487
event_source = (GAlsaSource *) g_source_new (&alsa_source_funcs,
488
sizeof (GAlsaSource));
489
event_source->controller = midi;
490
midi->seq_id = g_source_attach ((GSource *) event_source, NULL);
488
event_source = g_source_new (&alsa_source_funcs,
489
sizeof (GAlsaSource));
491
((GAlsaSource *) event_source)->controller = midi;
493
midi->seq_id = g_source_attach (event_source, NULL);
494
g_source_unref (event_source);
494
498
#endif /* HAVE_ALSA */
496
500
#ifdef G_OS_WIN32
497
fd = open (midi->device, O_RDONLY);
501
fd = g_open (midi->device, O_RDONLY, 0);
499
fd = open (midi->device, O_RDONLY | O_NONBLOCK);
503
fd = g_open (midi->device, O_RDONLY | O_NONBLOCK, 0);