Closed ericlyon closed 3 years ago
I think this question is directed to @umlaeute . (@ericlyon we have mention someone so the he/she gets email notification. Otherwise only people that read this are the "Watchers")
thanks @Lucarda :-) @erikd you probably should read a bit on markdown in order to format the code in a way that makes it fun to read :-)
about the problem at hand:
0.
rather than 1.
however, i agree that the current fix for the crash-problem is suboptimal. to recap:
the solution is bad insofar, as it doesn't address the actual problem, it just sweeps it under the carpet.
the real solution would be to just not access the arrays at invalid positions.
there is absolutely no need to write any data into the extended portions of both the channelOne
and the newChannel
arrays.
we are repeatedly doing N
operations on data that is never used (and should be always zero anyhow).
so my advise is to get rid of these extra operations:
copyArray
function unneededthanks for bringing the issue up: i wanted to write that 2nd part anyhow, but forgot about it...
@umlaeute You probably should ping @ericlyon rather than me.
Thanks @umlaeute for the clarification. My concern was less about optimization (I wasn't actually planning to do anything about it), but more about complexifying the code unnecessarily for anyone who's trying to understand how it works by adding a function call, rather than doing relatively simple work inside the do_mindwarp() function. That may be a matter of programming style preference - I like to jump around as little as possible when trying to understand an algorithm. I'll fix the bug with an inline solution, unless there are any concerns about that approach.
Regarding the other point about the unnecessary calculations - I'll have to think about that. As I understand it, the algorithm stretches or shrinks the spectrum dynamically, and when it stretches, then some of the spectrum goes above the Nyquist, but without causing aliasing; in this case the above-Nyquist spectrum is just ignored. At least I think that's what's going on, such that it might actually be simplest to allow the algorithm to stand as is.
Thanks for the other advice about formatting code in github comments. That will probably come in handy for the future!
The code has now been updated. Thank you @umlaeute for discovering the bug and providing the initial fixes.
@erikd oops indeed. so many eriqs around :facepalm: sorry for the noise
I just noticed that a new function was introduced, "copyArray." Looks like it's copying the array, and attempts to zero-pad. Not sure why zero pad values are set to 1.0, rather than 0.0 - looks like a bug.
In any case, I advise against using this function callout, as opposed to keeping the code within do_mindwarp(), since there may be a loss of efficiency in the function call. For improving efficiency, block operator functions memcpy() and memset() might be considered. Any thoughts?
static void copyArray(t_floatsrc, t_floatdst, size_t size, size_t zerosize) { size_t i; for(i=0; i<size; i++) dst++=src++; for(i=0; i<zerosize; i++) *dst++=1.; }