Permalink
Browse files

Made pops dissapear on slider 1

  • Loading branch information...
1 parent 733a24b commit 0f45300ebd6313246719f0e114b3b12f296ef12a @coryalder committed Nov 30, 2010
Showing with 17 additions and 3 deletions.
  1. +4 −0 Classes/SineWaverViewController.h
  2. +13 −3 Classes/SineWaverViewController.m
@@ -16,6 +16,9 @@
float fr2;
float fr3;
float fr4;
+
+ float t_fr1;
+
UILabel *LB1;
}
@@ -33,6 +36,7 @@
@property float fr2;
@property float fr3;
@property float fr4;
+@property float t_fr1;
@end
@@ -27,6 +27,7 @@ OSStatus playbackCallback(void *inRefCon,
SineWaverViewController *me = (SineWaverViewController *)inRefCon;
static int phase = 1;
+ static int phase1 = 1;
for(UInt32 i = 0; i < ioData->mNumberBuffers; i++) {
@@ -36,14 +37,22 @@ OSStatus playbackCallback(void *inRefCon,
float waves;
float volume=.5;
+ float wave1;
for(int j = 0; j < samples; j++) {
waves = 0;
+ wave1 = 0;
+ wave1 = sin(kWaveform * me.fr1 * phase1)*volume;
+ if (0.000001f > wave1) {
+ [me setFr1:me.t_fr1];
+ phase1 = 0;
+ //NSLog(@"switch");
+ }
- waves += sin(kWaveform * me.fr1 * phase)*volume;
+ waves += wave1;
waves += sin(kWaveform * me.fr2 * phase)*volume;
waves += sin(kWaveform * me.fr3 * phase)*volume;
waves += sin(kWaveform * me.fr4 * phase)*volume;
@@ -54,6 +63,7 @@ OSStatus playbackCallback(void *inRefCon,
values[j] += values[j]<<16;
phase++;
+ phase1++;
}
@@ -69,7 +79,7 @@ OSStatus playbackCallback(void *inRefCon,
@implementation SineWaverViewController
-@synthesize fr1, fr2, fr3, fr4, LB1;
+@synthesize fr1, fr2, fr3, fr4, LB1, t_fr1;
/*
@@ -104,7 +114,7 @@ - (void)viewDidLoad {
-(IBAction)valueChanged:(id)sender {
switch ([sender tag]) {
case 1:
- self.fr1 = [(UISlider *)sender value];
+ t_fr1 = [(UISlider *)sender value];
break;
case 2:
self.fr2 = [(UISlider *)sender value];

0 comments on commit 0f45300

Please sign in to comment.