#include <stdlib.h>
#include <stdio.h>
#include <fluidsynth.h>
short synth_destination, client_destination;
unsigned int time_marker;
unsigned int duration = 1440;
unsigned int notes[] = { 60, 64, 67, 72, 76, 79, 84, 79, 76, 72, 67, 64 };
unsigned int pattern_size;
void
void
schedule_noteon(int chan, short key, unsigned int ticks)
{
}
void
schedule_noteoff(int chan, short key, unsigned int ticks)
{
}
void
schedule_timer_event(void)
{
}
void
schedule_pattern(void)
{
unsigned int i;
int note_time, note_duration;
note_time = time_marker;
note_duration = duration / pattern_size;
for(i = 0; i < pattern_size; ++i)
{
schedule_noteon(0, notes[i], note_time);
note_time += note_duration;
schedule_noteoff(0, notes[i], note_time);
}
time_marker += duration;
}
void
{
schedule_timer_event();
schedule_pattern();
}
void
usage(char *prog_name)
{
printf("Usage: %s soundfont.sf2 [steps [duration]]\n", prog_name);
printf("\t(optional) steps: number of pattern notes, from 2 to %d\n",
pattern_size);
printf("\t(optional) duration: of the pattern in ticks, default %d\n",
duration);
}
int
main(int argc, char *argv[])
{
int n;
pattern_size = sizeof(notes) / sizeof(int);
if(argc < 2)
{
usage(argv[0]);
}
else
{
if(n != -1)
{
synth);
"arpeggio", sequencer_callback, NULL);
if(argc > 2)
{
n = atoi(argv[2]);
if((n > 1) && (n <= (int)pattern_size))
{
pattern_size = n;
}
}
if(argc > 3)
{
n = atoi(argv[3]);
if(n > 0)
{
duration = n;
}
}
schedule_pattern();
schedule_timer_event();
schedule_pattern();
printf("press <Enter> to stop\n");
n = getchar();
}
}
return 0;
}
struct _fluid_sequencer_t fluid_sequencer_t
Sequencer instance.
Definition: types.h:57
struct _fluid_hashtable_t fluid_settings_t
Configuration settings instance.
Definition: types.h:38
struct _fluid_audio_driver_t fluid_audio_driver_t
Audio driver instance.
Definition: types.h:46
struct _fluid_event_t fluid_event_t
Sequencer event.
Definition: types.h:56
struct _fluid_synth_t fluid_synth_t
Synthesizer instance.
Definition: types.h:39
fluid_audio_driver_t * new_fluid_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)
Create a new audio driver.
Definition: fluid_adriver.c:350
void delete_fluid_audio_driver(fluid_audio_driver_t *driver)
Deletes an audio driver instance.
Definition: fluid_adriver.c:443
void fluid_event_set_source(fluid_event_t *evt, fluid_seq_id_t src)
Set source of a sequencer event.
Definition: fluid_event.c:112
void fluid_event_set_dest(fluid_event_t *evt, fluid_seq_id_t dest)
Set destination of this sequencer event, i.e.
Definition: fluid_event.c:123
void fluid_event_noteon(fluid_event_t *evt, int channel, short key, short vel)
Set a sequencer event to be a note on event.
Definition: fluid_event.c:150
fluid_event_t * new_fluid_event(void)
Create a new sequencer event structure.
Definition: fluid_event.c:59
void fluid_event_timer(fluid_event_t *evt, void *data)
Set a sequencer event to be a timer event.
Definition: fluid_event.c:134
void fluid_event_noteoff(fluid_event_t *evt, int channel, short key)
Set a sequencer event to be a note off event.
Definition: fluid_event.c:171
void delete_fluid_event(fluid_event_t *evt)
Delete a sequencer event structure.
Definition: fluid_event.c:81
fluid_seq_id_t fluid_sequencer_register_client(fluid_sequencer_t *seq, const char *name, fluid_event_callback_t callback, void *data)
Register a sequencer client.
Definition: fluid_seq.c:210
fluid_sequencer_t * new_fluid_sequencer2(int use_system_timer)
Create a new sequencer object.
Definition: fluid_seq.c:113
int fluid_sequencer_send_at(fluid_sequencer_t *seq, fluid_event_t *evt, unsigned int time, int absolute)
Schedule an event for sending at a later time.
Definition: fluid_seq.c:476
fluid_seq_id_t fluid_sequencer_register_fluidsynth(fluid_sequencer_t *seq, fluid_synth_t *synth)
Registers a synthesizer as a destination client of the given sequencer.
Definition: fluid_seqbind.c:111
void delete_fluid_sequencer(fluid_sequencer_t *seq)
Free a sequencer object.
Definition: fluid_seq.c:157
unsigned int fluid_sequencer_get_tick(fluid_sequencer_t *seq)
Get the current tick of the sequencer scaled by the time scale currently set.
Definition: fluid_seq.c:547
fluid_settings_t * new_fluid_settings(void)
Create a new settings object.
Definition: fluid_settings.c:262
void delete_fluid_settings(fluid_settings_t *settings)
Delete the provided settings object.
Definition: fluid_settings.c:286
int fluid_synth_sfload(fluid_synth_t *synth, const char *filename, int reset_presets)
Load a SoundFont file (filename is interpreted by SoundFont loaders).
Definition: fluid_synth.c:5402
fluid_synth_t * new_fluid_synth(fluid_settings_t *settings)
Create new FluidSynth instance.
Definition: fluid_synth.c:645
void delete_fluid_synth(fluid_synth_t *synth)
Delete a FluidSynth instance.
Definition: fluid_synth.c:1044