From 8c876a019e1b9ad539b0c18a319b56aadfede5c4 Mon Sep 17 00:00:00 2001 From: Minki Avali Date: Fri, 5 Jan 2024 21:06:15 +0100 Subject: [PATCH] Fixed incorrect escape in banner print code --- __pycache__/offitracker.cpython-312.pyc | Bin 0 -> 6324 bytes offitracker.py | 10 +- offitracker.py~ | 124 ++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 5 deletions(-) create mode 100644 __pycache__/offitracker.cpython-312.pyc create mode 100644 offitracker.py~ diff --git a/__pycache__/offitracker.cpython-312.pyc b/__pycache__/offitracker.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..92f272b7e648b2ed4b5963c3f85b9cff67be92b2 GIT binary patch literal 6324 zcmbVQYit|WmA=CnlEarIilj|FVvU~?8(XwuWi3Bb*|Lz>l@eQZP${$tnlqFrQzShz z)Popqoo#;5ST8JNfm%jVgh3Zry4E6EpulRe{b46**4zFeO*vL3`jMhup#G=Y1-x

^VaYNo!r8*emhgd+t5=+;d;&J7<3Da99bX-J=V_PhEuk9tk}eE0w2dijW(GCp;A+ zW95<>qcqwuMr$QAX4Fd4n29%p%uy0zdHMq~X5ksgt-KL(8^4J+e?X1d`OQ2Fr9)`o zEf>285&ywJght+a8|J}85skKOpzRxI#|FA#1KqfRZrVUQH_**5&`koF+*a17KG%78 z)5QVM{4a3vrWP19)*NSHB`)5jj~Z*{sWCVFJkahCngzGuS#;l~%QIBg?a{d@GDpo( zKJR1f9v%!E%4}M0h8%}I9Vj0Tl`+WG?#X)2O6#P4oK-GDcmq!>b|N?FvUd=%En|}53YQaaQfOG0SuuS`e#YqY zpah;|On+;dtCTa;OhuZH9Ud=_{q_yj$cw2dNoBA|Gu`s6tWsin%L!3Th+HfY;-m3# zE}n==0>_8s5El^>Q(W3`kn>qpLjndSL-K^mOeUgnl}RLpxN3+eRbxmLLvt!4Oow7B zD+(b#7L5z4<-}}QNXpSfTs0=eXk7N0RjVdED9vx7Qhy(Y@wy&iixwN{-HTVzBh&d)Hdp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5nUXgVR+cL z31XZ%NgM?l!iv;Xa;_Xb*`!1&&hx@_G%SecaR`2nC|hd`2(@oFW#~ZnL9^hREySyi zfDsIq?K{E-1Z?8?G{h?vFf4z+Ge+YOJk_)o@zYcJ`v(Tb&)LIM2|g7Qj*7EDf^{X* z?;%^KDT?}rShfG=Z;1CBVp+G7M)zggw=PeCG(BOgl>3R7ruv>(DeASSCNK5s(_SA1 z5B*(=F!pTvKHc&)W65s+;3O0U>!B6quvQseVa8sp1Xh@HTFZMYOyI>zmAQX~Irg>L zn%#G;?@HfKGV_=2o4u>vwvXAHY|eSpcE#~K?<<8Z`%2#4tOIPD({uT))kfFlH-E=C a=lA3fEYCh*-qb{M516g%KEkwWoAAFQ>#+&| literal 0 HcmV?d00001 diff --git a/offitracker.py b/offitracker.py index b32f3ea..603c24d 100644 --- a/offitracker.py +++ b/offitracker.py @@ -105,11 +105,11 @@ if __name__ == "__main__": print(' ') print(' Mueller\'s Software Domain proudly presents:') print('________ _____ _____._____________ __ ') - print('\_____ \_/ ____\/ ____\__\__ ___/___________ ____ | | __ ___________ ') - print(' / | \ __\\\\ __\| | | | \_ __ \__ \ _/ ___\| |/ // __ \_ __ \\') - print('/ | \ | | | | | | | | | \// __ \\\\ \___| <\ ___/| | \/') - print('\_______ /__| |__| |__| |____| |__| (____ /\___ >__|_ \\\\___ >__| ') - print(' \/ \/ \/ \/ \/ ') + print('\\_____ \\_/ ____\\/ ____\\__\\__ ___/___________ ____ | | __ ___________ ') + print(' / | \\ __\\ | __\\| | | | \\_ __ \\__ \\ _/ ___\\| |/ // __ \\_ __ \\') + print('/ | \\ | | | | | | | | | \\// __ \\\\ \\___| <\\ ___/| | \\/') + print('\\_______ /__| |__| |__| |____| |__| (____ /\\___ >__|_ \\\\___ >__| ') + print(' \\/ \\/ \\/ \\/ \\/ ') print(' Version 1.4') if len(sys.argv) > 1: csv_file_path = sys.argv[1] diff --git a/offitracker.py~ b/offitracker.py~ new file mode 100644 index 0000000..b32f3ea --- /dev/null +++ b/offitracker.py~ @@ -0,0 +1,124 @@ +import sys +import csv +import numpy as np +import sounddevice as sd +import os + +# OffiTracker, the tracker that no one asked for but I made it anyways :3 +# This has started off as a silly little joke program, I never thought it would turn into such a complex little beast of a python project. +# (c) 2024 mueller_minki, Feel free to modify or share. + +stop_signal = False + +noise_data_cache = {} # Cache to store loaded noise data + +def load_noise_data(noise_type, sample_rate): + amplitude_factor = 0.5 # Adjust the amplitude factor as needed + noise_file_path = os.path.join('drums', f'drum{noise_type}.txt') + + try: + with open(noise_file_path, 'r') as file: + noise_data = np.array(eval(file.readline())) + return amplitude_factor * noise_data + except Exception as e: + print(f"Error loading noise data from {noise_file_path}: {e}") + return None + +def load_all_noise_data(): + global noise_data_cache + for i in range(1, 6): + noise_data_cache[i] = load_noise_data(i, 44100) + +def generate_noise(noise_type): + return noise_data_cache.get(noise_type, None) + +def play_square_waves(output_stream, frequencies, effects, duration, amplitude=1, noise_amplitude=0, sample_rate=44100): + global stop_signal + if stop_signal: + output_stream.stop() + else: + num_waves = len(frequencies) + t = np.linspace(0, duration / 1000, int(sample_rate * duration / 1000), endpoint=False) + + # Generate and sum square waves for each frequency with corresponding effects + waves = [amplitude * (effect / 100) * np.sign(np.sin(2 * np.pi * freq * t)) for freq, effect in zip(frequencies, effects)] + + # Add optional noise channel based on the noise column values + if noise_amplitude > 0: + noise_type = int(noise_amplitude) + noise = generate_noise(noise_type) + + if noise is not None: + # Pad the noise with zeros to match the duration of the other waves + noise = np.concatenate((noise, np.zeros(len(t) - len(noise)))) + waves.append(noise) + + combined_wave = np.sum(waves, axis=0) + combined_wave = combined_wave.astype(np.float32) + + output_stream.write(combined_wave) + +def play_csv_file(file_path, start_row=None, stop_row=None): + global stop_signal + global noise_data_cache + if 'playback_row_index' in locals(): + global playback_row_index + + # Load all noise data into the cache + load_all_noise_data() + + with open(file_path, 'r') as csv_file: + csv_reader = csv.DictReader(csv_file) + header = csv_reader.fieldnames + num_columns = len(header) + num_pairs = (num_columns - 1) // 2 + total_rows = sum(1 for _ in csv_reader) # Count the total number of rows + + # Reset the file pointer to the beginning + csv_file.seek(0) + next(csv_reader) # Skip the header + + with sd.OutputStream(channels=1) as output_stream: + for idx, row in enumerate(csv_reader): + if start_row is not None and idx < start_row: + continue + if stop_row is not None and idx > stop_row: + break + + frequencies = [float(row[f'Frequency{i}']) for i in range(1, num_pairs + 1)] + effects = [float(row[f'Effect{i}']) for i in range(1, num_pairs + 1)] + duration = float(row['Duration']) + + # Check if 'Noise' column exists in the CSV file + noise_amplitude = float(row.get('Noise', 0)) + + # Update row info + if 'playback_row_index' in globals(): + playback_row_index = idx + else: + print(f"\rRow {idx + 1} of {total_rows}", end='', flush=True) + + if stop_signal == False: + play_square_waves(output_stream, frequencies, effects, duration, noise_amplitude=noise_amplitude) + +if __name__ == "__main__": + print(' ') + print(' Mueller\'s Software Domain proudly presents:') + print('________ _____ _____._____________ __ ') + print('\_____ \_/ ____\/ ____\__\__ ___/___________ ____ | | __ ___________ ') + print(' / | \ __\\\\ __\| | | | \_ __ \__ \ _/ ___\| |/ // __ \_ __ \\') + print('/ | \ | | | | | | | | | \// __ \\\\ \___| <\ ___/| | \/') + print('\_______ /__| |__| |__| |____| |__| (____ /\___ >__|_ \\\\___ >__| ') + print(' \/ \/ \/ \/ \/ ') + print(' Version 1.4') + if len(sys.argv) > 1: + csv_file_path = sys.argv[1] + else: + csv_file_path = input("Choose a CSV file: ") + + # These should not be set in player mode + start_row = None + stop_row = None + + play_csv_file(csv_file_path, start_row=start_row, stop_row=stop_row) + print("\nPlayback complete.")