{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "ldVF6dMTbqB7" }, "source": [ "#Beat Manipulator" ] }, { "cell_type": "code", "source": [ "#@title 1. Run this cell to install all necessary libraries. This only needs to be done once each time you open this collab.\n", "import shutil, os\n", "try:\n", " if os.path.exists('BeatManipulator'): shutil.rmtree('BeatManipulator', ignore_errors=True)\n", "except: pass\n", "!pip install numpy cython soundfile ffmpeg-python pedalboard librosa\n", "!pip install madmom\n", "!git clone https://github.com/stunlocked1/BeatManipulator\n", "%cd BeatManipulator\n", "import beat_manipulator as bm" ], "metadata": { "id": "E-gDjnzBby5-", "cellView": "form" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "FYVs2fGzbqB9" }, "source": [ "***\n", "Use cells below as many times as you wish. Pattern syntax, scale and shift are explained here https://github.com/stunlocked1/BeatManipulator\n", "\n", "Enter pattern, scale and shift, run the cell, and it will let you upload your audio file.\n", "\n", "Analyzing beats for the first time will take some time, but if you open the same file for the second time, it will load a saved beat map." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "TFOLf-vrbqB-", "cellView": "form" }, "outputs": [], "source": [ "#@title 2. Beatswapping. Enter pattern, scale and shift, run the cell, and it will let you upload your audio file.\n", "pattern = \"1, 3, 2, 4\" #@param {type:\"string\"}\n", "scale = 1 #@param {type:\"number\"}\n", "shift = 0 #@param {type:\"number\"}\n", "\n", "pattern_length = None # Length of the pattern. If None, this will be inferred from the highest number in the pattern\n", "\n", "\n", "import beat_manipulator as bm, IPython\n", "from google.colab import files\n", "uploaded = list(files.upload().keys())[0]\n", "path = bm.beatswap(audio=uploaded, pattern = pattern, scale = scale, shift = shift, length = pattern_length)\n", "IPython.display.Audio(path)" ] }, { "cell_type": "markdown", "source": [ "***\n", "## Other stuff\n", "Those operate the same as the above cell" ], "metadata": { "id": "fQVrYbQ_rQzm" } }, { "cell_type": "markdown", "source": [ "**Song to image**\n", "\n", "creates an image based on beat positions. Each song will generate a unique image. The image will be a square, you can specify maximum size.` " ], "metadata": { "id": "7gc2jbelrTMb" } }, { "cell_type": "code", "source": [ "#@title Song to image\n", "image_size = 512 #@param {type:\"integer\"}\n", "\n", "\n", "import beat_manipulator as bm, IPython\n", "from google.colab import files\n", "uploaded = list(files.upload().keys())[0]\n", "path = bm.image(audio=uploaded, max_size = image_size)\n", "IPython.display.Image(path)" ], "metadata": { "id": "M2ufXQaxrWZT", "cellView": "form" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "***\n", "**osu! beatmap generator**\n", "\n", "generates an osu! beatmap from your song. This generates a hitmap, probabilities of hits at each sample, picks all ones above a threshold, and turns them into osu circles, trying to emulate actual osu beatmap. This doesn't generate sliders, however, because no known science has been able to comprehend the complexity of those.\n", "\n", "The .osz file will be downloaded automatically, open with osu! to install like any other beatmap." ], "metadata": { "id": "bqOYyiCisAjM" } }, { "cell_type": "code", "source": [ "difficulties = [0.2, 0.1, 0.05, 0.025, 0.01, 0.0075, 0.005, 0.0025, 0.0001] # all difficulties will be embedded in one beatmap, Lower is typically harder, but not always.\n", "\n", "\n", "import beat_manipulator.osu\n", "from google.colab import files\n", "uploaded = list(files.upload().keys())[0]\n", "path = beat_manipulator.osu.generate(song=uploaded, difficulties = difficulties)\n", "files.download(f'/content/BeatManipulator/{path}')" ], "metadata": { "id": "T1wLIS1_sB_K" }, "execution_count": null, "outputs": [] } ], "metadata": { "kernelspec": { "display_name": "audio310", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.9" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "f56da36b984886453ea677d340712034d0bd218b2dc7a53ab7c38da0c6f67f35" } }, "colab": { "provenance": [] } }, "nbformat": 4, "nbformat_minor": 0 }