How to increase WebRTC AECM Filter length to cater longer echoes? - webrtc

I have been working on echo cancellation on cross-platform smartphones (iOS & Android) clusters in a room. Since the phones in the cluster don't have fixed orientation with respect to the common form which is usually a circular or linear array of phones. The phones are placed randomly in the room.
All phones play the audio in synchronization with accuracy up to 10ms. But the problem is there is an echo (some kind of screeching sound) that doesn't get canceled. I have seen aec dump files and it seems that echoes are longer than the typical window of delay which the webrtc aecm caters with a default filter length of 128ms i.e.
For Android:
low latency phones : 50ms -> [50 ms to 170 ms]
High latency phones: 150ms ->[150ms to 270ms]
For iOS:
Recording latency: 50ms
Playing latency: 50ms
I have rectified webrtc code to use HW AEC in combination with WebRTC AECM but the problem is the echoes are outside these windows.
So how do I increase the filter length?

Related

RightLight technology in Logitech webcams

I note one feature for Logitech webcams - if the RightLight option is turned on in the webcam properties, then output frame rate decreases in two times (1920x1080 with 30 fps -> ~15 fps) for rendering. For test I used DirectShow and the Logitech webcams: c270, c310 and c920.
Any ideas - how to force a webcam to work with 30 fps with RightLight?
RightLight halves the framerate as part of how it functions. You are better off adding another light and turning off Rightlight.

WebRTC : Video black screen bitrate

Is the bit rate of black screen shown when video is muted same as the original video's bit rate or is it significantly less because it is just a black screen?
It is significantly less. Since there is essentially no video information being sent to the remote party. How much depends on a lot of factors (connection quality etc).
I just did a quick test and the outgoing bit rate at 640x480 # 27fps was around 900 kbps to 1 mbps. Disabling the video track of the stream resulted in an outgoing bitrate of 30 kbps.
Please keep in mind that this was only a simple test I did. You can get this kind of information yourself by evaluating the reports in peerConnection.getStats
Some documentation and libraries for getStats
https://www.w3.org/TR/webrtc-stats
https://github.com/muaz-khan/getStats
https://www.callstats.io/2015/07/06/basics-webrtc-getstats-api/
Came across chrome://webrtc-internals, which has inbuilt tracking for bit rates and has other good features.
As seen in graph, bit rate before video was muted was ~150k which reduces to ~30k on muting the video.

iBeacon Monitoring with Unreliable Results (didEnterRegion & didExitRegion)

I'm currently working on an iOS app that ranges and monitors an iBeacon in order to be able to do some actions and receive notifications.
Ranging is working flawlessly, but I'm having troubles with the beacon monitoring and the notifications. I've researched quite a bit about the subject and I'm aware that CoreLocation framework has usually problems like this, but I was wondering how other devs are fixing/approaching this.
Basically, I'm showing local notifications when didEnterRegion and didExitRegion methods are fired. Unfortunately, these two methods are being fired quite often (in an unreliable fashion), even when the iBeacon is right next to it, although sometimes is works perfectly, which makes it more annoying.
I've tried lowering the iBeacon advertising interval, and although it helped, it didn't fix the issue completely. Now, I'm trying with a logic filter where I ignore firing the notification if the enter or exit event happened in the last X minutes (I'm thinking of a 'magic' number between 5 and 15).
Is anyone having the same problems? Would adding a 2nd iBeacon to the situation help? (maybe monitor both of them, and filter logically the exit and enter events based on those two inputs?).
I was also thinking in adding another layer of data to show notifications, maybe based on GPS or Wifi info. Has anyone tried this?
Any other idea? I'm open to any recommendation.
Just in case, I'm using Estimote iBeacons and iOS9 (Objective-c).
Thanks for your time!
Intermittent region exit/entry events are a common problem, and are typically solved with a timer-baded software filter exactly as you suggest. The specifics of how you set up the filter (the minimum time to wait for a re-entry after an exit before processing exit logic) varies for each use case so it is good to have it under your control.
Understand that region exits are caused by iOS not detecting any Bluetooth advertisements from a beacon in the CLBeaconRegion for 30 seconds. If two detected packets are 31 seconds apart, you will get a region exit and then a region entry one second later.
This commonly happens with low signal levels. If an iOS device is on the outer edge of the beacon's transmission range, only a small percentage of packets will be received. With a beacon transmitting at 1Hz, if 30 packets in a row are missed, the iOS device will get an exit event.
There are several things you can do to reduce this problem in a specific area where you want solid coverage:
Turn your beacon transmitter power up to the maximum. This will give stronger signal levels and fewer missed packets in the area you care about.
Turn the advertising rate to the maximum. Advertising at 10 Hz gives 10x as many packets to receive as 1 Hz.
If needed add additional beacons with the same identifier to increase coverage.
Of course, there are costs to the above, including reduced battery life at high advertising rates and transmitter power levels.
Even if you do all of the above, you still need the software filter, because there will always be a point where you are on the edge if the nearest beacon's transmission radius.
You can see an example of software filter code in my answer here.
Beacons emit a pulsing signal. Ranging also performs an intermittent scan (roughly every 100 ms). This means that it is possible for your device to miss beacon for a few seconds in a row, which can cause the results you are experiencing. You can log the beacons RSSI value in this method:
- (void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)iBeacons inRegion:(CLBeaconRegion *)region
I believe you will see a lot of zero values before seeing didExitRegion being called. This isn't a fault in your code, or with the beacon. This just has to do with the fact that neither the signal being emitted or the detection are constant. They are pulsing. These problems can occur while the beacon is just sitting on the same desk as your device, and can be exaggerated in a real world setting when the signals are blocked by physical objects and people.
I would use ranging to determine more accurately if your beacon is around. Note that ranging, especially in the background can have a significant battery draw.

