Changing sequencer time-scale

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing sequencer time-scale

Jeroen Neve

Hello All,

 

 

In my proof of concept, I have the following code:

 

/* callback of the sequencer */

void sequencer_callback(unsigned int time, fluid_event_t* ev, fluid_sequencer_t* seq, void* pdata) {

 

       printf("%d\n", fluid_sequencer_get_tick(seq));

 

       fluid_sequencer_set_time_scale(seq, 500.0); // 500 ticks per second - i.e.: slow down

 

       printf("time-scale changed!\n");

 

       printf("%d\n", fluid_sequencer_get_tick(seq));

}

 

The sequencer runs at the default 1000 ticks/s (of rendered sound-output), and in the call-back I scheduled at 2400 ticks, I change the time-scale (representing a tempo change in the music)

 

The output here is:

2400

time-scale changed!

1200

 

It looks like that when the I change the time-scale that this also impacts the current tick of the sequencer.

Is there a way around this?

 

This may be relevant: fluid_sequencer_set_time_scale causes timing problems · Issue #195 · FluidSynth/fluidsynth · GitHub

 

 

Regards,

Jeroen Neve

 


_______________________________________________
fluid-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Reply | Threaded
Open this post in threaded view
|

Re: Changing sequencer time-scale

fluid-dev mailing list
This quirk will be fixed in fluidsynth 2.2.0. There are still two issues open before we are ready for releasing it. In the meantime, you can clone recent master and try it yourself. Feedback is welcome.

Tom

_______________________________________________
fluid-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Reply | Threaded
Open this post in threaded view
|

Re: Changing sequencer time-scale

dave-2

Hi,

 

Jeroen's question is relevant for my own efforts to schedule events, essentially from a MIDI file, in the FluidSynth sequencer, in order to create a WAV file.

 

It appears that the one important event that I can't directly schedule is a tempo change.  In MIDI this is a 6 byte event starting with (hex) bytes FF 51 03  and then with 3 data bytes specifying the new relationship between ticks and milliseconds.

 

It would be nice if I could just schedule this event directly in the sequencer when needed.  But...

 

.. I gather that the way to do it should be to schedule a call-back, and from within the call-back use fluid_sequencer_set_time_scale() to redefine the relationship between ticks and milliseconds.   Do I understand that this should work straightforwardly after the 2.2.0 fix?

 

If so, can I ask about 'simultaneous' events?   In music, a tempo change is usually notated at a bar line, and a note may start immediately after the bar line.  This would result in a note-on event scheduled with the same time-marking as the tempo change (or in this case the case the call-back).   Will that be OK?

 

Looking forward to getting further up the learning curve with FluidSynth in the New Year.   It’s going to save me from MIDI’s 16 channel constraint, and I’m seriously impressed.

Dave

 

 

From: fluid-dev <fluid-dev-bounces+dave=[hidden email]> On Behalf Of Tom M. via fluid-dev
Sent: 25 December 2020 23:05
To: Jeroen Neve <[hidden email]>
Cc: Tom M. <[hidden email]>; FluidSynth mailing list <[hidden email]>
Subject: Re: [fluid-dev] Changing sequencer time-scale

 

This quirk will be fixed in fluidsynth 2.2.0. There are still two issues open before we are ready for releasing it. In the meantime, you can clone recent master and try it yourself. Feedback is welcome.

 

Tom


_______________________________________________
fluid-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Reply | Threaded
Open this post in threaded view
|

Re: Changing sequencer time-scale

fluid-dev mailing list
> It appears that the one important event that I can't directly schedule is a tempo change. [...] It would be nice if I could just schedule this event directly in the sequencer when needed.

At the moment one needs to use a callback event, yes. However, thinking about it again, I do see a need for a dedicated FLUID_SEQ_SCALE event as well. I'll add one.

> This would result in a note-on event scheduled with the same time-marking as the tempo change. Will that be OK?


It is ok. For details pls see the hint for fluid_sequencer_send_at()  https://www.fluidsynth.org/api/group__sequencer.html#ga83314f4ad773979841afe50cc2efd83f



Tom

_______________________________________________
fluid-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Reply | Threaded
Open this post in threaded view
|

Re: Changing sequencer time-scale

Jeroen Neve
In reply to this post by fluid-dev mailing list

 

 

From: Tom M. <[hidden email]>
Sent: 26 December, 2020 00:05
To: Jeroen Neve <[hidden email]>
Cc: FluidSynth mailing list <[hidden email]>
Subject: Re: [fluid-dev] Changing sequencer time-scale

 

 

> This quirk will be fixed in fluidsynth 2.2.0. There are still two issues open before we are ready for releasing it. In the meantime, you can clone recent master and try it yourself. Feedback is welcome.

 

 

Thanks, Tom.

 

I’ve rebuilt fluidsynth from the lastest source, and now it works as one would expect. ( the sequencer tick keeps track when the time-scale changes.)

I also tried a time-scale factor > 1000.0, and the tempo sped up without a hitch.

 

Only tested this through the callback mechanism however, as the fluid_seq_scale  event was not yet pulled into the master branch.

 

 

Thanks again for  your efforts,
Jeroen Neve

 


_______________________________________________
fluid-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Reply | Threaded
Open this post in threaded view
|

Re: Changing sequencer time-scale

fluid-dev mailing list
> I’ve rebuilt fluidsynth from the lastest source, and now it works as one would expect.

Great, glad to hear that!

I've just finished testing the FLUID_SEQ_SCALE event and merged it to master now.

Tom

_______________________________________________
fluid-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Reply | Threaded
Open this post in threaded view
|

Re: Changing sequencer time-scale

dave-2
Thanks for that Tom and Jeroen,

I'm still working on saving a wav file, so it looks like it will probably be ready in a release version by the time I'm ready for it!

The time-scale factor > 1000.0 is also particularly useful.  I habitually work with a MIDI 'division' (ticks per crotchet/quarter-note) of 480, as this (=5*3*32) allows an even split into 128th notes, and triplets and quintuplets.   With that value, a typical march tempo of 120 crotchets per minute results in 960 ticks per second, and anything faster will go past 1000.   So it's nice not to have to compromise on this.

Dave

-----Original Message-----
From: fluid-dev <fluid-dev-bounces+dave=[hidden email]> On Behalf Of Tom M. via fluid-dev
Sent: 27 December 2020 16:55
To: Jeroen Neve <[hidden email]>
Cc: Tom M. <[hidden email]>; [hidden email]
Subject: Re: [fluid-dev] Changing sequencer time-scale

> I’ve rebuilt fluidsynth from the lastest source, and now it works as one would expect.

Great, glad to hear that!

I've just finished testing the FLUID_SEQ_SCALE event and merged it to master now.

Tom

_______________________________________________
fluid-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/fluid-dev


_______________________________________________
fluid-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/fluid-dev