Skip to main content

A customtkinter widget for playing and visualizing Audio.

Project description

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


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CTkVisualizer-1.0.4.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

CTkVisualizer-1.0.4-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file CTkVisualizer-1.0.4.tar.gz.

File metadata

  • Download URL: CTkVisualizer-1.0.4.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for CTkVisualizer-1.0.4.tar.gz
Algorithm Hash digest
SHA256 bedc0cea2fc6edd3dad88569271ff8772974a160c681f4c1e5d2662d3d50f4d8
MD5 e581cef2f3580d89c92146ba23d12dcc
BLAKE2b-256 88be2f8db43b39cbeb5bf19d6f2b2bac57842cc1c213f96ea8edbd680b27291e

See more details on using hashes here.

File details

Details for the file CTkVisualizer-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: CTkVisualizer-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for CTkVisualizer-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 90733e1a2730a0db49dcca27911f042c800ca3cfe2c9586145c9e8ad80119884
MD5 1419454c68053b0f2df9b954ff1ee460
BLAKE2b-256 75ccefbc534e02d0b6c738f03ce676ef69e9cbaac1f3424deb9f3995489477b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page