Skip to content

Instantly share code, notes, and snippets.

View hpux735's full-sized avatar

Will Dillon hpux735

View GitHub Profile
@hpux735
hpux735 / gist:2913436
Created June 11, 2012 23:38
Core Audio
struct AQPlayerState {
AudioStreamBasicDescription mDataFormat; // 2
AudioQueueRef mQueue; // 3
AudioQueueBufferRef mBuffers[kNumberBuffers]; // 4
SInt64 mCurrentPacket; // 7
UInt32 mNumPacketsToRead; // 8
AudioStreamPacketDescription *mPacketDescs; // 9
DAGAudioSinkNode *audioSink;
};
// The output at time 0 is the sum of the
// previous num_taps samples times the taps
int j;
for(j = 0; j < num_taps; j++) {
float2 sample = 0;
int sample_index = i - (num_taps - 1);
if (sample_index < 0) {
sample = lastBlock[2048+sample_index];
@hpux735
hpux735 / quartzPixelAlign
Created February 27, 2012 23:14
Pixel aligning lines using Quartz (from the TreeView sample code)
// Compute the needed adjustment in x and y to align our lines for crisp, exact pixel coverage. (We can only do this if the lineWidth is integral, which it usually is.)
CGFloat adjustment = 0.0;
CGFloat lineWidth = [[self enclosingTreeView] connectingLineWidth];
NSSize lineSize = NSMakeSize(lineWidth, lineWidth);
NSSize lineSizeInPixels = [self convertSizeToBase:lineSize];
CGFloat halfLineWidthInPixels = 0.5 * lineSizeInPixels.width;
if (fabs(halfLineWidthInPixels - floor(halfLineWidthInPixels)) > 0.0001) {
// If line width in pixels is odd, lay our path segments along the centers of pixel rows.
NSSize adjustmentAsSizeInPixels = NSMakeSize(0.5, 0.5);
NSSize adjustmentAsSize = [self convertSizeFromBase:adjustmentAsSizeInPixels];