Steven 2 gadi atpakaļ
vecāks
revīzija
f7c8919892

+ 50 - 28
KulexiuForStudent/KulexiuForStudent/Module/Widget/Controller/ToneTuningViewController.m

@@ -14,7 +14,6 @@
 #import <AVFoundation/AVFoundation.h>
 #import <AVFoundation/AVFoundation.h>
 #import "TunerSettingView.h"
 #import "TunerSettingView.h"
 #import "KSChoosePicker.h"
 #import "KSChoosePicker.h"
-//#import "KSGaugeView.h"
 
 
 @interface ToneTuningViewController ()<TunerDelegate>
 @interface ToneTuningViewController ()<TunerDelegate>
 
 
@@ -49,6 +48,9 @@
 
 
 @property (nonatomic, strong) NSArray *picthDescArray;
 @property (nonatomic, strong) NSArray *picthDescArray;
 
 
+// A4 频率
+@property (nonatomic, assign) NSInteger A4Frequence;
+
 @end
 @end
 
 
 @implementation ToneTuningViewController
 @implementation ToneTuningViewController
@@ -64,6 +66,7 @@
 
 
 - (void)configDefault {
 - (void)configDefault {
     self.chooseFrequence = 440;
     self.chooseFrequence = 440;
+    self.A4Frequence = 440;
     self.isTransfer = NO;
     self.isTransfer = NO;
 }
 }
 
 
@@ -94,17 +97,12 @@
     }];
     }];
 
 
     [self.view addSubview:self.bodyView];
     [self.view addSubview:self.bodyView];
-    self.bodyView.A4Frequence = self.chooseFrequence;
+    self.bodyView.A4Frequence = self.A4Frequence;
     [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
     [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.right.mas_equalTo(self.view);
         make.left.right.mas_equalTo(self.view);
         make.top.mas_equalTo(self.navView.mas_bottom);
         make.top.mas_equalTo(self.navView.mas_bottom);
         make.bottom.mas_equalTo(self.view.mas_bottom).offset(-iPhoneXSafeBottomMargin);
         make.bottom.mas_equalTo(self.view.mas_bottom).offset(-iPhoneXSafeBottomMargin);
     }];
     }];
