Patching Async C# Code

maybe don’t put it right after the samples arrive, it could mess up the order of samples. rather when you are finished gathering a block of samples and you want to process them with the sound fingerprinting library.

the operation of queuing a block of samples should be quite fast because it doesn’t do any heavy calculation. so it shouldn’t block the audio input thread for too long. also, the audio in event can have a very high rate, creating a task per event is probably less performant than doing it synchronously.

the process of finding an audio match is clearly something else and could take much longer, so this is a good place to make the cut between the threads.

in your patch the ToBackground is mostly on the the end, which doesn’t do anything, it doesn’t influence the observable above, it only has an effect on workload that happens after the node in the observable.

So in your case the ToBackground should be after ProcessAndDownsample.

do you know the Debug node in reactive? it gives you information about how often an observable has fired and on which thread ID. this could help here to understand whats going on.

1 Like