It would use similar logic to Crayon's transition API's fade calculations (I think I'll separate the fade logic from the transition logic so it can be used in many places).
In the current version of the Audio API all that would change is:
- The source struct would get a new variable
current_volume which replaces the purpose of the existing volume var
- The old
volume var would become set_volume we transition from/to when fading
- A new function that advances the "fade" by "1 frame" and then updates the source's sound to be
set_volume * fraction = current_volume. Eg. Fade takes 1 second (seconds/htz = num_frames), we have a current_frame (f) so the fraction = f/num_frames or 1 - f/num_frames for going the other way
However, at a later date I want to change this so the play/pause/unpause/stop functions I have automatically handle the fading in/out if the user requests it (With an option passed in). However that would require a separate thread which means I'd probably want to combine it with the streamer thread and also I'd need to detect when a new frame happens so I'd update it at the right time. Thats too complicated for now and I can just handle it manually.
It would use similar logic to Crayon's transition API's fade calculations (I think I'll separate the fade logic from the transition logic so it can be used in many places).
In the current version of the Audio API all that would change is:
current_volumewhich replaces the purpose of the existingvolumevarvolumevar would becomeset_volumewe transition from/to when fadingset_volume * fraction = current_volume. Eg. Fade takes 1 second (seconds/htz = num_frames), we have acurrent_frame(f) so thefraction = f/num_framesor1 - f/num_framesfor going the other wayHowever, at a later date I want to change this so the play/pause/unpause/stop functions I have automatically handle the fading in/out if the user requests it (With an option passed in). However that would require a separate thread which means I'd probably want to combine it with the streamer thread and also I'd need to detect when a new frame happens so I'd update it at the right time. Thats too complicated for now and I can just handle it manually.