# HG changeset patch # User Robert Tubb # Date 1359717416 0 # Node ID a4908ad8c78e9f079310b36c75d9a44a3084b431 # Parent dae6d77657a035d52e48be2fc390003945182729 Top and bottom toolbars. Intro page. diff -r dae6d77657a0 -r a4908ad8c78e BottomTabViewController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BottomTabViewController.h Fri Feb 01 11:16:56 2013 +0000 @@ -0,0 +1,20 @@ +// +// BottomTabViewController.h +// sonicZoom +// +// Created by Robert Tubb on 31/01/2013. +// +// + +#import + +@interface BottomTabViewController : UIViewController + +@property (nonatomic, assign) id theOFAppRef; + + +-(IBAction)show:(id)sender; +-(void)setAppRef:(id)theOFApp; +- (IBAction)interfaceSelected:(id)sender; + +@end diff -r dae6d77657a0 -r a4908ad8c78e BottomTabViewController.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BottomTabViewController.mm Fri Feb 01 11:16:56 2013 +0000 @@ -0,0 +1,56 @@ +// +// BottomTabViewController.m +// sonicZoom +// +// Created by Robert Tubb on 31/01/2013. +// +// + +#import "BottomTabViewController.h" +#import "testApp.h" +@interface BottomTabViewController () + +@end + +@implementation BottomTabViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)setAppRef:(id)theOFApp{ + self.theOFAppRef = theOFApp; + +} + +- (IBAction)interfaceSelected:(UISegmentedControl *)sender { + + NSInteger whichTab = sender.selectedSegmentIndex; + ((testApp *)self.theOFAppRef)->interfaceSelected(whichTab); + +} + +- (IBAction)show:(id)sender +{ + self.theOFAppRef = sender; + self.view.hidden = NO; +} + +@end diff -r dae6d77657a0 -r a4908ad8c78e BottomTabViewController.xib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BottomTabViewController.xib Fri Feb 01 11:16:56 2013 +0000 @@ -0,0 +1,191 @@ + + + + 1536 + 11G63 + 2844 + 1138.51 + 569.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1930 + + + IBProxyObject + IBUISegmentedControl + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + 292 + + + + 292 + {768, 44} + + + _NS:9 + NO + IBIPadFramework + 3 + 0 + + SLIDERS + BOTH + ZOOMER + + + + + + + + + + + + + {0, 0} + {0, 0} + {0, 0} + + + + + + + + + {768, 43} + + + + NO + NO + 6 + + IBUISimulatedFreeformSizeMetricsSentinel + Freeform + + IBIPadFramework + + + + + + + view + + + + 3 + + + + interfaceSelected: + + + 13 + + 5 + + + + + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 2 + + + + + + + + 4 + + + + + + + BottomTabViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + + 5 + + + + + BottomTabViewController + UIViewController + + id + id + + + + interfaceSelected: + id + + + show: + id + + + + IBProjectSource + ./Classes/BottomTabViewController.h + + + + + 0 + IBIPadFramework + YES + 3 + 1930 + + diff -r dae6d77657a0 -r a4908ad8c78e IntroViewController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IntroViewController.h Fri Feb 01 11:16:56 2013 +0000 @@ -0,0 +1,20 @@ +// +// IntroViewController.h +// sonicZoom +// +// Created by Robert Tubb on 29/01/2013. +// +// + +#import + +@interface IntroViewController : UIViewController + +@property (nonatomic, assign) id theOFAppRef; +@property (retain, nonatomic) IBOutlet UILabel *text; + +-(IBAction)hide:(id)sender; +-(IBAction)show:(id)sender; +-(IBAction)disagree:(id)sender; +-(void)setAppRef:(id)theOFApp; +@end diff -r dae6d77657a0 -r a4908ad8c78e IntroViewController.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IntroViewController.mm Fri Feb 01 11:16:56 2013 +0000 @@ -0,0 +1,68 @@ +// +// IntroViewController.m +// sonicZoom +// +// Created by Robert Tubb on 29/01/2013. +// +// + +#import "IntroViewController.h" +#import "testApp.h" +@interface IntroViewController () + +@end + +@implementation IntroViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)setAppRef:(id)theOFApp{ + self.theOFAppRef = theOFApp; + +} + +- (IBAction)show:(id)sender +{ + self.theOFAppRef = sender; + self.view.hidden = NO; +} +- (IBAction)hide:(id)sender +{ + self.view.hidden = YES; + ((testApp *)self.theOFAppRef)->introHidden(YES); + +} +- (IBAction)disagree:(id)sender +{ + // shut down the app + self.view.hidden = YES; + ((testApp *)self.theOFAppRef)->introHidden(NO); +} +- (void)dealloc { + [_text release]; + [super dealloc]; +} +- (void)viewDidUnload { + [self setText:nil]; + [super viewDidUnload]; +} +@end diff -r dae6d77657a0 -r a4908ad8c78e IntroViewController.xib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IntroViewController.xib Fri Feb 01 11:16:56 2013 +0000 @@ -0,0 +1,347 @@ + + + + 1536 + 11G63 + 2844 + 1138.51 + 569.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1930 + + + IBProxyObject + IBUIButton + IBUILabel + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + 292 + + + + 292 + {{326, 881}, {116, 44}} + + + _NS:9 + NO + IBIPadFramework + 0 + 0 + 1 + AGREE + + 3 + MQA + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + 3 + MC41AA + + + 2 + 15 + + + Helvetica-Bold + 15 + 16 + + + + + 292 + {{20, 68}, {728, 795}} + + + + _NS:9 + NO + YES + 9 + NO + IBIPadFramework + + V2VsY29tZSB0byB0aGUgIlNvbmljIFpvb20iLiBUaGlzIGlzIGEgcmVzZWFyY2ggcHJvamVjdCBhaW1l +ZCBhdCBmaW5kaW5nIG91dCBob3cgcGVvcGxlIGV4cGxvcmUgdGhlIHNwYWNlIG9mIHNvdW5kIHN5bnRo +ZXNpcyBwYXJhbWV0ZXJzLiANDUluIHRoaXMgYXBwIHRoZXJlIGFyZSBqdXN0IDEwIHBhcmFtZXRlcnMg +4oCTIDUgZm9yIHRoZSBzZXF1ZW5jZXIgcGF0dGVybiBnZW5lcmF0b3IgYW5kIDUgZm9yIGEgYmFzaWMg +Rk0vc3VidHJhY3RpdmUgc3ludGhlc2l6ZXIuIEhvd2V2ZXIsIGV2ZW4gd2l0aCBvbmx5IDEwIHBhcmFt +ZXRlcnMgdGhlIGFtb3VudCBvZiBkaWZmZXJlbnQgc291bmRzIHRvIGV4cGxvcmUgaXMgdmFzdDogaW4g +ZmFjdCB0aGVyZSBhcmUganVzdCBvdmVyIGEgYmlsbGlvbiB0cmlsbGlvbiBkaXN0aW5jdCBzZXR0aW5n +cyEgV2UgYWltIHRvIGxvb2sgYXQgd2hhdCBwYXRocyBwZW9wbGUgdGFrZSBpbiB0aGlzIGh1Z2Ugc3Bh +Y2UsIHdoYXQgcG9pbnRzIHRoZXkgbGlrZSBhbmQgZGlzbGlrZSwgYW5kIHVzZSB0aGUgZGF0YSB0byBj +cmVhdGUgc3ludGhzIHRoYXQgYXJlIGVhc2llciB0byBuYXZpZ2F0ZSwgb3IgdGhhdCBlbmNvdXJhZ2Ug +Y3JlYXRpdml0eS4NDVRoZXJlIGFyZSB0d28gaW50ZXJmYWNlcyBwcmVzZW50ZWQgaGVyZS4gVGhlIGZp +cnN0IGlzIG9uZSB5b3Ugd2lsbCBwcm9iYWJseSBiZSB1c2VkIHRvIGlmIHlvdSBhcmUgYSBtdXNpY2lh +bjogMTAgc2xpZGVycyBmb3IgZWFjaCBvZiB0aGUgcGFyYW1ldGVycy4gVGhlIHNlY29uZCBpcyBzb21l +d2hhdCBuZXc6IGV2ZXJ5IG9uZSBvZiB0aGUgYmlsbGlvbiB0cmlsbGlvbiBwb2ludHMgaGFzIGJlZW4g +bWFwcGVkIHRvIGEgMkQgc3VyZmFjZSAoaWYgeW91IHJlYWxseSB3YW50IHRvIGtub3cgLSBlYWNoIHNx +dWFyZSB5b3Ugc2VlIGlzIGEgc3F1YXNoZWQgb3V0IDEwRCBoeXBlcmN1YmUsIGFuZCBhbGwgb2YgdGhl +IDEwMjQgc3ViLXNxdWFyZXMgYXJlIHRoZSDigJxjb3JuZXJz4oCdIG9mIHRoaXMgMTAtY3ViZSwgd2hp +Y2ggdGhlbXNlbHZlcyBhcmUgYnVpbHQgZnJvbSBzbWFsbGVyIGh5cGVyY3ViZXMgYW5kIHNvIG9u4oCm +KS4gQXMgZmFyIGFzIHBvc3NpYmxlLCB0aGUgZnVydGhlciB5b3UgdHJhdmVsIGFsb25nIHRoaXMgMkQg +c3VyZmFjZSwgdGhlIG1vcmUgZGlmZmVyZW50IHRoZSBzb3VuZCB3aWxsIGJlY29tZS4NDVVwIGRvd24g +bW92ZW1lbnQgY29udHJvbHMgdGhlIHN5bnRoIHRpbWJyZSwgbGVmdCByaWdodCBjb250cm9scyB0aGUg +c2VxdWVuY2VyLiBXaGVuIHlvdSBjbGljayDigJxzYXZlIHByZXNldOKAnSB5b3Ugd2lsbCBkcm9wIGEg +cGluIG9udG8gdGhlIHN1cmZhY2UsIGFuZCB5b3UgY2FuIHJldmlzaXQgdGhpcyBwb2ludCBhdCBhbnl0 +aW1lIGJ5IHNjcm9sbGluZyB0byBpdC4gVGhpbmsgb2YgaXQgbGlrZSBhICJHb29nbGUgTWFwcyIgZm9y +IHN5bnRoIHNvdW5kcy4uLg0NWW91IGNhbiB1c2UgYSBwaW5jaCBnZXN0dXJlIHRvIHpvb20gaW4gYW5k +IG91dCBvZiB0aGUgc3VyZmFjZS4gWm9vbWluZyBpbiB3aWxsIGVuYWJsZSB5b3UgdG8gZXhwbG9yZSBz +bWFsbGVyIGxvY2FsaXRpZXMgb2YgdGhlIHNvdW5kIHNwYWNlLiBab29taW5nIG91dCB3aWxsIGdpdmUg +eW91IGEgYmlnZ2VyIHBlcnNwZWN0aXZlLCBidXQgb2YgY291cnNlIHRoZSBzb3VuZCB3aWxsIGJlY29t +ZSBmYXIgbW9yZSByYW5kb20gYW5kIHVuY29udHJvbGxhYmxlIGFzIHlvdSBtb3ZlIGJpZ2dlciBkaXN0 +YW5jZXMuDQ1XaGF0IHdlIGFyZSBhc2tpbmcgeW91LCB0aGUgcGFydGljaXBhbnQsIHRvIGRvIGlzIHVz +ZSBib3RoIHRoZSB6b29tZXIgYW5kIHRoZSBzbGlkZXJzIGZvciBhYm91dCAxMCBtaW51dGVzIGVhY2gs +IGFuZCBzYXZlIGFueSBzb3VuZHMgdGhhdCB5b3UgbGlrZS4gQWZ0ZXIgYWJvdXQgMjAgbWludXRlcyBv +ZiBpbnRlcmFjdGlvbiBhIHByb21wdCB3aWxsIGFwcGVhciBmb3IgYSBzaG9ydCBxdWVzdGlvbm5haXJl +IHRoYXQgd2lsbCBoZWxwIHVzIGFzc2VzcyB0aGUgaW50ZXJmYWNlIGZ1cnRoZXIuICBBZnRlciB0aGF0 +LCBwbGVhc2UgZmVlbCBmcmVlIHRvIHVzZSBpdCBzb21lIG1vcmU6IHRoZSBtb3JlIGRhdGEgd2UgZ2V0 +IHRoZSBiZXR0ZXIuIE1vcmUgZXhjaXRpbmcgZmVhdHVyZXMgYXJlIHBsYW5uZWQgZm9yIHRoaXMgYXBw +LCBzbyBwbGVhc2Ugd2F0Y2ggb3V0IGZvciB1cGRhdGVzLg0NTk9URTogWW91ciBhY3Rpb25zIHdpbGwg +YmUgbG9nZ2VkLCBhbmQgc2VudCB0byBhIHNlY3VyZSBzZXJ2ZXIgaGVyZSBhdCBRdWVlbiBNYXJ5IFVu +aXZlcnNpdHkuICBIb3dldmVyIG5vIHBlcnNvbmFsIGRhdGEgKG5hbWUsIGVtYWlsIGV0Yy4pIHdpbGwg +YmUgY29sbGVjdGVkLCBhc3NvY2lhdGVkIHdpdGggdGhpcyBJRCBvciBzdG9yZWQgaW4gdGhlIGRhdGFi +YXNlLiBJdCBpcyBoaWdobHkgcmVjb21tZW5kZWQgdGhhdCB5b3UgYXJlIGNvbm5lY3RlZCB0byBXaUZp +IGludGVybmV0IHdoaWxzdCB1c2luZyB0aGlzIEFwcC4NVG8gY29uc2VudCB0byB0aGlzIHBsZWFzZSBw +cmVzcyAiQWdyZWUiIGJlbG93LiBUbyBkZWNsaW5lIGp1c3QgZXhpdCB0aGUgYXBwLg0 + + + 1 + MC4zMzgyNjY5OTg0IDAuOTA1MzMyMjM5OSAxAA + + + 0 + 39 + + 1 + 17 + + + Helvetica + 17 + 16 + + NO + 728 + + + + 292 + {{299, 20}, {123, 21}} + + + + _NS:9 + NO + YES + 7 + NO + IBIPadFramework + SONIC ZOOM + + 1 + MC4zMzgyNjY5OTg0IDAuOTA1MzMyMjM5OSAxAA + + + 0 + + + NO + + + {768, 1024} + + + + + 1 + MCAwIDAAA + darkTextColor + + NO + + IBUIScreenMetrics + + YES + + + + + + {768, 1024} + {1024, 768} + + + IBIPadFramework + iPad Full Screen + 1 + + IBIPadFramework + + + + + + + view + + + + 3 + + + + text + + + + 57 + + + + hide: + + + 7 + + 55 + + + + + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 2 + + + + + + + + + + 4 + + + + + + 14 + + + + + + 50 + + + + + + + + IntroViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 57 + + + + + IntroViewController + UIViewController + + id + id + id + + + + disagree: + id + + + hide: + id + + + show: + id + + + + text + UILabel + + + text + + text + UILabel + + + + IBProjectSource + ./Classes/IntroViewController.h + + + + + 0 + IBIPadFramework + YES + 3 + 1930 + + diff -r dae6d77657a0 -r a4908ad8c78e Question.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Question.h Fri Feb 01 11:16:56 2013 +0000 @@ -0,0 +1,24 @@ +// +// Question.h +// sonicZoom +// +// Created by Robert Tubb on 21/01/2013. +// +// included by Qviewcont + +#import +typedef enum QuestionType{AGREE_DISAGREE, SLIDERS_ZOOMER} QuestionType; + +@interface Question : NSObject +{ + + +} +@property (strong, nonatomic) NSString *questionText; +@property QuestionType questionType; +@property int answer; // answer 0 means no answer was given (the blank line in picker) this distiguishes between "neither" and "don't know / no answer" + +-(id)initWithTextAndType:(NSString *)text:(QuestionType)type; ++ (int)count; ++(NSArray *)answersWithType:(QuestionType)type; +@end diff -r dae6d77657a0 -r a4908ad8c78e Question.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Question.m Fri Feb 01 11:16:56 2013 +0000 @@ -0,0 +1,61 @@ +// +// Question.m +// sonicZoom +// +// Created by Robert Tubb on 21/01/2013. +// +// + +#import "Question.h" + +@implementation Question + +@synthesize questionText = _questionText; +@synthesize questionType = _questionType; +@synthesize answer = _answer; + +static int theCount = 0; + +-(id)initWithTextAndType:(NSString *)text:(QuestionType)type{ + self = [super init]; + if(self){ + self.questionText = text; + self.questionType = type; + self.answer = 0; + } + + return self; + +} +//// +- (id)init +{ + return [self initWithTextAndType:@"Quo Vadis?":AGREE_DISAGREE]; +} + ++ (int) count { return theCount; } ++ (void) setCount:(int)c { theCount = c; } + + + ++(NSArray *)answersWithType:(QuestionType)type{ +// get the set of answers depending on what type the q was + // pseudo static variable + if(type == AGREE_DISAGREE){ + [Question setCount:6]; + return [[NSArray alloc] initWithObjects: + @" ", @"Strongly disagree", @"Disagree", @"Neither", + @"Agree", @"Strongly agree", nil]; + + + }else if(type == SLIDERS_ZOOMER){ + [Question setCount:6]; + return [[NSArray alloc] initWithObjects: + @" ", @"Definitely Sliders", @"Maybe Sliders", @"Neither", + @"Maybe Zoomer", @"Definitely Zoomer", nil]; + }else{ + return nil; + } +} +/// +@end diff -r dae6d77657a0 -r a4908ad8c78e TopButtonViewController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TopButtonViewController.h Fri Feb 01 11:16:56 2013 +0000 @@ -0,0 +1,27 @@ +// +// TopButtonViewController.h +// sonicZoom +// +// Created by Robert Tubb on 31/01/2013. +// +// + +#import + +@interface TopButtonViewController : UIViewController + +@property (nonatomic, assign) id theOFAppRef; + +@property (retain, nonatomic) IBOutlet UIBarButtonItem *playButton; +@property (retain, nonatomic) IBOutlet UIBarButtonItem *pauseButton; + +-(IBAction)show:(id)sender; +-(void)setAppRef:(id)theOFApp; +- (IBAction)playPressed:(id)sender; +- (IBAction)pausePressed:(id)sender; +- (IBAction)savePressed:(id)sender; +- (IBAction)lockSequencePressed:(id)sender; +- (IBAction)lockSynthPressed:(id)sender; +- (IBAction)qPressed:(id)sender; + +@end diff -r dae6d77657a0 -r a4908ad8c78e TopButtonViewController.mm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TopButtonViewController.mm Fri Feb 01 11:16:56 2013 +0000 @@ -0,0 +1,113 @@ +// +// TopButtonViewController.m +// sonicZoom +// +// Created by Robert Tubb on 31/01/2013. +// +// + +#import "TopButtonViewController.h" +#import "testApp.h" +#import "presetManager.h" + +extern PresetManager presetManager; + + +@interface TopButtonViewController () + +@end + +@implementation TopButtonViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. + self.playButton.enabled = true; + self.pauseButton.enabled = false; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)setAppRef:(id)theOFApp{ + self.theOFAppRef = theOFApp; + +} + +- (IBAction)playPressed:(id)sender { + ((testApp *)self.theOFAppRef)->seqStartStop(true); + self.playButton.enabled = false; + self.pauseButton.enabled = true; +} + +- (IBAction)pausePressed:(id)sender { + ((testApp *)self.theOFAppRef)->seqStartStop(false); + self.pauseButton.enabled = false; + self.playButton.enabled = true; +} + +- (IBAction)savePressed:(id)sender { + cout << "SAVE PRESET\n"; + presetManager.showNameDialog(); +} + +- (IBAction)lockSequencePressed:(id)sender { + UIBarButtonItem *button = (UIBarButtonItem *)sender; + if([button.title isEqualToString:@"Lock Sequence (X)"]){ + ((testApp *)self.theOFAppRef)->lockSequencerPressed(true); + button.title = @"Unlock Sequence (X)"; + }else if([button.title isEqualToString:@"Unlock Sequence (X)"]){ + ((testApp *)self.theOFAppRef)->lockSequencerPressed(false); + button.title = @"Lock Sequence (X)"; + }else{ + NSLog(@"button title error"); + } +} + +- (IBAction)lockSynthPressed:(id)sender { + UIBarButtonItem *button = (UIBarButtonItem *)sender; + if([button.title isEqualToString:@"Lock Synth (Y)"]){ + ((testApp *)self.theOFAppRef)->lockSynthPressed(true); + button.title = @"Unlock Synth (Y)"; + }else if([button.title isEqualToString:@"Unlock Synth (Y)"]){ + ((testApp *)self.theOFAppRef)->lockSynthPressed(false); + button.title = @"Lock Synth (Y)"; + }else{ + NSLog(@"button title error"); + } +} + +- (IBAction)qPressed:(id)sender { + ((testApp *)self.theOFAppRef)->showQuestionnaire(); +} + +- (IBAction)show:(id)sender +{ + self.theOFAppRef = sender; + self.view.hidden = NO; +} + +- (void)dealloc { + [_playButton release]; + [_pauseButton release]; + [super dealloc]; +} +- (void)viewDidUnload { + [self setPlayButton:nil]; + [self setPauseButton:nil]; + [super viewDidUnload]; +} +@end diff -r dae6d77657a0 -r a4908ad8c78e TopButtonViewController.xib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TopButtonViewController.xib Fri Feb 01 11:16:56 2013 +0000 @@ -0,0 +1,466 @@ + + + + 1536 + 11G63 + 2844 + 1138.51 + 569.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1930 + + + IBNSLayoutConstraint + IBProxyObject + IBUIBarButtonItem + IBUIToolbar + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + 292 + + + + 266 + {768, 44} + + + _NS:9 + NO + NO + IBIPadFramework + + + IBIPadFramework + 1 + + 17 + + + IBIPadFramework + 1 + + 18 + + + IBIPadFramework + 52 + + 6 + + + Save Preset + IBIPadFramework + 1 + + + 1 + MC4zNjc1OTI2Njc5IDAuNTkyNTIwODk2NyAxAA + + + + IBIPadFramework + 62 + + 6 + + + Take Questionnaire + IBIPadFramework + 1 + + + + IBIPadFramework + + 5 + + + Lock Sequence (X) + IBIPadFramework + 1 + + + + Lock Synth (Y) + IBIPadFramework + 1 + + + + + + {768, 44} + + + + + 3 + MQA + + 2 + + + NO + IBIPadFramework + + + + + + + view + + + + 3 + + + + playButton + + + + 26 + + + + pauseButton + + + + 27 + + + + savePressed: + + + + 22 + + + + playPressed: + + + + 20 + + + + qPressed: + + + + 25 + + + + lockSequencePressed: + + + + 23 + + + + lockSynthPressed: + + + + 24 + + + + pausePressed: + + + + 21 + + + + + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 2 + + + + + + 3 + 0 + + 3 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 5 + 0 + + 5 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + + + 4 + + + + + + + + + + + + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + 10 + + + + + 11 + + + + + 12 + + + + + 13 + + + + + 14 + + + + + 16 + + + + + 28 + + + + + + + TopButtonViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 28 + + + + + NSLayoutConstraint + NSObject + + IBProjectSource + ./Classes/NSLayoutConstraint.h + + + + TopButtonViewController + UIViewController + + id + id + id + id + id + id + id + + + + lockSequencePressed: + id + + + lockSynthPressed: + id + + + pausePressed: + id + + + playPressed: + id + + + qPressed: + id + + + savePressed: + id + + + show: + id + + + + UIBarButtonItem + UIBarButtonItem + + + + pauseButton + UIBarButtonItem + + + playButton + UIBarButtonItem + + + + IBProjectSource + ./Classes/TopButtonViewController.h + + + + + 0 + IBIPadFramework + YES + 3 + YES + 1930 + + diff -r dae6d77657a0 -r a4908ad8c78e eventLogger.h --- a/eventLogger.h Fri Jan 25 17:42:47 2013 +0000 +++ b/eventLogger.h Fri Feb 01 11:16:56 2013 +0000 @@ -25,6 +25,7 @@ #include #include "2dvector.h" #include "json.h" +#include "testApp.h" #import "usernameAlertViewController.h" diff -r dae6d77657a0 -r a4908ad8c78e eventLogger.mm --- a/eventLogger.mm Fri Jan 25 17:42:47 2013 +0000 +++ b/eventLogger.mm Fri Feb 01 11:16:56 2013 +0000 @@ -30,6 +30,9 @@ nextUploadQty = 5000; // amount of data uploaded is always more than 5000 events } //--------------------------------------------------------------------------- +// draw() - show path of last N scroll events - can be scrubbed along? +// +//--------------------------------------------------------------------------- void EventLogger::init(){ readJsonToLog(ofxiPhoneGetDocumentsDirectory() + EVENT_LOG_FILENAME); @@ -80,7 +83,7 @@ ofURLFileLoader fileLoader; ofHttpResponse resp; resp = fileLoader.get(request); - + //fileLoader.getAsync(request); cout << "HTTP STATUS " << resp.status << "\n"; cout << "HTTP ERROR " << resp.error << "\n"; cout << "HTTP DATA " << resp.data << "\n"; // ofBuffer @@ -133,14 +136,11 @@ return; }else{ - while(theFile){ theFile >> line; // cout << line; // lots!!!! fileText << line; - } - theFile.close(); } @@ -228,7 +228,10 @@ questionnaireCompleted = false; questionnaireUploaded = false; - [usernameAlertViewController showUserNamePrompt]; + ((testApp *)ofGetAppPtr())->showIntro(); + + + //[usernameAlertViewController showUserNamePrompt]; // then we get userName via setUsername, called from button delegate } diff -r dae6d77657a0 -r a4908ad8c78e grid.h --- a/grid.h Fri Jan 25 17:42:47 2013 +0000 +++ b/grid.h Fri Feb 01 11:16:56 2013 +0000 @@ -18,8 +18,38 @@ class Preset; class Grid { + +public: + bool snapped; + + + Grid(); + ~Grid(); + void init(); + void move(TwoVector moveP); // shift view by pixels + void zoom(float factor); + + + void snapCheck(); + void shiftCentreToSnapped(); + void draw(); // draw lines + + void update(); // change according to zoom + + vector getParams(); + TwoVector getCoord(); + void setMinZoom(); + void setMaxZoom(); + + vector calculateParamsFromCoord(TwoVector coord) const; + TwoVector calculateCoordFromParams(vector params) const; + TwoVector coordToPixel(TwoVector coord); + + // the inverse stuff + void setParams(vector); + private: - double scale; // surface units per pixel + double scale; // surface units per pixel GUI const double maxValue; // width of entire space const double minValue; // smallest zoom @@ -29,15 +59,14 @@ - TwoVector topLeft; // top left corner of view, surface coords + TwoVector topLeft; // top left corner of view, surface coords GUI TwoVector bottomRight; TwoVector size; // size of view, surface coords TwoVector pixSize; // size of view pixels (ie screen size!) + TwoVector centre; - - TwoVector snapCentre; - TwoVector snapDist; // number of pixels to snap to + TwoVector snapDist; // number of pixels to snap to GUI Preset * closestPreset; // pointer to the currently selected (snapped to ) preset.. NULL if none. bool maxZoom, minZoom; @@ -73,31 +102,7 @@ void setCoord(TwoVector coord); void drawCrossHairs(); -public: - Grid(); - ~Grid(); - void init(); - void move(TwoVector moveP); // shift view by pixels - void zoom(float factor); - bool snapped; - - void snapCheck(); - void shiftCentreToSnapped(); - void draw(); // draw lines - - void update(); // change according to zoom - - vector calculateParamsFromCoord(TwoVector coord) const; - TwoVector calculateCoordFromParams(vector params) const; - TwoVector coordToPixel(TwoVector coord); - vector getParams(); - TwoVector getCoord(); - void setMinZoom(); - void setMaxZoom(); - - // the inverse stuff - void setParams(vector); diff -r dae6d77657a0 -r a4908ad8c78e grid.mm --- a/grid.mm Fri Jan 25 17:42:47 2013 +0000 +++ b/grid.mm Fri Feb 01 11:16:56 2013 +0000 @@ -33,7 +33,7 @@ pixSize.setCoord(ofGetWidth(), ofGetHeight()); //set scale and position to mid way - scale = pow(32.0,3.0); + scale = 5500.0; snapDist = TwoVector(9,9); snapped = false; @@ -425,6 +425,7 @@ } //-------------------------------------------------------------- +// would be advisable to only have one "mover" object that has permission to move the grid (?) void Grid::move(TwoVector moveP){ // numspacing, pixelspacing stay the same diff -r dae6d77657a0 -r a4908ad8c78e testApp.h --- a/testApp.h Fri Jan 25 17:42:47 2013 +0000 +++ b/testApp.h Fri Feb 01 11:16:56 2013 +0000 @@ -19,16 +19,23 @@ #import "QuestionnaireViewController.h" +#import "BottomTabViewController.h" +#import "IntroViewController.h" +#import "TopButtonViewController.h" #define HOST "169.254.1.1" #define PORT 12345 +typedef enum {SLIDERS,ZOOMER,BOTH,INTRO,QUESTIONNAIRE}interfaceType; + class testApp : public ofxiPhoneApp { public: - + interfaceType whichInterfaceShowing; + bool consentGiven; + BottomTabViewController *bottomTabViewController; int prevTouchX; int prevTouchY; double prevDist; @@ -57,6 +64,9 @@ int numActiveTouches; QuestionnaireViewController * questionnaireViewController; + IntroViewController * introViewController; + TopButtonViewController * topButtonViewController; + // void setup(); @@ -86,14 +96,26 @@ ofxOscSender sender; void sendOSCParams(); + void lockSynthPressed(bool locked); + void lockSequencerPressed(bool locked); + void showQuestionnaire(); void questionnaireHidden(vector answers); + void showIntro(); + void introHidden(bool OK); + void interfaceSelected(int which); + void seqStartStop(bool go); + + void setupBottomGui(); + void bottomGuiEvent(); + void setupTopGui(); + void topGuiEvent(); // stardard GUI - knbs and sliders - hides zoomer - bool standardGUIShowing; - void standardGUIEvent(ofxUIEventArgs &e); - void setupStandardGui(); - ofxUICanvas *standardGUI; + void sliderGUIEvent(ofxUIEventArgs &e); + void setupSliderGui(); + ofxUICanvas *sliderGUI; + void sliderMoved(int which, float value); void setAllGUISliders(vector vals); diff -r dae6d77657a0 -r a4908ad8c78e testApp.mm --- a/testApp.mm Fri Jan 25 17:42:47 2013 +0000 +++ b/testApp.mm Fri Feb 01 11:16:56 2013 +0000 @@ -1,16 +1,23 @@ #include "testApp.h" - +#define SLIDER_GUI_WIDTH 256 extern Grid theGridView; extern PresetManager presetManager; extern EventLogger eventLogger; extern Frequencer frequencer; +const vector parameterNames; + +const string sliderParamNames[10] = {"Transpose", "1/4 note","1/6 note","1/7 note","1/8 note","Waveform", "Filter Type","Filter Freq", "Envelope","FM amt"}; +//const vector v(ra[0],ra[1]); + + //DeviceID3523537000 //-------------------------------------------------------------- void testApp::setup(){ paused = true; + ofBackground( 0, 0, 0 ); ofEnableAlphaBlending(); //ofEnableSmoothing(); @@ -46,20 +53,19 @@ ofxiPhoneSetOrientation( OFXIPHONE_ORIENTATION_PORTRAIT ); // do this before setting up all the other objects + // initialise the interfaces theGridView.init(); - setupStandardGui(); - standardGUIShowing = false; - standardGUI->setVisible(standardGUIShowing); - - setupZoomGui(); - zoomGUI->setVisible(!standardGUIShowing); + setupSliderGui(); + sliderGUI->setVisible(true); // initial slider vals for(int i=0; i<10;i++){ sliderVals.push_back(64); } + // initialise PD + int ticksPerBuffer = 8; // 8 * 64 = buffer len of 512 // setup the app core @@ -68,13 +74,58 @@ // setup OF sound stream ofSoundStreamSetup(2, 1, this, 44100, ofxPd::blockSize()*ticksPerBuffer, 3); + + + // set up iOS gui stuff + bottomTabViewController = [[BottomTabViewController alloc] initWithNibName:@"BottomTabViewController" bundle:nil]; + [ofxiPhoneGetGLParentView() addSubview:bottomTabViewController.view]; + + [bottomTabViewController setAppRef:(id)this]; + [bottomTabViewController show:(id)this]; + + bottomTabViewController.view.frame = CGRectMake(0,getHeight()-44,getWidth(),44); + + ///// + + topButtonViewController = [[TopButtonViewController alloc] initWithNibName:@"TopButtonViewController" bundle:nil]; + [ofxiPhoneGetGLParentView() addSubview:topButtonViewController.view]; + + [topButtonViewController setAppRef:(id)this]; + [topButtonViewController show:(id)this]; + + topButtonViewController.view.frame = CGRectMake(0,0,getWidth(),44); + + // initialise user logging stuff presetManager.startupLoadAll(); eventLogger.init(); - + + + // GO paused = false; +} + + +//-------------------------------------------------------------- +void testApp::exit(){ + if(consentGiven){ + presetManager.exitAndSaveAll(); + eventLogger.exitAndSave(); + } + // else - don't save anything and app will boot up into consent/intro screen + core.exit(); + + [introViewController release]; + [topButtonViewController release]; + [bottomTabViewController release]; + + delete sliderGUI; + + cout << "exit done \n"; } + +//-------------------------------------------------------------- #pragma mark GUI //-- float testApp::getWidth(){ @@ -87,41 +138,39 @@ return ofGetHeight(); } +#pragma mark GUI + //-------------------------------------------------------------- +/* void testApp::setupZoomGui(){ // width = height - zoomGUI = new ofxUICanvas(getWidth()-200,0,190,300); - zoomGUI->setTheme(OFX_UI_THEME_HACKER ); + int buttonHeight = 45; + zoomGUI = new ofxUICanvas(getWidth()-200,0,190,buttonHeight*7); + zoomGUI->setTheme(OFX_UI_THEME_METALGEAR ); - zoomGUI->addLabelToggle("SWITCH VIEW", false); - - zoomGUI->addLabelButton("SAVE PRESET", false); - - + zoomGUI->addLabelToggle("START/STOP", false); + zoomGUI->addLabelButton("SAVE PRESET", false); zoomGUI->addLabelButton("ZOOM MIN", false); zoomGUI->addLabelButton("ZOOM MAX", false); zoomGUI->addLabelButton("QUESTIONS", false); + + ofxUILabelToggle * butt = zoomGUI->addLabelToggle("LOCK SEQUENCE (X)", false); + butt->setColorFill(ofColor(0,0,255)); + butt->setColorFillHighlight(ofColor(0,0,255)); + + ofxUILabelToggle * butt2 = zoomGUI->addLabelToggle("LOCK SYNTH (Y)", false); + butt2->setColorFill(ofColor(255,0,0)); + butt2->setColorFillHighlight(ofColor(255,0,0)); + + ofAddListener(zoomGUI->newGUIEvent, this, &testApp::zoomGUIEvent); } + //-------------------------------------------------------------- void testApp::zoomGUIEvent(ofxUIEventArgs &e){ - if(e.widget->getName() == "SWITCH VIEW") - { - // is toggle - cout << "change VIEW\n"; - cout << "of width " << ofGetWidth() <<'\n'; - cout << "of height " << ofGetHeight() <<'\n'; - standardGUI->setVisible(!standardGUIShowing); - standardGUIShowing = !standardGUIShowing; - if(standardGUIShowing){ - // set the slider values to stuff got from zoomer - sliderVals = theGridView.getParams(); - setAllGUISliders(sliderVals); - } - - }else if(e.widget->getName() == "SAVE PRESET") + if(e.widget->getName() == "SAVE PRESET") { if(((ofxUIButton *)e.widget)->getValue()==0){ // touchup @@ -150,89 +199,7 @@ if(((ofxUIButton *)e.widget)->getValue()==0){ // touchup showQuestionnaire(); } - }else{ - cout << "GUI error : unknown event recieved\n"; - } - -} -//-------------------------------------------------------------- -void testApp::showQuestionnaire(){ - // stop updating / drawing - - // if(eventLogger.questionnaireCompleted) return; - - paused = true; - - questionnaireViewController = [[QuestionnaireViewController alloc] initWithNibName:@"QuestionnaireViewController" bundle:nil]; - [ofxiPhoneGetGLParentView() addSubview:questionnaireViewController.view]; - - [questionnaireViewController setAppRef:(id)this]; - [questionnaireViewController show:(id)this]; - - //IF THE VIEW IS HIDDEN LETS BRING IT BACK! - //if( questionnaireViewController.view.hidden ){ - // questionnaireViewController.view.hidden = NO; - //} - -} -//-------------------------------------------------------------- -void testApp::questionnaireHidden(vector answers){ - // send answers to server as json - eventLogger.questionnaireAnswersObtained(answers); - - // set "we've done questionnaire" to true in event logger - paused = false; -} -//-------------------------------------------------------------- -void testApp::setupStandardGui(){ - float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; - float length = 256-xInit*2; - - - float dim = 42; - - // LEFT GUI - standardGUI = new ofxUICanvas(0,0,length+90,getHeight()); - - - ofxUILabelToggle * butt = standardGUI->addLabelToggle("LOCK SEQUENCE (X)", false); - butt->setColorFill(ofColor(0,0,255)); - butt->setColorFillHighlight(ofColor(0,0,255)); - - // Uh.. loop this - for(int i = 1; i<=10;i++){ - stringstream ss; - ss << "P" << i; - ofxUISlider *slider; - slider = (ofxUISlider *)standardGUI->addWidgetDown(new ofxUISlider(length,dim,0.0,127,64,ss.str())); - slider->setDrawPadding(true); - if(i <= 5){ - slider->setColorFill(ofColor(0,0,255)); - slider->setColorFillHighlight(ofColor(0,0,255)); - }else{ - slider->setColorFill(ofColor(255,0,0)); - slider->setColorFillHighlight(ofColor(255,0,0)); - } - - sliders.push_back(slider); - } - - ofxUILabelToggle * butt2 = standardGUI->addLabelToggle("LOCK SYNTH (Y)", false); - butt2->setColorFill(ofColor(255,0,0)); - butt2->setColorFillHighlight(ofColor(255,0,0)); - - ofAddListener(standardGUI->newGUIEvent, this, &testApp::standardGUIEvent); - standardGUI->loadSettings(ofxiPhoneGetDocumentsDirectory() + "guiSettings.xml"); - -} -//-------------------------------------------------------------- -void testApp::standardGUIEvent(ofxUIEventArgs &e){ - if(!standardGUIShowing){ - cout << "GUI ERROR"; - return; - } - - if(e.widget->getName() == "LOCK SEQUENCE (X)") + }else if(e.widget->getName() == "LOCK SEQUENCE (X)") { cout << "LOCK SEQUENCE (X)\n"; @@ -252,36 +219,205 @@ yLocked = false; } + + }else if(e.widget->getName() == "START/STOP") + { + + + //pd.startMessage(); + /// pd.addSymbol("hello"); + /// pd.addFloat(1.23); + /// pd.finishList("test"); + }else{ + cout << "GUI error : unknown event recieved\n"; } +} + */ + + +//////////////////////////// +// These functions called from iOS toolbars +//-------------------------------------------------------------- +void testApp::lockSequencerPressed(bool locked){ + theGridView.shiftCentreToSnapped(); + xLocked = locked; + +} +//-------------------------------------------------------------- +void testApp::lockSynthPressed(bool locked){ + theGridView.shiftCentreToSnapped(); + yLocked = locked; + +} +//-------------------------------------------------------------- +void testApp::seqStartStop(bool go){ + if(!go){ //stop + core.pd.startMessage(); + core.pd.addFloat(0); + core.pd.finishMessage("fromOF", "seqStartStop"); + }else { // play + //stopSequencer(); + core.pd.startMessage(); + core.pd.addFloat(1); + core.pd.finishMessage("fromOF", "seqStartStop"); + } +} +//-------------------------------------------------------------- +void testApp::showQuestionnaire(){ + // stop updating / drawing + + // if(eventLogger.questionnaireCompleted) return; + + paused = true; + + //stopSequencer + core.pd.startMessage(); + core.pd.addFloat(0); + core.pd.finishMessage("fromOF", "seqStartStop"); + + questionnaireViewController = [[QuestionnaireViewController alloc] initWithNibName:@"QuestionnaireViewController" bundle:nil]; + [ofxiPhoneGetGLParentView() addSubview:questionnaireViewController.view]; + + [questionnaireViewController setAppRef:(id)this]; + [questionnaireViewController show:(id)this]; + + whichInterfaceShowing = QUESTIONNAIRE; + + +} +//-------------------------------------------------------------- +void testApp::questionnaireHidden(vector answers){ + // send answers to server as json + eventLogger.questionnaireAnswersObtained(answers); + + // set "we've done questionnaire" to true in event logger + paused = false; + + //startSequencer (TODO what about the toggle ? ?) + core.pd.startMessage(); + core.pd.addFloat(1); + core.pd.finishMessage("fromOF", "seqStartStop"); + whichInterfaceShowing = BOTH; + // tell bottomtabviewcontroller + +} +//-------------------------------------------------------------- +void testApp::showIntro(){ + paused = true; + consentGiven = false; + cout << "SHOW INTRO\n"; + + introViewController = [[IntroViewController alloc] initWithNibName:@"IntroViewController" bundle:nil]; + [ofxiPhoneGetGLParentView() addSubview:introViewController.view]; + + [introViewController setAppRef:(id)this]; + [introViewController show:(id)this]; + + + whichInterfaceShowing = INTRO; + +} +//-------------------------------------------------------------- +void testApp::introHidden(bool OK){ + if(OK){ + paused = false; + consentGiven = true; + whichInterfaceShowing = BOTH; + } + // no unOK +} +//-------------------------------------------------------------- +// called from BottomTabViewController iOS segmented thing +void testApp::interfaceSelected(int which){ + switch (which){ + case 0: + + whichInterfaceShowing = SLIDERS; + sliderGUI->setVisible(true); + // set the slider values to stuff got from zoomer + sliderVals = theGridView.getParams(); + setAllGUISliders(sliderVals); + break; + case 1: + + whichInterfaceShowing = BOTH; + sliderGUI->setVisible(true); + // set the slider values to stuff got from zoomer + sliderVals = theGridView.getParams(); + setAllGUISliders(sliderVals); + break; + case 2: + + sliderGUI->setVisible(false); + whichInterfaceShowing = ZOOMER; + break; + } + +} +//-------------------------------------------------------------- +//-------------------------------------------------------------- +void testApp::setupSliderGui(){ + float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; + float length = SLIDER_GUI_WIDTH - (OFX_UI_GLOBAL_WIDGET_SPACING*2); + + + //float dim = 42; + + // make this iphone size...? + int height = 480; + int width = 320; + float dim = (height-10.0*OFX_UI_GLOBAL_WIDGET_SPACING)/10.0; + // LEFT GUI + sliderGUI = new ofxUICanvas(0,100,SLIDER_GUI_WIDTH,getHeight()); + + // Uh.. loop this + for(int i = 1; i<=10;i++){ + + ofxUISlider *slider; + slider = (ofxUISlider *)sliderGUI->addWidgetDown(new ofxUISlider(width,dim,0.0,127,64,sliderParamNames[i-1])); + slider->setDrawPadding(true); + if(i <= 5){ + slider->setColorFill(ofColor(0,0,255)); + slider->setColorFillHighlight(ofColor(0,0,255)); + }else{ + slider->setColorFill(ofColor(255,0,0)); + slider->setColorFillHighlight(ofColor(255,0,0)); + } + + sliders.push_back(slider); + } + + + + ofAddListener(sliderGUI->newGUIEvent, this, &testApp::sliderGUIEvent); + +} +//-------------------------------------------------------------- +void testApp::sliderGUIEvent(ofxUIEventArgs &e){ + if(whichInterfaceShowing == ZOOMER){ + cout << "GUI ERROR"; + return; + } + // "normal" parameter changes for(int i = 1; i<=10;i++){ - stringstream ss; - ss << "P" << i; - string p = ss.str(); - if(e.widget->getName() == p) + if(e.widget->getName() == sliderParamNames[i-1]) { //cout << "param change: " << p; ofxUISlider *slider = (ofxUISlider *) e.widget; sliderMoved(i-1,slider->getScaledValue()); // internal array 0 indexed - - - } } - - // TODO reflect these changes in zoomer view? Or only when switching? - + } //-------------------------------------------------------------- void testApp::sliderMoved(int which, float value){ // an update caused by slider view being touched sliderVals[which] = (int)value; theGridView.setParams(sliderVals); - - // TODO if <5 do frequencer stuff and send list to PD - // if > 5 send control value to PD + sendParametersToPD(); eventLogger.logEvent(CHANGE_SLIDER, TwoVector(),0.0,which , value); @@ -343,7 +479,6 @@ // continiue to move at velocity, unless snapped if (numActiveTouches == 0){ // no touches, use momentum - // TODO set velocity to 0 when hits walls if(moveVel.norm() > 0.3){ if(theGridView.snapped){ @@ -394,32 +529,38 @@ //-------------------------------------------------------------- void testApp::draw(){ if(paused) return; - if (standardGUIShowing){// ? - ofSetColor(57, 57, 57,200); - ofRect(0,0,getWidth(),getHeight()); + + switch (whichInterfaceShowing){ + case SLIDERS: + break; + case ZOOMER: + theGridView.draw(); + break; + case BOTH: + + theGridView.draw(); + break; + case INTRO: + break; + + case QUESTIONNAIRE: + break; + } - theGridView.draw(); -} - -//-------------------------------------------------------------- -void testApp::exit(){ - presetManager.exitAndSaveAll(); - eventLogger.exitAndSave(); - core.exit(); - - delete standardGUI; - delete zoomGUI; - cout << "exit done \n"; } //-------------------------------------------------------------- void testApp::touchDown(ofTouchEventArgs &touch){ - if(standardGUIShowing){ - // check if in GUI area - if(touch.x < 256) return; - } + + // TODO check if in gui area!!! + if(whichInterfaceShowing == SLIDERS){ + return; + }else if (whichInterfaceShowing == BOTH && touch.x < (SLIDER_GUI_WIDTH+10)){ + return; + + }// otherwise we're good to let the zoomer handle touch numActiveTouches++; // absolute position doesn't matter @@ -450,14 +591,15 @@ //-------------------------------------------------------------- void testApp::touchMoved(ofTouchEventArgs &touch){ - //cout << "touch id " << touch.id << "\n"; - //cout << "active touches " << numActiveTouches << "\n"; + // TODO check if in gui area!!! + if(whichInterfaceShowing == SLIDERS){ + return; + }else if (whichInterfaceShowing == BOTH && touch.x < (SLIDER_GUI_WIDTH+10)){ + return; + + }// otherwise we're good to let the zoomer handle touch + - - if(standardGUIShowing){ - // TODO check if in GUI area - if(touch.x < 256) return; - } // check if in other gui area if(touch.x > getWidth()-200 && touch.y < 300){ return; @@ -541,13 +683,14 @@ void testApp::touchUp(ofTouchEventArgs &touch){ if(numActiveTouches > 0) numActiveTouches--; // dirty - if(standardGUIShowing){ - // check if in GUI area - if(touch.x < 256) + // TODO check if in gui area!!! + if(whichInterfaceShowing == SLIDERS){ + return; + }else if (whichInterfaceShowing == BOTH && touch.x < 256){ + return; - return; - } - // check if in + }// otherwise we're good to let the zoomer handle touch + // which one? if(touch.id == 0){ @@ -672,6 +815,22 @@ return y0; } +float ctrlSmoother(float newsamp){ + static float x1,x2,y1,y2; + float x0, y0; + + x0 = newsamp; + + y0 = fB[0]*x0 + fB[1]*x1 + fB[2]*x2 - fA[1]*y1 - fA[2]*y2; + + // shift + x2 = x1; + x1 = x0; + y2 = y1; + y1 = y0; + + return y0; +} //--------------------------------------------------------------- void testApp::sendOscShape(int ctrlin){ @@ -711,9 +870,9 @@ float ctrlout[numcontrols]; string ctrlName[4] = {"lpLev" , "bpLev", "hpLev", "reson"}; float values[3][4] = - {{1., 0., 0., 1}, // 0 - {0., 10., 0., 10}, // 64 - {0., 0., 1., 1}}; // 127 + {{2., 0., 0., 1.}, // 0 + {0., 10., 0., 10.}, // 64 + {0., 0., 1., 1.}}; // 127 float fidx = (numpoints-1)*ctrlin/128.; int idx = floor(fidx); @@ -732,10 +891,14 @@ } //--------------------------------------------------------------- void testApp::sendFiltFreq(int ctrlin){ + // smooth this + float fin = ctrlin; + float fout; + fout = (int)ctrlSmoother(fin); List toPD; toPD.addSymbol("filtFreq"); - toPD.addFloat(ctrlin); + toPD.addFloat(fout); core.pd.sendList("fromOF", toPD); }