#include <stdlib.h>
#include <stdio.h>
#include <fluidsynth.h>
short synth_destination, client_destination;
unsigned int time_marker;
#define TEMPO 120
unsigned int note_duration = 60000 / TEMPO;
unsigned int weak_note = 33;
unsigned int strong_note = 34;
unsigned int pattern_size = 4;
void
void
schedule_noteon (int chan, short key, unsigned int ticks)
{
}
void
schedule_timer_event ()
{
}
void
schedule_pattern ()
{
int i, note_time;
note_time = time_marker;
for (i = 0; i < pattern_size; ++i) {
schedule_noteon (9, i ? weak_note : strong_note, note_time);
note_time += note_duration;
}
time_marker = note_time;
}
void
{
schedule_timer_event ();
schedule_pattern ();
}
void
usage (char* prog_name)
{
printf ("Usage: %s soundfont.sf2 [beats [tempo]]\n", prog_name);
printf ("\t(optional) beats: number of pattern beats, default %d\n",
pattern_size);
printf ("\t(optional) tempo: BPM (Beats Per Minute), default %d\n", TEMPO);
}
int
main (int argc, char *argv[])
{
int n;
if (argc < 2) {
usage (argv[0]);
} else {
synth);
"fluidsynth_metronome", sequencer_callback, NULL);
if (n != -1) {
if (argc > 2) {
n = atoi (argv[2]);
if (n > 0) pattern_size = n;
}
if (argc > 3) {
n = atoi (argv[3]);
if (n > 0) note_duration = 60000 / n;
}
schedule_pattern ();
schedule_timer_event ();
schedule_pattern ();
printf ("press <Enter> to stop\n");
n = getchar ();
}
}
return 0;
}