Bladeren bron

调音器功能

Steven 2 jaren geleden
bovenliggende
commit
7e72e1703f
15 gewijzigde bestanden met toevoegingen van 234 en 53 verwijderingen
  1. 6 0
      KulexiuForStudent/KulexiuForStudent.xcodeproj/project.pbxproj
  2. 22 0
      KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Home/TuningImage/frequence_right.imageset/Contents.json
  3. BIN
      KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Home/TuningImage/frequence_right.imageset/frequence_right@2x.png
  4. BIN
      KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Home/TuningImage/frequence_right.imageset/frequence_right@3x.png
  5. 37 4
      KulexiuForStudent/KulexiuForStudent/Module/Widget/Controller/ToneTuningViewController.m
  6. 9 9
      KulexiuForStudent/KulexiuForStudent/Module/Widget/Model/TuningFunction/Tuner.swift
  7. 1 1
      KulexiuForStudent/KulexiuForStudent/Module/Widget/View/KSGaugeView/KSGaugeColorView.h
  8. 0 2
      KulexiuForStudent/KulexiuForStudent/Module/Widget/View/KSGaugeView/KSGaugeColorView.m
  9. 17 0
      KulexiuForStudent/KulexiuForStudent/Module/Widget/View/KSGaugeView/KSGaugeSectorView.h
  10. 50 0
      KulexiuForStudent/KulexiuForStudent/Module/Widget/View/KSGaugeView/KSGaugeSectorView.m
  11. 21 7
      KulexiuForStudent/KulexiuForStudent/Module/Widget/View/KSGaugeView/KSGaugeView.m
  12. 5 0
      KulexiuForStudent/KulexiuForStudent/Module/Widget/View/toneTuning/ToneTuningBodyView.h
  13. 22 0
      KulexiuForStudent/KulexiuForStudent/Module/Widget/View/toneTuning/ToneTuningBodyView.m
  14. 43 23
      KulexiuForStudent/KulexiuForStudent/Module/Widget/View/toneTuning/ToneTuningBodyView.xib
  15. 1 7
      KulexiuForStudent/KulexiuForStudent/Module/Widget/View/toneTuning/TuningForkSettingView.m

+ 6 - 0
KulexiuForStudent/KulexiuForStudent.xcodeproj/project.pbxproj

@@ -888,6 +888,7 @@
 		BCD457AF28646B580010B493 /* NoticeSourceModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD457AE28646B580010B493 /* NoticeSourceModel.m */; };
 		BCD886E12907E7AE00BC4EE6 /* KSGaugeView.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD886E02907E7AE00BC4EE6 /* KSGaugeView.m */; };
 		BCD886E42908E69900BC4EE6 /* KSGaugeColorView.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD886E32908E69900BC4EE6 /* KSGaugeColorView.m */; };
+		BCD886E7290A537600BC4EE6 /* KSGaugeSectorView.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD886E6290A537600BC4EE6 /* KSGaugeSectorView.m */; };
 		BCD9294F28F8FCA4006793E4 /* AudioKit in Frameworks */ = {isa = PBXBuildFile; productRef = BCD9294E28F8FCA4006793E4 /* AudioKit */; };
 		BCD9295228F90202006793E4 /* ToneTuningBodyView.m in Sources */ = {isa = PBXBuildFile; fileRef = BCD9295128F90202006793E4 /* ToneTuningBodyView.m */; };
 		BCD9295428F90209006793E4 /* ToneTuningBodyView.xib in Resources */ = {isa = PBXBuildFile; fileRef = BCD9295328F90209006793E4 /* ToneTuningBodyView.xib */; };
@@ -2498,6 +2499,8 @@
 		BCD886E02907E7AE00BC4EE6 /* KSGaugeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KSGaugeView.m; sourceTree = "<group>"; };
 		BCD886E22908E69900BC4EE6 /* KSGaugeColorView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KSGaugeColorView.h; sourceTree = "<group>"; };
 		BCD886E32908E69900BC4EE6 /* KSGaugeColorView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KSGaugeColorView.m; sourceTree = "<group>"; };
+		BCD886E5290A537600BC4EE6 /* KSGaugeSectorView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KSGaugeSectorView.h; sourceTree = "<group>"; };
+		BCD886E6290A537600BC4EE6 /* KSGaugeSectorView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KSGaugeSectorView.m; sourceTree = "<group>"; };
 		BCD9295028F90202006793E4 /* ToneTuningBodyView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ToneTuningBodyView.h; sourceTree = "<group>"; };
 		BCD9295128F90202006793E4 /* ToneTuningBodyView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ToneTuningBodyView.m; sourceTree = "<group>"; };
 		BCD9295328F90209006793E4 /* ToneTuningBodyView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ToneTuningBodyView.xib; sourceTree = "<group>"; };
@@ -6109,6 +6112,8 @@
 			children = (
 				BCD886DF2907E7AE00BC4EE6 /* KSGaugeView.h */,
 				BCD886E02907E7AE00BC4EE6 /* KSGaugeView.m */,
