.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Aborted (core dumped)
(venv) m@m:~/Downloads/musicpython/имитациявинила$ QT_QPA_PLATFORM=wayland 
(venv) m@m:~/Downloads/musicpython/имитациявинила$ python3 vini.py 
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Aborted (core dumped)
(venv) m@m:~/Downloads/musicpython/имитациявинила$ QT_QPA_PLATFORM=wayland python3 vini.py
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Aborted (core dumped)
(venv) m@m:~/Downloads/musicpython/имитациявинила$ QT_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/qt5/plugins QT_QPA_PLATFORM=xcb python3 vini.py
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Aborted (core dumped)
(venv) m@m:~/Downloads/musicpython/имитациявинила$ 

передкелай скрипт import sys
import numpy as np
import librosa
import soundfile as sf
from scipy import signal
from PyQt5 import QtWidgets, QtGui, QtCore

class VinylEmulator(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()
        self.init_ui()

    def init_ui(self):
        # Заголовок окна
        self.setWindowTitle('Vinyl Sound Emulator')
        self.setGeometry(100, 100, 400, 300)
        self.setFixedSize(400, 300)

        # Шрифты
        font_label = QtGui.QFont('Arial', 10)
        font_button = QtGui.QFont('Arial', 10)

        # Поля для выбора файлов
        self.input_label = QtWidgets.QLabel('Выберите входной FLAC файл:', self)
        self.input_label.setFont(font_label)
        self.input_label.move(20, 20)

        self.input_button = QtWidgets.QPushButton('Обзор...', self)
        self.input_button.setFont(font_button)
        self.input_button.move(250, 15)
        self.input_button.clicked.connect(self.select_input_file)

        self.output_label = QtWidgets.QLabel('Выберите имя выходного FLAC файла:', self)
        self.output_label.setFont(font_label)
        self.output_label.move(20, 60)

        self.output_button = QtWidgets.QPushButton('Сохранить как...', self)
        self.output_button.setFont(font_button)
        self.output_button.move(250, 55)
        self.output_button.clicked.connect(self.select_output_file)

        # Поля для отображения путей файлов
        self.input_path = QtWidgets.QLineEdit(self)
        self.input_path.setGeometry(20, 45, 350, 20)
        self.input_path.setReadOnly(True)

        self.output_path = QtWidgets.QLineEdit(self)
        self.output_path.setGeometry(20, 85, 350, 20)
        self.output_path.setReadOnly(True)

        # Кнопка запуска обработки
        self.process_button = QtWidgets.QPushButton('Начать обработку', self)
        self.process_button.setFont(font_button)
        self.process_button.move(140, 120)
        self.process_button.clicked.connect(self.process_audio)

        # Прогресс бар
        self.progress_bar = QtWidgets.QProgressBar(self)
        self.progress_bar.setGeometry(50, 160, 300, 20)
        self.progress_bar.setVisible(False)

        # Сообщение об успешном завершении
        self.status_label = QtWidgets.QLabel('', self)
        self.status_label.setFont(font_label)
        self.status_label.setGeometry(50, 190, 300, 20)
        self.status_label.setAlignment(QtCore.Qt.AlignCenter)

        self.show()

    def select_input_file(self):
        options = QtWidgets.QFileDialog.Options()
        file_name, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Выберите входной FLAC файл", "", "FLAC Files (*.flac);;All Files (*)", options=options)
        if file_name:
            self.input_path.setText(file_name)

    def select_output_file(self):
        options = QtWidgets.QFileDialog.Options()
        file_name, _ = QtWidgets.QFileDialog.getSaveFileName(self, "Сохранить выходной файл как", "", "FLAC Files (*.flac);;All Files (*)", options=options)
        if file_name:
            # Проверка, содержит ли имя файла расширение .flac
            if not file_name.lower().endswith('.flac'):
                file_name += '.flac'
            self.output_path.setText(file_name)

    def process_audio(self):
        input_file = self.input_path.text()
        output_file = self.output_path.text()

        if not input_file or not output_file:
            QtWidgets.QMessageBox.warning(self, 'Ошибка', 'Пожалуйста, выберите входной и выходной файлы.')
            return

        self.progress_bar.setVisible(True)
        self.progress_bar.setValue(0)
        self.status_label.setText('')

        # Запуск обработки в отдельном потоке
        QtCore.QTimer.singleShot(100, lambda: self.run_processing(input_file, output_file))

    def run_processing(self, input_file, output_file):
        try:
            y, sr = librosa.load(input_file, sr=None)
            total_steps = 5
            current_step = 0

            # Применяем виниловый эквалайзер
            y = apply_vinyl_eq(y, sr)
            current_step += 1
            self.progress_bar.setValue(int(current_step / total_steps * 100))

            # Добавляем эффект "wow" и "flutter"
            y = add_wow_and_flutter(y, sr)
            current_step += 1
            self.progress_bar.setValue(int(current_step / total_steps * 100))

            # Добавляем гармонические искажения
            y = add_harmonic_distortion(y, sr)
            current_step += 1
            self.progress_bar.setValue(int(current_step / total_steps * 100))

            # Добавляем сатурацию ленты
            y = add_tape_saturation(y, sr)
            current_step += 1
            self.progress_bar.setValue(int(current_step / total_steps * 100))

            # Динамическая компрессия
            y = apply_dynamic_compression(y, sr)
            current_step += 1
            self.progress_bar.setValue(int(current_step / total_steps * 100))

            # Нормализуем аудио
            y = y / np.max(np.abs(y))

            # Сохраняем обработанный файл во FLAC
            sf.write(output_file, y, sr, subtype='PCM_16')
            self.status_label.setText('Обработка завершена успешно!')
        except Exception as e:
            QtWidgets.QMessageBox.critical(self, 'Ошибка', f'Произошла ошибка при обработке аудио: {e}')
            self.status_label.setText('Ошибка при обработке.')
        finally:
            self.progress_bar.setVisible(False)

# Функции обработки аудио
def apply_vinyl_eq(y, sr):
    # Эквализация для имитации частотной характеристики винила
    # Усиливаем низкие и средние частоты, уменьшаем высокие
    b, a = signal.butter(4, 8000 / (sr / 2), btype='low')
    y = signal.filtfilt(b, a, y)
    return y

def add_wow_and_flutter(y, sr, wow_rate=0.5, wow_depth=0.003, flutter_rate=10, flutter_depth=0.0005):
    # Эффект "wow" и "flutter"
    t = np.arange(len(y)) / sr
    wow = np.sin(2 * np.pi * wow_rate * t) * wow_depth
    flutter = np.sin(2 * np.pi * flutter_rate * t) * flutter_depth
    modulation = wow + flutter
    # Изменяем фазу сигнала
    y_modulated = np.interp(t + modulation, t, y)
    return y_modulated

def add_harmonic_distortion(y, sr, gain=2.0, mix=0.7):
    # Гармонические искажения (ламповая сатурация)
    y_distorted = np.tanh(y * gain)
    y = mix * y_distorted + (1 - mix) * y
    return y

def add_tape_saturation(y, sr, threshold=0.6, ratio=2.0):
    # Сатурация ленты
    y_saturated = y.copy()
    y_saturated[y > threshold] = threshold + (y[y > threshold] - threshold) / ratio
    y_saturated[y < -threshold] = -threshold + (y[y < -threshold] + threshold) / ratio
    return y_saturated

def apply_dynamic_compression(y, sr, threshold=-20, ratio=4, makeup_gain=5):
    # Динамическая компрессия
    # Переводим в dB
    y_db = 20 * np.log10(np.abs(y) + 1e-6)
    max_db = np.max(y_db)
    # Применяем компрессию
    y_db_compressed = np.where(y_db > threshold, threshold + (y_db - threshold) / ratio, y_db)
    # Добавляем makeup gain
    y_db_compressed += makeup_gain
    # Ограничиваем максимальное значение
    y_db_compressed = np.clip(y_db_compressed, -80, max_db)
    # Возвращаемся в линейную шкалу
    y_compressed = np.sign(y) * (10 ** (y_db_compressed / 20))
    return y_compressed

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    window = VinylEmulator()
    sys.exit(app.exec_())