Skip to content

Instantly share code, notes, and snippets.

View bartolsthoorn's full-sized avatar

Bart Olsthoorn bartolsthoorn

View GitHub Profile
@bartolsthoorn
bartolsthoorn / signals.mm
Created April 24, 2012 20:51
Multiple signal generator with broken filter
// MULTIPLE SIGNAL GENERATOR!
__block float *phases = nil;
__block float dbVal = 0.0;
__block float *dbData;
[audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
{
float samplingRate = audioManager.samplingRate;
NSUInteger activeSignalCount = [tones count];
// Initialize phases
@bartolsthoorn
bartolsthoorn / test.mm
Created April 23, 2012 19:41
Multiple signal generator!
// MULTIPLE SIGNAL GENERATOR!
__block float *phases = nil;
[audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
{
float samplingRate = audioManager.samplingRate;
NSUInteger activeSignalCount = [tones count];
// Initialize phases
if (phases == nil) {
NSLog(@"Initializing float array");
@bartolsthoorn
bartolsthoorn / test.mm
Created April 23, 2012 19:35
Measuring dB / max amp in Novocaine
[audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels)
{
// Measure dB
float maxAmp = abs(data[0]);
for (int i=0; i < numFrames; ++i)
{
for (int iChannel = 0; iChannel < numChannels; ++iChannel)
{
if (abs(data[i*numChannels + iChannel]) > maxAmp) {
maxAmp = abs(data[i*numChannels + iChannel]);
#pragma mark -
#pragma mark Audio processing graph setup
// This method performs all the work needed to set up the audio processing graph:
// 1. Instantiate and open an audio processing graph
// 2. Obtain the audio unit nodes for the graph
// 3. Configure the Multichannel Mixer unit
// * specify the number of input buses
@bartolsthoorn
bartolsthoorn / MixerHostAudio.m
Created April 3, 2012 20:21
new error, see log
#pragma mark -
#pragma mark Audio processing graph setup
// This method performs all the work needed to set up the audio processing graph:
// 1. Instantiate and open an audio processing graph
// 2. Obtain the audio unit nodes for the graph
// 3. Configure the Multichannel Mixer unit
// * specify the number of input buses
// * specify the output sample rate
@bartolsthoorn
bartolsthoorn / MixerHostAudio.m
Created April 3, 2012 19:57
*** AudioUnitSetProperty (set EQ unit output stream format) error: -1073751081 FFFFFFCE prin
#pragma mark -
#pragma mark Audio processing graph setup
// This method performs all the work needed to set up the audio processing graph:
// 1. Instantiate and open an audio processing graph
// 2. Obtain the audio unit nodes for the graph
// 3. Configure the Multichannel Mixer unit
// * specify the number of input buses
// * specify the output sample rate
/*
Original comments from Apple:
File: MixerHostAudio.m
Abstract: Audio object: Handles all audio tasks for the application.
Version: 1.0
removeLastSentence = (text) ->
lastSeparator = Math.max(
text.lastIndexOf("."),
text.lastIndexOf("!"),
text.lastIndexOf("?")
)
revtext = text.split('').reverse().join('')
sep = revtext.search(/[A-Z]\s+(\")?[\.\!\?]/)
lastTag = text.length-revtext.search(/\/\</) - 2
NSString *xmldata_s = [[NSString alloc] initWithContentsOfFile:dataFile encoding:NSUTF8StringEncoding error:nil];
NSData *xmldata = [xmldata_s dataUsingEncoding: NSUTF8StringEncoding];
NSMutableArray *pp = [NSPropertyListSerialization propertyListFromData: xmldata
mutabilityOption: NSPropertyListMutableContainers
format: NSPropertyListXMLFormat_v1_0
errorDescription: nil];
NSLog(@"Deserialized: %@", pp);
[[NSUserDefaults standardUserDefaults] setObject:pp forKey:kPagePoints];
@bartolsthoorn
bartolsthoorn / AppViewController.m
Created July 8, 2011 11:18
Is it possible to change the url of one webview later in another function by using the specified tag?
for( int i = 0; i < 4; i++ ) {
UIWebView *wview;
int wx;
if (i < 2) {
wx = 12;
} else {
wx = 512;
}
wview = [[UIWebView alloc] initWithFrame:CGRectMake(wx, 16, 500, 716)];