On 3/21/25 10:38, IOhannes m zmölnig wrote:
- learn (basic) usage of a debugger.
the simplest one os of course the printf-debugger, but it only gets you so far. otoh "gdb" is a mighty beast, but for getting a basic backtrace of a crashed program you only need to learn 3 or so commands.
I've been using gdb, but TBH, I couldn't understand much from what I was getting, other than that it was some memory reallocation that was causing the crash.
- for memory issues, learn to use valgrind.
it will tell you all kinds of memory problems in your code (and in libraries used, so there might be a number of false positives, but the output is readable enough to quickly find any problems related to *your* code)
It didn't occur to me to use valgrind, should have...
- finally, i honestly believe you are suffering from NIH-syndrome.
you really should rethink your design: rather than spending time on debugging what went wrong with reading unsigned 16bit WAV files, you could just use tables pre-populated by [soundfiler] - and hey, you would get support for SND, AIFF, CAF and even text files *for free*, and not only 16bit but also 24bit and 32bit. and with the use of 3rd party externals, there would be FLAC And mp3 and ogg and whatnot support.
I was thinking that [soundfiler] wouldn't work with long audio files (around 15 minutes). First of all, I was wrong. Second, even if this was the case, I should have split my audio files to shorter chunks and indeed use [soundfiler]. Instead I indeed suffered from NIH-syndrome and preferred to go down the rabbit hole of trying to read audio files inside my object. I'll go with this option eventually.
Thanks for the tips.