Automatically generate music using python.
So, you want to have your computer make music for you, huh? Came to the right spot. Follow these simple instructions, and we'll get you up and running in no time. This has only been fully tested on OSX. It should work on Linux with some modifications, but no guarantees.
- Clone this repo with
git clone https://github.com/VikParuchuri/evolve-music2.git
. - Switch to the repo folder with
cd evolve-music2
. - Install the system packages in
brew-packages.txt
(osx) orapt-packages.txt
(linux).- If osx,
brew install INSERT_PACKAGENAME_HERE
. - If linux,
apt-get install INSERT_PACKAGENAME_HERE
. apt-packages.txt
may not be comprehensive, so if you get any missing dependency errors, you may need to revisit this.
- If osx,
- Install the python pre-requirements with
pip install -r pre-requirements.txt
-- scipy doesn't like when numpy isn't already installed. Virtualenv recommended. - Install the python packages using
pip install -r requirements.txt
. Virtualenv recommended.- Installing the
cryptography
package on OSX is a pain -- if you get any errors, verify that you have theopenssl
system package properly installed, and dobrew update
andbrew upgrade
. Runningenv ARCHFLAGS="-arch x86_64 -Wno-error=unused-command-line-argument-hard-error-in-future" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography==0.5.4
can also help.
- Installing the
- Download a soundfont, used to render midi. I got mine here.
- Put the
.sf2
file indata/soundfont
. - Update
SOUNDFONT_PATH
insettings.py
to point to your soundfont.
- Put the
- Run the scrapy crawler
- Use
cd crawler/crawler
to go into the crawler directory. - Run
scrapy crawl mas
to crawl one site. - Run
scrapy crawl mws
to crawl another site. - You should now have
.mid
files indata/midi/full
, and a file atdata/full.json
. - It's possible that one or more of the .mid files are just text stored as
.mid
, and you may get errors later (but you'll be able to delete them then). - Switch back to the
evolve-music2
directory (project root).
- Use
- You can now run
python evolve_tracks.py
to evolve tracks.- You can pass two optional arguments, the number of tracks, and the number of evolutions.
python evolve_tracks.py 20 5
will make 20 tracks total, and run through 5 evolutions. - The generated music will be in
data/good
. Both midi and ogg files will be available. You'll see as many files as there were evolutions. - If you get any errors while running this command, or if it hangs for over 30 minutes, you should check the logs at
data/em.log
. If the last line mentions a midi or ogg file, you should delete it -- it's probably corrupt. - All the features for the training data are extracted the first time, so the command will be much faster the second time you run it and beyond. If you need to regenerate training features, delete
data/generated/train_features.csv
. - If you set evolutions high (above 3 or 4), you'll see some duplicate tracks -- this is because the "best" track stays the "best" through multiple generations.
- You can pass two optional arguments, the number of tracks, and the number of evolutions.
Are great. Submit a pull request if you have any.