Hello. I've been trying to create a stereo audio effect based on how many red pixels there are on the screen, with a bias towards the left pixels for the left speaker, and the right pixels for the right speaker. For that, I need to get the red values of each pixel on screen, but I can't figure out how to do so. apparently I need to use lock() after getdata(), but adding it crashes the game and gives the error "Invalid call. Nonexistent function 'getpixel' in base 'Nil'." this is the faulty code in question.
leftamount = (get_viewport().get_texture().get_data().get_pixel(pixelcur.x, pixelcur.y).r) * effectleft
rightamount = (get_viewport().get_texture().get_data().get_pixel(pixelcur.x, pixelcur.y).r) * effectright