From 2aaf9c657112ebae00c17a8c146cb07c6b324a4a Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Sat, 18 May 2024 14:31:23 +0530 Subject: [PATCH 01/20] Left customisation --- Audio_SpectraCLI.egg-info/PKG-INFO | 217 ++++++++++++++++++ Audio_SpectraCLI.egg-info/SOURCES.txt | 13 ++ .../dependency_links.txt | 1 + Audio_SpectraCLI.egg-info/requires.txt | 8 + Audio_SpectraCLI.egg-info/top_level.txt | 1 + .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 232 bytes .../__pycache__/main.cpython-311.pyc | Bin 0 -> 9432 bytes Audio_SpectraCLI/main-old.py | 62 +++++ Audio_SpectraCLI/main.py | 148 ++++++++---- tests/{main.py => test-old.py} | 0 tests/test.py | 12 + 11 files changed, 419 insertions(+), 43 deletions(-) create mode 100644 Audio_SpectraCLI.egg-info/PKG-INFO create mode 100644 Audio_SpectraCLI.egg-info/SOURCES.txt create mode 100644 Audio_SpectraCLI.egg-info/dependency_links.txt create mode 100644 Audio_SpectraCLI.egg-info/requires.txt create mode 100644 Audio_SpectraCLI.egg-info/top_level.txt create mode 100644 Audio_SpectraCLI/__pycache__/__init__.cpython-311.pyc create mode 100644 Audio_SpectraCLI/__pycache__/main.cpython-311.pyc create mode 100644 Audio_SpectraCLI/main-old.py rename tests/{main.py => test-old.py} (100%) create mode 100644 tests/test.py diff --git a/Audio_SpectraCLI.egg-info/PKG-INFO b/Audio_SpectraCLI.egg-info/PKG-INFO new file mode 100644 index 0000000..1ef8ef8 --- /dev/null +++ b/Audio_SpectraCLI.egg-info/PKG-INFO @@ -0,0 +1,217 @@ +Metadata-Version: 2.1 +Name: Audio_SpectraCLI +Version: 3.2 +Summary: AudioSpectraCLI is a command-line tool that provides real-time FFT visualization of audio spectra. It captures audio input from the microphone and displays the corresponding frequency spectrum directly in the terminal window, allowing users to monitor and analyze audio signals without the need for graphical interfaces. +Home-page: https://github.com/AdityaSeth777/Audio-SpectraCLI +Author: Aditya Seth +Author-email: contact@adityaseth.in +License: MIT +Description-Content-Type: text/markdown +License-File: LICENSE +Requires-Dist: numpy +Requires-Dist: matplotlib +Requires-Dist: sounddevice +Requires-Dist: tabulate +Requires-Dist: setuptools +Requires-Dist: twine +Requires-Dist: wheel +Requires-Dist: pyaudio + +``` + _ _ _ ____ _ ____ _ ___ + / \ _ _ __| (_) ___ / ___| _ __ ___ ___| |_ _ __ __ _ / ___| | |_ _| + / _ \| | | |/ _` | |/ _ \ ____\___ \| '_ \ / _ \/ __| __| '__/ _` | | | | | | + / ___ \ |_| | (_| | | (_) |_____|__) | |_) | __/ (__| |_| | | (_| | |___| |___ | | +/_/ \_\__,_|\__,_|_|\___/ |____/| .__/ \___|\___|\__|_| \__,_|\____|_____|___| + |_| +``` + +Audio Spectrum Visualization is a Python project that visualizes real-time audio input as a spectrum using Fast Fourier Transform (FFT). It provides an interactive CLI interface for users to start the visualization and exit the program. + +## Current Features (with respect to 3.2) + +- Real-time visualization of Fast Fourier Transform (FFT) spectrum of audio input. +- Support for adjusting parameters such as duration, sampling rate, and block size. +- Seamless integration with SoundDevice for audio input capture. +- Customizable Frequency Range: Allow users to specify the frequency range to display in the spectrum. +- Color Customization: Provide options for users to customize the colors used in the spectrum visualization. + +## Packaging + +``` +Audio-SpectraCLI/ + +│ CODE_OF_CONDUCT.md +│ Contributing.md +│ Dockerfile +│ LICENSE +│ Readme.md +│ requirements.txt +│ setup.cfg +│ setup.py +│ +├───.github +│ └───workflows +│ python-publish.yml +│ +├───Audio_SpectraCLI +│ main.py +│ __init__.py +│ +└───tests + main.py +``` + +## Installation & Usage (Using PIP) + +1. Install using pip + +``` +pip install Audio-SpectraCLI +``` + +2. Import and use modules + +- Create a Python file. +- You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/main.py) as a reference or use the following code : + +``` +from Audio_SpectraCLI import AudioSpectrumVisualizer + +# Creating an instance of AudioSpectrumVisualizer with custom parameters. +audio_visualizer = AudioSpectrumVisualizer( + duration=5, frequency_range=(50, 5000), color='red') + +# Starting the audio spectrum visualization +audio_visualizer.start_visualization() +``` + +Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. + +--- + +## Examining & Usage for fun :D (Using Docker) + +1. Prerequisites + You should have docker installed on your machine. You can download and install Docker from [here](https://www.docker.com/products/docker-desktop). +2. Pulling the Docker Image + +You can pull the pre-built Docker image from Docker Hub using the following command: + +```sh +docker pull adityaseth777/audio-spectracli +``` + +3. Viewing Files Inside the Docker Container + For seeing the files inside the Docker container for debugging purposes, you can run an interactive shell session: + +```sh +docker run --rm -it --entrypoint /bin/bash audio-spectracli +``` + +4. Use the 'ls' command to view the files and get a proper understanding of the file structure : + +```sh +ls +``` + +5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/main.py) as a reference or use the following code : + +``` +from Audio_SpectraCLI import AudioSpectrumVisualizer + +# Creating an instance of AudioSpectrumVisualizer with custom parameters. +audio_visualizer = AudioSpectrumVisualizer( + duration=5, frequency_range=(50, 5000), color='red') + +# Starting the audio spectrum visualization +audio_visualizer.start_visualization() +``` + +Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. + +--- + +## Building the Docker Image Locally (for fun :D) + +If you prefer to build the Docker image locally, follow these steps: + +1. Clone the repository : + +```sh +git clone https://github.com/AdityaSeth777/Audio-SpectraCLI.git +cd Audio-SpectraCLI +``` + +2. Build the Docker image: + +```sh +docker build -t audio-spectracli . +``` + +3. Viewing Files Inside the Docker Container + For seeing the files inside the Docker container for debugging purposes, you can run an interactive shell session: + +```sh +docker run --rm -it --entrypoint /bin/bash audio-spectracli +``` + +4. Use the 'ls' command to view the files and get a proper understanding of the file structure : + +```sh +ls +``` + +5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/main.py) as a reference or use the following code : + +``` +from Audio_SpectraCLI import AudioSpectrumVisualizer + +# Creating an instance of AudioSpectrumVisualizer with custom parameters. +audio_visualizer = AudioSpectrumVisualizer( + duration=5, frequency_range=(50, 5000), color='red') + +# Starting the audio spectrum visualization +audio_visualizer.start_visualization() +``` + +Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. + +## Upcoming Features + +- CLI endpoints. +- Option to choose between CLI/GUI. +- Save and Export: Implement functionality to save the generated spectrum as an image file or export data for further analysis. +- Additional Audio Effects: Integrate additional audio effects or processing options to enhance the visualization. + +--- + +## For contributing + +Check the [Contributing page.](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/Contributing.md) +Make sure to PR your changes in the development branch. + +## .env file + +This file contains various environment variables that you can configure. + +## License + +[MIT © Aditya Seth](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/LICENSE) + +## What next? + +I will be improving this project. + +## Where to contact ? + +Contact: [contact@adityaseth.in] + +## 🙋‍♂️ Support + +💙 If you like this project, give it a ⭐ and share it with friends!`

