From: Jane's C. <jan...@gm...> - 2011-01-12 00:48:44
|
Dear all, I wrote Rob a mail before discovering this mailing list, I hope he's not mad now :) I'm trying to port some SOX plugins to Javascript, and I have some question on your code. Particularly, I'm a little confused by tempo.c: what exactly the functions tempo_output and tempo_input do? I believed they were called in order: tempo_input() to put some samples in the FIFO and tempo_output() to get back some processed samples after calling process(), but I see that the calling schema in your code is different: first, tempo_output() gets called, then tempo_input() and finally tempo_process() (in the flow() function). That's what I understood from the code, studying the flow() function: - tempo_input returns a pointer where one can store the (float32) samples. Its first parameter is the tempo_t structure we initialized, the second one is always NULL (at least, in flow() it is - I don't know what the second parameter means) and the third is the number of samples we want to store in the buffers, divided by the channel number. Once the function returns, we start writing the samples at the pointer given by its return value. - tempo_process reads the samples we wrote before and starts to generate output samples (maybe not from the beginning, because it has to wait for the buffers to fill). - tempo_output returns a pointer where the output samples are; again, the first parameter is the tempo_t structure, the second one is NULL (again, I don't know what it means) and the third parameters is a pointer to a size_t. tempo_output modifies it to give us the number of output samples. I noticed it takes a value, too (ie. it's not only an output parameter), but I can't say why. Once the function returns, we take the pointer it gives us and we read a number of samples equal to the current value of the variable given as third parameter. Is my analysis correct? I really can't get why the functions are called in that order, so maybe I misunderstood their behaviour. I really hope you have time to help me, for now thanks in advance! Best Regards, Cristiano Belloni. |