-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoundLevelController.m
66 lines (51 loc) · 1.49 KB
/
SoundLevelController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// SoundLevelController.m
// Sound Level Test
//
// Created by jeff ganyard on 9/5/06.
// Copyright 2006 Bithaus. All rights reserved.
//
#import "SoundLevelController.h"
#import "MetallicSoundLevelView.h"
@implementation SoundLevelController
- (id)init
{
self = [super initWithWindowNibName:@"SoundLevel"];
if (!waveView)
waveView = [[MetallicSoundLevelView alloc] init];
if (!roundView)
roundView = [[MetallicSoundLevelView alloc] init];
return self;
}
- (void)awakeFromNib
{
[waveView setThreshold:[NSNumber numberWithFloat:0.45]];
[waveView setWaveColor:[NSColor whiteColor]];
[waveView setScreenColor:[NSColor blueColor]];
// [self seedSampleArray:[waveView frame]];
[roundView setRound:YES];
[roundView setThreshold:[NSNumber numberWithFloat:0.45]];
[roundView setWaveColor:[NSColor greenColor]];
[roundView setScreenColor:[NSColor blackColor]];
// [self seedSampleArray:[roundView frame]];
NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval: 0.03
target: self
selector: @selector(handleTimer:)
userInfo: nil
repeats: YES];
}
- (void)handleTimer:(NSTimer *)timer
{
float seed = ((float)random()/RAND_MAX);
[waveView addToSampleArray:[NSNumber numberWithFloat:seed]];
[roundView addToSampleArray:[NSNumber numberWithFloat:seed]];
}
- (void)seedSampleArray:(NSRect)rect;
{
int i;
for (i = 0; i < rect.size.width/2; i++) {
[waveView addToSampleArray:[NSNumber numberWithFloat:((float)random()/RAND_MAX)]];
}
}
@end