W3C home > Mailing lists > Public > public-audio@w3.org > April to June 2013

Re: WaveShaperNode.curve

From: Robert O'Callahan <robert@ocallahan.org>
Date: Tue, 14 May 2013 15:37:55 +1200
Message-ID: <CAOp6jLb7ZBKXD8G1QPp9GO+yVOjtPhRY1DHvQGGE0iSyL0KWCA@mail.gmail.com>
To: Srikumar Karaikudi Subramanian <srikumarks@gmail.com>
Cc: Ehsan Akhgari <ehsan.akhgari@gmail.com>, Chris Rogers <crogers@google.com>, "public-audio@w3.org" <public-audio@w3.org>
On Tue, May 14, 2013 at 2:58 PM, Srikumar Karaikudi Subramanian <
srikumarks@gmail.com> wrote:

> shaper.curve = new Float32Array(100);
>>> for (var i = 0; i < 100; ++i) {
>>>   // oops, at this point the array has been internally copied,
>>>   // and while the code below doesn't throw an exception,
>>>   // it effectively sets the curve property to an all-0 array,
>>>   // which is not what the author has intended.
>>>   shaper.curve[i] = whatever;
>>> }
>>>
>>
> This code will bomb anyway if the array is neutered after setting the
> curve (the length of a
> neutered array is 0).
>

That's a good thing. Code that fails obviously and synchronously is better
than code that silently fails to work, from the point of view of an author
trying to find bugs.


> Furthermore, what would be
> the point of having a getter for the shaper.curve property if all it will
> provide is a neutered array?
> RoC's suggestion of a setCurve() without a getter is in this case a much
> cleaner solution.
>

We could arrange for the getter of 'curve' to return a new non-neutered
array, with the old contents, if the original array has been neutered.


> In general, please consider whether any "setBlah" qualifies as a full
> property before
> also including a getter for it. In this case, what we (devs) really need
> is a write-only property
> to avoid all this potential confusion. A setCurve() will offer a clear
> point where any consistency
> checks on the array can be expected to be performed.
>

Sounds good to me :-). Maybe we could add setCurve(), deprecate the
attribute, make setting the attribute neuter the array, and make getting
the attribute return a new array with the latest curve data.

Rob
-- 
q“qIqfq qyqoquq qlqoqvqeq qtqhqoqsqeq qwqhqoq qlqoqvqeq qyqoquq,q qwqhqaqtq
qcqrqeqdqiqtq qiqsq qtqhqaqtq qtqoq qyqoquq?q qEqvqeqnq qsqiqnqnqeqrqsq
qlqoqvqeq qtqhqoqsqeq qwqhqoq qlqoqvqeq qtqhqeqmq.q qAqnqdq qiqfq qyqoquq
qdqoq qgqoqoqdq qtqoq qtqhqoqsqeq qwqhqoq qaqrqeq qgqoqoqdq qtqoq qyqoquq,q
qwqhqaqtq qcqrqeqdqiqtq qiqsq qtqhqaqtq qtqoq qyqoquq?q qEqvqeqnq
qsqiqnqnqeqrqsq qdqoq qtqhqaqtq.q"
Received on Tuesday, 14 May 2013 03:38:23 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:03:18 UTC