Skip to content

Commit

Permalink
fixed patch opening so initial muting is not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich E committed Sep 30, 2012
1 parent 321c6aa commit 102b1ee
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 36 deletions.
30 changes: 15 additions & 15 deletions SlidePad/Classes/Controllers/SlidePadViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ @interface SlidePadViewController ()
@property (nonatomic, retain) QRadioDial *transposeDial;
@property (nonatomic, retain) Fingerboard *fingerboard;
@property (nonatomic, retain) NSArray *patches; // all the base names of synth patches (all contain [throw~])
@property (nonatomic, retain) PdFile *mainPatch;
@property (nonatomic, retain) PdFile *mainPatch; // contains the [catch~] and post effects, global tables

- (void)playTogglePressed:(UIButton *)sender;
- (void)quantizeTogglePressed:(UIButton *)sender;
- (void)sliderChanged:(QSlider *)sender;
- (void)patchSelectorChanged:(UISegmentedControl *)sender;

- (void)openPatchVoicesWithPatchNamed:(NSString *)patchName;
- (UIButton *)newButton;
- (UILabel *)newLabel;
- (void)formatLoadLabel;
Expand Down Expand Up @@ -274,32 +275,22 @@ - (void)quantizeTogglePressed:(UIButton *)sender {
}

- (void)patchSelectorChanged:(UISegmentedControl *)sender {
RLog(@"segment selected: %d", sender.selectedSegmentIndex);
if (sender.selectedSegmentIndex > [self.patches count]) {
RLog(@"Error: patch selector is too large");
return;
}
NSString *patchName = [self.patches objectAtIndex:sender.selectedSegmentIndex];
RLog(@"patch selected: %@", patchName);

NSString *bundlePath = [[NSBundle mainBundle] bundlePath];

if ([patchName isEqualToString:self.polyPatchController.patchName]) {
return;
}

[self.fingerboard mute]; // make sure all voices are silent before switching

// TODO: delay this
if (self.polyPatchController.patchName) {
[self.polyPatchController closePatches];
}

[self.polyPatchController openPatchesNamed:patchName path:bundlePath instances:kSynthNumVoices];

[PdBase sendFloat:kSynthFreqRamptime toReceiver:kSynthFreqRamptimeReceiver];
// make sure all voices are silent before switching
[self.fingerboard mute];

[self.fingerboard mute]; // make sure all voices start with 0 mag
// begin opening patches only after the current patches have finished being muted
[self performSelector:@selector(openPatchVoicesWithPatchNamed:) withObject:patchName afterDelay:kSynthFreqRamptime / 1000.0];
}

#pragma mark - Custom Accessors
Expand All @@ -313,6 +304,15 @@ - (void)setLoadPercentage:(int)loadPercentage {
}
#pragma mark - Private Helpers

- (void)openPatchVoicesWithPatchNamed:(NSString *)patchName {
if (self.polyPatchController.patchName) {
[self.polyPatchController closePatches];
}

[self.polyPatchController openPatchesNamed:patchName path:[[NSBundle mainBundle] bundlePath] instances:kSynthNumVoices];
[PdBase sendFloat:kSynthFreqRamptime toReceiver:kSynthFreqRamptimeReceiver];
}

- (UIButton *)newButton {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.layer.cornerRadius = 8.0;
Expand Down
18 changes: 8 additions & 10 deletions SlidePad/pd/classicsub-voice.pd
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@ license included with Pure Data.;
#X msg 126 94 500;
#X msg 89 92 0.9;
#X obj 55 181 hsl 128 15 0 1 0 0 empty empty empty -2 -8 0 10 -262144
-1 -1 11430 0;
-1 -1 0 0;
#X obj 22 34 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 22 11 loadbang;
#X obj 126 151 s vcf-cutoff;
#X msg 22 91 40;
#X msg 53 91 46;
Expand All @@ -100,21 +99,20 @@ license included with Pure Data.;
#X obj 23 152 s \$0-synth-freq;
#X obj 54 224 s \$0-synth-mag;
#X text 16 268 note: main.pd must be open for this patch to work;
#X connect 0 0 16 0;
#X connect 1 0 10 0;
#X connect 0 0 15 0;
#X connect 1 0 9 0;
#X connect 5 0 1 0;
#X connect 6 0 7 0;
#X connect 7 0 2 0;
#X connect 7 0 17 0;
#X connect 8 0 11 0;
#X connect 7 0 16 0;
#X connect 8 0 10 0;
#X connect 8 0 6 0;
#X connect 8 0 5 0;
#X connect 9 0 8 0;
#X connect 9 0 13 0;
#X connect 8 0 12 0;
#X connect 10 0 0 0;
#X connect 11 0 0 0;
#X connect 12 0 0 0;
#X connect 12 0 13 0;
#X connect 13 0 14 0;
#X connect 14 0 15 0;
#X restore 339 24 pd test;
#X text 19 367 This pd patch has been adapted from pd's own help file
'J08.classicsynth.pd' for use with SlidePad \, an iOS app within the
Expand Down
20 changes: 9 additions & 11 deletions SlidePad/pd/wavetabler-voice.pd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ the pd-for-ios collection \, powered by libpd.;
#X msg 336 67 \; pd dsp 0;
#X obj 22 34 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 22 11 loadbang;
#X msg 22 91 40;
#X msg 53 91 46;
#X msg 229 94 75;
Expand All @@ -34,18 +33,17 @@ the pd-for-ios collection \, powered by libpd.;
#X obj 23 152 s \$0-synth-freq;
#X obj 131 224 s \$0-synth-mag;
#X text 21 267 note: main.pd must be open for this patch to work;
#X connect 0 0 10 0;
#X connect 3 0 5 0;
#X connect 3 0 12 0;
#X connect 4 0 3 0;
#X connect 4 0 7 0;
#X connect 0 0 9 0;
#X connect 3 0 4 0;
#X connect 3 0 11 0;
#X connect 3 0 6 0;
#X connect 4 0 0 0;
#X connect 5 0 0 0;
#X connect 6 0 0 0;
#X connect 6 0 7 0;
#X connect 7 0 8 0;
#X connect 8 0 9 0;
#X connect 12 0 13 0;
#X connect 13 0 11 0;
#X connect 13 0 15 0;
#X connect 11 0 12 0;
#X connect 12 0 10 0;
#X connect 12 0 14 0;
#X restore 290 24 pd test;
#X obj 58 176 tabosc4~ wavetable;
#X obj 57 358 throw~ slidepad-audio;
Expand Down

0 comments on commit 102b1ee

Please sign in to comment.