Recording multiple USB microphone simulteneously using NAudio library

I wrote the code to get the mic recording from 3 USB microphones using 3 instances of WaveInEvent.
waveIn.DataAvailable += OnDataAvailable;
waveIn.RecordingStopped += OnRecordingStopped;
waveIn.StartRecording();
waveIn2.DataAvailable += OnDataAvailable2;
waveIn2.RecordingStopped += OnRecordingStopped;
waveIn2.StartRecording();
In my OnDataAvailable, I do nothing more than writing to a wav file
void waveIn_DataAvailable(object sender, WaveInEventArgs e)
{
writer.WriteData(e.Buffer, 0, e.BytesRecorded);
}
I tried manipulating the buffer size but did not really resolve the latency issue. How I am testing this is I place microphone right next to each other and record, if I run cross-correlation from these data, I should ideally be getting ~0 sample lag.
It would be ideal if I can get all signals from multiple microphones "at the same time" with no latency between different microphones. However, I noticed few sample delays between different microphones.
I know that for this sort of application that require no/low latency, NAudio is not preferable. I was wondering if I can reduce the latency between different USB mic further by using WASAPI or if you would suggest using other libraries...
In my experience latency of usb audio devices vary with the device type, driver and even the usb port. So you probably need to tune the latencies for perfect fit.
This could be possible with the BufferedWaveProvider.
Write data to it in your waveIn_DataAvailable. You can adjust the buffer size of each of the buffered wave providers which in turn adjusts their delay. Maybe you can tune the different delays to sync up your mics.
Of course you could run into the same problem as with adjusting the waveIn buffers. LAnguages running in the CLR (like C#) are non-deterministic with a time uncertainty of 10-20ms, which could make your task impossible.

Recognition of a short high frequency sound in low frequency noise (objc/c)

I am currently creating an application which signals readiness to other devices using a high frequency sound.
(transmitter): A device will produce a short burst of sound of around 20khz.
(receiver): Another device will be listening for a sound at this frequency at a small distance from the transmitter(10m approx) The device recieves audio data from a microphone
The background noise will be fairly loud, varying from around 0 - 10khz(about human speech range), and would be produced by a small crowd of people.
I need the receiving device to be able to detect the 20khz sound, separated from the noise,
and know the time at which it was received.
Any help with an appropriate algorithm, a library, or even better, code in C or
Objc to detect this high frequency sound would be greatly appreciated.
20 kHz may be pushing it, as (a) most sound cards have low pass (anti aliassing) filters at 18 - 20 kHz and (b) most speakers and microphones tend to have a poor response at 20 kHz. You might want to consider say 15 kHz ?
The actual detection part should be easy - just implement a narrow band pass filter at the tone frequency, rectify the output and low pass filter (e.g. 10 Hz).
You may want to look into FFT (Fast Fourier Transform). This algorithm will allow you to analyse a waveform and convert it to the frequency spectrum for further analysis.
If this is for Mac OS or iOS, I'd start looking into Core Audio's Audio Units.
1 Here's Apple's Core Audio Overview.
2 Some AudioUnits for Mac OS
3 Or for iOS AudioUnit Hosting
A sound with that high frequency will not travel at all with the iphone speaker.