File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Examples/Basic/JoinChannelAudio Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ struct StatisticsInfo {
15
15
var videoStats : AgoraRtcLocalVideoStats ?
16
16
var audioStats : AgoraRtcLocalAudioStats ?
17
17
var audioVolume : UInt ?
18
+ var audioPitch : UInt ?
18
19
}
19
20
20
21
struct RemoteInfo {
@@ -119,6 +120,17 @@ struct StatisticsInfo {
119
120
}
120
121
}
121
122
123
+ mutating func updatePitch( _ pitch: UInt ) {
124
+ switch type {
125
+ case . local( let info) :
126
+ var new = info
127
+ new. audioPitch = pitch
128
+ self . type = . local( new)
129
+ case . remote( _) :
130
+ break
131
+ }
132
+ }
133
+
122
134
func description( audioOnly: Bool ) -> String {
123
135
var full : String
124
136
switch type {
@@ -149,6 +161,9 @@ struct StatisticsInfo {
149
161
if let volume = info. audioVolume {
150
162
results. append ( " Volume: \( volume) " )
151
163
}
164
+ if let pitch = info. audioPitch {
165
+ results. append ( " Pitch: \( pitch) " )
166
+ }
152
167
153
168
if let channelStats = info. channelStats, let audioStats = info. audioStats {
154
169
results. append ( " LM Delay: \( channelStats. lastmileDelay) ms " )
Original file line number Diff line number Diff line change @@ -334,6 +334,8 @@ class JoinChannelAudioMain: BaseViewController {
334
334
agoraKit. setClientRole ( . broadcaster)
335
335
// enable volume indicator
336
336
agoraKit. enableAudioVolumeIndication ( 200 , smooth: 3 , report_vad: true )
337
+ // enable local voice pitch
338
+ agoraKit. enableLocalVoicePitchCallback ( 200 )
337
339
338
340
// start joining channel
339
341
// 1. Users can only see each other after they join the
@@ -485,4 +487,10 @@ extension JoinChannelAudioMain: AgoraRtcEngineDelegate {
485
487
}
486
488
}
487
489
}
490
+
491
+ /// Reports local user voice pitch
492
+ /// @params pitchInHz pitch with Hz of local user
493
+ func rtcEngine( _ engine: AgoraRtcEngineKit , reportLocalVoicePitchFrequency pitchInHz: Int ) {
494
+ videos [ 0 ] . statsInfo? . updatePitch ( UInt ( pitchInHz) )
495
+ }
488
496
}
You can’t perform that action at this time.
0 commit comments