Wednesday, December 25, 2024

Does it help or hurt for subs out of phase?

 https://www.youtube.com/watch?v=2veYdDtfJPM

This video is about how to improve the sound of your home theater system. The speaker, Paul McGowan, discusses how to run subwoofers out of phase with the mains. He says that this can help to reduce bass cancellations and standing waves in small rooms. He also recommends using a nearfield subwoofer setup, which can help to improve bass response in problematic rooms. Finally, he suggests looking for his new book, "The Audiophile's Guide to Subwoofers," which will be available in December.


Tuesday, December 24, 2024

Jetbrain's AI Assistant as a helper in PyCharm

 I was recently writing a project in PyCharm that downloaded large video files. I wanted to have a typical progress meter as the download progressed.

I asked this question to the AI Assistant "calculate time left based on start time, current time, total size and current size".

This is the response that it generated.

To calculate the time left for a download based on the start time, current time, total size, and the current size of the file downloaded, you can use the following approach:

Use the Formula

  1. Determine the elapsed time:

    • Elapsed time can be calculated by subtracting the start_time from the current_time.
  2. Calculate the download speed:

    • Download speed is current_size / elapsed_time.
  3. Calculate the remaining size:

    • Remaining size is total_size - current_size.
  4. Estimate the time left:

    • Time left is remaining_size / download_speed.

Here is a Python code snippet implementing this logic:

import time



def calculate_time_left(start_time, current_time, total_size, current_size):

    # Elapsed time in seconds

    elapsed_time = current_time - start_time


    # Avoid division by zero

    if elapsed_time == 0:

        return "Calculating..."


    # Download speed in size per second

    download_speed = current_size / elapsed_time


    # Remaining size

    remaining_size = total_size - current_size


    # Estimate time left in seconds

    if download_speed > 0:

        time_left = remaining_size / download_speed

    else:

        return "Speed is too slow to calculate time left"


    # Return time left in a human-readable format

    minutes, seconds = divmod(time_left, 60)

    return f"{int(minutes)} minutes {int(seconds)} seconds left"


Saturday, August 12, 2023

Follow me on mastodon

Follow me on mastodon 

FLET: A python GUI based on Flutter

I am always on the lookout for new (easier) ways to create GUIs for python. Recently I ran across the FLET. Also available on github.

Their description is

The fastest way to build Flutter apps in Python

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.

As an experiment I decided to create a simple login form.

import flet as ft

def main(page: ft.Page):
page.title = "Login"
page.window_height = 200
page.window_width = 500
page.window_always_on_top = True

def cancel_click(e):
page.window_destroy()

def login_click(e):
if txt_user.value == "admin" and txt_pwd.value == "admin":
dlg.content = ft.Text("Login Successful")
else:
dlg.content = ft.Text("Login failed")
dlg.modal = False
dlg.open = True
dlg.update()
page.update()

dlg = ft.AlertDialog(title=ft.Text("Login"), content=ft.Text("---"))
txt_user = ft.TextField(value = "", label="User ID")
txt_pwd = ft.TextField(value = "", password=True, can_reveal_password=True,
label="Password")
btn_cancel = ft.FilledButton(text="Cancel", on_click=cancel_click)
btn_login = ft.FilledButton(text="Login", on_click=login_click)
action_row = ft.Row(controls=[btn_cancel, btn_login])
page.add(txt_user, txt_pwd, action_row, dlg)
page.window_center()

ft.app(target=main)

  This results in the following window


A jupyter notebook is here.


Monday, October 1, 2018