diff --git a/AugmentedNet/texturizers.py b/AugmentedNet/texturizers.py index 0ab94a34..b68f55ba 100644 --- a/AugmentedNet/texturizers.py +++ b/AugmentedNet/texturizers.py @@ -1,6 +1,8 @@ """Templates for texturizing annotation files and turn them into scores.""" import random +from music21 import note +from music21 import interval class TextureTemplate(object): @@ -218,6 +220,36 @@ def templateSeventh(self): """ +class AuxiliaryNotes(TextureTemplate): + """A syncopated pattern to separate the upper voice from the rest. + + TODO: Add details""" + + supported_durations = [1.0, 2.0] + + def templateTriad(self): + transposed_note = note.Note(self.notes[2]).transpose(-1) + transposed_name = transposed_note.nameWithOctave + transposed_interval = interval.Interval(noteStart=note.Note(self.notes[0]), noteEnd=transposed_note).name + dur = self.duration / 4 + return f"""\ +0.0,{dur},,"['{self.notes[0]}', '{self.notes[1]}', '{self.notes[2]}']","['{self.intervals[0]}', '{self.intervals[1]}']","[True, True, True]" +{dur},{dur},,"['{self.notes[0]}', '{self.notes[1]}', '{transposed_name}']","['{self.intervals[0]}', '{transposed_interval}']","[False, False, True]" +{dur*2},{dur*2},,"['{self.notes[0]}', '{self.notes[1]}', '{self.notes[2]}']","['{self.intervals[0]}', '{self.intervals[1]}']","[False, False, True]" +""" + + def templateSeventh(self): + transposed_note = note.Note(self.notes[3]).transpose(-1) + transposed_name = transposed_note.nameWithOctave + transposed_interval = interval.Interval(noteStart=note.Note(self.notes[0]), noteEnd=transposed_note).name + dur = self.duration / 4 + return f"""\ +0.0,{dur},,"['{self.notes[0]}', '{self.notes[1]}', '{self.notes[2]}', '{self.notes[3]}']","['{self.intervals[0]}', '{self.intervals[1]}', '{self.intervals[2]}']","[True, True, True, True]" +{dur},{dur},,"['{self.notes[0]}', '{self.notes[1]}', '{self.notes[2]}', '{transposed_name}']","['{self.intervals[0]}', '{self.intervals[1]}', '{transposed_interval}']","[False, False, False, True]" +{dur*2},{dur*2},,"['{self.notes[0]}', '{self.notes[1]}', '{self.notes[2]}', '{self.notes[3]}']","['{self.intervals[0]}', '{self.intervals[1]}', '{self.intervals[2]}']","[False, False, False, True]" +""" + + class BlockChord(TextureTemplate): """A block-chord texture. The default texture in music21-generated scores.""" @@ -235,10 +267,11 @@ def templateSeventh(self): available_templates = { - "BassSplit": BassSplit, - "Alberti": Alberti, - "Syncopation": Syncopation, + # "BassSplit": BassSplit, + # "Alberti": Alberti, + # "Syncopation": Syncopation, "BlockChord": BlockChord, + "AuxiliaryNotes": AuxiliaryNotes, } available_durations = list( diff --git a/README.md b/README.md index 664aaf73..1ccb5f5d 100644 --- a/README.md +++ b/README.md @@ -244,3 +244,14 @@ These are the results for the best AugmentedNet configuration (11+) against othe | BPS | BPS | CS18 | 66.7 | 51.8 | 60.6 | 59.1 | - | - | 25.7 | - | **[Visualize experiments in TensorBoard.dev!](https://tensorboard.dev/experiment/fXVA71nWTkSZh6CqTXCeCw/#scalars)** + +## How to run on Google Cloud VM + +1. `wget https://github.com/Alicelavander/AugmentedNet/raw/setup/setup-cuda.sh` +2. `chmod +x setup-cuda.sh` +3. `sudo ./setup-cuda.sh` +4. `./setup-augmentednet.sh` +5. `sudo shutdown -r now` +6. `cd AugmentedNet` +7. `conda create -n aha python=3.8` +8. `conda activate aha` diff --git a/setup-augmentednet.sh b/setup-augmentednet.sh new file mode 100644 index 00000000..3b7e169e --- /dev/null +++ b/setup-augmentednet.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +#setup ssh for GitHub +#cd $HOME/.ssh +#ssh-keygen -t rsa +#cat id_rsa.pub +#ssh -T git@github.com + +#setup AugmentedNet +#git clone --recursive git@github.com:Alicelavander/AugmentedNet.git +wget https://github.com/napulen/AugmentedNet/archive/refs/heads/main.zip +apt install unzip +unzip main.zip +mv AugmentedNet-main AugmentedNet +cd AugmentedNet/ +wget https://github.com/napulen/AugmentedNet/releases/latest/download/dataset.zip +unzip dataset.zip +wget https://repo.anaconda.com/miniconda/Miniconda3-py38_23.1.0-1-Linux-x86_64.sh +bash Miniconda3-py38_23.1.0-1-Linux-x86_64.sh + +#pip install -r requirements.txt diff --git a/setup-cuda.sh b/setup-cuda.sh new file mode 100644 index 00000000..24a75527 --- /dev/null +++ b/setup-cuda.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +#setup CUDA & cuDNN +apt install gcc +apt-get install linux-headers-$(uname -r) +wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin +mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 +wget https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda-repo-ubuntu2004-12-1-local_12.1.0-530.30.02-1_amd64.deb +dpkg -i cuda-repo-ubuntu2004-12-1-local_12.1.0-530.30.02-1_amd64.deb +cp /var/cuda-repo-ubuntu2004-12-1-local/cuda-*-keyring.gpg /usr/share/keyrings/ +apt-get update +apt-get -y install cuda +apt install nvidia-cuda-toolkit +apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub +add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /" +apt-get update +apt-get install libcudnn8=8.8.0.121-1+cuda12.0 +apt-get autoremove + +wget https://github.com/Alicelavander/AugmentedNet/raw/setup/setup-augmentednet.sh +chmod +x setup-augmentednet.sh + +#nvidia-smi