Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MIDI player tempo reset issues #711

Merged
merged 46 commits into from
Jan 10, 2021
Merged

Fix MIDI player tempo reset issues #711

merged 46 commits into from
Jan 10, 2021

Conversation

jjceresa
Copy link
Collaborator

@jjceresa jjceresa commented Dec 5, 2020

This PR addresses issue #707 according to the last discussion.
@glm35, please, your are welcome to pull this branch fix-player-tempo an test the new function fluid_player_set_tempo(), and fluid_player_get_tempo().

@jjceresa
Copy link
Collaborator Author

jjceresa commented Dec 5, 2020

Please, as I am not familiar with doxygen formatting rule, could you have a check , in particular for fluid_player_tempo_type enum in midi.h file ?.

include/fluidsynth/midi.h Outdated Show resolved Hide resolved
@derselbst
Copy link
Member

Looks good to me. I'll keep this open for a few days to give @glm35 a chance to test this.

@jjceresa
Copy link
Collaborator Author

jjceresa commented Dec 6, 2020

Looks good to me....

Ok. Thanks for reviewing and fixing API docs, and grammar.

@jjceresa
Copy link
Collaborator Author

Could you precise that if no tempo is given in the midi file, a default value of 120 bpm will be used?

Yes, when no tempo change is given in a midi file, a default value of 120 bpm should be used. This is a MIDI file specification.
It will be useful to add this mention in the API comment.


60000000 bpm, really?

Yes, internally valid tempo value should be in the range [1..600000000] regardless if the value is in bpm or in us/quarter note.

jjceresa added 3 commits December 23, 2020 20:22
player.

(2)Add separate enum values
- fluid_player_set_tempo_type enum for fluid_player_set_tempo()
- fluid_player_get_tempo_type enum for fluid_player_get_tempo()
@jjceresa
Copy link
Collaborator Author

But I think that it might be enough to have a simpler API that would just return the current tempo used by the player in the desired format.

This is done in recent commit 0836a52 . One just need to call fluid_player_get_tempo() with FLUID_PLAYER_GET_TEMPO_USED_BPM or FLUID_PLAYER_GET_TEMPO_USED_MIDI.

@derselbst
Copy link
Member

First of all, I'm glad to see that everything is working as expected. Thanks for testing @glm35!

Regarding the get_tempo() function: I have a similar feeling as @glm35: It is too overengineered. A client app won't need this. The client app knows whether it has set an absolute tempo or a relative one. Splitting up the enum into a fluid_player_get_tempo_type and fluid_player_set_tempo_type doesn't really make this simpler. Thinking about it I would rather say to drop fluid_player_get_tempo() entirely, due to a missing use case at the present. Instead, the existing functions fluid_player_get_bpm() and fluid_player_get_midi_tempo() should be continued to use. Those functions obtain the tempo the player is using right now. This might be

  • the tempo given by the MIDI file multiplied by the relative factor, or
  • the absolute tempo dictated by the client app.

@jjceresa
Copy link
Collaborator Author

jjceresa commented Jan 5, 2021

Thinking about it I would rather say to drop fluid_player_get_tempo() entirely, due to a missing use case at the present. Instead, the existing functions fluid_player_get_bpm() and fluid_player_get_midi_tempo() should be continued to use. Those functions obtain the tempo the player is using right now.

Ok.

jjceresa added 5 commits January 5, 2021 02:48
present.
Instead, the existing functions fluid_player_get_bpm() and
fluid_player_get_midi_tempo() should be continued to use. Those functions
obtain the tempo the player is using right now.This might be
- the tempo given by the MIDI file multiplied by the relative factor, or
- the absolute tempo dictated by the client app.
@jjceresa
Copy link
Collaborator Author

jjceresa commented Jan 5, 2021

Now, the tempo multiplier factor set by fluid_player_set_tempo(..,FLUID_PLAYER_TEMPO_RELATIVE, multiplier) is only used when the player follow the internal tempo changes. So it seems that we should do the following changes:
1)pass this multiplier value in the tempo parameter when calling fluid_player_set_tempo(..,FLUID_PLAYER_TEMPO_INTERNAL, multiplier)
2)Get rid of FLUID_PLAYER_TEMPO_RELATIVE enum value.

These simplifications allows the caller to set the player in internal tempo mode and supplying the multiplier factor using only one API function call.
Opinions ?

@derselbst
Copy link
Member

Now, the tempo multiplier factor set by fluid_player_set_tempo(..,FLUID_PLAYER_TEMPO_RELATIVE, multiplier) is only used when the player follow the internal tempo changes. So it seems that we should do the following changes:

So, rather than ignoring the tempo parameter with FLUID_PLAYER_TEMPO_INTERNAL, we use it to pass the multiplier directly. Yes, that sounds good to me.

jjceresa and others added 3 commits January 6, 2021 23:46
  Rather than ignoring the tempo parameter with
  FLUID_PLAYER_TEMPO_INTERNAL, we use it to pass the multiplier directly
Copy link
Member

@derselbst derselbst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now. I'll wait for the CI and then squash it. Thanks!

@sonarcloud
Copy link

sonarcloud bot commented Jan 9, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@derselbst derselbst changed the title Fixes player tempo reset issues Fix MIDI player tempo reset issues Jan 10, 2021
@derselbst derselbst merged commit 2cada68 into master Jan 10, 2021
@derselbst derselbst deleted the fix-player-tempo branch January 10, 2021 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants