Debian Codegraph @

iOS/Csound iOS Obj-C Examples/csound-iOS/classes/bindings/ui/CsoundUI.m

raw
1 /*
2
3 CsoundUI.m:
4
5 Copyright (C) 2014 Steven Yi, Victor Lazzarini, Aurelius Prochazka
6
7 This file is part of Csound iOS Examples.
8
9 The Csound for iOS Library is free software; you can redistribute it
10 and/or modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 Csound is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with Csound; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 02111-1307 USA
23
24 */
25
26 #import "CsoundUI.h"
27
28 #import "CsoundButtonBinding.h"
29 #import "CsoundLabelBinding.h"
30 #import "CsoundMomentaryButtonBinding.h"
31 #import "CsoundSliderBinding.h"
32 #import "CsoundSwitchBinding.h"
33
34 @interface CsoundUI () {
35 CsoundObj *csoundObj;
36 }
37 @end
38
39 @implementation CsoundUI
40
41 - (instancetype)initWithCsoundObj:(CsoundObj *)csound {
42 self = [super init];
43 if (self) {
44 csoundObj = csound;
45 }
46 return self;
47 }
48
49
50 - (void)addLabel:(UILabel *)uiLabel
51 forChannelName:(NSString *)channelName
52 {
53 CsoundLabelBinding *labelBinding;
54 labelBinding = [[CsoundLabelBinding alloc] initLabel:uiLabel
55 channelName:channelName];
56 if(!_labelPrecision) {
57 _labelPrecision = 8;
58 }
59
60 labelBinding.precision = _labelPrecision;
61
62 [csoundObj addBinding:labelBinding];
63 }
64
65
66 - (void)addButton:(UIButton *)uiButton forChannelName:(NSString *)channelName
67 {
68 CsoundButtonBinding *buttonBinding;
69 buttonBinding = [[CsoundButtonBinding alloc] initButton:uiButton
70 channelName:channelName];
71 [csoundObj addBinding:buttonBinding];
72 }
73
74 - (void)addSlider:(UISlider *)uiSlider forChannelName:(NSString *)channelName
75 {
76 CsoundSliderBinding *sliderBinding;
77 sliderBinding = [[CsoundSliderBinding alloc] initSlider:uiSlider
78 channelName:channelName];
79 [csoundObj addBinding:sliderBinding];
80 }
81
82 - (void)addSwitch:(UISwitch *)uiSwitch forChannelName:(NSString *)channelName
83 {
84 CsoundSwitchBinding *switchBinding;
85 switchBinding = [[CsoundSwitchBinding alloc] initSwitch:uiSwitch
86 channelName:channelName];
87 [csoundObj addBinding:switchBinding];
88 }
89
90 - (void)addMomentaryButton:(UIButton *)uiButton forChannelName:(NSString *)channelName
91 {
92 CsoundMomentaryButtonBinding *momentaryButtonBinding;
93 momentaryButtonBinding = [[CsoundMomentaryButtonBinding alloc] initButton:uiButton
94 channelName:channelName];
95 [csoundObj addBinding:momentaryButtonBinding];
96 }
97
98
99 @end