<commit_before>/* $Id: midi.h,v 1.24 2016/08/13 18:20:59 je Exp $ */

/*
 * Copyright (c) 2015 <NAME> <<EMAIL>>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef MDL_MIDI_H
#define MDL_MIDI_H

#include "instrument.h"
#include "util.h"

#define MIDI_CHANNEL_COUNT	16
#define MIDI_NOTE_COUNT		128

enum midievent_type {
	MIDIEV_NOTEOFF,
	MIDIEV_INSTRUMENT_CHANGE,
	MIDIEV_NOTEON,
	MIDIEV_SONG_END,
	MIDIEV_TEMPOCHANGE,
	MIDIEV_TYPECOUNT,	/* not a type */
};

struct instrument_change {
	u_int8_t	channel, code;
};

struct midinote {
	u_int8_t	channel, note, velocity;
};

struct midievent {
	enum midievent_type	evtype;
	float			time_as_measures;
	union {
		struct midinote			note;
		struct instrument_change	instr_change;
		float				tempochange_bpm;
	} u;
};

enum mididev_type { MIDIDEV_NONE, MIDIDEV_RAW, MIDIDEV_SNDIO };

__BEGIN_DECLS
int	_mdl_midi_open_device(enum mididev_type, const char *);
int	_mdl_midi_check_midievent(struct midievent, float);
int	_mdl_midi_send_midievent(struct midievent *, int);
void	_mdl_midi_close_device(void);

enum mididev_type	_mdl_midi_get_mididev_type(const char *);

void	_mdl_midievent_log(enum logtype, const char *, struct midievent *,
    int);
__END_DECLS

#endif /* !MDL_MIDI_H */<commit_msg>Stylistic change on struct fields.<commit_after>/* $Id: midi.h,v 1.25 2016/08/18 20:01:29 je Exp $ */

/*
 * Copyright (c) 2015 <NAME> <<EMAIL>>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef MDL_MIDI_H
#define MDL_MIDI_H

#include "instrument.h"
#include "util.h"

#define MIDI_CHANNEL_COUNT	16
#define MIDI_NOTE_COUNT		128

enum midievent_type {
	MIDIEV_NOTEOFF,
	MIDIEV_INSTRUMENT_CHANGE,
	MIDIEV_NOTEON,
	MIDIEV_SONG_END,
	MIDIEV_TEMPOCHANGE,
	MIDIEV_TYPECOUNT,	/* not a type */
};

struct instrument_change {
	u_int8_t	channel;
	u_int8_t	code;
};

struct midinote {
	u_int8_t	channel;
	u_int8_t	note;
	u_int8_t	velocity;
};

struct midievent {
	enum midievent_type	evtype;
	float			time_as_measures;
	union {
		struct midinote			note;
		struct instrument_change	instr_change;
		float				tempochange_bpm;
	} u;
};

enum mididev_type { MIDIDEV_NONE, MIDIDEV_RAW, MIDIDEV_SNDIO };

__BEGIN_DECLS
int	_mdl_midi_open_device(enum mididev_type, const char *);
int	_mdl_midi_check_midievent(struct midievent, float);
int	_mdl_midi_send_midievent(struct midievent *, int);
void	_mdl_midi_close_device(void);

enum mididev_type	_mdl_midi_get_mididev_type(const char *);

void	_mdl_midievent_log(enum logtype, const char *, struct midievent *,
    int);
__END_DECLS

#endif /* !MDL_MIDI_H */
{'fraction_non_alphanumeric': 0.07444359171143515, 'fraction_numerical': 0.015093374264517779, 'mean_word_length': 4.924242424242424, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4953896', 'n_tokens_mistral': 1524, 'n_tokens_neox': 1407, 'n_words': 433}