` +[☕ Buy me a coffee](https://www.buymeacoffee.com/adityaseth) + +--- + +Made with ❤️ diff --git a/Audio_SpectraCLI.egg-info/SOURCES.txt b/Audio_SpectraCLI.egg-info/SOURCES.txt new file mode 100644 index 0000000..0f40500 --- /dev/null +++ b/Audio_SpectraCLI.egg-info/SOURCES.txt @@ -0,0 +1,13 @@ +LICENSE +setup.cfg +setup.py +Audio_SpectraCLI/__init__.py +Audio_SpectraCLI/main-n.py +Audio_SpectraCLI/main.py +Audio_SpectraCLI.egg-info/PKG-INFO +Audio_SpectraCLI.egg-info/SOURCES.txt +Audio_SpectraCLI.egg-info/dependency_links.txt +Audio_SpectraCLI.egg-info/requires.txt +Audio_SpectraCLI.egg-info/top_level.txt +tests/test-pyqt5.py +tests/test.py \ No newline at end of file diff --git a/Audio_SpectraCLI.egg-info/dependency_links.txt b/Audio_SpectraCLI.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Audio_SpectraCLI.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/Audio_SpectraCLI.egg-info/requires.txt b/Audio_SpectraCLI.egg-info/requires.txt new file mode 100644 index 0000000..6f8ef19 --- /dev/null +++ b/Audio_SpectraCLI.egg-info/requires.txt @@ -0,0 +1,8 @@ +numpy +matplotlib +sounddevice +tabulate +setuptools +twine +wheel +pyaudio diff --git a/Audio_SpectraCLI.egg-info/top_level.txt b/Audio_SpectraCLI.egg-info/top_level.txt new file mode 100644 index 0000000..62e5e68 --- /dev/null +++ b/Audio_SpectraCLI.egg-info/top_level.txt @@ -0,0 +1 @@ +Audio_SpectraCLI diff --git a/Audio_SpectraCLI/__pycache__/__init__.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5b6f6d85380975e3b8f263885379009259af0fa2 GIT binary patch literal 232 zcmZ3^%ge<81bLBcX*NLmF^B^LOi;#WAs}NqLkdF*V-7 zl2MuzlL*qMTMX8in4FUt12!lgVp5{Bk7rDLd}dx|NqoFsLFF$Fo80`A(wtPgA`YNA dAiIm@fy4)9Mn=XDYz&NA7Z@}#Q4t$Z4FCf@Jp2Fv literal 0 HcmV?d00001 diff --git a/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..df220220b584526920618a169a3c98c944cd7ea0 GIT binary patch literal 9432 zcmb_CU2haumet?4+ubzS#`xQ9u#MY*ZLmo)4&lSL2#DB&#{{x1GM#o;*|h1eR8~d`I#0|?>wGaEO-YPE>P-7Hfmk3@7puzzW5G-)7Rv03?aG8>;mq#XZVKy4 z@5$81>N5?o1_$Tl-sX7s9gg=1bx&Lz_YM3RA=W7D<-OOPSQ1Y;IU%sXJpr7)fj=X} znxMAv2^79DtGL)cVPC146)hQiKL;l?m0B##EL+=;cg(^b%yLoRI`)~4`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`T>~eXN4O~@ z<4-wbRp@Q{3prts!b$Ni6p{9&eGqTB91h1ukaILBT)pwFab1f2TjQD)^IPMBx9M+< z+pU=28kbW3_HT_lpltPRc;_7sINYt{hu43kE&pR}|CNh#2bYUwSBv6mSqn5RAHFZD zfmSWhdV69m)T4xY)KH%m>bre*%^mpc!lxHLnYuG|duq+?`|SLu=Rdh{=fZ9J+wgPl KRv3bA++P7VrFv-q literal 0 HcmV?d00001 diff --git a/Audio_SpectraCLI/main-old.py b/Audio_SpectraCLI/main-old.py new file mode 100644 index 0000000..12149c3 --- /dev/null +++ b/Audio_SpectraCLI/main-old.py @@ -0,0 +1,62 @@ +# Aditya Seth +# Description: This file contains the main code for the Audio-SpectraCLI project. It is responsible for creating the AudioSpectrumVisualizer class which is used to visualize the audio spectrum in real-time. + +import numpy as np +import matplotlib.pyplot as plt +import sounddevice as sd +import queue +import threading +import time + + +class AudioSpectrumVisualizer: + def __init__(self, duration=10, fs=44100, block_size=2048, frequency_range=(20, 20000), color='blue'): + self.duration = duration + self.fs = fs + self.block_size = block_size + self.num_blocks = int(duration * fs / block_size) + self.frequency_range = frequency_range + self.color = color + self.audio_queue = queue.Queue() + + def audio_callback(self, indata, frames, time, status): + if status: + print(status) + self.audio_queue.put(indata.copy()) + + def process_audio(self): + freq_bins = np.fft.fftfreq(self.block_size, 1/self.fs) + spectrum = np.zeros(self.block_size) + + plt.ion() + fig, ax = plt.subplots() + x = np.arange(0, self.block_size) + line, = ax.plot(freq_bins, spectrum, color=self.color) + ax.set_xlim(self.frequency_range) + ax.set_ylim(0, 0.1) + ax.set_xlabel('Frequency (Hz)') + ax.set_ylabel('Magnitude') + + while True: + audio_block = self.audio_queue.get() + spectrum = np.abs(np.fft.fft(audio_block[:, 0], n=self.block_size)) + max_magnitude = np.max(spectrum) + if max_magnitude > ax.get_ylim()[1]: + ax.set_ylim(0, max_magnitude * 1.1) + line.set_ydata(spectrum) + fig.canvas.draw() + fig.canvas.flush_events() + + def start_visualization(self): + audio_thread = threading.Thread(target=self.process_audio, daemon=True) + audio_thread.start() + + with sd.InputStream(callback=self.audio_callback, channels=1, samplerate=self.fs): + while True: + time.sleep(1) + + audio_thread.join() + + +# List of functions available for use: +__all__ = ['AudioSpectrumVisualizer'] diff --git a/Audio_SpectraCLI/main.py b/Audio_SpectraCLI/main.py index 12149c3..a48ea09 100644 --- a/Audio_SpectraCLI/main.py +++ b/Audio_SpectraCLI/main.py @@ -1,62 +1,124 @@ # Aditya Seth -# Description: This file contains the main code for the Audio-SpectraCLI project. It is responsible for creating the AudioSpectrumVisualizer class which is used to visualize the audio spectrum in real-time. +# Description: This file contains the main code for the Audio-SpectraCLI project. +# It is responsible for creating the AudioSpectrumVisualizer class which is used +# to visualize the audio spectrum in real-time. import numpy as np import matplotlib.pyplot as plt import sounddevice as sd import queue import threading -import time +from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QPushButton, QVBoxLayout, QWidget, QSlider +from PyQt5.QtCore import Qt, QTimer -class AudioSpectrumVisualizer: - def __init__(self, duration=10, fs=44100, block_size=2048, frequency_range=(20, 20000), color='blue'): - self.duration = duration - self.fs = fs - self.block_size = block_size - self.num_blocks = int(duration * fs / block_size) - self.frequency_range = frequency_range - self.color = color +class AudioSpectrumVisualizer(QMainWindow): + def __init__(self): + super().__init__() + self.setWindowTitle('Audio Spectrum Visualizer') + self.setGeometry(100, 100, 800, 600) + + self.duration = 5 # Default duration in seconds + self.fs = 44100 # Default sampling rate + self.block_size = 2048 # Default block size + self.frequency_range = (20, 20000) # Default frequency range + self.color = 'blue' # Default color + self.audio_queue = queue.Queue() + self.spectrum = np.zeros(self.block_size) + + self.setup_ui() + self.start_audio_capture() + + self.timer = QTimer() + self.timer.timeout.connect(self.process_audio) + self.timer.start(100) + + def setup_ui(self): + self.central_widget = QWidget() + self.setCentralWidget(self.central_widget) + + self.layout = QVBoxLayout() + + self.duration_slider = QSlider(Qt.Horizontal) + self.duration_slider.setMinimum(1) + self.duration_slider.setMaximum(10) + self.duration_slider.setValue(self.duration) + self.duration_slider.setTickInterval(1) + self.duration_slider.setTickPosition(QSlider.TicksBelow) + self.duration_slider.valueChanged.connect(self.set_duration) + self.layout.addWidget(QLabel('Duration (seconds):')) + self.layout.addWidget(self.duration_slider) + + self.fs_slider = QSlider(Qt.Horizontal) + self.fs_slider.setMinimum(22050) + self.fs_slider.setMaximum(44100) + self.fs_slider.setValue(self.fs) + self.fs_slider.setTickInterval(22050) + self.fs_slider.setTickPosition(QSlider.TicksBelow) + self.fs_slider.valueChanged.connect(self.set_sampling_rate) + self.layout.addWidget(QLabel('Sampling Rate (Hz):')) + self.layout.addWidget(self.fs_slider) - def audio_callback(self, indata, frames, time, status): - if status: - print(status) - self.audio_queue.put(indata.copy()) + self.block_size_slider = QSlider(Qt.Horizontal) + self.block_size_slider.setMinimum(256) + self.block_size_slider.setMaximum(4096) + self.block_size_slider.setValue(self.block_size) + self.block_size_slider.setTickInterval(512) + self.block_size_slider.setTickPosition(QSlider.TicksBelow) + self.block_size_slider.valueChanged.connect(self.set_block_size) + self.layout.addWidget(QLabel('Block Size:')) + self.layout.addWidget(self.block_size_slider) + + self.start_button = QPushButton('Start Visualization') + self.start_button.clicked.connect(self.start_visualization) + self.layout.addWidget(self.start_button) + + self.central_widget.setLayout(self.layout) + + def start_audio_capture(self): + def audio_callback(indata, frames, time, status): + if status: + print(status) + self.audio_queue.put(indata.copy()) + + self.stream = sd.InputStream(callback=audio_callback, channels=1, samplerate=self.fs) + self.stream.start() def process_audio(self): - freq_bins = np.fft.fftfreq(self.block_size, 1/self.fs) - spectrum = np.zeros(self.block_size) - - plt.ion() - fig, ax = plt.subplots() - x = np.arange(0, self.block_size) - line, = ax.plot(freq_bins, spectrum, color=self.color) - ax.set_xlim(self.frequency_range) - ax.set_ylim(0, 0.1) - ax.set_xlabel('Frequency (Hz)') - ax.set_ylabel('Magnitude') - - while True: + if not self.audio_queue.empty(): audio_block = self.audio_queue.get() - spectrum = np.abs(np.fft.fft(audio_block[:, 0], n=self.block_size)) - max_magnitude = np.max(spectrum) - if max_magnitude > ax.get_ylim()[1]: - ax.set_ylim(0, max_magnitude * 1.1) - line.set_ydata(spectrum) - fig.canvas.draw() - fig.canvas.flush_events() + self.spectrum = np.abs(np.fft.fft(audio_block[:, 0], n=self.block_size)) + self.update_plot() - def start_visualization(self): - audio_thread = threading.Thread(target=self.process_audio, daemon=True) - audio_thread.start() + def update_plot(self): + freq_bins = np.fft.fftfreq(self.block_size, 1 / self.fs) + max_magnitude = np.max(self.spectrum) + plt.clf() + plt.plot(freq_bins[:self.block_size // 2], self.spectrum[:self.block_size // 2], color=self.color) + plt.xlim(self.frequency_range) + plt.ylim(0, max_magnitude * 1.1) + plt.xlabel('Frequency (Hz)') + plt.ylabel('Magnitude') + plt.title('Audio Spectrum Visualization') + plt.pause(0.001) + + def set_duration(self, value): + self.duration = value - with sd.InputStream(callback=self.audio_callback, channels=1, samplerate=self.fs): - while True: - time.sleep(1) + def set_sampling_rate(self, value): + self.fs = value - audio_thread.join() + def set_block_size(self, value): + self.block_size = value + self.spectrum = np.zeros(self.block_size) # Reset spectrum array size + + def start_visualization(self): + self.timer.start(100) -# List of functions available for use: -__all__ = ['AudioSpectrumVisualizer'] +if __name__ == '__main__': + app = QApplication([]) + window = AudioSpectrumVisualizer() + window.show() + app.exec_() diff --git a/tests/main.py b/tests/test-old.py similarity index 100% rename from tests/main.py rename to tests/test-old.py diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..194a93e --- /dev/null +++ b/tests/test.py @@ -0,0 +1,12 @@ +from Audio_SpectraCLI import AudioSpectrumVisualizer +from PyQt5.QtWidgets import QApplication + +# Create an instance of AudioSpectrumVisualizer with custom parameters +app = QApplication([]) +audio_visualizer = AudioSpectrumVisualizer( + duration=5, fs=22050, block_size=1024, frequency_range=(50, 5000), color='red') + +# Start the audio spectrum visualization +audio_visualizer.show() +audio_visualizer.start_visualization() +app.exec_() From 3ce3c313e83d5b9b509df3133255dc06fa152a7f Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Sat, 18 May 2024 14:38:37 +0530 Subject: [PATCH 02/20] still jittering --- Audio_SpectraCLI.egg-info/SOURCES.txt | 4 +- .../__pycache__/main.cpython-311.pyc | Bin 9432 -> 9909 bytes Audio_SpectraCLI/main.py | 72 +++++++++--------- requirements.txt | 3 +- 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/Audio_SpectraCLI.egg-info/SOURCES.txt b/Audio_SpectraCLI.egg-info/SOURCES.txt index 0f40500..7a899eb 100644 --- a/Audio_SpectraCLI.egg-info/SOURCES.txt +++ b/Audio_SpectraCLI.egg-info/SOURCES.txt @@ -2,12 +2,12 @@ LICENSE setup.cfg setup.py Audio_SpectraCLI/__init__.py -Audio_SpectraCLI/main-n.py +Audio_SpectraCLI/main-old.py Audio_SpectraCLI/main.py Audio_SpectraCLI.egg-info/PKG-INFO Audio_SpectraCLI.egg-info/SOURCES.txt Audio_SpectraCLI.egg-info/dependency_links.txt Audio_SpectraCLI.egg-info/requires.txt Audio_SpectraCLI.egg-info/top_level.txt -tests/test-pyqt5.py +tests/test-old.py tests/test.py \ No newline at end of file diff --git a/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc index df220220b584526920618a169a3c98c944cd7ea0..eee9ff69cf34766e59ff76090bd4d86e40d4aef6 100644 GIT binary patch literal 9909 zcmbt4TWs7$lAM>OH4lv*wyd{Cwq$v%haa-+Sb5o!HnEY|u-1l?opr#YhLl2i9!isA zTY`e~$KIV1c#++MZ=)=HxWU5C+DHO;f%~|R`@F;bk^=$~2p9;k@P`jLK!NvTv0qo! z9CAo`MsboJs@RXJ?&|L9>Z+pt7>`FdNH+`T7S6YE+@G;vr%)yHd;>C{b0R1DvRvB7 z-u_%59rRgsp>zYQ3#Y^I_Gd}1G2NJpq$9a#I+}~6W4U-bo@+`s+`GcOl!eMmMdickqN*~CtJ8&B z?+Po0qH2cc-jl^e2{V_ovMA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q zC_@0^oQ7eQgsuyqXH)sSBo{S%F_kOG5=4U(=QXw{YL0_>ufT^0bXmn@^ ziL<(~%2B}eDtmf0B4Xq}(VqFb33`!!n~pgK04!K$IbnDiy$JqkN9}=+@;CDLr_0BG zSUvuuvhP&IcdF_;1*O>mrTD7j5e_`WfeP-Z;*N6tr<>LgWN>!fz2)1%ysK{#FXamA ztj5vEj)D#vml`i>+{A>c1fi>RQ<`I@AcEz|f;^?JTBbP+8^&Q*CUpy=s}}Z?UH$>< zyD+bKflT`Y3`c(E@9DcSd9O=@YR}P1=vXy$Y;o_^(Hi-a z-`{KFgb4LPj^_=(Ey6VRz{ zK3PtttI13mXDc{c#aTcM32oKp-U{xk;=VHOGf2%#qoqBSwsjTUU&Z}p+)v5&a%<1- z3XWBAtc+tiW$E<_j#P1^j3cx!lv{=?c%+I)%6LR4EP-Ty75mHepR$46>fE&c5Lg7> zrw8RtqjYHednvfxHKf)K>Wvt9BP7&MrYzYQ_A$DUo>d`qW0WF*hPk`w+&G;p>$NPC zKa-^8EJp{@2!--#T=y1ji#8+k%m4*8O&$8K(1Huc0s}`eU`A8T#DdewoCOJo;6(TB zfT8995gkQ}uBpX{qbP__x+v(T;049^kip2{U;%i=C;(717@^nE$Nu1FxYYJVq~af` z`bU7|T7(B2nvVqR+h8bYNj3OeSD0kk78>on?3hAJ1{5)R7%Q|?D+d6qJ+${hi5_;S zlo|%GfZ#^kX{AR*+(lA7z4P?`rSwn`qoALH(-hGCQK+MpJrwK%pt)9W+i6LblS$a) zL7?i(y;oziAnn05f!G;vA6c=izw$Phf5U- zn)UrmUYvR#{=b|B$V=y>bn+%L^r2jD0!$bn+XW^X*#xI~=k&7tcTB0%a~xv-=j;FDVs!uxbx3?5Vk8 zWml}?>Z`i?7WUOF_REJZ9=b4kX>?( Date: Sat, 18 May 2024 14:44:38 +0530 Subject: [PATCH 03/20] File formatting and Readme left --- .../__pycache__/main.cpython-311.pyc | Bin 9909 -> 9909 bytes Audio_SpectraCLI/main.py | 6 +++--- tests/test.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc index eee9ff69cf34766e59ff76090bd4d86e40d4aef6..1db55ec63d22aadfdd2f2c7d83ded519695b15fb 100644 GIT binary patch delta 109 zcmdn$yVaL>IWI340}vP#c%)@)B$=vZ!<0!`RtPbX E0IrQC$N&HU delta 109 zcmdn$yVaL>IWI340}zzwd!%`8Be#U8&x2ygG E0F&b-UH||9 diff --git a/Audio_SpectraCLI/main.py b/Audio_SpectraCLI/main.py index b9b0d40..353b6e6 100644 --- a/Audio_SpectraCLI/main.py +++ b/Audio_SpectraCLI/main.py @@ -14,7 +14,7 @@ class AudioSpectrumVisualizer(QMainWindow): - def __init__(self, duration=10, fs=44100, block_size=2048, frequency_range=(20, 20000), color='blue'): + def __init__(self, duration=10, fs=44100, block_size=4096, frequency_range=(20, 20000), color='blue'): super().__init__() self.setWindowTitle('Audio Spectrum Visualizer') self.setGeometry(100, 100, 800, 600) @@ -64,7 +64,7 @@ def setup_ui(self): self.block_size_slider = QSlider(Qt.Horizontal) self.block_size_slider.setMinimum(256) - self.block_size_slider.setMaximum(4096) + self.block_size_slider.setMaximum(8192) self.block_size_slider.setValue(self.block_size) self.block_size_slider.setTickInterval(512) self.block_size_slider.setTickPosition(QSlider.TicksBelow) @@ -116,7 +116,7 @@ def start_visualization(self): sd.default.channels = 1 self.stream = sd.InputStream(callback=self.audio_callback) self.stream.start() - self.timer.start(100) + self.timer.start(30) # Update every 30 milliseconds def closeEvent(self, event): self.timer.stop() diff --git a/tests/test.py b/tests/test.py index 194a93e..c492137 100644 --- a/tests/test.py +++ b/tests/test.py @@ -4,7 +4,7 @@ # Create an instance of AudioSpectrumVisualizer with custom parameters app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( - duration=5, fs=22050, block_size=1024, frequency_range=(50, 5000), color='red') + duration=5, fs=22050, block_size=4096, frequency_range=(50, 2000), color='blue') # Start the audio spectrum visualization audio_visualizer.show() From 18455bef6cc9f351184fd8b8fddd08d4ee3b726d Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Sat, 18 May 2024 14:58:45 +0530 Subject: [PATCH 04/20] hit a few setbacks --- .../__pycache__/main.cpython-311.pyc | Bin 9909 -> 10130 bytes Audio_SpectraCLI/main.py | 3 +++ tests/test.py | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc index 1db55ec63d22aadfdd2f2c7d83ded519695b15fb..aaae64af6c29e9cbfe9763334896ac1d3e9dfa26 100644 GIT binary patch delta 941 zcmZ`$PiWIn7=JHK)2vC>wfmE<>%VQ?X0dKVm`oAIK+&OFhZ_!}ShA(gb;(+i>>`s5 z+(8kM`3?%Ac(DqbqEtb|g9i`dsgr^;pchZ`w4n%s2j5HA&VznQe((4F-tT?yYtO68Dt^;DECa=r=JE~zR`FL3sabJNLn)xZ zF%V}ri8%7?{Yx793YVSR9E_uRZ$FF`o_HV7@Kj;ENu=OJLG`N+D5Fm;kC{n);$l1M zjrjTboFbd)R8GyB=L%1Q`yd=cUqVTkLEYgYVGJANP!HinH_&o;0BY#%t{yJyfyiN) zLlcp%qcj#so8M1E0B!*jVBDQAai54_AX z%#H|Bt_o8e|8cMthsjkK0GXN!$E{Q=uhDtj;_7aj9+0XY!bT27+Ik!y!{arKlB^F6 zc$_Dhk?}ZXF{Z3fr%j7dU;5y3hgAN>31tm* zjF!Z%M`o#K@LjAZCfCJeNlaehH`s=cY~TYMSZ9MJHdthXg@dhwu-^W?PWu*%Hq2~J zUq;v4&cX%stt}rTo!IT^lY|WsI6+{Tz$k%h=y`iL^rElrcRem=XbV)qhi=3Yum!!2 z9pV;=wUxjE`W<`azJng^mnl7&#*0{_O_v)lI0kH7a7 R2jDx3?v5oFdGsD!{tuvr&g%dG delta 641 zcmbQ_ztxv_IWI340}vP#c%)@a+!Oh*QAGsMij-W8mf(F>xlwu+1eBIn0bnlOIa2WlWyjFQdU2 zyLpFe}rz_ zNoq23PTnOcH#wVKfD;rv!3>%#ev|(zh%<6cHd8cHiUDf8#a3KWl$w}(i?z5Uv8bd- z11MG$1SEXkggPs^rKh4E8iDSm`a6;*$J=qK3(l$}xtyk2E4KP#*32L?F7H#tF7W^%cz0Hf68 z4pl3*YLIfp$!Aq}aZLv@L2fF3J9(m-{p3e#dXwL)u}v0Gw{yv5WEB6vfSsI?{Shql X1zA3UnSn?30+(t7I|vr(1C0d$`~{4P diff --git a/Audio_SpectraCLI/main.py b/Audio_SpectraCLI/main.py index 353b6e6..0bb6146 100644 --- a/Audio_SpectraCLI/main.py +++ b/Audio_SpectraCLI/main.py @@ -7,6 +7,7 @@ import matplotlib.pyplot as plt import sounddevice as sd import queue +import threading from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QPushButton, QVBoxLayout, QWidget, QSlider from PyQt5.QtCore import Qt, QTimer from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas @@ -112,6 +113,8 @@ def set_block_size(self, value): self.block_size = value def start_visualization(self): + audio_thread = threading.Thread(target=self.process_audio, daemon=True) + audio_thread.start() sd.default.samplerate = self.fs sd.default.channels = 1 self.stream = sd.InputStream(callback=self.audio_callback) diff --git a/tests/test.py b/tests/test.py index c492137..e1b8980 100644 --- a/tests/test.py +++ b/tests/test.py @@ -4,7 +4,7 @@ # Create an instance of AudioSpectrumVisualizer with custom parameters app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( - duration=5, fs=22050, block_size=4096, frequency_range=(50, 2000), color='blue') + duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') # Start the audio spectrum visualization audio_visualizer.show() From 81dbcac219f5f8f3f5a45f8c45477515ddba2374 Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Sat, 18 May 2024 17:08:38 +0530 Subject: [PATCH 05/20] Code done. Readme file is left, and version numbers. --- Audio_SpectraCLI.egg-info/PKG-INFO | 217 ------------------ Audio_SpectraCLI.egg-info/SOURCES.txt | 13 -- .../dependency_links.txt | 1 - Audio_SpectraCLI.egg-info/requires.txt | 8 - Audio_SpectraCLI.egg-info/top_level.txt | 1 - .../__pycache__/__init__.cpython-311.pyc | Bin 232 -> 0 bytes .../__pycache__/main.cpython-311.pyc | Bin 10130 -> 0 bytes Audio_SpectraCLI/main.py | 31 ++- 8 files changed, 14 insertions(+), 257 deletions(-) delete mode 100644 Audio_SpectraCLI.egg-info/PKG-INFO delete mode 100644 Audio_SpectraCLI.egg-info/SOURCES.txt delete mode 100644 Audio_SpectraCLI.egg-info/dependency_links.txt delete mode 100644 Audio_SpectraCLI.egg-info/requires.txt delete mode 100644 Audio_SpectraCLI.egg-info/top_level.txt delete mode 100644 Audio_SpectraCLI/__pycache__/__init__.cpython-311.pyc delete mode 100644 Audio_SpectraCLI/__pycache__/main.cpython-311.pyc diff --git a/Audio_SpectraCLI.egg-info/PKG-INFO b/Audio_SpectraCLI.egg-info/PKG-INFO deleted file mode 100644 index 1ef8ef8..0000000 --- a/Audio_SpectraCLI.egg-info/PKG-INFO +++ /dev/null @@ -1,217 +0,0 @@ -Metadata-Version: 2.1 -Name: Audio_SpectraCLI -Version: 3.2 -Summary: AudioSpectraCLI is a command-line tool that provides real-time FFT visualization of audio spectra. It captures audio input from the microphone and displays the corresponding frequency spectrum directly in the terminal window, allowing users to monitor and analyze audio signals without the need for graphical interfaces. -Home-page: https://github.com/AdityaSeth777/Audio-SpectraCLI -Author: Aditya Seth -Author-email: contact@adityaseth.in -License: MIT -Description-Content-Type: text/markdown -License-File: LICENSE -Requires-Dist: numpy -Requires-Dist: matplotlib -Requires-Dist: sounddevice -Requires-Dist: tabulate -Requires-Dist: setuptools -Requires-Dist: twine -Requires-Dist: wheel -Requires-Dist: pyaudio - -``` - _ _ _ ____ _ ____ _ ___ - / \ _ _ __| (_) ___ / ___| _ __ ___ ___| |_ _ __ __ _ / ___| | |_ _| - / _ \| | | |/ _` | |/ _ \ ____\___ \| '_ \ / _ \/ __| __| '__/ _` | | | | | | - / ___ \ |_| | (_| | | (_) |_____|__) | |_) | __/ (__| |_| | | (_| | |___| |___ | | -/_/ \_\__,_|\__,_|_|\___/ |____/| .__/ \___|\___|\__|_| \__,_|\____|_____|___| - |_| -``` - -Audio Spectrum Visualization is a Python project that visualizes real-time audio input as a spectrum using Fast Fourier Transform (FFT). It provides an interactive CLI interface for users to start the visualization and exit the program. - -## Current Features (with respect to 3.2) - -- Real-time visualization of Fast Fourier Transform (FFT) spectrum of audio input. -- Support for adjusting parameters such as duration, sampling rate, and block size. -- Seamless integration with SoundDevice for audio input capture. -- Customizable Frequency Range: Allow users to specify the frequency range to display in the spectrum. -- Color Customization: Provide options for users to customize the colors used in the spectrum visualization. - -## Packaging - -``` -Audio-SpectraCLI/ - -│ CODE_OF_CONDUCT.md -│ Contributing.md -│ Dockerfile -│ LICENSE -│ Readme.md -│ requirements.txt -│ setup.cfg -│ setup.py -│ -├───.github -│ └───workflows -│ python-publish.yml -│ -├───Audio_SpectraCLI -│ main.py -│ __init__.py -│ -└───tests - main.py -``` - -## Installation & Usage (Using PIP) - -1. Install using pip - -``` -pip install Audio-SpectraCLI -``` - -2. Import and use modules - -- Create a Python file. -- You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/main.py) as a reference or use the following code : - -``` -from Audio_SpectraCLI import AudioSpectrumVisualizer - -# Creating an instance of AudioSpectrumVisualizer with custom parameters. -audio_visualizer = AudioSpectrumVisualizer( - duration=5, frequency_range=(50, 5000), color='red') - -# Starting the audio spectrum visualization -audio_visualizer.start_visualization() -``` - -Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. - ---- - -## Examining & Usage for fun :D (Using Docker) - -1. Prerequisites - You should have docker installed on your machine. You can download and install Docker from [here](https://www.docker.com/products/docker-desktop). -2. Pulling the Docker Image - -You can pull the pre-built Docker image from Docker Hub using the following command: - -```sh -docker pull adityaseth777/audio-spectracli -``` - -3. Viewing Files Inside the Docker Container - For seeing the files inside the Docker container for debugging purposes, you can run an interactive shell session: - -```sh -docker run --rm -it --entrypoint /bin/bash audio-spectracli -``` - -4. Use the 'ls' command to view the files and get a proper understanding of the file structure : - -```sh -ls -``` - -5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/main.py) as a reference or use the following code : - -``` -from Audio_SpectraCLI import AudioSpectrumVisualizer - -# Creating an instance of AudioSpectrumVisualizer with custom parameters. -audio_visualizer = AudioSpectrumVisualizer( - duration=5, frequency_range=(50, 5000), color='red') - -# Starting the audio spectrum visualization -audio_visualizer.start_visualization() -``` - -Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. - ---- - -## Building the Docker Image Locally (for fun :D) - -If you prefer to build the Docker image locally, follow these steps: - -1. Clone the repository : - -```sh -git clone https://github.com/AdityaSeth777/Audio-SpectraCLI.git -cd Audio-SpectraCLI -``` - -2. Build the Docker image: - -```sh -docker build -t audio-spectracli . -``` - -3. Viewing Files Inside the Docker Container - For seeing the files inside the Docker container for debugging purposes, you can run an interactive shell session: - -```sh -docker run --rm -it --entrypoint /bin/bash audio-spectracli -``` - -4. Use the 'ls' command to view the files and get a proper understanding of the file structure : - -```sh -ls -``` - -5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/main.py) as a reference or use the following code : - -``` -from Audio_SpectraCLI import AudioSpectrumVisualizer - -# Creating an instance of AudioSpectrumVisualizer with custom parameters. -audio_visualizer = AudioSpectrumVisualizer( - duration=5, frequency_range=(50, 5000), color='red') - -# Starting the audio spectrum visualization -audio_visualizer.start_visualization() -``` - -Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. - -## Upcoming Features - -- CLI endpoints. -- Option to choose between CLI/GUI. -- Save and Export: Implement functionality to save the generated spectrum as an image file or export data for further analysis. -- Additional Audio Effects: Integrate additional audio effects or processing options to enhance the visualization. - ---- - -## For contributing - -Check the [Contributing page.](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/Contributing.md) -Make sure to PR your changes in the development branch. - -## .env file - -This file contains various environment variables that you can configure. - -## License - -[MIT © Aditya Seth](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/LICENSE) - -## What next? - -I will be improving this project. - -## Where to contact ? - -Contact: [contact@adityaseth.in] - -## 🙋‍♂️ Support - -💙 If you like this project, give it a ⭐ and share it with friends!`

` -[☕ Buy me a coffee](https://www.buymeacoffee.com/adityaseth) - ---- - -Made with ❤️ diff --git a/Audio_SpectraCLI.egg-info/SOURCES.txt b/Audio_SpectraCLI.egg-info/SOURCES.txt deleted file mode 100644 index 7a899eb..0000000 --- a/Audio_SpectraCLI.egg-info/SOURCES.txt +++ /dev/null @@ -1,13 +0,0 @@ -LICENSE -setup.cfg -setup.py -Audio_SpectraCLI/__init__.py -Audio_SpectraCLI/main-old.py -Audio_SpectraCLI/main.py -Audio_SpectraCLI.egg-info/PKG-INFO -Audio_SpectraCLI.egg-info/SOURCES.txt -Audio_SpectraCLI.egg-info/dependency_links.txt -Audio_SpectraCLI.egg-info/requires.txt -Audio_SpectraCLI.egg-info/top_level.txt -tests/test-old.py -tests/test.py \ No newline at end of file diff --git a/Audio_SpectraCLI.egg-info/dependency_links.txt b/Audio_SpectraCLI.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/Audio_SpectraCLI.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Audio_SpectraCLI.egg-info/requires.txt b/Audio_SpectraCLI.egg-info/requires.txt deleted file mode 100644 index 6f8ef19..0000000 --- a/Audio_SpectraCLI.egg-info/requires.txt +++ /dev/null @@ -1,8 +0,0 @@ -numpy -matplotlib -sounddevice -tabulate -setuptools -twine -wheel -pyaudio diff --git a/Audio_SpectraCLI.egg-info/top_level.txt b/Audio_SpectraCLI.egg-info/top_level.txt deleted file mode 100644 index 62e5e68..0000000 --- a/Audio_SpectraCLI.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -Audio_SpectraCLI diff --git a/Audio_SpectraCLI/__pycache__/__init__.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/__init__.cpython-311.pyc deleted file mode 100644 index 5b6f6d85380975e3b8f263885379009259af0fa2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 232 zcmZ3^%ge<81bLBcX*NLmF^B^LOi;#WAs}NqLkdF*V-7 zl2MuzlL*qMTMX8in4FUt12!lgVp5{Bk7rDLd}dx|NqoFsLFF$Fo80`A(wtPgA`YNA dAiIm@fy4)9Mn=XDYz&NA7Z@}#Q4t$Z4FCf@Jp2Fv diff --git a/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc deleted file mode 100644 index aaae64af6c29e9cbfe9763334896ac1d3e9dfa26..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10130 zcmbt4S!^7~aguW*{yq{3a*%q}OAA}A9QWT?u#>Nxd0BwWmz>Cnt~8f$(YHI} zNqAjWoiE|1b%8{HzDa_>+nsL61QWqbC=tqp6X8rG5y> zs!WzSqc5A!m)D{A*RX;TUA=@`Y+B#`ONtzF;>RV}QNbM|p@ zt6afdX|3c$*VlmmEu%qu+ACG*2076UKac4B+6(>R&q~nWwaW3Vyy}LMEvek92TE*S zt6nGtY|K?3l!#qYLE7!KM9%=0oU?%bA-j*-Y3Dd@DPreWxg|E5b6$YkSm{-W+WG3Y zb2JyH4pds5Z9uKrZi6vdeyPQ-EmY0NuH#@AmT=c;a`J~~4CKc*yV6MoC}vAgtV)DL zKupD8cTyk1X2uViJ|({_$tL0XR5qpZyxFKos&%%mrPQ=!hM@eml*>q}eAgs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DCSYQynpQkjy62)N&_t$g1QJ#~688>IRx$`ZR+9M{JV>lefmEz`kC+YWC$c1n5PvcK z*JxHAffo4wiJra{HE=7U84#rfA)i)3En@gUqOk*#g!n^NN-JjQoh;biS5=^ukv~EL zU}Mw5Q5>gy7{dbn%xMkjI09Fo*UCuUBS51Lj_?8%*9U+Fim^Rrv=48n;B@`hpw|Ar z-u}MP{{C9HL=ITmNhdwvuWR7A#|EDSe(lB&dcCE-ek<4gyshI=c0)AAE^2L4dfSxI zHU$zKDyt^cSUTwjKS`sJhlfE+U9Gn;vOpQ0Jr3Z%1D`+NhNlwDPQrey{v8uc52k+-F0=;-m}OTaPd88eAu`~e{`e3K}2hZ z1|ns&VdPc>7}}0E;%EOX_>1t_Kgjc$oS08zKFq@xdLeDK(68Mzjz#62o*H=`Y2f`L zqfVERbs0rl{u=;hr2MTtDW%gq4;R&OsHIV{3zk`cHk*t9%`4?U0KhkL`?u|G@}1k} z>Vd&g-}pAizzvtjH@eL+5cK)L{%4>u=6|Rl$gTC?6o;z#K+j)-NcC7b!+)wy2#bp{Dq|VFd*LH&qMft=fB~s zS!1;GkK{E=hTf3>9*TI;DgOsx+v9S%w!@sORpVN$r^NMZ&Zoq6X!cX$!uRQ~#5HO5 zQ{qzE&wonXVXf9v;;v}Ur^F3v&S%@7bGcy8Ys2-MKhl;zRJV&BEt<8 diff --git a/Audio_SpectraCLI/main.py b/Audio_SpectraCLI/main.py index 0bb6146..0ddecfc 100644 --- a/Audio_SpectraCLI/main.py +++ b/Audio_SpectraCLI/main.py @@ -30,8 +30,6 @@ def __init__(self, duration=10, fs=44100, block_size=4096, frequency_range=(20, self.spectrum = np.zeros(self.block_size) self.setup_ui() - self.timer = QTimer() - self.timer.timeout.connect(self.process_audio) def setup_ui(self): self.central_widget = QWidget() @@ -73,7 +71,7 @@ def setup_ui(self): self.layout.addWidget(QLabel('Block Size:')) self.layout.addWidget(self.block_size_slider) - self.start_button = QPushButton('Start Visualization') + self.start_button = QPushButton('End Visualization') self.start_button.clicked.connect(self.start_visualization) self.layout.addWidget(self.start_button) @@ -85,19 +83,20 @@ def audio_callback(self, indata, frames, time, status): self.audio_queue.put(indata.copy()) def process_audio(self): - if not self.audio_queue.empty(): - audio_block = self.audio_queue.get() - self.spectrum = np.abs(np.fft.fft( - audio_block[:, 0], n=self.block_size)) - self.update_plot() - - def update_plot(self): + while True: + if not self.audio_queue.empty(): + audio_block = self.audio_queue.get() + spectrum = np.abs(np.fft.fft( + audio_block[:, 0], n=self.block_size)) + max_magnitude = np.max(spectrum) + self.update_plot(spectrum, max_magnitude) + + def update_plot(self, spectrum, max_magnitude): freq_bins = np.fft.fftfreq(self.block_size, 1 / self.fs) - max_magnitude = np.max(self.spectrum) self.ax.clear() - self.ax.plot(freq_bins, self.spectrum, color=self.color) + self.ax.plot(freq_bins, spectrum, color=self.color) self.ax.set_xlim(self.frequency_range) - self.ax.set_ylim(0, max_magnitude * 1.1) + self.ax.set_ylim(0, max_magnitude * 1.8) self.ax.set_xlabel('Frequency (Hz)') self.ax.set_ylabel('Magnitude') self.ax.set_title('Audio Spectrum Visualization') @@ -113,16 +112,14 @@ def set_block_size(self, value): self.block_size = value def start_visualization(self): - audio_thread = threading.Thread(target=self.process_audio, daemon=True) - audio_thread.start() sd.default.samplerate = self.fs sd.default.channels = 1 self.stream = sd.InputStream(callback=self.audio_callback) self.stream.start() - self.timer.start(30) # Update every 30 milliseconds + audio_thread = threading.Thread(target=self.process_audio, daemon=True) + audio_thread.start() def closeEvent(self, event): - self.timer.stop() self.stream.stop() self.stream.close() event.accept() From a8747493112e2454eb6b2f80d6213c586b16cbf9 Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Sat, 18 May 2024 17:51:31 +0530 Subject: [PATCH 06/20] Readme done. Still will check for further improvements and fixes before publishing. --- Contributing.md | 19 +++++++--- Readme.md | 95 ++++++++++++++++++++++++++++--------------------- setup.cfg | 2 +- setup.py | 3 +- tests/test.py | 4 +-- 5 files changed, 75 insertions(+), 48 deletions(-) diff --git a/Contributing.md b/Contributing.md index 16dfefb..620a8e9 100644 --- a/Contributing.md +++ b/Contributing.md @@ -9,13 +9,23 @@ Fork, then clone the repo: git clone github.com/AdityaSeth777/Audio-SpectraCLI.git -Make your change. Add tests for your change. Make the tests pass: +## Making Changes -Push to your fork and [submit a pull request][pr]. +Here is an overview of how `@AdityaSeth777/Audio-SpectraCLI` works: + +- Create a topic branch from the main branch. +- Check for unnecessary whitespace / changes with `git diff --check` before committing. +- Keep git commit messages clear and appropriate. Ideally follow commit conventions described below. + +## Submitting the Pull Request + +- Push your changes to your topic branch on your fork of the repo. +- Submit a pull request from your topic branch to the main branch on the `Audio-SpectraCLI` repository : [submit a pull request][pr] +- Be sure to tag any issues your pull request is taking care of / contributing to. \* Adding "Closes #123" to a pull request description will auto close the issue once the pull request is merged in. [pr]: https://github.com/AdityaSeth777/Audio-SpectraCLI/compare/ -At this point you're waiting on us. I like to at least comment on pull requests +At this point you're waiting on me. I like to at least comment on pull requests within two business days (and, typically, one business day). I may suggest some changes or improvements or alternatives. @@ -26,4 +36,5 @@ Some things that will increase the chance that your pull request is accepted: [commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html -Thank you. +Thank you,
+[Aditya Seth.](https://adityaseth.in/linkedin) diff --git a/Readme.md b/Readme.md index df60de3..22e84bb 100644 --- a/Readme.md +++ b/Readme.md @@ -7,40 +7,48 @@ |_| ``` -Audio Spectrum Visualization is a Python project that visualizes real-time audio input as a spectrum using Fast Fourier Transform (FFT). It provides an interactive CLI interface for users to start the visualization and exit the program. +## Audio Spectrum Visualization is a Python project that visualizes real-time audio input as a spectrum using Fast Fourier Transform (FFT). It provides an interactive CLI interface for users to start the visualization and exit the program. -## Current Features (with respect to 3.2) +#### Notable point : From v4.0, I have implemented a whole new code using PyQt5, which you will find evident here in the new main default code - ['main.py'](./Audio_SpectraCLI/main.py) and the ['test.py'](./tests/test.py) case supporting that. + +#### The ['main-old.py'](./Audio_SpectraCLI/main-old.py), which is the code for the main file for v3.2, and the ['test-old.py'](./tests/test-old.py) case supporting that, is DEPRECATED. + +## Current Features (with respect to 4.0) - Real-time visualization of Fast Fourier Transform (FFT) spectrum of audio input. - Support for adjusting parameters such as duration, sampling rate, and block size. - Seamless integration with SoundDevice for audio input capture. - Customizable Frequency Range: Allow users to specify the frequency range to display in the spectrum. - Color Customization: Provide options for users to customize the colors used in the spectrum visualization. +- Added PyQt5 modules that enables user input for Duration (in seconds), Sampling Rate (in Hz), and Block Size. +- Much more dynamic and user-controlled interface. ## Packaging ``` Audio-SpectraCLI/ -│ CODE_OF_CONDUCT.md -│ Contributing.md -│ Dockerfile -│ LICENSE -│ Readme.md -│ requirements.txt -│ setup.cfg -│ setup.py -│ -├───.github -│ └───workflows -│ python-publish.yml -│ -├───Audio_SpectraCLI -│ main.py -│ __init__.py -│ -└───tests - main.py +├── .gitignore +├── CODE_OF_CONDUCT.md +├── Contributing.md +├── Dockerfile +├── LICENSE +├── Readme.md +├── requirements.txt +├── setup.cfg +├── setup.py +├── .github/ +│ └── workflows/ +│ ├── docker-publish.yml +│ ├── label.yml +│ └── python-publish.yml +├── Audio_SpectraCLI/ +│ ├── main-old.py +│ ├── main.py +│ └── __init__.py +└── tests/ + ├── test-old.py + └── test.py ``` ## Installation & Usage (Using PIP) @@ -54,20 +62,25 @@ pip install Audio-SpectraCLI 2. Import and use modules - Create a Python file. -- You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/main.py) as a reference or use the following code : +- You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/test.py) as a reference or use the following code : ``` from Audio_SpectraCLI import AudioSpectrumVisualizer +from PyQt5.QtWidgets import QApplication -# Creating an instance of AudioSpectrumVisualizer with custom parameters. +# Creating an instance of AudioSpectrumVisualizer with custom parameters +app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( - duration=5, frequency_range=(50, 5000), color='red') + duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') # Starting the audio spectrum visualization +audio_visualizer.show() audio_visualizer.start_visualization() +app.exec_() + ``` -Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. +Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. Also, the user can modify (wrt [v4.0](https://github.com/AdityaSeth777/Audio-SpectraCLI/tree/4.0)) the Duration (in seconds), Sampling Rate (in Hz), and Block Size. --- @@ -96,20 +109,24 @@ docker run --rm -it --entrypoint /bin/bash audio-spectracli ls ``` -5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/main.py) as a reference or use the following code : +5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/test.py) as a reference or use the following code : ``` from Audio_SpectraCLI import AudioSpectrumVisualizer +from PyQt5.QtWidgets import QApplication -# Creating an instance of AudioSpectrumVisualizer with custom parameters. +# Creating an instance of AudioSpectrumVisualizer with custom parameters +app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( - duration=5, frequency_range=(50, 5000), color='red') + duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') # Starting the audio spectrum visualization +audio_visualizer.show() audio_visualizer.start_visualization() +app.exec_() ``` -Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. +Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. Also, the user can modify (wrt [v4.0](https://github.com/AdityaSeth777/Audio-SpectraCLI/tree/4.0)) the Duration (in seconds), Sampling Rate (in Hz), and Block Size. --- @@ -143,38 +160,36 @@ docker run --rm -it --entrypoint /bin/bash audio-spectracli ls ``` -5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/main.py) as a reference or use the following code : +5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/test.py) as a reference or use the following code : ``` from Audio_SpectraCLI import AudioSpectrumVisualizer +from PyQt5.QtWidgets import QApplication -# Creating an instance of AudioSpectrumVisualizer with custom parameters. +# Creating an instance of AudioSpectrumVisualizer with custom parameters +app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( - duration=5, frequency_range=(50, 5000), color='red') + duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') # Starting the audio spectrum visualization +audio_visualizer.show() audio_visualizer.start_visualization() +app.exec_() ``` -Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. +Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. Also, the user can modify (wrt [v4.0](https://github.com/AdityaSeth777/Audio-SpectraCLI/tree/4.0)) the Duration (in seconds), Sampling Rate (in Hz), and Block Size. ## Upcoming Features +- Save and Export: Implement functionality to save the generated spectrum as an image file or export data for further analysis. - CLI endpoints. - Option to choose between CLI/GUI. -- Save and Export: Implement functionality to save the generated spectrum as an image file or export data for further analysis. -- Additional Audio Effects: Integrate additional audio effects or processing options to enhance the visualization. --- ## For contributing Check the [Contributing page.](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/Contributing.md) -Make sure to PR your changes in the development branch. - -## .env file - -This file contains various environment variables that you can configure. ## License diff --git a/setup.cfg b/setup.cfg index 223197e..2a44b8c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = Audio-SpectraCLI -version = 3.2 +version = 4.0 author = Aditya Seth author_email = contact@adityaseth.in description = AudioSpectraCLI is a command-line tool that provides real-time FFT visualization of audio spectra. It captures audio input from the microphone and displays the corresponding frequency spectrum directly in the terminal window, allowing users to monitor and analyze audio signals without the need for graphical interfaces. diff --git a/setup.py b/setup.py index 6fc7180..d3af10b 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='Audio_SpectraCLI', - version='3.2', + version='4.0', author="Aditya Seth", long_description=open('Readme.md', encoding='utf-8').read(), long_description_content_type='text/markdown', @@ -15,6 +15,7 @@ 'setuptools', 'twine', 'wheel', + 'pyqt5', 'pyaudio' ], license="MIT", diff --git a/tests/test.py b/tests/test.py index e1b8980..b81a604 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,12 +1,12 @@ from Audio_SpectraCLI import AudioSpectrumVisualizer from PyQt5.QtWidgets import QApplication -# Create an instance of AudioSpectrumVisualizer with custom parameters +# Creating an instance of AudioSpectrumVisualizer with custom parameters app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') -# Start the audio spectrum visualization +# Starting the audio spectrum visualization audio_visualizer.show() audio_visualizer.start_visualization() app.exec_() From 771f14769f36d63c2a273f80d7d29ac23ec454c7 Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Sat, 18 May 2024 18:14:44 +0530 Subject: [PATCH 07/20] I think everything is gtg. Still improvements can be done. --- Readme.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 22e84bb..7e33913 100644 --- a/Readme.md +++ b/Readme.md @@ -9,9 +9,9 @@ ## Audio Spectrum Visualization is a Python project that visualizes real-time audio input as a spectrum using Fast Fourier Transform (FFT). It provides an interactive CLI interface for users to start the visualization and exit the program. -#### Notable point : From v4.0, I have implemented a whole new code using PyQt5, which you will find evident here in the new main default code - ['main.py'](./Audio_SpectraCLI/main.py) and the ['test.py'](./tests/test.py) case supporting that. +#### Notable point : From v4.0, I have implemented a whole new code using PyQt5, which you will find evident here in the new main default code - ['main.py'](./Audio_SpectraCLI/main.py) and the ['test.py'](./tests/test.py) case supporting that. -#### The ['main-old.py'](./Audio_SpectraCLI/main-old.py), which is the code for the main file for v3.2, and the ['test-old.py'](./tests/test-old.py) case supporting that, is DEPRECATED. +#### The ['main-old.py'](./Audio_SpectraCLI/main-old.py), which is the code for the main file for v3.2, and the ['test-old.py'](./tests/test-old.py) case supporting that, is DEPRECATED. ## Current Features (with respect to 4.0) @@ -201,13 +201,14 @@ I will be improving this project. ## Where to contact ? -Contact: [contact@adityaseth.in] +Contact: [contact@adityaseth.in](mailto:contact@adityaseth.in?subject=Email%20owing%20to%20adityaseth.in&body=Greetings%2C%0AI%20am%20%5Bname%5D.%20I%20just%20came%20across%20your%20website%20and%20was%20hoping%20to%20talk%20to%20you%20about%20something.) ## 🙋‍♂️ Support -💙 If you like this project, give it a ⭐ and share it with friends!`

` -[☕ Buy me a coffee](https://www.buymeacoffee.com/adityaseth) +💙 If you like this project, give it a ⭐ and share it with friends!

+ +[buymeacoffee](https://www.buymeacoffee.com/adityaseth) --- -Made with ❤️ +# Made with love-circled and python From d74ee0d51c20684711e09eb578d25996cd4c5dfa Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Sun, 19 May 2024 19:04:39 +0530 Subject: [PATCH 08/20] Minor fixes before launching --- Readme.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Readme.md b/Readme.md index 7e33913..2972bbd 100644 --- a/Readme.md +++ b/Readme.md @@ -7,7 +7,7 @@ |_| ``` -## Audio Spectrum Visualization is a Python project that visualizes real-time audio input as a spectrum using Fast Fourier Transform (FFT). It provides an interactive CLI interface for users to start the visualization and exit the program. +## Audio Spectrum Visualization is a Python project that visualizes real-time audio input as a spectrum using Fast Fourier Transform (FFT). It provides an interactive and dynamic interface for users to start the visualization and exit the program. #### Notable point : From v4.0, I have implemented a whole new code using PyQt5, which you will find evident here in the new main default code - ['main.py'](./Audio_SpectraCLI/main.py) and the ['test.py'](./tests/test.py) case supporting that. @@ -64,7 +64,7 @@ pip install Audio-SpectraCLI - Create a Python file. - You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/test.py) as a reference or use the following code : -``` +```python from Audio_SpectraCLI import AudioSpectrumVisualizer from PyQt5.QtWidgets import QApplication @@ -77,7 +77,6 @@ audio_visualizer = AudioSpectrumVisualizer( audio_visualizer.show() audio_visualizer.start_visualization() app.exec_() - ``` Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. Also, the user can modify (wrt [v4.0](https://github.com/AdityaSeth777/Audio-SpectraCLI/tree/4.0)) the Duration (in seconds), Sampling Rate (in Hz), and Block Size. @@ -111,7 +110,7 @@ ls 5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/test.py) as a reference or use the following code : -``` +```python from Audio_SpectraCLI import AudioSpectrumVisualizer from PyQt5.QtWidgets import QApplication @@ -162,7 +161,7 @@ ls 5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/test.py) as a reference or use the following code : -``` +```python from Audio_SpectraCLI import AudioSpectrumVisualizer from PyQt5.QtWidgets import QApplication From dc556bcdedf8d85dff385b881337c9d6d12a6d72 Mon Sep 17 00:00:00 2001 From: Aditya Seth Date: Mon, 20 May 2024 11:19:44 +0530 Subject: [PATCH 09/20] License updated to Apache License, --- LICENSE | 222 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 201 insertions(+), 21 deletions(-) diff --git a/LICENSE b/LICENSE index fabf130..8e81943 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,201 @@ -MIT License - -Copyright (c) 2024 Aditya Seth - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2024] [Aditya Seth] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From 19bbe55745f538524262b68a66c20c8c98d442a2 Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Mon, 20 May 2024 13:16:26 +0530 Subject: [PATCH 10/20] product hunt link added ? :D --- Readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Readme.md b/Readme.md index 2972bbd..7625ee2 100644 --- a/Readme.md +++ b/Readme.md @@ -9,6 +9,8 @@ ## Audio Spectrum Visualization is a Python project that visualizes real-time audio input as a spectrum using Fast Fourier Transform (FFT). It provides an interactive and dynamic interface for users to start the visualization and exit the program. + + #### Notable point : From v4.0, I have implemented a whole new code using PyQt5, which you will find evident here in the new main default code - ['main.py'](./Audio_SpectraCLI/main.py) and the ['test.py'](./tests/test.py) case supporting that. #### The ['main-old.py'](./Audio_SpectraCLI/main-old.py), which is the code for the main file for v3.2, and the ['test-old.py'](./tests/test-old.py) case supporting that, is DEPRECATED. From 0b103732ca450442ec4f73d31997a179765a39cb Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Mon, 20 May 2024 18:38:00 +0530 Subject: [PATCH 11/20] Added those ugly visitor boxes everyone finds attractive (O_o) --- Readme.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index 7625ee2..87e66fc 100644 --- a/Readme.md +++ b/Readme.md @@ -9,11 +9,26 @@ ## Audio Spectrum Visualization is a Python project that visualizes real-time audio input as a spectrum using Fast Fourier Transform (FFT). It provides an interactive and dynamic interface for users to start the visualization and exit the program. - +

-#### Notable point : From v4.0, I have implemented a whole new code using PyQt5, which you will find evident here in the new main default code - ['main.py'](./Audio_SpectraCLI/main.py) and the ['test.py'](./tests/test.py) case supporting that. +![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat) +[![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2FAdityaSeth777%2FAudio-SpectraCLI&label=Visitors&countColor=%23263759&style=plastic)](https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2FAdityaSeth777%2FAudio-SpectraCLI) +![GitHub forks](https://img.shields.io/github/forks/AdityaSeth777/Audio-SpectraCLI) +![GitHub Repo stars](https://img.shields.io/github/stars/AdityaSeth777/Audio-SpectraCLI) +![GitHub last commit](https://img.shields.io/github/last-commit/AdityaSeth777/Audio-SpectraCLI) +![GitHub repo size](https://img.shields.io/github/repo-size/AdityaSeth777/Audio-SpectraCLI) +![GitHub issues](https://img.shields.io/github/issues/AdityaSeth777/Audio-SpectraCLI) +![GitHub closed issues](https://img.shields.io/github/issues-closed-raw/AdityaSeth777/Audio-SpectraCLI) +![GitHub pull requests](https://img.shields.io/github/issues-pr/AdityaSeth777/Audio-SpectraCLI) +![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/AdityaSeth777/Audio-SpectraCLI) -#### The ['main-old.py'](./Audio_SpectraCLI/main-old.py), which is the code for the main file for v3.2, and the ['test-old.py'](./tests/test-old.py) case supporting that, is DEPRECATED. +

+ +Audio-SpectraCLI - Visualizing real-time audio input as a spectrum using FFT | Product Hunt + +### Notable point : From v4.0, I have implemented a whole new code using PyQt5, which you will find evident here in the new main default code - ['main.py'](./Audio_SpectraCLI/main.py) and the ['test.py'](./tests/test.py) case supporting that. + +### The ['main-old.py'](./Audio_SpectraCLI/main-old.py), which is the code for the main file for v3.2, and the ['test-old.py'](./tests/test-old.py) case supporting that, is DEPRECATED. ## Current Features (with respect to 4.0) From b430931832386a2f38e73178284579111742c6f2 Mon Sep 17 00:00:00 2001 From: Aditya Seth Date: Mon, 20 May 2024 18:40:16 +0530 Subject: [PATCH 12/20] Delete LICENSE --- LICENSE | 201 -------------------------------------------------------- 1 file changed, 201 deletions(-) delete mode 100644 LICENSE diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 8e81943..0000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [2024] [Aditya Seth] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. From 512a988d80f9cd4f8b88278867c423dddcdf3970 Mon Sep 17 00:00:00 2001 From: Aditya Seth Date: Mon, 20 May 2024 18:41:25 +0530 Subject: [PATCH 13/20] Create LICENSE --- LICENSE | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..038e1ea --- /dev/null +++ b/LICENSE @@ -0,0 +1,190 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + +Copyright [2024] [Aditya Seth] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From 837a761c9bb9e66c80301280958ff78597572c64 Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Mon, 20 May 2024 18:44:23 +0530 Subject: [PATCH 14/20] Will publish it after a few days. --- setup.cfg | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 2a44b8c..0074358 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,6 +3,6 @@ name = Audio-SpectraCLI version = 4.0 author = Aditya Seth author_email = contact@adityaseth.in -description = AudioSpectraCLI is a command-line tool that provides real-time FFT visualization of audio spectra. It captures audio input from the microphone and displays the corresponding frequency spectrum directly in the terminal window, allowing users to monitor and analyze audio signals without the need for graphical interfaces. -license = MIT +description = AudioSpectraCLI is a tool that provides real-time FFT visualization of audio spectra. It captures audio input from the microphone and displays the corresponding frequency spectrum directly, allowing users to monitor and analyze audio signals. +license = Apache License 2.0 home-page = https://github.com/AdityaSeth777/Audio-SpectraCLI \ No newline at end of file diff --git a/setup.py b/setup.py index d3af10b..1c4f793 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,6 @@ 'pyqt5', 'pyaudio' ], - license="MIT", + license="Apache License 2.0", url="https://github.com/AdityaSeth777/Audio-SpectraCLI", ) From 4a9fc35836748f94b2879eab83a3ea2c9e529c2b Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Thu, 23 May 2024 13:57:43 +0530 Subject: [PATCH 15/20] Problems : It is super lagging and no one can see the changes because when it is quiet, it is showing a bunch of spectrum indicating noise or anything. I need it to be minimal and pop up when there is actual talking or music and it needs to be smooth and not jittery --- Audio_SpectraCLI.egg-info/PKG-INFO | 250 ++++++++++++++++++ Audio_SpectraCLI.egg-info/SOURCES.txt | 13 + .../dependency_links.txt | 1 + Audio_SpectraCLI.egg-info/requires.txt | 9 + Audio_SpectraCLI.egg-info/top_level.txt | 1 + .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 232 bytes .../__pycache__/main.cpython-311.pyc | Bin 0 -> 10359 bytes Audio_SpectraCLI/main.py | 38 ++- tests/test.py | 8 +- 9 files changed, 303 insertions(+), 17 deletions(-) create mode 100644 Audio_SpectraCLI.egg-info/PKG-INFO create mode 100644 Audio_SpectraCLI.egg-info/SOURCES.txt create mode 100644 Audio_SpectraCLI.egg-info/dependency_links.txt create mode 100644 Audio_SpectraCLI.egg-info/requires.txt create mode 100644 Audio_SpectraCLI.egg-info/top_level.txt create mode 100644 Audio_SpectraCLI/__pycache__/__init__.cpython-311.pyc create mode 100644 Audio_SpectraCLI/__pycache__/main.cpython-311.pyc diff --git a/Audio_SpectraCLI.egg-info/PKG-INFO b/Audio_SpectraCLI.egg-info/PKG-INFO new file mode 100644 index 0000000..a58c65f --- /dev/null +++ b/Audio_SpectraCLI.egg-info/PKG-INFO @@ -0,0 +1,250 @@ +Metadata-Version: 2.1 +Name: Audio_SpectraCLI +Version: 4.0 +Summary: AudioSpectraCLI is a tool that provides real-time FFT visualization of audio spectra. It captures audio input from the microphone and displays the corresponding frequency spectrum directly, allowing users to monitor and analyze audio signals. +Home-page: https://github.com/AdityaSeth777/Audio-SpectraCLI +Author: Aditya Seth +Author-email: contact@adityaseth.in +License: Apache License 2.0 +Description-Content-Type: text/markdown +License-File: LICENSE +Requires-Dist: numpy +Requires-Dist: matplotlib +Requires-Dist: sounddevice +Requires-Dist: tabulate +Requires-Dist: setuptools +Requires-Dist: twine +Requires-Dist: wheel +Requires-Dist: pyqt5 +Requires-Dist: pyaudio + +``` + _ _ _ ____ _ ____ _ ___ + / \ _ _ __| (_) ___ / ___| _ __ ___ ___| |_ _ __ __ _ / ___| | |_ _| + / _ \| | | |/ _` | |/ _ \ ____\___ \| '_ \ / _ \/ __| __| '__/ _` | | | | | | + / ___ \ |_| | (_| | | (_) |_____|__) | |_) | __/ (__| |_| | | (_| | |___| |___ | | +/_/ \_\__,_|\__,_|_|\___/ |____/| .__/ \___|\___|\__|_| \__,_|\____|_____|___| + |_| +``` + +## Audio Spectrum Visualization is a Python project that visualizes real-time audio input as a spectrum using Fast Fourier Transform (FFT). It provides an interactive and dynamic interface for users to start the visualization and exit the program. + +

+ +![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat) +[![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2FAdityaSeth777%2FAudio-SpectraCLI&label=Visitors&countColor=%23263759&style=plastic)](https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2FAdityaSeth777%2FAudio-SpectraCLI) +![GitHub forks](https://img.shields.io/github/forks/AdityaSeth777/Audio-SpectraCLI) +![GitHub Repo stars](https://img.shields.io/github/stars/AdityaSeth777/Audio-SpectraCLI) +![GitHub last commit](https://img.shields.io/github/last-commit/AdityaSeth777/Audio-SpectraCLI) +![GitHub repo size](https://img.shields.io/github/repo-size/AdityaSeth777/Audio-SpectraCLI) +![GitHub issues](https://img.shields.io/github/issues/AdityaSeth777/Audio-SpectraCLI) +![GitHub closed issues](https://img.shields.io/github/issues-closed-raw/AdityaSeth777/Audio-SpectraCLI) +![GitHub pull requests](https://img.shields.io/github/issues-pr/AdityaSeth777/Audio-SpectraCLI) +![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/AdityaSeth777/Audio-SpectraCLI) + +

+ +Audio-SpectraCLI - Visualizing real-time audio input as a spectrum using FFT | Product Hunt + +### Notable point : From v4.0, I have implemented a whole new code using PyQt5, which you will find evident here in the new main default code - ['main.py'](./Audio_SpectraCLI/main.py) and the ['test.py'](./tests/test.py) case supporting that. + +### The ['main-old.py'](./Audio_SpectraCLI/main-old.py), which is the code for the main file for v3.2, and the ['test-old.py'](./tests/test-old.py) case supporting that, is DEPRECATED. + +## Current Features (with respect to 4.0) + +- Real-time visualization of Fast Fourier Transform (FFT) spectrum of audio input. +- Support for adjusting parameters such as duration, sampling rate, and block size. +- Seamless integration with SoundDevice for audio input capture. +- Customizable Frequency Range: Allow users to specify the frequency range to display in the spectrum. +- Color Customization: Provide options for users to customize the colors used in the spectrum visualization. +- Added PyQt5 modules that enables user input for Duration (in seconds), Sampling Rate (in Hz), and Block Size. +- Much more dynamic and user-controlled interface. + +## Packaging + +``` +Audio-SpectraCLI/ + +├── .gitignore +├── CODE_OF_CONDUCT.md +├── Contributing.md +├── Dockerfile +├── LICENSE +├── Readme.md +├── requirements.txt +├── setup.cfg +├── setup.py +├── .github/ +│ └── workflows/ +│ ├── docker-publish.yml +│ ├── label.yml +│ └── python-publish.yml +├── Audio_SpectraCLI/ +│ ├── main-old.py +│ ├── main.py +│ └── __init__.py +└── tests/ + ├── test-old.py + └── test.py +``` + +## Installation & Usage (Using PIP) + +1. Install using pip + +``` +pip install Audio-SpectraCLI +``` + +2. Import and use modules + +- Create a Python file. +- You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/test.py) as a reference or use the following code : + +```python +from Audio_SpectraCLI import AudioSpectrumVisualizer +from PyQt5.QtWidgets import QApplication + +# Creating an instance of AudioSpectrumVisualizer with custom parameters +app = QApplication([]) +audio_visualizer = AudioSpectrumVisualizer( + duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') + +# Starting the audio spectrum visualization +audio_visualizer.show() +audio_visualizer.start_visualization() +app.exec_() +``` + +Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. Also, the user can modify (wrt [v4.0](https://github.com/AdityaSeth777/Audio-SpectraCLI/tree/4.0)) the Duration (in seconds), Sampling Rate (in Hz), and Block Size. + +--- + +## Examining & Usage for fun :D (Using Docker) + +1. Prerequisites + You should have docker installed on your machine. You can download and install Docker from [here](https://www.docker.com/products/docker-desktop). +2. Pulling the Docker Image + +You can pull the pre-built Docker image from Docker Hub using the following command: + +```sh +docker pull adityaseth777/audio-spectracli +``` + +3. Viewing Files Inside the Docker Container + For seeing the files inside the Docker container for debugging purposes, you can run an interactive shell session: + +```sh +docker run --rm -it --entrypoint /bin/bash audio-spectracli +``` + +4. Use the 'ls' command to view the files and get a proper understanding of the file structure : + +```sh +ls +``` + +5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/test.py) as a reference or use the following code : + +```python +from Audio_SpectraCLI import AudioSpectrumVisualizer +from PyQt5.QtWidgets import QApplication + +# Creating an instance of AudioSpectrumVisualizer with custom parameters +app = QApplication([]) +audio_visualizer = AudioSpectrumVisualizer( + duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') + +# Starting the audio spectrum visualization +audio_visualizer.show() +audio_visualizer.start_visualization() +app.exec_() +``` + +Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. Also, the user can modify (wrt [v4.0](https://github.com/AdityaSeth777/Audio-SpectraCLI/tree/4.0)) the Duration (in seconds), Sampling Rate (in Hz), and Block Size. + +--- + +## Building the Docker Image Locally (for fun :D) + +If you prefer to build the Docker image locally, follow these steps: + +1. Clone the repository : + +```sh +git clone https://github.com/AdityaSeth777/Audio-SpectraCLI.git +cd Audio-SpectraCLI +``` + +2. Build the Docker image: + +```sh +docker build -t audio-spectracli . +``` + +3. Viewing Files Inside the Docker Container + For seeing the files inside the Docker container for debugging purposes, you can run an interactive shell session: + +```sh +docker run --rm -it --entrypoint /bin/bash audio-spectracli +``` + +4. Use the 'ls' command to view the files and get a proper understanding of the file structure : + +```sh +ls +``` + +5. You can use [Example.py](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/tests/test.py) as a reference or use the following code : + +```python +from Audio_SpectraCLI import AudioSpectrumVisualizer +from PyQt5.QtWidgets import QApplication + +# Creating an instance of AudioSpectrumVisualizer with custom parameters +app = QApplication([]) +audio_visualizer = AudioSpectrumVisualizer( + duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') + +# Starting the audio spectrum visualization +audio_visualizer.show() +audio_visualizer.start_visualization() +app.exec_() +``` + +Once you have activated the audio_visualizer instance, feel free to use it wherever in the program. It consists of several parameters (which gives more control to the user), so make sure to configure and add those before using it in your code. Also, the user can modify (wrt [v4.0](https://github.com/AdityaSeth777/Audio-SpectraCLI/tree/4.0)) the Duration (in seconds), Sampling Rate (in Hz), and Block Size. + +## Upcoming Features + +- Save and Export: Implement functionality to save the generated spectrum as an image file or export data for further analysis. +- CLI endpoints. +- Option to choose between CLI/GUI. + +--- + +## For contributing + +Check the [Contributing page.](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/Contributing.md) + +## License + +[MIT © Aditya Seth](https://github.com/AdityaSeth777/Audio-SpectraCLI/blob/main/LICENSE) + +## What next? + +I will be improving this project. + +## Where to contact ? + +Contact: [contact@adityaseth.in](mailto:contact@adityaseth.in?subject=Email%20owing%20to%20adityaseth.in&body=Greetings%2C%0AI%20am%20%5Bname%5D.%20I%20just%20came%20across%20your%20website%20and%20was%20hoping%20to%20talk%20to%20you%20about%20something.) + +## 🙋‍♂️ Support + +💙 If you like this project, give it a ⭐ and share it with friends!

+ +[buymeacoffee](https://www.buymeacoffee.com/adityaseth) + +--- + +# Made with love-circled and python diff --git a/Audio_SpectraCLI.egg-info/SOURCES.txt b/Audio_SpectraCLI.egg-info/SOURCES.txt new file mode 100644 index 0000000..7a899eb --- /dev/null +++ b/Audio_SpectraCLI.egg-info/SOURCES.txt @@ -0,0 +1,13 @@ +LICENSE +setup.cfg +setup.py +Audio_SpectraCLI/__init__.py +Audio_SpectraCLI/main-old.py +Audio_SpectraCLI/main.py +Audio_SpectraCLI.egg-info/PKG-INFO +Audio_SpectraCLI.egg-info/SOURCES.txt +Audio_SpectraCLI.egg-info/dependency_links.txt +Audio_SpectraCLI.egg-info/requires.txt +Audio_SpectraCLI.egg-info/top_level.txt +tests/test-old.py +tests/test.py \ No newline at end of file diff --git a/Audio_SpectraCLI.egg-info/dependency_links.txt b/Audio_SpectraCLI.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Audio_SpectraCLI.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/Audio_SpectraCLI.egg-info/requires.txt b/Audio_SpectraCLI.egg-info/requires.txt new file mode 100644 index 0000000..b9e3009 --- /dev/null +++ b/Audio_SpectraCLI.egg-info/requires.txt @@ -0,0 +1,9 @@ +numpy +matplotlib +sounddevice +tabulate +setuptools +twine +wheel +pyqt5 +pyaudio diff --git a/Audio_SpectraCLI.egg-info/top_level.txt b/Audio_SpectraCLI.egg-info/top_level.txt new file mode 100644 index 0000000..62e5e68 --- /dev/null +++ b/Audio_SpectraCLI.egg-info/top_level.txt @@ -0,0 +1 @@ +Audio_SpectraCLI diff --git a/Audio_SpectraCLI/__pycache__/__init__.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5b6f6d85380975e3b8f263885379009259af0fa2 GIT binary patch literal 232 zcmZ3^%ge<81bLBcX*NLmF^B^LOi;#WAs}NqLkdF*V-7 zl2MuzlL*qMTMX8in4FUt12!lgVp5{Bk7rDLd}dx|NqoFsLFF$Fo80`A(wtPgA`YNA dAiIm@fy4)9Mn=XDYz&NA7Z@}#Q4t$Z4FCf@Jp2Fv literal 0 HcmV?d00001 diff --git a/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bbecd1793e02e9d32180675434a7724bb2eda28a GIT binary patch literal 10359 zcmbt4OKcohay|b?P7jAai+^&&pEROGeJHIZQnn>hE6K4$m@7rj&dO*sr<>GB^Wnbk z(TAY|9lQwbFjysUU^-!tK_J;OECULV!ya+R4v;Uo4xcC;w{SOxG6ewq2Z9wJ=PU0j_noD@t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wM0Et= z8_rtr0l@fyoVM8KUHT7D#4AyG1pri!$Fs$Ao;HnZwVo0;pt+wC*Qwc0iQ^xzzY^E1 z*-wc}X@B@r;(9dqQ{q0<+)s%c*4)ol@UF)L2VEbo-})_U`CWB8MAbo=H;z0A;UC+S F{|B(@Hbwvd literal 0 HcmV?d00001 diff --git a/Audio_SpectraCLI/main.py b/Audio_SpectraCLI/main.py index 0ddecfc..0a05e2f 100644 --- a/Audio_SpectraCLI/main.py +++ b/Audio_SpectraCLI/main.py @@ -9,7 +9,7 @@ import queue import threading from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QPushButton, QVBoxLayout, QWidget, QSlider -from PyQt5.QtCore import Qt, QTimer +from PyQt5.QtCore import Qt from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure @@ -30,6 +30,7 @@ def __init__(self, duration=10, fs=44100, block_size=4096, frequency_range=(20, self.spectrum = np.zeros(self.block_size) self.setup_ui() + self.running = False def setup_ui(self): self.central_widget = QWidget() @@ -71,8 +72,8 @@ def setup_ui(self): self.layout.addWidget(QLabel('Block Size:')) self.layout.addWidget(self.block_size_slider) - self.start_button = QPushButton('End Visualization') - self.start_button.clicked.connect(self.start_visualization) + self.start_button = QPushButton('Start Visualization') + self.start_button.clicked.connect(self.toggle_visualization) self.layout.addWidget(self.start_button) self.central_widget.setLayout(self.layout) @@ -83,7 +84,7 @@ def audio_callback(self, indata, frames, time, status): self.audio_queue.put(indata.copy()) def process_audio(self): - while True: + while self.running: if not self.audio_queue.empty(): audio_block = self.audio_queue.get() spectrum = np.abs(np.fft.fft( @@ -111,17 +112,28 @@ def set_sampling_rate(self, value): def set_block_size(self, value): self.block_size = value - def start_visualization(self): - sd.default.samplerate = self.fs - sd.default.channels = 1 - self.stream = sd.InputStream(callback=self.audio_callback) - self.stream.start() - audio_thread = threading.Thread(target=self.process_audio, daemon=True) - audio_thread.start() + def toggle_visualization(self): + if self.running: + self.running = False + self.stream.stop() + self.stream.close() + self.start_button.setText('Start Visualization') + else: + self.running = True + sd.default.samplerate = self.fs + sd.default.channels = 1 + self.stream = sd.InputStream(callback=self.audio_callback) + self.stream.start() + audio_thread = threading.Thread( + target=self.process_audio, daemon=True) + audio_thread.start() + self.start_button.setText('Pause Visualization') def closeEvent(self, event): - self.stream.stop() - self.stream.close() + self.running = False + if hasattr(self, 'stream'): + self.stream.stop() + self.stream.close() event.accept() diff --git a/tests/test.py b/tests/test.py index b81a604..b1413f7 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,12 +1,12 @@ from Audio_SpectraCLI import AudioSpectrumVisualizer from PyQt5.QtWidgets import QApplication -# Creating an instance of AudioSpectrumVisualizer with custom parameters +# Create an instance of AudioSpectrumVisualizer with custom parameters app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( - duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') + duration=5, fs=22050, block_size=1024, frequency_range=(50, 5000), color='red') -# Starting the audio spectrum visualization +# Start the audio spectrum visualization audio_visualizer.show() -audio_visualizer.start_visualization() +audio_visualizer.toggle_visualization() app.exec_() From 32dceb20f9f0edea27e4c535c8e2c1f95aa8a1de Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Thu, 23 May 2024 14:00:57 +0530 Subject: [PATCH 16/20] Blank screen. Should have left it XD --- .../__pycache__/main.cpython-311.pyc | Bin 10359 -> 10616 bytes Audio_SpectraCLI/main.py | 12 +++++++++--- tests/test.py | 1 - 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc index bbecd1793e02e9d32180675434a7724bb2eda28a..920d47cca49d2bb506064d99dff6e177765ac293 100644 GIT binary patch delta 2146 zcmZ`)|4&<06u+lf%3`h~UwT3Vp(I-r3K-4w?*Fc_%+UZUV)&__u5a- zJ?EZt&pqGz%gC?C-JiN#b%;LhzlQVWV8tC~Zd6kJiwqKw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YL*0O*Ex;Lu#b zx^HX2ny3?v^~Ue|2MT`BJ^sv}pz1^`jv<|Hv%HT`lzA`1-LQ9L-O6>Q8Ve OkXz}ck!w#456 diff --git a/Audio_SpectraCLI/main.py b/Audio_SpectraCLI/main.py index 0a05e2f..edcdb5a 100644 --- a/Audio_SpectraCLI/main.py +++ b/Audio_SpectraCLI/main.py @@ -8,8 +8,9 @@ import sounddevice as sd import queue import threading +from scipy.ndimage import gaussian_filter1d from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QPushButton, QVBoxLayout, QWidget, QSlider -from PyQt5.QtCore import Qt +from PyQt5.QtCore import Qt, QTimer from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure @@ -29,6 +30,8 @@ def __init__(self, duration=10, fs=44100, block_size=4096, frequency_range=(20, self.audio_queue = queue.Queue() self.spectrum = np.zeros(self.block_size) + self.noise_threshold = 10 # Adjust as needed for noise level + self.setup_ui() self.running = False @@ -89,8 +92,11 @@ def process_audio(self): audio_block = self.audio_queue.get() spectrum = np.abs(np.fft.fft( audio_block[:, 0], n=self.block_size)) + spectrum = gaussian_filter1d( + spectrum, sigma=2) # Apply smoothing filter max_magnitude = np.max(spectrum) - self.update_plot(spectrum, max_magnitude) + if max_magnitude > self.noise_threshold: + self.update_plot(spectrum, max_magnitude) def update_plot(self, spectrum, max_magnitude): freq_bins = np.fft.fftfreq(self.block_size, 1 / self.fs) @@ -127,7 +133,7 @@ def toggle_visualization(self): audio_thread = threading.Thread( target=self.process_audio, daemon=True) audio_thread.start() - self.start_button.setText('Pause Visualization') + self.start_button.setText('Stop Visualization') def closeEvent(self, event): self.running = False diff --git a/tests/test.py b/tests/test.py index b1413f7..d117795 100644 --- a/tests/test.py +++ b/tests/test.py @@ -8,5 +8,4 @@ # Start the audio spectrum visualization audio_visualizer.show() -audio_visualizer.toggle_visualization() app.exec_() From c1db97480c77c4eb044b95916059d978c24005fa Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Thu, 23 May 2024 14:07:30 +0530 Subject: [PATCH 17/20] God! --- .../__pycache__/main.cpython-311.pyc | Bin 10616 -> 10707 bytes Audio_SpectraCLI/main.py | 15 +++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc index 920d47cca49d2bb506064d99dff6e177765ac293..809a4783c1a26d7d0af9d3719429c958d25cff36 100644 GIT binary patch delta 1551 zcmZ`(|7%-S6u&pgOVcK4UY74^+I(x;zBcyDO1I9`w#?BVwsw=&`h#@Dta%NwX;SY? zwviRAzg4LWJ&JBaC=RAW5hNml=s%!?w2dqTh5jbuFA+tCD0uEmTFR#9CZBiiIrp4< z&bjB_NAvp&?H`%VZ3JnUTw1ZXK5vg`^!F$s?@|creWgXsH0@04H%MIMi#R0-&a4fd zkPX;0x!|DN0cCB}l)8P3)BUL#$p$*zhu#)e$Y#^oR86nsnVeXw85B8RSdSOd@RjZs z{Q~BNwg&&JkL=`>B)0@{U6><|=Gx?~o5Pydt0QZB?RVLyP9d!}+R?bIiE`BONZNxq@f* zlVkx4wLm2OMW#WeL~AtrOOq3nbZRY8w9F;02i6j)Y&u^^%1;L*Gm{|f9`(M!z4al~ zjD_`NA}`0+Gr7E^V^LUj4`N2Q-Dmn=M7{DS!X~MGn6Q11gw|46I;x@g@dV%!c9kN#Mk-46Ua-6gbx1BbT@wJoKx5K4VfqmL?8r9FUF%U!JZV7qTk5JPo`P_O96_5=n5>f{@Itv~!XgS-=_BZdK(DW*P6WY)eKFblBaJ~v zU(~^Csossh3=?a)WFaF@vK?6JtDc+IP*7%Q6yC9S{S*HYC*G_RJMq7>i4#N{5Hul8OVvZ#29c%`NJ!RVubWWEHnZzg zjSLMEAX6C;^$8^{98!>|5aJM7hyy)PA#tJ-g&racM7e-CfLs9*LV$R)j!mHOM*h4r z@4atlzIkuIIQi?m`>M;;#i6 zS6vreFMDd9s%NJ!P~~gRDvo;8GUDhSMKTRv&V}e0B9-Bg5VW^h6ZIFm&zs3O@V;wg z6t4SHWDI`vO_Bu|5g)HFBnU|%$Mr0Cl4CzvfMb%Mmz{J3&Pn@WTk6Gkej<(IJAaWL>UjbawXYG@xE;5* zmTz))IOG?J4IcNe!uS4oxQFxf80+?FblwGYynb*0L6bCr95SI{wh6p+hWYkij&36PTZzWL`c?m9sKWnRYbEV394`Sw{M)rGlohLx#{= zn&xn}8inn+zxjB!D8&?%L0s<{wQ6Df#S>#E|Q9oFbBt8s+0EO;;3aYiQZlJRj(SuW+VgwhoE zsO@3)_93&iisNtQ@Gi5V&|S=Pm<>ei$4&Au5bBav_R#eYAsrTD)q`{ohy1+(+|<7+ z=oEYy>xZji46O0{;Y1`-cZDm&`T)`_&`CSqG+m*3!>%u4SQZc0uq+slbP3(^uFy`UoLwrWTS5Pj=rN31O&Jos80`(5 z!>QIpK)oHF+EkNs+oyI0Le(R+K?*+tmD|?A#Ck|=X@RuI>?sLo}M7BZZgjurRR}X zwopSU>!PA5x=xKnx`rP5JVL{wWHM?=Z%ZMlD{4XSXaHOB{jm!er?LCSQ@1`KUpc(% z6PwaaN92|x(&S9`5T5=3R`YOTc2;KGOnpOR%F3Uzx}~h%C@T%hWToo}4Ocpy$t#+c zQS self.noise_threshold: self.update_plot(spectrum, max_magnitude) @@ -103,7 +105,7 @@ def update_plot(self, spectrum, max_magnitude): self.ax.clear() self.ax.plot(freq_bins, spectrum, color=self.color) self.ax.set_xlim(self.frequency_range) - self.ax.set_ylim(0, max_magnitude * 1.8) + self.ax.set_ylim(0, max_magnitude * 0.5) self.ax.set_xlabel('Frequency (Hz)') self.ax.set_ylabel('Magnitude') self.ax.set_title('Audio Spectrum Visualization') @@ -121,8 +123,9 @@ def set_block_size(self, value): def toggle_visualization(self): if self.running: self.running = False - self.stream.stop() - self.stream.close() + if self.stream is not None: + self.stream.stop() + self.stream.close() self.start_button.setText('Start Visualization') else: self.running = True @@ -137,7 +140,7 @@ def toggle_visualization(self): def closeEvent(self, event): self.running = False - if hasattr(self, 'stream'): + if self.stream is not None: self.stream.stop() self.stream.close() event.accept() From 10175f386b196bdf13a5988b43b317104d47691d Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Thu, 23 May 2024 14:53:22 +0530 Subject: [PATCH 18/20] Bins length wait --- .../__pycache__/main.cpython-311.pyc | Bin 10707 -> 10707 bytes Audio_SpectraCLI/main.py | 2 +- tests/test.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc index 809a4783c1a26d7d0af9d3719429c958d25cff36..3f1117e19b76fddd15299f8e7b8fefea03e20ce0 100644 GIT binary patch delta 32 kcmcZ{d^wnFIWI340}wpt+{jfb!+!P*2>jXHCgaNs0KLKt*#H0l delta 32 kcmcZ{d^wnFIWI340}vQ6Y~(7HVFxi87#?hHlkw#R0D)@ Date: Thu, 23 May 2024 14:56:03 +0530 Subject: [PATCH 19/20] Good to go. --- .../__pycache__/main.cpython-311.pyc | Bin 10707 -> 10714 bytes Audio_SpectraCLI/main.py | 6 +++--- tests/test.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc b/Audio_SpectraCLI/__pycache__/main.cpython-311.pyc index 3f1117e19b76fddd15299f8e7b8fefea03e20ce0..9e0d144c74d1d45bed44aa149f6cd2ceb04282dd 100644 GIT binary patch delta 312 zcmcZ{d@GoDIWI340}!-v`=<$R=45qOm35LXW}TDd`_l@F>A87 ztSnmwP^Lr_25zLI)o1K)+nAjRYE^C@xr}|Gm8^i>eR^$yLd_jaihzJ4^6E@FQb7JIf0kM@p SMAzgO>gO02Zr-jT!w3L!AyJ0_ delta 307 zcmcZ=d^wnRIWI340}wpt^iSj8$SW_-$Ts<+qR3=NammTt?3|O6#T6L^C%200%5s8~ zfj|w@GDZf5)j$jZwag`=lh2E*i*mz6vROc^BC#5V1w3HWX&9fw5GqImN0|I|0_sF<2vQNG$QzM@V)P0LHtthoHJ}EP=xEN%d0uU7G zfs9R`Tp(*H>Nm-6fyom44URil_ONgCz9`~wMZ{tAKH1rfj1`lkOc7`upuDA8$|em2!9X}1S0x3FH&=2i_@% diff --git a/Audio_SpectraCLI/main.py b/Audio_SpectraCLI/main.py index 6c25d3c..b3a4a8b 100644 --- a/Audio_SpectraCLI/main.py +++ b/Audio_SpectraCLI/main.py @@ -91,7 +91,7 @@ def process_audio(self): while self.running: if not self.audio_queue.empty(): audio_block = self.audio_queue.get() - spectrum = np.abs(np.fft.fft( + spectrum = np.abs(np.fft.rfft( audio_block[:, 0], n=self.block_size)) spectrum = gaussian_filter1d( spectrum, sigma=2) # Apply smoothing filter @@ -101,11 +101,11 @@ def process_audio(self): self.update_plot(spectrum, max_magnitude) def update_plot(self, spectrum, max_magnitude): - freq_bins = np.fft.fftfreq(self.block_size, 1 / self.fs) + freq_bins = np.fft.rfftfreq(self.block_size, 1 / self.fs) self.ax.clear() self.ax.plot(freq_bins, spectrum, color=self.color) self.ax.set_xlim(self.frequency_range) - self.ax.set_ylim(0, max_magnitude * 1.8) + self.ax.set_ylim(0, max_magnitude * 0.5) self.ax.set_xlabel('Frequency (Hz)') self.ax.set_ylabel('Magnitude') self.ax.set_title('Audio Spectrum Visualization') diff --git a/tests/test.py b/tests/test.py index abc9c51..60ae315 100644 --- a/tests/test.py +++ b/tests/test.py @@ -4,7 +4,7 @@ # Create an instance of AudioSpectrumVisualizer with custom parameters app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( - duration=5, fs=22050, block_size=1024, frequency_range=(50, 2000), color='red') + duration=5, fs=22050, block_size=1024, frequency_range=(1000, 5000), color='red') # Start the audio spectrum visualization audio_visualizer.show() From 2938617e93ad736e5315b7f8a97c5c48c8f25feb Mon Sep 17 00:00:00 2001 From: AdityaSeth777 Date: Thu, 23 May 2024 17:27:11 +0530 Subject: [PATCH 20/20] Ready - v4.0 --- Readme.md | 11 ++++------- tests/test.py | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Readme.md b/Readme.md index 87e66fc..1ca2d82 100644 --- a/Readme.md +++ b/Readme.md @@ -37,7 +37,7 @@ - Seamless integration with SoundDevice for audio input capture. - Customizable Frequency Range: Allow users to specify the frequency range to display in the spectrum. - Color Customization: Provide options for users to customize the colors used in the spectrum visualization. -- Added PyQt5 modules that enables user input for Duration (in seconds), Sampling Rate (in Hz), and Block Size. +- Added PyQt5 modules and a Gaussian filter that enables user input for Duration (in seconds), Sampling Rate (in Hz), Block Size, and also smoothens the output. - Much more dynamic and user-controlled interface. ## Packaging @@ -88,11 +88,10 @@ from PyQt5.QtWidgets import QApplication # Creating an instance of AudioSpectrumVisualizer with custom parameters app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( - duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') + duration=5, fs=22050, block_size=1024, frequency_range=(1000, 5000), color='red') # Starting the audio spectrum visualization audio_visualizer.show() -audio_visualizer.start_visualization() app.exec_() ``` @@ -134,11 +133,10 @@ from PyQt5.QtWidgets import QApplication # Creating an instance of AudioSpectrumVisualizer with custom parameters app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( - duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') + duration=5, fs=22050, block_size=1024, frequency_range=(1000, 5000), color='red') # Starting the audio spectrum visualization audio_visualizer.show() -audio_visualizer.start_visualization() app.exec_() ``` @@ -185,11 +183,10 @@ from PyQt5.QtWidgets import QApplication # Creating an instance of AudioSpectrumVisualizer with custom parameters app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( - duration=10, fs=22050, block_size=8192, frequency_range=(2000, 5000), color='green') + duration=5, fs=22050, block_size=1024, frequency_range=(1000, 5000), color='red') # Starting the audio spectrum visualization audio_visualizer.show() -audio_visualizer.start_visualization() app.exec_() ``` diff --git a/tests/test.py b/tests/test.py index 60ae315..0caa280 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,11 +1,11 @@ from Audio_SpectraCLI import AudioSpectrumVisualizer from PyQt5.QtWidgets import QApplication -# Create an instance of AudioSpectrumVisualizer with custom parameters +# Creating an instance of AudioSpectrumVisualizer with custom parameters app = QApplication([]) audio_visualizer = AudioSpectrumVisualizer( duration=5, fs=22050, block_size=1024, frequency_range=(1000, 5000), color='red') -# Start the audio spectrum visualization +# Starting the audio spectrum visualization audio_visualizer.show() app.exec_()