Skip to content

Instantly share code, notes, and snippets.

@kroger
kroger / midi2mp3
Last active December 18, 2023 17:03
Convert MIDI files to MP3 using fluidsynth. See
#!/usr/bin/env bash
SOUNDFONT=/Users/kroger/Dropbox/Sfonts/BOPLMEVF16.sf2
TMPDIR=/tmp
if [[ ! -f $SOUNDFONT ]]
then
echo "Couldn't find the soundfont: $SOUNDFONT"
exit 1
@kroger
kroger / gist:3856835
Created October 9, 2012 05:41
Example of Sphinx conf.py
# -*- coding: utf-8 -*-
import sys, os
sys.path.insert(0, os.path.abspath('extensions'))
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig',
'epub2', 'mobi', 'autoimage', 'code_example']
@kroger
kroger / gist:3856749
Created October 9, 2012 05:14
Show code examples in Sphinx
from __future__ import division
import os
import sys
import codecs
import textwrap
from StringIO import StringIO
from docutils import nodes
from docutils.parsers.rst import Directive, directives
from sphinx.directives.code import LiteralInclude
from sphinx.util.nodes import set_source_info
@kroger
kroger / mobi.py
Created June 26, 2013 11:37
Mobi builder based on Sphinx's epub builder.
# -*- coding: utf-8 -*-
"""
sphinx.builders.mobi
~~~~~~~~~~~~~~~~~~~~
Build mobi files.
Originally derived from epub.py.
:copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
@kroger
kroger / Makefile
Created October 9, 2012 05:48
Makefile for Sphinx
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build -E
PAPER =
BUILDDIR = build
LATEX-BW = $(BUILDDIR)/latex-bw
@kroger
kroger / convert.py
Created February 7, 2012 16:46
Rename wav files using frequency and pitch detection
#!/usr/bin/env python
import subprocess, os, glob
## Rename wav files using frequency and pitch detection:
## GTR_08.wav ---> automated pitch detection & file renaming ---> C - 130.81 Hz - GTR_08.wav
WAV_DIR = r"C:/Conversion"
AUBIO_DIR = r"C:/Conversion"
@kroger
kroger / gist:3856845
Created October 9, 2012 05:45
The LaTeX style file used in Music for Geeks and Nerds
\usepackage{wasysym}
\usepackage{moresize}
\usepackage{multicol}
\usepackage[Sonny]{fncychap}
\usepackage[margin=1in, paperwidth=6.69in, paperheight=9.61in]{geometry}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage{xltxtra}
\setmainfont[Mapping=tex-text]{Minion Pro}
\setmonofont[Mapping=tex-text,Scale=0.85]{Inconsolata}
%\setmonofont[Mapping=tex-text,Scale=0.75]{DejaVu Sans Mono}
\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage[scaled]{beramono}
\renewcommand*\familydefault{\ttdefault}
\usepackage{listings}
\lstset{
language=Python,
showstringspaces=false,
formfeed=\newpage,
@kroger
kroger / convert.sh
Last active May 7, 2018 18:48
midi-to-mp3
fluidsynth -F output.wav ~/Soundfonts/my-soundfont.sf2 myfile.midi
lame output.wav
@kroger
kroger / setup-python.sh
Created February 13, 2012 23:28
Install Python 2.7 on Mac OS
#!/bin/sh
#set -e
PYTHON_VERSION=$(brew info python | grep -o "stable 2\.7\.\d" | awk '{print $2}')
function install_python {
brew install readline sqlite gdbm
brew install python --universal --framework
}