+				BCD886E5290A537600BC4EE6 /* KSGaugeSectorView.h */,
+				BCD886E6290A537600BC4EE6 /* KSGaugeSectorView.m */,
 				BCD886E22908E69900BC4EE6 /* KSGaugeColorView.h */,
 				BCD886E32908E69900BC4EE6 /* KSGaugeColorView.m */,
 			);
@@ -6925,6 +6930,7 @@
 				BC50171227FC0D5600F8BCBC /* SubjectChooseViewController.m in Sources */,
 				2779359727E324A80010E277 /* TZVideoPlayerController.m in Sources */,
 				BC802DBD28BC8E2C0079E350 /* HomeHotLiveCourseView.m in Sources */,
+				BCD886E7290A537600BC4EE6 /* KSGaugeSectorView.m in Sources */,
 				275FA22E27E7356B00CFEA2E /* MineViewController.m in Sources */,
 				BC8A4597283DC33400094BBB /* CAudioUnit.m in Sources */,
 				2779354627E324A60010E277 /* UIView+Animation.m in Sources */,

+ 22 - 0
KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Home/TuningImage/frequence_right.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "frequence_right@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "frequence_right@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Home/TuningImage/frequence_right.imageset/frequence_right@2x.png


BIN
KulexiuForStudent/KulexiuForStudent/Assets.xcassets/Home/TuningImage/frequence_right.imageset/frequence_right@3x.png


+ 37 - 4
KulexiuForStudent/KulexiuForStudent/Module/Widget/Controller/ToneTuningViewController.m

@@ -15,6 +15,9 @@
 #import "TunerSettingView.h"
 #import "KSChoosePicker.h"
 
+//  正确后暂停的时间
+static float correctTime = 0.5;
+
 @interface ToneTuningViewController ()<TunerDelegate>
 
 @property (nonatomic, strong) TuningNavView *navView;
@@ -51,6 +54,11 @@
 // A4 频率
 @property (nonatomic, assign) NSInteger A4Frequence;
 
+/**
+ 上次显示正确的时间
+ */
+@property(nonatomic, assign) NSTimeInterval lastCorrectTime;
+
 @end
 
 @implementation ToneTuningViewController
@@ -173,6 +181,12 @@
 }
 
 - (void)tunerDidUpdate:(Tuner *)tuner output:(TunerOutput *)output {
+//    NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970];
+//    if (fabs(self.lastCorrectTime - currentTime) < correctTime) {
+//        return;
+//    }
+//    self.lastCorrectTime = currentTime;
+
     if (output.amplitude < 0.01) {
         
     }
@@ -181,10 +195,23 @@
         TunerOutput *transferOutput = [tuner getTransferPitchWithA4Frequency:self.A4Frequence toneChangeRate:self.toneChangeRate output:output];
 
         self.plateView.gaugeView.value = (NSInteger)transferOutput.distance;
+        
         self.bodyView.distance = (NSInteger)transferOutput.distance;
         
         // 调整频率后
-
+        float rate = 0.0;
+        if (labs((int)transferOutput.distance) <= 3) {
+            self.bodyView.frequenceCorrect = YES;
+//            rate = 1;
+        }
+        else {
+            self.bodyView.frequenceCorrect = NO;
+//            int distance = abs((int)transferOutput.distance) > 50 ? 50 : abs((int)transferOutput.distance);
+//            rate = (50.0 - distance) / 50;
+        }
+        int distance = abs((int)transferOutput.distance) > 50 ? 50 : abs((int)transferOutput.distance);
+        rate = (50.0 - distance) / 50;
+        self.bodyView.rateFrequence = rate;
         if (self.isTransfer == NO) {
             
             self.bodyView.nomalPitch.text = output.pitch;
@@ -200,7 +227,6 @@
             self.bodyView.pitchFrequenceLabel.text = [NSString stringWithFormat:@"%@%zd:%.0fHz", transferOutput.transferPitch, transferOutput.transferOctave, transferOutput.frequency];
             self.bodyView.preFrequence.text = [NSString stringWithFormat:@"%@%zd",transferOutput.prePitch, transferOutput.preOctave];
             self.bodyView.nextFrequence.text = [NSString stringWithFormat:@"%@%zd",transferOutput.nextPitch, transferOutput.nextOctave];
-            
         }
     }
     NSLog(@"-------- %@%zd --- distance :%f frequence : %f" , output.pitch, output.octave, output.distance, output.frequency);
