Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Latency when starting recording  (Read 3896 times)

0 Members and 1 Guest are viewing this topic.

MarkusLau

  • Newbie
  • *
  • Posts: 2
    • View Profile
Latency when starting recording
« on: October 14, 2018, 12:13:46 pm »
When starting a recording, the first aprox. 0.35 sekunds of samples in the soundbuffer are silence.   Is this a normal latency? or is there some ways to improve it?

The Attached picture is 1. secound of sound, with the silence  at the start.

basics of the code i'm using:

recorder.start(sampleRate);
Sleep(1000);
recorder.stop();

std::vector<int> finalSamples;

for(int i =0; i<recorder.getBuffer().getSampleCount();i++)
{

finaSamples.push_back(recorder.getBuffer().getSamples());
}

and then plotting the values of finalSamples.
« Last Edit: October 14, 2018, 12:27:08 pm by MarkusLau »

Antonio9227

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Latency when starting recording
« Reply #1 on: October 16, 2018, 04:13:41 pm »
This is just a guess but do you have any power saving options enabled on your device?

I had a similar problem with an old laptop where really short sounds (0.1 seconds) would not play because it had it's sound card disabled or in a low powered state. By the time my PC woke up the sound card, the actual sound I was trying to play was long over and it would seem as the sound itself was not playing.
By playing something on really low volume in the background my sound had no problems in playing on time and as intended.

You could test this by using your microphone to record something in audacity (to keep the device awake) and then run your program and see if anything changes.

If it works, you can disable the power saving stuff from DeviceManager > your device > uncheck 'allow the computer to turn off this device to save power'

MarkusLau

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Latency when starting recording
« Reply #2 on: October 17, 2018, 11:54:46 pm »
Thanks, that is the problem! but i dont have the option to "uncheck 'allow the computer to turn off this device to save power' " under deviceManager  :-\
But now that i know what the problem is, it is possible that i can find a solution  :)

ZeroZ30o

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: Latency when starting recording
« Reply #3 on: November 24, 2018, 07:35:45 pm »
Quite late of a reply, but: you could start the device earlier than you need and discard the first few seconds of values.