-//    KSGaugeView *gaugeView = [[KSGaugeView alloc] init];
-//    [self.bodyView.plateView addSubview:gaugeView];
-//    [gaugeView mas_makeConstraints:^(MASConstraintMaker *make) {
-//        make.top.bottom.left.right.mas_equalTo(self.bodyView.plateView);
-//    }];
     [self.bodyView.plateView addSubview:self.plateView];
     [self.bodyView.plateView addSubview:self.plateView];
     [self.plateView mas_makeConstraints:^(MASConstraintMaker *make) {
     [self.plateView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.bottom.left.right.mas_equalTo(self.bodyView.plateView);
         make.top.bottom.left.right.mas_equalTo(self.bodyView.plateView);
@@ -179,29 +177,29 @@
         
         
     }
     }
     else {
     else {
-//        if (fabs(output.distance) > 1) {
-            self.plateView.gaugeView.value = (NSInteger)output.distance;
-        self.bodyView.distance = (NSInteger)output.distance;
-//        }
-        
-//        [self.plateView.gaugeView setValue:output.distance animated:YES];
         
         
+        TunerOutput *transferOutput = [tuner getTransferPitchWithA4Frequency:self.A4Frequence toneChangeRate:self.toneChangeRate output:output];
+
+        self.plateView.gaugeView.value = (NSInteger)transferOutput.distance;
+        self.bodyView.distance = (NSInteger)transferOutput.distance;
         
         
         // 调整频率后
         // 调整频率后
-        
+
         if (self.isTransfer == NO) {
         if (self.isTransfer == NO) {
+            
             self.bodyView.nomalPitch.text = output.pitch;
             self.bodyView.nomalPitch.text = output.pitch;
             self.bodyView.pitchFrequenceLabel.text = [NSString stringWithFormat:@"%@%zd:%.0fHz", output.pitch, output.octave, output.frequency];
             self.bodyView.pitchFrequenceLabel.text = [NSString stringWithFormat:@"%@%zd:%.0fHz", output.pitch, output.octave, output.frequency];
             self.bodyView.preFrequence.text = [NSString stringWithFormat:@"%@%zd",output.prePitch, output.preOctave];
             self.bodyView.preFrequence.text = [NSString stringWithFormat:@"%@%zd",output.prePitch, output.preOctave];
             self.bodyView.nextFrequence.text = [NSString stringWithFormat:@"%@%zd",output.nextPitch, output.nextOctave];
             self.bodyView.nextFrequence.text = [NSString stringWithFormat:@"%@%zd",output.nextPitch, output.nextOctave];
         }
         }
         else {
         else {
-            self.bodyView.transferNomalPitch.text = output.pitch;
+            
+            self.bodyView.transferNomalPitch.text = transferOutput.pitch;
             self.bodyView.transferDesc.text = self.settingView.transferPicthDesc;
             self.bodyView.transferDesc.text = self.settingView.transferPicthDesc;
-//            self.bodyView.transferPitch.text = 
-            self.bodyView.pitchFrequenceLabel.text = [NSString stringWithFormat:@"%@%zd:%.0fHz", output.pitch, output.octave, output.frequency];
-            self.bodyView.preFrequence.text = [NSString stringWithFormat:@"%@%zd",output.prePitch, output.preOctave];
-            self.bodyView.nextFrequence.text = [NSString stringWithFormat:@"%@%zd",output.nextPitch, output.nextOctave];
+            self.bodyView.transferPitch.text = [NSString stringWithFormat:@"%@",transferOutput.transferPitch];
+            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];
             
             
         }
         }
     }
     }
@@ -231,9 +229,14 @@
             break;
             break;
         case TUNINGACTION_FREQUENCE: // 调整频率
         case TUNINGACTION_FREQUENCE: // 调整频率
         {
         {
-            self.chooseFrequence = frequence;
+            self.A4Frequence = frequence;
             self.settingView.A4Frequence = frequence;
             self.settingView.A4Frequence = frequence;
             self.tuner.A4Frequence = frequence;
             self.tuner.A4Frequence = frequence;
+            self.forkView.A4Frequence = frequence;
+            if (self.bodyView.isPlaying) {
+                CGFloat changefrequence = frequence / 440.0 * self.chooseFrequence;
+                [self.forkManager changeFrequenceWithFrequence:changefrequence];
+            }
         }
         }
             break;
             break;
         case TUNINGACTION_PLAY:      // 播放音叉
         case TUNINGACTION_PLAY:      // 播放音叉
@@ -252,7 +255,9 @@
 }
 }
 
 
 - (void)startForkPlay {
 - (void)startForkPlay {
-    [self.forkManager setupWithFrequence:self.chooseFrequence];
+    
+    CGFloat changefrequence = self.A4Frequence / 440.0 * self.chooseFrequence;
+    [self.forkManager setupWithFrequence:changefrequence];
 }
 }
 
 
 - (void)stopForkPlay {
 - (void)stopForkPlay {
@@ -273,13 +278,24 @@
         _forkView = [TuningForkSettingView shareInstance];
         _forkView = [TuningForkSettingView shareInstance];
         _forkView.frame = CGRectMake(0, 0, KPortraitWidth, KPortraitHeight);
         _forkView.frame = CGRectMake(0, 0, KPortraitWidth, KPortraitHeight);
         MJWeakSelf;
         MJWeakSelf;
-        [_forkView forkSettingAction:^(NSInteger frequence) {
+        [_forkView forkSettingAction:^(NSInteger frequence, BOOL isSure) {
             NSLog(@"----- frequence %zd", frequence);
             NSLog(@"----- frequence %zd", frequence);
+            
             weakSelf.chooseFrequence = frequence;
             weakSelf.chooseFrequence = frequence;
-            if (weakSelf.forkManager.isPlay) {
-                [weakSelf.forkManager changeFrequenceWithFrequence:frequence];
+            if (weakSelf.bodyView.isPlaying) {
+                CGFloat changefrequence = frequence / 440.0 * self.A4Frequence;
+                [weakSelf.forkManager changeFrequenceWithFrequence:changefrequence];
+            }
+            else {
+                if (isSure) {
+                    [weakSelf stopForkPlay];
+                }
+                else {
+                    [weakSelf startForkPlay];
+                }
             }
             }
         }];
         }];
+
     }
     }
     return _forkView;
     return _forkView;
 }
 }
