Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,961 changes: 4,961 additions & 0 deletions Stretch Markers/GabrielSchuck_reawarp.lua

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "add_beat"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "analyze"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "retempo"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "del_beat"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "double"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "bpm"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "halve"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "match"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "nudge_left"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "nudge_right"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "move_beat"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "next_beat"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "prev_beat"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "qsettings"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "quantize"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "restore"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "downbeat"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "settings"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "shift"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "tempo"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- @noindex
-- Generated by reawarp.lua. Do not edit: all the code is in reawarp.lua.
REAWARP_ACTION = "warp"
dofile(debug.getinfo(1, "S").source:match("^@?(.*[\\/])") .. "../../GabrielSchuck_reawarp.lua")
121 changes: 121 additions & 0 deletions Stretch Markers/GabrielSchuck_reawarp/backend/install_beat_this.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
@echo off
rem reawarp - installs the Beat This! beat detector in this folder.
rem No Python installation is needed: uv downloads a private Python here.
rem Copyright (C) 2026 Gabriel Schuck. GPL-3.0-or-later (see LICENSE).
rem Arguments: [gpu^|cpu] [auto]
rem gpu: PyTorch for NVIDIA graphics cards (about 2.5 GB); cpu: about 300 MB.
rem Without one it keeps the kind already installed (cpu on a new install).
rem auto: started by reawarp. The window closes at the end and reawarp shows the
rem result (install_status.txt: "ok <device>" or "fail"). The details of every
rem step go to install.log.
setlocal
set "KIND=%~1"
set "AUTO=%~2"
if /i "%KIND%"=="auto" (set "KIND=" & set "AUTO=auto")
cd /d "%~dp0"
set "LOG=%CD%\install.log"
set "STATUS=%CD%\install_status.txt"
if exist "%STATUS%" del "%STATUS%"
echo reawarp: Beat This! installation> "%LOG%"
call :say reawarp: installing the Beat This! beat detector.
call :say This downloads about 350 MB and needs about 1 GB of disk space
call :say (the version for NVIDIA graphics cards: about 2.5 GB, and 3 GB of disk).
call :say Everything goes inside this folder; no Python installation is needed.
if /i "%AUTO%"=="auto" call :say This window closes by itself when the installation ends.
echo.

set "UV_VERSION=0.12.20"
set "UV_TARGET=x86_64-pc-windows-msvc"
if /i "%PROCESSOR_ARCHITECTURE%"=="ARM64" set "UV_TARGET=aarch64-pc-windows-msvc"
set "UV=%CD%\uv\uv.exe"
rem keep uv's Python, cache and tools inside this folder, and never use a system Python
set "UV_PYTHON_INSTALL_DIR=%CD%\python"
set "UV_CACHE_DIR=%CD%\uvcache"
set "UV_PYTHON_PREFERENCE=only-managed"
set "UV_NO_CONFIG=1"
rem Windows' own tar (it opens .zip files; another tar on the PATH may not)
set "TAR=tar"
if exist "%SystemRoot%\System32\tar.exe" set "TAR=%SystemRoot%\System32\tar.exe"

if not exist "%UV%" (
call :say Downloading uv %UV_VERSION%...
if not exist uv mkdir uv
curl -L --fail -sS -o "uv\uv.zip" "https://github.com/astral-sh/uv/releases/download/%UV_VERSION%/uv-%UV_TARGET%.zip" >> "%LOG%" 2>&1 || goto fail
"%TAR%" -xf "uv\uv.zip" -C uv >> "%LOG%" 2>&1 || goto fail
del "uv\uv.zip"
)
if not exist "%UV%" goto fail

