Skip to content

How to get microphone data? #2205

Discussion options

You must be logged in to vote

Simple code:

SWIFT

import Foundation

class AudioCapture: NSObject {
    var audioEngine: AVAudioEngine!
    let audioBridge = AudioBridge()  // Instância da ponte Objective-C++
    
    func startRecording() {
        audioEngine = AVAudioEngine()
        let inputNode = audioEngine.inputNode
        let recordingFormat = inputNode.outputFormat(forBus: 0)

        inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) { (buffer, time) in
            let channelData = buffer.floatChannelData?[0]
            let channelDataValueArray = stride(from: 0, to: Int(buffer.frameLength), by: buffer.stride).map { channelData![$0] }

            let volume = self.calculateVolume(b…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@aismann
Comment options

aismann Oct 9, 2024
Collaborator

@paulocoutinhox
Comment options

@johnspeny
Comment options

@aismann
Comment options

aismann Oct 9, 2024
Collaborator

@aismann
Comment options

aismann Oct 9, 2024
Collaborator

Answer selected by paulocoutinhox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants