Re: [PD] 1 / 0 = 0?

2018-05-24 Thread Martin Peach
On Thu, May 24, 2018 at 12:43 PM, Alexandre Torres Porres 
wrote:

> Many math objects in pd have protection against nan/inf, not only in the
> audio control. It is the official policy
>
> I think it makes more sense to use FLT_MAX (1E+37) for +infinity, not
zero. For continuity with adjacent values. See attached patch.

Martin
#N canvas 270 322 450 300 10;
#X obj 191 112 / 1;
#X msg 179 52 1 1e-037;
#X obj 225 184 print;
#X floatatom 140 203 9 0 0 0 - - -;
#X connect 0 0 2 0;
#X connect 0 0 3 0;
#X connect 1 0 0 0;
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] 1 / 0 = 0?

2018-05-24 Thread Alexandre Torres Porres
expr can give you inf/nans eventually, but it was not originally part of
pd's core

2018-05-24 13:43 GMT-03:00 Alexandre Torres Porres :

> Many math objects in pd have protection against nan/inf, not only in the
> audio control. It is the official policy
>
> 2018-05-24 12:49 GMT-03:00 Martin Peach :
>
>> On Thu, May 24, 2018 at 10:57 AM, Christof Ressi 
>> wrote:
>>
>> there's no other sane way to handle division by 0 in the audio domain
>>> since the result must be a number and there are only two options: output 0
>>> or some ridiculously large number (which would be quite dangerous).
>>>
>>
>> Yes, but if you try division by a very small number close to zero you
>> still get very large numbers that audio hardware will clip to +-1; the
>> singularity at zero is weird.
>>
>> Martin
>>
>>
>> ___
>> Pd-list@lists.iem.at mailing list
>> UNSUBSCRIBE and account-management -> https://lists.puredata.info/li
>> stinfo/pd-list
>>
>>
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] 1 / 0 = 0?

2018-05-24 Thread Alexandre Torres Porres
Many math objects in pd have protection against nan/inf, not only in the
audio control. It is the official policy

2018-05-24 12:49 GMT-03:00 Martin Peach :

> On Thu, May 24, 2018 at 10:57 AM, Christof Ressi 
> wrote:
>
> there's no other sane way to handle division by 0 in the audio domain
>> since the result must be a number and there are only two options: output 0
>> or some ridiculously large number (which would be quite dangerous).
>>
>
> Yes, but if you try division by a very small number close to zero you
> still get very large numbers that audio hardware will clip to +-1; the
> singularity at zero is weird.
>
> Martin
>
>
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.puredata.info/
> listinfo/pd-list
>
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] 1 / 0 = 0?

2018-05-24 Thread Martin Peach
On Thu, May 24, 2018 at 10:57 AM, Christof Ressi 
wrote:

there's no other sane way to handle division by 0 in the audio domain since
> the result must be a number and there are only two options: output 0 or
> some ridiculously large number (which would be quite dangerous).
>

Yes, but if you try division by a very small number close to zero you still
get very large numbers that audio hardware will clip to +-1; the
singularity at zero is weird.

Martin
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] 1 / 0 = 0?

2018-05-24 Thread William Huston
Dear Christof,

I understand that tradeoff when working with real-time audio.

However, I was talking about control logic, not audio.

BH

--
William Huston:  williamahus...@gmail.com
Binghamton NY

*Public Service Mapping / Videography / Research*
Blog  -- Facebook
 -- Twitter
-- Youtube

Document collections: VirtualPipelines 
-- BHDCSDimockArchive 
Please support my work: TinyURL.com/DonateToBillHuston



On Thu, May 24, 2018 at 10:57 AM, Christof Ressi 
wrote:

> Hi William,
>
> there's no other sane way to handle division by 0 in the audio domain
> since the result must be a number and there are only two options: output 0
> or some ridiculously large number (which would be quite dangerous).
> Pd *could* handle it differently in the control domain, but why?
> as Matt said: just don't divide by 0 :-)
>
> Christof
>
>
> Gesendet: Donnerstag, 24. Mai 2018 um 16:52 Uhr
> Von: "Matt Davey" 
> An: "William Huston" 
> Cc: "pd-list@lists.iem.at" 
> Betreff: Re: [PD] 1 / 0 = 0?
> Just don’t allow your function to blow up in the first place.
>
> On Thursday, May 24, 2018, William Huston  mailto:williamahus...@gmail.com]> wrote:
>
> I have a function which blows up at a certain point, moves to infinity.
> In this case, it is basically 1/0.
>
> I was a little surprised to find that 1/0 = 0 (according to Pd).
> I was expecting NaN, or an overflow condition would could be trapped.
>
> So what I have to do is examine the *input* for the values
> which will blow up my function, and set a flag. While this
> is easy in this single case, it is awkward in the general case.
>
> This seems somewhat broken to me.
> Is this a bug?
>
> Thanks
> BH
>
>
>
> --
> William Huston:  williamahus...@gmail.com[mailto:williamahus...@gmail.com]
> Binghamton NY
>
> Public Service Mapping / Videography / Research
> Blog[http://WilliamAHuston.blogspot.com] -- Facebook[http://facebook.com/
> billhuston] -- Twitter [http://twitter.com/WilliamAHuston] -- Youtube[
> https://www.youtube.com/channel/UCGijK1amWOLglT3YeTyEBNQ?sub_
> congfirmation=1]
> Document collections: VirtualPipelines[http://TinyURL.com/VirtualPipelines]
> -- BHDCSDimockArchive[http://bit.ly/BHDCSDimockArchive]
> Please support my work: TinyURL.com/DonateToBillHuston[http://
> TinyURL.com/DonateToBillHuston]
>  ___ Pd-list@lists.iem.at
> mailing list UNSUBSCRIBE and account-management ->
> https://lists.puredata.info/listinfo/pd-list[https://
> lists.puredata.info/listinfo/pd-list]
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] [soundfile_info] made with vanilla

2018-05-24 Thread oliver

On 2018-05-24 16:43, Joe White wrote:

Hey Oliver,

I will admit to not fully digesting your patch, but from skim reading
it I'm assuming it loops over the sample data by incrementing the
-skip argument until you reach the end of the file.


well, more like see-sawing between a possible maximum of samples and 0,
and then find the last valid point "in the middle"

For my purposes

memory usage isn't really an issue, so I'd imagine it would be far
quicker to just load the whole sample into the table.


depends on the length of the file. if it's a 30 minute file,
this will freeze PD and probably lock the memory too. my approach tries 
to overcome that.
and also is of course much faster than waiting for a long file to get 
loaded into RAM just to know its length.




What would be nice is if [soundfiler] additionally read the data chunk
size property in the wav header for the number of samples. I imagine
that's why [soundfile_info] was created in the first place.


yes, that would be the nicest solution !

as alex pointed out, this is already a pull request. so, probably 
available in PD 0.49 ...


https://github.com/pure-data/pure-data/pull/193


until that, it's either [soundfile_info] or a workaround, like i 
proposed


best

oliver

___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] 1 / 0 = 0?

2018-05-24 Thread Christof Ressi
Hi William,
 
there's no other sane way to handle division by 0 in the audio domain since the 
result must be a number and there are only two options: output 0 or some 
ridiculously large number (which would be quite dangerous).
Pd *could* handle it differently in the control domain, but why? 
as Matt said: just don't divide by 0 :-)

Christof
 

Gesendet: Donnerstag, 24. Mai 2018 um 16:52 Uhr
Von: "Matt Davey" 
An: "William Huston" 
Cc: "pd-list@lists.iem.at" 
Betreff: Re: [PD] 1 / 0 = 0?
Just don’t allow your function to blow up in the first place. 

On Thursday, May 24, 2018, William Huston 
 wrote:

I have a function which blows up at a certain point, moves to infinity.
In this case, it is basically 1/0.
 
I was a little surprised to find that 1/0 = 0 (according to Pd).
I was expecting NaN, or an overflow condition would could be trapped.
 
So what I have to do is examine the *input* for the values
which will blow up my function, and set a flag. While this
is easy in this single case, it is awkward in the general case.
 
This seems somewhat broken to me.
Is this a bug?
 
Thanks
BH
 
 

--
William Huston:  williamahus...@gmail.com[mailto:williamahus...@gmail.com]
Binghamton NY

Public Service Mapping / Videography / Research
Blog[http://WilliamAHuston.blogspot.com] -- 
Facebook[http://facebook.com/billhuston] -- Twitter 
[http://twitter.com/WilliamAHuston] -- 
Youtube[https://www.youtube.com/channel/UCGijK1amWOLglT3YeTyEBNQ?sub_congfirmation=1]
Document collections: VirtualPipelines[http://TinyURL.com/VirtualPipelines] -- 
BHDCSDimockArchive[http://bit.ly/BHDCSDimockArchive]
Please support my work: 
TinyURL.com/DonateToBillHuston[http://TinyURL.com/DonateToBillHuston]
 ___ Pd-list@lists.iem.at mailing 
list UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list[https://lists.puredata.info/listinfo/pd-list]

___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] 1 / 0 = 0?

2018-05-24 Thread Matt Davey
Just don’t allow your function to blow up in the first place.

On Thursday, May 24, 2018, William Huston  wrote:

> I have a function which blows up at a certain point, moves to infinity.
> In this case, it is basically 1/0.
>
> I was a little surprised to find that 1/0 = 0 (according to Pd).
> I was expecting NaN, or an overflow condition would could be trapped.
>
> So what I have to do is examine the *input* for the values
> which will blow up my function, and set a flag. While this
> is easy in this single case, it is awkward in the general case.
>
> This seems somewhat broken to me.
> Is this a bug?
>
> Thanks
> BH
>
>
> --
> William Huston:  williamahus...@gmail.com
> Binghamton NY
>
> *Public Service Mapping / Videography / Research*
> Blog  -- Facebook
>  -- Twitter
> -- Youtube
> 
> Document collections: VirtualPipelines
>  -- BHDCSDimockArchive
> 
> Please support my work: TinyURL.com/DonateToBillHuston
>
>
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] [soundfile_info] made with vanilla

2018-05-24 Thread Joe White
Hey Oliver,

I will admit to not fully digesting your patch, but from skim reading it
I'm assuming it loops over the sample data by incrementing the -skip
argument until you reach the end of the file. For my purposes memory usage
isn't really an issue, so I'd imagine it would be far quicker to just load
the whole sample into the table.

What would be nice is if [soundfiler] additionally read the data chunk size
property in the wav header for the number of samples. I imagine that's why
[soundfile_info] was created in the first place.

Cheers,
Joe

On 24 May 2018 at 14:38, oliver  wrote:

> On 2018-05-24 15:03, Joe White wrote:
>
>> Hey Oliver,
>>
>> This is a neat trick, however for my purposes [soundfle_info] was
>> being used to extract both the sample rate and sample length to
>> calculate the duration of the file.
>>
>> Looks like in order to switch to [soundfiler] I'd have to load the
>> whole file to memory regardless, as the `-skip 1` flag means the left
>> outlet (sample length) of [soundfiler] only outputs '1'.
>>
>
> have a look again.
>
> in the middle of the patch, i use soundfiler's right outlet (available
> since PD 0.48, so make sure you are using this !) to get the file's
> samplerate, even though it is just reading 1 sample of it. so, no need to
> load the whole thing.
>
> the left part of the patch gives you the file's length in samples, which
> you can then re-calculate (using the file's samplerate) to ms or whatever
> you need.
>
> yes, the left outlet always only puts out 1 or 0, which i use to narrow
> down the last valid sample position, which is then the file's length in
> samples (endpoint).
>
> i send the patch again to illustrate what i mean (unless i misunderstood
> something)
>
> best
>
> oliver
>
>
>> Cheers,
>> Joe
>>
>> On 12 May 2018 at 19:37, Alexandre Torres Porres 
>> wrote:
>>
>> a new flag for [soundfiler] will make this easier without the need
>>> of a dummy buffer
>>>
>>> see https://github.com/pure-data/pure-data/pull/193 [1]
>>>
>>> 2018-05-12 14:06 GMT-03:00 oliver :
>>>
>>> Joe White wrote:
>>> Hi all,
>>>
>>> I recently spent a bit of time tracking down why a patch wasn't
>>> loading a couple of externals in a windows application that embeds
>>> libpd.
>>>
>>> The patch was using /vbap/ [0] and /soundfile_info/ from iemlib [1].
>>>
>>> hi,
>>>
>>> just the other night i was hacking together a [sound_file] info
>>> alternative with purely vanilla objects WITHOUT loading an entire
>>> file into RAM.
>>>
>>> the method is basically to use [soundfiler] to load 1 sample of a
>>> file into a table with a -skip message, and recalculate the skip
>>> position until [soundfiler]'s left outlet outputs 1 (instead of 0).
>>>
>>> all of [soundfile_info]'s other values are also output from
>>> [soundfiler]'s right outlet as of PD version 0.48.
>>>
>>> it takes a tad longer than [soundfile_info] to output the
>>> soundfile's length, but it's acceptable imho. plus you can use .aiff
>>> too !
>>>
>>> best
>>>
>>> oliver
>>>
>>> ___
>>> Pd-list@lists.iem.at mailing list
>>> UNSUBSCRIBE and account-management ->
>>> https://lists.puredata.info/listinfo/pd-list [2]
>>>
>>
>> ___
>> Pd-list@lists.iem.at mailing list
>> UNSUBSCRIBE and account-management ->
>> https://lists.puredata.info/listinfo/pd-list [2]
>>
>>
>>
>> Links:
>> --
>> [1] https://github.com/pure-data/pure-data/pull/193
>> [2] https://lists.puredata.info/listinfo/pd-list
>>
>
> ___
> Pd-list@lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.puredata.info/
> listinfo/pd-list
>
>
___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list


Re: [PD] [soundfile_info] made with vanilla

2018-05-24 Thread oliver

On 2018-05-24 15:03, Joe White wrote:

Hey Oliver,

This is a neat trick, however for my purposes [soundfle_info] was
being used to extract both the sample rate and sample length to
calculate the duration of the file.

Looks like in order to switch to [soundfiler] I'd have to load the
whole file to memory regardless, as the `-skip 1` flag means the left
outlet (sample length) of [soundfiler] only outputs '1'.


have a look again.

in the middle of the patch, i use soundfiler's right outlet (available 
since PD 0.48, so make sure you are using this !) to get the file's 
samplerate, even though it is just reading 1 sample of it. so, no need 
to load the whole thing.


the left part of the patch gives you the file's length in samples, which 
you can then re-calculate (using the file's samplerate) to ms or 
whatever you need.


yes, the left outlet always only puts out 1 or 0, which i use to narrow 
down the last valid sample position, which is then the file's length in 
samples (endpoint).


i send the patch again to illustrate what i mean (unless i misunderstood 
something)


best

oliver



Cheers,
Joe

On 12 May 2018 at 19:37, Alexandre Torres Porres 
wrote:


a new flag for [soundfiler] will make this easier without the need
of a dummy buffer

see https://github.com/pure-data/pure-data/pull/193 [1]

2018-05-12 14:06 GMT-03:00 oliver :

Joe White wrote:
Hi all,

I recently spent a bit of time tracking down why a patch wasn't
loading a couple of externals in a windows application that embeds
libpd.

The patch was using /vbap/ [0] and /soundfile_info/ from iemlib [1].

hi,

just the other night i was hacking together a [sound_file] info
alternative with purely vanilla objects WITHOUT loading an entire
file into RAM.

the method is basically to use [soundfiler] to load 1 sample of a
file into a table with a -skip message, and recalculate the skip
position until [soundfiler]'s left outlet outputs 1 (instead of 0).

all of [soundfile_info]'s other values are also output from
[soundfiler]'s right outlet as of PD version 0.48.

it takes a tad longer than [soundfile_info] to output the
soundfile's length, but it's acceptable imho. plus you can use .aiff
too !

best

oliver

___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management ->
https://lists.puredata.info/listinfo/pd-list [2]


___
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management ->
https://lists.puredata.info/listinfo/pd-list [2]



Links:
--
[1] https://github.com/pure-data/pure-data/pull/193
[2] https://lists.puredata.info/listinfo/pd-list
#N canvas 89 106 924 751 10;
#X obj 91 583 cnv 15 220 25 empty empty length_in_samples 80 12 0 14
-261682 -66577 0;
#X obj 406 478 cnv 15 170 25 empty empty samplerate 80 12 0 14 -261234
-66577 0;
#X obj 80 274 soundfiler;
#X obj 50 138 table test 1;
#X obj 50 189 t f f, f 8;
#X obj 80 321 f;
#X obj 80 296 sel 0 1, f 58;
#X msg 398 410 1;
#X obj 80 376 list prepend;
#X obj 252 325 f;
#X obj 252 383 list append;
#X obj 80 348 t f f;
#X obj 252 348 t f f;
#X obj 80 489 t f f f;
#X obj 98 517 !=, f 4;
#X obj 50 517 spigot;
#X obj 98 563 f;
#X obj 98 539 sel 0;
#X floatatom 398 578 10 0 0 0 - - -, f 10;
#X obj 717 195 soundfile_info;
#X obj 398 556 realtime;
#X obj 717 120 t b b, f 7;
#X floatatom 756 307 10 0 0 0 - - -, f 10;
#X obj 756 284 realtime;
#X obj 799 260 t b;
#X obj 717 93 bng 20 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X floatatom 98 648 10 0 0 0 - - -, f 10;
#X floatatom 685 371 10 0 0 0 - - -, f 10;
#X obj 80 400 t l l;
#X msg 107 423 \$2 \$1;
#X obj 107 445 -;
#X obj 107 466 * 0.5;
#X obj 80 466 +;
#X msg 80 423 \$1, f 2;
#X msg 379 353 \$1;
#X msg 685 222 \$3 \$1;
#X obj 685 243 /;
#X obj 322 331 soundfiler;
#X obj 379 376 t b b f;
#X msg 322 261 read \$1 test;
#X msg 80 250 read -skip \$1 \$2 test;
#X obj 238 187 t s s, f 11;
#X obj 80 225 pack 0 s, f 25;
#X obj 98 624 /, f 5;
#X floatatom 418 484 10 0 0 0 - - -, f 10;
#X msg 379 439 5e+008;
#X obj 238 55 openpanel;
#X obj 238 15 bng 30 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 278 120 list trim;
#X msg 238 145 symbol 
D:/#audio/hotelzimmerverwuestung/hotelzimmerverw_4_remaster.wav
;
#X obj 238 99 t b s;
#X obj 238 76 symbol;
#X obj 278 99 list prepend set symbol;
#X text 450 432 highest possible number (~ 188 minutes at 44100 khz)
, f 30;
#X text 429 409 lowest possible number (1 sample);
#X msg 717 172 read \$1;
#X obj 717 150 symbol;
#X text 167 646 <- length in milliseconds;
#X text 684 388 length in milliseconds;
#X text 728 222 samples / samplerate;
#X text 140 623 samples / samplerate;
#X text 280 20 load soundfile to calculate its length;
#X text 51 33 slower but vanilla:;
#X text 714 68 faster but needs [iemlib]:;
#X text 396 595 calc duration;
#X text 754 322 calc duration;
#X text 431 326 for some strange reason \, the samplerate has to be
calculated