English 中文(简体)
AS3 透射浮体从正确提取物转换
原标题:AS3 Alchemy byteArray float conversion from sound extract

我试图做一些简单的事:

向一个C图书馆派遣一个星座,填补一个缓冲地带,并读到记忆中,但我认为,我存在着转换问题。

这里,我是在以下行动中做的:

var memory:ByteArray = gstate.ds;
// get sound
var soundBytes:ByteArray = new ByteArray();
_source.extract(soundBytes, 4096);
soundBytes.position = 0;
// send sound
_lib.processSound(soundBytes);
// get sound back to play it
memory.position = _dataPosition
event.data.writeBytes(memory);

《刑法》:

我的缓冲变量:

float *buffer;

缓冲区一开始便衣着:

static AS3_Val initByteArray(void* self, AS3_Val args) {
    AS3_ArrayValue(args, "IntType", &bufferSize);
    buffer = (float*)malloc(bufferSize*sizeof(float));
    return AS3_Int((int)buffer);
}

我处理的是:

AS3_Val src = AS3_Undefined();
AS3_ArrayValue( args,"AS3ValType", &src );
// get length
AS3_Val lengthOfArgs = AS3_GetS(src,"length");
int len = AS3_IntValue(lengthOfArgs);
// set position to 0 and write the buffer
AS3_ByteArray_seek(src, 0, SEEK_SET);
AS3_Trace(AS3_GetS(src, "bytesAvailable"));
AS3_ByteArray_readBytes(buffer, src, len);

现在我犯了错误:

Exception fault: RangeError: Error #2004: One of the parameters is invalid. at flash.media::Sound/play()

在我写在缓冲地带时,记忆似乎正确增加,4096天,为32768人,为8人(左翼和右频道为4人)。

当我在寄送提格雷之前追踪闪电时,我有类似数目(具体立场是1421年比较):

soundBytes.position = 1421 * 8;
trace(soundBytes.readFloat()); // trace -0.000030517578125 (left)
trace(soundBytes.readFloat()); // trace 0.000030517578125 (right)

在C中,我可以找到同样的编号:

AS3_ByteArray_seek(src, 1421*8, SEEK_SET);
AS3_Val emptyParams = AS3_Array("");
AS3_Val readFloat = AS3_GetS(src, "readFloat");
AS3_Trace(readFloat);
AS3_Val left = AS3_Call(readFloat, src, emptyParams);
AS3_Trace(left); // trace -0.000030517578125 (left)
AS3_Val right = AS3_Call(readFloat, src, emptyParams);
AS3_Trace(right); // trace 0.000030517578125 (right)

但是,当我追踪缓冲区时:

AS3_Trace(AS3_Number(buffer[1421*2])); // trace 2.5783891743576634e-43
AS3_Trace(AS3_Number(buffer[(1421*2)+1])); trace 7.847271400218976e-44

在打字之后的闪光中:

soundBytes.position = 1421 * 8;
trace(soundBytes.readFloat()); // trace 2.5783891743576634e-43
trace(soundBytes.readFloat()); // trace 7.847271400218976e-44

我看一看该数字已经转换或具有不同的类型/格式:

-0.000030517578125 vs 2.5783891743576634e-43

不要说C的流利,对发生什么的想法是什么?

感谢阅读。

Romu

问题回答

暂无回答




相关问题
Haskell minimum/maximum Double Constant

Is there any way in Haskell to get the constant that is the largest and smallest possible positive rational number greater than zero that can be represented by doubles?

integer automatically converting to double but not float

I have a function like below: void add(int&,float&,float&); and when I call: add(1,30,30) it does not compile. add(1,30.0,30.0) also does not compile. It seems that in both cases, it ...

Lower Bounds For Floating Points

Are there any lower bounds for floating point types in C? Like there are lower bounds for integral types (int being at least 16 bits)?

Floating point again

Yesterday I asked a floating point question, and I have another one. I am doing some computations where I use the results of the math.h (C language) sine, cosine and tangent functions. One of the ...

热门标签