Skip to content

Instantly share code, notes, and snippets.

View goonzoid's full-sized avatar
🎛️

Will Pragnell goonzoid

🎛️
View GitHub Profile
@goonzoid
goonzoid / audioPlayback.m
Created October 26, 2012 08:50
Audio Queue Playback Callback
typedef struct FCAudioPlayer {
AudioStreamBasicDescription asbd;
AudioBuffer fileBuffer;
UInt32 playbackPosition;
UInt32 totalFrames;
} FCAudioPlayer;
static void FCAudioOutputCallback(void *inUserData, AudioQueueRef inAudioQueue, AudioQueueBufferRef inCompleteAudioQueueBuffer)
{
FCAudioPlayer *audioPlayer = (FCAudioPlayer *)inUserData;
@goonzoid
goonzoid / monoSumming.c
Created August 6, 2013 13:19
Naively sum a non-interleaved buffer of stereo, floating-point audio to mono using the Accelerate framework. See http://dsp.stackexchange.com/a/2485 for suggestion of a more sophisticated approach.
@import Accelerate;
static float* monoDataFromStereoNonInterleaved(const float *stereoData, size_t length) {
vDSP_Length numberOfSamples = length / sizeof(float) / 2;
const float *leftChannel = stereoData;
const float *rightChannel = leftChannel + numberOfSamples;
size_t monoDataLength = length / 2;
float *monoData = malloc(monoDataLength);
vDSP_vadd(leftChannel, 1, rightChannel, 1, monoData, 1, numberOfSamples);
float scale = 0.5;
@goonzoid
goonzoid / audio_devices.m
Created April 1, 2018 00:04
List audio devices on OS X
NSArray* audioDevices() {
AudioObjectPropertyAddress propertyAddress = {
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
UInt32 dataSize = 0;
OSStatus status = 0;
@goonzoid
goonzoid / .gitignore-JUCE_OSX
Last active November 27, 2019 00:32
.gitignore for OS X JUCE projects
.DS_Store
*.pbxuser
*.perspectivev3
*.xcbkptlist
*.xccheckout
xcuserdata
/Builds/MacOSX/build
@goonzoid
goonzoid / melodies_crow.lua
Last active January 26, 2023 03:31
First attempt at porting https://gist.github.com/schollz/e2cc49425d54336b422e144e7eeb34cc to crow. WARNING: this may lock up your Crow / Just Friends! Needs work still!
-- melody generator
-- based on https://gist.github.com/schollz/e2cc49425d54336b422e144e7eeb34cc
function init()
ii.jf.mode(1)
local chords={"I","vi","IV","iii"} -- change to any chords
local move_left=6 -- change to 0-12
local move_right=6 -- change to 0-12
local stay_on_chord=0.95 -- change to 0-1