[Clam-devel] [Patch] - Resize / Setsize Issue in SpectralPeakArray
Han, Yushen
yushen.han at gmail.com
Fri Jun 20 12:46:48 PDT 2008
Hi,
I send this patch (my first patch to CLAM) to fix a problem that
leads to a setsize-without-resize error, which is given by array.hxx.
(Actually I do not understand the necessity in array.hxx that requires
us to do both of setsize and resize.)
The error occured when I modified Greg's LoopingSDIFFileReader.cxx to
be SDIFFileReaderWithLoop.cxx in my simpleOboeSynthesizer.
It came from something like:
void SDIFFileReaderWithLoop::CrossfadeSpectralPeakArrays(SpectralPeakArray&
sourceSpectralPeaks1,
SpectralPeakArray& sourceSpectralPeaks2,
SpectralPeakArray& targetSpectralPeaks,
float crossfadeFactor)
{
// typedef Array<TData> DataArray; in array.hxx
DataArray& srcFreqBuffer1 = sourceSpectralPeaks1.GetFreqBuffer();
DataArray& srcMagBuffer1 = sourceSpectralPeaks1.GetMagBuffer(); //
this will give the Setsize error
...
}
To fix this, I add Resize() before Setsize() in SpectralPeakArray.hxx,
which is in CLAM/src/Data/BasicProcessing/
(Do you think it is better if we put the code in SpectralPeakArray.cxx
instead of *.hxx?)
/** Sets the actual size of the different instantiated buffers keeping them
* consistent. If allocated size is less than npeaks, a resize is automatically
* performed on all buffers.
*/
// I think we need the Resize() as well. It does not hurt at least. - Yushen Han
void SetnPeaks(TSize npeaks)
{
if (npeaks>GetnMaxPeaks()) SetnMaxPeaks(npeaks);
if(HasMagBuffer()) {
GetMagBuffer().Resize(npeaks);
GetMagBuffer().SetSize(npeaks);}
I think this may affect quite a few files since SpectralPeakArray is
quite useful...
Best regards,
Han, Yushen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ResizeInSpectralPeakArray.patch
Type: application/octet-stream
Size: 1521 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20080620/334b6243/attachment-0004.obj>
More information about the clam-devel
mailing list