Andrej Mitrovic Wrote:

> So, I need to convert a float[] to an int[] for some use with audio. The 
> conversion operation is to multiply each sample (the value) with 0x7FFF_0000, 
> and decrement with .5f, round this operation to an int and store it as the 
> new sample.
> 
> So here's how a float>int conversion looks like:
> 
> http://codepad.org/bqINREKG
> 
> 
> Now, I wanted to replace the foreach loop with a vector op. So first I've 
> tried this:
> 
> writeTo[] = to!int((data[] * 0x7FFF_0000) - 0.5f)
> 
> This won't work. I've tried to do a simple cast:
> 
> writeTo[] = cast(int[])((data[] * 0x7FFF_0000) - 0.5f);
> 
> floatToInt.d(26): Error: Array operation data[] * 0x1.fffcp+30F - 0.5F not 
> implemented

Well if the error is correct, this should mean you are doing it right, but the 
feature doesn't exist yet.

While it won't get you the performance gain, there is also map,

auto writeTo = array(map!"a*0x7FFF_0000 - 0.5f"(data));

Reply via email to