PnS Script Question

Official support for: bluecataudio.com
Post Reply New Topic
RELATED
PRODUCTS

Post

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;
}
}

Post

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

Post

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

Post

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

Post

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.

Post Reply

Return to “Blue Cat Audio”