Repository navigation
Expand file tree
/
Copy pathAppDelegate.m
More file actions
71 lines (55 loc) · 2.14 KB
/
Copy pathAppDelegate.m
File metadata and controls
71 lines (55 loc) · 2.14 KB
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
67
68
69
70
71
//
// AppDelegate.m
// UKSoundRecorder
//
// Created by Uli Kusterer on 14.07.07.
// Copyright 2007 M. Uli Kusterer. All rights reserved.
//
#import "AppDelegate.h"
@implementation AppDelegate
-(void) awakeFromNib
{
[self rebuildDevicesMenu];
[recorder takeOutputFilePathFrom: pathField];
[recorder setDelegate: self];
[recorder setInputDeviceUID: [UKSoundFileRecorder availableInputDevices].firstObject[UKSoundFileRecorderDeviceUID]];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(rebuildDevicesMenu) name: UKSoundFileRecorderAvailableInputDevicesChangedNotification object: recorder];
}
-(void) rebuildDevicesMenu
{
NSString * selectedDeviceUID = recorder.inputDeviceUID;
NSMenu * devicesMenu = [devicePopUp menu];
[devicesMenu removeAllItems];
for( NSDictionary<NSString*,NSString*> * deviceEntry in [UKSoundFileRecorder availableInputDevices] )
{
NSMenuItem * newItem = [[NSMenuItem alloc] initWithTitle: deviceEntry[UKSoundFileRecorderDeviceName] action: NULL keyEquivalent: @""];
NSString * currentDeviceUID = deviceEntry[UKSoundFileRecorderDeviceUID];
newItem.representedObject = currentDeviceUID;
[devicesMenu addItem: newItem];
if( [selectedDeviceUID isEqualToString: currentDeviceUID] )
[devicePopUp selectItem: newItem];
}
}
-(IBAction) devicePopUpSelectionChanged: (id)sender
{
NSMenuItem * selectedItem = devicePopUp.selectedItem;
NSString * deviceUID = selectedItem.representedObject;
[recorder setInputDeviceUID: deviceUID];
}
-(void) soundFileRecorderWasStarted: (UKSoundFileRecorder*)sender
{
[statusField setStringValue: [NSString stringWithFormat: @"Recording from %@...", recorder.inputDeviceName]];
}
-(void) soundFileRecorder: (UKSoundFileRecorder*)sender reachedDuration: (NSTimeInterval)timeInSeconds
{
[statusField setStringValue: [NSString stringWithFormat: @"%ld Seconds...", lroundf(timeInSeconds)]];
}
-(void) soundFileRecorder: (UKSoundFileRecorder*)sender hasAmplitude: (float)level
{
[levelField setStringValue: [NSString stringWithFormat: @"%f", level]];
}
-(void) soundFileRecorderWasStopped: (UKSoundFileRecorder*)sender
{
[statusField setStringValue: @"Ready."];
}
@end