commit 57ed722be1fe7905070e6e9a915b1a37b1a22995
parent 70a37137286944779020bc15a2eff4911599288c
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date: Thu, 29 Sep 2016 16:45:59 +0200
Restrict does not work on C++...
Diffstat:
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/include/clap/helpers/midi-parser.c b/include/clap/helpers/midi-parser.c
@@ -203,7 +203,7 @@ clap_midi_parse_track(struct clap_midi_parser *parser)
}
static inline bool
-clap_midi_parse_vtime(struct clap_midi_parser * restrict parser)
+clap_midi_parse_vtime(struct clap_midi_parser *parser)
{
uint8_t nbytes = 0;
bool cont = false; // continue flag
@@ -231,10 +231,10 @@ clap_midi_parse_channel_event(struct clap_midi_parser *parser)
if (parser->size < 3)
return CLAP_MIDI_PARSER_EOB;
- parser->channel.event_type = parser->in[0] >> 4;
- parser->channel.channel = parser->in[0] & 0xf;
- parser->channel.param1 = parser->in[1];
- parser->channel.param2 = parser->in[2];
+ parser->channel.status = parser->in[0] >> 4;
+ parser->channel.channel = parser->in[0] & 0xf;
+ parser->channel.param1 = parser->in[1];
+ parser->channel.param2 = parser->in[2];
parser->in += 3;
parser->size -= 3;
@@ -319,7 +319,7 @@ clap_midi_convert(const uint8_t *in,
enum clap_midi_parser_status status = clap_midi_parse(&parser);
switch (status) {
case CLAP_MIDI_PARSER_TRACK_MIDI:
- switch (parser.channel.event_type) {
+ switch (parser.channel.status) {
case CLAP_MIDI_STATUS_NOTE_OFF:
event->type = CLAP_EVENT_NOTE_OFF;
event->note.key = parser.channel.param1;
diff --git a/include/clap/helpers/midi-parser.h b/include/clap/helpers/midi-parser.h
@@ -7,6 +7,10 @@
#ifndef CLAP_HELPERS_MIDI_PARSER_H
# define CLAP_HELPERS_MIDI_PARSER_H
+# ifdef __cplusplus
+extern "C" {
+# endif
+
# include <stdint.h>
# include <string.h>
@@ -68,9 +72,9 @@ enum clap_midi_status
};
static const char *
-clap_midi_status_name(int type)
+clap_midi_status_name(int status)
{
- switch (type) {
+ switch (status) {
case CLAP_MIDI_STATUS_NOTE_OFF: return "Note Off";
case CLAP_MIDI_STATUS_NOTE_ON: return "Note On";
case CLAP_MIDI_STATUS_NOTE_AT: return "Note Aftertouch";
@@ -85,7 +89,7 @@ clap_midi_status_name(int type)
struct clap_midi_channel_event
{
- unsigned event_type : 4;
+ unsigned status : 4;
unsigned channel : 4;
uint8_t param1;
uint8_t param2;
@@ -136,4 +140,8 @@ clap_midi_convert(const uint8_t *in,
# include "midi-parser.c"
+# ifdef __cplusplus
+}
+# endif
+
#endif /* !CLAP_MIDI_PARSER_H */
diff --git a/tests/midi-parser/midi-parser.c b/tests/midi-parser/midi-parser.c
@@ -47,7 +47,7 @@ void parse_and_dump(struct clap_midi_parser *parser)
case CLAP_MIDI_PARSER_TRACK_MIDI:
puts("track-midi");
printf(" time: %d\n", parser->vtime);
- printf(" type: %d\n", parser->channel.event_type);
+ printf(" status: %d [%s]\n", parser->channel.status, clap_midi_status_name(parser->channel.status));
printf(" channel: %d\n", parser->channel.channel);
printf(" param1: %d\n", parser->channel.param1);
printf(" param2: %d\n", parser->channel.param2);