Originally Posted by
AndiPersti
That's 8192 kB = 8 MB.
Bye, Andreas
Ah, yes. That makes sense. 8 MB (or rather 8 MiB) seems to be the resulting maximal size that my test file could produce without segmentation fault (”a little more than” 5×10⁵×2 doubles, one double=8 bytes ⇨ ”a little more than” 8 MB, which 8 MiB is…).
Thanks for the information!
I'll try the malloc thing, although I think it's a little bit tricky to do that with multi dimensional arrays. As far as I understand, I need at least one loop for a 2D array, is that right?
So I guess Array[Channel][Sample] will be a lot faster to allocate than Array[Sample][Channel], since there are millions of samples but maximum 8 channels in a FLAC file.
Maybe it's a bit overkill to use a 2D array anyway in this case. The library I'm going to use will give me a 1D array of all the audio, maybe I should just stick with it. Well, I can decide that after some more experimenting. I like clean and easy-to-follow code, and I think Array[Channel[Sample] looks cleaner than Array[Sample*Channels+Channel]
Maybe I should just write a simple function that does the ”dirty job” for me:
Code:
double getSample(double Array, size_t Row, size_t Column, size_t Columns) {
return Array[Row*Columns+Column];
}
or something like that.
Or a macro…?
There is a lot to think about here, I guess. For example, if using a 1D array, I need to calculate the position (Sample*Channels+Channel) millions of times in my loops (once for each sample in every loop). With a 2D array, there's no need for that, so it should be faster, right?
Decisions, decision, decisions…