lokki i get 4 dropped blocks, but that is to be expected i guess
lokki g called presets2.wavpresets, i have no idea where that extra presets is coming from.
that is a C thing, where strings do not actually exists, but are sequences of
chars terminated by a null character (
\0). The length of the string "presets2.wav" is therefore
12+1 = 13. When you call
the first string actually exceeds the space allocated in
fileName, and effectively writes past the end of the array, causing undefined behaviour. In this case, the behaviour is that
tableName are allocated contiguously, so that the
\0 terminating character for the
fileName string actually ends up being the first element of the
tableName string, and the second line overwrites that. Remember that strings are
\0-terminated, which means that when you start reading a string from a given position in memory, the end of the string will be the first
\0 character encountered. As a result, if you start reading from
tableName, you get
presets, but if you start reading from
fileName, you will read
presets2.wavpresets. Whatever, just increase the size of those
char arrays. You should also use
snprintf instead, which is safer (check
man snprintf). But ultimately, in case you don't actually need to change your strings dynamically, there is no need to do any of that. This will do:
const char fileName = "presets2.wav";
const char tableName = "presets";
lokki is it a problem to use "4" in the writeSamples() for the frames input?
It is not a problem.
lokki i don't know how to get the size of the table from PD
According to this there is a
unsigned int hv_table_getLength(HeavyContextInterface *c, unsigned int tableHash); that should do it.
lokki ok when i change the sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
to: sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
the name is correct. however there is no data written in that case, file is 0.0kb and audacity can still not open it.
not sure what is happening there. Can you not go for
PCM_16 ? Note 1 at the bottom of the docs is a bit confusing for me as to what
float formats do, and my hint would be: stay away from them unless you actually need them (not that this explains why your code stops working when you do that).