Re: [Audacity-devel] recording with DirectSound?
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
From: Vaughan J. <va...@au...> - 2009-01-17 22:45:04
|
Wow! Thanks, Leland. I thought that section was suspect, but didn't have time to look into it before I had to leave last evening. Didn't mean for you to spend all that time tracking it down, but very grateful you did. I guess I'm leaning toward removing automatic latency correction again. Didn't know from the previous comments about its unreliability that it was SO flaky, and it's been working fine for my WMME driver -- just lucky I guess. Any other opinions about removing automatic latency correction? For Windows only? For WMME and DirectSound only? (Need to test with ASIO...) Thanks, Vaughan Leland wrote: > Vaughan Johnson wrote: > >> If I have DirectSound drivers for both input and output, it records >> fine, then gives "Latency setting has caused the recorded audio to be >> hidden before zero..." >> >> > Remember this bit in AudioIO()? > > // As of 06/17/2006, portaudio v19 returns inputBufferAdcTime set to > // zero. It is being worked on, but for now we just can't do much > // but follow the leader. > // > // 08/27/2006: too inconsistent for now...just leave it a zero. > // > // 04/16/2008: Looks like si->inputLatency comes back with something useful though. > // This rearranged logic uses si->inputLatency, but if PortAudio fixes inputBufferAdcTime, > // this code won't have to be modified to use it. > // Also avoids setting mLastRecordingOffset except when simultaneously playing and recording. > // > if (numCaptureChannels > 0 && numPlaybackChannels > 0) // simultaneously playing and recording > { > if (timeInfo->inputBufferAdcTime > 0) > gAudioIO->mLastRecordingOffset = timeInfo->inputBufferAdcTime - timeInfo->outputBufferDacTime; > else if (gAudioIO->mLastRecordingOffset == 0.0) > { > const PaStreamInfo* si = Pa_GetStreamInfo( gAudioIO->mPortStreamV19 ); > gAudioIO->mLastRecordingOffset = -si->inputLatency; > } > } > > Well, here's another case where the values can't be trusted. Search the portaudio-v19/hostapi directory for inputBufferAdcTime. > You'll find that some APIs actually set it, but the WMME and DSOUND ones do not. They are marked as TODOs. You did notice some > values there right? Those came from common/pa_process.c (near as I can tell) and only represent the amount of time the buffer > processor takes. It probably wouldn't even be close to the real latency. And, you may notice that most of the time it comes back > as zero. > > All of these values just are not consistently calculated by the different APIs. > > I added the following bit of code right after the last brace above and recorded twice on each platform. The first recording was > into an empty project and the second one done soon after completing the first. The project rate was set at 44100 and number of > channels was 2. Overdub was on See more comments below... > > { > const PaStreamInfo* si = Pa_GetStreamInfo( gAudioIO->mPortStreamV19 ); > wxLogDebug(wxT("iadc %f odac %f ilat %f olat %f inum %d onum %d offset %f\n"), > timeInfo->inputBufferAdcTime, > timeInfo->outputBufferDacTime, > si->inputLatency, > si->outputLatency, > numCaptureChannels, > numPlaybackChannels, > gAudioIO->mLastRecordingOffset); > } > > > WMME API, 1st recording: > > 00:26:31: Debug: iadc 0.000000 odac 0.000000 ilat 0.116100 olat 0.000000 inum 2 onum 0 offset 0.000000 > 00:26:31: Debug: iadc 0.000000 odac 0.000000 ilat 0.116100 olat 0.000000 inum 2 onum 0 offset 0.000000 > 00:26:31: Debug: iadc 0.000000 odac 0.000000 ilat 0.116100 olat 0.000000 inum 2 onum 0 offset 0.000000 > 00:26:32: Debug: iadc 0.000000 odac 0.000000 ilat 0.116100 olat 0.000000 inum 2 onum 0 offset 0.000000 > 00:26:32: Debug: iadc 0.000000 odac 0.000000 ilat 0.116100 olat 0.000000 inum 2 onum 0 offset 0.000000 > 00:26:32: Debug: iadc 0.000000 odac 0.000000 ilat 0.116100 olat 0.000000 inum 2 onum 0 offset 0.000000 > 00:26:32: Debug: iadc 0.000000 odac 0.000000 ilat 0.116100 olat 0.000000 inum 2 onum 0 offset 0.000000 > 00:26:32: Debug: iadc 0.000000 odac 0.000000 ilat 0.116100 olat 0.000000 inum 2 onum 0 offset 0.000000 > 00:26:32: Debug: iadc 0.000000 odac 0.000000 ilat 0.116100 olat 0.000000 inum 2 onum 0 offset 0.000000 > 00:26:32: Debug: iadc 0.000000 odac 0.000000 ilat 0.116100 olat 0.000000 inum 2 onum 0 offset 0.000000 > > WMME API, 2nd recording: > > 00:26:35: Debug: iadc 0.000000 odac 5831.976663 ilat 0.116100 olat 0.116100 inum 2 onum 2 offset -0.116100 > 00:26:35: Debug: iadc 0.000000 odac 5831.975795 ilat 0.116100 olat 0.116100 inum 2 onum 2 offset -0.116100 > 00:26:35: Debug: iadc 0.000000 odac 5832.120745 ilat 0.116100 olat 0.116100 inum 2 onum 2 offset -0.116100 > 00:26:35: Debug: iadc 0.000000 odac 5832.116933 ilat 0.116100 olat 0.116100 inum 2 onum 2 offset -0.116100 > 00:26:35: Debug: iadc 0.000000 odac 5832.114587 ilat 0.116100 olat 0.116100 inum 2 onum 2 offset -0.116100 > 00:26:35: Debug: iadc 0.000000 odac 5832.142442 ilat 0.116100 olat 0.116100 inum 2 onum 2 offset -0.116100 > 00:26:35: Debug: iadc 0.000000 odac 5832.162983 ilat 0.116100 olat 0.116100 inum 2 onum 2 offset -0.116100 > 00:26:35: Debug: iadc 0.000000 odac 5832.197126 ilat 0.116100 olat 0.116100 inum 2 onum 2 offset -0.116100 > 00:26:35: Debug: iadc 0.000000 odac 5832.226185 ilat 0.116100 olat 0.116100 inum 2 onum 2 offset -0.116100 > 00:26:35: Debug: iadc 0.000000 odac 5832.266317 ilat 0.116100 olat 0.116100 inum 2 onum 2 offset -0.116100 > > NOTABLES: > > iadc is always zero. > ilat looks like it might be valid. It would have to be tested to prove it out. > > DSOUND API, 1st recording: > > 00:28:37: Debug: iadc 0.000000 odac 5953.900221 ilat 0.000000 olat 0.099977 inum 2 onum 0 offset 0.000000 > 00:28:37: Debug: iadc 0.000000 odac 5953.923658 ilat 0.000000 olat 0.099977 inum 2 onum 0 offset 0.000000 > 00:28:37: Debug: iadc 0.000000 odac 5953.947073 ilat 0.000000 olat 0.099977 inum 2 onum 0 offset 0.000000 > 00:28:37: Debug: iadc 0.000000 odac 5953.970562 ilat 0.000000 olat 0.099977 inum 2 onum 0 offset 0.000000 > 00:28:37: Debug: iadc 0.000000 odac 5953.993897 ilat 0.000000 olat 0.099977 inum 2 onum 0 offset 0.000000 > 00:28:37: Debug: iadc 0.000000 odac 5954.021291 ilat 0.000000 olat 0.099977 inum 2 onum 0 offset 0.000000 > 00:28:37: Debug: iadc 0.000000 odac 5954.044735 ilat 0.000000 olat 0.099977 inum 2 onum 0 offset 0.000000 > 00:28:37: Debug: iadc 0.000000 odac 5954.068178 ilat 0.000000 olat 0.099977 inum 2 onum 0 offset 0.000000 > 00:28:37: Debug: iadc 0.000000 odac 5954.091576 ilat 0.000000 olat 0.099977 inum 2 onum 0 offset 0.000000 > 00:28:37: Debug: iadc 0.000000 odac 5954.115227 ilat 0.000000 olat 0.099977 inum 2 onum 0 offset 0.000000 > > DSOUND API, 2nd recording: > > 00:28:41: Debug: iadc 0.000000 odac 5958.628526 ilat 0.000000 olat 0.099977 inum 2 onum 2 offset -0.000000 > 00:28:42: Debug: iadc 0.000000 odac 5958.662010 ilat 0.000000 olat 0.099977 inum 2 onum 2 offset -0.000000 > 00:28:42: Debug: iadc 0.000000 odac 5958.682268 ilat 0.000000 olat 0.099977 inum 2 onum 2 offset -0.000000 > 00:28:42: Debug: iadc 0.000000 odac 5958.699159 ilat 0.000000 olat 0.099977 inum 2 onum 2 offset -0.000000 > 00:28:42: Debug: iadc 0.000000 odac 5958.742273 ilat 0.000000 olat 0.099977 inum 2 onum 2 offset -0.000000 > 00:28:42: Debug: iadc 0.023220 odac 5958.765493 ilat 0.000000 olat 0.099977 inum 2 onum 2 offset -5958.742273 > 00:28:42: Debug: iadc 0.000000 odac 5958.745750 ilat 0.000000 olat 0.099977 inum 2 onum 2 offset -5958.742273 > 00:28:42: Debug: iadc 0.000000 odac 5958.783044 ilat 0.000000 olat 0.099977 inum 2 onum 2 offset -5958.742273 > 00:28:42: Debug: iadc 0.000000 odac 5958.806494 ilat 0.000000 olat 0.099977 inum 2 onum 2 offset -5958.742273 > 00:28:42: Debug: iadc 0.000000 odac 5958.819920 ilat 0.000000 olat 0.099977 inum 2 onum 2 offset -5958.742273 > > NOTABLES: > > iadc is ALMOST always zero...check what happens ot the offset when it isn't (this is cause the message dialog above) > odac on first recording...why? > ilat is always zero. > olat on first recording...why? > offset goes whacko if iadc isn't zero. > > COREAUDIO API, 1st recording: > > iadc 0.026644 odac 0.000000 ilat 0.000000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 0.074966 odac 0.000000 ilat 0.000000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 0.123288 odac 0.000000 ilat 0.000000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 0.171610 odac 0.000000 ilat 0.000000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 0.219955 odac 0.000000 ilat 0.000000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 0.280816 odac 0.000000 ilat 0.000000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 0.329161 odac 0.000000 ilat 0.000000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 0.377483 odac 0.000000 ilat 0.000000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 0.425805 odac 0.000000 ilat 0.000000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 0.474127 odac 0.000000 ilat 0.000000 olat 0.000000 inum 2 onum 0 offset 0.000000 > > COREAUDIO API, 2nd recording: > > iadc 0.000000 odac 0.023220 ilat 0.000000 olat 0.023220 inum 2 onum 2 offset -0.000000 > iadc 0.000000 odac 0.046440 ilat 0.000000 olat 0.023220 inum 2 onum 2 offset -0.000000 > iadc 0.000000 odac 0.069660 ilat 0.000000 olat 0.023220 inum 2 onum 2 offset -0.000000 > iadc 0.000000 odac 0.092880 ilat 0.000000 olat 0.023220 inum 2 onum 2 offset -0.000000 > iadc 0.000000 odac 0.116100 ilat 0.000000 olat 0.023220 inum 2 onum 2 offset -0.000000 > iadc 0.000000 odac 0.139320 ilat 0.000000 olat 0.023220 inum 2 onum 2 offset -0.000000 > iadc 0.000000 odac 0.162540 ilat 0.000000 olat 0.023220 inum 2 onum 2 offset -0.000000 > iadc 0.000000 odac 0.185760 ilat 0.000000 olat 0.023220 inum 2 onum 2 offset -0.000000 > iadc 0.000000 odac 0.208980 ilat 0.000000 olat 0.023220 inum 2 onum 2 offset -0.000000 > iadc 0.000000 odac 0.232200 ilat 0.000000 olat 0.023220 inum 2 onum 2 offset -0.000000 > > NOTABLES: > > iadc is zero when overdubbing > ilat is always zero. > > ALSA API, 1st recording: > > iadc 745.844121 odac 0.000000 ilat 0.100000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 745.881746 odac 0.025000 ilat 0.100000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 745.919378 odac 0.050000 ilat 0.100000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 745.957086 odac 0.075000 ilat 0.100000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 745.994760 odac 0.100000 ilat 0.100000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 746.032372 odac 0.125000 ilat 0.100000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 746.068625 odac 0.150000 ilat 0.100000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 746.107748 odac 0.175000 ilat 0.100000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 746.145350 odac 0.200000 ilat 0.100000 olat 0.000000 inum 2 onum 0 offset 0.000000 > iadc 746.182977 odac 0.225000 ilat 0.100000 olat 0.000000 inum 2 onum 0 offset 0.000000 > > ALSA API, 2nd recording: > > iadc 766.255139 odac 766.308473 ilat 0.085333 olat 0.085333 inum 2 onum 2 offset -0.053333 > iadc 766.378601 odac 766.431935 ilat 0.085333 olat 0.085333 inum 2 onum 2 offset -0.053333 > iadc 766.504767 odac 766.558101 ilat 0.085333 olat 0.085333 inum 2 onum 2 offset -0.053333 > iadc 766.629051 odac 766.682385 ilat 0.085333 olat 0.085333 inum 2 onum 2 offset -0.053333 > iadc 766.753588 odac 766.806922 ilat 0.085333 olat 0.085333 inum 2 onum 2 offset -0.053333 > iadc 766.877923 odac 766.931257 ilat 0.085333 olat 0.085333 inum 2 onum 2 offset -0.053333 > iadc 767.038065 odac 767.091399 ilat 0.085333 olat 0.085333 inum 2 onum 2 offset -0.053333 > iadc 767.170921 odac 767.224255 ilat 0.085333 olat 0.085333 inum 2 onum 2 offset -0.053333 > iadc 767.296019 odac 767.349353 ilat 0.085333 olat 0.085333 inum 2 onum 2 offset -0.053333 > iadc 767.421381 odac 767.474715 ilat 0.085333 olat 0.085333 inum 2 onum 2 offset -0.053333 > > NOTABLES: > > odac on first recording...why...is suspect anyway. > ilat on 1st recording is suspect. > ilat during overdubbing may be correct, but it seems like it may be low...especially in my environment. > > (I wanted to try OSS, but couldn't get capture to work at all) > > As you can see, there's hardly any consistency in any of these values. If we still want to try and use them, we will have to code > it up so it's API specific. > > Or simply not attempt to determine a latency and leave it up to the user to set in Preferences. > > I do realize an automatic latency determination would be best since various factors can affect the latency from recording to > recording. But, can we trust what we're being given? > > Now, down to the problem this is causing when using the DirectSound API... > > The current determination of latency can't be used when the DirectSound API is active due to the iadc being non-zero every so often. > If it was consistently zero, then it wouldn't be a problem. > > Leland > > > > > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > audacity-devel mailing list > aud...@li... > https://lists.sourceforge.net/lists/listinfo/audacity-devel > > |