codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
// some generated float data float[] data = new float[](256); data[] = 1.0f; // output data isn't explicitly typed because you only get this // information at runtime, it can be one of numerous types // (int16, int32, float, double..) void[] output; // the soundcard initializes this buffer (assume size 256 in this code) // soundcard tells us it wants sample data typed as ints, so we use that int[] writeTo = cast(int[])output; // actual conversion from float data to int data foreach (inputSample, ref outputSample; lockstep(data, writeTo)) { outputSample = to!int((inputSample * 0x7FFF_0000) - 0.5f); }
Private
[
?
]
Run code
Submit