Re-integrate _check_array() into _read_or_write()#138
Conversation
|
Any justification for this? (Not that I'm against it, I'd just like to know your thoughts on this) |
|
The justification is in #36, mainly https://github.com/bastibe/PySoundFile/pull/36#issuecomment-44213305 and https://github.com/bastibe/PySoundFile/pull/36#issuecomment-44533741. At the time I wasn't quite sure, so I followed your wish to split the function into two parts. |
|
I am not opposed to this. But let's take this opportunity to talk about There has to be a better way. Maybe we can separate the snd-call from the data conversion/normalization somehow. Maybe we can pass in functions. But reading and writing are such fundamentally different operations, they should not live in the same function. |
This has nothing to do with the current PR, but ... whatever ...
There is no design without boundary conditions. The result may be ugly, but if it is the least bad solution to a given problem, its actually good design! But I'm not saying that it is ...
Quite likely ... there nearly always is ...
They may be conceptually different, but pragmatically, they are the same: sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
sf_count_t sf_writef_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;The only difference is a substring in the function name, which we pass as string argument into our wrapper function. As I mentioned in https://github.com/bastibe/PySoundFile/pull/36#issuecomment-43413445, we could change Alternatively, we could have two different I doubt this will turn out less terrible, though. Either way, this won't be a solution to your problem, because there would still be one function that does both reading and writing ... Currently, I don't see a nice way to use separate functions for reading and writing without code duplication. But I'm looking forward to a better solution! |
|
After merging #72, this PR is obsolete, I'm closing it ... |
This reverts a part of #36, namely ab33e66.