PnS Script Question

Official support for: bluecataudio.com
KVRist
34 posts since 6 May, 2021

Post Thu Oct 21, 2021 12:53 pm

Hello, I wonder could you tell me why you use an unsigned integer here, and why not just int?

void processSample(array<double>& ioSample)
{
for(uint channel=0;channel<audioInputsCount;channel++)
{
ioSample[channel]*=gain;
}
}

User avatar
KVRAF
4779 posts since 8 Sep, 2004 from Paris (France)

Post Fri Oct 22, 2021 12:34 am

It's just because Angelscript is a bit picky on types, and most indexes (array lengths etc.) are implemented with unsigned integers.

KVRist

Topic Starter

34 posts since 6 May, 2021

Post Sat Oct 23, 2021 7:44 am

OK thanks. is it something to do with stopping the index from going into negative numbers?

User avatar
KVRAF
4779 posts since 8 Sep, 2004 from Paris (France)

Post Mon Oct 25, 2021 1:43 am

Index is indeed not supposed to be negative, so using an unsigned int gives you a larger range, I guess that's the reason.

KVRist
281 posts since 28 May, 2011

Post Mon Oct 25, 2021 7:33 am

In general AngelScript array index error is one of the most common problems, because it is a silent error and the script just stops working, so you just have to guess what's wrong. And very often it's because you've tried to access a non-existent array index. So I always try to make sure the array is of a proper size using arrayname.resize(the_size) before accessing it.

Return to “Blue Cat Audio”