rem --allow-existing keeps the installed packages and repairs an env whose folder was moved
call :say Installing Python...
"%UV%" venv env --python 3.12 --allow-existing >> "%LOG%" 2>&1 || goto fail
rem the PyTorch build installed now: cpu, a CUDA version, or none
set "CUR="
for /f "delims=" %%v in ('env\Scripts\python.exe -c "import torch; print(torch.version.cuda or 0)" 2^>nul') do set "CUR=%%v"
if "%CUR%"=="0" set "CUR=cpu"
if not defined KIND (
set "KIND=cpu"
if defined CUR if /i not "%CUR%"=="cpu" set "KIND=keep"
)
set "INDEX=cpu"
if /i "%KIND%"=="gpu" call :cuda_index
set "REINSTALL="
if /i "%KIND%"=="keep" goto torch_install
if /i "%INDEX%"=="cpu" (
if defined CUR if /i not "%CUR%"=="cpu" set "REINSTALL=--reinstall-package torch --reinstall-package torchaudio"
) else (
if /i "%CUR%"=="cpu" set "REINSTALL=--reinstall-package torch --reinstall-package torchaudio"
)
:torch_install
if /i "%KIND%"=="keep" (
call :say PyTorch for the GPU is already installed.
) else (
if /i "%INDEX%"=="cpu" (call :say Installing PyTorch for the CPU...) else (call :say Installing PyTorch for the NVIDIA GPU [%INDEX%], about 2.5 GB. This takes a while...)
"%UV%" pip install --python "env\Scripts\python.exe" torch torchaudio --index-url https://download.pytorch.org/whl/%INDEX% %REINSTALL% >> "%LOG%" 2>&1 || goto fail
)
call :say Installing Beat This!...
"%UV%" pip install --python "env\Scripts\python.exe" beat-this==1.1.0 >> "%LOG%" 2>&1 || goto fail
call :say Downloading the model...
"env\Scripts\python.exe" reawarp_beat_this.py --download >> "%LOG%" 2>&1 || goto fail
set "DEVICE=cpu"
for /f "delims=" %%d in ('env\Scripts\python.exe reawarp_beat_this.py --device 2^>nul') do set "DEVICE=%%d"
if exist uvcache rmdir /s /q uvcache
call :say Done. Beat This! runs on: %DEVICE%.
echo ok %DEVICE%> "%STATUS%"
rem started by reawarp (cmd /k): "exit" closes the window too
if /i "%AUTO%"=="auto" exit 0
echo.
pause
exit /b 0

:say
rem a progress line, on the screen and in the log
echo %*
>> "%LOG%" echo %*
goto :eof

:cuda_index
rem the newest CUDA build that the NVIDIA driver supports
set "DRV="
for /f "tokens=1 delims=." %%a in ('nvidia-smi --query-gpu^=driver_version --format^=csv^,noheader 2^>nul') do if not defined DRV set "DRV=%%a"
if not defined DRV (
call :say No NVIDIA graphics card found: installing the CPU version.
goto :eof
)
if %DRV% GEQ 580 (set "INDEX=cu130" & goto :eof)
if %DRV% GEQ 570 (set "INDEX=cu128" & goto :eof)
if %DRV% GEQ 560 (set "INDEX=cu126" & goto :eof)
call :say The NVIDIA driver is too old for the GPU version: installing the CPU version.
goto :eof

:fail
rem (the download cache stays, so a retry does not download everything again)
call :say The installation failed. It needs an internet connection; you can run it again to retry.
echo fail> "%STATUS%"
if /i "%AUTO%"=="auto" exit 1
echo.
echo Details:
type "%LOG%"
echo.
pause
exit /b 1
125 changes: 125 additions & 0 deletions Stretch Markers/GabrielSchuck_reawarp/backend/install_beat_this.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/bin/sh
# reawarp - installs the Beat This! beat detector in this folder.
# No Python installation is needed: uv downloads a private Python here.
# Copyright (C) 2026 Gabriel Schuck. GPL-3.0-or-later (see LICENSE).
# Arguments: [gpu|cpu] [auto]
# gpu: PyTorch for NVIDIA graphics cards (Linux, about 2.5 GB); cpu: about 300 MB.
# Without one it keeps the kind already installed (cpu on a new install).
# On macOS the standard build is used: it also runs on the GPU of Apple silicon.
# auto: started by reawarp. The window closes at the end and reawarp shows the
# result (install_status.txt: "ok <device>" or "fail"). The details of every
# step go to install.log.
cd "$(dirname "$0")" || exit 1
HERE=$(pwd)
# macOS Terminal cannot pass arguments to a script: reawarp leaves them here
if [ $# -eq 0 ] && [ -f "$HERE/install_args.txt" ]; then
# shellcheck disable=SC2046
set -- $(cat "$HERE/install_args.txt")
rm -f "$HERE/install_args.txt"
fi
KIND="${1:-}"
AUTO="${2:-}"
if [ "$KIND" = auto ]; then KIND=""; AUTO=auto; fi
LOG="$HERE/install.log"
STATUS="$HERE/install_status.txt"
rm -f "$STATUS"
echo "reawarp: Beat This! installation" > "$LOG"

say() { # a progress line, on the screen and in the log
echo "$*"
echo "$*" >> "$LOG"
}

finish() {
# nothing here writable by everyone (folders synced to the cloud, as with
# MEGA, refuse 777): 775 for folders, 664 for files
chmod -R o-w "$HERE" 2>/dev/null
if [ "$AUTO" != auto ]; then
if [ "$1" != 0 ]; then echo; echo "Details:"; cat "$LOG"; fi
echo
printf 'Press Enter to close. '
read -r _
fi
exit "$1"
}

say "reawarp: installing the Beat This! beat detector."
say "This downloads about 350 MB and needs about 1 GB of disk space"
say "(the version for NVIDIA graphics cards: about 2.5 GB, and 3 GB of disk)."
say "Everything goes inside this folder; no Python installation is needed."
if [ "$AUTO" = auto ]; then say "This window closes by itself when the installation ends."; fi
echo

UV_VERSION=0.12.20
case "$(uname -s)-$(uname -m)" in
Darwin-arm64) TARGET=aarch64-apple-darwin ;;
Darwin-x86_64) TARGET=x86_64-apple-darwin ;;
Linux-x86_64) TARGET=x86_64-unknown-linux-gnu ;;
Linux-aarch64 | Linux-arm64) TARGET=aarch64-unknown-linux-gnu ;;
*) say "Unsupported system: $(uname -s) $(uname -m)"; echo fail > "$STATUS"; finish 1 ;;
esac
# keep uv's Python, cache and tools inside this folder, and never use a system Python
export UV_PYTHON_INSTALL_DIR="$HERE/python"
export UV_CACHE_DIR="$HERE/uvcache"
export UV_PYTHON_PREFERENCE=only-managed
export UV_NO_CONFIG=1
UV="$HERE/uv/uv"

