Skip to content

Instantly share code, notes, and snippets.

View francescopapaleo's full-sized avatar

Francesco Papaleo francescopapaleo

View GitHub Profile
@francescopapaleo
francescopapaleo / utility-torch.py
Created November 12, 2024 08:56
Lambda functions with Torch for basic DSP conversions
import torch
torch.pi = torch.acos(torch.zeros(1)).item() * 2 # which is 3.1415927410125732
db_to_mag = lambda x: 10 ** (x / 20)
mag_to_db = lambda x: 20 * torch.log10(x)
import random
from PIL import Image
def split_image(image, tile_size):
"""Split the image into square tiles and store their original positions."""
width, height = image.size
tiles = []
positions = []
for y in range(0, height, tile_size):
import json
def convert_bookmarks(json_file, html_file):
with open(json_file, 'r', encoding='utf-8') as f:
bookmarks = json.load(f)
def parse_node(node):
if 'children' in node:
if node['type'] == 'folder':
folder_html = f"<DT><H3>{node['name']}</H3>\n<DL><p>\n"
@francescopapaleo
francescopapaleo / find_files.py
Last active February 26, 2024 09:12
Find all files with a given extension in a directory recursively and return a list.
def find_files(start_path: str, extensions: List[str] = AUDIO_EXTENSIONS) -> List[str]:
"""Finds all audio files in a directory recursively.
Returns a list.
Parameters
----------
folder : str
Folder to look for audio files in, recursively.
ext : List[str], optional
Extensions to look for without the ., by default
"""Hardware latency measurement using sounddevice API
Copyright (C) 2024 Francesco Papaleo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@francescopapaleo
francescopapaleo / torch_signal_generator.py
Last active February 22, 2024 16:43
A class to generate various types of audio signals directly as PyTorch tensors.
"""
Torch Signal Generator Class
Copyright (C) 2024 Francesco Papaleo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@francescopapaleo
francescopapaleo / idmt-smt-audio-effects-readme.md
Created December 5, 2023 13:31
Encoding scheme for the IDMT-SMT-AUDIO-EFFECTS dataset
Encoding Scheme for Monophonic Sounds

A - Instrument Type
    B - Bass
    G - Guitar

B - Instrument Setting
    1 - Yamaha BB604, 1st setting
    2 - Yamaha BB604, 2nd setting
#!/bin/bash
# bash_profile
echo "export CLICOLOR=1" >> ~/.bash_profile
echo "export LSCOLORS=GxFxCxDxBxegedabagaced" >> ~/.bash_profile
echo "export TERM="xterm-color"" >> ~/.bash_profile
echo "export PS1='\[\e[0;33m\]\u\[\e[0m\]@\[\e[0;32m\]\h\[\e[0m\]:\[\e[0;34m\]\w\[\e[0m\]\$ '" >> ~/.bash_profile
exec bash -l