kyzfrintin / Godot-Mixing-Desk

A complete audio solution for Godot 3.3.x, making procedural sound and adaptive/procedural music possible with a few nodes and a couple lines of code.
MIT License
636 stars 32 forks source link

Beat progress variable #20

Open Vertiverti opened 3 years ago

Vertiverti commented 3 years ago

Telegraphing events before they happen or having windup animations for events that synchronise to the beat of the music is a common enough scenario. It's not feasible to have a signal like beat for this (because the amount of leeway you need can vary), but a beat progress variable could be useful for this.

Admittedly, I've not looked into the code for too long, but I couldn't find anything like it. It's just a couple lines of code at the end of _process to add it, though.

beat_progress = ((time/beat_length_ms) * 1000.0) beat_progress = beat_progress - int(floor(beat_progress)) returns beat_progress between 0.0 and 1.0

& then any nodes which use it would compare beat_progress & current beat to decide when to do whatever logic they need to.

I'm not aware of any other way to do this using GMD - if there is a better way, I'd love to hear it. But if not, I think this change would be really useful (:

kyzfrintin commented 3 years ago

@Vertiverti I see no reason not to include something like this, so I'll bundle it with the next update, which should be coming in the next week or so. Thanks for bringing this up :)