Skip to content

Instantly share code, notes, and snippets.

@bwhitman
bwhitman / chord.py
Created May 1, 2014 14:56
Chord class for synthesizing
#!/usr/bin/env python
# encoding: utf-8
"""
chord.py
Brian Whitman
brian@echonest.com
"""
@bwhitman
bwhitman / gist:0edba48fdf6839c43aa3
Created May 10, 2014 13:23
From "Jaws" by Donald Barthelme

"Go home," I say. "Praise the lamb."

"How do I know it won't be the spinal cord next?"

"Hard to get to. Probably couldn't even dent it."

"I feel like I'm married to some kind of animal."

"Our animal nature is part of us and we are part of it."

@bwhitman
bwhitman / write_sine.c
Created February 28, 2015 17:05
test multi channel in portaudio OS X
/** @file paex_write_sine.c
@ingroup examples_src
@brief Play a sine wave for several seconds using the blocking API (Pa_WriteStream())
@author Ross Bencina <rossb@audiomulch.com>
@author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id: paex_write_sine.c 1865 2012-09-01 21:16:25Z philburk $
*
* This program uses the PortAudio Portable Audio Library.
@bwhitman
bwhitman / portaudio_mac_nonpow2.diff
Created February 28, 2015 20:38
Fix for non-power-of-2 output channels on mac
Index: src/hostapi/coreaudio/pa_mac_core_blocking.c
===================================================================
--- src/hostapi/coreaudio/pa_mac_core_blocking.c (revision 1948)
+++ src/hostapi/coreaudio/pa_mac_core_blocking.c (working copy)
@@ -186,7 +186,7 @@
err = PaUtil_InitializeRingBuffer(
&blio->outputRingBuffer,
- 1, ringBufferSize*blio->outputSampleSizePow2*outChan,
+ outChan*blio->outputSampleSizePow2, ringBufferSize,
@bwhitman
bwhitman / aifc.diff
Created April 27, 2015 22:44
Python aifc.py sampler metadata support
296d295
< self._loops = []
328,329d326
< elif chunkname == 'INST':
< self._readinst(chunk)
402,407d398
< def getinst(self):
< if len(self._loops) == 0:
< return None
< return self._loops
@bwhitman
bwhitman / breaddetector.ino
Last active August 29, 2015 14:24
Bread Detector loop
void loop() {
uint sensorValue = read_analog();
delay(10);
if (sensorValue > 0) {
float voltage = sensorValue / 1023.0;
float temp = getTemp();
if (temp < 1) temp = 0; // bad connection or something
temp_average = temp_average + temp;
sensor_average = sensor_average + voltage;
readings = readings + 1;
crimp:build bwhitman$ sudo brew -v install liblastfm
Password:
Homebrew 0.7.1
==> Build Environment
CC: /usr/bin/cc => /usr/bin/gcc-4.2
CXX: /usr/bin/c++ => /usr/bin/c++-4.2
LD: /usr/bin/cc => /usr/bin/gcc-4.2
CFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
CXXFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
MAKEFLAGS: -j2
@bwhitman
bwhitman / gist:966551
Created May 11, 2011 14:31
Music beta by google instant mix response
POST data
{"title":"Accidents Will Happen Mix","type":"song","seeds":["5d2a0f8d-a005-33e7-b789-52c0cb800e8f"]}
Response
{
"id":"75e62b7b-c4c4-40de-819d-0c08efedd4fb",
"title":"Accidents Will Happen Mix",
"entries":[
{
"genre":"General Rock",
@bwhitman
bwhitman / gist:1041616
Created June 23, 2011 00:18
Echoprint accuracy numbers from Bigeval
NOTE: duplicates in our bigeval DB are the main cause of fp failures.
-c 1000 -d 30 -e wav -p
PR 0.0109 CAR 0.9907 FAR 0.1176 FRR 0.0093 {'err-api': 0, 'fp-a': 2, 'fp-b': 2, 'err-data': 3, 'tp': 960, 'tn': 15, 'err-codegen': 0, 'total': 1000, 'fn': 7, 'err-munge': 11}
-d 60 -e wav
PR 0.0030 CAR 0.9969 FAR 0.0000 FRR 0.0031 {'err-api': 0, 'fp-a': 2, 'fp-b': 0, 'err-data': 3, 'tp': 976, 'tn': 9, 'err-codegen': 0, 'total': 1000, 'fn': 1, 'err-munge': 9}
-d 60 -e mp3
PR 0.0136 CAR 0.9877 FAR 0.1000 FRR 0.0123 {'err-api': 0, 'fp-a': 3, 'fp-b': 1, 'err-data': 1, 'tp': 962, 'tn': 9, 'err-codegen': 0, 'total': 1000, 'fn': 9, 'err-munge': 15}
@bwhitman
bwhitman / gist:1041667
Created June 23, 2011 00:59
Song/identify response
{
response: {
status: {
version: "4.2",
code: 0,
message: "Success"
},
songs: [
{
score: 48,