In my iOS application, using swift
i am getting audio from digital health device (BLE). In the form of audio data, to hear heart beats.
- We apply ADPCM decoder. We receive a little background noise here, that we need to filter. Below is input and output to ADPCM decoder.
Input: byte 136, Output: unsignedDataArray [251, 249]
- We apply IIR filter, to remove background noise. Instead of background noise to be removed, extra uttering noise comes.
Below is a Filter code
func applyFilterToData(decoded: Data) -> Data { // Example usage var lastData = Data() for decodedData in decoded { let unsignedData = UInt8(decodedData) let lowPassUInt8 = iirFilterNew.filter(Double(unsignedData)) lastData.append(lowPassUInt8) filteredDataToShare.append(lastData) self.n = (self.n + 1) % 9 } // Receive UInt8 -> Data return lastData } Applied IIR filter in it, try to filter the noise, but not able to filter the audio properly. utter noise comes.
func filter(_ input: Double) -> UInt8 { // Update input history xHistory.insert(input, at: 0) xHistory.removeLast() // Calculate output var output = b[0] * xHistory[0] for i in 1.. 127.0 { val = 127.0 } if val < -128.0 { val = -128.0 } var signedInt: Int8 = 0 if val.isNaN { signedInt = 0 } else { signedInt = Int8(val) } return UInt8.init(bitPattern: Int8(signedInt)) }
Источник: https://stackoverflow.com/questions/780 ... oise-comes
Мобильная версия