Created
September 4, 2024 05:06
-
-
Save dmitriykovalev/5d1b4825d04cb344a6f4dda0c2092ce3 to your computer and use it in GitHub Desktop.
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
| import math | |
| def print_audio_frames(num_samples, freq_hz, sample_rate_hz, num_channels): | |
| for i in range(num_samples): | |
| a = math.sin(2 * math.pi * freq_hz * i / sample_rate_hz) | |
| print(f'{i // num_channels:4d} => ', end='') | |
| for j in range(num_channels): | |
| value = ((1 << (15 - j)) - 1) * a; | |
| print(f'{int(value):6d}', end='') | |
| print() | |
| print_audio_frames(10, freq_hz=250, sample_rate_hz=48000, num_channels=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment