Dear list,
I play a file using sound [readanysf~] which has the function of showing me the approximate time in seconds--unfortunately the numbers at the output are not always the same(but using always the same soundfile).
I need to send a 1-message 3 seconds before the file stops--so I compare the actual time with the overall time of the (soundfile -3)---the problem is now that sometimes the [==] message never sends a 1 because the left input sometimes reaches now value that equals (filelength-3).
print: 14.7215 print: 16.1844 print: 17.6472
soundfilelength=18.49 int(soundfilelength-3)=15
when the output of the seconds of readanysf~ is like above--it doesn't equal 15
How can I quickly solve that?
Attached is a patch+*.wav illustrating the problem.
Thank you. Gerda
#N canvas 0 0 615 439 10; #X obj 220 162 readanysf~; #X obj 285 197 route float length; #X obj 285 300 ==; #X floatatom 345 293 5 0 0 0 - - -; #X obj 285 342 print now; #X floatatom 345 225 5 0 0 0 - - -; #X floatatom 285 255 5 0 0 0 - - -; #X obj 345 249 int; #X obj 285 278 int; #X obj 345 271 - 3; #X obj 300 323 s end; #X obj 440 235 loadbang; #X msg 439 256 18; #X msg 220 134 open /home/gerda/campioni_pd/earth41.wav; #X msg 164 100 start; #X obj 221 221 dac~ 1; #X floatatom 229 370 5 0 0 0 - - -; #X obj 225 288 print; #X connect 0 0 15 0; #X connect 0 2 1 0; #X connect 1 0 6 0; #X connect 1 1 5 0; #X connect 2 0 4 0; #X connect 2 0 10 0; #X connect 2 0 16 0; #X connect 5 0 7 0; #X connect 6 0 8 0; #X connect 6 0 17 0; #X connect 7 0 9 0; #X connect 8 0 2 0; #X connect 9 0 2 1; #X connect 9 0 3 0; #X connect 11 0 12 0; #X connect 12 0 2 1; #X connect 13 0 0 0; #X connect 14 0 0 0;
Hi,
Gerda Strobl wrote:
Dear list,
I need to send a 1-message 3 seconds before the file stops--so I compare the actual time with the overall time of the (soundfile -3)---the problem is now that sometimes the [==] message never sends a 1 because the left input sometimes reaches now value that equals (filelength-3).
print: 14.7215 print: 16.1844 print: 17.6472
soundfilelength=18.49 int(soundfilelength-3)=15
when the output of the seconds of readanysf~ is like above--it doesn't equal 15
How can I quickly solve that?
I would get a single bang from the (variable) play time and the (fixed) total time using [>=], [change], and [select 1]. The important thing is the ">=", because float "==" is inherently inaccurate, due to rounding errors and other limitations of floating point numbers. ">=" is useable as a trigger source when you know that the variable is steadily increasing.
Claude Heiland-Allen wrote:
I would get a single bang from the (variable) play time and the (fixed) total time using [>=], [change], and [select 1]. The important thing is the ">=", because float "==" is inherently inaccurate, due to rounding errors and other limitations of floating point numbers. ">=" is useable as a trigger source when you know that the variable is steadily increasing.
Claude
Yuhuu! Thank you Claude, that's it!
Thank you, Gerda
Dear list,
I play a file using sound [readanysf~] which has the function of showing me the approximate time in seconds--unfortunately the numbers at the output are not always the same(but using always the same soundfile).
I need to send a 1-message 3 seconds before the file stops--so I compare the actual time with the overall time of the (soundfile -3)---the problem is now that sometimes the [==] message never sends a 1 because the left input sometimes reaches now value that equals (filelength-3).
Gerda,
just so you know, you can increase the resolution of the information output of readanysf~ by sending it a [set_tick n( message, where n is some integer value.
[set_tick 1( means it will output the soundfile info every time at the audio rate...which is set to default at 64 samples. That would be very fast, and probably very undesirable if you are showing the numbers in your patch. It will eat your CPU.
I think readanysf~ will have a tick of 100 by default, or once every 6,400 audio samples (for a block size of 64).
viel spass -august.
august wrote:
Gerda,
just so you know, you can increase the resolution of the information output of readanysf~ by sending it a [set_tick n( message, where n is some integer value.
[set_tick 1( means it will output the soundfile info every time at the audio rate...which is set to default at 64 samples. That would be very fast, and probably very undesirable if you are showing the numbers in your patch. It will eat your CPU.
I think readanysf~ will have a tick of 100 by default, or once every 6,400 audio samples (for a block size of 64).
viel spass -august.
Hi August, cool--I just saw that you actuallay included the [set_tick] message in your helpfile-I completely overlooked that. But thanks for your detailed explanation, that' useful.
lg Gerda