Last active
November 10, 2023 21:09
-
-
Save theoknock/3cdf7785a498865ba4295624ec4aff10 to your computer and use it in GitHub Desktop.
Used for audio processing or synthesis algorithms, where the normalized time is used to apply effects or transformations to an audio signal based on its position in time. Values returned: 0 to 1 from 0 to the number of points/samples/frames/etc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AVAudioFrameCount frame_count = ...; | |
typedef simd_double1 * normalized_time_ref[frame_count]; | |
typeof(normalized_time_ref) normalized_time; | |
__block simd_double1 * normalized_time_ptr = &normalized_time; | |
AVAudioFrameCount frame = 0; | |
AVAudioFrameCount * frame_t = &frame; | |
const simd_double1 frame_index_offset = frame_count - 1.f; | |
for (*frame_t = 0; *frame_t < frame_count; *frame_t += 1) { | |
simd_double1 time = ((*frame_t - 1.f) / (frame_index_offset - 1.f)); | |
*(normalized_time_ptr + *frame_t) = time; | |
} | |
for (*frame_t = *frame_t - 1; *frame_t > 0; *frame_t -= 1) { | |
simd_double1 time = *(normalized_time_ptr + *frame_t); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment