[sdiy] OT (but very synthy): C question
Olivier Gillet
ol.gillet at gmail.com
Tue Mar 29 16:37:25 CEST 2011
Here is what I would recommend:
lfo.h:
#ifndef PATH_TO_LFO_H_
#define PATH_TO_LFO_H_
/* We only need a forward declaration here, no need to include the
full MIDI declaration */
typedef struct MIDI MIDI;
struct LFO {
uint32_t phase_;
};
void process_lfo(LFO* lfo, MIDI* midi);
#endif /* PATH_TO_LFO_H_ */
midi.h:
#ifndef PATH_TO_MIDI_H_
#define PATH_TO_MIDI_H_
/* Includes in headers are bad, but there's no other option here
because MIDI_MESSAGE
can be left as an incomplete type - we must know what it is made of to know
the right size of the MIDI struct */
#include "midi_message.h"
/* We only need a forward declaration here, no need to include the
full LFO declaration */
typedef struct LFO LFO;
struct MIDI {
uint8_t running_status_;
uint8_t data_[8]; /* whatever */
MIDI_MESSAGE last_message_;
};
void process_midi(MIDI* midi, LFO* lfo);
#endif /* PATH_TO_MIDI_H_ */
More information about the Synth-diy
mailing list