Audiofile odkryli że memcpy pogarsza jakość dźwięku i debatują która implementacja memcpy daje najlepszą jakość :D
https://www.audioasylum.com/cgi/t.mpl?f=pcaudio&m=119979
In Reply to: RE: A revolution in audio rendering posted by SBGK on January 29, 2013 at 15:42:42
continue to optimise and get improvements in sound, one thing I have found is that as the loop is optimal the reliance on low latency is reduced, in fact sounds much worse at low values, so can now use a period of 0.5s
found that best vs2010 optimisation settings were for speed.
playing wav files from a ramdisk gave best sound
then moved on to memory play, initially SQ was worse.
found that a function called memcpy was the culprit, most memory players use memcpy and this is one of the reasons why memory play sounds worse ie digital sounding. Fortunately there is an optimised version of memcpy from http://www.agner.org/optimize/, using this version removes the hard edge produced by memcpy. the other thing I did was to close the file after reading into the buffer.
also most players use malloc to get memory while new is the c++ method and sounds better.
updated exe below, sounds fantastic I use it all the time now, doesn't have the processed sound of JPlay and is the best player I have heard on my system.
https://rapidshare.com/#myrs_filemanager/file/3363
optimised loop below.
Kopiuj
BYTE *sound_buffer = new BYTE [sizeof(BYTE) * nBytesInFile];
hr = mmioRead(hFile, (HPSTR)sound_buffer, nBytesInFile);
mmioClose(hFile, 0);
//UINT32 nByteCnt = nBytesInFile - nBytesThisPass*2;
//while (nBytesToSkip < nByteCnt)
//while (--nBuffersPlayed)
do
{
WaitForSingleObject(hNeedDataEvent, INFINITE);
hr = pAudioRenderClient->ReleaseBuffer(nFramesInBuffer, 0);
hr = pAudioRenderClient->GetBuffer(nFramesInBuffer, &pData);
A_memcpy (pData, sound_buffer + nBytesToSkip, nBytesThisPass);
nBytesToSkip += nBytesThisPass;
}
while (--nBuffersPlayed);
//while (nBytesToSkip < nByteCnt);
//while (nBuffersPlayed > 0);
// render loop
WaitForSingleObject(hNeedDataEvent, INFINITE);
//hr = mmioRead(hFile, (HPSTR)pData, nBytesThisPass);
hr = pAudioRenderClient->ReleaseBuffer(nFramesInBuffer, 0);
WaitForSingleObject(hNeedDataEvent, INFINITE);
hr = pAudioRenderClient->GetBuffer(nFramesInBuffer, &pData);
nFramesThisPass = nFramesInFile - nBuffersinFile*nFramesInBuffer;
nBytesThisPass = nFramesThisPass * pWfx->nBlockAlign;
A_memcpy (pData, sound_buffer + nBytesToSkip, nBytesThisPass);
if (nFramesThisPass < nFramesInBuffer) {
UINT32 nBytesToZero = (nFramesInBuffer * pWfx->nBlockAlign) - nBytesThisPass;
ZeroMemory(pData + nBytesThisPass, nBytesToZero);