Full Code of wzk1015/video-bgm-generation for AI

main 0158632d9b48 cached
117 files
870.0 KB
229.4k tokens
1500 symbols
1 requests
Download .txt
Showing preview only (915K chars total). Download the full file or copy to clipboard to get everything.
Repository: wzk1015/video-bgm-generation
Branch: main
Commit: 0158632d9b48
Files: 117
Total size: 870.0 KB

Directory structure:
gitextract_53lrthg8/

├── .gitignore
├── CMT.ipynb
├── LICENSE
├── README.md
├── dataset/
│   └── .gitkeep
├── exp/
│   └── .gitkeep
├── inference/
│   └── .gitkeep
├── logs/
│   └── .gitkeep
├── py3_requirements.txt
├── src/
│   ├── dictionary_mix.py
│   ├── gen_midi_conditional.py
│   ├── match.py
│   ├── midi2mp3.py
│   ├── midi2numpy_mix.py
│   ├── model.py
│   ├── numpy2midi_mix.py
│   ├── pianoroll2midi.py
│   ├── train.py
│   ├── utils.py
│   └── video2npz/
│       ├── dictionary_mix.py
│       ├── metadata2numpy_mix.py
│       ├── optical_flow.py
│       ├── resize_video.py
│       ├── resize_videos.sh
│       ├── stat_mix.py
│       ├── video2metadata.py
│       ├── video2npz.sh
│       └── visbeat3/
│           ├── LICENSE
│           ├── MANIFEST.in
│           ├── README.md
│           ├── VisBeatAssets/
│           │   └── VideoSources/
│           │       └── wzk_vlog_beat_enhance1_track1238/
│           │           ├── Data/
│           │           │   ├── Backups/
│           │           │   │   └── VideoSource.json
│           │           │   └── Features/
│           │           │       └── video/
│           │           │           └── directogram_powers/
│           │           │               └── wzk_vlog_beat_enhance1_track1238_maxheight_360.pkl
│           │           └── VideoSource.json
│           ├── bin/
│           │   └── dancefer
│           ├── build/
│           │   ├── lib/
│           │   │   └── visbeat3/
│           │   │       ├── ADefines.py
│           │   │       ├── AFileManager.py
│           │   │       ├── AFuncDict.py
│           │   │       ├── AImports.py
│           │   │       ├── AObject.py
│           │   │       ├── AParamDict.py
│           │   │       ├── Audio.py
│           │   │       ├── AudioClip.py
│           │   │       ├── Event.py
│           │   │       ├── EventList.py
│           │   │       ├── Image.py
│           │   │       ├── Image_CV.py
│           │   │       ├── SourceLocationParser.py
│           │   │       ├── TimeSignal.py
│           │   │       ├── TimeSignal1D.py
│           │   │       ├── VBMIDI.py
│           │   │       ├── VBObject.py
│           │   │       ├── Video.py
│           │   │       ├── VideoClip.py
│           │   │       ├── VideoSource.py
│           │   │       ├── Video_CV.py
│           │   │       ├── VisBeatDefines.py
│           │   │       ├── VisBeatExampleVideo.py
│           │   │       ├── VisBeatImports.py
│           │   │       ├── VisualBeat.py
│           │   │       ├── Warp.py
│           │   │       ├── __init__.py
│           │   │       ├── _dancefer_examples.py
│           │   │       ├── _dancify_examples.py
│           │   │       ├── _mediafiles.py
│           │   │       ├── _music_examples.py
│           │   │       ├── command_line.py
│           │   │       ├── fileui/
│           │   │       │   ├── __init__.py
│           │   │       │   └── uipath.py
│           │   │       └── vbgui/
│           │   │           ├── BeatGUI.py
│           │   │           └── __init__.py
│           │   └── scripts-3.7/
│           │       └── dancefer
│           ├── dist/
│           │   └── visbeat3-0.0.8-py3.7.egg
│           ├── setup.cfg
│           ├── setup.py
│           ├── test.py
│           ├── visbeat3/
│           │   ├── ADefines.py
│           │   ├── AFileManager.py
│           │   ├── AFuncDict.py
│           │   ├── AImports.py
│           │   ├── AObject.py
│           │   ├── AParamDict.py
│           │   ├── Audio.py
│           │   ├── AudioClip.py
│           │   ├── Event.py
│           │   ├── EventList.py
│           │   ├── Image.py
│           │   ├── Image_CV.py
│           │   ├── SourceLocationParser.py
│           │   ├── TimeSignal.py
│           │   ├── TimeSignal1D.py
│           │   ├── VBMIDI.py
│           │   ├── VBObject.py
│           │   ├── Video.py
│           │   ├── VideoClip.py
│           │   ├── VideoSource.py
│           │   ├── Video_CV.py
│           │   ├── VisBeatDefines.py
│           │   ├── VisBeatExampleVideo.py
│           │   ├── VisBeatImports.py
│           │   ├── VisualBeat.py
│           │   ├── Warp.py
│           │   ├── __init__.py
│           │   ├── _dancefer_examples.py
│           │   ├── _dancify_examples.py
│           │   ├── _mediafiles.py
│           │   ├── _music_examples.py
│           │   ├── command_line.py
│           │   ├── fileui/
│           │   │   ├── __init__.py
│           │   │   └── uipath.py
│           │   └── vbgui/
│           │       ├── BeatGUI.py
│           │       └── __init__.py
│           └── visbeat3.egg-info/
│               ├── PKG-INFO
│               ├── SOURCES.txt
│               ├── dependency_links.txt
│               ├── requires.txt
│               └── top_level.txt
└── videos/
    └── .gitkeep

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
/logs/*.log
/exp/*/
/inference/*.npz
/inference/*.mid
#!/inference/wzk.npz
/src_no_pos/
/src/*.jpg
/src/*.npz
!/src/midi2mp3.py
/src/metadata.json
/dataset/*.npz
/dataset/json_*/
/src/video2npz/VisBeatAssets/
/src/video2npz/image/*
/src/video2npz/examples/*
/src/video2npz/fig/*
/src/video2npz/flow/*
/src/video2npz/optical_flow/*

.DS_Store
__pycache__/
*.pt
.idea/
/new/
*.mp4
*.mp3
*.m4a
*.pyc
cookies.txt
metadata.json
*.sf2


================================================
FILE: CMT.ipynb
================================================
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "CMT.ipynb",
      "private_outputs": true,
      "provenance": [],
      "collapsed_sections": [],
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/wzk1015/video-bgm-generation/blob/develop/CMT.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# **Demo of Controllable Music Transformer**\n",
        "\n",
        "We provide a colab notebook for running inference with CMT. You can upload a video and generate a background music using this notebook."
      ],
      "metadata": {
        "id": "Qx-JUsBYpv3X"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "# 1. Preparation"
      ],
      "metadata": {
        "id": "iGsKCYiR8ZBy"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Clone the repo"
      ],
      "metadata": {
        "id": "t34LcwtQGq7_"
      }
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "YMTYugKn6NNp"
      },
      "outputs": [],
      "source": [
        "import os\n",
        "from google.colab import files\n",
        "import json\n",
        "\n",
        "os.chdir('/content')\n",
        "!git clone https://github.com/wzk1015/video-bgm-generation\n",
        "os.chdir('/content/video-bgm-generation')"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "Download checkpoint and soundfont\n",
        "\n"
      ],
      "metadata": {
        "id": "X9ZN2EbvG9J4"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "!gsutil -m cp gs://cmt/loss_8_params.pt /content/video-bgm-generation/exp/\n",
        "!gsutil -m cp gs://magentadata/soundfonts/SGM-v2.01-Sal-Guit-Bass-V1.3.sf2 /content/video-bgm-generation/"
      ],
      "metadata": {
        "id": "c7XER9vH8mfb"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Install dependencies"
      ],
      "metadata": {
        "id": "b4RRCIybl7_I"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "!apt-get update && apt-get install libfluidsynth1 build-essential libasound2-dev libjack-dev fluidsynth"
      ],
      "metadata": {
        "id": "efg5Ya8cJL5o"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "!pip install --upgrade pip\n",
        "# this may take ~15 minutes\n",
        "!pip install pytorch-fast-transformers==0.3.0\n",
        "# Note: Version of pytorch-fast-transformers is tricky - depends on your randomly assigned colab GPU, it could be 0.3.0 or 0.4.0 or others.\n",
        "# Incorrect fast-transformers version could lead to Errors or generating awful results for unknown reasons,\n",
        "# so you should try different versions, or refer to https://github.com/idiap/fast-transformers\n",
        "\n",
        "!pip install -r py3_requirements.txt\n",
        "os.chdir(\"/content/video-bgm-generation/src/video2npz/visbeat3/\")\n",
        "!python setup.py install"
      ],
      "metadata": {
        "id": "SkRSrynzSrA-"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# 2. Process input video"
      ],
      "metadata": {
        "id": "ygRjsNf5F0FT"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Upload your video\n",
        "\n",
        "It is recommended to use videos **less than 2 minutes**, otherwise it gets really slow"
      ],
      "metadata": {
        "id": "QMS5SlFOrVv-"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "os.chdir(\"/content/video-bgm-generation/\")\n",
        "uploaded = files.upload()\n",
        "assert len(uploaded) == 1, \"upload one video file only\"\n",
        "filename = list(uploaded.keys())[0]\n",
        "os.system(f'mv {filename} videos/test_raw.mp4')"
      ],
      "metadata": {
        "id": "gczMG7TyQYCC"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Convert to 360p to speed up extracting optical flow and visbeats"
      ],
      "metadata": {
        "id": "dR5dCMo5qfk-"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "os.chdir(\"/content/video-bgm-generation/videos/\")\n",
        "!rm test.mp4\n",
        "!ffmpeg -i test_raw.mp4 -strict -2 -vf scale=-1:360 test.mp4"
      ],
      "metadata": {
        "id": "RzRrVu9RqTZ6"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Extracting optical flow and visbeats, convert video into npz file"
      ],
      "metadata": {
        "id": "sgm_TOq7QYXn"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "os.chdir(\"/content/video-bgm-generation/src/video2npz/\")\n",
        "!rm -r VisBeatAssets/ fig/ flow/ image/ optical_flow/\n",
        "!bash video2npz.sh ../../videos/test.mp4\n",
        "# extracting optical flow and visbeats may be slow"
      ],
      "metadata": {
        "id": "y_l8VDLFFE-c"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# 3. Run the model to generate background music"
      ],
      "metadata": {
        "id": "-JASD-zxJZJt"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Run inference to generate MIDI (.mid) output"
      ],
      "metadata": {
        "id": "TpZnfeIsHhyM"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "os.chdir(\"/content/video-bgm-generation/src/\")\n",
        "!python gen_midi_conditional.py -f \"../inference/test.npz\" -c \"../exp/loss_8_params.pt\" -n 1"
      ],
      "metadata": {
        "id": "Xxus1H-XGHXj"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Convert midi into audio: use **GarageBand (recommended)** or midi2audio\n",
        "\n",
        "Remember to **set tempo to the value of tempo in video2npz/metadata.json**"
      ],
      "metadata": {
        "id": "pR3rUJWIJnVp"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "os.chdir(\"/content/video-bgm-generation/src/\")\n",
        "files.download('../inference/test.npz_0.mid')\n",
        "\n",
        "with open(\"video2npz/metadata.json\") as f:\n",
        "    tempo = json.load(f)['tempo']\n",
        "    print(\"tempo:\", tempo)"
      ],
      "metadata": {
        "id": "lKR7qWinMUFM"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Generate audio with midi2audio\n",
        "\n",
        "Instead of running this cell, we recommend using GarageBand or other softwares, since their soundfonts are better. But this also works fine"
      ],
      "metadata": {
        "id": "GzEb08C4ovjD"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import note_seq\n",
        "from pretty_midi import PrettyMIDI\n",
        "import midi2audio\n",
        "import numpy as np\n",
        "import io\n",
        "import scipy\n",
        "\n",
        "SAMPLE_RATE = 16000\n",
        "SF2_PATH = '/content/video-bgm-generation/SGM-v2.01-Sal-Guit-Bass-V1.3.sf2'\n",
        "os.chdir(\"/content/video-bgm-generation/inference/\")\n",
        "\n",
        "input_mid = 'test.npz_0.mid'\n",
        "midi_obj = PrettyMIDI(input_mid)\n",
        "# convert tempo\n",
        "midi_length = midi_obj.get_end_time()\n",
        "midi_obj.adjust_times([0, midi_length], [0, midi_length*120/tempo])\n",
        "processed_mid = input_mid[:-4] + \"_processed.mid\"\n",
        "midi_obj.write(processed_mid)\n",
        "print(\"converting into mp3\")\n",
        "fs = midi2audio.FluidSynth(SF2_PATH, sample_rate=SAMPLE_RATE)\n",
        "fs.midi_to_audio(processed_mid, \"music.mp3\")\n",
        "\n",
        "print(\"playing music\")\n",
        "ns = note_seq.midi_io.midi_to_note_sequence(midi_obj)\n",
        "note_seq.play_sequence(ns, synth=note_seq.fluidsynth, sample_rate=SAMPLE_RATE, sf2_path=SF2_PATH)\n",
        "note_seq.plot_sequence(ns)\n",
        "  "
      ],
      "metadata": {
        "id": "fZHzA0UtKDWa"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Combine original video and audio into video with BGM\n",
        "\n",
        "Generate/upload the audio file under `inference`, name it as `music.mp3`, and run this to combine video and music"
      ],
      "metadata": {
        "id": "KKObBCKBKlU1"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "os.chdir(\"/content/video-bgm-generation/inference/\")\n",
        "!rm output.mp4\n",
        "!ffmpeg -i ../videos/test_raw.mp4 -i music.mp3 -c:v copy -c:a aac -strict experimental -map 0:v:0 -map 1:a:0 output.mp4\n",
        "files.download('output.mp4')"
      ],
      "metadata": {
        "id": "SqNLXFzmLPjP"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}

================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2021 Shangzhe Di

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
# Controllable Music Transformer

Official code for our paper *Video Background Music Generation with Controllable Music Transformer* (ACM MM 2021 **Best Paper Award**) 

[[Paper]](https://arxiv.org/abs/2111.08380) [[Project Page]](https://wzk1015.github.io/cmt/) [[Colab Demo]](https://colab.research.google.com/github/wzk1015/video-bgm-generation/blob/main/CMT.ipynb)



## News

[2025.3] **Take a look at our survey on vision-to-music generation, published in ISMIR 2025 ([Paper](https://arxiv.org/abs/2503.21254), [Repo](https://github.com/wzk1015/Awesome-Vision-to-Music-Generation))**, with the latest methods, datasets and evaluation in video-to-music and image-to-music generation.

[2024.12] 🚀🚀 **Check out our new [paper](https://github.com/wbs2788/VMB/tree/main) for multimodal music generation!** We propose a novel multimodal music generation approach with explicit text and music bridges for video-to-music, image-to-music, text-to-music, and controllable music generation tasks.

[2023.9] **Check out our new [ICCV 2023 paper](https://arxiv.org/abs/2211.11248) for video background music generation.** We provide a video and symbolic music dataset with rich annotations, an objective metric for video-music correspondence, and a benchmark model that utilizes music priors of chords, melody, and accompaniment along with video-music relations of semantic, color, and motion features.

[2022.5] **We provide a [colab notebook](https://colab.research.google.com/github/wzk1015/video-bgm-generation/blob/main/CMT.ipynb) for demo!** You can run inference code and generate background music for your input video.

[2021.10] 🏆 We won the **ACM MM 2021 [Best Paper Award](https://www.wzk.plus/award_imgs/mm.jpg)**!

## Introduction

We address the unexplored task – *video background music generation*. We first establish three rhythmic relations between video and background music. We then propose a **C**ontrollable **M**usic **T**ransformer (CMT) to achieve local and global control of the music generation process. Our proposed method does not require paired video and music data for training while generating melodious and compatible music with the given video. 

![](https://raw.githubusercontent.com/wzk1015/wzk1015.github.io/master/cmt/img/head.png)



## Directory Structure

* `src/`: code of the whole pipeline
  * `train.py`: training script, take an npz file as input music data to train the model 
  * `model.py`: code of the model
  * `gen_midi_conditional.py`: inference script, take an npz file (represents a video) as input to generate several songs
  
  * `midi2mp3.py`: script of converting midi into mp3
  
  * `src/video2npz/`: convert video into npz by extracting motion saliency and motion speed
* `dataset/`: processed dataset for training, in the format of npz
* `logs/`: logs that automatically generated during training, can be used to track the training process
* `exp/`: checkpoints, named after val loss (e.g. `loss_8_params.pt`)
* `inference/`: processed video for inference (.npz), and generated music(.mid) 




## Preparation

* Clone this repo

* Download the processed training data `lpd_5_prcem_mix_v8_10000.npz`  from [HERE](https://drive.google.com/file/d/19f_DytIbEiSDCwz8FPpScrHqmnqNtVYT/view?usp=sharing) and put it under `dataset/` 

* Download the pre-trained model `loss_8_params.pt` from [HERE](https://drive.google.com/file/d/1KvIRRm0KqTlEFDjAgs4fMtLRQBq0rBWy/view?usp=sharing) and put it under `exp/` 

* Install `ffmpeg=3.2.4` 

* Install Python3 dependencies `pip install -r py3_requirements.txt`

  * Choose the correct version of `torch` and `pytorch-fast-transformers` based on your CUDA version (see [fast-transformers repo](https://github.com/idiap/fast-transformers) and [this issue](https://github.com/wzk1015/video-bgm-generation/issues/3))

* Install `visbeat3` package: `cd src/video2npz/visbeat3; python setup.py install`

* (Optional) If you want to convert midi into mp3 with midi2audio:

  * Install fluidsynth following [this](https://github.com/FluidSynth/fluidsynth/wiki/Download)
  * Download soundfont `SGM-v2.01-Sal-Guit-Bass-V1.3.sf2` from [HERE](https://drive.google.com/file/d/1zDg0P-0rCXDl_wX4zeLcKRNmOFobq6u8/view?usp=sharing) and put it directly under this folder (`video-bgm-generation`)

  

## Training

- A quick start by using the processed data `lpd_5_prcem_mix_v8_10000.npz` (1~2 days on 8x 1080Ti GPUs):

  ```shell
  python train.py --name train_default -b 8 --gpus 0 1 2 3 4 5 6 7
  ```

* (Optional) If you want to reproduce the whole process:

  1. Download the lpd-5-cleansed dataset from [HERE](https://drive.google.com/file/d/1AzLZ4fHrcek1rVNlOC3pzxsMaNSITZsG/view?usp=sharing) and put the extracted files under `dataset/lpd_5_cleansed/`

  2. Go to `src/` and convert the pianoroll files (.npz) to midi files (~3 files / sec):

     ```shell
     python pianoroll2midi.py --in_dir ../dataset/lpd_5_cleansed/ --out_dir ../dataset/lpd_5_cleansed_midi/
     ```

  3. Convert midi files to .npz files with our proposed representation (~5 files / sec):

       ```shell
       python midi2numpy_mix.py --midi_dir ../dataset/lpd_5_cleansed_midi/ --out_name data.npz 
       ```

  4. Train the model (1~2 days on 8x 1080Ti GPUs):

      ```shell
      python train.py --name train_exp --train_data ../dataset/data.npz -b 8 --gpus 0 1 2 3 4 5 6 7
      ```

**Note:** If you want to train with another MIDI dataset, please ensure that each track belongs to one of the five instruments (Drums, Piano, Guitar, Bass, or Strings) and is named exactly with its instrument. Otherwise, you may have to change the track names in the MIDI files. You can check this with [Muspy](https://salu133445.github.io/muspy/):

```python
import muspy
midi = muspy.read_midi('xxx.mid')
print([track.name for track in midi.tracks]) # Should be like ['Drums', 'Guitar', 'Bass', 'Strings']
```



## Inference

Inference requires one GPU. You can try our [colab notebook](https://colab.research.google.com/github/wzk1015/video-bgm-generation/blob/main/CMT.ipynb) to run inference.

It is recommended to use videos *less than 2 minutes*, otherwise, it gets really slow

* Resize the video into 360p

  ```shell
  ffmpeg -i xxx.mp4 -strict -2 -vf scale=-1:360 test.mp4
  ```

* Convert input video (MP4 format) into npz

  ```shell
  cd src/video2npz
  sh video2npz.sh ../../videos/test.mp4
  ```
  
* Run model to generate `.mid` : 

  ```shell
  python gen_midi_conditional.py -f "../inference/test.npz" -c "../exp/loss_8_params.pt" -n 5
  
  # If using another training set, change `decoder_n_class` in `gen_midi_conditional` to the one in `train.py`
  ```

* Convert midi into audio

  * Get tempo of the music: 

  * ```python
     # metadata.json is generated when running `video2npz.sh`
    with open("video2npz/metadata.json") as f:
        tempo = json.load(f)['tempo']
        print("tempo:", tempo)
    ```
  * (A) Use GarageBand to convert midi into audio

    * this is **recommended** since their soundfonts are better, and no need to install fluidsynth and soundfonts
    * remember to set tempo

  * (B) Use midi2audio

    ```shell
    # Make sure you have installed fluidsynth and downloaded soundfont
    python midi2mp3.py --input ../inference/get_0.mid --output ../inference/get_0.mp3
    ```

* Combine original video and audio into video with BGM:

  ````shell
  ffmpeg -i test.mp4 -i get_0.mp3 -c:v copy -c:a aac -strict experimental -map 0:v:0 -map 1:a:0 output.mp4
  
  # test.mp4: input video
  # get_0.mp3: audio file generated in the previous step
  # output.mp4: output video with BGM
  ````



## Matching Method

The matching method finds the five most matching music pieces from the music library for a given video.

```shell
python src/match.py inference/test.npz dataset/lpd_5_prcem_mix_v8_10000.npz
```



## Citation

```bibtex
@inproceedings{di2021video,
  title={Video Background Music Generation with Controllable Music Transformer},
  author={Di, Shangzhe and Jiang, Zeren and Liu, Si and Wang, Zhaokai and Zhu, Leyan and He, Zexin and Liu, Hongming and Yan, Shuicheng},
  booktitle={ACM Multimedia},
  year={2021}
}

@inproceedings{zhuo2023video,
  title={Video background music generation: Dataset, method and evaluation},
  author={Zhuo, Le and Wang, Zhaokai and Wang, Baisen and Liao, Yue and Bao, Chenxi and Peng, Stanley and Han, Songhao and Zhang, Aixi and Fang, Fei and Liu, Si},
  booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
  pages={15637--15647},
  year={2023}
}

@article{vmb,
  title={Multimodal Music Generation with Explicit Bridges and Retrieval Augmentation},
  author={Wang, Baisen and Zhuo, Le and Wang, Zhaokai and Bao, Chenxi and Wu, Chengjing and Nie, Xuecheng and Dai, Jiao and Han, Jizhong and Liao, Yue and Liu, Si},
  journal={arXiv preprint arXiv:2412.09428},
  year={2024}
}

@inproceedings{wang2025vision,
  title={Vision-to-Music Generation: A Survey},
  author={Wang, Zhaokai and Bao, Chenxi and Zhuo, Le and Han, Jingrui and Yue, Yang and Tang, Yihong and Huang, Victor Shea-Jay and Liao, Yue},
  booktitle={ISMIR},
  year={2025}
}
```



## Acknowledgements

Our code is based on [Compound Word Transformer](https://github.com/YatingMusic/compound-word-transformer).

`src/video2npz/visbeat3` is built upon [haofanwang/visbeat3](https://github.com/haofanwang/visbeat3) and the original [visbeat](http://abedavis.com/visualbeat/).


================================================
FILE: dataset/.gitkeep
================================================


================================================
FILE: exp/.gitkeep
================================================


================================================
FILE: inference/.gitkeep
================================================


================================================
FILE: logs/.gitkeep
================================================


================================================
FILE: py3_requirements.txt
================================================
tqdm
urllib3==1.26.9
six==1.16.0
threadpoolctl==2.1.0
h5py==2.10.0
matplotlib==3.3.4
numpy==1.23.1
miditoolkit==0.1.15
muspy==0.4.0
scikit_learn==1.0
torch==1.9.0
pytorch-fast-transformers
opencv-python==4.5.3.56
scikit-video==1.1.11
pypianoroll
scipy
bs4
librosa==0.6.2
imageio==2.9.0
requests
moviepy==1.0.3
termcolor==1.1.0
youtube-dl==2021.12.17
numba==0.48.0
pretty_midi
pyfluidsynth==1.2.5
note_seq
midi2audio


================================================
FILE: src/dictionary_mix.py
================================================
preset_event2word = {
    "tempo"     : {
        0          : 0,
        "CONTI"    : 1,
        "Tempo_0"  : 2,
        "Tempo_1"  : 3,
        "Tempo_2"  : 4,
        "Tempo_3"  : 5,
        "Tempo_4"  : 6,
        "Tempo_5"  : 7,
        "Tempo_6"  : 8,
        "Tempo_7"  : 9,
        "Tempo_8"  : 10,
        "Tempo_9"  : 11,
        "Tempo_10" : 12,
        "Tempo_11" : 13,
        "Tempo_12" : 14,
        "Tempo_13" : 15,
        "Tempo_14" : 16,
        "Tempo_15" : 17,
        "Tempo_16" : 18,
        "Tempo_17" : 19,
        "Tempo_18" : 20,
        "Tempo_19" : 21,
        "Tempo_20" : 22,
        "Tempo_21" : 23,
        "Tempo_22" : 24,
        "Tempo_23" : 25,
        "Tempo_24" : 26,
        "Tempo_25" : 27,
        "Tempo_26" : 28,
        "Tempo_27" : 29,
        "Tempo_28" : 30,
        "Tempo_29" : 31,
        "Tempo_30" : 32,
        "Tempo_31" : 33,
        "Tempo_32" : 34,
        "Tempo_33" : 35,
        "Tempo_34" : 36,
        "Tempo_35" : 37,
        "Tempo_36" : 38,
        "Tempo_37" : 39,
        "Tempo_38" : 40,
        "Tempo_39" : 41,
        "Tempo_40" : 42,
        "Tempo_41" : 43,
        "Tempo_42" : 44,
        "Tempo_43" : 45,
        "Tempo_44" : 46,
        "Tempo_45" : 47,
        "Tempo_46" : 48,
        "Tempo_47" : 49,
        "Tempo_48" : 50,
        "Tempo_49" : 51,
        "Tempo_50" : 52,
        "Tempo_51" : 53,
        "Tempo_52" : 54,
        "Tempo_53" : 55,
        "Tempo_54" : 56,
        "Tempo_55" : 57,
        "Tempo_56" : 58,
        "Tempo_57" : 59,
        "Tempo_58" : 60,
        "Tempo_59" : 61,
        "Tempo_60" : 62,
        "Tempo_61" : 63,
        "Tempo_62" : 64,
        "Tempo_63" : 65,
        "Tempo_64" : 66,
        "Tempo_65" : 67,
        "Tempo_66" : 68,
        "Tempo_67" : 69,
        "Tempo_68" : 70,
        "Tempo_69" : 71,
        "Tempo_70" : 72,
        "Tempo_71" : 73,
        "Tempo_72" : 74,
        "Tempo_73" : 75,
        "Tempo_74" : 76,
        "Tempo_75" : 77,
        "Tempo_76" : 78,
        "Tempo_77" : 79,
        "Tempo_78" : 80,
        "Tempo_79" : 81,
        "Tempo_80" : 82,
        "Tempo_81" : 83,
        "Tempo_82" : 84,
        "Tempo_83" : 85,
        "Tempo_84" : 86,
        "Tempo_85" : 87,
        "Tempo_86" : 88,
        "Tempo_87" : 89,
        "Tempo_88" : 90,
        "Tempo_89" : 91,
        "Tempo_90" : 92,
        "Tempo_91" : 93,
        "Tempo_92" : 94,
        "Tempo_93" : 95,
        "Tempo_94" : 96,
        "Tempo_95" : 97,
        "Tempo_96" : 98,
        "Tempo_97" : 99,
        "Tempo_98" : 100,
        "Tempo_99" : 101,
        "Tempo_100": 102,
        "Tempo_101": 103,
        "Tempo_102": 104,
        "Tempo_103": 105,
        "Tempo_104": 106,
        "Tempo_105": 107,
        "Tempo_106": 108,
        "Tempo_107": 109,
        "Tempo_108": 110,
        "Tempo_109": 111,
        "Tempo_110": 112,
        "Tempo_111": 113,
        "Tempo_112": 114,
        "Tempo_113": 115,
        "Tempo_114": 116,
        "Tempo_115": 117,
        "Tempo_116": 118,
        "Tempo_117": 119,
        "Tempo_118": 120,
        "Tempo_119": 121,
        "Tempo_120": 122,
        "Tempo_121": 123,
        "Tempo_122": 124,
        "Tempo_123": 125,
        "Tempo_124": 126,
        "Tempo_125": 127,
        "Tempo_126": 128,
        "Tempo_127": 129,
        "Tempo_128": 130,
        "Tempo_129": 131,
        "Tempo_130": 132,
        "Tempo_131": 133,
        "Tempo_132": 134,
        "Tempo_133": 135,
        "Tempo_134": 136,
        "Tempo_135": 137,
        "Tempo_136": 138,
        "Tempo_137": 139,
        "Tempo_138": 140,
        "Tempo_139": 141,
        "Tempo_140": 142,
        "Tempo_141": 143,
        "Tempo_142": 144,
        "Tempo_143": 145,
        "Tempo_144": 146,
        "Tempo_145": 147,
        "Tempo_146": 148,
        "Tempo_147": 149,
        "Tempo_148": 150,
        "Tempo_149": 151,
        "Tempo_150": 152,
        "Tempo_151": 153,
        "Tempo_152": 154,
        "Tempo_153": 155,
        "Tempo_154": 156,
        "Tempo_155": 157,
        "Tempo_156": 158,
        "Tempo_157": 159,
        "Tempo_158": 160,
        "Tempo_159": 161,
        "Tempo_160": 162,
        "Tempo_161": 163,
        "Tempo_162": 164,
        "Tempo_163": 165,
        "Tempo_164": 166,
        "Tempo_165": 167,
        "Tempo_166": 168,
        "Tempo_167": 169,
        "Tempo_168": 170,
        "Tempo_169": 171,
        "Tempo_170": 172,
        "Tempo_171": 173,
        "Tempo_172": 174,
        "Tempo_173": 175,
        "Tempo_174": 176,
        "Tempo_175": 177,
        "Tempo_176": 178,
        "Tempo_177": 179,
        "Tempo_178": 180,
        "Tempo_179": 181,
        "Tempo_180": 182,
        "Tempo_181": 183,
        "Tempo_182": 184,
        "Tempo_183": 185,
        "Tempo_184": 186,
        "Tempo_185": 187,
        "Tempo_186": 188,
        "Tempo_187": 189,
        "Tempo_188": 190,
        "Tempo_189": 191,
        "Tempo_190": 192,
        "Tempo_191": 193,
        "Tempo_192": 194,
        "Tempo_193": 195,
        "Tempo_194": 196,
        "Tempo_195": 197,
        "Tempo_196": 198,
        "Tempo_197": 199,
        "Tempo_198": 200,
        "Tempo_199": 201,
        "Tempo_200": 202,
        "Tempo_201": 203,
        "Tempo_202": 204,
        "Tempo_203": 205,
        "Tempo_204": 206,
        "Tempo_205": 207,
        "Tempo_206": 208,
        "Tempo_207": 209,
        "Tempo_208": 210,
        "Tempo_209": 211,
        "Tempo_210": 212,
        "Tempo_211": 213,
        "Tempo_212": 214,
        "Tempo_213": 215,
        "Tempo_214": 216,
        "Tempo_215": 217,
        "Tempo_216": 218,
        "Tempo_217": 219,
        "Tempo_218": 220,
        "Tempo_219": 221,
        "Tempo_220": 222,
        "Tempo_221": 223,
        "Tempo_222": 224,
        "Tempo_223": 225,
        "Tempo_224": 226,
        "Tempo_225": 227,
        "Tempo_226": 228,
        "Tempo_227": 229,
        "Tempo_228": 230,
        "Tempo_229": 231,
        "Tempo_230": 232,
        "Tempo_231": 233,
        "Tempo_232": 234,
        "Tempo_233": 235,
        "Tempo_234": 236,
        "Tempo_235": 237,
        "Tempo_236": 238,
        "Tempo_237": 239,
        "Tempo_238": 240,
        "Tempo_239": 241,
        "Tempo_240": 242,
        "Tempo_241": 243,
        "Tempo_242": 244,
        "Tempo_243": 245,
        "Tempo_244": 246,
        "Tempo_245": 247,
        "Tempo_246": 248,
        "Tempo_247": 249,
        "Tempo_248": 250,
        "Tempo_249": 251,
        "Tempo_250": 252,
        "Tempo_251": 253,
        "Tempo_252": 254,
        "Tempo_253": 255,
        "Tempo_254": 256,
        "Tempo_255": 257,
        "Tempo_256": 258,
        "Tempo_257": 259,
        "Tempo_258": 260,
        "Tempo_259": 261,
        "Tempo_260": 262,
        "Tempo_261": 263,
        "Tempo_262": 264,
        "Tempo_263": 265,
        "Tempo_264": 266,
        "Tempo_265": 267,
        "Tempo_266": 268,
        "Tempo_267": 269,
        "Tempo_268": 270,
        "Tempo_269": 271,
        "Tempo_270": 272,
        "Tempo_271": 273,
        "Tempo_272": 274,
        "Tempo_273": 275,
        "Tempo_274": 276,
        "Tempo_275": 277,
        "Tempo_276": 278,
        "Tempo_277": 279,
        "Tempo_278": 280,
        "Tempo_279": 281,
        "Tempo_280": 282,
        "Tempo_281": 283,
        "Tempo_282": 284,
        "Tempo_283": 285,
        "Tempo_284": 286,
        "Tempo_285": 287,
        "Tempo_286": 288,
        "Tempo_287": 289,
        "Tempo_288": 290,
        "Tempo_289": 291,
        "Tempo_290": 292,
        "Tempo_291": 293,
        "Tempo_292": 294,
        "Tempo_293": 295,
        "Tempo_294": 296,
        "Tempo_295": 297,
        "Tempo_296": 298,
        "Tempo_297": 299,
        "Tempo_298": 300,
        "Tempo_299": 301,
        "Tempo_300": 302,
        "Tempo_301": 303,
        "Tempo_302": 304,
        "Tempo_303": 305,
        "Tempo_304": 306,
        "Tempo_305": 307,
        "Tempo_306": 308,
        "Tempo_307": 309,
        "Tempo_308": 310,
        "Tempo_309": 311,
        "Tempo_310": 312,
        "Tempo_311": 313,
        "Tempo_312": 314,
        "Tempo_313": 315,
        "Tempo_314": 316,
        "Tempo_315": 317,
        "Tempo_316": 318,
        "Tempo_317": 319,
        "Tempo_318": 320,
        "Tempo_319": 321,
        "Tempo_320": 322,
        "Tempo_321": 323,
        "Tempo_322": 324,
        "Tempo_323": 325,
        "Tempo_324": 326,
        "Tempo_325": 327,
        "Tempo_326": 328,
        "Tempo_327": 329,
        "Tempo_328": 330,
        "Tempo_329": 331,
        "Tempo_330": 332,
        "Tempo_331": 333,
        "Tempo_332": 334,
        "Tempo_333": 335,
        "Tempo_334": 336,
        "Tempo_335": 337,
        "Tempo_336": 338,
        "Tempo_337": 339,
        "Tempo_338": 340,
        "Tempo_339": 341,
        "Tempo_340": 342,
        "Tempo_341": 343,
        "Tempo_342": 344,
        "Tempo_343": 345,
        "Tempo_344": 346,
        "Tempo_345": 347,
        "Tempo_346": 348,
        "Tempo_347": 349,
        "Tempo_348": 350,
        "Tempo_349": 351,
        "Tempo_350": 352,
        "Tempo_351": 353,
        "Tempo_352": 354,
        "Tempo_353": 355,
        "Tempo_354": 356,
        "Tempo_355": 357,
        "Tempo_356": 358,
        "Tempo_357": 359,
        "Tempo_358": 360,
        "Tempo_359": 361,
        "Tempo_360": 362
    },
    "chord"     : {
        0      : 0,
        "CONTI": 1
    },
    "beat"      : {
        0        : 0,
        "Beat_0" : 1,
        "Beat_1" : 2,
        "Beat_2" : 3,
        "Beat_3" : 4,
        "Beat_4" : 5,
        "Beat_5" : 6,
        "Beat_6" : 7,
        "Beat_7" : 8,
        "Beat_8" : 9,
        "Beat_9" : 10,
        "Beat_10": 11,
        "Beat_11": 12,
        "Beat_12": 13,
        "Beat_13": 14,
        "Beat_14": 15,
        "Beat_15": 16,
        "Bar"    : 17,
    },
    "type"      : {
        "EOS"   : 0,
        "M"     : 1,
        "Note"  : 2,
        'Global': 3,
    },
    "instr_type": {
        'None'   : 0,
        'Drums'  : 1,
        'Piano'  : 2,
        'Guitar' : 3,
        'Bass'   : 4,
        'Strings': 5,
    },
    "key/genre" : {
        "None"      : 0,
        'C'         : 5,
        'C#'        : 6,
        'D'         : 7,
        'D#'        : 8,
        'E'         : 9,
        'F'         : 10,
        'F#'        : 11,
        'G'         : 12,
        'G#'        : 13,
        'A'         : 14,
        'A#'        : 15,
        'B'         : 16,
        'c'         : 17,
        'c#'        : 18,
        'd'         : 19,
        'd#'        : 20,
        'e'         : 21,
        'f'         : 22,
        'f#'        : 23,
        'g'         : 24,
        'g#'        : 25,
        'a'         : 26,
        'a#'        : 27,
        'b'         : 28,

        'Pop'       : 29,
        'Rock'      : 30,
        'Country'   : 31,
        'Electronic': 32,
        'Metal'     : 33,

    },
    "pitch"     : {
        0               : 0,
        "Note_Pitch_0"  : 1,
        "Note_Pitch_1"  : 2,
        "Note_Pitch_2"  : 3,
        "Note_Pitch_3"  : 4,
        "Note_Pitch_4"  : 5,
        "Note_Pitch_5"  : 6,
        "Note_Pitch_6"  : 7,
        "Note_Pitch_7"  : 8,
        "Note_Pitch_8"  : 9,
        "Note_Pitch_9"  : 10,
        "Note_Pitch_10" : 11,
        "Note_Pitch_11" : 12,
        "Note_Pitch_12" : 13,
        "Note_Pitch_13" : 14,
        "Note_Pitch_14" : 15,
        "Note_Pitch_15" : 16,
        "Note_Pitch_16" : 17,
        "Note_Pitch_17" : 18,
        "Note_Pitch_18" : 19,
        "Note_Pitch_19" : 20,
        "Note_Pitch_20" : 21,
        "Note_Pitch_21" : 22,
        "Note_Pitch_22" : 23,
        "Note_Pitch_23" : 24,
        "Note_Pitch_24" : 25,
        "Note_Pitch_25" : 26,
        "Note_Pitch_26" : 27,
        "Note_Pitch_27" : 28,
        "Note_Pitch_28" : 29,
        "Note_Pitch_29" : 30,
        "Note_Pitch_30" : 31,
        "Note_Pitch_31" : 32,
        "Note_Pitch_32" : 33,
        "Note_Pitch_33" : 34,
        "Note_Pitch_34" : 35,
        "Note_Pitch_35" : 36,
        "Note_Pitch_36" : 37,
        "Note_Pitch_37" : 38,
        "Note_Pitch_38" : 39,
        "Note_Pitch_39" : 40,
        "Note_Pitch_40" : 41,
        "Note_Pitch_41" : 42,
        "Note_Pitch_42" : 43,
        "Note_Pitch_43" : 44,
        "Note_Pitch_44" : 45,
        "Note_Pitch_45" : 46,
        "Note_Pitch_46" : 47,
        "Note_Pitch_47" : 48,
        "Note_Pitch_48" : 49,
        "Note_Pitch_49" : 50,
        "Note_Pitch_50" : 51,
        "Note_Pitch_51" : 52,
        "Note_Pitch_52" : 53,
        "Note_Pitch_53" : 54,
        "Note_Pitch_54" : 55,
        "Note_Pitch_55" : 56,
        "Note_Pitch_56" : 57,
        "Note_Pitch_57" : 58,
        "Note_Pitch_58" : 59,
        "Note_Pitch_59" : 60,
        "Note_Pitch_60" : 61,
        "Note_Pitch_61" : 62,
        "Note_Pitch_62" : 63,
        "Note_Pitch_63" : 64,
        "Note_Pitch_64" : 65,
        "Note_Pitch_65" : 66,
        "Note_Pitch_66" : 67,
        "Note_Pitch_67" : 68,
        "Note_Pitch_68" : 69,
        "Note_Pitch_69" : 70,
        "Note_Pitch_70" : 71,
        "Note_Pitch_71" : 72,
        "Note_Pitch_72" : 73,
        "Note_Pitch_73" : 74,
        "Note_Pitch_74" : 75,
        "Note_Pitch_75" : 76,
        "Note_Pitch_76" : 77,
        "Note_Pitch_77" : 78,
        "Note_Pitch_78" : 79,
        "Note_Pitch_79" : 80,
        "Note_Pitch_80" : 81,
        "Note_Pitch_81" : 82,
        "Note_Pitch_82" : 83,
        "Note_Pitch_83" : 84,
        "Note_Pitch_84" : 85,
        "Note_Pitch_85" : 86,
        "Note_Pitch_86" : 87,
        "Note_Pitch_87" : 88,
        "Note_Pitch_88" : 89,
        "Note_Pitch_89" : 90,
        "Note_Pitch_90" : 91,
        "Note_Pitch_91" : 92,
        "Note_Pitch_92" : 93,
        "Note_Pitch_93" : 94,
        "Note_Pitch_94" : 95,
        "Note_Pitch_95" : 96,
        "Note_Pitch_96" : 97,
        "Note_Pitch_97" : 98,
        "Note_Pitch_98" : 99,
        "Note_Pitch_99" : 100,
        "Note_Pitch_100": 101,
        "Note_Pitch_101": 102,
        "Note_Pitch_102": 103,
        "Note_Pitch_103": 104,
        "Note_Pitch_104": 105,
        "Note_Pitch_105": 106,
        "Note_Pitch_106": 107,
        "Note_Pitch_107": 108,
        "Note_Pitch_108": 109,
        "Note_Pitch_109": 110,
        "Note_Pitch_110": 111,
        "Note_Pitch_111": 112,
        "Note_Pitch_112": 113,
        "Note_Pitch_113": 114,
        "Note_Pitch_114": 115,
        "Note_Pitch_115": 116,
        "Note_Pitch_116": 117,
        "Note_Pitch_117": 118,
        "Note_Pitch_118": 119,
        "Note_Pitch_119": 120,
        "Note_Pitch_120": 121,
        "Note_Pitch_121": 122,
        "Note_Pitch_122": 123,
        "Note_Pitch_123": 124,
        "Note_Pitch_124": 125,
        "Note_Pitch_125": 126,
        "Note_Pitch_126": 127,
        "Note_Pitch_127": 128,
    },
    "duration"  : {
        0                   : 0,
        "Note_Duration_0"   : 1,
        "Note_Duration_120" : 2,
        "Note_Duration_240" : 3,
        "Note_Duration_360" : 4,
        "Note_Duration_480" : 5,
        "Note_Duration_600" : 6,
        "Note_Duration_720" : 7,
        "Note_Duration_840" : 8,
        "Note_Duration_960" : 9,
        "Note_Duration_1080": 10,
        "Note_Duration_1200": 11,
        "Note_Duration_1320": 12,
        "Note_Duration_1440": 13,
        "Note_Duration_1560": 14,
        "Note_Duration_1680": 15,
        "Note_Duration_1800": 16,
        "Note_Duration_1920": 17
    },
    "velocity"  : {
        0                  : 0,
        "Note_Velocity_0"  : 1,
        "Note_Velocity_1"  : 2,
        "Note_Velocity_2"  : 3,
        "Note_Velocity_3"  : 4,
        "Note_Velocity_4"  : 5,
        "Note_Velocity_5"  : 6,
        "Note_Velocity_6"  : 7,
        "Note_Velocity_7"  : 8,
        "Note_Velocity_8"  : 9,
        "Note_Velocity_9"  : 10,
        "Note_Velocity_10" : 11,
        "Note_Velocity_11" : 12,
        "Note_Velocity_12" : 13,
        "Note_Velocity_13" : 14,
        "Note_Velocity_14" : 15,
        "Note_Velocity_15" : 16,
        "Note_Velocity_16" : 17,
        "Note_Velocity_17" : 18,
        "Note_Velocity_18" : 19,
        "Note_Velocity_19" : 20,
        "Note_Velocity_20" : 21,
        "Note_Velocity_21" : 22,
        "Note_Velocity_22" : 23,
        "Note_Velocity_23" : 24,
        "Note_Velocity_24" : 25,
        "Note_Velocity_25" : 26,
        "Note_Velocity_26" : 27,
        "Note_Velocity_27" : 28,
        "Note_Velocity_28" : 29,
        "Note_Velocity_29" : 30,
        "Note_Velocity_30" : 31,
        "Note_Velocity_31" : 32,
        "Note_Velocity_32" : 33,
        "Note_Velocity_33" : 34,
        "Note_Velocity_34" : 35,
        "Note_Velocity_35" : 36,
        "Note_Velocity_36" : 37,
        "Note_Velocity_37" : 38,
        "Note_Velocity_38" : 39,
        "Note_Velocity_39" : 40,
        "Note_Velocity_40" : 41,
        "Note_Velocity_41" : 42,
        "Note_Velocity_42" : 43,
        "Note_Velocity_43" : 44,
        "Note_Velocity_44" : 45,
        "Note_Velocity_45" : 46,
        "Note_Velocity_46" : 47,
        "Note_Velocity_47" : 48,
        "Note_Velocity_48" : 49,
        "Note_Velocity_49" : 50,
        "Note_Velocity_50" : 51,
        "Note_Velocity_51" : 52,
        "Note_Velocity_52" : 53,
        "Note_Velocity_53" : 54,
        "Note_Velocity_54" : 55,
        "Note_Velocity_55" : 56,
        "Note_Velocity_56" : 57,
        "Note_Velocity_57" : 58,
        "Note_Velocity_58" : 59,
        "Note_Velocity_59" : 60,
        "Note_Velocity_60" : 61,
        "Note_Velocity_61" : 62,
        "Note_Velocity_62" : 63,
        "Note_Velocity_63" : 64,
        "Note_Velocity_64" : 65,
        "Note_Velocity_65" : 66,
        "Note_Velocity_66" : 67,
        "Note_Velocity_67" : 68,
        "Note_Velocity_68" : 69,
        "Note_Velocity_69" : 70,
        "Note_Velocity_70" : 71,
        "Note_Velocity_71" : 72,
        "Note_Velocity_72" : 73,
        "Note_Velocity_73" : 74,
        "Note_Velocity_74" : 75,
        "Note_Velocity_75" : 76,
        "Note_Velocity_76" : 77,
        "Note_Velocity_77" : 78,
        "Note_Velocity_78" : 79,
        "Note_Velocity_79" : 80,
        "Note_Velocity_80" : 81,
        "Note_Velocity_81" : 82,
        "Note_Velocity_82" : 83,
        "Note_Velocity_83" : 84,
        "Note_Velocity_84" : 85,
        "Note_Velocity_85" : 86,
        "Note_Velocity_86" : 87,
        "Note_Velocity_87" : 88,
        "Note_Velocity_88" : 89,
        "Note_Velocity_89" : 90,
        "Note_Velocity_90" : 91,
        "Note_Velocity_91" : 92,
        "Note_Velocity_92" : 93,
        "Note_Velocity_93" : 94,
        "Note_Velocity_94" : 95,
        "Note_Velocity_95" : 96,
        "Note_Velocity_96" : 97,
        "Note_Velocity_97" : 98,
        "Note_Velocity_98" : 99,
        "Note_Velocity_99" : 100,
        "Note_Velocity_100": 101,
        "Note_Velocity_101": 102,
        "Note_Velocity_102": 103,
        "Note_Velocity_103": 104,
        "Note_Velocity_104": 105,
        "Note_Velocity_105": 106,
        "Note_Velocity_106": 107,
        "Note_Velocity_107": 108,
        "Note_Velocity_108": 109,
        "Note_Velocity_109": 110,
        "Note_Velocity_110": 111,
        "Note_Velocity_111": 112,
        "Note_Velocity_112": 113,
        "Note_Velocity_113": 114,
        "Note_Velocity_114": 115,
        "Note_Velocity_115": 116,
        "Note_Velocity_116": 117,
        "Note_Velocity_117": 118,
        "Note_Velocity_118": 119,
        "Note_Velocity_119": 120,
        "Note_Velocity_120": 121,
        "Note_Velocity_121": 122,
        "Note_Velocity_122": 123,
        "Note_Velocity_123": 124,
        "Note_Velocity_124": 125,
        "Note_Velocity_125": 126,
        "Note_Velocity_126": 127,
        "Note_Velocity_127": 128,
        "Note_Velocity_128": 129,
        "Note_Velocity_129": 130,
        "Note_Velocity_130": 131,
        "Note_Velocity_131": 132,
        "Note_Velocity_132": 133,
        "Note_Velocity_133": 134,
        "Note_Velocity_134": 135,
        "Note_Velocity_135": 136,
        "Note_Velocity_136": 137,
        "Note_Velocity_137": 138,
        "Note_Velocity_138": 139,
        "Note_Velocity_139": 140,
        "Note_Velocity_140": 141,
        "Note_Velocity_141": 142,
        "Note_Velocity_142": 143,
        "Note_Velocity_143": 144,
        "Note_Velocity_144": 145,
        "Note_Velocity_145": 146,
        "Note_Velocity_146": 147,
        "Note_Velocity_147": 148,
        "Note_Velocity_148": 149,
        "Note_Velocity_149": 150,
        "Note_Velocity_150": 151,
        "Note_Velocity_151": 152,
        "Note_Velocity_152": 153,
        "Note_Velocity_153": 154,
        "Note_Velocity_154": 155,
        "Note_Velocity_155": 156,
        "Note_Velocity_156": 157,
        "Note_Velocity_157": 158,
        "Note_Velocity_158": 159,
        "Note_Velocity_159": 160,
        "Note_Velocity_160": 161,
        "Note_Velocity_161": 162,
        "Note_Velocity_162": 163,
        "Note_Velocity_163": 164,
        "Note_Velocity_164": 165,
        "Note_Velocity_165": 166,
        "Note_Velocity_166": 167,
        "Note_Velocity_167": 168,
        "Note_Velocity_168": 169,
        "Note_Velocity_169": 170,
        "Note_Velocity_170": 171,
        "Note_Velocity_171": 172,
        "Note_Velocity_172": 173,
        "Note_Velocity_173": 174,
        "Note_Velocity_174": 175,
        "Note_Velocity_175": 176,
        "Note_Velocity_176": 177,
        "Note_Velocity_177": 178,
        "Note_Velocity_178": 179,
        "Note_Velocity_179": 180,
        "Note_Velocity_180": 181,
        "Note_Velocity_181": 182,
        "Note_Velocity_182": 183,
        "Note_Velocity_183": 184,
        "Note_Velocity_184": 185,
        "Note_Velocity_185": 186,
        "Note_Velocity_186": 187,
        "Note_Velocity_187": 188,
        "Note_Velocity_188": 189,
        "Note_Velocity_189": 190,
        "Note_Velocity_190": 191,
        "Note_Velocity_191": 192,
        "Note_Velocity_192": 193,
        "Note_Velocity_193": 194,
        "Note_Velocity_194": 195,
        "Note_Velocity_195": 196,
        "Note_Velocity_196": 197,
        "Note_Velocity_197": 198,
        "Note_Velocity_198": 199,
        "Note_Velocity_199": 200,
        "Note_Velocity_200": 201,
        "Note_Velocity_201": 202,
        "Note_Velocity_202": 203,
        "Note_Velocity_203": 204,
        "Note_Velocity_204": 205,
        "Note_Velocity_205": 206,
        "Note_Velocity_206": 207,
        "Note_Velocity_207": 208,
        "Note_Velocity_208": 209,
        "Note_Velocity_209": 210,
        "Note_Velocity_210": 211,
        "Note_Velocity_211": 212,
        "Note_Velocity_212": 213,
        "Note_Velocity_213": 214,
        "Note_Velocity_214": 215,
        "Note_Velocity_215": 216,
        "Note_Velocity_216": 217,
        "Note_Velocity_217": 218,
        "Note_Velocity_218": 219,
        "Note_Velocity_219": 220,
        "Note_Velocity_220": 221,
        "Note_Velocity_221": 222,
        "Note_Velocity_222": 223,
        "Note_Velocity_223": 224,
        "Note_Velocity_224": 225,
        "Note_Velocity_225": 226,
        "Note_Velocity_226": 227,
        "Note_Velocity_227": 228,
        "Note_Velocity_228": 229,
        "Note_Velocity_229": 230,
        "Note_Velocity_230": 231,
        "Note_Velocity_231": 232,
        "Note_Velocity_232": 233,
        "Note_Velocity_233": 234,
        "Note_Velocity_234": 235,
        "Note_Velocity_235": 236,
        "Note_Velocity_236": 237,
        "Note_Velocity_237": 238,
        "Note_Velocity_238": 239,
        "Note_Velocity_239": 240,
        "Note_Velocity_240": 241,
        "Note_Velocity_241": 242,
        "Note_Velocity_242": 243,
        "Note_Velocity_243": 244,
        "Note_Velocity_244": 245,
        "Note_Velocity_245": 246,
        "Note_Velocity_246": 247,
        "Note_Velocity_247": 248,
        "Note_Velocity_248": 249,
        "Note_Velocity_249": 250,
        "Note_Velocity_250": 251,
        "Note_Velocity_251": 252,
        "Note_Velocity_252": 253,
        "Note_Velocity_253": 254,
        "Note_Velocity_254": 255,
        "Note_Velocity_255": 256,
        "Note_Velocity_256": 257,
        "Note_Velocity_257": 258,
        "Note_Velocity_258": 259,
        "Note_Velocity_259": 260,
        "Note_Velocity_260": 261,
        "Note_Velocity_261": 262,
        "Note_Velocity_262": 263,
        "Note_Velocity_263": 264,
        "Note_Velocity_264": 265,
        "Note_Velocity_265": 266,
        "Note_Velocity_266": 267,
        "Note_Velocity_267": 268,
        "Note_Velocity_268": 269,
        "Note_Velocity_269": 270,
        "Note_Velocity_270": 271,
        "Note_Velocity_271": 272,
        "Note_Velocity_272": 273,
        "Note_Velocity_273": 274,
        "Note_Velocity_274": 275,
        "Note_Velocity_275": 276,
        "Note_Velocity_276": 277,
        "Note_Velocity_277": 278,
        "Note_Velocity_278": 279,
        "Note_Velocity_279": 280,
        "Note_Velocity_280": 281,
        "Note_Velocity_281": 282,
        "Note_Velocity_282": 283,
        "Note_Velocity_283": 284,
        "Note_Velocity_284": 285,
        "Note_Velocity_285": 286,
        "Note_Velocity_286": 287,
        "Note_Velocity_287": 288,
        "Note_Velocity_288": 289,
        "Note_Velocity_289": 290,
        "Note_Velocity_290": 291,
        "Note_Velocity_291": 292,
        "Note_Velocity_292": 293,
        "Note_Velocity_293": 294,
        "Note_Velocity_294": 295,
        "Note_Velocity_295": 296,
        "Note_Velocity_296": 297,
        "Note_Velocity_297": 298,
        "Note_Velocity_298": 299,
        "Note_Velocity_299": 300,
        "Note_Velocity_300": 301,
        "Note_Velocity_301": 302,
        "Note_Velocity_302": 303,
        "Note_Velocity_303": 304,
        "Note_Velocity_304": 305,
        "Note_Velocity_305": 306,
        "Note_Velocity_306": 307,
        "Note_Velocity_307": 308,
        "Note_Velocity_308": 309,
        "Note_Velocity_309": 310,
        "Note_Velocity_310": 311,
        "Note_Velocity_311": 312,
        "Note_Velocity_312": 313,
        "Note_Velocity_313": 314,
        "Note_Velocity_314": 315,
        "Note_Velocity_315": 316,
        "Note_Velocity_316": 317,
        "Note_Velocity_317": 318,
        "Note_Velocity_318": 319,
        "Note_Velocity_319": 320,
        "Note_Velocity_320": 321,
        "Note_Velocity_321": 322,
        "Note_Velocity_322": 323,
        "Note_Velocity_323": 324,
        "Note_Velocity_324": 325,
        "Note_Velocity_325": 326,
        "Note_Velocity_326": 327,
        "Note_Velocity_327": 328,
        "Note_Velocity_328": 329,
        "Note_Velocity_329": 330,
        "Note_Velocity_330": 331,
        "Note_Velocity_331": 332,
        "Note_Velocity_332": 333,
        "Note_Velocity_333": 334,
        "Note_Velocity_334": 335,
        "Note_Velocity_335": 336,
        "Note_Velocity_336": 337,
        "Note_Velocity_337": 338,
        "Note_Velocity_338": 339,
        "Note_Velocity_339": 340,
        "Note_Velocity_340": 341,
        "Note_Velocity_341": 342,
        "Note_Velocity_342": 343,
        "Note_Velocity_343": 344,
        "Note_Velocity_344": 345,
        "Note_Velocity_345": 346,
        "Note_Velocity_346": 347,
        "Note_Velocity_347": 348,
        "Note_Velocity_348": 349,
        "Note_Velocity_349": 350,
        "Note_Velocity_350": 351,
        "Note_Velocity_351": 352,
        "Note_Velocity_352": 353,
        "Note_Velocity_353": 354,
        "Note_Velocity_354": 355,
        "Note_Velocity_355": 356,
        "Note_Velocity_356": 357,
        "Note_Velocity_357": 358,
        "Note_Velocity_358": 359,
        "Note_Velocity_359": 360,
        "Note_Velocity_360": 361
    },
    "boundary"  : {
        0         : 0,
        "None"    : 1,
        "Boundary": 2,
    },
    # 'density': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
    'variance'  : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
}

preset_word2event = {
    "tempo"     : {
        0  : 0,
        1  : "CONTI",
        2  : "Tempo_0",
        3  : "Tempo_1",
        4  : "Tempo_2",
        5  : "Tempo_3",
        6  : "Tempo_4",
        7  : "Tempo_5",
        8  : "Tempo_6",
        9  : "Tempo_7",
        10 : "Tempo_8",
        11 : "Tempo_9",
        12 : "Tempo_10",
        13 : "Tempo_11",
        14 : "Tempo_12",
        15 : "Tempo_13",
        16 : "Tempo_14",
        17 : "Tempo_15",
        18 : "Tempo_16",
        19 : "Tempo_17",
        20 : "Tempo_18",
        21 : "Tempo_19",
        22 : "Tempo_20",
        23 : "Tempo_21",
        24 : "Tempo_22",
        25 : "Tempo_23",
        26 : "Tempo_24",
        27 : "Tempo_25",
        28 : "Tempo_26",
        29 : "Tempo_27",
        30 : "Tempo_28",
        31 : "Tempo_29",
        32 : "Tempo_30",
        33 : "Tempo_31",
        34 : "Tempo_32",
        35 : "Tempo_33",
        36 : "Tempo_34",
        37 : "Tempo_35",
        38 : "Tempo_36",
        39 : "Tempo_37",
        40 : "Tempo_38",
        41 : "Tempo_39",
        42 : "Tempo_40",
        43 : "Tempo_41",
        44 : "Tempo_42",
        45 : "Tempo_43",
        46 : "Tempo_44",
        47 : "Tempo_45",
        48 : "Tempo_46",
        49 : "Tempo_47",
        50 : "Tempo_48",
        51 : "Tempo_49",
        52 : "Tempo_50",
        53 : "Tempo_51",
        54 : "Tempo_52",
        55 : "Tempo_53",
        56 : "Tempo_54",
        57 : "Tempo_55",
        58 : "Tempo_56",
        59 : "Tempo_57",
        60 : "Tempo_58",
        61 : "Tempo_59",
        62 : "Tempo_60",
        63 : "Tempo_61",
        64 : "Tempo_62",
        65 : "Tempo_63",
        66 : "Tempo_64",
        67 : "Tempo_65",
        68 : "Tempo_66",
        69 : "Tempo_67",
        70 : "Tempo_68",
        71 : "Tempo_69",
        72 : "Tempo_70",
        73 : "Tempo_71",
        74 : "Tempo_72",
        75 : "Tempo_73",
        76 : "Tempo_74",
        77 : "Tempo_75",
        78 : "Tempo_76",
        79 : "Tempo_77",
        80 : "Tempo_78",
        81 : "Tempo_79",
        82 : "Tempo_80",
        83 : "Tempo_81",
        84 : "Tempo_82",
        85 : "Tempo_83",
        86 : "Tempo_84",
        87 : "Tempo_85",
        88 : "Tempo_86",
        89 : "Tempo_87",
        90 : "Tempo_88",
        91 : "Tempo_89",
        92 : "Tempo_90",
        93 : "Tempo_91",
        94 : "Tempo_92",
        95 : "Tempo_93",
        96 : "Tempo_94",
        97 : "Tempo_95",
        98 : "Tempo_96",
        99 : "Tempo_97",
        100: "Tempo_98",
        101: "Tempo_99",
        102: "Tempo_100",
        103: "Tempo_101",
        104: "Tempo_102",
        105: "Tempo_103",
        106: "Tempo_104",
        107: "Tempo_105",
        108: "Tempo_106",
        109: "Tempo_107",
        110: "Tempo_108",
        111: "Tempo_109",
        112: "Tempo_110",
        113: "Tempo_111",
        114: "Tempo_112",
        115: "Tempo_113",
        116: "Tempo_114",
        117: "Tempo_115",
        118: "Tempo_116",
        119: "Tempo_117",
        120: "Tempo_118",
        121: "Tempo_119",
        122: "Tempo_120",
        123: "Tempo_121",
        124: "Tempo_122",
        125: "Tempo_123",
        126: "Tempo_124",
        127: "Tempo_125",
        128: "Tempo_126",
        129: "Tempo_127",
        130: "Tempo_128",
        131: "Tempo_129",
        132: "Tempo_130",
        133: "Tempo_131",
        134: "Tempo_132",
        135: "Tempo_133",
        136: "Tempo_134",
        137: "Tempo_135",
        138: "Tempo_136",
        139: "Tempo_137",
        140: "Tempo_138",
        141: "Tempo_139",
        142: "Tempo_140",
        143: "Tempo_141",
        144: "Tempo_142",
        145: "Tempo_143",
        146: "Tempo_144",
        147: "Tempo_145",
        148: "Tempo_146",
        149: "Tempo_147",
        150: "Tempo_148",
        151: "Tempo_149",
        152: "Tempo_150",
        153: "Tempo_151",
        154: "Tempo_152",
        155: "Tempo_153",
        156: "Tempo_154",
        157: "Tempo_155",
        158: "Tempo_156",
        159: "Tempo_157",
        160: "Tempo_158",
        161: "Tempo_159",
        162: "Tempo_160",
        163: "Tempo_161",
        164: "Tempo_162",
        165: "Tempo_163",
        166: "Tempo_164",
        167: "Tempo_165",
        168: "Tempo_166",
        169: "Tempo_167",
        170: "Tempo_168",
        171: "Tempo_169",
        172: "Tempo_170",
        173: "Tempo_171",
        174: "Tempo_172",
        175: "Tempo_173",
        176: "Tempo_174",
        177: "Tempo_175",
        178: "Tempo_176",
        179: "Tempo_177",
        180: "Tempo_178",
        181: "Tempo_179",
        182: "Tempo_180",
        183: "Tempo_181",
        184: "Tempo_182",
        185: "Tempo_183",
        186: "Tempo_184",
        187: "Tempo_185",
        188: "Tempo_186",
        189: "Tempo_187",
        190: "Tempo_188",
        191: "Tempo_189",
        192: "Tempo_190",
        193: "Tempo_191",
        194: "Tempo_192",
        195: "Tempo_193",
        196: "Tempo_194",
        197: "Tempo_195",
        198: "Tempo_196",
        199: "Tempo_197",
        200: "Tempo_198",
        201: "Tempo_199",
        202: "Tempo_200",
        203: "Tempo_201",
        204: "Tempo_202",
        205: "Tempo_203",
        206: "Tempo_204",
        207: "Tempo_205",
        208: "Tempo_206",
        209: "Tempo_207",
        210: "Tempo_208",
        211: "Tempo_209",
        212: "Tempo_210",
        213: "Tempo_211",
        214: "Tempo_212",
        215: "Tempo_213",
        216: "Tempo_214",
        217: "Tempo_215",
        218: "Tempo_216",
        219: "Tempo_217",
        220: "Tempo_218",
        221: "Tempo_219",
        222: "Tempo_220",
        223: "Tempo_221",
        224: "Tempo_222",
        225: "Tempo_223",
        226: "Tempo_224",
        227: "Tempo_225",
        228: "Tempo_226",
        229: "Tempo_227",
        230: "Tempo_228",
        231: "Tempo_229",
        232: "Tempo_230",
        233: "Tempo_231",
        234: "Tempo_232",
        235: "Tempo_233",
        236: "Tempo_234",
        237: "Tempo_235",
        238: "Tempo_236",
        239: "Tempo_237",
        240: "Tempo_238",
        241: "Tempo_239",
        242: "Tempo_240",
        243: "Tempo_241",
        244: "Tempo_242",
        245: "Tempo_243",
        246: "Tempo_244",
        247: "Tempo_245",
        248: "Tempo_246",
        249: "Tempo_247",
        250: "Tempo_248",
        251: "Tempo_249",
        252: "Tempo_250",
        253: "Tempo_251",
        254: "Tempo_252",
        255: "Tempo_253",
        256: "Tempo_254",
        257: "Tempo_255",
        258: "Tempo_256",
        259: "Tempo_257",
        260: "Tempo_258",
        261: "Tempo_259",
        262: "Tempo_260",
        263: "Tempo_261",
        264: "Tempo_262",
        265: "Tempo_263",
        266: "Tempo_264",
        267: "Tempo_265",
        268: "Tempo_266",
        269: "Tempo_267",
        270: "Tempo_268",
        271: "Tempo_269",
        272: "Tempo_270",
        273: "Tempo_271",
        274: "Tempo_272",
        275: "Tempo_273",
        276: "Tempo_274",
        277: "Tempo_275",
        278: "Tempo_276",
        279: "Tempo_277",
        280: "Tempo_278",
        281: "Tempo_279",
        282: "Tempo_280",
        283: "Tempo_281",
        284: "Tempo_282",
        285: "Tempo_283",
        286: "Tempo_284",
        287: "Tempo_285",
        288: "Tempo_286",
        289: "Tempo_287",
        290: "Tempo_288",
        291: "Tempo_289",
        292: "Tempo_290",
        293: "Tempo_291",
        294: "Tempo_292",
        295: "Tempo_293",
        296: "Tempo_294",
        297: "Tempo_295",
        298: "Tempo_296",
        299: "Tempo_297",
        300: "Tempo_298",
        301: "Tempo_299",
        302: "Tempo_300",
        303: "Tempo_301",
        304: "Tempo_302",
        305: "Tempo_303",
        306: "Tempo_304",
        307: "Tempo_305",
        308: "Tempo_306",
        309: "Tempo_307",
        310: "Tempo_308",
        311: "Tempo_309",
        312: "Tempo_310",
        313: "Tempo_311",
        314: "Tempo_312",
        315: "Tempo_313",
        316: "Tempo_314",
        317: "Tempo_315",
        318: "Tempo_316",
        319: "Tempo_317",
        320: "Tempo_318",
        321: "Tempo_319",
        322: "Tempo_320",
        323: "Tempo_321",
        324: "Tempo_322",
        325: "Tempo_323",
        326: "Tempo_324",
        327: "Tempo_325",
        328: "Tempo_326",
        329: "Tempo_327",
        330: "Tempo_328",
        331: "Tempo_329",
        332: "Tempo_330",
        333: "Tempo_331",
        334: "Tempo_332",
        335: "Tempo_333",
        336: "Tempo_334",
        337: "Tempo_335",
        338: "Tempo_336",
        339: "Tempo_337",
        340: "Tempo_338",
        341: "Tempo_339",
        342: "Tempo_340",
        343: "Tempo_341",
        344: "Tempo_342",
        345: "Tempo_343",
        346: "Tempo_344",
        347: "Tempo_345",
        348: "Tempo_346",
        349: "Tempo_347",
        350: "Tempo_348",
        351: "Tempo_349",
        352: "Tempo_350",
        353: "Tempo_351",
        354: "Tempo_352",
        355: "Tempo_353",
        356: "Tempo_354",
        357: "Tempo_355",
        358: "Tempo_356",
        359: "Tempo_357",
        360: "Tempo_358",
        361: "Tempo_359",
        362: "Tempo_360"
    },
    "chord"     : {
        0: "0",
        1: "CONTI"
    },
    "bar-beat"  : {
        0 : 0,
        1 : "Bar",
        2 : "Beat_0",
        3 : "Beat_1",
        4 : "Beat_2",
        5 : "Beat_3",
        6 : "Beat_4",
        7 : "Beat_5",
        8 : "Beat_6",
        9 : "Beat_7",
        10: "Beat_8",
        11: "Beat_9",
        12: "Beat_10",
        13: "Beat_11",
        14: "Beat_12",
        15: "Beat_13",
        16: "Beat_14",
        17: "Beat_15"
    },
    "type"      : {
        0: "EOS",
        1: "Metrical",
        2: "Note",
        3: "Seg",
    },
    "instr_type": {
        0: 'None',
        1: 'Drums',
        2: 'Piano',
        3: 'Guitar',
        4: 'Bass',
        5: 'Strings',
    },
    "pitch"     : {
        0  : 0,
        1  : "Note_Pitch_0",
        2  : "Note_Pitch_1",
        3  : "Note_Pitch_2",
        4  : "Note_Pitch_3",
        5  : "Note_Pitch_4",
        6  : "Note_Pitch_5",
        7  : "Note_Pitch_6",
        8  : "Note_Pitch_7",
        9  : "Note_Pitch_8",
        10 : "Note_Pitch_9",
        11 : "Note_Pitch_10",
        12 : "Note_Pitch_11",
        13 : "Note_Pitch_12",
        14 : "Note_Pitch_13",
        15 : "Note_Pitch_14",
        16 : "Note_Pitch_15",
        17 : "Note_Pitch_16",
        18 : "Note_Pitch_17",
        19 : "Note_Pitch_18",
        20 : "Note_Pitch_19",
        21 : "Note_Pitch_20",
        22 : "Note_Pitch_21",
        23 : "Note_Pitch_22",
        24 : "Note_Pitch_23",
        25 : "Note_Pitch_24",
        26 : "Note_Pitch_25",
        27 : "Note_Pitch_26",
        28 : "Note_Pitch_27",
        29 : "Note_Pitch_28",
        30 : "Note_Pitch_29",
        31 : "Note_Pitch_30",
        32 : "Note_Pitch_31",
        33 : "Note_Pitch_32",
        34 : "Note_Pitch_33",
        35 : "Note_Pitch_34",
        36 : "Note_Pitch_35",
        37 : "Note_Pitch_36",
        38 : "Note_Pitch_37",
        39 : "Note_Pitch_38",
        40 : "Note_Pitch_39",
        41 : "Note_Pitch_40",
        42 : "Note_Pitch_41",
        43 : "Note_Pitch_42",
        44 : "Note_Pitch_43",
        45 : "Note_Pitch_44",
        46 : "Note_Pitch_45",
        47 : "Note_Pitch_46",
        48 : "Note_Pitch_47",
        49 : "Note_Pitch_48",
        50 : "Note_Pitch_49",
        51 : "Note_Pitch_50",
        52 : "Note_Pitch_51",
        53 : "Note_Pitch_52",
        54 : "Note_Pitch_53",
        55 : "Note_Pitch_54",
        56 : "Note_Pitch_55",
        57 : "Note_Pitch_56",
        58 : "Note_Pitch_57",
        59 : "Note_Pitch_58",
        60 : "Note_Pitch_59",
        61 : "Note_Pitch_60",
        62 : "Note_Pitch_61",
        63 : "Note_Pitch_62",
        64 : "Note_Pitch_63",
        65 : "Note_Pitch_64",
        66 : "Note_Pitch_65",
        67 : "Note_Pitch_66",
        68 : "Note_Pitch_67",
        69 : "Note_Pitch_68",
        70 : "Note_Pitch_69",
        71 : "Note_Pitch_70",
        72 : "Note_Pitch_71",
        73 : "Note_Pitch_72",
        74 : "Note_Pitch_73",
        75 : "Note_Pitch_74",
        76 : "Note_Pitch_75",
        77 : "Note_Pitch_76",
        78 : "Note_Pitch_77",
        79 : "Note_Pitch_78",
        80 : "Note_Pitch_79",
        81 : "Note_Pitch_80",
        82 : "Note_Pitch_81",
        83 : "Note_Pitch_82",
        84 : "Note_Pitch_83",
        85 : "Note_Pitch_84",
        86 : "Note_Pitch_85",
        87 : "Note_Pitch_86",
        88 : "Note_Pitch_87",
        89 : "Note_Pitch_88",
        90 : "Note_Pitch_89",
        91 : "Note_Pitch_90",
        92 : "Note_Pitch_91",
        93 : "Note_Pitch_92",
        94 : "Note_Pitch_93",
        95 : "Note_Pitch_94",
        96 : "Note_Pitch_95",
        97 : "Note_Pitch_96",
        98 : "Note_Pitch_97",
        99 : "Note_Pitch_98",
        100: "Note_Pitch_99",
        101: "Note_Pitch_100",
        102: "Note_Pitch_101",
        103: "Note_Pitch_102",
        104: "Note_Pitch_103",
        105: "Note_Pitch_104",
        106: "Note_Pitch_105",
        107: "Note_Pitch_106",
        108: "Note_Pitch_107",
        109: "Note_Pitch_108",
        110: "Note_Pitch_109",
        111: "Note_Pitch_110",
        112: "Note_Pitch_111",
        113: "Note_Pitch_112",
        114: "Note_Pitch_113",
        115: "Note_Pitch_114",
        116: "Note_Pitch_115",
        117: "Note_Pitch_116",
        118: "Note_Pitch_117",
        119: "Note_Pitch_118",
        120: "Note_Pitch_119",
        121: "Note_Pitch_120",
        122: "Note_Pitch_121",
        123: "Note_Pitch_122",
        124: "Note_Pitch_123",
        125: "Note_Pitch_124",
        126: "Note_Pitch_125",
        127: "Note_Pitch_126",
        128: "Note_Pitch_127",
        129: "Note_Pitch_128",
    },
    "duration"  : {
        0 : 0,
        1 : "Note_Duration_0",
        2 : "Note_Duration_120",
        3 : "Note_Duration_240",
        4 : "Note_Duration_360",
        5 : "Note_Duration_480",
        6 : "Note_Duration_600",
        7 : "Note_Duration_720",
        8 : "Note_Duration_840",
        9 : "Note_Duration_960",
        10: "Note_Duration_1080",
        11: "Note_Duration_1200",
        12: "Note_Duration_1320",
        13: "Note_Duration_1440",
        14: "Note_Duration_1560",
        15: "Note_Duration_1680",
        16: "Note_Duration_1800",
        17: "Note_Duration_1920"
    },
    "velocity"  : {
        0  : 0,
        1  : "Note_Velocity_0",
        2  : "Note_Velocity_1",
        3  : "Note_Velocity_2",
        4  : "Note_Velocity_3",
        5  : "Note_Velocity_4",
        6  : "Note_Velocity_5",
        7  : "Note_Velocity_6",
        8  : "Note_Velocity_7",
        9  : "Note_Velocity_8",
        10 : "Note_Velocity_9",
        11 : "Note_Velocity_10",
        12 : "Note_Velocity_11",
        13 : "Note_Velocity_12",
        14 : "Note_Velocity_13",
        15 : "Note_Velocity_14",
        16 : "Note_Velocity_15",
        17 : "Note_Velocity_16",
        18 : "Note_Velocity_17",
        19 : "Note_Velocity_18",
        20 : "Note_Velocity_19",
        21 : "Note_Velocity_20",
        22 : "Note_Velocity_21",
        23 : "Note_Velocity_22",
        24 : "Note_Velocity_23",
        25 : "Note_Velocity_24",
        26 : "Note_Velocity_25",
        27 : "Note_Velocity_26",
        28 : "Note_Velocity_27",
        29 : "Note_Velocity_28",
        30 : "Note_Velocity_29",
        31 : "Note_Velocity_30",
        32 : "Note_Velocity_31",
        33 : "Note_Velocity_32",
        34 : "Note_Velocity_33",
        35 : "Note_Velocity_34",
        36 : "Note_Velocity_35",
        37 : "Note_Velocity_36",
        38 : "Note_Velocity_37",
        39 : "Note_Velocity_38",
        40 : "Note_Velocity_39",
        41 : "Note_Velocity_40",
        42 : "Note_Velocity_41",
        43 : "Note_Velocity_42",
        44 : "Note_Velocity_43",
        45 : "Note_Velocity_44",
        46 : "Note_Velocity_45",
        47 : "Note_Velocity_46",
        48 : "Note_Velocity_47",
        49 : "Note_Velocity_48",
        50 : "Note_Velocity_49",
        51 : "Note_Velocity_50",
        52 : "Note_Velocity_51",
        53 : "Note_Velocity_52",
        54 : "Note_Velocity_53",
        55 : "Note_Velocity_54",
        56 : "Note_Velocity_55",
        57 : "Note_Velocity_56",
        58 : "Note_Velocity_57",
        59 : "Note_Velocity_58",
        60 : "Note_Velocity_59",
        61 : "Note_Velocity_60",
        62 : "Note_Velocity_61",
        63 : "Note_Velocity_62",
        64 : "Note_Velocity_63",
        65 : "Note_Velocity_64",
        66 : "Note_Velocity_65",
        67 : "Note_Velocity_66",
        68 : "Note_Velocity_67",
        69 : "Note_Velocity_68",
        70 : "Note_Velocity_69",
        71 : "Note_Velocity_70",
        72 : "Note_Velocity_71",
        73 : "Note_Velocity_72",
        74 : "Note_Velocity_73",
        75 : "Note_Velocity_74",
        76 : "Note_Velocity_75",
        77 : "Note_Velocity_76",
        78 : "Note_Velocity_77",
        79 : "Note_Velocity_78",
        80 : "Note_Velocity_79",
        81 : "Note_Velocity_80",
        82 : "Note_Velocity_81",
        83 : "Note_Velocity_82",
        84 : "Note_Velocity_83",
        85 : "Note_Velocity_84",
        86 : "Note_Velocity_85",
        87 : "Note_Velocity_86",
        88 : "Note_Velocity_87",
        89 : "Note_Velocity_88",
        90 : "Note_Velocity_89",
        91 : "Note_Velocity_90",
        92 : "Note_Velocity_91",
        93 : "Note_Velocity_92",
        94 : "Note_Velocity_93",
        95 : "Note_Velocity_94",
        96 : "Note_Velocity_95",
        97 : "Note_Velocity_96",
        98 : "Note_Velocity_97",
        99 : "Note_Velocity_98",
        100: "Note_Velocity_99",
        101: "Note_Velocity_100",
        102: "Note_Velocity_101",
        103: "Note_Velocity_102",
        104: "Note_Velocity_103",
        105: "Note_Velocity_104",
        106: "Note_Velocity_105",
        107: "Note_Velocity_106",
        108: "Note_Velocity_107",
        109: "Note_Velocity_108",
        110: "Note_Velocity_109",
        111: "Note_Velocity_110",
        112: "Note_Velocity_111",
        113: "Note_Velocity_112",
        114: "Note_Velocity_113",
        115: "Note_Velocity_114",
        116: "Note_Velocity_115",
        117: "Note_Velocity_116",
        118: "Note_Velocity_117",
        119: "Note_Velocity_118",
        120: "Note_Velocity_119",
        121: "Note_Velocity_120",
        122: "Note_Velocity_121",
        123: "Note_Velocity_122",
        124: "Note_Velocity_123",
        125: "Note_Velocity_124",
        126: "Note_Velocity_125",
        127: "Note_Velocity_126",
        128: "Note_Velocity_127",
        129: "Note_Velocity_128",
        130: "Note_Velocity_129",
        131: "Note_Velocity_130",
        132: "Note_Velocity_131",
        133: "Note_Velocity_132",
        134: "Note_Velocity_133",
        135: "Note_Velocity_134",
        136: "Note_Velocity_135",
        137: "Note_Velocity_136",
        138: "Note_Velocity_137",
        139: "Note_Velocity_138",
        140: "Note_Velocity_139",
        141: "Note_Velocity_140",
        142: "Note_Velocity_141",
        143: "Note_Velocity_142",
        144: "Note_Velocity_143",
        145: "Note_Velocity_144",
        146: "Note_Velocity_145",
        147: "Note_Velocity_146",
        148: "Note_Velocity_147",
        149: "Note_Velocity_148",
        150: "Note_Velocity_149",
        151: "Note_Velocity_150",
        152: "Note_Velocity_151",
        153: "Note_Velocity_152",
        154: "Note_Velocity_153",
        155: "Note_Velocity_154",
        156: "Note_Velocity_155",
        157: "Note_Velocity_156",
        158: "Note_Velocity_157",
        159: "Note_Velocity_158",
        160: "Note_Velocity_159",
        161: "Note_Velocity_160",
        162: "Note_Velocity_161",
        163: "Note_Velocity_162",
        164: "Note_Velocity_163",
        165: "Note_Velocity_164",
        166: "Note_Velocity_165",
        167: "Note_Velocity_166",
        168: "Note_Velocity_167",
        169: "Note_Velocity_168",
        170: "Note_Velocity_169",
        171: "Note_Velocity_170",
        172: "Note_Velocity_171",
        173: "Note_Velocity_172",
        174: "Note_Velocity_173",
        175: "Note_Velocity_174",
        176: "Note_Velocity_175",
        177: "Note_Velocity_176",
        178: "Note_Velocity_177",
        179: "Note_Velocity_178",
        180: "Note_Velocity_179",
        181: "Note_Velocity_180",
        182: "Note_Velocity_181",
        183: "Note_Velocity_182",
        184: "Note_Velocity_183",
        185: "Note_Velocity_184",
        186: "Note_Velocity_185",
        187: "Note_Velocity_186",
        188: "Note_Velocity_187",
        189: "Note_Velocity_188",
        190: "Note_Velocity_189",
        191: "Note_Velocity_190",
        192: "Note_Velocity_191",
        193: "Note_Velocity_192",
        194: "Note_Velocity_193",
        195: "Note_Velocity_194",
        196: "Note_Velocity_195",
        197: "Note_Velocity_196",
        198: "Note_Velocity_197",
        199: "Note_Velocity_198",
        200: "Note_Velocity_199",
        201: "Note_Velocity_200",
        202: "Note_Velocity_201",
        203: "Note_Velocity_202",
        204: "Note_Velocity_203",
        205: "Note_Velocity_204",
        206: "Note_Velocity_205",
        207: "Note_Velocity_206",
        208: "Note_Velocity_207",
        209: "Note_Velocity_208",
        210: "Note_Velocity_209",
        211: "Note_Velocity_210",
        212: "Note_Velocity_211",
        213: "Note_Velocity_212",
        214: "Note_Velocity_213",
        215: "Note_Velocity_214",
        216: "Note_Velocity_215",
        217: "Note_Velocity_216",
        218: "Note_Velocity_217",
        219: "Note_Velocity_218",
        220: "Note_Velocity_219",
        221: "Note_Velocity_220",
        222: "Note_Velocity_221",
        223: "Note_Velocity_222",
        224: "Note_Velocity_223",
        225: "Note_Velocity_224",
        226: "Note_Velocity_225",
        227: "Note_Velocity_226",
        228: "Note_Velocity_227",
        229: "Note_Velocity_228",
        230: "Note_Velocity_229",
        231: "Note_Velocity_230",
        232: "Note_Velocity_231",
        233: "Note_Velocity_232",
        234: "Note_Velocity_233",
        235: "Note_Velocity_234",
        236: "Note_Velocity_235",
        237: "Note_Velocity_236",
        238: "Note_Velocity_237",
        239: "Note_Velocity_238",
        240: "Note_Velocity_239",
        241: "Note_Velocity_240",
        242: "Note_Velocity_241",
        243: "Note_Velocity_242",
        244: "Note_Velocity_243",
        245: "Note_Velocity_244",
        246: "Note_Velocity_245",
        247: "Note_Velocity_246",
        248: "Note_Velocity_247",
        249: "Note_Velocity_248",
        250: "Note_Velocity_249",
        251: "Note_Velocity_250",
        252: "Note_Velocity_251",
        253: "Note_Velocity_252",
        254: "Note_Velocity_253",
        255: "Note_Velocity_254",
        256: "Note_Velocity_255",
        257: "Note_Velocity_256",
        258: "Note_Velocity_257",
        259: "Note_Velocity_258",
        260: "Note_Velocity_259",
        261: "Note_Velocity_260",
        262: "Note_Velocity_261",
        263: "Note_Velocity_262",
        264: "Note_Velocity_263",
        265: "Note_Velocity_264",
        266: "Note_Velocity_265",
        267: "Note_Velocity_266",
        268: "Note_Velocity_267",
        269: "Note_Velocity_268",
        270: "Note_Velocity_269",
        271: "Note_Velocity_270",
        272: "Note_Velocity_271",
        273: "Note_Velocity_272",
        274: "Note_Velocity_273",
        275: "Note_Velocity_274",
        276: "Note_Velocity_275",
        277: "Note_Velocity_276",
        278: "Note_Velocity_277",
        279: "Note_Velocity_278",
        280: "Note_Velocity_279",
        281: "Note_Velocity_280",
        282: "Note_Velocity_281",
        283: "Note_Velocity_282",
        284: "Note_Velocity_283",
        285: "Note_Velocity_284",
        286: "Note_Velocity_285",
        287: "Note_Velocity_286",
        288: "Note_Velocity_287",
        289: "Note_Velocity_288",
        290: "Note_Velocity_289",
        291: "Note_Velocity_290",
        292: "Note_Velocity_291",
        293: "Note_Velocity_292",
        294: "Note_Velocity_293",
        295: "Note_Velocity_294",
        296: "Note_Velocity_295",
        297: "Note_Velocity_296",
        298: "Note_Velocity_297",
        299: "Note_Velocity_298",
        300: "Note_Velocity_299",
        301: "Note_Velocity_300",
        302: "Note_Velocity_301",
        303: "Note_Velocity_302",
        304: "Note_Velocity_303",
        305: "Note_Velocity_304",
        306: "Note_Velocity_305",
        307: "Note_Velocity_306",
        308: "Note_Velocity_307",
        309: "Note_Velocity_308",
        310: "Note_Velocity_309",
        311: "Note_Velocity_310",
        312: "Note_Velocity_311",
        313: "Note_Velocity_312",
        314: "Note_Velocity_313",
        315: "Note_Velocity_314",
        316: "Note_Velocity_315",
        317: "Note_Velocity_316",
        318: "Note_Velocity_317",
        319: "Note_Velocity_318",
        320: "Note_Velocity_319",
        321: "Note_Velocity_320",
        322: "Note_Velocity_321",
        323: "Note_Velocity_322",
        324: "Note_Velocity_323",
        325: "Note_Velocity_324",
        326: "Note_Velocity_325",
        327: "Note_Velocity_326",
        328: "Note_Velocity_327",
        329: "Note_Velocity_328",
        330: "Note_Velocity_329",
        331: "Note_Velocity_330",
        332: "Note_Velocity_331",
        333: "Note_Velocity_332",
        334: "Note_Velocity_333",
        335: "Note_Velocity_334",
        336: "Note_Velocity_335",
        337: "Note_Velocity_336",
        338: "Note_Velocity_337",
        339: "Note_Velocity_338",
        340: "Note_Velocity_339",
        341: "Note_Velocity_340",
        342: "Note_Velocity_341",
        343: "Note_Velocity_342",
        344: "Note_Velocity_343",
        345: "Note_Velocity_344",
        346: "Note_Velocity_345",
        347: "Note_Velocity_346",
        348: "Note_Velocity_347",
        349: "Note_Velocity_348",
        350: "Note_Velocity_349",
        351: "Note_Velocity_350",
        352: "Note_Velocity_351",
        353: "Note_Velocity_352",
        354: "Note_Velocity_353",
        355: "Note_Velocity_354",
        356: "Note_Velocity_355",
        357: "Note_Velocity_356",
        358: "Note_Velocity_357",
        359: "Note_Velocity_358",
        360: "Note_Velocity_359",
        361: "Note_Velocity_360"
    },
    "boundary"  : {
        0: 0,
        1: "None",
        2: "Boundary",
    },
    "key"       : {
        0 : 0,
        1 : "None",
        2 : 'C',
        3 : 'C#',
        4 : 'D',
        5 : 'D#',
        6 : 'E',
        7 : 'F',
        8 : 'F#',
        9 : 'G',
        10: 'G#',
        11: 'A',
        12: 'A#',
        13: 'B',
        14: 'c',
        15: 'c#',
        16: 'd',
        17: 'd#',
        18: 'e',
        19: 'f',
        20: 'f#',
        21: 'g',
        22: 'g#',
        23: 'a',
        24: 'a#',
        25: 'b',
    }
}

init_dictionary = {
    "instr_type": {
        'None'   : 0,
        'Drums'  : 1,
        'Piano'  : 2,
        'Guitar' : 3,
        'Bass'   : 4,
        'Strings': 5,
    },
    "key"       : {
        "None": 0,
        'C'   : 1,
        'C#'  : 2,
        'D'   : 3,
        'D#'  : 4,
        'E'   : 5,
        'F'   : 6,
        'F#'  : 7,
        'G'   : 8,
        'G#'  : 9,
        'A'   : 10,
        'A#'  : 11,
        'B'   : 12,
        'c'   : 13,
        'c#'  : 14,
        'd'   : 15,
        'd#'  : 16,
        'e'   : 17,
        'f'   : 18,
        'f#'  : 19,
        'g'   : 20,
        'g#'  : 21,
        'a'   : 22,
        'a#'  : 23,
        'b'   : 24,
    },
    "genre"     : {
        "None"      : 0,
        'Metal'     : 1,
        'Country'   : 2,
        'dance'     : 3,
        'Electronic': 4,
        'Pop'       : 5,
        'Rock'      : 6,
    }
}

genre = {
    'Metal'     : 1,
    'Country'   : 2,
    'dance'     : 3,
    'Electronic': 4,
    'Pop'       : 5,
    'Rock'      : 6,
}

================================================
FILE: src/gen_midi_conditional.py
================================================
import sys
import os

import time
import glob
import numpy as np

import torch
import argparse

sys.path.append("../dataset/")

from numpy2midi_mix import numpy2midi
from model import CMT


def cal_control_error(err_note_number_list, err_beat_number_list):
    print("err_note_number_list", err_note_number_list)
    print("err_beat_number_list", err_beat_number_list)
    print("strength control error", np.mean(err_note_number_list) / 1.83)
    print("density control error", np.mean(err_beat_number_list) / 10.90)


def generate():
    # path
    parser = argparse.ArgumentParser(description="Args for generating background music")
    parser.add_argument('-c', '--ckpt', default="../exp/loss_8_params.pt", help="Model checkpoint to be loaded")
    parser.add_argument('-f', '--files', required=True, help="Input npz file of a video")
    parser.add_argument('-g', '--gpus', help="Id of gpu. Only ONE gpu is needed")
    parser.add_argument('-n', '--num_songs', default=1, help="Number of generated songs")
    args = parser.parse_args()
    
    num_songs = int(args.num_songs)

    if args.gpus is not None:
        if not args.gpus.isnumeric():
            raise RuntimeError('Only 1 GPU is needed for inference')
        os.environ['CUDA_VISIBLE_DEVICES'] = args.gpus
    else:
        os.environ['CUDA_VISIBLE_DEVICES'] = '0'

    path_saved_ckpt = args.ckpt
    filelist = glob.glob(args.files)


    # change this if using another training set (see the output of decoder_n_class in train.py)
    decoder_n_class = [18, 3, 18, 129, 18, 6, 20, 102, 5025] 
    init_n_token = [7, 1, 6]


    # init model
    net = torch.nn.DataParallel(CMT(decoder_n_class, init_n_token))

    # load model
    print('[*] load model from:', path_saved_ckpt)
    if torch.cuda.is_available():
        net.cuda()
        net.eval()
        net.load_state_dict(torch.load(path_saved_ckpt))
    else:
        net.eval()
        net.load_state_dict(torch.load(path_saved_ckpt, map_location=torch.device('cpu')))

    if len(filelist) == 0:
        raise RuntimeError('no npz file in ' + str(filelist))

    for file_name in filelist:
        # gen
        start_time = time.time()
        song_time_list = []
        words_len_list = []

        sidx = 0

        while sidx < num_songs:
            try:
                print("new song")
                start_time = time.time()
                vlog_npz = np.load(file_name)['input']

                vlog_npz = vlog_npz[vlog_npz[:, 2] != 1]
                print(vlog_npz)

                res, err_note_number_list, err_beat_number_list = net(is_train=False, vlog=vlog_npz, C=0.7)

                cal_control_error(err_note_number_list, err_beat_number_list)

                numpy2midi(f"{file_name}_{sidx}", res[:, [1, 0, 2, 3, 4, 5, 6]].astype(np.int32))
                song_time = time.time() - start_time
                word_len = len(res)
                print('song time:', song_time)
                print('word_len:', word_len)
                words_len_list.append(word_len)
                song_time_list.append(song_time)

                sidx += 1
            except KeyboardInterrupt:
                raise ValueError(' [x] terminated.')


if __name__ == '__main__':
    print("inference")
    generate()


================================================
FILE: src/match.py
================================================
import argparse
from tqdm import tqdm
import numpy as np


def _get_density(bar_word):
    assert _is_bar_word(bar_word)
    if len(bar_word) == 10:
        return bar_word[2] - 1
    elif len(bar_word) == 6:
        return bar_word[1] - 1
    else:
        raise NotImplementedError


def _get_strength_and_tick(beat_word):
    assert _is_beat_word(beat_word)
    if len(beat_word) == 10:
        return beat_word[6], beat_word[1] - 1
    elif len(beat_word) == 6:
        return beat_word[2], beat_word[0] - 1
    else:
        raise NotImplementedError


def _is_bar_word(word):
    if len(word) == 10:
        return word[0] == 1 and word[1] == 17
    elif len(word) == 6:
        return word[0] == 17
    else:
        raise NotImplementedError


def _is_beat_word(word):
    if len(word) == 10:
        return word[0] == 1 and word[1] > 0 and word[1] < 17
    elif len(word) == 6:
        return word[0] > 0 and word[0] < 17
    else:
        raise NotImplementedError


def _get_density_and_strength_from_npz(npz):
    l_density = []
    l_strength = []
    for word in npz:
        if _is_bar_word(word):
            l_density.append(_get_density(word))
            l_strength.append([0] * 16)
        elif _is_beat_word(word):
            strength, tick = _get_strength_and_tick(word)
            l_strength[-1][tick] = strength
    return np.asarray(l_density), np.asarray(l_strength)


def cal_matchness(midi_npz, v_density, v_strength):
    m_density, m_strength = _get_density_and_strength_from_npz(midi_npz)

    n_bar = min(v_density.shape[0], m_density.shape[0])
    v_density = v_density[:n_bar]
    v_strength = v_strength[:n_bar]
    m_density = m_density[:n_bar]
    m_strength = m_strength[:n_bar]

    m_strength *= (v_strength > 0)
    dist = ((v_density - m_density) ** 2).mean() + ((v_strength - m_strength) ** 2).mean()
    return 1. / dist


def match_midi(video_npz, all_midi_metadata, all_midi_npz):
    res = []
    v_density, v_strength = _get_density_and_strength_from_npz(video_npz)

    print('Computing matching scores:')
    for i, midi_npz in enumerate(tqdm(all_midi_npz)):
        matchess = cal_matchness(midi_npz, v_density, v_strength)
        res.append((all_midi_metadata[i]['id'], matchess))
    res.sort(key=lambda x: x[1], reverse=True)

    print('IDs and matching scores of the 5 most matching music pieces:')
    for i in range(5):
        print(res[i][0], res[i][1])


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('video', default='../inference/wzk.npz', help='Video npz path')
    parser.add_argument('music_lib', default='../dataset/lpd_5_prcem_mix_v8_10000.npz', help='Music npz path')
    args = parser.parse_args()

    video_npz = np.load(args.video, allow_pickle=True)['input']
    tmp = np.load(args.music_lib, allow_pickle=True)
    all_midi_metadata = tmp['metadata']
    all_midi_npz = tmp['x']
    del tmp
    match_midi(video_npz, all_midi_metadata, all_midi_npz)

================================================
FILE: src/midi2mp3.py
================================================
import note_seq
from pretty_midi import PrettyMIDI
import midi2audio
import argparse

SAMPLE_RATE = 16000
SF2_PATH = '../SGM-v2.01-Sal-Guit-Bass-V1.3.sf2'


def midi_to_mp3(midi_path, tempo, mp3_path):
    midi_obj = PrettyMIDI(midi_path)
    # convert tempo
    midi_length = midi_obj.get_end_time()
    midi_obj.adjust_times([0, midi_length], [0, midi_length*120/tempo])
    processed_mid = midi_path[:-4] + "_processed.mid"
    midi_obj.write(processed_mid)

    print("converting into mp3")
    fs = midi2audio.FluidSynth(SF2_PATH, sample_rate=SAMPLE_RATE)
    fs.midi_to_audio(processed_mid, mp3_path)
    
    print("playing music")
    
    ns = note_seq.midi_io.midi_to_note_sequence(midi_obj)
    note_seq.play_sequence(ns, synth=note_seq.fluidsynth, sample_rate=SAMPLE_RATE, sf2_path=SF2_PATH)
    note_seq.plot_sequence(ns)


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--input", default="../inference/get_0.mid")
    parser.add_argument("--tempo", default="96")
    parser.add_argument("--output", default="../inference/get_0.mp3")
    args = parser.parse_args()
    midi_to_mp3(args.input, float(args.tempo), args.output)


================================================
FILE: src/midi2numpy_mix.py
================================================
import os
import math
import json

import muspy
import numpy as np
from tqdm import tqdm
import argparse

from dictionary_mix import preset_event2word, preset_word2event

#np.random.seed(208)

RESOLUTION = 16  # 每小节16个时间单位
DECODER_MAX_LEN = 10000
# DECODER_MAX_LEN = 3000
DECODER_DIMENSION = {
    'type'      : 0,
    'beat'      : 1,
    'density'   : 2,
    'pitch'     : 3,
    'duration'  : 4,
    'instr_type': 5,
    'strength'  : 6,
    'i_beat'    : 7,
    'n_beat'    : 8,
    'p_beat'    : 9,
}
N_DECODER_DIMENSION = len(DECODER_DIMENSION)
KEYS = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B', 'c', 'c#', 'd', 'd#', 'e', 'f', 'f#', 'g',
        'g#', 'a', 'a#', 'b']


class Note:
    def __init__(self, muspy_note=None, instr_type=None):  # bar starts from 0
        if muspy_note is not None and instr_type is not None:
            self.time = muspy_note.time
            self.bar = self.time // RESOLUTION  # 从0开始
            self.beat = muspy_note.time % RESOLUTION  # 小节内部的第几个beat
            self.i_beat = self.bar * RESOLUTION + self.beat  # 整首歌的第几个beat
            self.pitch = muspy_note.pitch
            self.duration = min(RESOLUTION, muspy_note.duration)  # TODO: 截断过长的note?
            self.instr_type = instr_type
            # self.velocity = muspy_note.velocity
            self.velocity = 80

    def to_decoder_list(self, n_beat: int) -> list:
        l = [0] * N_DECODER_DIMENSION
        l[DECODER_DIMENSION['type']] = preset_event2word['type']['Note']
        l[DECODER_DIMENSION['pitch']] = preset_event2word['pitch']['Note_Pitch_%d' % self.pitch]
        l[DECODER_DIMENSION['duration']] = preset_event2word['duration']['Note_Duration_%d' % (self.duration * 120)]
        l[DECODER_DIMENSION['instr_type']] = preset_event2word['instr_type'][self.instr_type]
        l[DECODER_DIMENSION['i_beat']] = self.i_beat
        l[DECODER_DIMENSION['n_beat']] = n_beat
        l[DECODER_DIMENSION['p_beat']] = int(self.i_beat / n_beat * 100)
        return l

    def to_muspy_note(self) -> muspy.Note:
        return muspy.Note(time=self.time, pitch=self.pitch, duration=self.duration, velocity=self.velocity)

    def from_decoder_array(self, np_array: np.ndarray, bar: int, beat: int) -> muspy.Note:
        assert np_array[DECODER_DIMENSION['type']] == preset_event2word['type']['Note']
        assert np_array[DECODER_DIMENSION['pitch']] > 0
        assert np_array[DECODER_DIMENSION['duration']] > 0
        assert np_array[DECODER_DIMENSION['instr_type']] > 0
        self.time = bar * RESOLUTION + beat
        self.pitch = np_array[DECODER_DIMENSION['pitch']] - 1
        self.duration = np_array[DECODER_DIMENSION['duration']] - 1
        self.instr_type = preset_word2event['instr_type'][np_array[DECODER_DIMENSION['instr_type']]]
        self.velocity = 80
        return self.to_muspy_note()


class Bar:
    def __init__(self, notes, i_bar):
        self.notes = notes
        self.n_notes = len(self.notes)
        self.i_bar = i_bar

    def _get_beat_token(self, note, density, strength, n_beat: int) -> list:
        l = [[0] * N_DECODER_DIMENSION]
        l[0][DECODER_DIMENSION['type']] = preset_event2word['type']['M']
        l[0][DECODER_DIMENSION['beat']] = preset_event2word['beat']['Beat_%d' % note.beat]
        l[0][DECODER_DIMENSION['density']] = density + 1
        l[0][DECODER_DIMENSION['instr_type']] = preset_event2word['instr_type'][note.instr_type]
        l[0][DECODER_DIMENSION['strength']] = strength
        l[0][DECODER_DIMENSION['i_beat']] = note.i_beat
        l[0][DECODER_DIMENSION['n_beat']] = n_beat
        l[0][DECODER_DIMENSION['p_beat']] = int(note.i_beat / n_beat * 100)
        return l

    def _get_bar_token(self, density, n_beat: int) -> list:
        l = [[0] * N_DECODER_DIMENSION]
        l[0][DECODER_DIMENSION['type']] = preset_event2word['type']['M']
        l[0][DECODER_DIMENSION['beat']] = preset_event2word['beat']['Bar']
        l[0][DECODER_DIMENSION['density']] = density + 1
        l[0][DECODER_DIMENSION['i_beat']] = self.i_bar * RESOLUTION
        l[0][DECODER_DIMENSION['n_beat']] = n_beat
        l[0][DECODER_DIMENSION['p_beat']] = int(self.i_bar * RESOLUTION / n_beat * 100)
        return l

    def to_decoder_list(self, n_beat: int) -> list:
        # 逆序构建
        n_beats = 0
        l = []
        if len(self.notes) > 0:
            # add the last note token
            l = [self.notes[-1].to_decoder_list(n_beat)]
            prev_note = self.notes[-1]
            n_notes_per_beat = 1
            for note in reversed(self.notes[:-1]):
                if note.beat != prev_note.beat or note.instr_type != prev_note.instr_type:
                    # add beat token
                    l = self._get_beat_token(note=prev_note, density=n_beats, strength=n_notes_per_beat,
                                             n_beat=n_beat) + l
                    if note.beat != prev_note.beat:
                        n_beats += 1
                    n_notes_per_beat = 0
                # add note token
                l = [note.to_decoder_list(n_beat)] + l
                n_notes_per_beat += 1
                prev_note = note
            # add the first beat token
            l = self._get_beat_token(note=prev_note, density=n_beats, strength=n_notes_per_beat, n_beat=n_beat) + l
            n_beats += 1
        # add bar token
        l = self._get_bar_token(density=n_beats, n_beat=n_beat) + l
        return l


class MIDI:
    def __init__(self, id: str):
        self.id = id
        self.midi = muspy.read_midi(os.path.join(midi_dir, id + '.mid'))
        self.midi.adjust_resolution(target=RESOLUTION // 4)

        self.n_beat = self.midi.get_end_time()
        self.n_bars = math.ceil((self.n_beat + 1) / RESOLUTION)

        muspy_tracks = []
        for track in self.midi.tracks:  # filter tracks with <=20 notes
            if len(track.notes) > 20:
                muspy_tracks.append(track)
        self.midi.tracks = muspy_tracks
        self.instruments = [track.name for track in muspy_tracks]
        self.bars = self._get_bars()

    def _get_bars(self):
        bars = [[] for i in range(self.n_bars)]
        for i, track in enumerate(self.midi.tracks):
            for j, muspy_note in enumerate(track.notes):
                note = Note(muspy_note, track.name)
                bars[note.bar].append(note)
        new_bars = []
        for i in range(len(bars)):
            bars[i].sort(key=lambda x: x.time)
            new_bars.append(Bar(notes=bars[i], i_bar=i))
        return new_bars

    def to_decoder_list(self) -> list:
        l = []
        for bar in self.bars:
            l += bar.to_decoder_list(self.n_beat)
        l += [[0] * N_DECODER_DIMENSION]  # 多一个EOS
        mask = [1] * len(l)
        return l, mask, len(l)


def midi2numpy(id_list: list):
    if not os.path.exists(json_dir):
        os.makedirs(json_dir)

    decoder = []
    decoder_mask = []
    metadata_list = []
    decoder_len = []

    for id in tqdm(id_list):
        id_filename = os.path.join(json_dir, id + '.json')
        if os.path.exists(id_filename):
            with open(id_filename, 'r') as f:
                load_dict = json.load(f)
                decoder_list = load_dict['decoder_list']
                de_mask = load_dict['de_mask']
                de_len = load_dict['de_len']
                decoder_len.append(de_len)
                metadata = load_dict['metadata']
        else:

            midi = MIDI(id)
            decoder_list, de_mask, de_len = midi.to_decoder_list()

            decoder_len.append(de_len)
            if de_len > DECODER_MAX_LEN:
                continue

            # Padding to MAX_LEN
            decoder_list += [[0] * N_DECODER_DIMENSION] * (DECODER_MAX_LEN - de_len)
            de_mask += [0] * (DECODER_MAX_LEN - de_len)

            metadata = {'id': id, 'de_len': de_len, 'instruments': midi.instruments, 'genre': "N/A"}
            ##### genre set to empty

            dic = {'decoder_list': decoder_list, 'de_mask': de_mask, 'de_len': de_len, 'metadata': metadata}
            with open(id_filename, 'w') as f:
                json.dump(dic, f)

        decoder.append(decoder_list)
        decoder_mask.append(de_mask)
        metadata_list.append(metadata)

    print('max decoder length: %d' % max(decoder_len))

    decoder = np.asarray(decoder, dtype=int)
    x = decoder[:, :-1]
    y = decoder[:, 1:]
    decoder_mask = np.asarray(decoder_mask, dtype=int)

    np.savez(npz_filename, x=x, y=y, decoder_mask=decoder_mask, metadata=metadata_list)
    print(npz_filename)
    print('%d songs' % len(decoder))


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("--midi_dir", default="../../lpd_5_cleansed_midi/", required=True)
    parser.add_argument("--out_name", default="data.npz", required=True)
    args = parser.parse_args()

    midi_dir = args.midi_dir
    npz_filename = os.path.join("../dataset/", args.out_name)
    json_dir = os.path.join("../dataset/json/")

    id_list = []
    for name in os.listdir(midi_dir):
        if name.endswith(".mid"):
            id_list.append(name[:-4])
        elif name.endswith(".midi"):
            id_list.append(name[:-5])
    
    midi2numpy(id_list)


================================================
FILE: src/model.py
================================================
import numpy as np
import torch
import torch.cuda
from torch import nn

from utils import Embeddings, BeatPositionalEncoding

from fast_transformers.builders import TransformerEncoderBuilder
from fast_transformers.masking import TriangularCausalMask

D_MODEL = 512
N_LAYER_ENCODER = 12
N_HEAD = 8

ATTN_DECODER = "causal-linear"


################################################################################
# Sampling
################################################################################
# -- temperature -- #
def softmax_with_temperature(logits, temperature):
    logits -= np.max(logits)
    probs = np.exp(logits / temperature) / np.sum(np.exp(logits / temperature))
    return probs


def weighted_sampling(probs):
    probs /= (sum(probs) + 1e-10)
    sorted_probs = np.sort(probs)[::-1]
    sorted_index = np.argsort(probs)[::-1]
    try:
        word = np.random.choice(sorted_index, size=1, p=sorted_probs)[0]
    except:
        word = sorted_index[0]
    return word


# -- nucleus -- #
def nucleus(probs, p):
    probs /= (sum(probs) + 1e-5)
    sorted_probs = np.sort(probs)[::-1]
    sorted_index = np.argsort(probs)[::-1]
    cusum_sorted_probs = np.cumsum(sorted_probs)
    after_threshold = cusum_sorted_probs > p
    if sum(after_threshold) > 0:
        last_index = np.where(after_threshold)[0][0] + 1
        candi_index = sorted_index[:last_index]
    else:
        candi_index = sorted_index[:]
    candi_probs = [probs[i] for i in candi_index]
    candi_probs /= sum(candi_probs)
    word = np.random.choice(candi_index, size=1, p=candi_probs)[0]
    return word


def sampling(logit, p=None, t=1.0):
    logit = logit.squeeze().cpu().numpy()
    probs = softmax_with_temperature(logits=logit, temperature=t)

    if p is not None:
        cur_word = nucleus(probs, p=p)
    else:
        cur_word = weighted_sampling(probs)
    return cur_word


'''
last dimension of input data | attribute:
0: bar/beat
1: type
2: density
3: pitch
4: duration
5: instr
6: strength onset_density
7: time_encoding
'''


class CMT(nn.Module):
    def __init__(self, n_token, init_n_token, is_training=True):
        super(CMT, self).__init__()

        print("D_MODEL", D_MODEL, " N_LAYER", N_LAYER_ENCODER, " N_HEAD", N_HEAD, "DECODER ATTN", ATTN_DECODER)

        # --- params config --- #
        self.n_token = n_token
        self.d_model = D_MODEL
        self.n_layer_encoder = N_LAYER_ENCODER  #
        # self.n_layer_decoder = N_LAYER_DECODER
        self.dropout = 0.1
        self.n_head = N_HEAD  #
        self.d_head = D_MODEL // N_HEAD
        self.d_inner = 2048
        self.loss_func = nn.CrossEntropyLoss(reduction='none')
        # self.emb_sizes = [64, 32, 512, 128, 32]
        self.emb_sizes = [64, 32, 64, 512, 128, 32, 64]

        self.init_n_token = init_n_token  # genre, key, instrument
        self.init_emb_sizes = [64, 64, 64]
        self.time_encoding_size = 256
        # --- modules config --- #
        # embeddings
        print('>>>>>:', self.n_token)

        self.init_emb_genre = Embeddings(self.init_n_token[0], self.init_emb_sizes[0])
        self.init_emb_key = Embeddings(self.init_n_token[1], self.init_emb_sizes[1])
        self.init_emb_instrument = Embeddings(self.init_n_token[2], self.init_emb_sizes[2])
        self.init_in_linear = nn.Linear(int(np.sum(self.init_emb_sizes)), self.d_model)

        self.encoder_emb_barbeat = Embeddings(self.n_token[0], self.emb_sizes[0])
        self.encoder_emb_type = Embeddings(self.n_token[1], self.emb_sizes[1])
        self.encoder_emb_beat_density = Embeddings(self.n_token[2], self.emb_sizes[2])
        self.encoder_emb_pitch = Embeddings(self.n_token[3], self.emb_sizes[3])
        self.encoder_emb_duration = Embeddings(self.n_token[4], self.emb_sizes[4])
        self.encoder_emb_instr = Embeddings(self.n_token[5], self.emb_sizes[5])
        self.encoder_emb_onset_density = Embeddings(self.n_token[6], self.emb_sizes[6])
        self.encoder_emb_time_encoding = Embeddings(self.n_token[7], self.time_encoding_size)
        self.encoder_pos_emb = BeatPositionalEncoding(self.d_model, self.dropout)

        # # linear
        self.encoder_in_linear = nn.Linear(int(np.sum(self.emb_sizes)), self.d_model)
        self.encoder_time_linear = nn.Linear(int(self.time_encoding_size), self.d_model)

        self.transformer_encoder = TransformerEncoderBuilder.from_kwargs(
            n_layers=self.n_layer_encoder,
            n_heads=self.n_head,
            query_dimensions=self.d_model // self.n_head,
            value_dimensions=self.d_model // self.n_head,
            feed_forward_dimensions=2048,
            activation='gelu',
            dropout=0.1,
            attention_type="causal-linear",
        ).get()

        # blend with type
        self.project_concat_type = nn.Linear(self.d_model + 32, self.d_model)

        # individual output
        self.proj_barbeat = nn.Linear(self.d_model, self.n_token[0])
        self.proj_type = nn.Linear(self.d_model, self.n_token[1])
        self.proj_beat_density = nn.Linear(self.d_model, self.n_token[2])
        self.proj_pitch = nn.Linear(self.d_model, self.n_token[3])
        self.proj_duration = nn.Linear(self.d_model, self.n_token[4])
        self.proj_instr = nn.Linear(self.d_model, self.n_token[5])
        self.proj_onset_density = nn.Linear(self.d_model, self.n_token[6])

    def compute_loss(self, predict, target, loss_mask):
        loss = self.loss_func(predict, target)
        loss = loss * loss_mask
        loss = torch.sum(loss) / torch.sum(loss_mask)
        return loss

    def forward_init_token_vis(self, x, memory=None, is_training=True):
        emb_genre = self.init_emb_genre(x[..., 0])
        emb_key = self.init_emb_key(x[..., 1])
        emb_instrument = self.init_emb_instrument(x[..., 2])
        return emb_genre, emb_key, emb_instrument

    def forward_init_token(self, x, memory=None, is_training=True):
        emb_genre = self.init_emb_genre(x[..., 0])
        emb_key = self.init_emb_key(x[..., 1])
        emb_instrument = self.init_emb_instrument(x[..., 2])
        embs = torch.cat(
            [
                emb_genre,
                emb_key,
                emb_instrument,
            ], dim=-1)
        encoder_emb_linear = self.init_in_linear(embs)
        if is_training:
            return encoder_emb_linear
        else:
            pos_emb = encoder_emb_linear.squeeze(0)
            h, memory = self.transformer_encoder(pos_emb, memory=memory)
            y_type = self.proj_type(h)
            return h, y_type, memory

    def forward_hidden(self, x, memory=None, is_training=True, init_token=None):
        # linear transformer: b, s, f   x.shape=(bs, nf)

        # embeddings
        emb_barbeat = self.encoder_emb_barbeat(x[..., 0])
        emb_type = self.encoder_emb_type(x[..., 1])
        emb_beat_density = self.encoder_emb_beat_density(x[..., 2])
        emb_pitch = self.encoder_emb_pitch(x[..., 3])
        emb_duration = self.encoder_emb_duration(x[..., 4])
        emb_instr = self.encoder_emb_instr(x[..., 5])
        emb_onset_density = self.encoder_emb_onset_density(x[..., 6])
        emb_time_encoding = self.encoder_emb_time_encoding(x[..., 7])

        embs = torch.cat(
            [
                emb_barbeat,
                emb_type,
                emb_beat_density,
                emb_pitch,
                emb_duration,
                emb_instr,
                emb_onset_density
            ], dim=-1)

        encoder_emb_linear = self.encoder_in_linear(embs)
        # import ipdb;ipdb.set_trace()
        encoder_emb_time_linear = self.encoder_time_linear(emb_time_encoding)
        encoder_emb_linear = encoder_emb_linear + encoder_emb_time_linear
        encoder_pos_emb = self.encoder_pos_emb(encoder_emb_linear, x[:, :, 8])

        if is_training:
            assert init_token is not None
            init_emb_linear = self.forward_init_token(init_token)
            encoder_pos_emb = torch.cat([init_emb_linear, encoder_pos_emb], dim=1)
        else:
            assert init_token is not None
            init_emb_linear = self.forward_init_token(init_token)
            encoder_pos_emb = torch.cat([init_emb_linear, encoder_pos_emb], dim=1)
        # transformer
        if is_training:
            attn_mask = TriangularCausalMask(encoder_pos_emb.size(1), device=x.device)
            encoder_hidden = self.transformer_encoder(encoder_pos_emb, attn_mask)
            # print("forward decoder done")
            y_type = self.proj_type(encoder_hidden[:, 7:, :])
            return encoder_hidden, y_type

        else:
            encoder_mask = TriangularCausalMask(encoder_pos_emb.size(1), device=x.device)
            h = self.transformer_encoder(encoder_pos_emb, encoder_mask)  # y: s x d_model
            h = h[:, -1:, :]
            h = h.squeeze(0)
            y_type = self.proj_type(h)

            return h, y_type

    def forward_output(self, h, y):
        # for training
        tf_skip_type = self.encoder_emb_type(y[..., 1])
        h = h[:, 7:, :]
        # project other
        y_concat_type = torch.cat([h, tf_skip_type], dim=-1)
        y_ = self.project_concat_type(y_concat_type)

        y_barbeat = self.proj_barbeat(y_)
        y_beat_density = self.proj_beat_density(y_)
        y_pitch = self.proj_pitch(y_)
        y_duration = self.proj_duration(y_)
        y_instr = self.proj_instr(y_)
        y_onset_density = self.proj_onset_density(y_)
        # import ipdb;ipdb.set_trace()

        return y_barbeat, y_pitch, y_duration, y_instr, y_onset_density, y_beat_density

    def forward_output_sampling(self, h, y_type, recurrent=True):
        '''
        for inference
        '''
        y_type_logit = y_type[0, :]  # dont know wtf
        cur_word_type = sampling(y_type_logit, p=0.90)

        type_word_t = torch.from_numpy(
            np.array([cur_word_type])).long().unsqueeze(0)

        if torch.cuda.is_available():
            type_word_t = type_word_t.cuda()

        tf_skip_type = self.encoder_emb_type(type_word_t).squeeze(0)

        # concat
        y_concat_type = torch.cat([h, tf_skip_type], dim=-1)
        y_ = self.project_concat_type(y_concat_type)

        # project other
        y_barbeat = self.proj_barbeat(y_)

        y_pitch = self.proj_pitch(y_)
        y_duration = self.proj_duration(y_)
        y_instr = self.proj_instr(y_)
        y_onset_density = self.proj_onset_density(y_)
        y_beat_density = self.proj_beat_density(y_)

        # sampling gen_cond
        cur_word_barbeat = sampling(y_barbeat, t=1.2)
        cur_word_pitch = sampling(y_pitch, p=0.9)
        cur_word_duration = sampling(y_duration, t=2, p=0.9)
        cur_word_instr = sampling(y_instr, p=0.90)
        cur_word_onset_density = sampling(y_onset_density, p=0.90)
        cur_word_beat_density = sampling(y_beat_density, p=0.90)

        # collect
        next_arr = np.array([
            cur_word_barbeat,
            cur_word_type,
            cur_word_beat_density,
            cur_word_pitch,
            cur_word_duration,
            cur_word_instr,
            cur_word_onset_density,
        ])
        return next_arr

    def inference_from_scratch(self, **kwargs):
        vlog = kwargs['vlog']
        C = kwargs['C']

        def get_p_beat(cur_bar, cur_beat, n_beat):
            all_beat = cur_bar * 16 + cur_beat - 1
            p_beat = round(all_beat / n_beat * 100) + 1
            return p_beat

        dictionary = {'bar': 17}
        strength_track_list = [1, 2, 3]

        pre_init = np.array([
            [5, 0, 0],
            [0, 0, 0],
            [0, 0, 1],
            [0, 0, 2],
            [0, 0, 3],
            [0, 0, 4],
            [0, 0, 5],
        ])
        init = np.array([
            [17, 1, vlog[0][1], 0, 0, 0, 0, 1, 0],  # bar
        ])

        with torch.no_grad():
            final_res = []
            h = None

            init_t = torch.from_numpy(init).long()
            pre_init = torch.from_numpy(pre_init).long().unsqueeze(0)
            if torch.cuda.is_available():
                pre_init = pre_init.cuda()
                init_t = init_t.cuda()

            print('------ initiate ------')
            for step in range(init.shape[0]):
                input_ = init_t[step, :].unsqueeze(0).unsqueeze(0)
                print(input_)
                final_res.append(init[step, :][None, ...])
                h, y_type = self.forward_hidden(input_, is_training=False, init_token=pre_init)

            print('------- condition -------')
            assert vlog is not None
            n_beat = vlog[0][4]
            len_vlog = len(vlog)
            cur_vlog = 1
            cur_track = 0
            idx = 0
            acc_beat_num = vlog[0][1]
            beat_num = {}
            acc_note_num = 0
            note_num = 0
            err_note_number_list = []
            err_beat_number_list = []
            p_beat = 1
            cur_bar = 0
            while (True):
                # sample others
                print(idx, end="\r")
                idx += 1
                next_arr = self.forward_output_sampling(h, y_type)
                if next_arr[1] == 1:
                    replace = False
                if next_arr[1] == 2 and next_arr[5] == 0:
                    next_arr[5] = 1
                    print("warning note with instrument 0 detected, replaced by drum###################")
                if cur_vlog >= len_vlog:
                    print("exceed vlog len")
                    break
                vlog_i = vlog[cur_vlog]
                if vlog_i[0] == dictionary['bar'] and next_arr[0] == dictionary['bar']:
                    err_beat_number = np.abs(len(beat_num.keys()) - acc_beat_num)
                    err_beat_number_list.append(err_beat_number)
                    flag = (np.random.rand() < C)
                    print("replace beat density-----", vlog_i, next_arr)
                    if flag:
                        next_arr = np.array([17, 1, vlog_i[1], 0, 0, 0, 0])
                        print("replace beat density-----", next_arr)
                        beat_num = {}
                        acc_beat_num = vlog_i[1]
                        replace = True
                        cur_vlog += 1
                    else:
                        print("replace denied----")
                        cur_vlog += 1
                elif vlog_i[0] < dictionary['bar'] and next_arr[0] >= vlog_i[0]:
                    err_note_number = np.abs(acc_note_num - note_num)
                    err_note_number_list.append(err_note_number)
                    print("replace onset density----", vlog_i, next_arr)
                    if cur_track == 0:
                        cur_density = next_arr[2]
                        flag = (np.random.rand() < C)
                        if next_arr[0] == dictionary['bar']:
                            cur_density = 1

                    next_arr = np.array(
                        [vlog_i[0], 1, cur_density, 0, 0, strength_track_list[cur_track], vlog_i[2] + 0])
                    replace = True
                    acc_note_num = vlog_i[2] + 0
                    note_num = 0
                    cur_track += 1
                    if cur_track >= len(strength_track_list):
                        cur_track = 0
                        cur_vlog += 1

                if next_arr[1] == 1:
                    beat_num[next_arr[0]] = 1
                elif next_arr[1] == 2 and replace == True:
                    note_num += 1

                if next_arr[0] == dictionary['bar']:
                    cur_bar += 1
                if next_arr[1] == 1:
                    if next_arr[0] == 17:
                        cur_beat = 1
                    else:
                        cur_beat = next_arr[0]
                    p_beat = get_p_beat(cur_bar, cur_beat, n_beat)
                if p_beat >= 102:
                    print("exceed max p_beat----")
                    break
                next_arr = np.concatenate([next_arr, [p_beat], [cur_bar * 16 + cur_beat - 1]])
                final_res.append(next_arr[None, ...])
                print(next_arr)
                # forward
                input_cur = torch.from_numpy(next_arr).long().unsqueeze(0).unsqueeze(0)
                if torch.cuda.is_available():
                    input_cur = input_cur.cuda()
                input_ = torch.cat((input_, input_cur), dim=1)
                if replace:
                    h, y_type = self.forward_hidden(input_, is_training=False, init_token=pre_init)
                else:
                    h, y_type = self.forward_hidden(input_, is_training=False, init_token=pre_init)
                if next_arr[1] == 0:
                    print("EOS predicted")
                    break

        print('\n--------[Done]--------')
        final_res = np.concatenate(final_res)
        print(final_res.shape)
        return final_res, err_note_number_list, err_beat_number_list


    def train_forward(self, **kwargs):
        x = kwargs['x']
        target = kwargs['target']
        loss_mask = kwargs['loss_mask']
        init_token = kwargs['init_token']
        h, y_type = self.forward_hidden(x, memory=None, is_training=True, init_token=init_token)
        y_barbeat, y_pitch, y_duration, y_instr, y_onset_density, y_beat_density = self.forward_output(h, target)

        # reshape (b, s, f) -> (b, f, s)
        y_barbeat = y_barbeat[:, ...].permute(0, 2, 1)
        y_type = y_type[:, ...].permute(0, 2, 1)
        y_pitch = y_pitch[:, ...].permute(0, 2, 1)
        y_duration = y_duration[:, ...].permute(0, 2, 1)
        y_instr = y_instr[:, ...].permute(0, 2, 1)
        y_onset_density = y_onset_density[:, ...].permute(0, 2, 1)
        y_beat_density = y_beat_density[:, ...].permute(0, 2, 1)

        # loss
        loss_barbeat = self.compute_loss(
            y_barbeat, target[..., 0], loss_mask)
        loss_type = self.compute_loss(
            y_type, target[..., 1], loss_mask)
        loss_beat_density = self.compute_loss(
            y_beat_density, target[..., 2], loss_mask)
        loss_pitch = self.compute_loss(
            y_pitch, target[..., 3], loss_mask)
        loss_duration = self.compute_loss(
            y_duration, target[..., 4], loss_mask)
        loss_instr = self.compute_loss(
            y_instr, target[..., 5], loss_mask)
        loss_onset_density = self.compute_loss(
            y_onset_density, target[..., 6], loss_mask)

        return loss_barbeat, loss_type, loss_pitch, loss_duration, loss_instr, loss_onset_density, loss_beat_density

    def forward(self, **kwargs):
        if kwargs['is_train']:
            return self.train_forward(**kwargs)
        return self.inference_from_scratch(**kwargs)

================================================
FILE: src/numpy2midi_mix.py
================================================
import muspy
import numpy as np

from midi2numpy_mix import Note, DECODER_DIMENSION, RESOLUTION
from dictionary_mix import preset_event2word

INSTRUMENT_PROGRAM = {
    'Drums'  : 114,
    'Piano'  : 0,  # Acoustic Grand Piano
    'Guitar' : 24,  # Acoustic Guitar (nylon)
    'Bass'   : 33,  # Electric Bass (finger)
    'Strings': 41  # Viola
}


def test_numpy2midi(idx: int) -> muspy.Music:
    npz = np.load('lpd_5_ccdepr_mix_v4_10000.npz', allow_pickle=True)
    decoder = npz['x'][idx]
    name = npz['metadata'][idx]['id']
    return numpy2midi(name, decoder)


def numpy2midi(name, decoder: np.ndarray) -> muspy.Music:
    muspy_tracks = []
    # Decoder
    n_bars = -1
    beat = 0
    track_notes = {instr_type: [] for instr_type in INSTRUMENT_PROGRAM.keys()}
    for word in decoder:
        w_type = word[DECODER_DIMENSION['type']]
        if w_type == preset_event2word['type']['M']:
            if word[DECODER_DIMENSION['beat']] == preset_event2word['beat']['Bar']:
                n_bars += 1
            elif word[DECODER_DIMENSION['beat']] > 0 and word[DECODER_DIMENSION['beat']] < 17:
                beat = word[DECODER_DIMENSION['beat']] - 1
        elif w_type == preset_event2word['type']['Note']:
            note = Note()
            muspy_note = note.from_decoder_array(np_array=word, bar=n_bars, beat=beat)
            track_notes[note.instr_type].append(muspy_note)
        else:
            assert w_type == preset_event2word['type']['EOS']
            break
    for instr_type, muspy_notes in track_notes.items():
        muspy_tracks.append(muspy.Track(
            program=INSTRUMENT_PROGRAM[instr_type],
            is_drum=(instr_type == 'Drums'),
            name=instr_type,
            notes=muspy_notes
        ))

    muspy_music = muspy.Music(resolution=RESOLUTION // 4, tracks=muspy_tracks)

    muspy.write_midi(name + ".mid", muspy_music)

    return muspy_music


if __name__ == '__main__':
    test_numpy2midi(idx=66)


================================================
FILE: src/pianoroll2midi.py
================================================
"""Author: Shangzhe Di (shangzhe.di@gmail.com)

Convert the pianoroll files (.npz) in the lpd-5/LPD-5-cleansed (https://salu133445.github.io/lakh-pianoroll-dataset/dataset) to midi files.

The pianoroll files are organized as:
lpd_5_cleansed
├── A
│   ├── A
│   │   ├── A
│   │   │   ├── TRAAAGR128F425B14B
│   │   │   │   └── b97c529ab9ef783a849b896816001748.npz
│   │   │   └── TRAAAZF12903CCCF6B
│   │   │       └── 05f21994c71a5f881e64f45c8d706165.npz
│   │   ├── B
│   │   │   └── TRAABXH128F42955D6
│   │   │       └── 04266ac849c1d3814dc03bbf61511b33.npz
...

The converted midi files will be organized as:
lpd_5_cleansed_midi/
├── TRDNFHP128F9324C47.mid
├── TRHIZHZ128F4295EFA.mid
├── TRRRAJP128E0793859.mid
├── TRRREEC128F9336C97.mid
├── TRRREEO128F933C62F.mid
├── TRRRERM128F429B7A0.mid
├── TRRRGET128F426655D.mid
...

"""

import pypianoroll
import argparse
import os
import os.path as osp
from tqdm import tqdm


def process_dataset(in_dir, out_dir):
    if not os.path.exists(out_dir):
        os.makedirs(out_dir)

    in_filename_list, out_filename_list = [], []
    for main_dir, sub_dir, filename_list in os.walk(in_dir):
        for filename in filename_list:
            if '.npz' not in filename:
                continue
            in_filename_list.append(osp.join(main_dir, filename))
            track_name = main_dir.split("/")[-1]
            out_filename_list.append(osp.join(out_dir, track_name + '.mid'))

    for i, in_filename in enumerate(tqdm(in_filename_list)):
        convert_midi(in_filename, out_filename_list[i])


def convert_midi(in_filename, out_filename):
    pianoroll = pypianoroll.load(in_filename)
    pypianoroll.write(out_filename, pianoroll)


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("--in_dir", help='the directory of the LPD dataset', default='./lpd_5_cleansed/')
    parser.add_argument("--out_dir", help='the directory of the output midi files', default='./lpd_5_cleansed_midi/')
    args = parser.parse_args()
    process_dataset(args.in_dir, args.out_dir)


================================================
FILE: src/train.py
================================================
import sys
import datetime
import argparse
import os
import time

import numpy as np
import torch
from torch import optim
from torch.nn.utils import clip_grad_norm_

sys.path.append(".")

import utils
from utils import log, Saver, network_paras
from model import CMT



def train_dp():
    parser = argparse.ArgumentParser(description="Args for training CMT")
    parser.add_argument('-n', '--name', default="debug",
                        help="Name of the experiment, also the log file and checkpoint directory. If 'debug', checkpoints won't be saved")
    parser.add_argument('-l', '--lr', default=0.0001, help="Initial learning rate")
    parser.add_argument('-b', '--batch_size', default=6, help="Batch size")
    parser.add_argument('-p', '--path', help="If set, load model from the given path")
    parser.add_argument('-e', '--epochs', default=200, help="Num of epochs")
    parser.add_argument('-t', '--train_data', default='../dataset/lpd_5_prcem_mix_v8_10000.npz',
                        help="Path of the training data (.npz file)")
    parser.add_argument('-g', '--gpus', type=int, nargs='+', help="Ids of gpu")
    args = parser.parse_args()

    if args.gpus is None:
        os.environ['CUDA_VISIBLE_DEVICES'] = ",".join([str(g) for g in list(range(torch.cuda.device_count()))])
    else:
        os.environ['CUDA_VISIBLE_DEVICES'] = ",".join([str(g) for g in args.gpus])

    path_train_data = args.train_data

    init_lr = float(args.lr)

    batch_size = int(args.batch_size)

    DEBUG = args.name == "debug"

    params = {
        "DECAY_EPOCH": [],
        "DECAY_RATIO": 0.1,
    }

    log("name:", args.name)
    log("args", args)

    if DEBUG:
        log("DEBUG MODE checkpoints will not be saved")
    else:
        utils.flog = open("../logs/" + args.name + ".log", "w")

    # hyper params
    n_epoch = args.epochs
    max_grad_norm = 3

    # config
    train_data = np.load(path_train_data, allow_pickle=True)
    train_x = train_data['x'][:, :, [1, 0, 2, 3, 4, 5, 6, 9, 7]]
    train_y = train_data['y'][:, :, [1, 0, 2, 3, 4, 5, 6, 9, 7]]
    train_mask = train_data['decoder_mask'][:, :9999]

    metadata = train_data['metadata']
    for i, m in enumerate(metadata):
        total = m["de_len"] - 1
        train_x[i, :total, 7] = train_x[i, :total, 7] + 1

    init_token = np.tile(np.array([
            [5, 0, 0],
            [0, 0, 0],
            [0, 0, 1],
            [0, 0, 2],
            [0, 0, 3],
            [0, 0, 4],
            [0, 0, 5],
        ]), (train_x.shape[0], 1, 1))

    num_batch = len(train_x) // batch_size

    # create saver
    saver_agent = Saver(exp_dir="../exp/" + args.name, debug=DEBUG)

    decoder_n_class = np.max(train_x, axis=(0, 1)) + 1
    init_n_class = [7, 1, 6]

    #    decoder_n_class = [18, 3, 18, 129, 18, 6, 20, 102, 5025]
    #    init_n_class = [7, 1, 6]

    # log
    log('num of encoder classes:', decoder_n_class, init_n_class)

    # init

    net = torch.nn.DataParallel(CMT(decoder_n_class, init_n_class))

    if torch.cuda.is_available():
        net.cuda()

    DEVICE_COUNT = torch.cuda.device_count()
    log("DEVICE COUNT:", DEVICE_COUNT)
    log("VISIBLE: " + os.environ["CUDA_VISIBLE_DEVICES"])

    net.train()
    n_parameters = network_paras(net)
    log('n_parameters: {:,}'.format(n_parameters))
    saver_agent.add_summary_msg(
        ' > params amount: {:,d}'.format(n_parameters))

    if args.path is not None:
        print('[*] load model from:', args.path)
        net.load_state_dict(torch.load(args.path))

    # optimizers
    optimizer = optim.Adam(net.parameters(), lr=init_lr)

    log('    train_data:', path_train_data.split("/")[-2])
    log('    batch_size:', batch_size)
    log('    num_batch:', num_batch)
    log('    train_x:', train_x.shape)
    log('    train_y:', train_y.shape)
    log('    train_mask:', train_mask.shape)
    log('    lr_init:', init_lr)
    for k, v in params.items():
        log(f'    {k}: {v}')

    # run
    start_time = time.time()
    for epoch in range(n_epoch):
        acc_loss = 0
        acc_losses = np.zeros(7)

        if epoch in params['DECAY_EPOCH']:
            log('LR decay by ratio', params['DECAY_RATIO'])
            for p in optimizer.param_groups:
                p['lr'] *= params['DECAY_RATIO']

        for bidx in range(num_batch):  # num_batch
            saver_agent.global_step_increment()

            # index
            bidx_st = batch_size * bidx
            bidx_ed = batch_size * (bidx + 1)

            # unpack batch data
            batch_x = train_x[bidx_st:bidx_ed]
            batch_y = train_y[bidx_st:bidx_ed]
            batch_mask = train_mask[bidx_st:bidx_ed]
            batch_init = init_token[bidx_st:bidx_ed]

            # to tensor
            batch_x = torch.from_numpy(batch_x).long()
            batch_y = torch.from_numpy(batch_y).long()
            batch_mask = torch.from_numpy(batch_mask).float()
            batch_init = torch.from_numpy(batch_init).long()

            if torch.cuda.is_available():
                batch_x = batch_x.cuda()
                batch_y = batch_y.cuda()
                batch_mask = batch_mask.cuda()
                batch_init = batch_init.cuda()

            # run
            losses = net(is_train=True, x=batch_x, target=batch_y, loss_mask=batch_mask, init_token=batch_init)
            losses = [l.sum() for l in losses]
            loss = (losses[0] + losses[1] + losses[2] + losses[3] + losses[4] + losses[5] + losses[6]) / 7

            # Update
            net.zero_grad()
            loss.backward()
            if max_grad_norm is not None:
                clip_grad_norm_(net.parameters(), max_grad_norm)
            optimizer.step()

            # print
            sys.stdout.write(
                '{}/{} | Loss: {:.3f} | barbeat {:.3f}, type {:.3f}, pitch {:.3f}, duration {:.3f}, instr {:.3f}, strength {:.3f}, density {:.3f}\r'.format(
                    bidx, num_batch, float(loss), losses[0], losses[1], losses[2], losses[3], losses[4], losses[5],
                    losses[6]))
            sys.stdout.flush()

            # acc
            acc_losses += np.array([l.item() for l in losses])
            acc_loss += loss.item()

            # log
            saver_agent.add_summary('batch loss', loss.item())

        # epoch loss
        runtime = time.time() - start_time
        epoch_loss = acc_loss / num_batch
        acc_losses = acc_losses / num_batch
        log('-' * 80)
        log(time.ctime() + ' epoch: {}/{} | Loss: {:.3f} | time: {}'.format(
            epoch, n_epoch, epoch_loss, str(datetime.timedelta(seconds=runtime))))
        each_loss_str = 'barbeat {:.3f}, type {:.3f}, pitch {:.3f}, duration {:.3f}, instr {:.3f}, strength {:.3f}, density {:.3f}\r'.format(
            acc_losses[0], acc_losses[1], acc_losses[2], acc_losses[3], acc_losses[4], acc_losses[5], acc_losses[6])
        log('each loss > ' + each_loss_str)

        saver_agent.add_summary('epoch loss', epoch_loss)
        saver_agent.add_summary('epoch each loss', each_loss_str)

        # save model, with policy
        loss = epoch_loss
        if 0.2 < loss:
            fn = int(loss * 10) * 10
            saver_agent.save_model(net, name='loss_' + str(fn))
        elif 0.001 < loss <= 0.20:
            fn = int(loss * 100)
            saver_agent.save_model(net, name='loss_' + str(fn))
        elif loss <= 0.001:
            log('Finished')
            return


#        else:
#            saver_agent.save_model(net, name='loss_high')


if __name__ == '__main__':
    train_dp()


================================================
FILE: src/utils.py
================================================
import math
import numpy as np
import torch
import torch.nn as nn

import os
import time
import collections
import matplotlib.pyplot as plt
import logging

flog = None


################################################################################
# Sampling
################################################################################
# -- temperature -- #
def softmax_with_temperature(logits, temperature):
    probs = np.exp(logits / temperature) / np.sum(np.exp(logits / temperature))
    return probs


def weighted_sampling(probs):
    probs /= sum(probs)
    sorted_probs = np.sort(probs)[::-1]
    sorted_index = np.argsort(probs)[::-1]
    word = np.random.choice(sorted_index, size=1, p=sorted_probs)[0]
    return word


# -- nucleus -- #
def nucleus(probs, p):
    probs /= (sum(probs) + 1e-5)
    sorted_probs = np.sort(probs)[::-1]
    sorted_index = np.argsort(probs)[::-1]
    cusum_sorted_probs = np.cumsum(sorted_probs)
    after_threshold = cusum_sorted_probs > p
    if sum(after_threshold) > 0:
        last_index = np.where(after_threshold)[0][0] + 1
        candi_index = sorted_index[:last_index]
    else:
        candi_index = sorted_index[:]
    candi_probs = [probs[i] for i in candi_index]
    candi_probs /= sum(candi_probs)
    word = np.random.choice(candi_index, size=1, p=candi_probs)[0]
    return word


def sampling(logit, p=None, t=1.0):
    logit = logit.squeeze().cpu().numpy()
    probs = softmax_with_temperature(logits=logit, temperature=t)

    if p is not None:
        cur_word = nucleus(probs, p=p)
    else:
        cur_word = weighted_sampling(probs)
    return cur_word


################################################################################
# Model
################################################################################


def network_paras(model):
    # compute only trainable params
    model_parameters = filter(lambda p: p.requires_grad, model.parameters())
    params = sum([np.prod(p.size()) for p in model_parameters])
    return params


class Embeddings(nn.Module):
    def __init__(self, n_token, d_model):
        super(Embeddings, self).__init__()
        self.lut = nn.Embedding(n_token, d_model)
        self.d_model = d_model

    def forward(self, x):
        return self.lut(x) * math.sqrt(self.d_model)


class PositionalEncoding(nn.Module):
    def __init__(self, d_model, dropout=0.1, max_len=20000):
        super(PositionalEncoding, self).__init__()
        self.dropout = nn.Dropout(p=dropout)

        pe = torch.zeros(max_len, d_model)
        position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
        div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-math.log(10000.0) / d_model))
        pe[:, 0::2] = torch.sin(position * div_term)
        pe[:, 1::2] = torch.cos(position * div_term)
        pe = pe.unsqueeze(0)
        self.register_buffer('pe', pe)

    def forward(self, x):
        # print(x.shape, self.pe[:, :x.size(1), :].shape)
        x = x + self.pe[:, :x.size(1), :]
        return self.dropout(x)


class BeatPositionalEncoding(nn.Module):
    def __init__(self, d_model, dropout=0.1, max_len=20000):
        super(BeatPositionalEncoding, self).__init__()
        self.dropout = nn.Dropout(p=dropout)

        pe = torch.zeros(max_len, d_model)
        position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
        div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-math.log(10000.0) / d_model))
        pe[:, 0::2] = torch.sin(position * div_term)
        pe[:, 1::2] = torch.cos(position * div_term)
        pe = pe.unsqueeze(0)
        self.register_buffer('pe', pe)

    def forward(self, x, index):
        x = x + self.pe[:, index, :]
        return self.dropout(x)[0]


class Saver(object):
    def __init__(
            self,
            exp_dir,
            mode='w',
            debug=False):

        self.exp_dir = exp_dir
        self.init_time = time.time()
        self.global_step = 0
        self.debug = debug

        # makedirs
        os.makedirs(exp_dir, exist_ok=True)

        # logging config
        path_logger = os.path.join(exp_dir, 'log.txt')
        logging.basicConfig(
            level=logging.DEBUG,
            format='%(message)s',
            filename=path_logger,
            filemode=mode)
        self.logger = logging.getLogger('training monitor')

    def add_summary_msg(self, msg):
        if self.debug:
            return
        self.logger.debug(msg)

    def add_summary(
            self,
            key,
            val,
            step=None,
            cur_time=None):
        if self.debug:
            return
        if cur_time is None:
            cur_time = time.time() - self.init_time
        if step is None:
            step = self.global_step

        # write msg (key, val, step, time)
        if isinstance(val, float):
            msg_str = '{:10s} | {:.10f} | {:10d} | {}'.format(
                key,
                val,
                step,
                cur_time
            )
        else:
            msg_str = '{:10s} | {} | {:10d} | {}'.format(
                key,
                val,
                step,
                cur_time
            )

        self.logger.debug(msg_str)

    def save_model(
            self,
            model,
            optimizer=None,
            outdir=None,
            name='model'):
        if self.debug:
            return
        if outdir is None:
            outdir = self.exp_dir
        print(' [*] saving model to {}, name: {}'.format(outdir, name))
        # torch.save(model, os.path.join(outdir, name+'.pt'))
        torch.save(model.state_dict(), os.path.join(outdir, name + '_params.pt'))

        if optimizer is not None:
            torch.save(optimizer.state_dict(), os.path.join(outdir, name + '_opt.pt'))

    def load_model(
            self,
            path_exp,
            device='cpu',
            name='model.pt'):

        path_pt = os.path.join(path_exp, name)
        print(' [*] restoring model from', path_pt)
        model = torch.load(path_pt, map_location=torch.device(device))
        return model

    def global_step_increment(self):
        self.global_step += 1


def make_loss_report(
        path_log,
        path_figure='loss.png',
        dpi=100):
    # load logfile
    monitor_vals = collections.defaultdict(list)
    with open(path_log, 'r') as f:
        for line in f:
            try:
                line = line.strip()
                key, val, step, acc_time = line.split(' | ')
                monitor_vals[key].append((float(val), int(step), acc_time))
            except:
                continue

    # collect
    step_train = [item[1] for item in monitor_vals['train loss']]
    vals_train = [item[0] for item in monitor_vals['train loss']]

    step_valid = [item[1] for item in monitor_vals['valid loss']]
    vals_valid = [item[0] for item in monitor_vals['valid loss']]

    x_min = step_valid[np.argmin(vals_valid)]
    y_min = min(vals_valid)

    # plot
    fig = plt.figure(dpi=dpi)
    plt.title('training process')
    plt.plot(step_train, vals_train, label='train')
    plt.plot(step_valid, vals_valid, label='valid')
    plt.yscale('log')
    plt.plot([x_min], [y_min], 'ro')
    plt.legend(loc='upper right')
    plt.tight_layout()
    plt.savefig(path_figure)


def log(*args, **kwargs):
    print(*args, **kwargs)
    if flog is not None:
        print(*args, file=flog, flush=True)

================================================
FILE: src/video2npz/dictionary_mix.py
================================================
preset_event2word = {
    "tempo"     : {
        0          : 0,
        "CONTI"    : 1,
        "Tempo_0"  : 2,
        "Tempo_1"  : 3,
        "Tempo_2"  : 4,
        "Tempo_3"  : 5,
        "Tempo_4"  : 6,
        "Tempo_5"  : 7,
        "Tempo_6"  : 8,
        "Tempo_7"  : 9,
        "Tempo_8"  : 10,
        "Tempo_9"  : 11,
        "Tempo_10" : 12,
        "Tempo_11" : 13,
        "Tempo_12" : 14,
        "Tempo_13" : 15,
        "Tempo_14" : 16,
        "Tempo_15" : 17,
        "Tempo_16" : 18,
        "Tempo_17" : 19,
        "Tempo_18" : 20,
        "Tempo_19" : 21,
        "Tempo_20" : 22,
        "Tempo_21" : 23,
        "Tempo_22" : 24,
        "Tempo_23" : 25,
        "Tempo_24" : 26,
        "Tempo_25" : 27,
        "Tempo_26" : 28,
        "Tempo_27" : 29,
        "Tempo_28" : 30,
        "Tempo_29" : 31,
        "Tempo_30" : 32,
        "Tempo_31" : 33,
        "Tempo_32" : 34,
        "Tempo_33" : 35,
        "Tempo_34" : 36,
        "Tempo_35" : 37,
        "Tempo_36" : 38,
        "Tempo_37" : 39,
        "Tempo_38" : 40,
        "Tempo_39" : 41,
        "Tempo_40" : 42,
        "Tempo_41" : 43,
        "Tempo_42" : 44,
        "Tempo_43" : 45,
        "Tempo_44" : 46,
        "Tempo_45" : 47,
        "Tempo_46" : 48,
        "Tempo_47" : 49,
        "Tempo_48" : 50,
        "Tempo_49" : 51,
        "Tempo_50" : 52,
        "Tempo_51" : 53,
        "Tempo_52" : 54,
        "Tempo_53" : 55,
        "Tempo_54" : 56,
        "Tempo_55" : 57,
        "Tempo_56" : 58,
        "Tempo_57" : 59,
        "Tempo_58" : 60,
        "Tempo_59" : 61,
        "Tempo_60" : 62,
        "Tempo_61" : 63,
        "Tempo_62" : 64,
        "Tempo_63" : 65,
        "Tempo_64" : 66,
        "Tempo_65" : 67,
        "Tempo_66" : 68,
        "Tempo_67" : 69,
        "Tempo_68" : 70,
        "Tempo_69" : 71,
        "Tempo_70" : 72,
        "Tempo_71" : 73,
        "Tempo_72" : 74,
        "Tempo_73" : 75,
        "Tempo_74" : 76,
        "Tempo_75" : 77,
        "Tempo_76" : 78,
        "Tempo_77" : 79,
        "Tempo_78" : 80,
        "Tempo_79" : 81,
        "Tempo_80" : 82,
        "Tempo_81" : 83,
        "Tempo_82" : 84,
        "Tempo_83" : 85,
        "Tempo_84" : 86,
        "Tempo_85" : 87,
        "Tempo_86" : 88,
        "Tempo_87" : 89,
        "Tempo_88" : 90,
        "Tempo_89" : 91,
        "Tempo_90" : 92,
        "Tempo_91" : 93,
        "Tempo_92" : 94,
        "Tempo_93" : 95,
        "Tempo_94" : 96,
        "Tempo_95" : 97,
        "Tempo_96" : 98,
        "Tempo_97" : 99,
        "Tempo_98" : 100,
        "Tempo_99" : 101,
        "Tempo_100": 102,
        "Tempo_101": 103,
        "Tempo_102": 104,
        "Tempo_103": 105,
        "Tempo_104": 106,
        "Tempo_105": 107,
        "Tempo_106": 108,
        "Tempo_107": 109,
        "Tempo_108": 110,
        "Tempo_109": 111,
        "Tempo_110": 112,
        "Tempo_111": 113,
        "Tempo_112": 114,
        "Tempo_113": 115,
        "Tempo_114": 116,
        "Tempo_115": 117,
        "Tempo_116": 118,
        "Tempo_117": 119,
        "Tempo_118": 120,
        "Tempo_119": 121,
        "Tempo_120": 122,
        "Tempo_121": 123,
        "Tempo_122": 124,
        "Tempo_123": 125,
        "Tempo_124": 126,
        "Tempo_125": 127,
        "Tempo_126": 128,
        "Tempo_127": 129,
        "Tempo_128": 130,
        "Tempo_129": 131,
        "Tempo_130": 132,
        "Tempo_131": 133,
        "Tempo_132": 134,
        "Tempo_133": 135,
        "Tempo_134": 136,
        "Tempo_135": 137,
        "Tempo_136": 138,
        "Tempo_137": 139,
        "Tempo_138": 140,
        "Tempo_139": 141,
        "Tempo_140": 142,
        "Tempo_141": 143,
        "Tempo_142": 144,
        "Tempo_143": 145,
        "Tempo_144": 146,
        "Tempo_145": 147,
        "Tempo_146": 148,
        "Tempo_147": 149,
        "Tempo_148": 150,
        "Tempo_149": 151,
        "Tempo_150": 152,
        "Tempo_151": 153,
        "Tempo_152": 154,
        "Tempo_153": 155,
        "Tempo_154": 156,
        "Tempo_155": 157,
        "Tempo_156": 158,
        "Tempo_157": 159,
        "Tempo_158": 160,
        "Tempo_159": 161,
        "Tempo_160": 162,
        "Tempo_161": 163,
        "Tempo_162": 164,
        "Tempo_163": 165,
        "Tempo_164": 166,
        "Tempo_165": 167,
        "Tempo_166": 168,
        "Tempo_167": 169,
        "Tempo_168": 170,
        "Tempo_169": 171,
        "Tempo_170": 172,
        "Tempo_171": 173,
        "Tempo_172": 174,
        "Tempo_173": 175,
        "Tempo_174": 176,
        "Tempo_175": 177,
        "Tempo_176": 178,
        "Tempo_177": 179,
        "Tempo_178": 180,
        "Tempo_179": 181,
        "Tempo_180": 182,
        "Tempo_181": 183,
        "Tempo_182": 184,
        "Tempo_183": 185,
        "Tempo_184": 186,
        "Tempo_185": 187,
        "Tempo_186": 188,
        "Tempo_187": 189,
        "Tempo_188": 190,
        "Tempo_189": 191,
        "Tempo_190": 192,
        "Tempo_191": 193,
        "Tempo_192": 194,
        "Tempo_193": 195,
        "Tempo_194": 196,
        "Tempo_195": 197,
        "Tempo_196": 198,
        "Tempo_197": 199,
        "Tempo_198": 200,
        "Tempo_199": 201,
        "Tempo_200": 202,
        "Tempo_201": 203,
        "Tempo_202": 204,
        "Tempo_203": 205,
        "Tempo_204": 206,
        "Tempo_205": 207,
        "Tempo_206": 208,
        "Tempo_207": 209,
        "Tempo_208": 210,
        "Tempo_209": 211,
        "Tempo_210": 212,
        "Tempo_211": 213,
        "Tempo_212": 214,
        "Tempo_213": 215,
        "Tempo_214": 216,
        "Tempo_215": 217,
        "Tempo_216": 218,
        "Tempo_217": 219,
        "Tempo_218": 220,
        "Tempo_219": 221,
        "Tempo_220": 222,
        "Tempo_221": 223,
        "Tempo_222": 224,
        "Tempo_223": 225,
        "Tempo_224": 226,
        "Tempo_225": 227,
        "Tempo_226": 228,
        "Tempo_227": 229,
        "Tempo_228": 230,
        "Tempo_229": 231,
        "Tempo_230": 232,
        "Tempo_231": 233,
        "Tempo_232": 234,
        "Tempo_233": 235,
        "Tempo_234": 236,
        "Tempo_235": 237,
        "Tempo_236": 238,
        "Tempo_237": 239,
        "Tempo_238": 240,
        "Tempo_239": 241,
        "Tempo_240": 242,
        "Tempo_241": 243,
        "Tempo_242": 244,
        "Tempo_243": 245,
        "Tempo_244": 246,
        "Tempo_245": 247,
        "Tempo_246": 248,
        "Tempo_247": 249,
        "Tempo_248": 250,
        "Tempo_249": 251,
        "Tempo_250": 252,
        "Tempo_251": 253,
        "Tempo_252": 254,
        "Tempo_253": 255,
        "Tempo_254": 256,
        "Tempo_255": 257,
        "Tempo_256": 258,
        "Tempo_257": 259,
        "Tempo_258": 260,
        "Tempo_259": 261,
        "Tempo_260": 262,
        "Tempo_261": 263,
        "Tempo_262": 264,
        "Tempo_263": 265,
        "Tempo_264": 266,
        "Tempo_265": 267,
        "Tempo_266": 268,
        "Tempo_267": 269,
        "Tempo_268": 270,
        "Tempo_269": 271,
        "Tempo_270": 272,
        "Tempo_271": 273,
        "Tempo_272": 274,
        "Tempo_273": 275,
        "Tempo_274": 276,
        "Tempo_275": 277,
        "Tempo_276": 278,
        "Tempo_277": 279,
        "Tempo_278": 280,
        "Tempo_279": 281,
        "Tempo_280": 282,
        "Tempo_281": 283,
        "Tempo_282": 284,
        "Tempo_283": 285,
        "Tempo_284": 286,
        "Tempo_285": 287,
        "Tempo_286": 288,
        "Tempo_287": 289,
        "Tempo_288": 290,
        "Tempo_289": 291,
        "Tempo_290": 292,
        "Tempo_291": 293,
        "Tempo_292": 294,
        "Tempo_293": 295,
        "Tempo_294": 296,
        "Tempo_295": 297,
        "Tempo_296": 298,
        "Tempo_297": 299,
        "Tempo_298": 300,
        "Tempo_299": 301,
        "Tempo_300": 302,
        "Tempo_301": 303,
        "Tempo_302": 304,
        "Tempo_303": 305,
        "Tempo_304": 306,
        "Tempo_305": 307,
        "Tempo_306": 308,
        "Tempo_307": 309,
        "Tempo_308": 310,
        "Tempo_309": 311,
        "Tempo_310": 312,
        "Tempo_311": 313,
        "Tempo_312": 314,
        "Tempo_313": 315,
        "Tempo_314": 316,
        "Tempo_315": 317,
        "Tempo_316": 318,
        "Tempo_317": 319,
        "Tempo_318": 320,
        "Tempo_319": 321,
        "Tempo_320": 322,
        "Tempo_321": 323,
        "Tempo_322": 324,
        "Tempo_323": 325,
        "Tempo_324": 326,
        "Tempo_325": 327,
        "Tempo_326": 328,
        "Tempo_327": 329,
        "Tempo_328": 330,
        "Tempo_329": 331,
        "Tempo_330": 332,
        "Tempo_331": 333,
        "Tempo_332": 334,
        "Tempo_333": 335,
        "Tempo_334": 336,
        "Tempo_335": 337,
        "Tempo_336": 338,
        "Tempo_337": 339,
        "Tempo_338": 340,
        "Tempo_339": 341,
        "Tempo_340": 342,
        "Tempo_341": 343,
        "Tempo_342": 344,
        "Tempo_343": 345,
        "Tempo_344": 346,
        "Tempo_345": 347,
        "Tempo_346": 348,
        "Tempo_347": 349,
        "Tempo_348": 350,
        "Tempo_349": 351,
        "Tempo_350": 352,
        "Tempo_351": 353,
        "Tempo_352": 354,
        "Tempo_353": 355,
        "Tempo_354": 356,
        "Tempo_355": 357,
        "Tempo_356": 358,
        "Tempo_357": 359,
        "Tempo_358": 360,
        "Tempo_359": 361,
        "Tempo_360": 362
    },
    "chord"     : {
        0      : 0,
        "CONTI": 1
    },
    "beat"      : {
        0        : 0,
        "Beat_0" : 1,
        "Beat_1" : 2,
        "Beat_2" : 3,
        "Beat_3" : 4,
        "Beat_4" : 5,
        "Beat_5" : 6,
        "Beat_6" : 7,
        "Beat_7" : 8,
        "Beat_8" : 9,
        "Beat_9" : 10,
        "Beat_10": 11,
        "Beat_11": 12,
        "Beat_12": 13,
        "Beat_13": 14,
        "Beat_14": 15,
        "Beat_15": 16,
        "Bar"    : 17,
    },
    "type"      : {
        "EOS"   : 0,
        "M"     : 1,
        "Note"  : 2,
        'Global': 3,
    },
    "instr_type": {
        'None'   : 0,
        'Drums'  : 1,
        'Piano'  : 2,
        'Guitar' : 3,
        'Bass'   : 4,
        'Strings': 5,
    },
    "key/genre" : {
        "None"      : 0,
        'C'         : 5,
        'C#'        : 6,
        'D'         : 7,
        'D#'        : 8,
        'E'         : 9,
        'F'         : 10,
        'F#'        : 11,
        'G'         : 12,
        'G#'        : 13,
        'A'         : 14,
        'A#'        : 15,
        'B'         : 16,
        'c'         : 17,
        'c#'        : 18,
        'd'         : 19,
        'd#'        : 20,
        'e'         : 21,
        'f'         : 22,
        'f#'        : 23,
        'g'         : 24,
        'g#'        : 25,
        'a'         : 26,
        'a#'        : 27,
        'b'         : 28,

        'classic'   : 29,
        'country'   : 30,
        'dance'     : 31,
        'electronic': 32,
        'pop'       : 33,
        'rock'      : 34,

        # 'happy': 29,
        # 'sad': 30,

        # 'Rock':         29,
        # 'Rap':          30,
        # 'Latin':        31,
        # 'Jazz':         32,
        # 'Electronic':   33,
        # 'Punk':         34,
        # 'Pop':          35,
        # 'New Age':      36,
        # 'Metal':        37,
        # 'RnB':          38,
        # 'Country':      39,
        # 'Reggae':       40,
        # 'Folk':         41,
        # 'Blues':        42,
        # 'World':        43
    },
    "pitch"     : {
        0               : 0,
        "Note_Pitch_0"  : 1,
        "Note_Pitch_1"  : 2,
        "Note_Pitch_2"  : 3,
        "Note_Pitch_3"  : 4,
        "Note_Pitch_4"  : 5,
        "Note_Pitch_5"  : 6,
        "Note_Pitch_6"  : 7,
        "Note_Pitch_7"  : 8,
        "Note_Pitch_8"  : 9,
        "Note_Pitch_9"  : 10,
        "Note_Pitch_10" : 11,
        "Note_Pitch_11" : 12,
        "Note_Pitch_12" : 13,
        "Note_Pitch_13" : 14,
        "Note_Pitch_14" : 15,
        "Note_Pitch_15" : 16,
        "Note_Pitch_16" : 17,
        "Note_Pitch_17" : 18,
        "Note_Pitch_18" : 19,
        "Note_Pitch_19" : 20,
        "Note_Pitch_20" : 21,
        "Note_Pitch_21" : 22,
        "Note_Pitch_22" : 23,
        "Note_Pitch_23" : 24,
        "Note_Pitch_24" : 25,
        "Note_Pitch_25" : 26,
        "Note_Pitch_26" : 27,
        "Note_Pitch_27" : 28,
        "Note_Pitch_28" : 29,
        "Note_Pitch_29" : 30,
        "Note_Pitch_30" : 31,
        "Note_Pitch_31" : 32,
        "Note_Pitch_32" : 33,
        "Note_Pitch_33" : 34,
        "Note_Pitch_34" : 35,
        "Note_Pitch_35" : 36,
        "Note_Pitch_36" : 37,
        "Note_Pitch_37" : 38,
        "Note_Pitch_38" : 39,
        "Note_Pitch_39" : 40,
        "Note_Pitch_40" : 41,
        "Note_Pitch_41" : 42,
        "Note_Pitch_42" : 43,
        "Note_Pitch_43" : 44,
        "Note_Pitch_44" : 45,
        "Note_Pitch_45" : 46,
        "Note_Pitch_46" : 47,
        "Note_Pitch_47" : 48,
        "Note_Pitch_48" : 49,
        "Note_Pitch_49" : 50,
        "Note_Pitch_50" : 51,
        "Note_Pitch_51" : 52,
        "Note_Pitch_52" : 53,
        "Note_Pitch_53" : 54,
        "Note_Pitch_54" : 55,
        "Note_Pitch_55" : 56,
        "Note_Pitch_56" : 57,
        "Note_Pitch_57" : 58,
        "Note_Pitch_58" : 59,
        "Note_Pitch_59" : 60,
        "Note_Pitch_60" : 61,
        "Note_Pitch_61" : 62,
        "Note_Pitch_62" : 63,
        "Note_Pitch_63" : 64,
        "Note_Pitch_64" : 65,
        "Note_Pitch_65" : 66,
        "Note_Pitch_66" : 67,
        "Note_Pitch_67" : 68,
        "Note_Pitch_68" : 69,
        "Note_Pitch_69" : 70,
        "Note_Pitch_70" : 71,
        "Note_Pitch_71" : 72,
        "Note_Pitch_72" : 73,
        "Note_Pitch_73" : 74,
        "Note_Pitch_74" : 75,
        "Note_Pitch_75" : 76,
        "Note_Pitch_76" : 77,
        "Note_Pitch_77" : 78,
        "Note_Pitch_78" : 79,
        "Note_Pitch_79" : 80,
        "Note_Pitch_80" : 81,
        "Note_Pitch_81" : 82,
        "Note_Pitch_82" : 83,
        "Note_Pitch_83" : 84,
        "Note_Pitch_84" : 85,
        "Note_Pitch_85" : 86,
        "Note_Pitch_86" : 87,
        "Note_Pitch_87" : 88,
        "Note_Pitch_88" : 89,
        "Note_Pitch_89" : 90,
        "Note_Pitch_90" : 91,
        "Note_Pitch_91" : 92,
        "Note_Pitch_92" : 93,
        "Note_Pitch_93" : 94,
        "Note_Pitch_94" : 95,
        "Note_Pitch_95" : 96,
        "Note_Pitch_96" : 97,
        "Note_Pitch_97" : 98,
        "Note_Pitch_98" : 99,
        "Note_Pitch_99" : 100,
        "Note_Pitch_100": 101,
        "Note_Pitch_101": 102,
        "Note_Pitch_102": 103,
        "Note_Pitch_103": 104,
        "Note_Pitch_104": 105,
        "Note_Pitch_105": 106,
        "Note_Pitch_106": 107,
        "Note_Pitch_107": 108,
        "Note_Pitch_108": 109,
        "Note_Pitch_109": 110,
        "Note_Pitch_110": 111,
        "Note_Pitch_111": 112,
        "Note_Pitch_112": 113,
        "Note_Pitch_113": 114,
        "Note_Pitch_114": 115,
        "Note_Pitch_115": 116,
        "Note_Pitch_116": 117,
        "Note_Pitch_117": 118,
        "Note_Pitch_118": 119,
        "Note_Pitch_119": 120,
        "Note_Pitch_120": 121,
        "Note_Pitch_121": 122,
        "Note_Pitch_122": 123,
        "Note_Pitch_123": 124,
        "Note_Pitch_124": 125,
        "Note_Pitch_125": 126,
        "Note_Pitch_126": 127,
        "Note_Pitch_127": 128,
    },
    "duration"  : {
        0                   : 0,
        "Note_Duration_0"   : 1,
        "Note_Duration_120" : 2,
        "Note_Duration_240" : 3,
        "Note_Duration_360" : 4,
        "Note_Duration_480" : 5,
        "Note_Duration_600" : 6,
        "Note_Duration_720" : 7,
        "Note_Duration_840" : 8,
        "Note_Duration_960" : 9,
        "Note_Duration_1080": 10,
        "Note_Duration_1200": 11,
        "Note_Duration_1320": 12,
        "Note_Duration_1440": 13,
        "Note_Duration_1560": 14,
        "Note_Duration_1680": 15,
        "Note_Duration_1800": 16,
        "Note_Duration_1920": 17
    },
    "velocity"  : {
        0                  : 0,
        "Note_Velocity_0"  : 1,
        "Note_Velocity_1"  : 2,
        "Note_Velocity_2"  : 3,
        "Note_Velocity_3"  : 4,
        "Note_Velocity_4"  : 5,
        "Note_Velocity_5"  : 6,
        "Note_Velocity_6"  : 7,
        "Note_Velocity_7"  : 8,
        "Note_Velocity_8"  : 9,
        "Note_Velocity_9"  : 10,
        "Note_Velocity_10" : 11,
        "Note_Velocity_11" : 12,
        "Note_Velocity_12" : 13,
        "Note_Velocity_13" : 14,
        "Note_Velocity_14" : 15,
        "Note_Velocity_15" : 16,
        "Note_Velocity_16" : 17,
        "Note_Velocity_17" : 18,
        "Note_Velocity_18" : 19,
        "Note_Velocity_19" : 20,
        "Note_Velocity_20" : 21,
        "Note_Velocity_21" : 22,
        "Note_Velocity_22" : 23,
        "Note_Velocity_23" : 24,
        "Note_Velocity_24" : 25,
        "Note_Velocity_25" : 26,
        "Note_Velocity_26" : 27,
        "Note_Velocity_27" : 28,
        "Note_Velocity_28" : 29,
        "Note_Velocity_29" : 30,
        "Note_Velocity_30" : 31,
        "Note_Velocity_31" : 32,
        "Note_Velocity_32" : 33,
        "Note_Velocity_33" : 34,
        "Note_Velocity_34" : 35,
        "Note_Velocity_35" : 36,
        "Note_Velocity_36" : 37,
        "Note_Velocity_37" : 38,
        "Note_Velocity_38" : 39,
        "Note_Velocity_39" : 40,
        "Note_Velocity_40" : 41,
        "Note_Velocity_41" : 42,
        "Note_Velocity_42" : 43,
        "Note_Velocity_43" : 44,
        "Note_Velocity_44" : 45,
        "Note_Velocity_45" : 46,
        "Note_Velocity_46" : 47,
        "Note_Velocity_47" : 48,
        "Note_Velocity_48" : 49,
        "Note_Velocity_49" : 50,
        "Note_Velocity_50" : 51,
        "Note_Velocity_51" : 52,
        "Note_Velocity_52" : 53,
        "Note_Velocity_53" : 54,
        "Note_Velocity_54" : 55,
        "Note_Velocity_55" : 56,
        "Note_Velocity_56" : 57,
        "Note_Velocity_57" : 58,
        "Note_Velocity_58" : 59,
        "Note_Velocity_59" : 60,
        "Note_Velocity_60" : 61,
        "Note_Velocity_61" : 62,
        "Note_Velocity_62" : 63,
        "Note_Velocity_63" : 64,
        "Note_Velocity_64" : 65,
        "Note_Velocity_65" : 66,
        "Note_Velocity_66" : 67,
        "Note_Velocity_67" : 68,
        "Note_Velocity_68" : 69,
        "Note_Velocity_69" : 70,
        "Note_Velocity_70" : 71,
        "Note_Velocity_71" : 72,
        "Note_Velocity_72" : 73,
        "Note_Velocity_73" : 74,
        "Note_Velocity_74" : 75,
        "Note_Velocity_75" : 76,
        "Note_Velocity_76" : 77,
        "Note_Velocity_77" : 78,
        "Note_Velocity_78" : 79,
        "Note_Velocity_79" : 80,
        "Note_Velocity_80" : 81,
        "Note_Velocity_81" : 82,
        "Note_Velocity_82" : 83,
        "Note_Velocity_83" : 84,
        "Note_Velocity_84" : 85,
        "Note_Velocity_85" : 86,
        "Note_Velocity_86" : 87,
        "Note_Velocity_87" : 88,
        "Note_Velocity_88" : 89,
        "Note_Velocity_89" : 90,
        "Note_Velocity_90" : 91,
        "Note_Velocity_91" : 92,
        "Note_Velocity_92" : 93,
        "Note_Velocity_93" : 94,
        "Note_Velocity_94" : 95,
        "Note_Velocity_95" : 96,
        "Note_Velocity_96" : 97,
        "Note_Velocity_97" : 98,
        "Note_Velocity_98" : 99,
        "Note_Velocity_99" : 100,
        "Note_Velocity_100": 101,
        "Note_Velocity_101": 102,
        "Note_Velocity_102": 103,
        "Note_Velocity_103": 104,
        "Note_Velocity_104": 105,
        "Note_Velocity_105": 106,
        "Note_Velocity_106": 107,
        "Note_Velocity_107": 108,
        "Note_Velocity_108": 109,
        "Note_Velocity_109": 110,
        "Note_Velocity_110": 111,
        "Note_Velocity_111": 112,
        "Note_Velocity_112": 113,
        "Note_Velocity_113": 114,
        "Note_Velocity_114": 115,
        "Note_Velocity_115": 116,
        "Note_Velocity_116": 117,
        "Note_Velocity_117": 118,
        "Note_Velocity_118": 119,
        "Note_Velocity_119": 120,
        "Note_Velocity_120": 121,
        "Note_Velocity_121": 122,
        "Note_Velocity_122": 123,
        "Note_Velocity_123": 124,
        "Note_Velocity_124": 125,
        "Note_Velocity_125": 126,
        "Note_Velocity_126": 127,
        "Note_Velocity_127": 128,
        "Note_Velocity_128": 129,
        "Note_Velocity_129": 130,
        "Note_Velocity_130": 131,
        "Note_Velocity_131": 132,
        "Note_Velocity_132": 133,
        "Note_Velocity_133": 134,
        "Note_Velocity_134": 135,
        "Note_Velocity_135": 136,
        "Note_Velocity_136": 137,
        "Note_Velocity_137": 138,
        "Note_Velocity_138": 139,
        "Note_Velocity_139": 140,
        "Note_Velocity_140": 141,
        "Note_Velocity_141": 142,
        "Note_Velocity_142": 143,
        "Note_Velocity_143": 144,
        "Note_Velocity_144": 145,
        "Note_Velocity_145": 146,
        "Note_Velocity_146": 147,
        "Note_Velocity_147": 148,
        "Note_Velocity_148": 149,
        "Note_Velocity_149": 150,
        "Note_Velocity_150": 151,
        "Note_Velocity_151": 152,
        "Note_Velocity_152": 153,
        "Note_Velocity_153": 154,
        "Note_Velocity_154": 155,
        "Note_Velocity_155": 156,
        "Note_Velocity_156": 157,
        "Note_Velocity_157": 158,
        "Note_Velocity_158": 159,
        "Note_Velocity_159": 160,
        "Note_Velocity_160": 161,
        "Note_Velocity_161": 162,
        "Note_Velocity_162": 163,
        "Note_Velocity_163": 164,
        "Note_Velocity_164": 165,
        "Note_Velocity_165": 166,
        "Note_Velocity_166": 167,
        "Note_Velocity_167": 168,
        "Note_Velocity_168": 169,
        "Note_Velocity_169": 170,
        "Note_Velocity_170": 171,
        "Note_Velocity_171": 172,
        "Note_Velocity_172": 173,
        "Note_Velocity_173": 174,
        "Note_Velocity_174": 175,
        "Note_Velocity_175": 176,
        "Note_Velocity_176": 177,
        "Note_Velocity_177": 178,
        "Note_Velocity_178": 179,
        "Note_Velocity_179": 180,
        "Note_Velocity_180": 181,
        "Note_Velocity_181": 182,
        "Note_Velocity_182": 183,
        "Note_Velocity_183": 184,
        "Note_Velocity_184": 185,
        "Note_Velocity_185": 186,
        "Note_Velocity_186": 187,
        "Note_Velocity_187": 188,
        "Note_Velocity_188": 189,
        "Note_Velocity_189": 190,
        "Note_Velocity_190": 191,
        "Note_Velocity_191": 192,
        "Note_Velocity_192": 193,
        "Note_Velocity_193": 194,
        "Note_Velocity_194": 195,
        "Note_Velocity_195": 196,
        "Note_Velocity_196": 197,
        "Note_Velocity_197": 198,
        "Note_Velocity_198": 199,
        "Note_Velocity_199": 200,
        "Note_Velocity_200": 201,
        "Note_Velocity_201": 202,
        "Note_Velocity_202": 203,
        "Note_Velocity_203": 204,
        "Note_Velocity_204": 205,
        "Note_Velocity_205": 206,
        "Note_Velocity_206": 207,
        "Note_Velocity_207": 208,
        "Note_Velocity_208": 209,
        "Note_Velocity_209": 210,
        "Note_Velocity_210": 211,
        "Note_Velocity_211": 212,
        "Note_Velocity_212": 213,
        "Note_Velocity_213": 214,
        "Note_Velocity_214": 215,
        "Note_Velocity_215": 216,
        "Note_Velocity_216": 217,
        "Note_Velocity_217": 218,
        "Note_Velocity_218": 219,
        "Note_Velocity_219": 220,
        "Note_Velocity_220": 221,
        "Note_Velocity_221": 222,
        "Note_Velocity_222": 223,
        "Note_Velocity_223": 224,
        "Note_Velocity_224": 225,
        "Note_Velocity_225": 226,
        "Note_Velocity_226": 227,
        "Note_Velocity_227": 228,
        "Note_Velocity_228": 229,
        "Note_Velocity_229": 230,
        "Note_Velocity_230": 231,
        "Note_Velocity_231": 232,
        "Note_Velocity_232": 233,
        "Note_Velocity_233": 234,
        "Note_Velocity_234": 235,
        "Note_Velocity_235": 236,
        "Note_Velocity_236": 237,
        "Note_Velocity_237": 238,
        "Note_Velocity_238": 239,
        "Note_Velocity_239": 240,
        "Note_Velocity_240": 241,
        "Note_Velocity_241": 242,
        "Note_Velocity_242": 243,
        "Note_Velocity_243": 244,
        "Note_Velocity_244": 245,
        "Note_Velocity_245": 246,
        "Note_Velocity_246": 247,
        "Note_Velocity_247": 248,
        "Note_Velocity_248": 249,
        "Note_Velocity_249": 250,
        "Note_Velocity_250": 251,
        "Note_Velocity_251": 252,
        "Note_Velocity_252": 253,
        "Note_Velocity_253": 254,
        "Note_Velocity_254": 255,
        "Note_Velocity_255": 256,
        "Note_Velocity_256": 257,
        "Note_Velocity_257": 258,
        "Note_Velocity_258": 259,
        "Note_Velocity_259": 260,
        "Note_Velocity_260": 261,
        "Note_Velocity_261": 262,
        "Note_Velocity_262": 263,
        "Note_Velocity_263": 264,
        "Note_Velocity_264": 265,
        "Note_Velocity_265": 266,
        "Note_Velocity_266": 267,
        "Note_Velocity_267": 268,
        "Note_Velocity_268": 269,
        "Note_Velocity_269": 270,
        "Note_Velocity_270": 271,
        "Note_Velocity_271": 272,
        "Note_Velocity_272": 273,
        "Note_Velocity_273": 274,
        "Note_Velocity_274": 275,
        "Note_Velocity_275": 276,
        "Note_Velocity_276": 277,
        "Note_Velocity_277": 278,
        "Note_Velocity_278": 279,
        "Note_Velocity_279": 280,
        "Note_Velocity_280": 281,
        "Note_Velocity_281": 282,
        "Note_Velocity_282": 283,
        "Note_Velocity_283": 284,
        "Note_Velocity_284": 285,
        "Note_Velocity_285": 286,
        "Note_Velocity_286": 287,
        "Note_Velocity_287": 288,
        "Note_Velocity_288": 289,
        "Note_Velocity_289": 290,
        "Note_Velocity_290": 291,
        "Note_Velocity_291": 292,
        "Note_Velocity_292": 293,
        "Note_Velocity_293": 294,
        "Note_Velocity_294": 295,
        "Note_Velocity_295": 296,
        "Note_Velocity_296": 297,
        "Note_Velocity_297": 298,
        "Note_Velocity_298": 299,
        "Note_Velocity_299": 300,
        "Note_Velocity_300": 301,
        "Note_Velocity_301": 302,
        "Note_Velocity_302": 303,
        "Note_Velocity_303": 304,
        "Note_Velocity_304": 305,
        "Note_Velocity_305": 306,
        "Note_Velocity_306": 307,
        "Note_Velocity_307": 308,
        "Note_Velocity_308": 309,
        "Note_Velocity_309": 310,
        "Note_Velocity_310": 311,
        "Note_Velocity_311": 312,
        "Note_Velocity_312": 313,
        "Note_Velocity_313": 314,
        "Note_Velocity_314": 315,
        "Note_Velocity_315": 316,
        "Note_Velocity_316": 317,
        "Note_Velocity_317": 318,
        "Note_Velocity_318": 319,
        "Note_Velocity_319": 320,
        "Note_Velocity_320": 321,
        "Note_Velocity_321": 322,
        "Note_Velocity_322": 323,
        "Note_Velocity_323": 324,
        "Note_Velocity_324": 325,
        "Note_Velocity_325": 326,
        "Note_Velocity_326": 327,
        "Note_Velocity_327": 328,
        "Note_Velocity_328": 329,
        "Note_Velocity_329": 330,
        "Note_Velocity_330": 331,
        "Note_Velocity_331": 332,
        "Note_Velocity_332": 333,
        "Note_Velocity_333": 334,
        "Note_Velocity_334": 335,
        "Note_Velocity_335": 336,
        "Note_Velocity_336": 337,
        "Note_Velocity_337": 338,
        "Note_Velocity_338": 339,
        "Note_Velocity_339": 340,
        "Note_Velocity_340": 341,
        "Note_Velocity_341": 342,
        "Note_Velocity_342": 343,
        "Note_Velocity_343": 344,
        "Note_Velocity_344": 345,
        "Note_Velocity_345": 346,
        "Note_Velocity_346": 347,
        "Note_Velocity_347": 348,
        "Note_Velocity_348": 349,
        "Note_Velocity_349": 350,
        "Note_Velocity_350": 351,
        "Note_Velocity_351": 352,
        "Note_Velocity_352": 353,
        "Note_Velocity_353": 354,
        "Note_Velocity_354": 355,
        "Note_Velocity_355": 356,
        "Note_Velocity_356": 357,
        "Note_Velocity_357": 358,
        "Note_Velocity_358": 359,
        "Note_Velocity_359": 360,
        "Note_Velocity_360": 361
    },
    "boundary"  : {
        0         : 0,
        "None"    : 1,
        "Boundary": 2,
    },
    # 'density': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
    'variance'  : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
}

preset_word2event = {
    "tempo"     : {
        0  : 0,
        1  : "CONTI",
        2  : "Tempo_0",
        3  : "Tempo_1",
        4  : "Tempo_2",
        5  : "Tempo_3",
        6  : "Tempo_4",
        7  : "Tempo_5",
        8  : "Tempo_6",
        9  : "Tempo_7",
        10 : "Tempo_8",
        11 : "Tempo_9",
        12 : "Tempo_10",
        13 : "Tempo_11",
        14 : "Tempo_12",
        15 : "Tempo_13",
        16 : "Tempo_14",
        17 : "Tempo_15",
        18 : "Tempo_16",
        19 : "Tempo_17",
        20 : "Tempo_18",
        21 : "Tempo_19",
        22 : "Tempo_20",
        23 : "Tempo_21",
        24 : "Tempo_22",
        25 : "Tempo_23",
        26 : "Tempo_24",
        27 : "Tempo_25",
        28 : "Tempo_26",
        29 : "Tempo_27",
        30 : "Tempo_28",
        31 : "Tempo_29",
        32 : "Tempo_30",
        33 : "Tempo_31",
        34 : "Tempo_32",
        35 : "Tempo_33",
        36 : "Tempo_34",
        37 : "Tempo_35",
        38 : "Tempo_36",
        39 : "Tempo_37",
        40 : "Tempo_38",
        41 : "Tempo_39",
        42 : "Tempo_40",
        43 : "Tempo_41",
        44 : "Tempo_42",
        45 : "Tempo_43",
        46 : "Tempo_44",
        47 : "Tempo_45",
        48 : "Tempo_46",
        49 : "Tempo_47",
        50 : "Tempo_48",
        51 : "Tempo_49",
        52 : "Tempo_50",
        53 : "Tempo_51",
        54 : "Tempo_52",
        55 : "Tempo_53",
        56 : "Tempo_54",
        57 : "Tempo_55",
        58 : "Tempo_56",
        59 : "Tempo_57",
        60 : "Tempo_58",
        61 : "Tempo_59",
        62 : "Tempo_60",
        63 : "Tempo_61",
        64 : "Tempo_62",
        65 : "Tempo_63",
        66 : "Tempo_64",
        67 : "Tempo_65",
        68 : "Tempo_66",
        69 : "Tempo_67",
        70 : "Tempo_68",
        71 : "Tempo_69",
        72 : "Tempo_70",
        73 : "Tempo_71",
        74 : "Tempo_72",
        75 : "Tempo_73",
        76 : "Tempo_74",
        77 : "Tempo_75",
        78 : "Tempo_76",
        79 : "Tempo_77",
        80 : "Tempo_78",
        81 : "Tempo_79",
        82 : "Tempo_80",
        83 : "Tempo_81",
        84 : "Tempo_82",
        85 : "Tempo_83",
        86 : "Tempo_84",
        87 : "Tempo_85",
        88 : "Tempo_86",
        89 : "Tempo_87",
        90 : "Tempo_88",
        91 : "Tempo_89",
        92 : "Tempo_90",
        93 : "Tempo_91",
        94 : "Tempo_92",
        95 : "Tempo_93",
        96 : "Tempo_94",
        97 : "Tempo_95",
        98 : "Tempo_96",
        99 : "Tempo_97",
        100: "Tempo_98",
        101: "Tempo_99",
        102: "Tempo_100",
        103: "Tempo_101",
        104: "Tempo_102",
        105: "Tempo_103",
        106: "Tempo_104",
        107: "Tempo_105",
        108: "Tempo_106",
        109: "Tempo_107",
        110: "Tempo_108",
        111: "Tempo_109",
        112: "Tempo_110",
        113: "Tempo_111",
        114: "Tempo_112",
        115: "Tempo_113",
        116: "Tempo_114",
        117: "Tempo_115",
        118: "Tempo_116",
        119: "Tempo_117",
        120: "Tempo_118",
        121: "Tempo_119",
        122: "Tempo_120",
        123: "Tempo_121",
        124: "Tempo_122",
        125: "Tempo_123",
        126: "Tempo_124",
        127: "Tempo_125",
        128: "Tempo_126",
        129: "Tempo_127",
        130: "Tempo_128",
        131: "Tempo_129",
        132: "Tempo_130",
        133: "Tempo_131",
        134: "Tempo_132",
        135: "Tempo_133",
        136: "Tempo_134",
        137: "Tempo_135",
        138: "Tempo_136",
        139: "Tempo_137",
        140: "Tempo_138",
        141: "Tempo_139",
        142: "Tempo_140",
        143: "Tempo_141",
        144: "Tempo_142",
        145: "Tempo_143",
        146: "Tempo_144",
        147: "Tempo_145",
        148: "Tempo_146",
        149: "Tempo_147",
        150: "Tempo_148",
        151: "Tempo_149",
        152: "Tempo_150",
        153: "Tempo_151",
        154: "Tempo_152",
        155: "Tempo_153",
        156: "Tempo_154",
        157: "Tempo_155",
        158: "Tempo_156",
        159: "Tempo_157",
        160: "Tempo_158",
        161: "Tempo_159",
        162: "Tempo_160",
        163: "Tempo_161",
        164: "Tempo_162",
        165: "Tempo_163",
        166: "Tempo_164",
        167: "Tempo_165",
        168: "Tempo_166",
        169: "Tempo_167",
        170: "Tempo_168",
        171: "Tempo_169",
        172: "Tempo_170",
        173: "Tempo_171",
        174: "Tempo_172",
        175: "Tempo_173",
        176: "Tempo_174",
        177: "Tempo_175",
        178: "Tempo_176",
        179: "Tempo_177",
        180: "Tempo_178",
        181: "Tempo_179",
        182: "Tempo_180",
        183: "Tempo_181",
        184: "Tempo_182",
        185: "Tempo_183",
        186: "Tempo_184",
        187: "Tempo_185",
        188: "Tempo_186",
        189: "Tempo_187",
        190: "Tempo_188",
        191: "Tempo_189",
        192: "Tempo_190",
        193: "Tempo_191",
        194: "Tempo_192",
        195: "Tempo_193",
        196: "Tempo_194",
        197: "Tempo_195",
        198: "Tempo_196",
        199: "Tempo_197",
        200: "Tempo_198",
        201: "Tempo_199",
        202: "Tempo_200",
        203: "Tempo_201",
        204: "Tempo_202",
        205: "Tempo_203",
        206: "Tempo_204",
        207: "Tempo_205",
        208: "Tempo_206",
        209: "Tempo_207",
        210: "Tempo_208",
        211: "Tempo_209",
        212: "Tempo_210",
        213: "Tempo_211",
        214: "Tempo_212",
        215: "Tempo_213",
        216: "Tempo_214",
        217: "Tempo_215",
        218: "Tempo_216",
        219: "Tempo_217",
        220: "Tempo_218",
        221: "Tempo_219",
        222: "Tempo_220",
        223: "Tempo_221",
        224: "Tempo_222",
        225: "Tempo_223",
        226: "Tempo_224",
        227: "Tempo_225",
        228: "Tempo_226",
        229: "Tempo_227",
        230: "Tempo_228",
        231: "Tempo_229",
        232: "Tempo_230",
        233: "Tempo_231",
        234: "Tempo_232",
        235: "Tempo_233",
        236: "Tempo_234",
        237: "Tempo_235",
        238: "Tempo_236",
        239: "Tempo_237",
        240: "Tempo_238",
        241: "Tempo_239",
        242: "Tempo_240",
        243: "Tempo_241",
        244: "Tempo_242",
        245: "Tempo_243",
        246: "Tempo_244",
        247: "Tempo_245",
        248: "Tempo_246",
        249: "Tempo_247",
        250: "Tempo_248",
        251: "Tempo_249",
        252: "Tempo_250",
        253: "Tempo_251",
        254: "Tempo_252",
        255: "Tempo_253",
        256: "Tempo_254",
        257: "Tempo_255",
        258: "Tempo_256",
        259: "Tempo_257",
        260: "Tempo_258",
        261: "Tempo_259",
        262: "Tempo_260",
        263: "Tempo_261",
        264: "Tempo_262",
        265: "Tempo_263",
        266: "Tempo_264",
        267: "Tempo_265",
        268: "Tempo_266",
        269: "Tempo_267",
        270: "Tempo_268",
        271: "Tempo_269",
        272: "Tempo_270",
        273: "Tempo_271",
        274: "Tempo_272",
        275: "Tempo_273",
        276: "Tempo_274",
        277: "Tempo_275",
        278: "Tempo_276",
        279: "Tempo_277",
        280: "Tempo_278",
        281: "Tempo_279",
        282: "Tempo_280",
        283: "Tempo_281",
        284: "Tempo_282",
        285: "Tempo_283",
        286: "Tempo_284",
        287: "Tempo_285",
        288: "Tempo_286",
        289: "Tempo_287",
        290: "Tempo_288",
        291: "Tempo_289",
        292: "Tempo_290",
        293: "Tempo_291",
        294: "Tempo_292",
        295: "Tempo_293",
        296: "Tempo_294",
        297: "Tempo_295",
        298: "Tempo_296",
        299: "Tempo_297",
        300: "Tempo_298",
        301: "Tempo_299",
        302: "Tempo_300",
        303: "Tempo_301",
        304: "Tempo_302",
        305: "Tempo_303",
        306: "Tempo_304",
        307: "Tempo_305",
        308: "Tempo_306",
        309: "Tempo_307",
        310: "Tempo_308",
        311: "Tempo_309",
        312: "Tempo_310",
        313: "Tempo_311",
        314: "Tempo_312",
        315: "Tempo_313",
        316: "Tempo_314",
        317: "Tempo_315",
        318: "Tempo_316",
        319: "Tempo_317",
        320: "Tempo_318",
        321: "Tempo_319",
        322: "Tempo_320",
        323: "Tempo_321",
        324: "Tempo_322",
        325: "Tempo_323",
        326: "Tempo_324",
        327: "Tempo_325",
        328: "Tempo_326",
        329: "Tempo_327",
        330: "Tempo_328",
        331: "Tempo_329",
        332: "Tempo_330",
        333: "Tempo_331",
        334: "Tempo_332",
        335: "Tempo_333",
        336: "Tempo_334",
        337: "Tempo_335",
        338: "Tempo_336",
        339: "Tempo_337",
        340: "Tempo_338",
        341: "Tempo_339",
        342: "Tempo_340",
        343: "Tempo_341",
        344: "Tempo_342",
        345: "Tempo_343",
        346: "Tempo_344",
        347: "Tempo_345",
        348: "Tempo_346",
        349: "Tempo_347",
        350: "Tempo_348",
        351: "Tempo_349",
        352: "Tempo_350",
        353: "Tempo_351",
        354: "Tempo_352",
        355: "Tempo_353",
        356: "Tempo_354",
        357: "Tempo_355",
        358: "Tempo_356",
        359: "Tempo_357",
        360: "Tempo_358",
        361: "Tempo_359",
        362: "Tempo_360"
    },
    "chord"     : {
        0: "0",
        1: "CONTI"
    },
    "bar-beat"  : {
        0 : 0,
        1 : "Bar",
        2 : "Beat_0",
        3 : "Beat_1",
        4 : "Beat_2",
        5 : "Beat_3",
        6 : "Beat_4",
        7 : "Beat_5",
        8 : "Beat_6",
        9 : "Beat_7",
        10: "Beat_8",
        11: "Beat_9",
        12: "Beat_10",
        13: "Beat_11",
        14: "Beat_12",
        15: "Beat_13",
        16: "Beat_14",
        17: "Beat_15"
    },
    "type"      : {
        0: "EOS",
        1: "Metrical",
        2: "Note",
        3: "Seg",
    },
    "instr_type": {
        0: 'None',
        1: 'Drums',
        2: 'Piano',
        3: 'Guitar',
        4: 'Bass',
        5: 'Strings',
    },
    "pitch"     : {
        0  : 0,
        1  : "Note_Pitch_0",
        2  : "Note_Pitch_1",
        3  : "Note_Pitch_2",
        4  : "Note_Pitch_3",
        5  : "Note_Pitch_4",
        6  : "Note_Pitch_5",
        7  : "Note_Pitch_6",
        8  : "Note_Pitch_7",
        9  : "Note_Pitch_8",
        10 : "Note_Pitch_9",
        11 : "Note_Pitch_10",
        12 : "Note_Pitch_11",
        13 : "Note_Pitch_12",
        14 : "Note_Pitch_13",
        15 : "Note_Pitch_14",
        16 : "Note_Pitch_15",
        17 : "Note_Pitch_16",
        18 : "Note_Pitch_17",
        19 : "Note_Pitch_18",
        20 : "Note_Pitch_19",
        21 : "Note_Pitch_20",
        22 : "Note_Pitch_21",
        23 : "Note_Pitch_22",
        24 : "Note_Pitch_23",
        25 : "Note_Pitch_24",
        26 : "Note_Pitch_25",
        27 : "Note_Pitch_26",
        28 : "Note_Pitch_27",
        29 : "Note_Pitch_28",
        30 : "Note_Pitch_29",
        31 : "Note_Pitch_30",
        32 : "Note_Pitch_31",
        33 : "Note_Pitch_32",
        34 : "Note_Pitch_33",
        35 : "Note_Pitch_34",
        36 : "Note_Pitch_35",
        37 : "Note_Pitch_36",
        38 : "Note_Pitch_37",
        39 : "Note_Pitch_38",
        40 : "Note_Pitch_39",
        41 : "Note_Pitch_40",
        42 : "Note_Pitch_41",
        43 : "Note_Pitch_42",
        44 : "Note_Pitch_43",
        45 : "Note_Pitch_44",
        46 : "Note_Pitch_45",
        47 : "Note_Pitch_46",
        48 : "Note_Pitch_47",
        49 : "Note_Pitch_48",
        50 : "Note_Pitch_49",
        51 : "Note_Pitch_50",
        52 : "Note_Pitch_51",
        53 : "Note_Pitch_52",
        54 : "Note_Pitch_53",
        55 : "Note_Pitch_54",
        56 : "Note_Pitch_55",
        57 : "Note_Pitch_56",
        58 : "Note_Pitch_57",
        59 : "Note_Pitch_58",
        60 : "Note_Pitch_59",
        61 : "Note_Pitch_60",
        62 : "Note_Pitch_61",
        63 : "Note_Pitch_62",
        64 : "Note_Pitch_63",
        65 : "Note_Pitch_64",
        66 : "Note_Pitch_65",
        67 : "Note_Pitch_66",
        68 : "Note_Pitch_67",
        69 : "Note_Pitch_68",
        70 : "Note_Pitch_69",
        71 : "Note_Pitch_70",
        72 : "Note_Pitch_71",
        73 : "Note_Pitch_72",
        74 : "Note_Pitch_73",
        75 : "Note_Pitch_74",
        76 : "Note_Pitch_75",
        77 : "Note_Pitch_76",
        78 : "Note_Pitch_77",
        79 : "Note_Pitch_78",
        80 : "Note_Pitch_79",
        81 : "Note_Pitch_80",
        82 : "Note_Pitch_81",
        83 : "Note_Pitch_82",
        84 : "Note_Pitch_83",
        85 : "Note_Pitch_84",
        86 : "Note_Pitch_85",
        87 : "Note_Pitch_86",
        88 : "Note_Pitch_87",
        89 : "Note_Pitch_88",
        90 : "Note_Pitch_89",
        91 : "Note_Pitch_90",
        92 : "Note_Pitch_91",
        93 : "Note_Pitch_92",
        94 : "Note_Pitch_93",
        95 : "Note_Pitch_94",
        96 : "Note_Pitch_95",
        97 : "Note_Pitch_96",
        98 : "Note_Pitch_97",
        99 : "Note_Pitch_98",
        100: "Note_Pitch_99",
        101: "Note_Pitch_100",
        102: "Note_Pitch_101",
        103: "Note_Pitch_102",
        104: "Note_Pitch_103",
        105: "Note_Pitch_104",
        106: "Note_Pitch_105",
        107: "Note_Pitch_106",
        108: "Note_Pitch_107",
        109: "Note_Pitch_108",
        110: "Note_Pitch_109",
        111: "Note_Pitch_110",
        112: "Note_Pitch_111",
        113: "Note_Pitch_112",
        114: "Note_Pitch_113",
        115: "Note_Pitch_114",
        116: "Note_Pitch_115",
        117: "Note_Pitch_116",
        118: "Note_Pitch_117",
        119: "Note_Pitch_118",
        120: "Note_Pitch_119",
        121: "Note_Pitch_120",
        122: "Note_Pitch_121",
        123: "Note_Pitch_122",
        124: "Note_Pitch_123",
        125: "Note_Pitch_124",
        126: "Note_Pitch_125",
        127: "Note_Pitch_126",
        128: "Note_Pitch_127",
        129: "Note_Pitch_128",
    },
    "duration"  : {
        0 : 0,
        1 : "Note_Duration_0",
        2 : "Note_Duration_120",
        3 : "Note_Duration_240",
        4 : "Note_Duration_360",
        5 : "Note_Duration_480",
        6 : "Note_Duration_600",
        7 : "Note_Duration_720",
        8 : "Note_Duration_840",
        9 : "Note_Duration_960",
        10: "Note_Duration_1080",
        11: "Note_Duration_1200",
        12: "Note_Duration_1320",
        13: "Note_Duration_1440",
        14: "Note_Duration_1560",
        15: "Note_Duration_1680",
        16: "Note_Duration_1800",
        17: "Note_Duration_1920"
    },
    "velocity"  : {
        0  : 0,
        1  : "Note_Velocity_0",
        2  : "Note_Velocity_1",
        3  : "Note_Velocity_2",
        4  : "Note_Velocity_3",
        5  : "Note_Velocity_4",
        6  : "Note_Velocity_5",
        7  : "Note_Velocity_6",
        8  : "Note_Velocity_7",
        9  : "Note_Velocity_8",
        10 : "Note_Velocity_9",
        11 : "Note_Velocity_10",
        12 : "Note_Velocity_11",
        13 : "Note_Velocity_12",
        14 : "Note_Velocity_13",
        15 : "Note_Velocity_14",
        16 : "Note_Velocity_15",
        17 : "Note_Velocity_16",
        18 : "Note_Velocity_17",
        19 : "Note_Velocity_18",
        20 : "Note_Velocity_19",
        21 : "Note_Velocity_20",
        22 : "Note_Velocity_21",
        23 : "Note_Velocity_22",
        24 : "Note_Velocity_23",
        25 : "Note_Velocity_24",
        26 : "Note_Velocity_25",
        27 : "Note_Velocity_26",
        28 : "Note_Velocity_27",
        29 : "Note_Velocity_28",
        30 : "Note_Velocity_29",
        31 : "Note_Velocity_30",
        32 : "Note_Velocity_31",
        33 : "Note_Velocity_32",
        34 : "Note_Velocity_33",
        35 : "Note_Velocity_34",
        36 : "Note_Velocity_35",
        37 : "Note_Velocity_36",
        38 : "Note_Velocity_37",
        39 : "Note_Velocity_38",
        40 : "Note_Velocity_39",
        41 : "Note_Velocity_40",
        42 : "Note_Velocity_41",
        43 : "Note_Velocity_42",
        44 : "Note_Velocity_43",
        45 : "Note_Velocity_44",
        46 : "Note_Velocity_45",
        47 : "Note_Velocity_46",
        48 : "Note_Velocity_47",
        49 : "Note_Velocity_48",
        50 : "Note_Velocity_49",
        51 : "Note_Velocity_50",
        52 : "Note_Velocity_51",
        53 : "Note_Velocity_52",
        54 : "Note_Velocity_53",
        55 : "Note_Velocity_54",
        56 : "Note_Velocity_55",
        57 : "Note_Velocity_56",
        58 : "Note_Velocity_57",
        59 : "Note_Velocity_58",
        60 : "Note_Velocity_59",
        61 : "Note_Velocity_60",
        62 : "Note_Velocity_61",
        63 : "Note_Velocity_62",
        64 : "Note_Velocity_63",
        65 : "Note_Velocity_64",
        66 : "Note_Velocity_65",
        67 : "Note_Velocity_66",
        68 : "Note_Velocity_67",
        69 : "Note_Velocity_68",
        70 : "Note_Velocity_69",
        71 : "Note_Velocity_70",
        72 : "Note_Velocity_71",
        73 : "Note_Velocity_72",
        74 : "Note_Velocity_73",
        75 : "Note_Velocity_74",
        76 : "Note_Velocity_75",
        77 : "Note_Velocity_76",
        78 : "Note_Velocity_77",
        79 : "Note_Velocity_78",
        80 : "Note_Velocity_79",
        81 : "Note_Velocity_80",
        82 : "Note_Velocity_81",
        83 : "Note_Velocity_82",
        84 : "Note_Velocity_83",
        85 : "Note_Velocity_84",
        86 : "Note_Velocity_85",
        87 : "Note_Velocity_86",
        88 : "Note_Velocity_87",
        89 : "Note_Velocity_88",
        90 : "Note_Velocity_89",
        91 : "Note_Velocity_90",
        92 : "Note_Velocity_91",
        93 : "Note_Velocity_92",
        94 : "Note_Velocity_93",
        95 : "Note_Velocity_94",
        96 : "Note_Velocity_95",
        97 : "Note_Velocity_96",
        98 : "Note_Velocity_97",
        99 : "Note_Velocity_98",
        100: "Note_Velocity_99",
        101: "Note_Velocity_100",
        102: "Note_Velocity_101",
        103: "Note_Velocity_102",
        104: "Note_Velocity_103",
        105: "Note_Velocity_104",
        106: "Note_Velocity_105",
        107: "Note_Velocity_106",
        108: "Note_Velocity_107",
        109: "Note_Velocity_108",
        110: "Note_Velocity_109",
        111: "Note_Velocity_110",
        112: "Note_Velocity_111",
        113: "Note_Velocity_112",
        114: "Note_Velocity_113",
        115: "Note_Velocity_114",
        116: "Note_Velocity_115",
        117: "Note_Velocity_116",
        118: "Note_Velocity_117",
        119: "Note_Velocity_118",
        120: "Note_Velocity_119",
        121: "Note_Velocity_120",
        122: "Note_Velocity_121",
        123: "Note_Velocity_122",
        124: "Note_Velocity_123",
        125: "Note_Velocity_124",
        126: "Note_Velocity_125",
        127: "Note_Velocity_126",
        128: "Note_Velocity_127",
        129: "Note_Velocity_128",
        130: "Note_Velocity_129",
        131: "Note_Velocity_130",
        132: "Note_Velocity_131",
        133: "Note_Velocity_132",
        134: "Note_Velocity_133",
        135: "Note_Velocity_134",
        136: "Note_Velocity_135",
        137: "Note_Velocity_136",
        138: "Note_Velocity_137",
        139: "Note_Velocity_138",
        140: "Note_Velocity_139",
        141: "Note_Velocity_140",
        142: "Note_Velocity_141",
        143: "Note_Velocity_142",
        144: "Note_Velocity_143",
        145: "Note_Velocity_144",
        146: "Note_Velocity_145",
        147: "Note_Velocity_146",
        148: "Note_Velocity_147",
        149: "Note_Velocity_148",
        150: "Note_Velocity_149",
        151: "Note_Velocity_150",
        152: "Note_Velocity_151",
        153: "Note_Velocity_152",
        154: "Note_Velocity_153",
        155: "Note_Velocity_154",
        156: "Note_Velocity_155",
        157: "Note_Velocity_156",
        158: "Note_Velocity_157",
        159: "Note_Velocity_158",
        160: "Note_Velocity_159",
        161: "Note_Velocity_160",
        162: "Note_Velocity_161",
        163: "Note_Velocity_162",
        164: "Note_Velocity_163",
        165: "Note_Velocity_164",
        166: "Note_Velocity_165",
        167: "Note_Velocity_166",
        168: "Note_Velocity_167",
        169: "Note_Velocity_168",
        170: "Note_Velocity_169",
        171: "Note_Velocity_170",
        172: "Note_Velocity_171",
        173: "Note_Velocity_172",
        174: "Note_Velocity_173",
        175: "Note_Velocity_174",
        176: "Note_Velocity_175",
        177: "Note_Velocity_176",
        178: "Note_Velocity_177",
        179: "Note_Velocity_178",
        180: "Note_Velocity_179",
        181: "Note_Velocity_180",
        182: "Note_Velocity_181",
        183: "Note_Velocity_182",
        184: "Note_Velocity_183",
        185: "Note_Velocity_184",
        186: "Note_Velocity_185",
        187: "Note_Velocity_186",
        188: "Note_Velocity_187",
        189: "Note_Velocity_188",
        190: "Note_Velocity_189",
        191: "Note_Velocity_190",
        192: "Note_Velocity_191",
        193: "Note_Velocity_192",
        194: "Note_Velocity_193",
        195: "Note_Velocity_194",
        196: "Note_Velocity_195",
        197: "Note_Velocity_196",
        198: "Note_Velocity_197",
        199: "Note_Velocity_198",
        200: "Note_Velocity_199",
        201: "Note_Velocity_200",
        202: "Note_Velocity_201",
        203: "Note_Velocity_202",
        204: "Note_Velocity_203",
        205: "Note_Velocity_204",
        206: "Note_Velocity_205",
        207: "Note_Velocity_206",
        208: "Note_Velocity_207",
        209: "Note_Velocity_208",
        210: "Note_Velocity_209",
        211: "Note_Velocity_210",
        212: "Note_Velocity_211",
        213: "Note_Velocity_212",
        214: "Note_Velocity_213",
        215: "Note_Velocity_214",
        216: "Note_Velocity_215",
        217: "Note_Velocity_216",
        218: "Note_Velocity_217",
        219: "Note_Velocity_218",
        220: "Note_Velocity_219",
        221: "Note_Velocity_220",
        222: "Note_Velocity_221",
        223: "Note_Velocity_222",
        224: "Note_Velocity_223",
        225: "Note_Velocity_224",
        226: "Note_Velocity_225",
        227: "Note_Velocity_226",
        228: "Note_Velocity_227",
        229: "Note_Velocity_228",
        230: "Note_Velocity_229",
        231: "Note_Velocity_230",
        232: "Note_Velocity_231",
        233: "Note_Velocity_232",
        234: "Note_Velocity_233",
        235: "Note_Velocity_234",
        236: "Note_Velocity_235",
        237: "Note_Velocity_236",
        238: "Note_Velocity_237",
        239: "Note_Velocity_238",
        240: "Note_Velocity_239",
        241: "Note_Velocity_240",
        242: "Note_Velocity_241",
        243: "Note_Velocity_242",
        244: "Note_Velocity_243",
        245: "Note_Velocity_244",
        246: "Note_Velocity_245",
        247: "Note_Velocity_246",
        248: "Note_Velocity_247",
        249: "Note_Velocity_248",
        250: "Note_Velocity_249",
        251: "Note_Velocity_250",
        252: "Note_Velocity_251",
        253: "Note_Velocity_252",
        254: "Note_Velocity_253",
        255: "Note_Velocity_254",
        256: "Note_Velocity_255",
        257: "Note_Velocity_256",
        258: "Note_Velocity_257",
        259: "Note_Velocity_258",
        260: "Note_Velocity_259",
        261: "Note_Velocity_260",
        262: "Note_Velocity_261",
        263: "Note_Velocity_262",
        264: "Note_Velocity_263",
        265: "Note_Velocity_264",
        266: "Note_Velocity_265",
        267: "Note_Velocity_266",
        268: "Note_Velocity_267",
        269: "Note_Velocity_268",
        270: "Note_Velocity_269",
        271: "Note_Velocity_270",
        272: "Note_Velocity_271",
        273: "Note_Velocity_272",
        274: "Note_Velocity_273",
        275: "Note_Velocity_274",
        276: "Note_Velocity_275",
        277: "Note_Velocity_276",
        278: "Note_Velocity_277",
        279: "Note_Velocity_278",
        280: "Note_Velocity_279",
        281: "Note_Velocity_280",
        282: "Note_Velocity_281",
        283: "Note_Velocity_282",
        284: "Note_Velocity_283",
        285: "Note_Velocity_284",
        286: "Note_Velocity_285",
        287: "Note_Velocity_286",
        288: "Note_Velocity_287",
        289: "Note_Velocity_288",
        290: "Note_Velocity_289",
        291: "Note_Velocity_290",
        292: "Note_Velocity_291",
        293: "Note_Velocity_292",
        294: "Note_Velocity_293",
        295: "Note_Velocity_294",
        296: "Note_Velocity_295",
        297: "Note_Velocity_296",
        298: "Note_Velocity_297",
        299: "Note_Velocity_298",
        300: "Note_Velocity_299",
        301: "Note_Velocity_300",
        302: "Note_Velocity_301",
        303: "Note_Velocity_302",
        304: "Note_Velocity_303",
        305: "Note_Velocity_304",
        306: "Note_Velocity_305",
        307: "Note_Velocity_306",
        308: "Note_Velocity_307",
        309: "Note_Velocity_308",
        310: "Note_Velocity_309",
        311: "Note_Velocity_310",
        312: "Note_Velocity_311",
        313: "Note_Velocity_312",
        314: "Note_Velocity_313",
        315: "Note_Velocity_314",
        316: "Note_Velocity_315",
        317: "Note_Velocity_316",
        318: "Note_Velocity_317",
        319: "Note_Velocity_318",
        320: "Note_Velocity_319",
        321: "Note_Velocity_320",
        322: "Note_Velocity_321",
        323: "Note_Velocity_322",
        324: "Note_Velocity_323",
        325: "Note_Velocity_324",
        326: "Note_Velocity_325",
        327: "Note_Velocity_326",
        328: "Note_Velocity_327",
        329: "Note_Velocity_328",
        330: "Note_Velocity_329",
        331: "Note_Velocity_330",
        332: "Note_Velocity_331",
        333: "Note_Velocity_332",
        334: "Note_Velocity_333",
        335: "Note_Velocity_334",
        336: "Note_Velocity_335",
        337: "Note_Velocity_336",
        338: "Note_Velocity_337",
        339: "Note_Velocity_338",
        340: "Note_Velocity_339",
        341: "Note_Velocity_340",
        342: "Note_Velocity_341",
        343: "Note_Velocity_342",
        344: "Note_Velocity_343",
        345: "Note_Velocity_344",
        346: "Note_Velocity_345",
        347: "Note_Velocity_346",
        348: "Note_Velocity_347",
        349: "Note_Velocity_348",
        350: "Note_Velocity_349",
        351: "Note_Velocity_350",
        352: "Note_Velocity_351",
        353: "Note_Velocity_352",
        354: "Note_Velocity_353",
        355: "Note_Velocity_354",
        356: "Note_Velocity_355",
        357: "Note_Velocity_356",
        358: "Note_Velocity_357",
        359: "Note_Velocity_358",
        360: "Note_Velocity_359",
        361: "Note_Velocity_360"
    },
    "boundary"  : {
        0: 0,
        1: "None",
        2: "Boundary",
    },
    "key"       : {
        0 : 0,
        1 : "None",
        2 : 'C',
        3 : 'C#',
        4 : 'D',
        5 : 'D#',
        6 : 'E',
        7 : 'F',
        8 : 'F#',
        9 : 'G',
        10: 'G#',
        11: 'A',
        12: 'A#',
        13: 'B',
        14: 'c',
        15: 'c#',
        16: 'd',
        17: 'd#',
        18: 'e',
        19: 'f',
        20: 'f#',
        21: 'g',
        22: 'g#',
        23: 'a',
        24: 'a#',
        25: 'b',
    }
}

================================================
FILE: src/video2npz/metadata2numpy_mix.py
================================================
#/usr/bin/env python
# -*- coding: UTF-8 -*-
import json
import os
import math
import argparse

import numpy as np

from dictionary_mix import preset_event2word
from stat_mix import vbeat_weight_percentile, fmpb_percentile

RESOLUTION = 16
DIMENSION = {
    'beat'    : 0,
    'density' : 1,
    'strength': 2,
    'i_beat'  : 3,
    'n_beat'  : 4,
    'p_beat'  : 5,
}
N_DIMENSION = len(DIMENSION)


def _cal_density(flow_magnitude):
    for i, percentile in enumerate(fmpb_percentile):
        if flow_magnitude < percentile:
            return i
    return len(fmpb_percentile)


def _cal_strength(weight):
    for i, percentile in enumerate(vbeat_weight_percentile):
        if weight < percentile:
            return i
    return len(vbeat_weight_percentile)


def _get_beat_token(beat, strength, i_beat, n_beat):
    l = [[0] * N_DIMENSION]
    l[0][DIMENSION['beat']] = preset_event2word['beat']['Beat_%d' % beat]
    l[0][DIMENSION['strength']] = strength
    l[0][DIMENSION['i_beat']] = i_beat
    l[0][DIMENSION['n_beat']] = n_beat
    l[0][DIMENSION['p_beat']] = round(float(i_beat) / n_beat * 100) + 1
    return l


def _get_bar_token(density, i_beat, n_beat):
    l = [[0] * N_DIMENSION]
    l[0][DIMENSION['beat']] = preset_event2word['beat']['Bar']
    l[0][DIMENSION['density']] = density + 1
    l[0][DIMENSION['i_beat']] = i_beat
    l[0][DIMENSION['n_beat']] = n_beat
    l[0][DIMENSION['p_beat']] = round(float(i_beat) / n_beat * 100) + 1
    return l


def metadata2numpy(metadata):
    vbeats = metadata['vbeats']
    fmpb = metadata['flow_magnitude_per_bar']
    n_beat = int(math.ceil(float(metadata['duration']) / 60 * float(metadata['tempo']) * 4))

    n_bars = 0  # 已添加 bar token 个数
    l = []
    for vbeat in vbeats:
        # add bar token
        while int(vbeat['bar']) >= n_bars:
            i_beat = n_bars * RESOLUTION
            l += _get_bar_token(density=_cal_density(fmpb[n_bars]), i_beat=i_beat, n_beat=n_beat)
            n_bars += 1
        # add beat token
        i_beat = int(vbeat['bar']) * RESOLUTION + int(vbeat['tick'])
        l += _get_beat_token(beat=int(vbeat['tick']), strength=_cal_strength(vbeat['weight']), i_beat=i_beat,
                             n_beat=n_beat)
    # add empty bars
    while n_bars < len(fmpb):
        i_beat = n_bars * RESOLUTION
        l += _get_bar_token(density=_cal_density(fmpb[n_bars]), i_beat=i_beat, n_beat=n_beat)
        n_bars += 1

    return np.asarray(l, dtype=int)


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--out_dir', default="../../inference/")
    parser.add_argument('--video', default="final_640.mp4")
    parser.add_argument('--metadata', default="metadata.json")
    args = parser.parse_args()

    video_name = os.path.basename(args.video)

    with open(args.metadata) as f:
        metadata = json.load(f)

    target_path = os.path.join(args.out_dir, video_name.replace('.mp4', '.npz'))

    print('processing to save to %s' % target_path)
    input_numpy = metadata2numpy(metadata)
    np.savez(target_path, input=input_numpy)
    print("saved to " + str(target_path))

================================================
FILE: src/video2npz/optical_flow.py
================================================
#encoding=utf-8
import cv2
import argparse
import os
import numpy as np
import matplotlib.pyplot as plt
import skvideo.io
from tqdm import tqdm


def makedirs(dirs):
    for dir in dirs:
        if not os.path.exists(dir):
            os.makedirs(dir)


video_dir = '../../videos/'
flow_dir = 'flow/'
fig_dir = 'fig/'
makedirs([video_dir, flow_dir, fig_dir, 'optical_flow/'])

TIME_PER_BAR = 2  # 暂定2s一小节

# 文字参数
ORG = (50, 50)
FONT = cv2.FONT_HERSHEY_SIMPLEX
FONT_SCALE = 1
COLOR = (0, 0, 255)
THICKNESS = 2


def dense_optical_flow(method, video_path, params=[], to_gray=False):
    #	print(video_path)
    assert os.path.exists(video_path)
    metadata = skvideo.io.ffprobe(video_path)
    print("video loaded successfully")
    frame, time = metadata['video']['@avg_frame_rate'].split('/')
    fps = round(float(frame) / float(time))
    if os.path.exists(os.path.join(flow_dir, os.path.basename(video_path).split('.')[0] + '.npz')):
        flow_magnitude_list = list(
            np.load(os.path.join(flow_dir, os.path.basename(video_path).split('.')[0] + '.npz'))['flow'])
    else:
        # Read the video and first frame
        video = skvideo.io.vread(video_path)[:]
        n_frames = len(video)  # 总帧数
        old_frame = video[0]

        # crate HSV & make Value a constant
        hsv = np.zeros_like(old_frame)
        hsv[..., 1] = 255

        # Preprocessing for exact method
        if to_gray:
            old_frame = cv2.cvtColor(old_frame, cv2.COLOR_RGB2GRAY)

        flow_magnitude_list = []
        for i in tqdm(range(1, n_frames)):
            # Read the next frame
            new_frame = video[i]

            # Preprocessing for exact method
            if to_gray:
                new_frame = cv2.cvtColor(new_frame, cv2.COLOR_RGB2GRAY)

            # Calculate Optical Flow
            flow = method(old_frame, new_frame, None, *params)
            flow_magnitude = np.mean(np.abs(flow))
            flow_magnitude_list.append(flow_magnitude)

            # Update the previous frame
            old_frame = new_frame

    frame_per_bar = TIME_PER_BAR * fps
    flow_magnitude_per_bar = []
    temp = np.zeros((len(flow_magnitude_list)))
    for i in np.arange(0, len(flow_magnitude_list), frame_per_bar):
        mean_flow = np.mean(flow_magnitude_list[int(i): min(int(i + frame_per_bar), len(flow_magnitude_list))])
        flow_magnitude_per_bar.append(mean_flow)
        temp[int(i): min(int(i + frame_per_bar), len(flow_magnitude_list))] = mean_flow

    np.savez(os.path.join(flow_dir, os.path.basename(video_path).split('.')[0] + '.npz'),
             flow=np.asarray(flow_magnitude_list))

    # 绘制flow强度折线图
    x = np.arange(0, len(flow_magnitude_list))
    plt.figure(figsize=(10, 4))
    plt.plot(x, temp, 'b.')
    plt.title('Optical Flow Magnitude')
    plt.savefig(os.path.join(fig_dir, os.path.basename(video_path).split('.')[0] + '.jpg'))

    # return optical_flow, flow_magnitude_list
    return flow_magnitude_per_bar, flow_magnitude_list


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("--method", choices=["farneback", "lucaskanade_dense", "rlof"], default="farneback")
    parser.add_argument("--video", default="../../videos/final_640.mp4")
    args = parser.parse_args()

    flow = []

    video_path = args.video
    print("video_path", video_path)
    if args.method == 'lucaskanade_dense':
        method = cv2.optflow.calcOpticalFlowSparseToDense
        optical_flow, flow_magnitude_list = dense_optical_flow(method, video_path, to_gray=True)
    elif args.method == 'farneback':
        method = cv2.calcOpticalFlowFarneback
        params = [0.5, 3, 15, 3, 5, 1.2, 0]  # default Farneback's algorithm parameters
        optical_flow, flow_magnitude_list = dense_optical_flow(method, video_path, params, to_gray=True)
    elif args.method == "rlof":
        method = cv2.optflow.calcOpticalFlowDenseRLOF
        optical_flow, flow_magnitude_list = dense_optical_flow(method, video_path)

    flow += optical_flow

    flow = np.asarray(flow)
    for percentile in range(10, 101, 10):
        print('percentile %d: %.4f' % (percentile, np.percentile(flow, percentile)))
    np.savez('optical_flow/flow.npz', flow=flow)

================================================
FILE: src/video2np
Download .txt
gitextract_53lrthg8/

├── .gitignore
├── CMT.ipynb
├── LICENSE
├── README.md
├── dataset/
│   └── .gitkeep
├── exp/
│   └── .gitkeep
├── inference/
│   └── .gitkeep
├── logs/
│   └── .gitkeep
├── py3_requirements.txt
├── src/
│   ├── dictionary_mix.py
│   ├── gen_midi_conditional.py
│   ├── match.py
│   ├── midi2mp3.py
│   ├── midi2numpy_mix.py
│   ├── model.py
│   ├── numpy2midi_mix.py
│   ├── pianoroll2midi.py
│   ├── train.py
│   ├── utils.py
│   └── video2npz/
│       ├── dictionary_mix.py
│       ├── metadata2numpy_mix.py
│       ├── optical_flow.py
│       ├── resize_video.py
│       ├── resize_videos.sh
│       ├── stat_mix.py
│       ├── video2metadata.py
│       ├── video2npz.sh
│       └── visbeat3/
│           ├── LICENSE
│           ├── MANIFEST.in
│           ├── README.md
│           ├── VisBeatAssets/
│           │   └── VideoSources/
│           │       └── wzk_vlog_beat_enhance1_track1238/
│           │           ├── Data/
│           │           │   ├── Backups/
│           │           │   │   └── VideoSource.json
│           │           │   └── Features/
│           │           │       └── video/
│           │           │           └── directogram_powers/
│           │           │               └── wzk_vlog_beat_enhance1_track1238_maxheight_360.pkl
│           │           └── VideoSource.json
│           ├── bin/
│           │   └── dancefer
│           ├── build/
│           │   ├── lib/
│           │   │   └── visbeat3/
│           │   │       ├── ADefines.py
│           │   │       ├── AFileManager.py
│           │   │       ├── AFuncDict.py
│           │   │       ├── AImports.py
│           │   │       ├── AObject.py
│           │   │       ├── AParamDict.py
│           │   │       ├── Audio.py
│           │   │       ├── AudioClip.py
│           │   │       ├── Event.py
│           │   │       ├── EventList.py
│           │   │       ├── Image.py
│           │   │       ├── Image_CV.py
│           │   │       ├── SourceLocationParser.py
│           │   │       ├── TimeSignal.py
│           │   │       ├── TimeSignal1D.py
│           │   │       ├── VBMIDI.py
│           │   │       ├── VBObject.py
│           │   │       ├── Video.py
│           │   │       ├── VideoClip.py
│           │   │       ├── VideoSource.py
│           │   │       ├── Video_CV.py
│           │   │       ├── VisBeatDefines.py
│           │   │       ├── VisBeatExampleVideo.py
│           │   │       ├── VisBeatImports.py
│           │   │       ├── VisualBeat.py
│           │   │       ├── Warp.py
│           │   │       ├── __init__.py
│           │   │       ├── _dancefer_examples.py
│           │   │       ├── _dancify_examples.py
│           │   │       ├── _mediafiles.py
│           │   │       ├── _music_examples.py
│           │   │       ├── command_line.py
│           │   │       ├── fileui/
│           │   │       │   ├── __init__.py
│           │   │       │   └── uipath.py
│           │   │       └── vbgui/
│           │   │           ├── BeatGUI.py
│           │   │           └── __init__.py
│           │   └── scripts-3.7/
│           │       └── dancefer
│           ├── dist/
│           │   └── visbeat3-0.0.8-py3.7.egg
│           ├── setup.cfg
│           ├── setup.py
│           ├── test.py
│           ├── visbeat3/
│           │   ├── ADefines.py
│           │   ├── AFileManager.py
│           │   ├── AFuncDict.py
│           │   ├── AImports.py
│           │   ├── AObject.py
│           │   ├── AParamDict.py
│           │   ├── Audio.py
│           │   ├── AudioClip.py
│           │   ├── Event.py
│           │   ├── EventList.py
│           │   ├── Image.py
│           │   ├── Image_CV.py
│           │   ├── SourceLocationParser.py
│           │   ├── TimeSignal.py
│           │   ├── TimeSignal1D.py
│           │   ├── VBMIDI.py
│           │   ├── VBObject.py
│           │   ├── Video.py
│           │   ├── VideoClip.py
│           │   ├── VideoSource.py
│           │   ├── Video_CV.py
│           │   ├── VisBeatDefines.py
│           │   ├── VisBeatExampleVideo.py
│           │   ├── VisBeatImports.py
│           │   ├── VisualBeat.py
│           │   ├── Warp.py
│           │   ├── __init__.py
│           │   ├── _dancefer_examples.py
│           │   ├── _dancify_examples.py
│           │   ├── _mediafiles.py
│           │   ├── _music_examples.py
│           │   ├── command_line.py
│           │   ├── fileui/
│           │   │   ├── __init__.py
│           │   │   └── uipath.py
│           │   └── vbgui/
│           │       ├── BeatGUI.py
│           │       └── __init__.py
│           └── visbeat3.egg-info/
│               ├── PKG-INFO
│               ├── SOURCES.txt
│               ├── dependency_links.txt
│               ├── requires.txt
│               └── top_level.txt
└── videos/
    └── .gitkeep
Download .txt
SYMBOL INDEX (1500 symbols across 72 files)

FILE: src/gen_midi_conditional.py
  function cal_control_error (line 17) | def cal_control_error(err_note_number_list, err_beat_number_list):
  function generate (line 24) | def generate():

FILE: src/match.py
  function _get_density (line 6) | def _get_density(bar_word):
  function _get_strength_and_tick (line 16) | def _get_strength_and_tick(beat_word):
  function _is_bar_word (line 26) | def _is_bar_word(word):
  function _is_beat_word (line 35) | def _is_beat_word(word):
  function _get_density_and_strength_from_npz (line 44) | def _get_density_and_strength_from_npz(npz):
  function cal_matchness (line 57) | def cal_matchness(midi_npz, v_density, v_strength):
  function match_midi (line 71) | def match_midi(video_npz, all_midi_metadata, all_midi_npz):

FILE: src/midi2mp3.py
  function midi_to_mp3 (line 10) | def midi_to_mp3(midi_path, tempo, mp3_path):

FILE: src/midi2numpy_mix.py
  class Note (line 34) | class Note:
    method __init__ (line 35) | def __init__(self, muspy_note=None, instr_type=None):  # bar starts fr...
    method to_decoder_list (line 47) | def to_decoder_list(self, n_beat: int) -> list:
    method to_muspy_note (line 58) | def to_muspy_note(self) -> muspy.Note:
    method from_decoder_array (line 61) | def from_decoder_array(self, np_array: np.ndarray, bar: int, beat: int...
  class Bar (line 74) | class Bar:
    method __init__ (line 75) | def __init__(self, notes, i_bar):
    method _get_beat_token (line 80) | def _get_beat_token(self, note, density, strength, n_beat: int) -> list:
    method _get_bar_token (line 92) | def _get_bar_token(self, density, n_beat: int) -> list:
    method to_decoder_list (line 102) | def to_decoder_list(self, n_beat: int) -> list:
  class MIDI (line 131) | class MIDI:
    method __init__ (line 132) | def __init__(self, id: str):
    method _get_bars (line 148) | def _get_bars(self):
    method to_decoder_list (line 160) | def to_decoder_list(self) -> list:
  function midi2numpy (line 169) | def midi2numpy(id_list: list):

FILE: src/model.py
  function softmax_with_temperature (line 22) | def softmax_with_temperature(logits, temperature):
  function weighted_sampling (line 28) | def weighted_sampling(probs):
  function nucleus (line 40) | def nucleus(probs, p):
  function sampling (line 57) | def sampling(logit, p=None, t=1.0):
  class CMT (line 81) | class CMT(nn.Module):
    method __init__ (line 82) | def __init__(self, n_token, init_n_token, is_training=True):
    method compute_loss (line 149) | def compute_loss(self, predict, target, loss_mask):
    method forward_init_token_vis (line 155) | def forward_init_token_vis(self, x, memory=None, is_training=True):
    method forward_init_token (line 161) | def forward_init_token(self, x, memory=None, is_training=True):
    method forward_hidden (line 180) | def forward_hidden(self, x, memory=None, is_training=True, init_token=...
    method forward_output (line 235) | def forward_output(self, h, y):
    method forward_output_sampling (line 253) | def forward_output_sampling(self, h, y_type, recurrent=True):
    method inference_from_scratch (line 301) | def inference_from_scratch(self, **kwargs):
    method train_forward (line 445) | def train_forward(self, **kwargs):
    method forward (line 480) | def forward(self, **kwargs):

FILE: src/numpy2midi_mix.py
  function test_numpy2midi (line 16) | def test_numpy2midi(idx: int) -> muspy.Music:
  function numpy2midi (line 23) | def numpy2midi(name, decoder: np.ndarray) -> muspy.Music:

FILE: src/pianoroll2midi.py
  function process_dataset (line 39) | def process_dataset(in_dir, out_dir):
  function convert_midi (line 56) | def convert_midi(in_filename, out_filename):

FILE: src/train.py
  function train_dp (line 20) | def train_dp():

FILE: src/utils.py
  function softmax_with_temperature (line 19) | def softmax_with_temperature(logits, temperature):
  function weighted_sampling (line 24) | def weighted_sampling(probs):
  function nucleus (line 33) | def nucleus(probs, p):
  function sampling (line 50) | def sampling(logit, p=None, t=1.0):
  function network_paras (line 66) | def network_paras(model):
  class Embeddings (line 73) | class Embeddings(nn.Module):
    method __init__ (line 74) | def __init__(self, n_token, d_model):
    method forward (line 79) | def forward(self, x):
  class PositionalEncoding (line 83) | class PositionalEncoding(nn.Module):
    method __init__ (line 84) | def __init__(self, d_model, dropout=0.1, max_len=20000):
    method forward (line 96) | def forward(self, x):
  class BeatPositionalEncoding (line 102) | class BeatPositionalEncoding(nn.Module):
    method __init__ (line 103) | def __init__(self, d_model, dropout=0.1, max_len=20000):
    method forward (line 115) | def forward(self, x, index):
  class Saver (line 120) | class Saver(object):
    method __init__ (line 121) | def __init__(
    method add_summary_msg (line 144) | def add_summary_msg(self, msg):
    method add_summary (line 149) | def add_summary(
    method save_model (line 180) | def save_model(
    method load_model (line 197) | def load_model(
    method global_step_increment (line 208) | def global_step_increment(self):
  function make_loss_report (line 212) | def make_loss_report(
  function log (line 249) | def log(*args, **kwargs):

FILE: src/video2npz/metadata2numpy_mix.py
  function _cal_density (line 25) | def _cal_density(flow_magnitude):
  function _cal_strength (line 32) | def _cal_strength(weight):
  function _get_beat_token (line 39) | def _get_beat_token(beat, strength, i_beat, n_beat):
  function _get_bar_token (line 49) | def _get_bar_token(density, i_beat, n_beat):
  function metadata2numpy (line 59) | def metadata2numpy(metadata):

FILE: src/video2npz/optical_flow.py
  function makedirs (line 11) | def makedirs(dirs):
  function dense_optical_flow (line 32) | def dense_optical_flow(method, video_path, params=[], to_gray=False):

FILE: src/video2npz/resize_video.py
  function resize_video (line 4) | def resize_video(video_name, in_dir='video', out_dir='video_360p', max_h...

FILE: src/video2npz/stat_mix.py
  function _cal_density (line 1) | def _cal_density(flow_magnitude):
  function _cal_strength (line 8) | def _cal_strength(weight):

FILE: src/video2npz/video2metadata.py
  function makedirs (line 17) | def makedirs(d):
  function frange (line 22) | def frange(start, stop, step=1.0):
  function process_all_videos (line 28) | def process_all_videos(args):
  function process_video (line 42) | def process_video(video_path, args):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/AFileManager.py
  class AFileManager (line 5) | class AFileManager(AObject):
    method AOBJECT_TYPE (line 12) | def AOBJECT_TYPE():
    method getJSONPath (line 15) | def getJSONPath(self):
    method __init__ (line 18) | def __init__(self, path=None, clear_temp=None):
    method initializeBlank (line 26) | def initializeBlank(self):
    method getJSONName (line 30) | def getJSONName(self):
    method initWithPath (line 33) | def initWithPath(self, path=None, clear_temp=None):
    method setDir (line 87) | def setDir(self, name, path):
    method addDir (line 94) | def addDir(self, name):
    method getDir (line 98) | def getDir(self, name):
    method emptyDir (line 103) | def emptyDir(self, name):
    method deleteDir (line 109) | def deleteDir(self, name):
    method toDictionary (line 118) | def toDictionary(self):
    method copyPathToDir (line 124) | def copyPathToDir(self, path_to_copy, dest_dir):
    method copyDirToPath (line 133) | def copyDirToPath(self, dir_to_copy, dest_path):
    method copyRandomFractionOfFilesInSourceDir (line 141) | def copyRandomFractionOfFilesInSourceDir(source_dir, dest_dir, fractio...
    method initFromDictionary (line 177) | def initFromDictionary(self, d):
    method save (line 181) | def save(self):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/AFuncDict.py
  class AFuncDict (line 4) | class AFuncDict(AParamDict):
    method __init__ (line 12) | def __init__(self, owner=None, name=None, path=None):
    method getEntry (line 16) | def getEntry(self, name=None, params=None, force_recompute=False):
    method getValue (line 32) | def getValue(self, name=None, params=None, force_recompute=False):
    method getParams (line 39) | def getParams(self, name=None):
    method getFunction (line 46) | def getFunction(self, name=None):
    method setValue (line 49) | def setValue(self, name, value=None, params=None, modified=True):
    method setFunction (line 55) | def setFunction(self, name, function=None):
    method saveEntry (line 58) | def saveEntry(self, name, path, force=False):
    method setEntryModified (line 71) | def setEntryModified(self, name, is_modified=True):
    method isEntryModified (line 76) | def isEntryModified(self, name):
    method isModified (line 87) | def isModified(self):
    method setModified (line 90) | def setModified(self, is_modified):
    method save (line 93) | def save(self, path, force=False):
    method loadEntry (line 103) | def loadEntry(self, name, path):
    method load (line 111) | def load(self, path):
    method getKeyList (line 119) | def getKeyList(self):
    method getFunctionList (line 122) | def getFunctionList(self):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/AImports.py
  function AWARN (line 21) | def AWARN(message):
  function AINFORM (line 24) | def AINFORM(message):
  function AWARN (line 30) | def AWARN(message):
  function AINFORM (line 33) | def AINFORM(message):
  function local_time_string (line 37) | def local_time_string():
  function get_temp_file_path (line 40) | def get_temp_file_path(final_file_path="TEMP", temp_dir_path = None):
  function runningInNotebook (line 55) | def runningInNotebook():
  function getshellname (line 67) | def getshellname():
  function runningInSpyder (line 75) | def runningInSpyder():
  function pickleToPath (line 78) | def pickleToPath(d, path):
  function unpickleFromPath (line 86) | def unpickleFromPath(path):
  function make_sure_path_exists (line 92) | def make_sure_path_exists(path):
  function make_sure_dir_exists (line 99) | def make_sure_dir_exists(path):
  function safe_file_name (line 108) | def safe_file_name(input_string):
  function pathstring (line 111) | def pathstring(path):
  function is_interactive (line 114) | def is_interactive():
  function printOb (line 118) | def printOb(obj):
  function pathstring (line 122) | def pathstring(path):
  function get_prepended_name_file_path (line 125) | def get_prepended_name_file_path(original_file_path, string_to_prepend):
  function safe_file_name (line 131) | def safe_file_name(input_string):
  function change_extension (line 134) | def change_extension(input_path, new_ext):
  function printDictionary (line 138) | def printDictionary(obj):
  function spotgt_shift_bit_length (line 155) | def spotgt_shift_bit_length(x):
  function get_file_name_from_path (line 159) | def get_file_name_from_path(pth):
  function get_dir_from_path (line 162) | def get_dir_from_path(pth):
  function get_file_names_from_paths (line 165) | def get_file_names_from_paths(pths):
  function writeDictionaryToJSON (line 171) | def writeDictionaryToJSON(d, json_path=None):
  function vtt_to_srt (line 177) | def vtt_to_srt(fileContents):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/AObject.py
  class AObject (line 8) | class AObject(object):
    method __init__ (line 17) | def __init__(self, path=None, **kwargs):
    method initializeBlank (line 23) | def initializeBlank(self):
    method setPath (line 30) | def setPath(self, file_path=None, **kwargs):
    method getPath (line 45) | def getPath(self):
    method _showFile (line 51) | def _showFile(self):
    method _open (line 55) | def _open(self):
    method getRelativePath (line 59) | def getRelativePath(self, base_path=None):
    method getFileName (line 67) | def getFileName(self):
    method getFileExtension (line 73) | def getFileExtension(self):
    method getDirectoryPath (line 79) | def getDirectoryPath(self):
    method setInfo (line 82) | def setInfo(self, label, value):
    method getInfo (line 85) | def getInfo(self, label):
    method loadFromJSON (line 88) | def loadFromJSON(self, json_path=None):
    method writeToJSON (line 96) | def writeToJSON(self, json_path=None):
    method serializeInfo (line 104) | def serializeInfo(self):
    method save (line 107) | def save(self, features_to_save='all', overwrite=True, **kwargs):
    method load (line 113) | def load(self, features_to_load=None, **kwargs):
    method AOBJECT_TYPE (line 121) | def AOBJECT_TYPE():
    method toDictionary (line 124) | def toDictionary(self):
    method initFromDictionary (line 128) | def initFromDictionary(self, d):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/AParamDict.py
  class AParamDict (line 2) | class AParamDict(object):
    method __init__ (line 12) | def __init__(self, owner=None, name=None, path=None):
    method getEntry (line 18) | def getEntry(self, name=None, params=None, force_recompute=False):
    method setEntry (line 24) | def setEntry(self, name, d):
    method removeEntry (line 28) | def removeEntry(self, name, assert_if_absent=True, set_modified = True):
    method hasEntry (line 37) | def hasEntry(self, name=None):
    method getValue (line 40) | def getValue(self, name=None, params=None, force_recompute=False):
    method getParams (line 47) | def getParams(self, name=None):
    method setValue (line 54) | def setValue(self, name, value=None, params=None, modified=True):
    method saveEntry (line 59) | def saveEntry(self, name, path, force=False):
    method setEntryModified (line 70) | def setEntryModified(self, name, is_modified=True):
    method isEntryModified (line 75) | def isEntryModified(self, name):
    method isModified (line 82) | def isModified(self):
    method setModified (line 85) | def setModified(self, is_modified):
    method save (line 88) | def save(self, path, force=False):
    method loadEntry (line 97) | def loadEntry(self, name, path):
    method load (line 105) | def load(self, path):
    method getKeyList (line 113) | def getKeyList(self):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/Audio.py
  class Audio (line 11) | class Audio(TimeSignal1D):
    method __init__ (line 20) | def __init__(self, path=None, sampling_rate=None, x=None, name=None):
    method name (line 34) | def name(self):
    method getName (line 36) | def getName(self):
    method name (line 39) | def name(self, value):
    method _setName (line 41) | def _setName(self, value):
    method initializeBlank (line 45) | def initializeBlank(self):
    method _getFrameRate (line 50) | def _getFrameRate(self):
    method clone (line 53) | def clone(self):
    method loadFile (line 65) | def loadFile(self, file_path=None, sampling_rate=None, convert_to_mono...
    method getStereo (line 77) | def getStereo(self):
    method getStereoSamplingRate (line 80) | def getStereoSamplingRate(self):
    method getStringForHTMLStreamingBase64 (line 85) | def getStringForHTMLStreamingBase64(self):
    method getStereoEncodedBase64WAV (line 89) | def getStereoEncodedBase64WAV(self):
    method getMonoEncodedBase64WAV (line 99) | def getMonoEncodedBase64WAV(self):
    method getLocalRhythmicSaliency (line 106) | def getLocalRhythmicSaliency(self, **kwargs):
    method play (line 110) | def play(self, autoplay = None):
    method playBeats (line 145) | def playBeats(self, indices=None, beats=None):
    method AudioClipFromBeatRange (line 163) | def AudioClipFromBeatRange(self, beat_range, beats=None):
    method playSegment (line 176) | def playSegment(self, time_range, autoplay=None):
    method writeToFile (line 200) | def writeToFile(self, output_path=None, output_sampling_rate=None):
    method setValueRange (line 208) | def setValueRange(self, value_range=None):
    method resample (line 213) | def resample(self, sampling_rate):
    method GetResampled (line 218) | def GetResampled(self, sampling_rate):
    method AlignedTo (line 225) | def AlignedTo(self, B):
    method getOffsetFrom (line 267) | def getOffsetFrom(self, B):
    method getShiftAmountTo (line 270) | def getShiftAmountTo(self, B):
    method getBeatEventList (line 316) | def getBeatEventList(self, time_range = None):
    method getBeatEvents (line 335) | def getBeatEvents(self, start_time=None, end_time=None):
    method AudioClip (line 339) | def AudioClip(self, start, end):
    method getWithSoundAdded (line 345) | def getWithSoundAdded(self, add_times, sound=None, mute_original=None,...
    method showSpectrogram (line 372) | def showSpectrogram(self, time_range = None, **kwargs):
    method showMelSpectrogram (line 393) | def showMelSpectrogram(self, force_recompute=False, **kwargs):
    method Silence (line 410) | def Silence(n_seconds, sampling_rate, name=None):
    method _getDampedSin (line 419) | def _getDampedSin(freq, n_seconds=None, sampling_rate=16000, damping=0...
    method PingSound (line 444) | def PingSound(n_seconds=None, freqs=None, damping=None, sampling_rate ...
    method getBeats (line 469) | def getBeats(self, use_full_signal=True, tightness = None, force_recom...
    method getBeatVector (line 497) | def getBeatVector(self, vector_length=None, force_recompute=False):
    method getOnsets (line 513) | def getOnsets(self, use_full_signal=True, force_recompute=False, **kwa...
    method getOnsetSamplingRate (line 526) | def getOnsetSamplingRate(self):
    method pickOnsets (line 529) | def pickOnsets(self, pre_max_time=0.03,
    method getEvents (line 578) | def getEvents(self):
    method getEventList (line 581) | def getEventList(self):
    method getOnsetEvents (line 584) | def getOnsetEvents(self):
    method getBeatEvents (line 589) | def getBeatEvents(self, start_time=None, end_time=None, **kwargs):
    method getOnsetEnvelope (line 604) | def getOnsetEnvelope(self, use_full_signal=True, force_recompute=False...
    method getMelSpectrogram (line 618) | def getMelSpectrogram(self, n_mels = 128, force_recompute=False):
    method getSpectrogram (line 627) | def getSpectrogram(self, hop_length=None, force_recompute=False, **kwa...
    method getRMSE (line 648) | def getRMSE(self, force_recompute=False, hop_length=None, frame_length...
    method getBeatTimeBefore (line 664) | def getBeatTimeBefore(self, t):
    method getBeatBefore (line 667) | def getBeatBefore(self, t):
    method getBeatIndexBefore (line 672) | def getBeatIndexBefore(self, t):
    method getTempogram (line 680) | def getTempogram(self, window_length=None, force_recompute=None, frame...
    method plotTempogram (line 726) | def plotTempogram(self, window=None, time_range=None, **kwargs):
    method plotOnsets (line 746) | def plotOnsets(self, **kwargs):
    method plotBeats (line 754) | def plotBeats(self, **kwargs):
    method plotOnsetEnvelope (line 763) | def plotOnsetEnvelope(self, **kwargs):
    method plotSignal (line 772) | def plotSignal(self, time_range=None, ylim=None, **kwargs):
  function _make_wav (line 796) | def _make_wav(data, rate):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/AudioClip.py
  class AudioClip (line 3) | class AudioClip(Audio):
    method VBOBJECT_TYPE (line 10) | def VBOBJECT_TYPE(self):
    method __init__ (line 13) | def __init__(self, audio=None, start=None, end=None, path=None):
    method _pull_clip_potion (line 42) | def _pull_clip_potion(self):
    method resample (line 54) | def resample(self, sampling_rate):
    method initializeBlank (line 58) | def initializeBlank(self):
    method getSignal (line 65) | def getSignal(self, resample=False):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/Event.py
  class Event (line 3) | class Event(AObject):
    method AOBJECT_TYPE (line 14) | def AOBJECT_TYPE(self):
    method __str__ (line 17) | def __str__(self):
    method __init__ (line 20) | def __init__(self, start=None, type=None, weight=None, index=None, is_...
    method initializeBlank (line 31) | def initializeBlank(self):
    method getAttributeDict (line 42) | def getAttributeDict(self):
    method toDictionary (line 53) | def toDictionary(self):
    method initAttributesFromDictionary (line 59) | def initAttributesFromDictionary(self, d):
    method initFromDictionary (line 71) | def initFromDictionary(self, d):
    method clone (line 75) | def clone(self, start=None):
    method _getIsSelected (line 83) | def _getIsSelected(self):
    method _setIsSelected (line 85) | def _setIsSelected(self, is_selected):
    method _getPhase (line 88) | def _getPhase(self, phase_resolution=None):
    method _setPhase (line 96) | def _setPhase(self, phase, phase_resolution):
    method _getBoundaryType (line 102) | def _getBoundaryType(self):
    method _setBoundaryType (line 104) | def _setBoundaryType(self, boundary_type):
    method _FromGUIDict (line 108) | def _FromGUIDict(cls, gd, phase_resolution=None):
    method _FromGUIDicts (line 117) | def _FromGUIDicts(cls, gds, type=None):
    method _toGUIDict (line 126) | def _toGUIDict(self):
    method _ToGUIDicts (line 142) | def _ToGUIDicts(events, active=None):
    method getUnrolledStartTime (line 162) | def getUnrolledStartTime(self):
    method getStartTime (line 169) | def getStartTime(self):
    method getShifted (line 174) | def getShifted(self, new_start_time):
    method GetUnrolledList (line 181) | def GetUnrolledList(event_list, assert_on_folds=None):
    method NewFromIndices (line 197) | def NewFromIndices(event_list, inds):
    method RollToNOld (line 204) | def RollToNOld(events, n_out, momentum = 0.25):
    method UnfoldToN (line 228) | def UnfoldToN(events, n_out, momentum=0.25):
    method GetDirectedLinks (line 235) | def GetDirectedLinks(events):
    method RollToN (line 274) | def RollToN(events, n_out, start_index = 0, momentum=0.1):
    method Clone (line 304) | def Clone(event_list):
    method SetDirections (line 311) | def SetDirections(event_list, direction):
    method FromStartTimes (line 319) | def FromStartTimes(cls, starts, type=None):
    method FromStartsAndWeights (line 326) | def FromStartsAndWeights(cls, starts, weights, type=None):
    method ToStartTimes (line 334) | def ToStartTimes(events):
    method ToWeights (line 341) | def ToWeights(events):
    method RepeatToLength (line 349) | def RepeatToLength(events, n, endpoints=False):
    method Double (line 368) | def Double(events):
    method Half (line 377) | def Half(events, offset=0):
    method SubdivideIntervals (line 388) | def SubdivideIntervals(events, extra_samples_per_interval=1):
    method Third (line 400) | def Third(events, offset=0):
    method SubsampleEveryN (line 410) | def SubsampleEveryN(events, n, offset=0):
    method FromSignalPeaks (line 434) | def FromSignalPeaks(signal, sampling_rate, event_type=None, index_offs...
    method PlotEventMatches (line 486) | def PlotEventMatches(source_events, target_events, source_in=None, tar...
    method GetWithFirstEventAt (line 503) | def GetWithFirstEventAt(events, first_event_time):
    method GetWithStartTimesShifted (line 511) | def GetWithStartTimesShifted(events, new_start_time):
    method GetScaled (line 518) | def GetScaled(events, scale):
    method GetScaledAndStartingAt (line 525) | def GetScaledAndStartingAt(events, scale, starting_at):
    method ClosestToTargetMatch (line 531) | def ClosestToTargetMatch(source_events, target_events):
    method Sort (line 587) | def Sort(event_list, func=None):
    method GetSorted (line 593) | def GetSorted(event_list, func=None):
    method GetWithTwoWayMerged (line 599) | def GetWithTwoWayMerged(event_list, merge_window = 0.1):
    method ApplyIndices (line 615) | def ApplyIndices(event_list):
    method PlotSignalAndEvents (line 620) | def PlotSignalAndEvents(signal, sampling_rate, events, time_range = No...

FILE: src/video2npz/visbeat3/build/lib/visbeat3/EventList.py
  class EventList (line 3) | class EventList(AObject):
    method AOBJECT_TYPE (line 9) | def AOBJECT_TYPE(self):
    method __init__ (line 12) | def __init__(self, events=None):
    method initializeBlank (line 18) | def initializeBlank(self):
    method list (line 22) | def list(self):
    method Clone (line 25) | def Clone(self):
    method toDictionary (line 28) | def toDictionary(self):
    method serializeEvents (line 33) | def serializeEvents(self):
    method getActiveEvents (line 39) | def getActiveEvents(self):
    method initFromDictionary (line 46) | def initFromDictionary(self, d):
    method unroll (line 54) | def unroll(self, assert_on_folds=None):
    method getUnrolled (line 58) | def getUnrolled(self, assert_on_folds=None):
    method getFromIndices (line 61) | def getFromIndices(self, inds):
    method getRolledToN (line 64) | def getRolledToN(self, n_out, momentum = 0.1):
    method toStartTimes (line 68) | def toStartTimes(self):
    method _toGUIDicts (line 71) | def _toGUIDicts(self):
    method _FromGUIDicts (line 75) | def _FromGUIDicts(gds, type=None):
    method FromJSON (line 81) | def FromJSON(json_path=None):
    method FromStartTimes (line 89) | def FromStartTimes(starts, type=None, event_class=None):
    method toWeights (line 98) | def toWeights(self):
    method getDoubled (line 101) | def getDoubled(self):
    method getHalved (line 104) | def getHalved(self, offset=0):
    method getThirded (line 107) | def getThirded(self, offset=0):
    method FromSignalPeaks (line 111) | def FromSignalPeaks(**kwargs):
    method PlotEventMatches (line 115) | def PlotEventMatches(source_elist, target_elist, source_in=None, targe...
    method getWithFirstEventAt (line 118) | def getWithFirstEventAt(self, first_event_time):
    method getWithStartTimesShifted (line 121) | def getWithStartTimesShifted(self, new_start_time):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/Image.py
  function imshow (line 14) | def imshow(imdata, new_figure = True):
  class Image (line 26) | class Image(AObject):
    method AOBJECT_TYPE (line 33) | def AOBJECT_TYPE(self):
    method __init__ (line 36) | def __init__(self, data=None, path = None):
    method initializeBlank (line 42) | def initializeBlank(self):
    method setBlank (line 46) | def setBlank(self, shape=None):
    method loadImageData (line 52) | def loadImageData(self, path = None, force_reload=True):
    method shape (line 61) | def shape(self):
    method _getShape (line 64) | def _getShape(self):
    method dtype (line 68) | def dtype(self):
    method width (line 72) | def width(self):
    method _getWidth (line 75) | def _getWidth(self):
    method height (line 79) | def height(self):
    method _getHeight (line 82) | def _getHeight(self):
    method _is_float (line 86) | def _is_float(self):
    method _is_int (line 90) | def _is_int(self):
    method _pixels_float (line 94) | def _pixels_float(self):
    method _pixels_uint (line 101) | def _pixels_uint(self):
    method n_channels (line 108) | def n_channels(self):
    method _getNChannels (line 111) | def _getNChannels(self):
    method FromGrayScale (line 118) | def FromGrayScale(gray_data, color_map = None, format=None, **kwargs):
    method printTempDir (line 135) | def printTempDir():
    method scaleToValueRange (line 138) | def scaleToValueRange(self, value_range=None):
    method nChannels (line 158) | def nChannels(self):
    method getClone (line 164) | def getClone(self):
    method getGridPixel (line 168) | def getGridPixel(self,x,y,repeatEdge=0):
    method getPixel (line 202) | def getPixel(self, x, y, repeatEdge=0):
    method getShape (line 229) | def getShape(self):
    method getScaled (line 232) | def getScaled(self, shape=None, shape_xy=None):
    method getRotated (line 243) | def getRotated(self, theta):
    method _splatAtPixCoord (line 250) | def _splatAtPixCoord(self, im, location=[0,0], **kwargs):
    method reflectY (line 268) | def reflectY(self):
    method reflectX (line 271) | def reflectX(self):
    method PIL (line 274) | def PIL(self):
    method getRGBData (line 277) | def getRGBData(self):
    method normalize (line 280) | def normalize(self, scale=1.0):
    method show (line 284) | def show(self, new_figure = True):
    method writeToFile (line 296) | def writeToFile(self, out_path):
    method getEncodedBase64 (line 299) | def getEncodedBase64(self):
    method getDataAsString (line 302) | def getDataAsString(self):
    method FromBase64 (line 306) | def FromBase64(encoded_data, shape):
    method FromDataString (line 316) | def FromDataString(data_string, shape, dtype=None):
    method _get_font_size (line 324) | def _get_font_size(self, text, font_path, max_width=None, max_height=N...
    method writeOutlinedText (line 337) | def writeOutlinedText(self, xy, text,
    method writeText (line 356) | def writeText(self, xy, text, font_filename='RobotoCondensed-Regular.t...
    method _get_text_size (line 397) | def _get_text_size(self, font_path, font_size, text):
    method _VBMark (line 402) | def _VBMark():
    method _vbmark (line 407) | def _vbmark(self):
    method _vbmarker (line 410) | def _vbmarker(self):
    method writeTextBox (line 422) | def writeTextBox(self, xy, text, box_width, font_filename='RobotoConde...

FILE: src/video2npz/visbeat3/build/lib/visbeat3/Image_CV.py
  function flow2rgb (line 25) | def flow2rgb(flow):
  function showFlowHSV (line 42) | def showFlowHSV(flow, new_figure = True):
  function cornerHarris (line 52) | def cornerHarris(im, blockSize=None, ksize=None, k=None):
  function cvDenseFlowFarneback (line 61) | def cvDenseFlowFarneback(from_image, to_image, pyr_scale=None, levels=No...
  function RGB2Gray (line 118) | def RGB2Gray(self):
  function Gray2RGB (line 124) | def Gray2RGB(self):
  function cvGoodFeaturesToTrack (line 128) | def cvGoodFeaturesToTrack(self, maxCorners=None, qualityLevel=None, minD...
  function withFlow (line 155) | def withFlow(self, flow, step=16):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/SourceLocationParser.py
  class SourceURL (line 15) | class SourceURL(object):
    method SourceLocationType (line 25) | def SourceLocationType(cls):
    method __init__ (line 28) | def __init__(self, source_location):
    method code (line 34) | def code(self):
    method _getCode (line 41) | def _getCode(self):
    method code (line 45) | def code(self, value):
    method _setCode (line 47) | def _setCode(self, value):
    method url (line 53) | def url(self):
    method get_url (line 58) | def get_url(self):
    method protocol (line 62) | def protocol(self):
    method thumbnail (line 69) | def thumbnail(self):
    method is_valid (line 76) | def is_valid(cls, url):
  class WebSourceException (line 79) | class WebSourceException(Exception):
  class VideoDoesntExistException (line 84) | class VideoDoesntExistException(WebSourceException):
  class UnknownBackendException (line 89) | class UnknownBackendException(WebSourceException):
  class UnknownIdException (line 94) | class UnknownIdException(VideoDoesntExistException):
  class YoutubeURL (line 101) | class YoutubeURL(SourceURL):
    method SourceLocationType (line 107) | def SourceLocationType(cls):
    method get_url (line 154) | def get_url(self):
    method get_thumbnail_url (line 162) | def get_thumbnail_url(self):
    method _getCode (line 172) | def _getCode(self):
    method get_thumbnail_url (line 190) | def get_thumbnail_url(self):
  class FilePathURL (line 206) | class FilePathURL(SourceURL):
    method SourceLocationType (line 208) | def SourceLocationType(cls):
    method __init__ (line 211) | def __init__(self, source_location):
    method is_valid (line 216) | def is_valid(cls, source_location):
    method _getCode (line 219) | def _getCode(self):
  function ParseSourseLocation (line 230) | def ParseSourseLocation(url):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/TimeSignal.py
  class TimeSignal (line 7) | class TimeSignal(VBObject):
    method VBBJECT_TYPE (line 14) | def VBBJECT_TYPE(self):
    method __init__ (line 17) | def __init__(self, path=None, sampling_rate = None):
    method initializeBlank (line 25) | def initializeBlank(self):
    method frame_rate (line 32) | def frame_rate(self):
    method _getFrameRate (line 34) | def _getFrameRate(self):
    method getSampleAtTime (line 39) | def getSampleAtTime(self, f):
    method getSampleAtIndex (line 45) | def getSampleAtIndex(self, i):
    method getDuration (line 48) | def getDuration(self):
    method getSampleDuration (line 51) | def getSampleDuration(self):
    method getTimeForIndex (line 54) | def getTimeForIndex(self, i):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/TimeSignal1D.py
  class TimeSignal1D (line 4) | class TimeSignal1D(TimeSignal):
    method VBOJECT_TYPE (line 11) | def VBOJECT_TYPE(self):
    method __init__ (line 14) | def __init__(self, path=None, sampling_rate = None, x=None):
    method initializeBlank (line 20) | def initializeBlank(self):
    method getSignal (line 24) | def getSignal(self, resampled=False):
    method getSignalSegment (line 27) | def getSignalSegment(self, time_range):
    method getFullSignal (line 33) | def getFullSignal(self):
    method getSampleAtTime (line 36) | def getSampleAtTime(self, f):
    method getSampleAtIndex (line 42) | def getSampleAtIndex(self, i):
    method getDuration (line 45) | def getDuration(self):
    method setValueRange (line 48) | def setValueRange(self, value_range=None):
    method setMaxAbsValue (line 57) | def setMaxAbsValue(self, max_abs_val=1.0):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/VBMIDI.py
  class VBMIDITrack (line 9) | class VBMIDITrack(object):
    method __init__ (line 10) | def __init__(self, track, ticks_per_beat):
    method getBPM (line 20) | def getBPM(self):
    method getNoteOnTimes (line 23) | def getNoteOnTimes(self, include_negative=None):
    method _get_note_on_times (line 29) | def _get_note_on_times(self, include_negative = None):
    method get_note_durations (line 47) | def get_note_durations(self, track_num):
    method get_mouth_events (line 69) | def get_mouth_events(self):
    method getNoteOnTimesAsAudio (line 104) | def getNoteOnTimesAsAudio(self, sampling_rate = None, note_sound=None,...
  class VBMIDI (line 116) | class VBMIDI(TimeSignal1D):
    method __init__ (line 117) | def __init__(self, path=None):
    method getNoteOnTimes (line 124) | def getNoteOnTimes(self, include_negative=None):
    method getMouthEvents (line 127) | def getMouthEvents(self):
    method getNoteOnTimesAsAudio (line 130) | def getNoteOnTimesAsAudio(self, sampling_rate=None, note_sound=None):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/VBObject.py
  class VBObject (line 7) | class VBObject(AObject):
    method __init__ (line 20) | def __init__(self, path=None):
    method initializeBlank (line 23) | def initializeBlank(self):
    method saveFeature (line 29) | def saveFeature(self, name, path):
    method saveFeatures (line 33) | def saveFeatures(self, path):
    method loadFeature (line 36) | def loadFeature(self, name, path):
    method loadFeatures (line 40) | def loadFeatures(self, path):
    method getFeature (line 43) | def getFeature(self,name, force_recompute=False, **kwargs):
    method getFeatureEntry (line 49) | def getFeatureEntry(self, name, params=None, force_recompute=False):
    method getFeatureParams (line 52) | def getFeatureParams(self, name):
    method setFeature (line 55) | def setFeature(self, name, value, params=None):
    method removeFeature (line 60) | def removeFeature(self, name, assert_if_absent=True, set_modified=True):
    method hasFeature (line 65) | def hasFeature(self, name):
    method getFeatureFunction (line 69) | def getFeatureFunction(self, feature_name):
    method getFeaturesList (line 72) | def getFeaturesList(self):
    method getFeatureFunctionsList (line 75) | def getFeatureFunctionsList(self):
    method clearFeatureFiles (line 78) | def clearFeatureFiles(self, features_to_clear=None, **kwargs):
    method AOBJECT_TYPE (line 87) | def AOBJECT_TYPE(self):
    method VBOBJECT_TYPE (line 90) | def VBOBJECT_TYPE(self):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/Video.py
  function MPYWriteVideoFile (line 16) | def MPYWriteVideoFile(mpyclip, filename, **kwargs):
  class Video (line 22) | class Video(TimeSignal):
    method AOBJECT_TYPE (line 30) | def AOBJECT_TYPE(self):
    method __init__ (line 33) | def __init__(self, path=None, name=None, num_frames_total=None):
    method initializeBlank (line 40) | def initializeBlank(self):
    method _getFrameRate (line 56) | def _getFrameRate(self):
    method gui (line 62) | def gui(self):
    method _getGui (line 65) | def _getGui(self):
    method gui (line 69) | def gui(self, value):
    method _setGui (line 72) | def _setGui(self, value):
    method getVersionInfo (line 77) | def getVersionInfo(self):
    method getName (line 89) | def getName(self):
    method getTempDir (line 95) | def getTempDir(self):
    method getStringForHTMLStreamingBase64 (line 101) | def getStringForHTMLStreamingBase64(self):
    method n_frames (line 107) | def n_frames(self):
    method getDuration (line 112) | def getDuration(self):
    method getStartTime (line 115) | def getStartTime(self):
    method getEndTime (line 118) | def getEndTime(self):
    method getMPYClip (line 121) | def getMPYClip(self, get_audio=True):
    method getAudio (line 124) | def getAudio(self):
    method loadFile (line 127) | def loadFile(self, file_path=None, num_frames_total=None):
    method openVideoWriter (line 148) | def openVideoWriter(self, output_file_path, fps=None):
    method closeVideoWriter (line 158) | def closeVideoWriter(self):
    method getFrameShape (line 162) | def getFrameShape(self):
    method calcNumFramesTotal (line 170) | def calcNumFramesTotal(self):
    method readFrameBasic (line 188) | def readFrameBasic(self, i):
    method getFrame (line 197) | def getFrame(self, f):
    method getFrameFromTime (line 200) | def getFrameFromTime(self, t):
    method getFrameLinearInterp (line 204) | def getFrameLinearInterp(self, f):
    method writeFrame (line 213) | def writeFrame(self, img):
    method play (line 219) | def play(self):
    method show (line 232) | def show(self):
    method write (line 235) | def write(self, output_path, output_sampling_rate=None):
    method VideoClip (line 267) | def VideoClip(self, start=None, end=None, name=None):
    method getImageFromFrame (line 278) | def getImageFromFrame(self, i):
    method getImageFromTime (line 284) | def getImageFromTime(self, t):
    method writeResolutionCopyFFMPEG (line 294) | def writeResolutionCopyFFMPEG(self, path, max_height=None):
    method writeFFMPEG (line 308) | def writeFFMPEG(self, output_path):
    method writeResolutionCopy (line 315) | def writeResolutionCopy(self, path, max_height=None, reshape=None, inp...
    method writeWarped (line 376) | def writeWarped(self, output_path, warp, output_sampling_rate=None, ou...
    method getVersionLabel (line 453) | def getVersionLabel(self):
    method getWarpsDir (line 456) | def getWarpsDir(self):
    method getWithBeginningCroppedToAudio (line 462) | def getWithBeginningCroppedToAudio(self, target):
    method getWarped (line 478) | def getWarped(self, target,
    method getWithSoundsOnEvents (line 543) | def getWithSoundsOnEvents(self, events, output_path=None, name_tag = N...
    method CreateFromVideoAndAudio (line 592) | def CreateFromVideoAndAudio(video_path=None, audio_path=None, video_ob...
    method CreateByStackingVideos (line 668) | def CreateByStackingVideos(video_objects=None, video_paths=None, outpu...
    method CreateFromVideoAndAudioPaths (line 716) | def CreateFromVideoAndAudioPaths(video_path, audio_path, output_path, ...
    method CreateFromVideoAndAudioObjects (line 720) | def CreateFromVideoAndAudioObjects(video, audio, output_path, clip_to_...
    method _getDefaultPeakPickingTimeParams (line 724) | def _getDefaultPeakPickingTimeParams(self, **kwargs):
    method getFrameIndexes (line 740) | def getFrameIndexes(self, force_recompute=False):
    method getFeaturesList (line 752) | def getFeaturesList(self):
    method getVideoFeaturesList (line 755) | def getVideoFeaturesList(self):
    method getFeatureFunctionsList (line 758) | def getFeatureFunctionsList(self):
    method getFeatureSourceType (line 761) | def getFeatureSourceType(self, name):
    method getFeature (line 771) | def getFeature(self, name, force_recompute=False, **kwargs):
  function getEvents (line 835) | def getEvents(self, **kwargs):
  function getEventList (line 840) | def getEventList(self, **kwargs):
  function runBeatGUIOnAudio (line 843) | def runBeatGUIOnAudio(self):
  function runGUI (line 848) | def runGUI(self, local_saliency=None, frame_rate = None, eventlist = 'de...

FILE: src/video2npz/visbeat3/build/lib/visbeat3/VideoClip.py
  class VideoClip (line 5) | class VideoClip(Video):
    method AOBJECT_TYPE (line 12) | def AOBJECT_TYPE(self):
    method __init__ (line 15) | def __init__(self, video=None, start=None, end=None, clip_to_frame=Tru...
    method initializeBlank (line 41) | def initializeBlank(self):
    method getFrameLinearInterp (line 50) | def getFrameLinearInterp(self, f):
    method getFrame (line 53) | def getFrame(self, f):
    method getDuration (line 56) | def getDuration(self, round_to_frames=False):
    method n_frames (line 62) | def n_frames(self):
    method getStartTime (line 73) | def getStartTime(self):
    method getEndTime (line 76) | def getEndTime(self):
    method getMPYClip (line 79) | def getMPYClip(self, get_audio=True):
    method play (line 82) | def play(self):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/VideoSource.py
  function safe_file_name (line 12) | def safe_file_name(input_string):
  class VideoSource (line 15) | class VideoSource(AFileManager):
    method getJSONName (line 25) | def getJSONName(self):
    method AOBJECT_TYPE (line 28) | def AOBJECT_TYPE(self):
    method __init__ (line 31) | def __init__(self, path, name=None, source_location=None, VideoClass =...
    method NewVideoSource (line 52) | def NewVideoSource(destination, name, source_location=None, VideoClass...
    method initializeBlank (line 58) | def initializeBlank(self):
    method toDictionary (line 70) | def toDictionary(self):
    method initFromDictionary (line 86) | def initFromDictionary(self, d):
    method initWithPath (line 99) | def initWithPath(self, path=None, clear_temp=None):
    method setFeaturesDir (line 107) | def setFeaturesDir(self, features_dir=None):
    method getName (line 115) | def getName(self):
    method _versionLabelString (line 132) | def _versionLabelString(version_label=None):
    method _versionGroupString (line 139) | def _versionGroupString(version_group=None):
    method _getVersionLabelDirName (line 145) | def _getVersionLabelDirName(version_label=None):
    method getVersionPath (line 152) | def getVersionPath(self, version_label=None, version_group=None):
    method getDirForVersion (line 160) | def getDirForVersion(self, version_label=None, version_group=None):
    method getVersionInfo (line 165) | def getVersionInfo(self, version_label, version_group=None, info_label...
    method getVersionDictionary (line 179) | def getVersionDictionary(self, version_label=None, version_group=None):
    method setVersionDictionary (line 188) | def setVersionDictionary(self, version_label=None, version_group=None,...
    method setVersionInfo (line 198) | def setVersionInfo(self, version_label=None, version_group=None, video...
    method hardSave (line 211) | def hardSave(self):
    method save (line 216) | def save(self):
    method getWarpsDir (line 323) | def getWarpsDir(self, version_label=None):
    method getVersion (line 332) | def getVersion(self, max_height=None, get_if_missing=True, load_featur...
    method saveFeaturesForVideo (line 369) | def saveFeaturesForVideo(self, video, features_to_save=None, output_di...
    method saveFeatureForVideo (line 377) | def saveFeatureForVideo(self, video, feature_name, output_dir=None, ov...
    method loadFeaturesForVideo (line 394) | def loadFeaturesForVideo(self, video, features_to_load=None):
    method loadFeatureForVideo (line 402) | def loadFeatureForVideo(self, video, feature_name):
    method getFeaturePath (line 414) | def getFeaturePath(self, feature_name=None, source_type=None, version_...
    method getFeatureDir (line 428) | def getFeatureDir(self, feature_name=None, source_type=None):
    method saveFeaturesForVersion (line 435) | def saveFeaturesForVersion(self, version_label=None, output_dir=None):
    method RegisteredVideo (line 441) | def RegisteredVideo(self, path=None, version_label=None, version_group...
    method RegisterVideo (line 447) | def RegisterVideo(self, video, version_label = None, version_group = N...
    method addVersion (line 472) | def addVersion(self, path, version_label=None, version_group=None):
    method addVersionToVideo (line 479) | def addVersionToVideo(self, video, new_video, version_label=None, vers...
    method setSource (line 488) | def setSource(self, source_location=None, assert_valid=True, **kwargs):
    method setSourceYoutube (line 516) | def setSourceYoutube(self, url=None, max_height=None, pull_fullres=Tru...
    method setSourceFile (line 523) | def setSourceFile(self, path=None, copy=True, **kwargs):
    method pullVersion (line 556) | def pullVersion(self, max_height=None, **kwargs):
    method pullFileVideo (line 567) | def pullFileVideo(self, max_height=None, force_recompute=None):
    method pullYoutubeVideo (line 582) | def pullYoutubeVideo(self, max_height=None, write_subtitles=False, sav...

FILE: src/video2npz/visbeat3/build/lib/visbeat3/Video_CV.py
  function localRhythmicSaliencyFunction (line 33) | def localRhythmicSaliencyFunction(self, **kwargs):
  function visualBeatFunction (line 39) | def visualBeatFunction(self, **kwargs):
  function getLocalRhythmicSaliency (line 56) | def getLocalRhythmicSaliency(self, force_recompute=False, **kwargs):
  function getVisualBeats (line 66) | def getVisualBeats(self, force_recompute=False, **kwargs):
  function cvGetGrayFrame (line 83) | def cvGetGrayFrame(self, f):
  function getImageFromFrameGray (line 87) | def getImageFromFrameGray(self, f):
  function flow2row (line 92) | def flow2row(ang, amp, bins, subdivs, n_shifts, density):
  function getFlowFrame (line 128) | def getFlowFrame(self, frame_index):
  function getFlowFramePolar (line 133) | def getFlowFramePolar(self, frame_index):
  function computeDirectogramPowers (line 146) | def computeDirectogramPowers(self, bins=None, dead_zone= 0.05, density=N...
  function getDirectogramPowers (line 224) | def getDirectogramPowers(self, force_recompute=False, **kwargs):
  function getDirectogram (line 231) | def getDirectogram(self, **kwargs):
  function getVisualTempo (line 240) | def getVisualTempo(self, force_recompute=None, **kwargs):
  function getVisualTempogram (line 250) | def getVisualTempogram(self, window_length=None, force_recompute=None, n...
  function getVisibleImpactEnvelope (line 311) | def getVisibleImpactEnvelope(self, force_recompute=False, **kwargs):
  function getForwardVisibleImpactEnvelope (line 319) | def getForwardVisibleImpactEnvelope(self, force_recompute=False, **kwargs):
  function getBackwardVisibleImpactEnvelope (line 334) | def getBackwardVisibleImpactEnvelope(self, force_recompute=False, **kwar...
  function getBothWayVisibleImpactEnvelope (line 342) | def getBothWayVisibleImpactEnvelope(self, force_recompute=False, **kwargs):
  function getVisibleImpactEnvelopePowers (line 350) | def getVisibleImpactEnvelopePowers(self, force_recompute=False, **kwargs):
  function getCutTimes (line 362) | def getCutTimes(self):
  function getCutEvents (line 365) | def getCutEvents(self, force_recompute=False, **kwargs):
  function visualBeatsFromEvents (line 402) | def visualBeatsFromEvents(self, events):
  function getVisualBeatTimes (line 431) | def getVisualBeatTimes(self, **kwargs):
  function getDirectionalFlux (line 434) | def getDirectionalFlux(self,
  function computeImpactEnvelope (line 472) | def computeImpactEnvelope(self,
  function computeImpactEnvelopeOld (line 558) | def computeImpactEnvelopeOld(self, f_sigma=None, median_kernel=None, hig...
  function getVisibleImpacts (line 641) | def getVisibleImpacts(self, force_recompute=False, include_cut_events = ...
  function getForwardVisibleImpacts (line 664) | def getForwardVisibleImpacts(self, force_recompute=False, include_cut_ev...
  function getBackwardVisibleImpacts (line 682) | def getBackwardVisibleImpacts(self, force_recompute=False, include_cut_e...
  function findAccidentalDanceSequences (line 702) | def findAccidentalDanceSequences(self, target_n_beats = 7, n_samples=25,...
  function getVisualBeatSequences (line 720) | def getVisualBeatSequences(self,
  function printVisualBeatSequences (line 802) | def printVisualBeatSequences(self,
  function plotEvents (line 863) | def plotEvents(self, events, time_range = 'default', **kwargs):
  function plotCutEvents (line 875) | def plotCutEvents(self, **kwargs):
  function plotVisibleImpacts (line 880) | def plotVisibleImpacts(self, **kwargs):
  function plotImpactEnvelope (line 888) | def plotImpactEnvelope(self, **kwargs):
  function plotVisualBeats (line 897) | def plotVisualBeats(self, **kwargs):
  function loadFlowFeatures (line 906) | def loadFlowFeatures(self):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/VisBeatExampleVideo.py
  class VisBeatExampleVideo (line 4) | class VisBeatExampleVideo(object):
    method __init__ (line 5) | def __init__(self, name, url, start_beat=None, end_beat = None, displa...
    method code (line 20) | def code(self):
    method _getCode (line 22) | def _getCode(self):
    method code (line 25) | def code(self, value):
    method _setCode (line 27) | def _setCode(self, value):
    method display_name (line 35) | def display_name(self):
    method _getDisplayName (line 37) | def _getDisplayName(self):
    method _ytWatchURL (line 45) | def _ytWatchURL(self):
    method _ytEmbedURL (line 48) | def _ytEmbedURL(self, autoplay=None):
    method _ytThumbURL (line 54) | def _ytThumbURL(self):
    method _fancyBoxCode (line 57) | def _fancyBoxCode(self, with_label = None):
  class HTMLCode (line 76) | class HTMLCode(object):
    method __init__ (line 77) | def __init__(self, start_string=None):
    method string (line 86) | def string(self):
    method _getString (line 88) | def _getString(self):
    method code (line 93) | def code(self):
    method _getCode (line 95) | def _getCode(self):
    method code (line 98) | def code(self, value):
    method _setCode (line 100) | def _setCode(self, value):
    method soup (line 107) | def soup(self):
    method _getSoup (line 109) | def _getSoup(self):
    method _makeSoup (line 114) | def _makeSoup(self):
    method add (line 123) | def add(self, s):
    method addLine (line 126) | def addLine(self, s):
    method startTable (line 129) | def startTable(self, id=None, class_ = None, **kwargs):
    method endTable (line 141) | def endTable(self):
    method startRow (line 145) | def startRow(self):
    method endRow (line 148) | def endRow(self):
    method addColumnLabel (line 151) | def addColumnLabel(self, label):
    method addRowLabel (line 156) | def addRowLabel(self, label):
    method addRowCell (line 161) | def addRowCell(self, content):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/VisBeatImports.py
  function local_time_string (line 29) | def local_time_string():
  function VBWARN (line 33) | def VBWARN(message):
  function vb_get_ipython (line 65) | def vb_get_ipython():
  function clipping_params (line 68) | def clipping_params(clip_bins=30, clip_fraction=0.95):
  function get_hist_clipped (line 71) | def get_hist_clipped(signal, clip_bins=30, clip_fraction=0.95):
  function np_scale_to_range (line 99) | def np_scale_to_range(data, value_range=None):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/VisualBeat.py
  class VisualBeat (line 3) | class VisualBeat(Event):
    method VBOBJECT_TYPE (line 4) | def VBOBJECT_TYPE(self):
    method __init__ (line 7) | def __init__(self, start=None, type=None, weight=None, index=None, unr...
    method initializeBlank (line 10) | def initializeBlank(self):
    method __str__ (line 16) | def __str__(self):
    method toDictionary (line 22) | def toDictionary(self):
    method initFromDictionary (line 34) | def initFromDictionary(self, d):
    method clone (line 46) | def clone(self, start=None):
    method FromEvent (line 57) | def FromEvent(e):
    method time_window_func (line 64) | def time_window_func(max_separation, break_on_cuts=None):
    method tempo_binary_objective (line 75) | def tempo_binary_objective(target_period, binary_weight=None):
    method autocor_binary_objective (line 84) | def autocor_binary_objective(binary_weight=None, **kwargs):
    method angle_binary_objective (line 104) | def angle_binary_objective(binary_weight=None, absolute=None):
    method Double (line 121) | def Double(events, type=None):
    method weight_unary_objective (line 133) | def weight_unary_objective(unary_weight=None):
    method PullOptimalPaths_Basic (line 141) | def PullOptimalPaths_Basic(vis_beats, target_period, unary_weight=None...
    method PullOptimalPaths (line 153) | def PullOptimalPaths(vis_beats, unary_fn=None, binary_fn=None, window_...
    method PullOptimalPaths_Autocor (line 173) | def PullOptimalPaths_Autocor(vis_beats, unary_weight=None, binary_weig...
    method DynamicProgramOptimalPaths (line 189) | def DynamicProgramOptimalPaths(vis_beats, unary_objective_func, binary...

FILE: src/video2npz/visbeat3/build/lib/visbeat3/Warp.py
  class Warp (line 10) | class Warp(AObject):
    method VBOBJECT_TYPE (line 17) | def VBOBJECT_TYPE(self):
    method __init__ (line 20) | def __init__(self, path=None):
    method FromEvents (line 27) | def FromEvents(source_events, target_events):
    method FromEventLists (line 43) | def FromEventLists(source_eventlist, target_eventlist):
    method initializeBlank (line 51) | def initializeBlank(self):
    method getTargetStart (line 61) | def getTargetStart(self, lead=None):
    method getTargetEnd (line 68) | def getTargetEnd(self, lead=None):
    method getSourceStart (line 73) | def getSourceStart(self):
    method getSourceEnd (line 78) | def getSourceEnd(self):
    method getWarpedSourceStart (line 83) | def getWarpedSourceStart(self, lead=None):
    method getWarpedSourceEnd (line 90) | def getWarpedSourceEnd(self, tail=None):
    method setWarpFunc (line 99) | def setWarpFunc(self, warp_type, **kwargs):
    method warpSourceTime (line 156) | def warpSourceTime(self, t):
    method warpSourceTimes (line 160) | def warpSourceTimes(self, t):
    method warpTargetTime (line 167) | def warpTargetTime(self, t):
    method warpTargetTimes (line 171) | def warpTargetTimes(self, t):
    method plot (line 178) | def plot(self, xlim=None, sampling_rate=None, new_figure=None, render_...
    method plotImage (line 233) | def plotImage(self, xlim=None, sampling_rate=None):
    method repeatShorterEvents (line 253) | def repeatShorterEvents(self, endpoints=False):
    method FromEvents (line 260) | def FromEvents(source_events, target_events):
    method LinearInterp (line 269) | def LinearInterp(t, a_events, b_events):
    method plotWarpMethodTest (line 305) | def plotWarpMethodTest(warp_type, additional_points=None, **kwargs):
    method SquareInterp (line 341) | def SquareInterp(t, a_events, b_events):
    method GetEventWarpFunc (line 380) | def GetEventWarpFunc(from_events, to_events, f, lead_time=None, **kwar...
    method WFunc_Quadratic (line 410) | def WFunc_Quadratic():
    method WFunc_Weight (line 430) | def WFunc_Weight(use_to_weights=None, **kwargs):
    method WFunc_P (line 463) | def WFunc_P(p=None, **kwargs):
    method WFunc_Mouth (line 491) | def WFunc_Mouth(p_acceleration_time=0.1, **kwargs):
    method WFunc_targettime_sourcefraction (line 524) | def WFunc_targettime_sourcefraction(acceleration_target_time=0.1, acce...
    method WFunc_target_source_fractions (line 574) | def WFunc_target_source_fractions(acceleration_target_fraction=0.8, ac...
    method WFunc_AB (line 628) | def WFunc_AB(const_factor, quad_factor, **kwargs):
    method ABWarp (line 646) | def ABWarp():
    method CubicInterp (line 667) | def CubicInterp(t, a_events, b_events):
    method LinearInterpFunc (line 674) | def LinearInterpFunc(a_events, b_events):
    method CubicInterpFunc (line 688) | def CubicInterpFunc(a_events, b_events):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/__init__.py
  function SetAssetsDir (line 20) | def SetAssetsDir(assets_dir):
  function GetAssetsDir (line 31) | def GetAssetsDir():
  function GetVideoSourcesDir (line 34) | def GetVideoSourcesDir():
  function PullVideo (line 39) | def PullVideo(name=None, source_location=None, max_height=240, **kwargs):
  function ClipVideo (line 62) | def ClipVideo(video, time_range, max_height=240):
  function GetVideoSource (line 74) | def GetVideoSource(name):
  function LoadVideo (line 82) | def LoadVideo(name, max_height=240):
  function Dancefer (line 96) | def Dancefer(source_video, target,
  function get_temp_file_path (line 250) | def get_temp_file_path(final_file_path="TEMP", temp_dir_path = None):
  function AutoDancefer (line 265) | def AutoDancefer(source, target, output_path = None, synch_video_beat = ...
  function Dancify (line 276) | def Dancify(source_video, target,

FILE: src/video2npz/visbeat3/build/lib/visbeat3/_mediafiles.py
  function GetTestAudioPath (line 17) | def GetTestAudioPath(filename):
  function GetTestImagePath (line 38) | def GetTestImagePath(filename=None):
  function GetVBMarkPath (line 43) | def GetVBMarkPath():

FILE: src/video2npz/visbeat3/build/lib/visbeat3/fileui/__init__.py
  function GetFilePath (line 17) | def GetFilePath(initial_path=None):
  function GetDirectory (line 22) | def GetDirectory(initial_path=None):
  function GetSaveFilePath (line 27) | def GetSaveFilePath(initial_path=None, file_extension = None):
  function Show (line 33) | def Show(path):
  function Open (line 36) | def Open(path):
  function GetFilePath (line 40) | def GetFilePath(initial_path=None):
  function GetDirectory (line 42) | def GetDirectory(initial_path=None):
  function GetSaveFilePath (line 44) | def GetSaveFilePath(initial_path=None, file_extension = None):
  function Show (line 46) | def Show(path):
  function Open (line 48) | def Open(path):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/fileui/uipath.py
  function uiGetFilePath (line 6) | def uiGetFilePath(initial_path=None):
  function uiGetDirectory (line 18) | def uiGetDirectory(initial_path=None):
  function uiGetSaveFilePath (line 29) | def uiGetSaveFilePath(initial_path=None, file_extension=None):
  function showInFinder (line 49) | def showInFinder(path):
  function openOSX (line 52) | def openOSX(path):
  function put_string_in_quotes (line 55) | def put_string_in_quotes(s):
  function get_file_name_from_path (line 58) | def get_file_name_from_path(pth):
  function get_dir_from_path (line 61) | def get_dir_from_path(pth):

FILE: src/video2npz/visbeat3/build/lib/visbeat3/vbgui/BeatGUI.py
  function media_GUI_func (line 16) | def media_GUI_func(self):
  class BeatGUI (line 22) | class BeatGUI(AObject):
    method AOBJECT_TYPE (line 26) | def AOBJECT_TYPE(self):
    method __init__ (line 29) | def __init__(self, media=None, path=None, clear_temp=None):
    method initializeBlank (line 37) | def initializeBlank(self):
    method getJSONName (line 43) | def getJSONName(self):
    method media (line 51) | def media(self):
    method _getMedia (line 53) | def _getMedia(self):
    method media (line 56) | def media(self, value):
    method _setMedia (line 58) | def _setMedia(self, value):
    method media_type (line 64) | def media_type(self):
    method _getMediaType (line 66) | def _getMediaType(self):
    method widget (line 75) | def widget(self):
    method _getWidget (line 77) | def _getWidget(self):
    method widget (line 82) | def widget(self, value):
    method _setWidget (line 84) | def _setWidget(self, value):
    method frame_rate (line 90) | def frame_rate(self):
    method _getFrameRate (line 92) | def _getFrameRate(self):
    method frame_rate (line 100) | def frame_rate(self, value):
    method _setFrameRate (line 102) | def _setFrameRate(self, value):
    method frame_offset (line 109) | def frame_offset(self):
    method _getFrameOffset (line 111) | def _getFrameOffset(self):
    method frame_offset (line 114) | def frame_offset(self, value):
    method _setFrameOffset (line 116) | def _setFrameOffset(self, value):
    method run (line 120) | def run(self, local_saliency=None, frame_rate = None, eventlist = 'def...
    method guessFrameOffset (line 151) | def guessFrameOffset(self):
    method deactivateAllEvents (line 158) | def deactivateAllEvents(self):
    method activateAllEvents (line 168) | def activateAllEvents(self):
    method activatePattern (line 178) | def activatePattern(self, pattern=None, prefix=None, apply_to_active=N...
    method shiftEventsByNFrames (line 207) | def shiftEventsByNFrames(self, n_frames=None):
    method getActiveEventTimes (line 220) | def getActiveEventTimes(self):
    method getEventTimes (line 227) | def getEventTimes(self):
    method getEvents (line 234) | def getEvents(self, active_only=None):
    method getEventList (line 237) | def getEventList(self, active_only=None):
    method getActiveEvents (line 242) | def getActiveEvents(self):
    method getEventDicts (line 245) | def getEventDicts(self, active_only = None):
    method saveEvents (line 256) | def saveEvents(self, save_path = None):
    method saveEventsAs (line 269) | def saveEventsAs(self, save_path = None):
    method setEvents (line 284) | def setEvents(self, events):
    method setEventList (line 287) | def setEventList(self, event_list):
    method loadEvents (line 293) | def loadEvents(self, load_path = None):
    method getEventListWithSelectedSegments (line 302) | def getEventListWithSelectedSegments(self):

FILE: src/video2npz/visbeat3/visbeat3/AFileManager.py
  class AFileManager (line 5) | class AFileManager(AObject):
    method AOBJECT_TYPE (line 12) | def AOBJECT_TYPE():
    method getJSONPath (line 15) | def getJSONPath(self):
    method __init__ (line 18) | def __init__(self, path=None, clear_temp=None):
    method initializeBlank (line 26) | def initializeBlank(self):
    method getJSONName (line 30) | def getJSONName(self):
    method initWithPath (line 33) | def initWithPath(self, path=None, clear_temp=None):
    method setDir (line 87) | def setDir(self, name, path):
    method addDir (line 94) | def addDir(self, name):
    method getDir (line 98) | def getDir(self, name):
    method emptyDir (line 103) | def emptyDir(self, name):
    method deleteDir (line 109) | def deleteDir(self, name):
    method toDictionary (line 118) | def toDictionary(self):
    method copyPathToDir (line 124) | def copyPathToDir(self, path_to_copy, dest_dir):
    method copyDirToPath (line 133) | def copyDirToPath(self, dir_to_copy, dest_path):
    method copyRandomFractionOfFilesInSourceDir (line 141) | def copyRandomFractionOfFilesInSourceDir(source_dir, dest_dir, fractio...
    method initFromDictionary (line 177) | def initFromDictionary(self, d):
    method save (line 181) | def save(self):

FILE: src/video2npz/visbeat3/visbeat3/AFuncDict.py
  class AFuncDict (line 4) | class AFuncDict(AParamDict):
    method __init__ (line 12) | def __init__(self, owner=None, name=None, path=None):
    method getEntry (line 16) | def getEntry(self, name=None, params=None, force_recompute=False):
    method getValue (line 32) | def getValue(self, name=None, params=None, force_recompute=False):
    method getParams (line 39) | def getParams(self, name=None):
    method getFunction (line 46) | def getFunction(self, name=None):
    method setValue (line 49) | def setValue(self, name, value=None, params=None, modified=True):
    method setFunction (line 55) | def setFunction(self, name, function=None):
    method saveEntry (line 58) | def saveEntry(self, name, path, force=False):
    method setEntryModified (line 71) | def setEntryModified(self, name, is_modified=True):
    method isEntryModified (line 76) | def isEntryModified(self, name):
    method isModified (line 87) | def isModified(self):
    method setModified (line 90) | def setModified(self, is_modified):
    method save (line 93) | def save(self, path, force=False):
    method loadEntry (line 103) | def loadEntry(self, name, path):
    method load (line 111) | def load(self, path):
    method getKeyList (line 119) | def getKeyList(self):
    method getFunctionList (line 122) | def getFunctionList(self):

FILE: src/video2npz/visbeat3/visbeat3/AImports.py
  function AWARN (line 21) | def AWARN(message):
  function AINFORM (line 24) | def AINFORM(message):
  function AWARN (line 30) | def AWARN(message):
  function AINFORM (line 33) | def AINFORM(message):
  function local_time_string (line 37) | def local_time_string():
  function get_temp_file_path (line 40) | def get_temp_file_path(final_file_path="TEMP", temp_dir_path = None):
  function runningInNotebook (line 55) | def runningInNotebook():
  function getshellname (line 67) | def getshellname():
  function runningInSpyder (line 75) | def runningInSpyder():
  function pickleToPath (line 78) | def pickleToPath(d, path):
  function unpickleFromPath (line 86) | def unpickleFromPath(path):
  function make_sure_path_exists (line 92) | def make_sure_path_exists(path):
  function make_sure_dir_exists (line 99) | def make_sure_dir_exists(path):
  function safe_file_name (line 108) | def safe_file_name(input_string):
  function pathstring (line 111) | def pathstring(path):
  function is_interactive (line 114) | def is_interactive():
  function printOb (line 118) | def printOb(obj):
  function pathstring (line 122) | def pathstring(path):
  function get_prepended_name_file_path (line 125) | def get_prepended_name_file_path(original_file_path, string_to_prepend):
  function safe_file_name (line 131) | def safe_file_name(input_string):
  function change_extension (line 134) | def change_extension(input_path, new_ext):
  function printDictionary (line 138) | def printDictionary(obj):
  function spotgt_shift_bit_length (line 155) | def spotgt_shift_bit_length(x):
  function get_file_name_from_path (line 159) | def get_file_name_from_path(pth):
  function get_dir_from_path (line 162) | def get_dir_from_path(pth):
  function get_file_names_from_paths (line 165) | def get_file_names_from_paths(pths):
  function writeDictionaryToJSON (line 171) | def writeDictionaryToJSON(d, json_path=None):
  function vtt_to_srt (line 177) | def vtt_to_srt(fileContents):

FILE: src/video2npz/visbeat3/visbeat3/AObject.py
  class AObject (line 8) | class AObject(object):
    method __init__ (line 17) | def __init__(self, path=None, **kwargs):
    method initializeBlank (line 23) | def initializeBlank(self):
    method setPath (line 30) | def setPath(self, file_path=None, **kwargs):
    method getPath (line 45) | def getPath(self):
    method _showFile (line 51) | def _showFile(self):
    method _open (line 55) | def _open(self):
    method getRelativePath (line 59) | def getRelativePath(self, base_path=None):
    method getFileName (line 67) | def getFileName(self):
    method getFileExtension (line 73) | def getFileExtension(self):
    method getDirectoryPath (line 79) | def getDirectoryPath(self):
    method setInfo (line 82) | def setInfo(self, label, value):
    method getInfo (line 85) | def getInfo(self, label):
    method loadFromJSON (line 88) | def loadFromJSON(self, json_path=None):
    method writeToJSON (line 96) | def writeToJSON(self, json_path=None):
    method serializeInfo (line 104) | def serializeInfo(self):
    method save (line 107) | def save(self, features_to_save='all', overwrite=True, **kwargs):
    method load (line 113) | def load(self, features_to_load=None, **kwargs):
    method AOBJECT_TYPE (line 121) | def AOBJECT_TYPE():
    method toDictionary (line 124) | def toDictionary(self):
    method initFromDictionary (line 128) | def initFromDictionary(self, d):

FILE: src/video2npz/visbeat3/visbeat3/AParamDict.py
  class AParamDict (line 2) | class AParamDict(object):
    method __init__ (line 12) | def __init__(self, owner=None, name=None, path=None):
    method getEntry (line 18) | def getEntry(self, name=None, params=None, force_recompute=False):
    method setEntry (line 24) | def setEntry(self, name, d):
    method removeEntry (line 28) | def removeEntry(self, name, assert_if_absent=True, set_modified = True):
    method hasEntry (line 37) | def hasEntry(self, name=None):
    method getValue (line 40) | def getValue(self, name=None, params=None, force_recompute=False):
    method getParams (line 47) | def getParams(self, name=None):
    method setValue (line 54) | def setValue(self, name, value=None, params=None, modified=True):
    method saveEntry (line 59) | def saveEntry(self, name, path, force=False):
    method setEntryModified (line 70) | def setEntryModified(self, name, is_modified=True):
    method isEntryModified (line 75) | def isEntryModified(self, name):
    method isModified (line 82) | def isModified(self):
    method setModified (line 85) | def setModified(self, is_modified):
    method save (line 88) | def save(self, path, force=False):
    method loadEntry (line 97) | def loadEntry(self, name, path):
    method load (line 105) | def load(self, path):
    method getKeyList (line 113) | def getKeyList(self):

FILE: src/video2npz/visbeat3/visbeat3/Audio.py
  class Audio (line 11) | class Audio(TimeSignal1D):
    method __init__ (line 20) | def __init__(self, path=None, sampling_rate=None, x=None, name=None):
    method name (line 34) | def name(self):
    method getName (line 36) | def getName(self):
    method name (line 39) | def name(self, value):
    method _setName (line 41) | def _setName(self, value):
    method initializeBlank (line 45) | def initializeBlank(self):
    method _getFrameRate (line 50) | def _getFrameRate(self):
    method clone (line 53) | def clone(self):
    method loadFile (line 65) | def loadFile(self, file_path=None, sampling_rate=None, convert_to_mono...
    method getStereo (line 77) | def getStereo(self):
    method getStereoSamplingRate (line 80) | def getStereoSamplingRate(self):
    method getStringForHTMLStreamingBase64 (line 85) | def getStringForHTMLStreamingBase64(self):
    method getStereoEncodedBase64WAV (line 89) | def getStereoEncodedBase64WAV(self):
    method getMonoEncodedBase64WAV (line 99) | def getMonoEncodedBase64WAV(self):
    method getLocalRhythmicSaliency (line 106) | def getLocalRhythmicSaliency(self, **kwargs):
    method play (line 110) | def play(self, autoplay = None):
    method playBeats (line 145) | def playBeats(self, indices=None, beats=None):
    method AudioClipFromBeatRange (line 163) | def AudioClipFromBeatRange(self, beat_range, beats=None):
    method playSegment (line 176) | def playSegment(self, time_range, autoplay=None):
    method writeToFile (line 200) | def writeToFile(self, output_path=None, output_sampling_rate=None):
    method setValueRange (line 208) | def setValueRange(self, value_range=None):
    method resample (line 213) | def resample(self, sampling_rate):
    method GetResampled (line 218) | def GetResampled(self, sampling_rate):
    method AlignedTo (line 225) | def AlignedTo(self, B):
    method getOffsetFrom (line 267) | def getOffsetFrom(self, B):
    method getShiftAmountTo (line 270) | def getShiftAmountTo(self, B):
    method getBeatEventList (line 316) | def getBeatEventList(self, time_range = None):
    method getBeatEvents (line 335) | def getBeatEvents(self, start_time=None, end_time=None):
    method AudioClip (line 339) | def AudioClip(self, start, end):
    method getWithSoundAdded (line 345) | def getWithSoundAdded(self, add_times, sound=None, mute_original=None,...
    method showSpectrogram (line 372) | def showSpectrogram(self, time_range = None, **kwargs):
    method showMelSpectrogram (line 393) | def showMelSpectrogram(self, force_recompute=False, **kwargs):
    method Silence (line 410) | def Silence(n_seconds, sampling_rate, name=None):
    method _getDampedSin (line 419) | def _getDampedSin(freq, n_seconds=None, sampling_rate=16000, damping=0...
    method PingSound (line 444) | def PingSound(n_seconds=None, freqs=None, damping=None, sampling_rate ...
    method getBeats (line 469) | def getBeats(self, use_full_signal=True, tightness = None, force_recom...
    method getBeatVector (line 497) | def getBeatVector(self, vector_length=None, force_recompute=False):
    method getOnsets (line 513) | def getOnsets(self, use_full_signal=True, force_recompute=False, **kwa...
    method getOnsetSamplingRate (line 526) | def getOnsetSamplingRate(self):
    method pickOnsets (line 529) | def pickOnsets(self, pre_max_time=0.03,
    method getEvents (line 578) | def getEvents(self):
    method getEventList (line 581) | def getEventList(self):
    method getOnsetEvents (line 584) | def getOnsetEvents(self):
    method getBeatEvents (line 589) | def getBeatEvents(self, start_time=None, end_time=None, **kwargs):
    method getOnsetEnvelope (line 604) | def getOnsetEnvelope(self, use_full_signal=True, force_recompute=False...
    method getMelSpectrogram (line 618) | def getMelSpectrogram(self, n_mels = 128, force_recompute=False):
    method getSpectrogram (line 627) | def getSpectrogram(self, hop_length=None, force_recompute=False, **kwa...
    method getRMSE (line 648) | def getRMSE(self, force_recompute=False, hop_length=None, frame_length...
    method getBeatTimeBefore (line 664) | def getBeatTimeBefore(self, t):
    method getBeatBefore (line 667) | def getBeatBefore(self, t):
    method getBeatIndexBefore (line 672) | def getBeatIndexBefore(self, t):
    method getTempogram (line 680) | def getTempogram(self, window_length=None, force_recompute=None, frame...
    method plotTempogram (line 726) | def plotTempogram(self, window=None, time_range=None, **kwargs):
    method plotOnsets (line 746) | def plotOnsets(self, **kwargs):
    method plotBeats (line 754) | def plotBeats(self, **kwargs):
    method plotOnsetEnvelope (line 763) | def plotOnsetEnvelope(self, **kwargs):
    method plotSignal (line 772) | def plotSignal(self, time_range=None, ylim=None, **kwargs):
  function _make_wav (line 796) | def _make_wav(data, rate):

FILE: src/video2npz/visbeat3/visbeat3/AudioClip.py
  class AudioClip (line 3) | class AudioClip(Audio):
    method VBOBJECT_TYPE (line 10) | def VBOBJECT_TYPE(self):
    method __init__ (line 13) | def __init__(self, audio=None, start=None, end=None, path=None):
    method _pull_clip_potion (line 42) | def _pull_clip_potion(self):
    method resample (line 54) | def resample(self, sampling_rate):
    method initializeBlank (line 58) | def initializeBlank(self):
    method getSignal (line 65) | def getSignal(self, resample=False):

FILE: src/video2npz/visbeat3/visbeat3/Event.py
  class Event (line 3) | class Event(AObject):
    method AOBJECT_TYPE (line 14) | def AOBJECT_TYPE(self):
    method __str__ (line 17) | def __str__(self):
    method __init__ (line 20) | def __init__(self, start=None, type=None, weight=None, index=None, is_...
    method initializeBlank (line 31) | def initializeBlank(self):
    method getAttributeDict (line 42) | def getAttributeDict(self):
    method toDictionary (line 53) | def toDictionary(self):
    method initAttributesFromDictionary (line 59) | def initAttributesFromDictionary(self, d):
    method initFromDictionary (line 71) | def initFromDictionary(self, d):
    method clone (line 75) | def clone(self, start=None):
    method _getIsSelected (line 83) | def _getIsSelected(self):
    method _setIsSelected (line 85) | def _setIsSelected(self, is_selected):
    method _getPhase (line 88) | def _getPhase(self, phase_resolution=None):
    method _setPhase (line 96) | def _setPhase(self, phase, phase_resolution):
    method _getBoundaryType (line 102) | def _getBoundaryType(self):
    method _setBoundaryType (line 104) | def _setBoundaryType(self, boundary_type):
    method _FromGUIDict (line 108) | def _FromGUIDict(cls, gd, phase_resolution=None):
    method _FromGUIDicts (line 117) | def _FromGUIDicts(cls, gds, type=None):
    method _toGUIDict (line 126) | def _toGUIDict(self):
    method _ToGUIDicts (line 142) | def _ToGUIDicts(events, active=None):
    method getUnrolledStartTime (line 162) | def getUnrolledStartTime(self):
    method getStartTime (line 169) | def getStartTime(self):
    method getShifted (line 174) | def getShifted(self, new_start_time):
    method GetUnrolledList (line 181) | def GetUnrolledList(event_list, assert_on_folds=None):
    method NewFromIndices (line 197) | def NewFromIndices(event_list, inds):
    method RollToNOld (line 204) | def RollToNOld(events, n_out, momentum = 0.25):
    method UnfoldToN (line 228) | def UnfoldToN(events, n_out, momentum=0.25):
    method GetDirectedLinks (line 235) | def GetDirectedLinks(events):
    method RollToN (line 274) | def RollToN(events, n_out, start_index = 0, momentum=0.1):
    method Clone (line 304) | def Clone(event_list):
    method SetDirections (line 311) | def SetDirections(event_list, direction):
    method FromStartTimes (line 319) | def FromStartTimes(cls, starts, type=None):
    method FromStartsAndWeights (line 326) | def FromStartsAndWeights(cls, starts, weights, type=None):
    method ToStartTimes (line 334) | def ToStartTimes(events):
    method ToWeights (line 341) | def ToWeights(events):
    method RepeatToLength (line 349) | def RepeatToLength(events, n, endpoints=False):
    method Double (line 368) | def Double(events):
    method Half (line 377) | def Half(events, offset=0):
    method SubdivideIntervals (line 388) | def SubdivideIntervals(events, extra_samples_per_interval=1):
    method Third (line 400) | def Third(events, offset=0):
    method SubsampleEveryN (line 410) | def SubsampleEveryN(events, n, offset=0):
    method FromSignalPeaks (line 434) | def FromSignalPeaks(signal, sampling_rate, event_type=None, index_offs...
    method PlotEventMatches (line 486) | def PlotEventMatches(source_events, target_events, source_in=None, tar...
    method GetWithFirstEventAt (line 503) | def GetWithFirstEventAt(events, first_event_time):
    method GetWithStartTimesShifted (line 511) | def GetWithStartTimesShifted(events, new_start_time):
    method GetScaled (line 518) | def GetScaled(events, scale):
    method GetScaledAndStartingAt (line 525) | def GetScaledAndStartingAt(events, scale, starting_at):
    method ClosestToTargetMatch (line 531) | def ClosestToTargetMatch(source_events, target_events):
    method Sort (line 587) | def Sort(event_list, func=None):
    method GetSorted (line 593) | def GetSorted(event_list, func=None):
    method GetWithTwoWayMerged (line 599) | def GetWithTwoWayMerged(event_list, merge_window = 0.1):
    method ApplyIndices (line 615) | def ApplyIndices(event_list):
    method PlotSignalAndEvents (line 620) | def PlotSignalAndEvents(signal, sampling_rate, events, time_range = No...

FILE: src/video2npz/visbeat3/visbeat3/EventList.py
  class EventList (line 3) | class EventList(AObject):
    method AOBJECT_TYPE (line 9) | def AOBJECT_TYPE(self):
    method __init__ (line 12) | def __init__(self, events=None):
    method initializeBlank (line 18) | def initializeBlank(self):
    method list (line 22) | def list(self):
    method Clone (line 25) | def Clone(self):
    method toDictionary (line 28) | def toDictionary(self):
    method serializeEvents (line 33) | def serializeEvents(self):
    method getActiveEvents (line 39) | def getActiveEvents(self):
    method initFromDictionary (line 46) | def initFromDictionary(self, d):
    method unroll (line 54) | def unroll(self, assert_on_folds=None):
    method getUnrolled (line 58) | def getUnrolled(self, assert_on_folds=None):
    method getFromIndices (line 61) | def getFromIndices(self, inds):
    method getRolledToN (line 64) | def getRolledToN(self, n_out, momentum = 0.1):
    method toStartTimes (line 68) | def toStartTimes(self):
    method _toGUIDicts (line 71) | def _toGUIDicts(self):
    method _FromGUIDicts (line 75) | def _FromGUIDicts(gds, type=None):
    method FromJSON (line 81) | def FromJSON(json_path=None):
    method FromStartTimes (line 89) | def FromStartTimes(starts, type=None, event_class=None):
    method toWeights (line 98) | def toWeights(self):
    method getDoubled (line 101) | def getDoubled(self):
    method getHalved (line 104) | def getHalved(self, offset=0):
    method getThirded (line 107) | def getThirded(self, offset=0):
    method FromSignalPeaks (line 111) | def FromSignalPeaks(**kwargs):
    method PlotEventMatches (line 115) | def PlotEventMatches(source_elist, target_elist, source_in=None, targe...
    method getWithFirstEventAt (line 118) | def getWithFirstEventAt(self, first_event_time):
    method getWithStartTimesShifted (line 121) | def getWithStartTimesShifted(self, new_start_time):

FILE: src/video2npz/visbeat3/visbeat3/Image.py
  function imshow (line 14) | def imshow(imdata, new_figure = True):
  class Image (line 26) | class Image(AObject):
    method AOBJECT_TYPE (line 33) | def AOBJECT_TYPE(self):
    method __init__ (line 36) | def __init__(self, data=None, path = None):
    method initializeBlank (line 42) | def initializeBlank(self):
    method setBlank (line 46) | def setBlank(self, shape=None):
    method loadImageData (line 52) | def loadImageData(self, path = None, force_reload=True):
    method shape (line 61) | def shape(self):
    method _getShape (line 64) | def _getShape(self):
    method dtype (line 68) | def dtype(self):
    method width (line 72) | def width(self):
    method _getWidth (line 75) | def _getWidth(self):
    method height (line 79) | def height(self):
    method _getHeight (line 82) | def _getHeight(self):
    method _is_float (line 86) | def _is_float(self):
    method _is_int (line 90) | def _is_int(self):
    method _pixels_float (line 94) | def _pixels_float(self):
    method _pixels_uint (line 101) | def _pixels_uint(self):
    method n_channels (line 108) | def n_channels(self):
    method _getNChannels (line 111) | def _getNChannels(self):
    method FromGrayScale (line 118) | def FromGrayScale(gray_data, color_map = None, format=None, **kwargs):
    method printTempDir (line 135) | def printTempDir():
    method scaleToValueRange (line 138) | def scaleToValueRange(self, value_range=None):
    method nChannels (line 158) | def nChannels(self):
    method getClone (line 164) | def getClone(self):
    method getGridPixel (line 168) | def getGridPixel(self,x,y,repeatEdge=0):
    method getPixel (line 202) | def getPixel(self, x, y, repeatEdge=0):
    method getShape (line 229) | def getShape(self):
    method getScaled (line 232) | def getScaled(self, shape=None, shape_xy=None):
    method getRotated (line 243) | def getRotated(self, theta):
    method _splatAtPixCoord (line 250) | def _splatAtPixCoord(self, im, location=[0,0], **kwargs):
    method reflectY (line 268) | def reflectY(self):
    method reflectX (line 271) | def reflectX(self):
    method PIL (line 274) | def PIL(self):
    method getRGBData (line 277) | def getRGBData(self):
    method normalize (line 280) | def normalize(self, scale=1.0):
    method show (line 284) | def show(self, new_figure = True):
    method writeToFile (line 296) | def writeToFile(self, out_path):
    method getEncodedBase64 (line 299) | def getEncodedBase64(self):
    method getDataAsString (line 302) | def getDataAsString(self):
    method FromBase64 (line 306) | def FromBase64(encoded_data, shape):
    method FromDataString (line 316) | def FromDataString(data_string, shape, dtype=None):
    method _get_font_size (line 324) | def _get_font_size(self, text, font_path, max_width=None, max_height=N...
    method writeOutlinedText (line 337) | def writeOutlinedText(self, xy, text,
    method writeText (line 356) | def writeText(self, xy, text, font_filename='RobotoCondensed-Regular.t...
    method _get_text_size (line 397) | def _get_text_size(self, font_path, font_size, text):
    method _VBMark (line 402) | def _VBMark():
    method _vbmark (line 407) | def _vbmark(self):
    method _vbmarker (line 410) | def _vbmarker(self):
    method writeTextBox (line 422) | def writeTextBox(self, xy, text, box_width, font_filename='RobotoConde...

FILE: src/video2npz/visbeat3/visbeat3/Image_CV.py
  function flow2rgb (line 25) | def flow2rgb(flow):
  function showFlowHSV (line 42) | def showFlowHSV(flow, new_figure = True):
  function cornerHarris (line 52) | def cornerHarris(im, blockSize=None, ksize=None, k=None):
  function cvDenseFlowFarneback (line 61) | def cvDenseFlowFarneback(from_image, to_image, pyr_scale=None, levels=No...
  function RGB2Gray (line 118) | def RGB2Gray(self):
  function Gray2RGB (line 124) | def Gray2RGB(self):
  function cvGoodFeaturesToTrack (line 128) | def cvGoodFeaturesToTrack(self, maxCorners=None, qualityLevel=None, minD...
  function withFlow (line 155) | def withFlow(self, flow, step=16):

FILE: src/video2npz/visbeat3/visbeat3/SourceLocationParser.py
  class SourceURL (line 15) | class SourceURL(object):
    method SourceLocationType (line 25) | def SourceLocationType(cls):
    method __init__ (line 28) | def __init__(self, source_location):
    method code (line 34) | def code(self):
    method _getCode (line 41) | def _getCode(self):
    method code (line 45) | def code(self, value):
    method _setCode (line 47) | def _setCode(self, value):
    method url (line 53) | def url(self):
    method get_url (line 58) | def get_url(self):
    method protocol (line 62) | def protocol(self):
    method thumbnail (line 69) | def thumbnail(self):
    method is_valid (line 76) | def is_valid(cls, url):
  class WebSourceException (line 79) | class WebSourceException(Exception):
  class VideoDoesntExistException (line 84) | class VideoDoesntExistException(WebSourceException):
  class UnknownBackendException (line 89) | class UnknownBackendException(WebSourceException):
  class UnknownIdException (line 94) | class UnknownIdException(VideoDoesntExistException):
  class YoutubeURL (line 101) | class YoutubeURL(SourceURL):
    method SourceLocationType (line 107) | def SourceLocationType(cls):
    method get_url (line 154) | def get_url(self):
    method get_thumbnail_url (line 162) | def get_thumbnail_url(self):
    method _getCode (line 172) | def _getCode(self):
    method get_thumbnail_url (line 190) | def get_thumbnail_url(self):
  class FilePathURL (line 206) | class FilePathURL(SourceURL):
    method SourceLocationType (line 208) | def SourceLocationType(cls):
    method __init__ (line 211) | def __init__(self, source_location):
    method is_valid (line 216) | def is_valid(cls, source_location):
    method _getCode (line 219) | def _getCode(self):
  function ParseSourseLocation (line 230) | def ParseSourseLocation(url):

FILE: src/video2npz/visbeat3/visbeat3/TimeSignal.py
  class TimeSignal (line 7) | class TimeSignal(VBObject):
    method VBBJECT_TYPE (line 14) | def VBBJECT_TYPE(self):
    method __init__ (line 17) | def __init__(self, path=None, sampling_rate = None):
    method initializeBlank (line 25) | def initializeBlank(self):
    method frame_rate (line 32) | def frame_rate(self):
    method _getFrameRate (line 34) | def _getFrameRate(self):
    method getSampleAtTime (line 39) | def getSampleAtTime(self, f):
    method getSampleAtIndex (line 45) | def getSampleAtIndex(self, i):
    method getDuration (line 48) | def getDuration(self):
    method getSampleDuration (line 51) | def getSampleDuration(self):
    method getTimeForIndex (line 54) | def getTimeForIndex(self, i):

FILE: src/video2npz/visbeat3/visbeat3/TimeSignal1D.py
  class TimeSignal1D (line 4) | class TimeSignal1D(TimeSignal):
    method VBOJECT_TYPE (line 11) | def VBOJECT_TYPE(self):
    method __init__ (line 14) | def __init__(self, path=None, sampling_rate = None, x=None):
    method initializeBlank (line 20) | def initializeBlank(self):
    method getSignal (line 24) | def getSignal(self, resampled=False):
    method getSignalSegment (line 27) | def getSignalSegment(self, time_range):
    method getFullSignal (line 33) | def getFullSignal(self):
    method getSampleAtTime (line 36) | def getSampleAtTime(self, f):
    method getSampleAtIndex (line 42) | def getSampleAtIndex(self, i):
    method getDuration (line 45) | def getDuration(self):
    method setValueRange (line 48) | def setValueRange(self, value_range=None):
    method setMaxAbsValue (line 57) | def setMaxAbsValue(self, max_abs_val=1.0):

FILE: src/video2npz/visbeat3/visbeat3/VBMIDI.py
  class VBMIDITrack (line 9) | class VBMIDITrack(object):
    method __init__ (line 10) | def __init__(self, track, ticks_per_beat):
    method getBPM (line 20) | def getBPM(self):
    method getNoteOnTimes (line 23) | def getNoteOnTimes(self, include_negative=None):
    method _get_note_on_times (line 29) | def _get_note_on_times(self, include_negative = None):
    method get_note_durations (line 47) | def get_note_durations(self, track_num):
    method get_mouth_events (line 69) | def get_mouth_events(self):
    method getNoteOnTimesAsAudio (line 104) | def getNoteOnTimesAsAudio(self, sampling_rate = None, note_sound=None,...
  class VBMIDI (line 116) | class VBMIDI(TimeSignal1D):
    method __init__ (line 117) | def __init__(self, path=None):
    method getNoteOnTimes (line 124) | def getNoteOnTimes(self, include_negative=None):
    method getMouthEvents (line 127) | def getMouthEvents(self):
    method getNoteOnTimesAsAudio (line 130) | def getNoteOnTimesAsAudio(self, sampling_rate=None, note_sound=None):

FILE: src/video2npz/visbeat3/visbeat3/VBObject.py
  class VBObject (line 7) | class VBObject(AObject):
    method __init__ (line 20) | def __init__(self, path=None):
    method initializeBlank (line 23) | def initializeBlank(self):
    method saveFeature (line 29) | def saveFeature(self, name, path):
    method saveFeatures (line 33) | def saveFeatures(self, path):
    method loadFeature (line 36) | def loadFeature(self, name, path):
    method loadFeatures (line 40) | def loadFeatures(self, path):
    method getFeature (line 43) | def getFeature(self,name, force_recompute=False, **kwargs):
    method getFeatureEntry (line 49) | def getFeatureEntry(self, name, params=None, force_recompute=False):
    method getFeatureParams (line 52) | def getFeatureParams(self, name):
    method setFeature (line 55) | def setFeature(self, name, value, params=None):
    method removeFeature (line 60) | def removeFeature(self, name, assert_if_absent=True, set_modified=True):
    method hasFeature (line 65) | def hasFeature(self, name):
    method getFeatureFunction (line 69) | def getFeatureFunction(self, feature_name):
    method getFeaturesList (line 72) | def getFeaturesList(self):
    method getFeatureFunctionsList (line 75) | def getFeatureFunctionsList(self):
    method clearFeatureFiles (line 78) | def clearFeatureFiles(self, features_to_clear=None, **kwargs):
    method AOBJECT_TYPE (line 87) | def AOBJECT_TYPE(self):
    method VBOBJECT_TYPE (line 90) | def VBOBJECT_TYPE(self):

FILE: src/video2npz/visbeat3/visbeat3/Video.py
  function MPYWriteVideoFile (line 16) | def MPYWriteVideoFile(mpyclip, filename, **kwargs):
  class Video (line 22) | class Video(TimeSignal):
    method AOBJECT_TYPE (line 30) | def AOBJECT_TYPE(self):
    method __init__ (line 33) | def __init__(self, path=None, name=None, num_frames_total=None):
    method initializeBlank (line 40) | def initializeBlank(self):
    method _getFrameRate (line 56) | def _getFrameRate(self):
    method gui (line 62) | def gui(self):
    method _getGui (line 65) | def _getGui(self):
    method gui (line 69) | def gui(self, value):
    method _setGui (line 72) | def _setGui(self, value):
    method getVersionInfo (line 77) | def getVersionInfo(self):
    method getName (line 89) | def getName(self):
    method getTempDir (line 95) | def getTempDir(self):
    method getStringForHTMLStreamingBase64 (line 101) | def getStringForHTMLStreamingBase64(self):
    method n_frames (line 107) | def n_frames(self):
    method getDuration (line 112) | def getDuration(self):
    method getStartTime (line 115) | def getStartTime(self):
    method getEndTime (line 118) | def getEndTime(self):
    method getMPYClip (line 121) | def getMPYClip(self, get_audio=True):
    method getAudio (line 124) | def getAudio(self):
    method loadFile (line 127) | def loadFile(self, file_path=None, num_frames_total=None):
    method openVideoWriter (line 148) | def openVideoWriter(self, output_file_path, fps=None):
    method closeVideoWriter (line 158) | def closeVideoWriter(self):
    method getFrameShape (line 162) | def getFrameShape(self):
    method calcNumFramesTotal (line 170) | def calcNumFramesTotal(self):
    method readFrameBasic (line 188) | def readFrameBasic(self, i):
    method getFrame (line 197) | def getFrame(self, f):
    method getFrameFromTime (line 200) | def getFrameFromTime(self, t):
    method getFrameLinearInterp (line 204) | def getFrameLinearInterp(self, f):
    method writeFrame (line 213) | def writeFrame(self, img):
    method play (line 219) | def play(self):
    method show (line 232) | def show(self):
    method write (line 235) | def write(self, output_path, output_sampling_rate=None):
    method VideoClip (line 267) | def VideoClip(self, start=None, end=None, name=None):
    method getImageFromFrame (line 278) | def getImageFromFrame(self, i):
    method getImageFromTime (line 284) | def getImageFromTime(self, t):
    method writeResolutionCopyFFMPEG (line 294) | def writeResolutionCopyFFMPEG(self, path, max_height=None):
    method writeFFMPEG (line 308) | def writeFFMPEG(self, output_path):
    method writeResolutionCopy (line 315) | def writeResolutionCopy(self, path, max_height=None, reshape=None, inp...
    method writeWarped (line 376) | def writeWarped(self, output_path, warp, output_sampling_rate=None, ou...
    method getVersionLabel (line 453) | def getVersionLabel(self):
    method getWarpsDir (line 456) | def getWarpsDir(self):
    method getWithBeginningCroppedToAudio (line 462) | def getWithBeginningCroppedToAudio(self, target):
    method getWarped (line 478) | def getWarped(self, target,
    method getWithSoundsOnEvents (line 543) | def getWithSoundsOnEvents(self, events, output_path=None, name_tag = N...
    method CreateFromVideoAndAudio (line 592) | def CreateFromVideoAndAudio(video_path=None, audio_path=None, video_ob...
    method CreateByStackingVideos (line 668) | def CreateByStackingVideos(video_objects=None, video_paths=None, outpu...
    method CreateFromVideoAndAudioPaths (line 716) | def CreateFromVideoAndAudioPaths(video_path, audio_path, output_path, ...
    method CreateFromVideoAndAudioObjects (line 720) | def CreateFromVideoAndAudioObjects(video, audio, output_path, clip_to_...
    method _getDefaultPeakPickingTimeParams (line 724) | def _getDefaultPeakPickingTimeParams(self, **kwargs):
    method getFrameIndexes (line 740) | def getFrameIndexes(self, force_recompute=False):
    method getFeaturesList (line 752) | def getFeaturesList(self):
    method getVideoFeaturesList (line 755) | def getVideoFeaturesList(self):
    method getFeatureFunctionsList (line 758) | def getFeatureFunctionsList(self):
    method getFeatureSourceType (line 761) | def getFeatureSourceType(self, name):
    method getFeature (line 771) | def getFeature(self, name, force_recompute=False, **kwargs):
  function getEvents (line 835) | def getEvents(self, **kwargs):
  function getEventList (line 840) | def getEventList(self, **kwargs):
  function runBeatGUIOnAudio (line 843) | def runBeatGUIOnAudio(self):
  function runGUI (line 848) | def runGUI(self, local_saliency=None, frame_rate = None, eventlist = 'de...

FILE: src/video2npz/visbeat3/visbeat3/VideoClip.py
  class VideoClip (line 5) | class VideoClip(Video):
    method AOBJECT_TYPE (line 12) | def AOBJECT_TYPE(self):
    method __init__ (line 15) | def __init__(self, video=None, start=None, end=None, clip_to_frame=Tru...
    method initializeBlank (line 41) | def initializeBlank(self):
    method getFrameLinearInterp (line 50) | def getFrameLinearInterp(self, f):
    method getFrame (line 53) | def getFrame(self, f):
    method getDuration (line 56) | def getDuration(self, round_to_frames=False):
    method n_frames (line 62) | def n_frames(self):
    method getStartTime (line 73) | def getStartTime(self):
    method getEndTime (line 76) | def getEndTime(self):
    method getMPYClip (line 79) | def getMPYClip(self, get_audio=True):
    method play (line 82) | def play(self):

FILE: src/video2npz/visbeat3/visbeat3/VideoSource.py
  function safe_file_name (line 12) | def safe_file_name(input_string):
  class VideoSource (line 15) | class VideoSource(AFileManager):
    method getJSONName (line 25) | def getJSONName(self):
    method AOBJECT_TYPE (line 28) | def AOBJECT_TYPE(self):
    method __init__ (line 31) | def __init__(self, path, name=None, source_location=None, VideoClass =...
    method NewVideoSource (line 52) | def NewVideoSource(destination, name, source_location=None, VideoClass...
    method initializeBlank (line 58) | def initializeBlank(self):
    method toDictionary (line 70) | def toDictionary(self):
    method initFromDictionary (line 86) | def initFromDictionary(self, d):
    method initWithPath (line 99) | def initWithPath(self, path=None, clear_temp=None):
    method setFeaturesDir (line 107) | def setFeaturesDir(self, features_dir=None):
    method getName (line 115) | def getName(self):
    method _versionLabelString (line 132) | def _versionLabelString(version_label=None):
    method _versionGroupString (line 139) | def _versionGroupString(version_group=None):
    method _getVersionLabelDirName (line 145) | def _getVersionLabelDirName(version_label=None):
    method getVersionPath (line 152) | def getVersionPath(self, version_label=None, version_group=None):
    method getDirForVersion (line 160) | def getDirForVersion(self, version_label=None, version_group=None):
    method getVersionInfo (line 165) | def getVersionInfo(self, version_label, version_group=None, info_label...
    method getVersionDictionary (line 179) | def getVersionDictionary(self, version_label=None, version_group=None):
    method setVersionDictionary (line 188) | def setVersionDictionary(self, version_label=None, version_group=None,...
    method setVersionInfo (line 198) | def setVersionInfo(self, version_label=None, version_group=None, video...
    method hardSave (line 211) | def hardSave(self):
    method save (line 216) | def save(self):
    method getWarpsDir (line 323) | def getWarpsDir(self, version_label=None):
    method getVersion (line 332) | def getVersion(self, max_height=None, get_if_missing=True, load_featur...
    method saveFeaturesForVideo (line 369) | def saveFeaturesForVideo(self, video, features_to_save=None, output_di...
    method saveFeatureForVideo (line 377) | def saveFeatureForVideo(self, video, feature_name, output_dir=None, ov...
    method loadFeaturesForVideo (line 394) | def loadFeaturesForVideo(self, video, features_to_load=None):
    method loadFeatureForVideo (line 402) | def loadFeatureForVideo(self, video, feature_name):
    method getFeaturePath (line 414) | def getFeaturePath(self, feature_name=None, source_type=None, version_...
    method getFeatureDir (line 428) | def getFeatureDir(self, feature_name=None, source_type=None):
    method saveFeaturesForVersion (line 435) | def saveFeaturesForVersion(self, version_label=None, output_dir=None):
    method RegisteredVideo (line 441) | def RegisteredVideo(self, path=None, version_label=None, version_group...
    method RegisterVideo (line 447) | def RegisterVideo(self, video, version_label = None, version_group = N...
    method addVersion (line 472) | def addVersion(self, path, version_label=None, version_group=None):
    method addVersionToVideo (line 479) | def addVersionToVideo(self, video, new_video, version_label=None, vers...
    method setSource (line 488) | def setSource(self, source_location=None, assert_valid=True, **kwargs):
    method setSourceYoutube (line 516) | def setSourceYoutube(self, url=None, max_height=None, pull_fullres=Tru...
    method setSourceFile (line 523) | def setSourceFile(self, path=None, copy=True, **kwargs):
    method pullVersion (line 556) | def pullVersion(self, max_height=None, **kwargs):
    method pullFileVideo (line 567) | def pullFileVideo(self, max_height=None, force_recompute=None):
    method pullYoutubeVideo (line 582) | def pullYoutubeVideo(self, max_height=None, write_subtitles=False, sav...

FILE: src/video2npz/visbeat3/visbeat3/Video_CV.py
  function localRhythmicSaliencyFunction (line 33) | def localRhythmicSaliencyFunction(self, **kwargs):
  function visualBeatFunction (line 39) | def visualBeatFunction(self, **kwargs):
  function getLocalRhythmicSaliency (line 56) | def getLocalRhythmicSaliency(self, force_recompute=False, **kwargs):
  function getVisualBeats (line 66) | def getVisualBeats(self, force_recompute=False, **kwargs):
  function cvGetGrayFrame (line 83) | def cvGetGrayFrame(self, f):
  function getImageFromFrameGray (line 87) | def getImageFromFrameGray(self, f):
  function flow2row (line 92) | def flow2row(ang, amp, bins, subdivs, n_shifts, density):
  function getFlowFrame (line 128) | def getFlowFrame(self, frame_index):
  function getFlowFramePolar (line 133) | def getFlowFramePolar(self, frame_index):
  function computeDirectogramPowers (line 146) | def computeDirectogramPowers(self, bins=None, dead_zone= 0.05, density=N...
  function getDirectogramPowers (line 224) | def getDirectogramPowers(self, force_recompute=False, **kwargs):
  function getDirectogram (line 231) | def getDirectogram(self, **kwargs):
  function getVisualTempo (line 240) | def getVisualTempo(self, force_recompute=None, **kwargs):
  function getVisualTempogram (line 250) | def getVisualTempogram(self, window_length=None, force_recompute=None, n...
  function getVisibleImpactEnvelope (line 311) | def getVisibleImpactEnvelope(self, force_recompute=False, **kwargs):
  function getForwardVisibleImpactEnvelope (line 319) | def getForwardVisibleImpactEnvelope(self, force_recompute=False, **kwargs):
  function getBackwardVisibleImpactEnvelope (line 334) | def getBackwardVisibleImpactEnvelope(self, force_recompute=False, **kwar...
  function getBothWayVisibleImpactEnvelope (line 342) | def getBothWayVisibleImpactEnvelope(self, force_recompute=False, **kwargs):
  function getVisibleImpactEnvelopePowers (line 350) | def getVisibleImpactEnvelopePowers(self, force_recompute=False, **kwargs):
  function getCutTimes (line 362) | def getCutTimes(self):
  function getCutEvents (line 365) | def getCutEvents(self, force_recompute=False, **kwargs):
  function visualBeatsFromEvents (line 402) | def visualBeatsFromEvents(self, events):
  function getVisualBeatTimes (line 431) | def getVisualBeatTimes(self, **kwargs):
  function getDirectionalFlux (line 434) | def getDirectionalFlux(self,
  function computeImpactEnvelope (line 472) | def computeImpactEnvelope(self,
  function computeImpactEnvelopeOld (line 558) | def computeImpactEnvelopeOld(self, f_sigma=None, median_kernel=None, hig...
  function getVisibleImpacts (line 641) | def getVisibleImpacts(self, force_recompute=False, include_cut_events = ...
  function getForwardVisibleImpacts (line 664) | def getForwardVisibleImpacts(self, force_recompute=False, include_cut_ev...
  function getBackwardVisibleImpacts (line 682) | def getBackwardVisibleImpacts(self, force_recompute=False, include_cut_e...
  function findAccidentalDanceSequences (line 702) | def findAccidentalDanceSequences(self, target_n_beats = 7, n_samples=25,...
  function getVisualBeatSequences (line 720) | def getVisualBeatSequences(self,
  function printVisualBeatSequences (line 802) | def printVisualBeatSequences(self,
  function plotEvents (line 863) | def plotEvents(self, events, time_range = 'default', **kwargs):
  function plotCutEvents (line 875) | def plotCutEvents(self, **kwargs):
  function plotVisibleImpacts (line 880) | def plotVisibleImpacts(self, **kwargs):
  function plotImpactEnvelope (line 888) | def plotImpactEnvelope(self, **kwargs):
  function plotVisualBeats (line 897) | def plotVisualBeats(self, **kwargs):
  function loadFlowFeatures (line 906) | def loadFlowFeatures(self):

FILE: src/video2npz/visbeat3/visbeat3/VisBeatExampleVideo.py
  class VisBeatExampleVideo (line 4) | class VisBeatExampleVideo(object):
    method __init__ (line 5) | def __init__(self, name, url, start_beat=None, end_beat = None, displa...
    method code (line 20) | def code(self):
    method _getCode (line 22) | def _getCode(self):
    method code (line 25) | def code(self, value):
    method _setCode (line 27) | def _setCode(self, value):
    method display_name (line 35) | def display_name(self):
    method _getDisplayName (line 37) | def _getDisplayName(self):
    method _ytWatchURL (line 45) | def _ytWatchURL(self):
    method _ytEmbedURL (line 48) | def _ytEmbedURL(self, autoplay=None):
    method _ytThumbURL (line 54) | def _ytThumbURL(self):
    method _fancyBoxCode (line 57) | def _fancyBoxCode(self, with_label = None):
  class HTMLCode (line 76) | class HTMLCode(object):
    method __init__ (line 77) | def __init__(self, start_string=None):
    method string (line 86) | def string(self):
    method _getString (line 88) | def _getString(self):
    method code (line 93) | def code(self):
    method _getCode (line 95) | def _getCode(self):
    method code (line 98) | def code(self, value):
    method _setCode (line 100) | def _setCode(self, value):
    method soup (line 107) | def soup(self):
    method _getSoup (line 109) | def _getSoup(self):
    method _makeSoup (line 114) | def _makeSoup(self):
    method add (line 123) | def add(self, s):
    method addLine (line 126) | def addLine(self, s):
    method startTable (line 129) | def startTable(self, id=None, class_ = None, **kwargs):
    method endTable (line 141) | def endTable(self):
    method startRow (line 145) | def startRow(self):
    method endRow (line 148) | def endRow(self):
    method addColumnLabel (line 151) | def addColumnLabel(self, label):
    method addRowLabel (line 156) | def addRowLabel(self, label):
    method addRowCell (line 161) | def addRowCell(self, content):

FILE: src/video2npz/visbeat3/visbeat3/VisBeatImports.py
  function local_time_string (line 29) | def local_time_string():
  function VBWARN (line 33) | def VBWARN(message):
  function vb_get_ipython (line 65) | def vb_get_ipython():
  function clipping_params (line 68) | def clipping_params(clip_bins=30, clip_fraction=0.95):
  function get_hist_clipped (line 71) | def get_hist_clipped(signal, clip_bins=30, clip_fraction=0.95):
  function np_scale_to_range (line 99) | def np_scale_to_range(data, value_range=None):

FILE: src/video2npz/visbeat3/visbeat3/VisualBeat.py
  class VisualBeat (line 3) | class VisualBeat(Event):
    method VBOBJECT_TYPE (line 4) | def VBOBJECT_TYPE(self):
    method __init__ (line 7) | def __init__(self, start=None, type=None, weight=None, index=None, unr...
    method initializeBlank (line 10) | def initializeBlank(self):
    method __str__ (line 16) | def __str__(self):
    method toDictionary (line 22) | def toDictionary(self):
    method initFromDictionary (line 34) | def initFromDictionary(self, d):
    method clone (line 46) | def clone(self, start=None):
    method FromEvent (line 57) | def FromEvent(e):
    method time_window_func (line 64) | def time_window_func(max_separation, break_on_cuts=None):
    method tempo_binary_objective (line 75) | def tempo_binary_objective(target_period, binary_weight=None):
    method autocor_binary_objective (line 84) | def autocor_binary_objective(binary_weight=None, **kwargs):
    method angle_binary_objective (line 104) | def angle_binary_objective(binary_weight=None, absolute=None):
    method Double (line 121) | def Double(events, type=None):
    method weight_unary_objective (line 133) | def weight_unary_objective(unary_weight=None):
    method PullOptimalPaths_Basic (line 141) | def PullOptimalPaths_Basic(vis_beats, target_period, unary_weight=None...
    method PullOptimalPaths (line 153) | def PullOptimalPaths(vis_beats, unary_fn=None, binary_fn=None, window_...
    method PullOptimalPaths_Autocor (line 173) | def PullOptimalPaths_Autocor(vis_beats, unary_weight=None, binary_weig...
    method DynamicProgramOptimalPaths (line 189) | def DynamicProgramOptimalPaths(vis_beats, unary_objective_func, binary...

FILE: src/video2npz/visbeat3/visbeat3/Warp.py
  class Warp (line 10) | class Warp(AObject):
    method VBOBJECT_TYPE (line 17) | def VBOBJECT_TYPE(self):
    method __init__ (line 20) | def __init__(self, path=None):
    method FromEvents (line 27) | def FromEvents(source_events, target_events):
    method FromEventLists (line 43) | def FromEventLists(source_eventlist, target_eventlist):
    method initializeBlank (line 51) | def initializeBlank(self):
    method getTargetStart (line 61) | def getTargetStart(self, lead=None):
    method getTargetEnd (line 68) | def getTargetEnd(self, lead=None):
    method getSourceStart (line 73) | def getSourceStart(self):
    method getSourceEnd (line 78) | def getSourceEnd(self):
    method getWarpedSourceStart (line 83) | def getWarpedSourceStart(self, lead=None):
    method getWarpedSourceEnd (line 90) | def getWarpedSourceEnd(self, tail=None):
    method setWarpFunc (line 99) | def setWarpFunc(self, warp_type, **kwargs):
    method warpSourceTime (line 156) | def warpSourceTime(self, t):
    method warpSourceTimes (line 160) | def warpSourceTimes(self, t):
    method warpTargetTime (line 167) | def warpTargetTime(self, t):
    method warpTargetTimes (line 171) | def warpTargetTimes(self, t):
    method plot (line 178) | def plot(self, xlim=None, sampling_rate=None, new_figure=None, render_...
    method plotImage (line 233) | def plotImage(self, xlim=None, sampling_rate=None):
    method repeatShorterEvents (line 253) | def repeatShorterEvents(self, endpoints=False):
    method FromEvents (line 260) | def FromEvents(source_events, target_events):
    method LinearInterp (line 269) | def LinearInterp(t, a_events, b_events):
    method plotWarpMethodTest (line 305) | def plotWarpMethodTest(warp_type, additional_points=None, **kwargs):
    method SquareInterp (line 341) | def SquareInterp(t, a_events, b_events):
    method GetEventWarpFunc (line 380) | def GetEventWarpFunc(from_events, to_events, f, lead_time=None, **kwar...
    method WFunc_Quadratic (line 410) | def WFunc_Quadratic():
    method WFunc_Weight (line 430) | def WFunc_Weight(use_to_weights=None, **kwargs):
    method WFunc_P (line 463) | def WFunc_P(p=None, **kwargs):
    method WFunc_Mouth (line 491) | def WFunc_Mouth(p_acceleration_time=0.1, **kwargs):
    method WFunc_targettime_sourcefraction (line 524) | def WFunc_targettime_sourcefraction(acceleration_target_time=0.1, acce...
    method WFunc_target_source_fractions (line 574) | def WFunc_target_source_fractions(acceleration_target_fraction=0.8, ac...
    method WFunc_AB (line 628) | def WFunc_AB(const_factor, quad_factor, **kwargs):
    method ABWarp (line 646) | def ABWarp():
    method CubicInterp (line 667) | def CubicInterp(t, a_events, b_events):
    method LinearInterpFunc (line 674) | def LinearInterpFunc(a_events, b_events):
    method CubicInterpFunc (line 688) | def CubicInterpFunc(a_events, b_events):

FILE: src/video2npz/visbeat3/visbeat3/__init__.py
  function SetAssetsDir (line 20) | def SetAssetsDir(assets_dir):
  function GetAssetsDir (line 31) | def GetAssetsDir():
  function GetVideoSourcesDir (line 34) | def GetVideoSourcesDir():
  function PullVideo (line 39) | def PullVideo(name=None, source_location=None, max_height=240, **kwargs):
  function ClipVideo (line 62) | def ClipVideo(video, time_range, max_height=240):
  function GetVideoSource (line 74) | def GetVideoSource(name):
  function LoadVideo (line 82) | def LoadVideo(name, max_height=240):
  function Dancefer (line 96) | def Dancefer(source_video, target,
  function get_temp_file_path (line 250) | def get_temp_file_path(final_file_path="TEMP", temp_dir_path = None):
  function AutoDancefer (line 265) | def AutoDancefer(source, target, output_path = None, synch_video_beat = ...
  function Dancify (line 276) | def Dancify(source_video, target,

FILE: src/video2npz/visbeat3/visbeat3/_mediafiles.py
  function GetTestAudioPath (line 17) | def GetTestAudioPath(filename):
  function GetTestImagePath (line 38) | def GetTestImagePath(filename=None):
  function GetVBMarkPath (line 43) | def GetVBMarkPath():

FILE: src/video2npz/visbeat3/visbeat3/fileui/__init__.py
  function GetFilePath (line 17) | def GetFilePath(initial_path=None):
  function GetDirectory (line 22) | def GetDirectory(initial_path=None):
  function GetSaveFilePath (line 27) | def GetSaveFilePath(initial_path=None, file_extension = None):
  function Show (line 33) | def Show(path):
  function Open (line 36) | def Open(path):
  function GetFilePath (line 40) | def GetFilePath(initial_path=None):
  function GetDirectory (line 42) | def GetDirectory(initial_path=None):
  function GetSaveFilePath (line 44) | def GetSaveFilePath(initial_path=None, file_extension = None):
  function Show (line 46) | def Show(path):
  function Open (line 48) | def Open(path):

FILE: src/video2npz/visbeat3/visbeat3/fileui/uipath.py
  function uiGetFilePath (line 6) | def uiGetFilePath(initial_path=None):
  function uiGetDirectory (line 18) | def uiGetDirectory(initial_path=None):
  function uiGetSaveFilePath (line 29) | def uiGetSaveFilePath(initial_path=None, file_extension=None):
  function showInFinder (line 49) | def showInFinder(path):
  function openOSX (line 52) | def openOSX(path):
  function put_string_in_quotes (line 55) | def put_string_in_quotes(s):
  function get_file_name_from_path (line 58) | def get_file_name_from_path(pth):
  function get_dir_from_path (line 61) | def get_dir_from_path(pth):

FILE: src/video2npz/visbeat3/visbeat3/vbgui/BeatGUI.py
  function media_GUI_func (line 16) | def media_GUI_func(self):
  class BeatGUI (line 22) | class BeatGUI(AObject):
    method AOBJECT_TYPE (line 26) | def AOBJECT_TYPE(self):
    method __init__ (line 29) | def __init__(self, media=None, path=None, clear_temp=None):
    method initializeBlank (line 37) | def initializeBlank(self):
    method getJSONName (line 43) | def getJSONName(self):
    method media (line 51) | def media(self):
    method _getMedia (line 53) | def _getMedia(self):
    method media (line 56) | def media(self, value):
    method _setMedia (line 58) | def _setMedia(self, value):
    method media_type (line 64) | def media_type(self):
    method _getMediaType (line 66) | def _getMediaType(self):
    method widget (line 75) | def widget(self):
    method _getWidget (line 77) | def _getWidget(self):
    method widget (line 82) | def widget(self, value):
    method _setWidget (line 84) | def _setWidget(self, value):
    method frame_rate (line 90) | def frame_rate(self):
    method _getFrameRate (line 92) | def _getFrameRate(self):
    method frame_rate (line 100) | def frame_rate(self, value):
    method _setFrameRate (line 102) | def _setFrameRate(self, value):
    method frame_offset (line 109) | def frame_offset(self):
    method _getFrameOffset (line 111) | def _getFrameOffset(self):
    method frame_offset (line 114) | def frame_offset(self, value):
    method _setFrameOffset (line 116) | def _setFrameOffset(self, value):
    method run (line 120) | def run(self, local_saliency=None, frame_rate = None, eventlist = 'def...
    method guessFrameOffset (line 151) | def guessFrameOffset(self):
    method deactivateAllEvents (line 158) | def deactivateAllEvents(self):
    method activateAllEvents (line 168) | def activateAllEvents(self):
    method activatePattern (line 178) | def activatePattern(self, pattern=None, prefix=None, apply_to_active=N...
    method shiftEventsByNFrames (line 207) | def shiftEventsByNFrames(self, n_frames=None):
    method getActiveEventTimes (line 220) | def getActiveEventTimes(self):
    method getEventTimes (line 227) | def getEventTimes(self):
    method getEvents (line 234) | def getEvents(self, active_only=None):
    method getEventList (line 237) | def getEventList(self, active_only=None):
    method getActiveEvents (line 242) | def getActiveEvents(self):
    method getEventDicts (line 245) | def getEventDicts(self, active_only = None):
    method saveEvents (line 256) | def saveEvents(self, save_path = None):
    method saveEventsAs (line 269) | def saveEventsAs(self, save_path = None):
    method setEvents (line 284) | def setEvents(self, events):
    method setEventList (line 287) | def setEventList(self, event_list):
    method loadEvents (line 293) | def loadEvents(self, load_path = None):
    method getEventListWithSelectedSegments (line 302) | def getEventListWithSelectedSegments(self):
Condensed preview — 117 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (937K chars).
[
  {
    "path": ".gitignore",
    "chars": 429,
    "preview": "/logs/*.log\n/exp/*/\n/inference/*.npz\n/inference/*.mid\n#!/inference/wzk.npz\n/src_no_pos/\n/src/*.jpg\n/src/*.npz\n!/src/midi"
  },
  {
    "path": "CMT.ipynb",
    "chars": 9847,
    "preview": "{\n  \"nbformat\": 4,\n  \"nbformat_minor\": 0,\n  \"metadata\": {\n    \"colab\": {\n      \"name\": \"CMT.ipynb\",\n      \"private_outpu"
  },
  {
    "path": "LICENSE",
    "chars": 1068,
    "preview": "MIT License\n\nCopyright (c) 2021 Shangzhe Di\n\nPermission is hereby granted, free of charge, to any person obtaining a cop"
  },
  {
    "path": "README.md",
    "chars": 9413,
    "preview": "# Controllable Music Transformer\n\nOfficial code for our paper *Video Background Music Generation with Controllable Music"
  },
  {
    "path": "dataset/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "exp/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "inference/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "logs/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "py3_requirements.txt",
    "chars": 416,
    "preview": "tqdm\nurllib3==1.26.9\nsix==1.16.0\nthreadpoolctl==2.1.0\nh5py==2.10.0\nmatplotlib==3.3.4\nnumpy==1.23.1\nmiditoolkit==0.1.15\nm"
  },
  {
    "path": "src/dictionary_mix.py",
    "chars": 58342,
    "preview": "preset_event2word = {\r\n    \"tempo\"     : {\r\n        0          : 0,\r\n        \"CONTI\"    : 1,\r\n        \"Tempo_0\"  : 2,\r\n "
  },
  {
    "path": "src/gen_midi_conditional.py",
    "chars": 3261,
    "preview": "import sys\nimport os\n\nimport time\nimport glob\nimport numpy as np\n\nimport torch\nimport argparse\n\nsys.path.append(\"../data"
  },
  {
    "path": "src/match.py",
    "chars": 2971,
    "preview": "import argparse\nfrom tqdm import tqdm\nimport numpy as np\n\n\ndef _get_density(bar_word):\n    assert _is_bar_word(bar_word)"
  },
  {
    "path": "src/midi2mp3.py",
    "chars": 1182,
    "preview": "import note_seq\nfrom pretty_midi import PrettyMIDI\nimport midi2audio\nimport argparse\n\nSAMPLE_RATE = 16000\nSF2_PATH = '.."
  },
  {
    "path": "src/midi2numpy_mix.py",
    "chars": 9252,
    "preview": "import os\nimport math\nimport json\n\nimport muspy\nimport numpy as np\nfrom tqdm import tqdm\nimport argparse\n\nfrom dictionar"
  },
  {
    "path": "src/model.py",
    "chars": 18766,
    "preview": "import numpy as np\nimport torch\nimport torch.cuda\nfrom torch import nn\n\nfrom utils import Embeddings, BeatPositionalEnco"
  },
  {
    "path": "src/numpy2midi_mix.py",
    "chars": 1965,
    "preview": "import muspy\nimport numpy as np\n\nfrom midi2numpy_mix import Note, DECODER_DIMENSION, RESOLUTION\nfrom dictionary_mix impo"
  },
  {
    "path": "src/pianoroll2midi.py",
    "chars": 2062,
    "preview": "\"\"\"Author: Shangzhe Di (shangzhe.di@gmail.com)\n\nConvert the pianoroll files (.npz) in the lpd-5/LPD-5-cleansed (https://"
  },
  {
    "path": "src/train.py",
    "chars": 7562,
    "preview": "import sys\nimport datetime\nimport argparse\nimport os\nimport time\n\nimport numpy as np\nimport torch\nfrom torch import opti"
  },
  {
    "path": "src/utils.py",
    "chars": 7450,
    "preview": "import math\nimport numpy as np\nimport torch\nimport torch.nn as nn\n\nimport os\nimport time\nimport collections\nimport matpl"
  },
  {
    "path": "src/video2npz/dictionary_mix.py",
    "chars": 55852,
    "preview": "preset_event2word = {\n    \"tempo\"     : {\n        0          : 0,\n        \"CONTI\"    : 1,\n        \"Tempo_0\"  : 2,\n      "
  },
  {
    "path": "src/video2npz/metadata2numpy_mix.py",
    "chars": 3131,
    "preview": "#/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport json\nimport os\nimport math\nimport argparse\n\nimport numpy as np\n\nfrom"
  },
  {
    "path": "src/video2npz/optical_flow.py",
    "chars": 4227,
    "preview": "#encoding=utf-8\nimport cv2\nimport argparse\nimport os\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport skvideo.i"
  },
  {
    "path": "src/video2npz/resize_video.py",
    "chars": 364,
    "preview": "import os\n\n\ndef resize_video(video_name, in_dir='video', out_dir='video_360p', max_height=360):\n    command = 'ffmpeg -i"
  },
  {
    "path": "src/video2npz/resize_videos.sh",
    "chars": 173,
    "preview": "mkdir video_360p\nfiles=$(ls video)\nfor filename in $files\ndo\n    echo $filename\n    ffmpeg -i video/$filename -strict -2"
  },
  {
    "path": "src/video2npz/stat_mix.py",
    "chars": 1071,
    "preview": "def _cal_density(flow_magnitude):\n    for i, percentile in enumerate(fmpb_percentile):\n        if flow_magnitude < perce"
  },
  {
    "path": "src/video2npz/video2metadata.py",
    "chars": 4945,
    "preview": "#/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport matplotlib\n\nmatplotlib.use('Agg')\nimport visbeat3 as vb\nimport os\nim"
  },
  {
    "path": "src/video2npz/video2npz.sh",
    "chars": 267,
    "preview": "# extract flow magnitude into optical_flow/flow.npz\npython optical_flow.py --video $1\n\n# convert video into metadata.jso"
  },
  {
    "path": "src/video2npz/visbeat3/LICENSE",
    "chars": 3268,
    "preview": "SOFTWARE LICENSE AGREEMENT For Stanford Docket S18-164, \"Visual Rhythm and Beat:\nAutomatic Synchronization of visual bea"
  },
  {
    "path": "src/video2npz/visbeat3/MANIFEST.in",
    "chars": 199,
    "preview": "# Include the README\ninclude *.md\n\n# Include the license file\ninclude LICENSE\ninclude LICENSE.pdf\n\n# Include the data fi"
  },
  {
    "path": "src/video2npz/visbeat3/README.md",
    "chars": 667,
    "preview": "# visbeat3\n\nThis is a migration of [visbeat](http://abedavis.com/visualbeat/) from Python2 to Python3. All credits belon"
  },
  {
    "path": "src/video2npz/visbeat3/VisBeatAssets/VideoSources/wzk_vlog_beat_enhance1_track1238/Data/Backups/VideoSource.json",
    "chars": 3596,
    "preview": "{\n    \"a_info\": {\n        \"AObjectType\": \"VideoSource\",\n        \"base_path\": null,\n        \"directory_path\": \"./VisBeatA"
  },
  {
    "path": "src/video2npz/visbeat3/VisBeatAssets/VideoSources/wzk_vlog_beat_enhance1_track1238/VideoSource.json",
    "chars": 3596,
    "preview": "{\n    \"a_info\": {\n        \"AObjectType\": \"VideoSource\",\n        \"base_path\": null,\n        \"directory_path\": \"./VisBeatA"
  },
  {
    "path": "src/video2npz/visbeat3/bin/dancefer",
    "chars": 601,
    "preview": "#!/usr/bin/env python\n\nimport sys\nimport matplotlib\nmatplotlib.use('PS')\nimport visbeat3\n\nsource_url = 'https://www.yout"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/ADefines.py",
    "chars": 30,
    "preview": "# AD_DEBUG = 1;\n\nAD_DEBUG = 0;"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/AFileManager.py",
    "chars": 7539,
    "preview": "from .AObject import *\n#import shutil\nfrom distutils.dir_util import copy_tree\n\nclass AFileManager(AObject):\n    \"\"\"AFil"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/AFuncDict.py",
    "chars": 4349,
    "preview": "from .AParamDict import *\nimport pickle as pickle\nimport os\nclass AFuncDict(AParamDict):\n    \"\"\"AFuncDict (class): Exten"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/AImports.py",
    "chars": 5086,
    "preview": "#AImports\nfrom . import ADefines as defines\nimport os\nimport os.path\nimport errno\nimport json\nimport pickle as pickle\nim"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/AObject.py",
    "chars": 4780,
    "preview": "#AO#labels#AObject\nimport os\nimport json\n\nfrom .AParamDict import *\nfrom . import fileui\n\nclass AObject(object):\n    \"\"\""
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/AParamDict.py",
    "chars": 3935,
    "preview": "from .AImports import *\nclass AParamDict(object):\n    \"\"\"AParamDict (class): Dictionary that stores values and the param"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/Audio.py",
    "chars": 33049,
    "preview": "from .EventList import *\nfrom .TimeSignal1D import *\nfrom scipy.io.wavfile import write\nimport librosa\nimport librosa.di"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/AudioClip.py",
    "chars": 2493,
    "preview": "from .Audio import *\n\nclass AudioClip(Audio):\n    \"\"\"AudioClip (class): A segment of a video, and a bunch of convenience"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/Event.py",
    "chars": 21121,
    "preview": "from .VisBeatImports import *\n\nclass Event(AObject):\n    \"\"\"Event (class): An event in time, either in video or audio\n  "
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/EventList.py",
    "chars": 3796,
    "preview": "from .Event import *\n\nclass EventList(AObject):\n    \"\"\"Event (class): An event in time, either in video or audio\n       "
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/Image.py",
    "chars": 17549,
    "preview": "#Image_Base\n#import numpy as np\n#import scipy as sp\nfrom PIL import Image as PIM\nfrom PIL import ImageDraw, ImageFont\n\nf"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/Image_CV.py",
    "chars": 5738,
    "preview": "\n\n#CVFunctions\nfrom .VisBeatImports import *\nimport numpy as np\nimport scipy as sp\nfrom PIL import Image as PIM\n#from VB"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/SourceLocationParser.py",
    "chars": 6133,
    "preview": "\"\"\"\nThis code was a last minute hack. It works fine enough for parsing youtube urls, but I would use it for any kind of "
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/TimeSignal.py",
    "chars": 2224,
    "preview": "from .VBObject import *\nfrom .Event import *\nimport math\nfrom operator import truediv\nfrom .VisBeatImports import *\n\ncla"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/TimeSignal1D.py",
    "chars": 2006,
    "preview": "from .TimeSignal import *\nimport math\n\nclass TimeSignal1D(TimeSignal):\n    \"\"\"TimeSignal1D (class): A time signal, and a"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/VBMIDI.py",
    "chars": 5804,
    "preview": "# %load VisBeat/MidiParse.py\nimport mido\nimport numpy as np\nimport os\n# from TimeSignal1D import *\nfrom .Audio import *\n"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/VBObject.py",
    "chars": 4220,
    "preview": "import os\nimport json\nfrom .VisBeatImports import *\nfrom .AFuncDict import *\nfrom .AObject import AObject\n\nclass VBObjec"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/Video.py",
    "chars": 35932,
    "preview": "#VideoVersion#from VisBeatImports import *\nfrom .AObject import *\nfrom .TimeSignal import *\nfrom .Audio import *\nfrom .W"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/VideoClip.py",
    "chars": 3363,
    "preview": "\nfrom .Video import *\nfrom .AudioClip import *\n\nclass VideoClip(Video):\n    \"\"\"VideoClip (class): A segment of a video, "
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/VideoSource.py",
    "chars": 30970,
    "preview": "from .VisBeatImports import *\nfrom .Video import *\nfrom .AFileManager import AFileManager\n\ntry:\n    import youtube_dl\nex"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/Video_CV.py",
    "chars": 39650,
    "preview": "# from Video import *\nfrom .Image import *\nfrom .Event import *\nfrom .VisualBeat import *\nimport librosa\n\nFEATURE_FUNCS "
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/VisBeatDefines.py",
    "chars": 87,
    "preview": "VB_DEBUG = True;\n\nDEFAULT_TEMPOGRAM_WINDOW_SECONDS = 5;\nAUDIO_DEFAULT_HOP_LENGTH = 512;"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/VisBeatExampleVideo.py",
    "chars": 5256,
    "preview": "import os\nfrom visbeat3.SourceLocationParser import ParseSourseLocation\n\nclass VisBeatExampleVideo(object):\n    def __in"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/VisBeatImports.py",
    "chars": 3690,
    "preview": "from .VisBeatDefines import *\nfrom .AImports import *\nfrom .AObject import AObject\nimport numpy as np\nimport scipy as sp"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/VisualBeat.py",
    "chars": 10929,
    "preview": "from .Event import *\n\nclass VisualBeat(Event):\n    def VBOBJECT_TYPE(self):\n        return 'VisualBeat';\n\n    def __init"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/Warp.py",
    "chars": 28628,
    "preview": "\n\nfrom .VisBeatImports import *\nfrom .EventList import *\nimport math\n\nDEFAULT_LEAD_TIME = 0;\nDEFAULT_TAIL_TIME = 0;\n\ncla"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/__init__.py",
    "chars": 18725,
    "preview": "\nfrom .VisBeatImports import *\nfrom .Video import *\nfrom .VideoClip import *\nfrom .VideoSource import *\nfrom .VisBeatExa"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/_dancefer_examples.py",
    "chars": 3437,
    "preview": "\n\nfrom .VisBeatExampleVideo import *\nfrom ._music_examples import *\n\n# dances = [];\ndances.append(VisBeatExampleVideo(di"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/_dancify_examples.py",
    "chars": 1222,
    "preview": "from .VisBeatExampleVideo import *\nfrom ._music_examples import *\n\ndances.append(VisBeatExampleVideo(display_name = 'Tur"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/_mediafiles.py",
    "chars": 1431,
    "preview": "import os\n\n\nVB_MEDIA_UTILS_PATH = os.path.abspath(__file__)\nVB_MEDIA_UTILS_DIR = os.path.abspath(os.path.dirname(__file_"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/_music_examples.py",
    "chars": 3479,
    "preview": "from .VisBeatExampleVideo import *\ndances = [];\n\nmusic = [];\n\nmusic.append(VisBeatExampleVideo(display_name = 'U Cant To"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/command_line.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/fileui/__init__.py",
    "chars": 1458,
    "preview": "\nfrom sys import platform\nif platform == \"linux\" or platform == \"linux2\":\n    PLATFORM = 'linux';\nelif platform == \"darw"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/fileui/uipath.py",
    "chars": 2944,
    "preview": "import os\nimport subprocess\n\n\n\ndef uiGetFilePath(initial_path=None):\n    try:\n        if(initial_path):\n            outp"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/vbgui/BeatGUI.py",
    "chars": 10460,
    "preview": "from visbeat3.AImports import *\n\nVIEWER_INSTALLED = 1;\ntry:\n    import vbwidget as Viewer\nexcept ImportError as e:\n    V"
  },
  {
    "path": "src/video2npz/visbeat3/build/lib/visbeat3/vbgui/__init__.py",
    "chars": 1,
    "preview": "\n"
  },
  {
    "path": "src/video2npz/visbeat3/build/scripts-3.7/dancefer",
    "chars": 617,
    "preview": "#!/opt/anaconda3/envs/py37/bin/python\n\nimport sys\nimport matplotlib\nmatplotlib.use('PS')\nimport visbeat3\n\nsource_url = '"
  },
  {
    "path": "src/video2npz/visbeat3/setup.cfg",
    "chars": 659,
    "preview": "[metadata]\n# This includes the license file(s) in the wheel.\n# https://wheel.readthedocs.io/en/stable/user_guide.html#in"
  },
  {
    "path": "src/video2npz/visbeat3/setup.py",
    "chars": 1021,
    "preview": "import setuptools\n\nwith open(\"README.md\", \"r\") as fh:\n    long_description = fh.read()\n\nsetuptools.setup(\n  name=\"visbea"
  },
  {
    "path": "src/video2npz/visbeat3/test.py",
    "chars": 964,
    "preview": "import visbeat3 as vb\nimport os\n\nvideo_dir = '../videos/'\ntempos = {}\n# try:\n#     for file in os.listdir(video_dir):\n# "
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/ADefines.py",
    "chars": 30,
    "preview": "# AD_DEBUG = 1;\n\nAD_DEBUG = 0;"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/AFileManager.py",
    "chars": 7539,
    "preview": "from .AObject import *\n#import shutil\nfrom distutils.dir_util import copy_tree\n\nclass AFileManager(AObject):\n    \"\"\"AFil"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/AFuncDict.py",
    "chars": 4349,
    "preview": "from .AParamDict import *\nimport pickle as pickle\nimport os\nclass AFuncDict(AParamDict):\n    \"\"\"AFuncDict (class): Exten"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/AImports.py",
    "chars": 5086,
    "preview": "#AImports\nfrom . import ADefines as defines\nimport os\nimport os.path\nimport errno\nimport json\nimport pickle as pickle\nim"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/AObject.py",
    "chars": 4780,
    "preview": "#AO#labels#AObject\nimport os\nimport json\n\nfrom .AParamDict import *\nfrom . import fileui\n\nclass AObject(object):\n    \"\"\""
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/AParamDict.py",
    "chars": 3935,
    "preview": "from .AImports import *\nclass AParamDict(object):\n    \"\"\"AParamDict (class): Dictionary that stores values and the param"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/Audio.py",
    "chars": 33049,
    "preview": "from .EventList import *\nfrom .TimeSignal1D import *\nfrom scipy.io.wavfile import write\nimport librosa\nimport librosa.di"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/AudioClip.py",
    "chars": 2493,
    "preview": "from .Audio import *\n\nclass AudioClip(Audio):\n    \"\"\"AudioClip (class): A segment of a video, and a bunch of convenience"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/Event.py",
    "chars": 21121,
    "preview": "from .VisBeatImports import *\n\nclass Event(AObject):\n    \"\"\"Event (class): An event in time, either in video or audio\n  "
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/EventList.py",
    "chars": 3796,
    "preview": "from .Event import *\n\nclass EventList(AObject):\n    \"\"\"Event (class): An event in time, either in video or audio\n       "
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/Image.py",
    "chars": 17549,
    "preview": "#Image_Base\n#import numpy as np\n#import scipy as sp\nfrom PIL import Image as PIM\nfrom PIL import ImageDraw, ImageFont\n\nf"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/Image_CV.py",
    "chars": 5738,
    "preview": "\n\n#CVFunctions\nfrom .VisBeatImports import *\nimport numpy as np\nimport scipy as sp\nfrom PIL import Image as PIM\n#from VB"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/SourceLocationParser.py",
    "chars": 6133,
    "preview": "\"\"\"\nThis code was a last minute hack. It works fine enough for parsing youtube urls, but I would use it for any kind of "
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/TimeSignal.py",
    "chars": 2224,
    "preview": "from .VBObject import *\nfrom .Event import *\nimport math\nfrom operator import truediv\nfrom .VisBeatImports import *\n\ncla"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/TimeSignal1D.py",
    "chars": 2006,
    "preview": "from .TimeSignal import *\nimport math\n\nclass TimeSignal1D(TimeSignal):\n    \"\"\"TimeSignal1D (class): A time signal, and a"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/VBMIDI.py",
    "chars": 5804,
    "preview": "# %load VisBeat/MidiParse.py\nimport mido\nimport numpy as np\nimport os\n# from TimeSignal1D import *\nfrom .Audio import *\n"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/VBObject.py",
    "chars": 4220,
    "preview": "import os\nimport json\nfrom .VisBeatImports import *\nfrom .AFuncDict import *\nfrom .AObject import AObject\n\nclass VBObjec"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/Video.py",
    "chars": 35932,
    "preview": "#VideoVersion#from VisBeatImports import *\nfrom .AObject import *\nfrom .TimeSignal import *\nfrom .Audio import *\nfrom .W"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/VideoClip.py",
    "chars": 3363,
    "preview": "\nfrom .Video import *\nfrom .AudioClip import *\n\nclass VideoClip(Video):\n    \"\"\"VideoClip (class): A segment of a video, "
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/VideoSource.py",
    "chars": 30970,
    "preview": "from .VisBeatImports import *\nfrom .Video import *\nfrom .AFileManager import AFileManager\n\ntry:\n    import youtube_dl\nex"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/Video_CV.py",
    "chars": 39650,
    "preview": "# from Video import *\nfrom .Image import *\nfrom .Event import *\nfrom .VisualBeat import *\nimport librosa\n\nFEATURE_FUNCS "
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/VisBeatDefines.py",
    "chars": 87,
    "preview": "VB_DEBUG = True;\n\nDEFAULT_TEMPOGRAM_WINDOW_SECONDS = 5;\nAUDIO_DEFAULT_HOP_LENGTH = 512;"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/VisBeatExampleVideo.py",
    "chars": 5256,
    "preview": "import os\nfrom visbeat3.SourceLocationParser import ParseSourseLocation\n\nclass VisBeatExampleVideo(object):\n    def __in"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/VisBeatImports.py",
    "chars": 3690,
    "preview": "from .VisBeatDefines import *\nfrom .AImports import *\nfrom .AObject import AObject\nimport numpy as np\nimport scipy as sp"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/VisualBeat.py",
    "chars": 10929,
    "preview": "from .Event import *\n\nclass VisualBeat(Event):\n    def VBOBJECT_TYPE(self):\n        return 'VisualBeat';\n\n    def __init"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/Warp.py",
    "chars": 28628,
    "preview": "\n\nfrom .VisBeatImports import *\nfrom .EventList import *\nimport math\n\nDEFAULT_LEAD_TIME = 0;\nDEFAULT_TAIL_TIME = 0;\n\ncla"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/__init__.py",
    "chars": 18725,
    "preview": "\nfrom .VisBeatImports import *\nfrom .Video import *\nfrom .VideoClip import *\nfrom .VideoSource import *\nfrom .VisBeatExa"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/_dancefer_examples.py",
    "chars": 3437,
    "preview": "\n\nfrom .VisBeatExampleVideo import *\nfrom ._music_examples import *\n\n# dances = [];\ndances.append(VisBeatExampleVideo(di"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/_dancify_examples.py",
    "chars": 1222,
    "preview": "from .VisBeatExampleVideo import *\nfrom ._music_examples import *\n\ndances.append(VisBeatExampleVideo(display_name = 'Tur"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/_mediafiles.py",
    "chars": 1431,
    "preview": "import os\n\n\nVB_MEDIA_UTILS_PATH = os.path.abspath(__file__)\nVB_MEDIA_UTILS_DIR = os.path.abspath(os.path.dirname(__file_"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/_music_examples.py",
    "chars": 3479,
    "preview": "from .VisBeatExampleVideo import *\ndances = [];\n\nmusic = [];\n\nmusic.append(VisBeatExampleVideo(display_name = 'U Cant To"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/command_line.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/fileui/__init__.py",
    "chars": 1458,
    "preview": "\nfrom sys import platform\nif platform == \"linux\" or platform == \"linux2\":\n    PLATFORM = 'linux';\nelif platform == \"darw"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/fileui/uipath.py",
    "chars": 2944,
    "preview": "import os\nimport subprocess\n\n\n\ndef uiGetFilePath(initial_path=None):\n    try:\n        if(initial_path):\n            outp"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/vbgui/BeatGUI.py",
    "chars": 10460,
    "preview": "from visbeat3.AImports import *\n\nVIEWER_INSTALLED = 1;\ntry:\n    import vbwidget as Viewer\nexcept ImportError as e:\n    V"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3/vbgui/__init__.py",
    "chars": 1,
    "preview": "\n"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3.egg-info/PKG-INFO",
    "chars": 1421,
    "preview": "Metadata-Version: 2.1\nName: visbeat3\nVersion: 0.0.8\nSummary: Python3 Implementation for 'Visual Rhythm and Beat' SIGGRAP"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3.egg-info/SOURCES.txt",
    "chars": 7139,
    "preview": ".DS_Store\nLICENSE\nLICENSE.pdf\nMANIFEST.in\nREADME.md\nsetup.cfg\nsetup.py\ntest.py\n.git/.DS_Store\n.git/HEAD\n.git/config\n.git"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3.egg-info/dependency_links.txt",
    "chars": 1,
    "preview": "\n"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3.egg-info/requires.txt",
    "chars": 81,
    "preview": "numpy\nscipy\nbs4\nlibrosa\nimageio\nrequests\nmoviepy\ntermcolor\nyoutube-dl\nmatplotlib\n"
  },
  {
    "path": "src/video2npz/visbeat3/visbeat3.egg-info/top_level.txt",
    "chars": 9,
    "preview": "visbeat3\n"
  },
  {
    "path": "videos/.gitkeep",
    "chars": 0,
    "preview": ""
  }
]

// ... and 2 more files (download for full content)

About this extraction

This page contains the full source code of the wzk1015/video-bgm-generation GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 117 files (870.0 KB), approximately 229.4k tokens, and a symbol index with 1500 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!