There was someone on the jack mailing list that was working on a resampling library. This would be something we could replace our resampling code with. More than likely the library would support several resampling algorithms allowing for an appropriate one to be selected based on cpu speed and quality. I'll mail the jack devel list and see if there is any new status on the progress of the library.
Thanks, Chris
From: Francois Gouget fgouget@codeweavers.com Date: 2002/12/13 Fri PM 03:42:07 EST To: wine-patches@winehq.com Subject: wavemap: Avoid resampling if possible
The distorsion that lead to my previous patch was in fact caused by the resampling of an 11025Hz signal to 48kHz. According to the signal processing literature I could find, what we do is a '1st Order Linear Interpolation Filter' and that is considered a poor filter. That literature says we should be using an 'nth Order Interpolation / Decimation' filter.
I didn't really feel motivated enough to implement such a beast, plus this is more the job of a sound library than of Wine. I hope aRts, ESound, Jack and friends implement such a filter so it will hopefully soon be a moot point soon anyway. However one easy thing we can do is to try not to do any resampling unless absolutely necessary. This means first trying simple 8/16bits or mono/stereo conversions first. If we find a match the sound quality will be better and the conversion will use less CPU.
Changelog:
Francois Gouget <fgouget@codeweavers.com>
dlls/winmm/wavemap/wavemap.c
Our resampling algorithm is quite primitive so try simple 8/16
mono/stereo conversions first. Only resample if we cannot avoid it.
-- Francois Gouget fgouget@codeweavers.com
Index: dlls/winmm/wavemap/wavemap.c
RCS file: /home/wine/wine/dlls/winmm/wavemap/wavemap.c,v retrieving revision 1.26 diff -u -r1.26 wavemap.c --- dlls/winmm/wavemap/wavemap.c 13 Dec 2002 02:18:20 -0000 1.26 +++ dlls/winmm/wavemap/wavemap.c 13 Dec 2002 19:18:56 -0000 @@ -185,6 +191,19 @@ #define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \ if (wodOpenHelper(wom, i, lpDesc, &wfx, dwFlags | WAVE_FORMAT_DIRECT) == MMSYSERR_NOERROR) \ {wom->avgSpeedInner = wfx.nAvgBytesPerSec; goto found;}
/* Our resampling algorithm is quite primitive so first try
* to just change the bit depth and number of channels
*/
for (i = ndlo; i < ndhi; i++) {
wfx.nSamplesPerSec=lpDesc->lpFormat->nSamplesPerSec;
wfx.nChannels = lpDesc->lpFormat->nChannels;
TRY(wfx.nSamplesPerSec, 16);
TRY(wfx.nSamplesPerSec, 8);
wfx.nChannels ^= 3;
TRY(wfx.nSamplesPerSec, 16);
TRY(wfx.nSamplesPerSec, 8);
} for (i = ndlo; i < ndhi; i++) { /* first try with same stereo/mono option as source */
On Fri, 13 Dec 2002 chrismorgan@rcn.com wrote:
There was someone on the jack mailing list that was working on a resampling library. This would be something we could replace our resampling code with. More than likely the library would support several resampling algorithms allowing for an appropriate one to be selected based on cpu speed and quality. I'll mail the jack devel list and see if there is any new status on the progress of the library.
We could, but then it seems the future is that Wine with more often use the Jack or aRts drivers than our current wineoss driver. So we will automatically benefit from Jack's or aRts resampling capabilities.
Improving our resampling code might still be useful for NAS or Alsa though I'm not really sure about that. That would be something to check and if neither of these two needs resampling in wine then we should go the the resampling solution that requires the least maintenance.
(and it might even be that copy/pasting another project's code would require less maintenance...)
On Saturday 14 December 2002 02:41 pm, Francois Gouget wrote:
On Fri, 13 Dec 2002 chrismorgan@rcn.com wrote:
There was someone on the jack mailing list that was working on a resampling library. This would be something we could replace our resampling code with. More than likely the library would support several resampling algorithms allowing for an appropriate one to be selected based on cpu speed and quality. I'll mail the jack devel list and see if there is any new status on the progress of the library.
We could, but then it seems the future is that Wine with more often use the Jack or aRts drivers than our current wineoss driver. So we will automatically benefit from Jack's or aRts resampling capabilities.
I'm kind of hoping arts is replaced with jack as jack is suitable for both desktop and professional audio users. The jack developers are reluctant to put resampling inside of the server, they would rather the client resampled using a library like the one I suggested. The intent is to keep the server simpler. I'm not sure if they will change their mind when jack is more widely used for general purpose audio like we are doing with wine.
Chris