帮助将这个AS3 code到Pixel Bender的code [英] help converting this as3 code to pixel bender code

查看:168
本文介绍了帮助将这个AS3 code到Pixel Bender的code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一些帮助将AS3 code到pixelbender code,企图以提高我的应用程序的性能。

这AS3 code去如下。我通过大块的ByteArray的数量值扫描。比方说这个块lenght 100号我读2号(左,右),并尝试找到的最大值。在我的ByteArray的数字是PCM数据,因此有百万人,这code往往需要很长的时间来执行,特别是在低规格的机器。

的此整个的目的是尽可能快地呈现的波形。我不是很了解的Pixel Bender。我基本上可以做一个新的文件,并创建它在Flash中的ShaderJob但我真的不确定如何处理这...

我想我真的问我如何通过pixelbender要么

A)号的大块,并把它传给我回来2最大值(左,右)

B)我的整个字节组,并得到Pixel Bender的做了分块的东西对我来说

  VAR spritePixelIndex:数= 0;
            VAR spriteSize:数字;
            spriteSize = _sizes [_numberOfZoomLevels  -  1];
            块大小= Math.floor(_pcmLength / spriteSize);
                块大小=块大小* 100;


对于(VAR我:= 0; I<块大小; ++ I)
            {
                如果(_pcmData.bytesAvailable)
                {
                    VAR LA:数= _pcmData.readFloat();
                    变种RA:数= _pcmData.readFloat();
                    VAR L:数= LA> 0.0? LA:-La;
                    变种R:数= RA> 0.0? RA:-ra;

                    ++ _ divCount;
                    VAR毫升:数= 0;
                    VAR先生:数= 0;
                    VAR a_ml:数=毫升> 0.0?毫升:-ml;
                    VAR a_mr:数=先生> 0.0?先生:-mr;

                    毫升= a_ml> (升)?毫升:L;
                    MR = a_mr> (r)的?先生,R;
                }
}
 

解决方案

Pixel Bender的是不是合适的工具完成这个任务,因为它不支持循环,因而无法通过数据数组搜索,返回单个值。这还不能值传递到下一个处理块,这将是很好的,因为那么你可以只比较当前块的previously发现最大的,就像在链斗。

相反,我建议你看一看炼金术,并利用其快速的ByteArray运codeS快速通过数据搜索。 JOA艾伯特和布拉克Kalayci兼得构建辅助工具,让您使用这些运codeS即使没有C语言编程的需要:的 http://philippe.elsass.me/2010/05/as3-fast-memory-access-without-alchem​​y/

I'm looking for some help converting as3 code to pixelbender code in an attempt to improve the performance of my application.

This as3 code goes as follows. I scan through the Number values of a bytearray in chunks. Lets say this chunk lenght was 100 numbers I read 2 numbers (left and right) and try find the maximum values. The numbers in my bytearray are PCM data so there is millions of them and this code can often take a long time to execute, especially on a low spec machine.

The whole aim of this is to render a waveform as quickly as possible. I know very little about pixel bender. I can basically make a new file and create a shaderJob of it in flash but I'm really uncertain how to approach this...

I guess I'm really asking how do I pass pixelbender either

A) a "chunk" of numbers and get it to pass me back 2 maximum values (left and right)

or

B) my entire bytearray and get pixel bender to do the chunking stuff for me

var spritePixelIndex:Number=0;
            var spriteSize:Number;
            spriteSize=_sizes[_numberOfZoomLevels - 1];
            blockSize=Math.floor(_pcmLength / spriteSize);
                chunksize=blockSize * 100;


for (var i:int=0; i < chunksize; ++i)
            {
                if (_pcmData.bytesAvailable)
                {
                    var la:Number=_pcmData.readFloat();
                    var ra:Number=_pcmData.readFloat();
                    var l:Number=la > 0.0 ? la : -la;
                    var r:Number=ra > 0.0 ? ra : -ra;

                    ++_divCount;
                    var ml:Number=0;
                    var mr:Number=0;
                    var a_ml:Number=ml > 0.0 ? ml : -ml;
                    var a_mr:Number=mr > 0.0 ? mr : -mr;

                    ml=a_ml > (l) ? ml : l;
                    mr=a_mr > (r) ? mr : r;
                }
}

解决方案

Pixel Bender is not the right tool for this task, since it does not support loops and thus cannot search through an array of data to return you single values. It can also not pass values over to the next processed chunk, which would be nice since then you could just compare the current chunk with the previously found maximum, like in a bucket chain.

Instead I recommend you to have a look at Alchemy and use its fast bytearray opcodes to quickly search through your data. Joa Ebert and Burak Kalayci have both build helper tools that allow you to use these opcodes even without the need to program in C: http://philippe.elsass.me/2010/05/as3-fast-memory-access-without-alchemy/

这篇关于帮助将这个AS3 code到Pixel Bender的code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