Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5dbf267

Browse files
author
Arlin
committed
Add local voice pitch by ios
1 parent 8554e10 commit 5dbf267

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

iOS/APIExample/Common/VideoView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class VideoView: UIView {
3636
@IBOutlet weak var videoView:UIView!
3737
@IBOutlet weak var placeholderLabel:UILabel!
3838
@IBOutlet weak var infoLabel:UILabel!
39+
@IBOutlet weak var pitchLabel: UILabel!
3940
@IBOutlet weak var statsLabel:UILabel!
4041
var audioOnly:Bool = false
4142
var uid:UInt = 0
@@ -65,6 +66,10 @@ class VideoView: UIView {
6566
infoLabel.text = text
6667
}
6768

69+
func setPitch(text:String) {
70+
pitchLabel.text = text
71+
}
72+
6873
override func awakeFromNib() {
6974
super.awakeFromNib()
7075
statsLabel.layer.shadowColor = UIColor.appColor(.textShadow)?.cgColor

iOS/APIExample/Common/VideoView.xib

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
77
<capability name="Named colors" minToolsVersion="9.0"/>
88
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -21,39 +21,48 @@
2121
<color key="textColor" name="videoPlaceholder"/>
2222
<nil key="highlightedColor"/>
2323
</label>
24-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="z6G-aL-Ut4">
25-
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
26-
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
27-
</view>
2824
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2sO-zb-ccE" userLabel="Info">
2925
<rect key="frame" x="394" y="54" width="0.0" height="0.0"/>
3026
<fontDescription key="fontDescription" type="system" pointSize="13"/>
3127
<nil key="textColor"/>
3228
<nil key="highlightedColor"/>
3329
</label>
30+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="L5F-ux-zBn" userLabel="Info">
31+
<rect key="frame" x="394" y="59" width="0.0" height="0.0"/>
32+
<fontDescription key="fontDescription" type="system" pointSize="13"/>
33+
<nil key="textColor"/>
34+
<nil key="highlightedColor"/>
35+
</label>
3436
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tmV-Lc-ye5">
3537
<rect key="frame" x="10" y="852" width="0.0" height="0.0"/>
3638
<fontDescription key="fontDescription" type="system" pointSize="9"/>
3739
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
3840
<nil key="highlightedColor"/>
3941
</label>
42+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="z6G-aL-Ut4">
43+
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
44+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
45+
</view>
4046
</subviews>
4147
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
4248
<color key="backgroundColor" name="videoBackground"/>
4349
<constraints>
4450
<constraint firstItem="z6G-aL-Ut4" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" id="65z-Qr-jbs"/>
4551
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="tmV-Lc-ye5" secondAttribute="bottom" constant="10" id="FeW-aO-BeS"/>
52+
<constraint firstItem="L5F-ux-zBn" firstAttribute="top" secondItem="2sO-zb-ccE" secondAttribute="bottom" constant="5" id="Fgi-lP-d1q"/>
4653
<constraint firstItem="2sO-zb-ccE" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="10" id="Idv-HE-LBC"/>
4754
<constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="z6G-aL-Ut4" secondAttribute="bottom" id="Kq0-Vn-UTZ"/>
4855
<constraint firstItem="tmV-Lc-ye5" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="10" id="MiJ-sX-qHJ"/>
4956
<constraint firstItem="z6G-aL-Ut4" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="R1u-w9-cbP"/>
5057
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="2sO-zb-ccE" secondAttribute="trailing" constant="20" id="cLx-LC-AQf"/>
58+
<constraint firstItem="L5F-ux-zBn" firstAttribute="trailing" secondItem="2sO-zb-ccE" secondAttribute="trailing" id="qF5-xs-tsI"/>
5159
<constraint firstItem="jNO-yh-cWz" firstAttribute="centerY" secondItem="vUN-kp-3ea" secondAttribute="centerY" id="qPg-FY-TVT"/>
5260
<constraint firstItem="jNO-yh-cWz" firstAttribute="centerX" secondItem="vUN-kp-3ea" secondAttribute="centerX" id="tnR-4i-aTA"/>
5361
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="z6G-aL-Ut4" secondAttribute="trailing" id="vMm-b5-ZoF"/>
5462
</constraints>
5563
<connections>
5664
<outlet property="infoLabel" destination="2sO-zb-ccE" id="P4i-71-J0G"/>
65+
<outlet property="pitchLabel" destination="L5F-ux-zBn" id="JTI-NK-7jm"/>
5766
<outlet property="placeholderLabel" destination="jNO-yh-cWz" id="FTU-Vl-aoH"/>
5867
<outlet property="statsLabel" destination="tmV-Lc-ye5" id="gzG-68-uKf"/>
5968
<outlet property="videoView" destination="z6G-aL-Ut4" id="Jfc-RP-ol4"/>

iOS/APIExample/Examples/Basic/JoinChannelAudio/JoinChannelAudio.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ class JoinChannelAudioMain: BaseViewController {
119119
// enable volume indicator
120120
agoraKit.enableAudioVolumeIndication(200, smooth: 3, report_vad: false)
121121

122+
// enable local voice pitch
123+
agoraKit.enableLocalVoicePitchCallback(200)
124+
122125

123126
// start joining channel
124127
// 1. Users can only see each other after they join the
@@ -253,6 +256,14 @@ extension JoinChannelAudioMain: AgoraRtcEngineDelegate {
253256
}
254257
}
255258

259+
/// Reports local user voice pitch
260+
/// @params pitchInHz pitch with Hz of local user
261+
func rtcEngine(_ engine: AgoraRtcEngineKit, reportLocalVoicePitchFrequency pitchInHz: Int) {
262+
if let audioView = audioViews[0] {
263+
audioView.setPitch(text: "Pitch:\(pitchInHz)")
264+
}
265+
}
266+
256267
/// Reports the statistics of the current call. The SDK triggers this callback once every two seconds after the user joins the channel.
257268
/// @param stats stats struct
258269
func rtcEngine(_ engine: AgoraRtcEngineKit, reportRtcStats stats: AgoraChannelStats) {

0 commit comments

Comments
 (0)