2 Replies Latest reply on Feb 5, 2010 7:10 AM by phaseblue

    How many bytes is the "pixel" data type?

    phaseblue Level 1

      I`m fairly new to using Pixel Bender to process audio data, so I`m sorry for my lack of understanding with regards to the following.

      I had a question about the "pixel" and "image" data types in Pixel Bender.

       

      I am trying to figure out the code Kevin Goldsmith wrote for his 2-channel audio mixer and there seems to be a discrepancy between the amount of data being sent to the PB shader, and the amount being received each time the buffer is sent to it for processing.

       

      Here is the link to the code:

      http://blogs.adobe.com/kevin.goldsmith/2009/08/pixel_bender_au.html

       

      At the top of the code, he declares a "BUFFER" constant of 2048:

      private static var BUFFER_SIZE:uint = 0x800;

       

      Then, in the processSound() function, he sets up a byteArray with a size of 16,384 bytes:

      shaderBuffer.length = BUFFER_SIZE * 2 * 4;     <--- (2048 * 2 stereo samples * 4 bytes/sample)

       

      However, I`m confused about the part where he defines a hypothetical image and sends the data off to the shader:

      effectShader.data["source"].width = BUFFER_SIZE / 1024;     <--- (2048 / 1024 = 2)

      effectShader.data["source"].height = 512;

       

      From the above code, one can easily see that the image size is only 1024 "pixels" (2 * 512), and on the receiving end there is an "image4" input variable waiting to receive it.  So far, I have been under the assumption that an "image4" data type is composed of a varying amount of pixels (determined by the size of the image that is feed into it), each composed of 4, 1-byte color channels.  Following this logic, each pixel in an "image4" data type should consist of 4 bytes.  Now, let`s do the math:  4 bytes * 1024 pixels = 4096.

       

      4096 does not equal 16,384!

      How can you feed a 16,384 byte "byteArray" into a 4096 byte "image4" variable?

       

      I`m sorry to sound presumptuous with the above explanation, but I just can`t figure out what is going on here!

      How many bytes is a "pixel" in PB?  Does it hold float or integer values, or either?

       

      I have scoured the web to find out these answers, but to no avail!  Perhaps I`m off the mark with my current understanding of pixels and images in PB, but I need to figure this out before I can move on with the application I am making.

       

      I greatly appreciate any advice/information anyone can give.

       

      Thanks,

       

      Matt