Skip to main content

CTkVisualizer


A Visualizer that actually represents the Audio that's playing.

alt text

Inspired from Akascape's TkVisualizer

Install it by running: pip install CTkVisualizer (Verify that you're atleast running with Version 1.0.3)


Disclaimer

  • This Widget is absolutely unfriendly to Integrate since it doesn't just Visualize Audio (what you might expect), it also plays it using pygame.mixer. Unfortunately, this makes it do more than what a Widget is supposed to do. Usually you'd want to handle the Audio Playing seperately, and not in some GUI Widget. I wasn't able to implement it any other way. I tried my best to compensate for it by providing Audio Control Methods with the Widget natively, like pause(), resume() and set_volume()

  • This Widget has serious Problems with vertical Resizing! Horizontal Resizing works like a Charm, the Bars get thicker, but vertically, the Bars will get "chopped off"

  • This Widget has been tested with WAVE files (.wav) and MPEG3 Files (.mp3), both worked fine.


Quick Overview

This Overview just helps you get started quickly.

  • play_new_song(self, path_to_WAVE_file: str, finish_callback=None)

    • Loads and plays a new audio file while stopping any currently playing song.
    • Parameters:
      • path_to_WAVE_file: The path to the new audio file.
      • finish_callback: A callback to execute when the song finishes loading (default is None).
    • [!] You would most likely want to run this Threaded for performance reasons!
  • pause(self)

    • Pauses the currently playing audio.
  • play(self)

    • Resumes playback of the paused audio.
  • resume(self)

    • Resumes playback of the audio if it was paused.
  • is_playing(self)

    • Checks if audio is currently playing.
    • Returns: True if audio is playing, False otherwise.
  • change_color(self, color)

    • Changes the color of all audio bars.
    • Parameters:
      • color: The new RGB color for the audio bars.
  • get_music_filename(self)

    • Gets the base filename of the currently loaded music file.
    • Returns: The base filename of the music file without extension, or None if no file is loaded.
  • set_volume(self, volume: float)

    • Sets the volume for the currently playing audio.
    • Parameters:
      • volume: A float value representing the volume level, where 0.0 is muted and 1.0 is the maximum volume.
    • Raises: ValueError if the volume is not between 0.0 and 1.0.

Quick Overview - Quickstart

import customtkinter as ctk
from CTkVisualizer import AudioVisualizer

# Create the main application window
root = ctk.CTk()
root.title("Audio Visualizer")

# Initialize the audio visualizer
visualizer = AudioVisualizer(root, "path/to/your/audio/file.wav")
visualizer.pack(expand=True, fill="both")

# Run the application
root.mainloop()

Quick Overview - Try the Demo!

If you want a quick and practical overview of how it works, you can look at AudioMusicVisualizerDemo.py - There I also added some Buttons to change the Color of the Bars or Play/Pause the Song.


If you have any suggestions or if you happen to find any Bugs, please report them by opening an Issue

If you like this Project, feel free to help me out by leaving a Star or Sponsoring me! ⭐

Lastly, if you made anything cool with this Project, please tell me! I'd love to see it. Just open an Issue about it or tell me via Discord: @ilollek


Metadata

Release files for CTkVisualizer 1.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for CTkVisualizer 1.0.8
File Size Uploaded
CTkVisualizer-1.0.8.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for CTkVisualizer 1.0.8
File Interpreter ABI Platform
CTkVisualizer-1.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / CTkVisualizer-1.0.8.tar.gz

Download URL CTkVisualizer-1.0.8.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
63dfebb642c9232721196b1862119fb2683d70c76730aff99fea1f8f6a827e70
BLAKE2b-256 checksum
How to use checksums
c9e02e2f155e7cab67192aee994bb6fb60d7cd43b69c107d064de22c5172d9b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / CTkVisualizer-1.0.8-py3-none-any.whl

Download URL CTkVisualizer-1.0.8-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb497265c358f991c041e7e87a388117a8c09968ecf97d83afdaab5e351e5996
BLAKE2b-256 checksum
How to use checksums
31b3fc3f67b704f066201f2e397de5b844ea52caa3bf586a1e2c435be00cf862
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release history Release notifications | RSS feed

This release

1.0.8 This release

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page