fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[fluid-dev] [API] get total number of synthesized audio frames


From: Tom M.
Subject: [fluid-dev] [API] get total number of synthesized audio frames
Date: Mon, 3 Oct 2016 17:55:57 +0200

Hi,

I'm trying to write a wrapper to make fluidsynth useable with my own
audio player. Instead of retrieving small buffers with decoded PCM, my
player holds the whole decoded song in memory. Thus is there any
(simple) way to predict the total number of audioframes that will be
generated when rendering a single midi file? Or how to get the total
time this midi file will play?

Given the following example code:

int main(int argc, char** argv)
{
    fluid_settings_t* settings;
    fluid_synth_t* synth;
    fluid_player_t* player;

    settings = new_fluid_settings();
    fluid_settings_setstr(settings, "player.timing-source", "sample");
    fluid_settings_setint(settings, "synth.parallel-render", 0);

    synth = new_fluid_synth(settings);
    player = new_fluid_player(synth);

    fluid_synth_sfload(synth, "someSF.sf2", 0);
    fluid_player_add(player, "someMidi.mid");

    /* play the midi files, if any */
    fluid_player_play(player);

    // TODO:

    // somehow get the total number of audio frames, that will be
generated by fluid_synth_process() to render whole song

    // then, synthesize the audio through a single call to fluid_synth_process()

    /* wait for playback termination */
    fluid_player_join(player);
    /* cleanup */
    delete_fluid_player(player);
    delete_fluid_synth(synth);
    delete_fluid_settings(settings);
    return 0;
}


Tom



reply via email to

[Prev in Thread] Current Thread [Next in Thread]