set -e
# (the download cache stays after a failure, so a retry does not download everything again)
trap 'say "The installation failed. It needs an internet connection; you can run it again to retry."; echo fail > "$STATUS"; finish 1' EXIT
if [ ! -x "$UV" ]; then
say "Downloading uv $UV_VERSION..."
mkdir -p uv
URL="https://github.com/astral-sh/uv/releases/download/$UV_VERSION/uv-$TARGET.tar.gz"
if command -v curl >/dev/null 2>&1; then curl -L --fail -sS -o uv/uv.tar.gz "$URL" >> "$LOG" 2>&1
else wget -q -O uv/uv.tar.gz "$URL" >> "$LOG" 2>&1; fi
tar -xzf uv/uv.tar.gz -C uv --strip-components=1 >> "$LOG" 2>&1
rm uv/uv.tar.gz
fi
# --allow-existing keeps the installed packages and repairs an env whose folder was moved
say "Installing Python..."
"$UV" venv env --python 3.12 --allow-existing >> "$LOG" 2>&1
if [ "$(uname -s)" = "Darwin" ]; then
say "Installing PyTorch..."
"$UV" pip install --python env/bin/python torch torchaudio >> "$LOG" 2>&1
else
CUR=$(env/bin/python -c "import torch; print(torch.version.cuda or 'cpu')" 2>/dev/null || true)
if [ -z "$KIND" ]; then
if [ -n "$CUR" ] && [ "$CUR" != cpu ]; then KIND=keep; else KIND=cpu; fi
fi
INDEX=cpu
if [ "$KIND" = gpu ]; then
# the newest CUDA build that the NVIDIA driver supports
DRV=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null | head -n 1 | cut -d. -f1 || true)
case "$DRV" in
'' | *[!0-9]*) say "No NVIDIA graphics card found: installing the CPU version." ;;
*) if [ "$DRV" -ge 580 ]; then INDEX=cu130
elif [ "$DRV" -ge 570 ]; then INDEX=cu128
elif [ "$DRV" -ge 560 ]; then INDEX=cu126
else say "The NVIDIA driver is too old for the GPU version: installing the CPU version."
fi ;;
esac
fi
if [ "$KIND" = keep ]; then
say "PyTorch for the GPU is already installed."
else
REINSTALL=""
if [ "$INDEX" = cpu ] && [ -n "$CUR" ] && [ "$CUR" != cpu ]; then REINSTALL="--reinstall-package torch --reinstall-package torchaudio"; fi
if [ "$INDEX" != cpu ] && [ "$CUR" = cpu ]; then REINSTALL="--reinstall-package torch --reinstall-package torchaudio"; fi
if [ "$INDEX" = cpu ]; then say "Installing PyTorch for the CPU..."
else say "Installing PyTorch for the NVIDIA GPU ($INDEX), about 2.5 GB. This takes a while..."; fi
# shellcheck disable=SC2086
"$UV" pip install --python env/bin/python torch torchaudio --index-url "https://download.pytorch.org/whl/$INDEX" $REINSTALL >> "$LOG" 2>&1
fi
fi
say "Installing Beat This!..."
"$UV" pip install --python env/bin/python beat-this==1.1.0 >> "$LOG" 2>&1
say "Downloading the model..."
env/bin/python reawarp_beat_this.py --download >> "$LOG" 2>&1
DEVICE=$(env/bin/python reawarp_beat_this.py --device 2>/dev/null || echo cpu)
rm -rf uvcache
trap - EXIT
say "Done. Beat This! runs on: $DEVICE."
echo "ok $DEVICE" > "$STATUS"
finish 0
Loading