fluid-dev
[Top][All Lists]
Advanced

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

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


From: CERESA Jean-Jacques ENAC/ENAC
Subject: Re: [fluid-dev] [API] get total number of synthesized audio frames
Date: Thu, 27 Oct 2016 15:36:39 +0200

Hi Tom

"..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?"

Taking account the fact that a MIDI file may contains "tempo changes events",
the only way to known by advance the total time this file will play is to write
a procedure that look inside the file and compute this time. The principle to do that
is not too complicated, if you intend to do that and don't know how to do , i think i can
give the way.

regards

jjc

Le 03/10/16, "Tom M." <address@hidden> a écrit :
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

_______________________________________________
fluid-dev mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fluid-dev

reply via email to

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