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

add Mix_SetMusicBeat and Mix_GetMusicBeat #481

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

connorjclark
Copy link
Contributor

I have a use case where I must set the position of MIDI music to a particular beat index (something supported by the old allegro 4 midi player, and perhaps other midi players).

Example MIDI: https://drive.google.com/file/d/1qiE7sVyvQoVRxJftKhz-n4juuArfwri8/view?usp=share_link

And positions of tunes within:

0:    Wind Fish
81:   Overworld
233:  Hyrule Castle
553:  Lost Woods
814:  Great Sea
985:  East Hyrule
1153: Dancing Dragon
1333: Stone Tower
1556: Villages
1801: Swamp + Desert
2069: Outset Island
2189: Kakariko Village
2569: Clock Town
2753: Temple
2856: Dark World
3042: Dragon Roost
3125: Horse Race
3217: Credits
3296: Zelda's Lullaby

Note: I'm not certain if there's an off-by-one error in this code, or in the source midi player these positions are defined to work in (allegro 4), but I found I need to take the beat values above and subtract one to get the exact right positioning.

You can use the playmus example program to seek to a specific tune (you'll need a timidity.cfg and soundfont within your build directory, as always):

./playmus -n 552 TheTravelsOfLink.mid

Draft until some feedback (then I'll update the other music interfaces with NULL stubs).

@connorjclark connorjclark marked this pull request as draft December 24, 2022 02:19
reset_voices(song);
while (song->current_event->beat < beat)
{
switch(song->current_event->type)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exact same contents in this switch statement as the other seek_foward function. I could split out to a help function.

@sezero sezero requested review from icculus and slouken January 6, 2023 14:58
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.

1 participant