@@ -291,7 +317,13 @@
                     [weakSelf stopForkPlay];
                 }
                 else {
-                    [weakSelf startForkPlay];
+                    if (weakSelf.forkManager.isPlay) {
+                        CGFloat changefrequence = frequence / 440.0 * self.A4Frequence;
+                        [weakSelf.forkManager changeFrequenceWithFrequence:changefrequence];
+                    }
+                    else {
+                        [weakSelf startForkPlay];
+                    }
                 }
             }
         }];
@@ -359,7 +391,8 @@
 
 - (NSArray *)picthRateArray {
     if (!_picthRateArray) {
-        _picthRateArray = @[@0,@-2,@-9,@-2,@0,@-12,@-2,@0,@5,@-2,@0,@-2];
+//        _picthRateArray = @[@0,@-2,@-9,@-2,@0,@-12,@-2,@0,@-7,@-2,@0,@-2];
+        _picthRateArray = @[@0,@-10,@-3,@-10,@0,@-12,@-10,@0,@-5,@-10,@0,@-10];
     }
     return _picthRateArray;
 }

+ 9 - 9
KulexiuForStudent/KulexiuForStudent/Module/Widget/Model/TuningFunction/Tuner.swift

@@ -241,7 +241,7 @@ private let frequencies: [Float] = [
         output.frequency = frequency
         output.amplitude = amplitude
         output.distance = frequency - frequencies[i]
-        output.pitch = String(format: "%@", sharps[i % sharps.count], flats[i % flats.count])
+        output.pitch = String(format: "%@", flats[i % flats.count], sharps[i % sharps.count])
         
         var index = i-1
         if i == 0 {
@@ -251,17 +251,17 @@ private let frequencies: [Float] = [
         }
         
         output.preOctave = (index) / 12
-        output.prePitch = String(format: "%@", sharps[(index) % sharps.count], flats[(index) % flats.count])
+        output.prePitch = String(format: "%@", flats[(index) % flats.count], sharps[(index) % sharps.count])
 
         output.nextOctave = (index+2) / 12
-        output.nextPitch = String(format: "%@", sharps[(index+2) % sharps.count], flats[(index+2) % flats.count])
+        output.nextPitch = String(format: "%@", flats[(index+2) % flats.count], sharps[(index+2) % sharps.count])
         return output
     }
     
     @objc public func getTransferPitch(A4Frequency: Float, toneChangeRate: Int, output: TunerOutput)->TunerOutput {
         let newOutput = TunerOutput()
-        // 将收到的频率转成 440hz频率后对比
-        var norm = output.frequency / A4Frequency * 440;
+        
+        var norm = output.frequency
         while norm > frequencies[frequencies.count - 1] {
             norm = norm / 2.0
         }
@@ -289,17 +289,17 @@ private let frequencies: [Float] = [
         newOutput.octave = output.octave
         newOutput.frequency = output.frequency
         newOutput.amplitude = output.amplitude
-        newOutput.distance = output.frequency / A4Frequency * 440 - frequencies[i]
+        newOutput.distance = output.frequency / A4Frequency * 440 - frequencies[i] // 将收到的频率转成 440hz频率后对比
         newOutput.pitch = output.pitch
         
         newOutput.preOctave = (index) / 12
-        newOutput.prePitch = String(format: "%@", sharps[(index) % sharps.count], flats[(index) % flats.count])
+        newOutput.prePitch = String(format: "%@", flats[(index) % flats.count],sharps[(index) % sharps.count])
         
         newOutput.nextOctave = (index+2) / 12
-        newOutput.nextPitch = String(format: "%@", sharps[(index+2) % sharps.count], flats[(index+2) % flats.count])
+        newOutput.nextPitch = String(format: "%@", flats[(index+2) % flats.count],sharps[(index+2) % sharps.count])
         // 移调之后的显示
         newOutput.transferOctave = (index+1) / 12
-        newOutput.transferPitch = String(format: "%@", sharps[(index+1) % sharps.count], flats[(index+1) % flats.count])
+        newOutput.transferPitch = String(format: "%@", flats[(index+1) % flats.count],sharps[(index+1) % sharps.count])
         return newOutput
     }
     

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/KSGaugeView/KSGaugeColorView.h

@@ -8,7 +8,7 @@
 #import <UIKit/UIKit.h>
 
 NS_ASSUME_NONNULL_BEGIN
-
+// 渐变色区域
 @interface KSGaugeColorView : UIView
 
 @end

+ 0 - 2
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/KSGaugeView/KSGaugeColorView.m

@@ -16,8 +16,6 @@
 
 - (void)drawRoundRect:(CGRect)rect context:(CGContextRef)context {
     // 1. 还是添加一个圆弧路径
-    //获取图形上下文
-//    CGContextRef context = UIGraphicsGetCurrentContext();
     //设置线的宽度
     CGContextSetLineWidth(context, 18.0f);
     //设置圆环线条的两个端点做圆滑处理

+ 17 - 0
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/KSGaugeView/KSGaugeSectorView.h

@@ -0,0 +1,17 @@
+//
+//  KSGaugeSectorView.h
+//  KulexiuForStudent
+//
+//  Created by 王智 on 2022/10/27.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+// 扇形区域
+@interface KSGaugeSectorView : UIView
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 50 - 0
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/KSGaugeView/KSGaugeSectorView.m

@@ -0,0 +1,50 @@
+//
+//  KSGaugeSectorView.m
+//  KulexiuForStudent
+//
+//  Created by 王智 on 2022/10/27.
+//
+
+#import "KSGaugeSectorView.h"
+
+#define DEGREES_TO_RADIANS(degrees) (degrees) / 180.0 * M_PI
+
+@implementation KSGaugeSectorView
+
+- (void)drawRect:(CGRect)rect {
+    CGContextRef context = UIGraphicsGetCurrentContext();
+    [self drawColorView:rect context:context];
+}
+
+- (void)drawColorView:(CGRect)rect context:(CGContextRef)context {
+    //设置圆心
+    CGFloat originX = rect.size.width / 2.0f;
+    CGFloat originY = (rect.size.height - 25);
+    //计算半径
+    CGFloat radius = originY - 18 / 2.0f - 38;
+    // 设置起始点
+    CGContextMoveToPoint(context, originX, originY);
+
+    //逆时针画一个圆弧
+    CGContextAddArc(context, originX, originY, radius, DEGREES_TO_RADIANS(-72), DEGREES_TO_RADIANS(-108), YES);
+
+    
+    CGContextSetFillColorWithColor(context, HexRGBAlpha(0x6DB7FF, 0.25).CGColor);
+    
+    CGContextFillPath(context);
+}
+
+- (CGPoint)calcCicleCoordinateWithCenter:(CGPoint)centerPoint angle:(CGFloat)angle radius:(CGFloat)radius {
+    CGFloat positionX = radius * cosf(angle*M_PI/180);
+    CGFloat positionY = radius * sinf(angle*M_PI/180);
+    return CGPointMake(centerPoint.x + positionX, centerPoint.y-positionY);
+}
+/*
+// Only override drawRect: if you perform custom drawing.
+// An empty implementation adversely affects performance during animation.
+- (void)drawRect:(CGRect)rect {
+    // Drawing code
+}
+*/
+
+@end

+ 21 - 7
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/KSGaugeView/KSGaugeView.m

@@ -7,6 +7,7 @@
 
 #import "KSGaugeView.h"
 #import "KSGaugeColorView.h"
+#import "KSGaugeSectorView.h"
 
 /* Degrees to radians conversion macro */
 #define DEGREES_TO_RADIANS(degrees) (degrees) / 180.0 * M_PI
@@ -47,14 +48,24 @@
     _maxValue = 50.0;
     _minValue = -50.0;
     _scaleDivisions = 10;
-    _scaleSubdivisions = 5;
+    _scaleSubdivisions = 10;
     _scaleDivisionsWidth = 2;
     _scaleDivisionsLength = 15;
     _scaleSubdivisionsWidth = 1;
-    _scaleSubdivisionsLength = 5;
+    _scaleSubdivisionsLength = 8;
     [self initScale];
+    [self addShaperView];
     [self addColorView];
 }
+// 添加扇形区域
+- (void)addShaperView {
+    KSGaugeSectorView *sectorView = [[KSGaugeSectorView alloc] init];
+    sectorView.backgroundColor = [UIColor clearColor];
+    [self addSubview:sectorView];
+    [sectorView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.bottom.left.right.mas_equalTo(self);
+    }];
+}
 
 - (void)addColorView {
     KSGaugeColorView *colorView = [[KSGaugeColorView alloc] init];
@@ -84,10 +95,13 @@
     [self drawDevision:rect context:context];
 
     // 绘制指针
-    rootNeedleLayer = [CALayer new];
-    // For performance puporse, the needle layer is not scaled to [0-1] range
-    rootNeedleLayer.frame = CGRectMake(0, 40, rect.size.width, (originY - 40) * 2);
-    [self.layer addSublayer:rootNeedleLayer];
+    if (![self.layer.sublayers containsObject:rootNeedleLayer]) {
+        rootNeedleLayer = [CALayer new];
+        // For performance puporse, the needle layer is not scaled to [0-1] range
+        rootNeedleLayer.frame = CGRectMake(0, 40, rect.size.width, (originY - 40) * 2);
+        [self.layer addSublayer:rootNeedleLayer];
+    }
+    
     [self drawNeedle:rect context:context];
 }
 
@@ -191,7 +205,7 @@
         }
         else {
             // Initialize Core Graphics settings
-            UIColor *color = HexRGBAlpha(0x2dc7aa, 0.2);
+            UIColor *color = HexRGBAlpha(0x2dc7aa, 0.5);
             CGContextSetStrokeColorWithColor(context, color.CGColor);
             CGContextSetLineWidth(context, _scaleSubdivisionsWidth);
             CGContextMoveToPoint(context, center.x, y1);

+ 5 - 0
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/toneTuning/ToneTuningBodyView.h

@@ -57,6 +57,11 @@ NS_ASSUME_NONNULL_BEGIN
 // 偏移
 @property (nonatomic, assign) NSInteger distance;
 
+// 频率是否正常
+@property (nonatomic, assign) BOOL frequenceCorrect;
+
+@property (nonatomic, assign) CGFloat rateFrequence;
+
 + (instancetype)shareInstance;
 
 - (void)tuningViewAction:(TuningActionCallback)callback;

+ 22 - 0
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/toneTuning/ToneTuningBodyView.m

@@ -20,7 +20,10 @@
 @property (weak, nonatomic) IBOutlet UIButton *playButton;
 @property (weak, nonatomic) IBOutlet UILabel *distanceLabel;
 
+@property (weak, nonatomic) IBOutlet UIImageView *rightImage;
+
 @property (nonatomic, copy) TuningActionCallback callback;
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *lineWidth;
 
 @end
 
@@ -133,6 +136,25 @@
     _distance = distance;
     self.distanceLabel.text = [NSString stringWithFormat:@"%zd¢", distance];
 }
