PnS Script Question
-
- KVRist
- 40 posts since 6 May, 2021
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;
}
}
void processSample(array<double>& ioSample)
{
for(uint channel=0;channel<audioInputsCount;channel++)
{
ioSample[channel]*=gain;
}
}
-
Blue Cat Audio Blue Cat Audio https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=39981
- KVRAF
- 6345 posts since 8 Sep, 2004 from Paris (France)
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
- 40 posts since 6 May, 2021
OK thanks. is it something to do with stopping the index from going into negative numbers?
-
Blue Cat Audio Blue Cat Audio https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=39981
- KVRAF
- 6345 posts since 8 Sep, 2004 from Paris (France)
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
- 316 posts since 28 May, 2011
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.