Zitiere thewade pdman@aproximation.org:
Hello list,
hi.
problem 2: a) why use truncf() instead of a simple cast to integer ? t_float f=1.3; int i=(int)f; b) you will have to link against the mathlib (-lm)
to cast (t_float *) to (float) for truncf but I get errors unless I make *(t_float *)...
probably it is a bad idea to cast a pointer to a float-value to a float-value itself. read a good C-book.
Problem 1: a closer look. Ive included my code at the bottom of this email. I really appreciate if someone could point out what Im doing wrong. Ive looked at snapshot~ and tried to adopt some of its methods, but it doesnt seem to work when compaired to print~ output.
a) i'd suggest to pass the whole object-structure to the _perform routine rather than just selected values. (but of course you are free to do as you please)
b) it is NOT a good idea to manipulate data in the _dsp routine !!! the _dsp() routine is called only ONCE!!!! you do not get the signal-data into your _perform-routine but the data + an offset (that cannot be changed at runtime) i'd suggest just using dsp_add(fftbin_tilde_perform, 3, ref, sp[0]->s_vec, sp[0]->s_n); and then reference your values as described in the externals-HOWTO.
c) just at tip: you probably could move part of your value-checking into the set()-routine (everything but the check for >=n)
mfg.ads.r IOhannes
PS: i have found (and sometimes still find) it very useful to put post()s into all crucial points of my objects that happen to function not properly (and most of them are misbehaving in the beginning) of course this will flood your console when trying to debug dsp-objects. but still...you will most probably see a lot of interesting thing
PPS: an alternative would be to learn how to handle a real debugger (like gdb) - but i must admit, my knowledge for this is *very* rudimentary.