@@ -294,7 +310,7 @@
 - (TunerSettingView *)settingView {
 - (TunerSettingView *)settingView {
     if (!_settingView) {
     if (!_settingView) {
         _settingView = [TunerSettingView shareInstance];
         _settingView = [TunerSettingView shareInstance];
-        _settingView.A4Frequence = self.chooseFrequence;
+        _settingView.A4Frequence = self.A4Frequence;
         _settingView.frame = CGRectMake(0, 0, KPortraitWidth, KPortraitHeight);
         _settingView.frame = CGRectMake(0, 0, KPortraitWidth, KPortraitHeight);
         MJWeakSelf;
         MJWeakSelf;
         [_settingView tunerSettingAction:^(TUNETSETTING_ACTION action, NSInteger toneChangeRate, NSInteger frequence) {
         [_settingView tunerSettingAction:^(TUNETSETTING_ACTION action, NSInteger toneChangeRate, NSInteger frequence) {
@@ -312,6 +328,7 @@
         self.instrumentPicker = [[KSChoosePicker alloc] initWithTitle:@"" sourceData:self.instrumentArray chooseReturnWithBlock:^(NSString * _Nonnull returnValue, NSInteger chooseIndex) {
         self.instrumentPicker = [[KSChoosePicker alloc] initWithTitle:@"" sourceData:self.instrumentArray chooseReturnWithBlock:^(NSString * _Nonnull returnValue, NSInteger chooseIndex) {
             weakSelf.settingView.instrumentLabel.text = returnValue;
             weakSelf.settingView.instrumentLabel.text = returnValue;
             NSInteger pitchRate = [self.picthRateArray[chooseIndex] integerValue];
             NSInteger pitchRate = [self.picthRateArray[chooseIndex] integerValue];
+            weakSelf.A4Frequence = frequence;
             weakSelf.settingView.toneChangeRate = pitchRate;
             weakSelf.settingView.toneChangeRate = pitchRate;
             weakSelf.settingView.transferPicthDesc = self.picthDescArray[chooseIndex];
             weakSelf.settingView.transferPicthDesc = self.picthDescArray[chooseIndex];
         } cancel:^{
         } cancel:^{
@@ -321,10 +338,15 @@
     }
     }
     else if (action == TUNETSETTING_ACTION_SURE) {
     else if (action == TUNETSETTING_ACTION_SURE) {
         // 设置成功
         // 设置成功
-        self.chooseFrequence = frequence;
+        self.A4Frequence = frequence;
         self.bodyView.A4Frequence = frequence;
         self.bodyView.A4Frequence = frequence;
         self.toneChangeRate = toneChangeRate;
         self.toneChangeRate = toneChangeRate;
         self.tuner.A4Frequence = frequence;
         self.tuner.A4Frequence = frequence;
+        self.forkView.A4Frequence = frequence;
+        if (self.bodyView.isPlaying) {
+            CGFloat changefrequence = frequence / 440.0 * self.chooseFrequence;
+            [self.forkManager changeFrequenceWithFrequence:changefrequence];
+        }
     }
     }
 }
 }
 
 
@@ -337,14 +359,14 @@
 
 
 - (NSArray *)picthRateArray {
 - (NSArray *)picthRateArray {
     if (!_picthRateArray) {
     if (!_picthRateArray) {
-        _picthRateArray = @[@0,@1,@8,@1,@0,@-12,@1,@0,@-5,@1,@0,@1];
+        _picthRateArray = @[@0,@-2,@-9,@-2,@0,@-12,@-2,@0,@5,@-2,@0,@-2];
     }
     }
     return _picthRateArray;
     return _picthRateArray;
 }
 }
 
 
 - (NSArray *)picthDescArray {
 - (NSArray *)picthDescArray {
     if (!_picthDescArray) {
     if (!_picthDescArray) {
-        _picthDescArray = @[@"C ins.",@"B ins.",@"E ins.",@"B ins.",@"C ins.",@"C调大调 ins.",@"B ins.",@"C ins.",@"F ins.",@"C ins.",@"B ins."];
+        _picthDescArray = @[@"C ins.",@"B ins.",@"E ins.",@"B ins.",@"C ins.",@"C调大调 ins.",@"B ins.",@"C ins.",@"F ins.",@"C ins.",@"B ins."];
     }
     }
     return _picthDescArray;
     return _picthDescArray;
 }
 }

+ 55 - 13
KulexiuForStudent/KulexiuForStudent/Module/Widget/Model/TuningFunction/Tuner.swift

@@ -65,23 +65,25 @@ private let frequencies: [Float] = [
     @objc public fileprivate(set) var prePitch: String = ""
     @objc public fileprivate(set) var prePitch: String = ""
     
     
     /**
     /**
-     The octave of the interpreted  mid pitch.
+     The octave of the interpreted  next pitch.
      */
      */
-    @objc public fileprivate(set) var midOctave: Int = 0
+    @objc public fileprivate(set) var nextOctave: Int = 0
+    
     /**
     /**
-     The interpreted mid pitch of the microphone audio.
+     The interpreted next pitch of the microphone audio.
      */
      */
-    @objc public fileprivate(set) var midPitch: String = ""
+    @objc public fileprivate(set) var nextPitch: String = ""
     
     
     /**
     /**
-     The octave of the interpreted  next pitch.
+     The octave of the interpreted  transfer pitch.
      */
      */
-    @objc public fileprivate(set) var nextOctave: Int = 0
+    @objc public fileprivate(set) var transferOctave: Int = 0
     
     
     /**
     /**
-     The interpreted next pitch of the microphone audio.
+     The interpreted transfer pitch of the microphone audio.
      */
      */
-    @objc public fileprivate(set) var nextPitch: String = ""
+    @objc public fileprivate(set) var transferPitch: String = ""
+    
     /**
     /**
      The difference between the frequency of the interpreted pitch and the actual
      The difference between the frequency of the interpreted pitch and the actual
      frequency of the microphone audio.
      frequency of the microphone audio.
@@ -250,15 +252,55 @@ private let frequencies: [Float] = [
         
         
         output.preOctave = (index) / 12
         output.preOctave = (index) / 12
         output.prePitch = String(format: "%@", sharps[(index) % sharps.count], flats[(index) % flats.count])
         output.prePitch = String(format: "%@", sharps[(index) % sharps.count], flats[(index) % flats.count])
-        output.midOctave = (index+1) / 12
-        output.midPitch = String(format: "%@", sharps[(index+1) % sharps.count], flats[(index+1) % flats.count])
+
         output.nextOctave = (index+2) / 12
         output.nextOctave = (index+2) / 12
         output.nextPitch = String(format: "%@", sharps[(index+2) % sharps.count], flats[(index+2) % flats.count])
         output.nextPitch = String(format: "%@", sharps[(index+2) % sharps.count], flats[(index+2) % flats.count])
         return output
         return output
     }
     }
     
     
-//    @objc public func getTransferPitch(frequency: Float, toneChangeRate: Int)-> {
-//       
-//    }
+    @objc public func getTransferPitch(A4Frequency: Float, toneChangeRate: Int, output: TunerOutput)->TunerOutput {
+        let newOutput = TunerOutput()
+        // 将收到的频率转成 440hz频率后对比
+        var norm = output.frequency / A4Frequency * 440;
+        while norm > frequencies[frequencies.count - 1] {
+            norm = norm / 2.0
+        }
+        while norm < frequencies[0] {
+            norm = norm * 2.0
+        }
+        
+        var i = -1
+        var min = Float.infinity
+        for n in 0...frequencies.count-1 {
+            let diff = frequencies[n] - norm
+            if abs(diff) < abs(min) {
+                min = diff
+                i = n
+            }
+        }
+        
+        var index = i-1+toneChangeRate
+        if index <= 0 {
+            index = 0
+        } else if index+2 >= frequencies.count-1 {
+            index = frequencies.count-2
+        }
+        
+        newOutput.octave = output.octave
+        newOutput.frequency = output.frequency
+        newOutput.amplitude = output.amplitude
+        newOutput.distance = output.frequency / A4Frequency * 440 - frequencies[i]
+        newOutput.pitch = output.pitch
+        
+        newOutput.preOctave = (index) / 12
+        newOutput.prePitch = String(format: "%@", sharps[(index) % sharps.count], flats[(index) % flats.count])
+        
+        newOutput.nextOctave = (index+2) / 12
+        newOutput.nextPitch = String(format: "%@", sharps[(index+2) % sharps.count], flats[(index+2) % flats.count])
+        // 移调之后的显示
+        newOutput.transferOctave = (index+1) / 12
+        newOutput.transferPitch = String(format: "%@", sharps[(index+1) % sharps.count], flats[(index+1) % flats.count])
+        return newOutput
+    }
     
     
 }
 }

+ 9 - 9
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/toneTuning/ToneTuningBodyView.xib

@@ -44,10 +44,10 @@
                     </constraints>
                     </constraints>
                 </view>
                 </view>
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9aU-LL-Lsq">
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9aU-LL-Lsq">
-                    <rect key="frame" x="160" y="204" width="70" height="70"/>
+                    <rect key="frame" x="155" y="194" width="80" height="80"/>
                     <subviews>
                     <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">
                         <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="15.666666666666657" y="19.666666666666657" width="39" height="31"/>
+                            <rect key="frame" x="20.666666666666657" y="24.666666666666657" width="39" height="31"/>
                             <fontDescription key="fontDescription" name="DINAlternate-Bold" family="DIN Alternate" pointSize="26"/>
                             <fontDescription key="fontDescription" name="DINAlternate-Bold" family="DIN Alternate" pointSize="26"/>
                             <color key="textColor" red="0.0" green="1" blue="0.81176470588235294" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                             <color key="textColor" red="0.0" green="1" blue="0.81176470588235294" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                             <nil key="highlightedColor"/>
                             <nil key="highlightedColor"/>
@@ -55,14 +55,14 @@
                     </subviews>
                     </subviews>
                     <color key="backgroundColor" red="0.062745098039215685" green="0.074509803921568626" blue="0.094117647058823528" alpha="1" colorSpace="calibratedRGB"/>
                     <color key="backgroundColor" red="0.062745098039215685" green="0.074509803921568626" blue="0.094117647058823528" alpha="1" colorSpace="calibratedRGB"/>
                     <constraints>
                     <constraints>
-                        <constraint firstAttribute="height" constant="70" id="EVn-sM-7ft"/>
+                        <constraint firstAttribute="height" constant="80" id="EVn-sM-7ft"/>
                         <constraint firstItem="D7p-nE-fr1" firstAttribute="centerY" secondItem="9aU-LL-Lsq" secondAttribute="centerY" id="YyQ-A4-OY3"/>
                         <constraint firstItem="D7p-nE-fr1" firstAttribute="centerY" secondItem="9aU-LL-Lsq" secondAttribute="centerY" id="YyQ-A4-OY3"/>
-                        <constraint firstAttribute="width" constant="70" id="gV3-KZ-iAV"/>
+                        <constraint firstAttribute="width" constant="80" id="gV3-KZ-iAV"/>
                         <constraint firstItem="D7p-nE-fr1" firstAttribute="centerX" secondItem="9aU-LL-Lsq" secondAttribute="centerX" id="rVT-76-xxU"/>
                         <constraint firstItem="D7p-nE-fr1" firstAttribute="centerX" secondItem="9aU-LL-Lsq" secondAttribute="centerX" id="rVT-76-xxU"/>
                     </constraints>
                     </constraints>
                     <userDefinedRuntimeAttributes>
                     <userDefinedRuntimeAttributes>
                         <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
                         <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
-                            <real key="value" value="35"/>
+                            <real key="value" value="40"/>
                         </userDefinedRuntimeAttribute>
                         </userDefinedRuntimeAttribute>
                     </userDefinedRuntimeAttributes>
                     </userDefinedRuntimeAttributes>
                 </view>
                 </view>
@@ -290,7 +290,7 @@
                     </constraints>
                     </constraints>
                 </imageView>
                 </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">
                 <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="75" y="254" width="0.0" height="14"/>
+                    <rect key="frame" x="65" y="254" width="0.0" height="14"/>
                     <constraints>
                     <constraints>
                         <constraint firstAttribute="height" constant="14" id="g2f-fr-DrN"/>
                         <constraint firstAttribute="height" constant="14" id="g2f-fr-DrN"/>
                     </constraints>
                     </constraints>
@@ -299,7 +299,7 @@
                     <nil key="highlightedColor"/>
                     <nil key="highlightedColor"/>
                 </label>
                 </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">
                 <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="315" y="254" width="0.0" height="14"/>
+                    <rect key="frame" x="325" y="254" width="0.0" height="14"/>
                     <constraints>
                     <constraints>
                         <constraint firstAttribute="height" constant="14" id="Csw-Dx-b3r"/>
                         <constraint firstAttribute="height" constant="14" id="Csw-Dx-b3r"/>
                     </constraints>
                     </constraints>
@@ -340,7 +340,7 @@
                 <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="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="p0z-qL-bMm" firstAttribute="leading" secondItem="Tkl-Cw-Mdz" secondAttribute="trailing" id="5EB-Vw-dj2"/>
                 <constraint firstItem="Cai-ev-v5E" firstAttribute="leading" secondItem="v4Z-dA-iqI" secondAttribute="trailing" constant="22" id="6b8-ki-CY9"/>
                 <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="-50" id="6hN-re-nBS"/>
+                <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"/>
                 <constraint firstItem="7Em-FC-3EL" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="14" id="7ZV-OX-B1b"/>
                 <constraint firstItem="Cai-ev-v5E" firstAttribute="centerY" secondItem="v4Z-dA-iqI" secondAttribute="centerY" id="8Eb-SN-txF"/>
                 <constraint firstItem="Cai-ev-v5E" firstAttribute="centerY" secondItem="v4Z-dA-iqI" secondAttribute="centerY" id="8Eb-SN-txF"/>
                 <constraint firstItem="IXi-hL-in1" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="Au1-eF-R25"/>
                 <constraint firstItem="IXi-hL-in1" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="Au1-eF-R25"/>
@@ -371,7 +371,7 @@
                 <constraint firstItem="7Em-FC-3EL" firstAttribute="bottom" secondItem="ZeX-qM-LJD" secondAttribute="bottom" id="coV-Qi-RkQ"/>
                 <constraint firstItem="7Em-FC-3EL" firstAttribute="bottom" secondItem="ZeX-qM-LJD" secondAttribute="bottom" id="coV-Qi-RkQ"/>
                 <constraint firstItem="Ux8-2g-RqK" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="22" id="cwN-DO-wkV"/>
                 <constraint firstItem="Ux8-2g-RqK" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="22" id="cwN-DO-wkV"/>
                 <constraint firstItem="VJU-LE-Pdq" firstAttribute="bottom" secondItem="uwR-ra-cDH" secondAttribute="bottom" id="e0m-sL-feH"/>
                 <constraint firstItem="VJU-LE-Pdq" firstAttribute="bottom" secondItem="uwR-ra-cDH" secondAttribute="bottom" id="e0m-sL-feH"/>
-                <constraint firstItem="5sT-Eb-2rJ" firstAttribute="leading" secondItem="Zrx-Pe-2NT" secondAttribute="leading" constant="50" id="eBI-aU-v4Z"/>
+                <constraint firstItem="5sT-Eb-2rJ" firstAttribute="leading" secondItem="Zrx-Pe-2NT" secondAttribute="leading" constant="40" id="eBI-aU-v4Z"/>
                 <constraint firstItem="Ux8-2g-RqK" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="10" id="ev8-FX-ve4"/>
                 <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="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="5sT-Eb-2rJ" firstAttribute="top" secondItem="Zrx-Pe-2NT" secondAttribute="bottom" id="ixH-ow-czJ"/>

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Widget/View/toneTuning/TuningForkSettingView.h

@@ -7,7 +7,7 @@
 
 
 #import <UIKit/UIKit.h>
 #import <UIKit/UIKit.h>
 
 
-typedef void(^ForkSettingCallback)(NSInteger frequence);
+typedef void(^ForkSettingCallback)(NSInteger frequence, BOOL isSure);
 
 
 NS_ASSUME_NONNULL_BEGIN
 NS_ASSUME_NONNULL_BEGIN
 
 

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

@@ -71,6 +71,14 @@
 - (void)showView {
 - (void)showView {
     [[NSObject getKeyWindow] addSubview:self];
     [[NSObject getKeyWindow] addSubview:self];
     [self setPopAnimation];
     [self setPopAnimation];
+    if (self.callback) {
+        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);
+        }
+    }
 }
 }
 
 
 - (void)removeView {
 - (void)removeView {
@@ -152,6 +160,14 @@
     UIImageView *chooseImageView = self.imageArray[index];
     UIImageView *chooseImageView = self.imageArray[index];
     [chooseImageView setImage:[UIImage imageNamed:@"fork_pitchChoosed"]];
     [chooseImageView setImage:[UIImage imageNamed:@"fork_pitchChoosed"]];
     self.chooseIndex = index;
     self.chooseIndex = index;
+    if (self.callback) {
+        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);
+        }
+    }
 }
 }
 
 
 
 
@@ -162,6 +178,15 @@
         return;
         return;
     }
     }
     self.musicalScale++;
     self.musicalScale++;
+    if (self.callback) {
+        // 获取频率
+        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);
+        }
+    }
 }
 }
 // 音阶-
 // 音阶-
 - (IBAction)musicalScaleMinus:(id)sender {
 - (IBAction)musicalScaleMinus:(id)sender {
@@ -169,6 +194,15 @@
         return;
         return;
     }
     }
     self.musicalScale--;
     self.musicalScale--;
+    if (self.callback) {
+        // 获取频率
+        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);
+        }
+    }
 }
 }
 
 
 // 设置保存
 // 设置保存
@@ -178,7 +212,8 @@
         NSInteger index = self.musicalScale * 12 + self.chooseIndex;
         NSInteger index = self.musicalScale * 12 + self.chooseIndex;
         if (self.frequenceArray.count > index) {
         if (self.frequenceArray.count > index) {
             NSInteger frequence = [self.frequenceArray[index] integerValue];
             NSInteger frequence = [self.frequenceArray[index] integerValue];
-            self.callback(frequence);
+//            frequence = (NSInteger)(frequence * _A4Frequence / 440.0);
+            self.callback(frequence,YES);
         }
         }
     }
     }
     [self removeView];
     [self removeView];