Last active
September 7, 2021 06:59
-
-
Save JosephTLyons/f75e6e59813c1d300f5221cc4098f695 to your computer and use it in GitHub Desktop.
A little program to emulate signal chain processing
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 | |
| import random | |
| import time | |
| SIGNAL_CHAIN = [ | |
| lambda sample: sample + 1, | |
| lambda sample: sample / 2, | |
| lambda sample: math.tan(sample), | |
| lambda sample: abs(sample), | |
| lambda sample: round(sample, 1), | |
| ] | |
| def process(sample): | |
| processed_sample = sample | |
| for processor in SIGNAL_CHAIN: | |
| processed_sample = processor(processed_sample) | |
| return processed_sample | |
| def main(): | |
| sample_number = 1 | |
| while True: | |
| padding_sample_number_string = str(sample_number).rjust(10, "0") | |
| sample_number += 1 | |
| sample = random.uniform(0, 15) | |
| processed_sample = process(sample) | |
| print(f"{padding_sample_number_string}: {processed_sample}") | |
| time.sleep(0.1) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment