0

I am using a push button which records incoming microphone sound signal. Usually, the signal arrives a little late after pressing the record button and my recorded output contains zero until 10 ms(after which i receive an actual output). I am using the following QTimer function to set the delay but there is the ouput is the same,

QTimer->singleShot(0.010, this, SLOT(onStartRecordPushButton))

Are there any other methods to crop the signal for the first 10 ms or start recording only when a non zero signal arrive? Thanks

neo_v
  • 41
  • 7
  • 2
    Please, have a look at [`QTimer::singleShot()`](http://doc.qt.io/qt-5/qtimer.html#singleShot): The first parameter is of type `int` and expects time in **milliseconds**. Providing `0.010` means (after converting to `int`) that you request 0 milliseconds - i.e. immediate shot after returning to event loop. You probably want `10` for 10 milliseconds. – Scheff's Cat Sep 25 '18 at 09:16
  • You may also consider what the `QTimer` doc. tells about [Accuracy and Timer Resolution](http://doc.qt.io/qt-5/qtimer.html#accuracy-and-timer-resolution). – Scheff's Cat Sep 25 '18 at 09:18

1 Answers1

1

QTimer::singleShot takes milliseconds as an argument, not seconds. Your call should probably look like this:

QTimer->singleShot(10, this, SLOT(onStartRecordPushButton))
perivesta
  • 3,417
  • 1
  • 10
  • 25