+
+- (void)setFrequenceCorrect:(BOOL)frequenceCorrect {
+    _frequenceCorrect = frequenceCorrect;
+    if (frequenceCorrect) {
+        self.rightImage.hidden = NO;
+    }
+    else {
+        self.rightImage.hidden = YES;
+    }
+}
+
+- (void)setRateFrequence:(CGFloat)rateFrequence {
+    _rateFrequence = rateFrequence;
+    [UIView animateWithDuration:0.8 animations:^{
+        self.lineWidth.constant = (kScreenWidth - 50) * rateFrequence;
+    } completion:^(BOOL finished) {
+
+    }];
+}
 /*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.

+ 43 - 23
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/toneTuning/ToneTuningBodyView.xib

@@ -4,7 +4,6 @@
     <dependencies>
         <deployment identifier="iOS"/>
         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
-        <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -37,14 +36,17 @@
                     </constraints>
                 </imageView>
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Zrx-Pe-2NT">
-                    <rect key="frame" x="25" y="84" width="340" height="170"/>
+                    <rect key="frame" x="15" y="79" width="360" height="180"/>
                     <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     <constraints>
                         <constraint firstAttribute="width" secondItem="Zrx-Pe-2NT" secondAttribute="height" multiplier="2:1" id="J6J-6P-lDY"/>
                     </constraints>
                 </view>
+                <imageView hidden="YES" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="frequence_right" translatesAutoresizingMaskIntoConstraints="NO" id="dOO-kx-vvP">
+                    <rect key="frame" x="180" y="144" width="30" height="30"/>
+                </imageView>
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9aU-LL-Lsq">
-                    <rect key="frame" x="155" y="194" width="80" height="80"/>
+                    <rect key="frame" x="155" y="199" width="80" height="80"/>
                     <subviews>
                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0¢" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D7p-nE-fr1">
                             <rect key="frame" x="20.666666666666657" y="24.666666666666657" width="39" height="31"/>
@@ -166,9 +168,13 @@
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZeX-qM-LJD">
                     <rect key="frame" x="14" y="380" width="362" height="170"/>
                     <subviews>
-                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="A#" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uIc-iL-EXg">
-                            <rect key="frame" x="155" y="56" width="52" height="46"/>
-                            <fontDescription key="fontDescription" type="boldSystem" pointSize="38"/>
+                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uIc-iL-EXg">
+                            <rect key="frame" x="148.66666666666666" y="56" width="65" height="50"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="50" id="CLE-2e-wuG"/>
+                                <constraint firstAttribute="width" constant="65" id="eee-My-kgb"/>
+                            </constraints>
+                            <fontDescription key="fontDescription" type="boldSystem" pointSize="40"/>
                             <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                             <nil key="highlightedColor"/>
                         </label>
@@ -177,10 +183,15 @@
                             <subviews>
                                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="i3w-7a-0hL">
                                     <rect key="frame" x="0.0" y="0.0" width="0.0" height="5"/>
-                                    <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                    <color key="backgroundColor" red="0.0" green="1" blue="0.81176470588235294" alpha="1" colorSpace="calibratedRGB"/>
                                     <constraints>
                                         <constraint firstAttribute="width" id="Ndf-lc-KO2"/>
                                     </constraints>
+                                    <userDefinedRuntimeAttributes>
+                                        <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                            <real key="value" value="2.5"/>
+                                        </userDefinedRuntimeAttribute>
+                                    </userDefinedRuntimeAttributes>
                                 </view>
                             </subviews>
                             <color key="backgroundColor" red="0.1764705882352941" green="0.21176470588235294" blue="0.28235294117647058" alpha="1" colorSpace="calibratedRGB"/>
@@ -190,6 +201,11 @@
                                 <constraint firstItem="i3w-7a-0hL" firstAttribute="top" secondItem="6FP-hm-dfl" secondAttribute="top" id="KB8-r8-QVf"/>
                                 <constraint firstItem="i3w-7a-0hL" firstAttribute="leading" secondItem="6FP-hm-dfl" secondAttribute="leading" id="qxd-Xa-3KK"/>
                             </constraints>
+                            <userDefinedRuntimeAttributes>
+                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                    <real key="value" value="2.5"/>
+                                </userDefinedRuntimeAttribute>
+                            </userDefinedRuntimeAttributes>
                         </view>
                         <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ya5-kp-sTW">
                             <rect key="frame" x="0.0" y="0.0" width="362" height="143"/>
@@ -201,32 +217,34 @@
                                         <constraint firstAttribute="height" constant="23" id="Jad-yu-6YO"/>
                                     </constraints>
                                 </imageView>
-                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="A#" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MNR-s0-re6">
-                                    <rect key="frame" x="68" y="65" width="52" height="53"/>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MNR-s0-re6">
+                                    <rect key="frame" x="55" y="65" width="65" height="53"/>
                                     <constraints>
+                                        <constraint firstAttribute="width" constant="65" id="UZx-8Z-YUR"/>
                                         <constraint firstAttribute="height" constant="53" id="rPI-W9-m7n"/>
                                     </constraints>
-                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="38"/>
+                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="40"/>
                                     <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                     <nil key="highlightedColor"/>
                                 </label>
-                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="C#" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vku-Yz-AEN">
-                                    <rect key="frame" x="242" y="65" width="53" height="53"/>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vku-Yz-AEN">
+                                    <rect key="frame" x="242" y="65" width="65" height="53"/>
                                     <constraints>
+                                        <constraint firstAttribute="width" constant="65" id="J62-5N-w7f"/>
                                         <constraint firstAttribute="height" constant="53" id="vCR-NZ-KzZ"/>
                                     </constraints>
-                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="38"/>
+                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="40"/>
                                     <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                     <nil key="highlightedColor"/>
                                 </label>
                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Concert" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FLn-wI-hyg">
-                                    <rect key="frame" x="71.666666666666671" y="38" width="45" height="17"/>
+                                    <rect key="frame" x="65" y="38" width="45" height="17"/>
                                     <fontDescription key="fontDescription" name="DINAlternate-Bold" family="DIN Alternate" pointSize="14"/>
                                     <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                     <nil key="highlightedColor"/>
                                 </label>
-                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="F# ins." textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tD3-d1-rfd">
-                                    <rect key="frame" x="249" y="38" width="39" height="17"/>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" ins." textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tD3-d1-rfd">
+                                    <rect key="frame" x="262.33333333333331" y="38" width="24.333333333333314" height="17"/>
                                     <fontDescription key="fontDescription" name="DINAlternate-Bold" family="DIN Alternate" pointSize="14"/>
                                     <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                     <nil key="highlightedColor"/>
@@ -290,7 +308,7 @@
                     </constraints>
                 </imageView>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5sT-Eb-2rJ">
-                    <rect key="frame" x="65" y="254" width="0.0" height="14"/>
+                    <rect key="frame" x="55" y="259" width="0.0" height="14"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="14" id="g2f-fr-DrN"/>
                     </constraints>
@@ -299,7 +317,7 @@
                     <nil key="highlightedColor"/>
                 </label>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ke2-CX-K7G">
-                    <rect key="frame" x="325" y="254" width="0.0" height="14"/>
+                    <rect key="frame" x="335" y="259" width="0.0" height="14"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="14" id="Csw-Dx-b3r"/>
                     </constraints>
@@ -322,7 +340,7 @@
                     </constraints>
                 </imageView>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PnS-Ku-vsa">
-                    <rect key="frame" x="195" y="46" width="0.0" height="20"/>
+                    <rect key="frame" x="195" y="41" width="0.0" height="20"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="20" id="2X9-wE-8CN"/>
                     </constraints>
@@ -339,6 +357,7 @@
                 <constraint firstItem="g4h-vE-BMO" firstAttribute="bottom" secondItem="Cai-ev-v5E" secondAttribute="bottom" id="3KO-qD-HZ2"/>
                 <constraint firstItem="p0z-qL-bMm" firstAttribute="top" secondItem="7Em-FC-3EL" secondAttribute="bottom" constant="12" id="4SR-6A-ipm"/>
                 <constraint firstItem="p0z-qL-bMm" firstAttribute="leading" secondItem="Tkl-Cw-Mdz" secondAttribute="trailing" id="5EB-Vw-dj2"/>
+                <constraint firstItem="dOO-kx-vvP" firstAttribute="centerX" secondItem="Zrx-Pe-2NT" secondAttribute="centerX" id="5bg-6Y-rr4"/>
                 <constraint firstItem="Cai-ev-v5E" firstAttribute="leading" secondItem="v4Z-dA-iqI" secondAttribute="trailing" constant="22" id="6b8-ki-CY9"/>
                 <constraint firstItem="Ke2-CX-K7G" firstAttribute="trailing" secondItem="Zrx-Pe-2NT" secondAttribute="trailing" constant="-40" id="6hN-re-nBS"/>
                 <constraint firstItem="7Em-FC-3EL" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="14" id="7ZV-OX-B1b"/>
@@ -364,6 +383,7 @@
                 <constraint firstItem="V2v-I8-jzm" firstAttribute="leading" secondItem="VJU-LE-Pdq" secondAttribute="trailing" constant="22" id="YYc-Q5-aGD"/>
                 <constraint firstItem="IXi-hL-in1" firstAttribute="top" secondItem="Tkl-Cw-Mdz" secondAttribute="bottom" constant="7" id="YgN-1n-xha"/>
                 <constraint firstAttribute="trailing" secondItem="7Em-FC-3EL" secondAttribute="trailing" constant="14" id="a3n-fN-euB"/>
+                <constraint firstItem="dOO-kx-vvP" firstAttribute="firstBaseline" secondItem="Zrx-Pe-2NT" secondAttribute="firstBaseline" constant="65" id="bHF-Ev-tZG"/>
                 <constraint firstItem="g4h-vE-BMO" firstAttribute="leading" secondItem="Cai-ev-v5E" secondAttribute="leading" id="btp-Oe-y1i"/>
                 <constraint firstItem="sZj-ZO-VHR" firstAttribute="centerY" secondItem="Cai-ev-v5E" secondAttribute="centerY" id="cIh-IQ-xRr"/>
                 <constraint firstItem="Tkl-Cw-Mdz" firstAttribute="top" secondItem="7Em-FC-3EL" secondAttribute="bottom" constant="12" id="cJp-sC-nM0"/>
@@ -375,7 +395,7 @@
                 <constraint firstItem="Ux8-2g-RqK" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="10" id="ev8-FX-ve4"/>
                 <constraint firstItem="VJU-LE-Pdq" firstAttribute="leading" secondItem="uwR-ra-cDH" secondAttribute="leading" id="hAr-OA-5ce"/>
                 <constraint firstItem="5sT-Eb-2rJ" firstAttribute="top" secondItem="Zrx-Pe-2NT" secondAttribute="bottom" id="ixH-ow-czJ"/>
-                <constraint firstItem="Zrx-Pe-2NT" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="25" id="lyO-cd-xcJ"/>
+                <constraint firstItem="Zrx-Pe-2NT" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="15" id="lyO-cd-xcJ"/>
                 <constraint firstItem="Sbe-L2-liH" firstAttribute="leading" secondItem="Ux8-2g-RqK" secondAttribute="trailing" constant="5" id="meC-LK-DKS"/>
                 <constraint firstItem="g4h-vE-BMO" firstAttribute="top" secondItem="Cai-ev-v5E" secondAttribute="top" id="nxA-Si-aiG"/>
                 <constraint firstItem="7Em-FC-3EL" firstAttribute="trailing" secondItem="ZeX-qM-LJD" secondAttribute="trailing" id="oKn-54-J78"/>
@@ -393,6 +413,7 @@
                 <outlet property="addButton" destination="VJU-LE-Pdq" id="Ap2-3f-er6"/>
                 <outlet property="addView" destination="uwR-ra-cDH" id="aTz-zS-V4w"/>
                 <outlet property="distanceLabel" destination="D7p-nE-fr1" id="36B-jL-Pga"/>
+                <outlet property="lineWidth" destination="Ndf-lc-KO2" id="njb-WP-esU"/>
                 <outlet property="minusButton" destination="Cai-ev-v5E" id="7T1-RS-zM3"/>
                 <outlet property="minusView" destination="g4h-vE-BMO" id="SOP-VD-G0z"/>
                 <outlet property="nextFrequence" destination="Ke2-CX-K7G" id="fQM-qB-mxv"/>
@@ -402,6 +423,7 @@
                 <outlet property="plateView" destination="Zrx-Pe-2NT" id="ppk-X8-oX5"/>
                 <outlet property="playButton" destination="p0z-qL-bMm" id="DsB-sp-PJ7"/>
                 <outlet property="preFrequence" destination="5sT-Eb-2rJ" id="YqE-f3-IK2"/>
+                <outlet property="rightImage" destination="dOO-kx-vvP" id="qI5-na-huC"/>
                 <outlet property="transferDesc" destination="tD3-d1-rfd" id="vBI-n9-F5P"/>
                 <outlet property="transferNomalPitch" destination="MNR-s0-re6" id="sVk-tj-gtm"/>
                 <outlet property="transferPitch" destination="vku-Yz-AEN" id="ca0-HH-hao"/>
@@ -416,14 +438,12 @@
         <image name="fork_unchoose" width="42" height="28"/>
         <image name="freguqnce_add" width="14" height="14"/>
         <image name="frequence_minus" width="14" height="14"/>
+        <image name="frequence_right" width="30" height="30"/>
         <image name="plate_bg" width="359" height="254"/>
         <image name="playButton_bg" width="182" height="90"/>
         <image name="toning_bottom" width="338" height="29"/>
         <image name="tuning_decorate" width="48" height="32"/>
         <image name="tuning_transfer" width="20" height="23"/>
         <image name="tuning_warning" width="13" height="12"/>
-        <systemColor name="systemBackgroundColor">
-            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-        </systemColor>
     </resources>
 </document>

+ 1 - 7
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/toneTuning/TuningForkSettingView.m

@@ -75,7 +75,6 @@
         NSInteger index = self.musicalScale * 12 + self.chooseIndex;
         if (self.frequenceArray.count > index) {
             NSInteger frequence = [self.frequenceArray[index] integerValue];
-            frequence = (NSInteger)(frequence * _A4Frequence / 440.0);
             self.callback(frequence,NO);
         }
     }
@@ -88,7 +87,7 @@
 - (void)configDefaultSource {
     self.A4Frequence = 440;
     self.musicalScale = 4;
-    self.isFallingTone = NO;
+    self.isFallingTone = YES;
     self.imageArray = [NSMutableArray arrayWithArray:@[self.pitchCImage,self.pitchDhalfImage,self.pitchDImage,self.pitchEhalfImage,self.pitchEImage,self.pitchFImage,self.pitchGhalfImage,self.pitchGImage,self.pitchAhalfImage,self.pitchAImage,self.pitchBhalfImage,self.pitchBImage]];
     self.chooseIndex = 0;
     self.frequenceArray = [NSMutableArray arrayWithArray:@[
@@ -149,7 +148,6 @@
 
 - (IBAction)pitchChooseAction:(UIButton *)sender {
     NSInteger index = sender.tag - 1000;
-    NSLog(@"----- %zd",index);
     if (self.chooseIndex == index) {
         return;
     }
@@ -164,7 +162,6 @@
         NSInteger index = self.musicalScale * 12 + self.chooseIndex;
         if (self.frequenceArray.count > index) {
             NSInteger frequence = [self.frequenceArray[index] integerValue];
-//            frequence = (NSInteger)(frequence * _A4Frequence / 440.0);
             self.callback(frequence,NO);
         }
     }
@@ -183,7 +180,6 @@
         NSInteger index = self.musicalScale * 12 + self.chooseIndex;
         if (self.frequenceArray.count > index) {
             NSInteger frequence = [self.frequenceArray[index] integerValue];
-//            frequence = (NSInteger)(frequence * _A4Frequence / 440.0);
             self.callback(frequence,NO);
         }
     }
@@ -199,7 +195,6 @@
         NSInteger index = self.musicalScale * 12 + self.chooseIndex;
         if (self.frequenceArray.count > index) {
             NSInteger frequence = [self.frequenceArray[index] integerValue];
-//            frequence = (NSInteger)(frequence * _A4Frequence / 440.0);
             self.callback(frequence,NO);
         }
     }
@@ -212,7 +207,6 @@
         NSInteger index = self.musicalScale * 12 + self.chooseIndex;
         if (self.frequenceArray.count > index) {
             NSInteger frequence = [self.frequenceArray[index] integerValue];
-//            frequence = (NSInteger)(frequence * _A4Frequence / 440.0);
             self.callback(frequence,YES);
         }
     }