1

Using mcisendstring, I want to stop recording if a silence period (no input from microphone) is reached. I understand a timer would be involved, so after x seconds a check needs to be made, but what to check exactly?

Currently,I record using:

i = mciSendString("record capture", Nothing, 0, 0)

Thanks.

NoChance
  • 5,632
  • 4
  • 31
  • 45
  • 1
    Did you try fourier transform on amplitude data to get frequencies and check if there aren't many frequencies? – huseyin tugrul buyukisik Mar 28 '17 at 00:19
  • Never though Fourier Transform has to do with this to be honest! Would you kindly suggest a reference? Thx. – NoChance Mar 28 '17 at 00:22
  • 1
    Sampling rate, data format, many things can help but you can try to clear the background noise with a filter first. I don't have a reference. – huseyin tugrul buyukisik Mar 28 '17 at 00:28
  • @huseyintugrulbuyukisik Good ideas man, thanks. – NoChance Mar 28 '17 at 00:29
  • 1
    Consider migrating or posting this question on the [digital signal processing](http://dsp.stackexchange.com/?tags=audio) forum. – John Wu Mar 28 '17 at 00:51
  • 1
    Move to the Win32 Wave In functions - specifically `waveInOpen`; and define your `waveInProc` where you have comeplete access to the low level audio data, something MCI doesn't allow you to do. No need for 3rd-party libs –  Mar 28 '17 at 01:07
  • @MickyD, thanks for the good idea. I could try that. – NoChance Mar 28 '17 at 01:09

1 Answers1

2

You will need an audio library that allows you to access the record buffer while recording is in progress. I don't think MCI will let you do that. So it sounds like you are in the market for a more nuanced audio library.

Here is a link to a StackOverflow question that lists several digital audio libraries.

You might also consider using an open source .NET framework like NAudio, where they have done a lot of the work for you already.

To make a recording, you will most likely need to allocate a primary buffer, plus a callback that will allocate secondary/permanent buffers as needed (e.g. as the recording gets longer and longer). To detect silence, you will need to perform some sort of signal processing on the primary buffer as bytes are added to it.

The "signal processing" in this case could be very simple, e.g. you could take a moving average (essentially a low pass filter) and determine if the average amplitude is below a certain threshold level, which could be calibrated during the silence at the beginning of the recording (which presumably will give you a decent baseline).

A more advanced process would attempt to filter out ambient noise or line noise (e.g. a 60 hz filter to remove the hum caused by household AC). You could go pretty deep with this if you wanted to.

Community
  • 1
  • 1
John Wu
  • 50,556
  • 8
  • 44
  • 80
  • Thank you for the detailed explanation. I was hoping life could be easier, but it is never so...Thanks again. – NoChance Mar 28 '17 at 00:54