Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start using floatarray internally. #17

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/id.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let () =
FFT.Window.cosine c;
FFT.fft fft c;
let c = Array.map (fun c -> c.Complex.re) c in
let buf = Array.make read#channels c in
let buf = Float.Array.make read#channels c in
write#write buf 0 (Audio.length buf)
done;
write#close;
Expand Down
21 changes: 10 additions & 11 deletions examples/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let () =
A.U8.of_audio src 0 buf 0 len;
A.U8.to_audio (Bytes.unsafe_to_string buf) 0 dst 0 len
done;
assert (dst.(1).(len - 1) = 1.));
assert (dst.(1).!(len - 1) = 1.));
let src = A.make 2 len 1. in
let buf = Bytes.create (A.S16LE.size 2 len) in
let dst = A.create 2 len in
Expand All @@ -78,8 +78,8 @@ let () =
A.S16LE.of_audio src 0 buf 0 len;
A.S16LE.to_audio (Bytes.unsafe_to_string buf) 0 dst 0 len
done;
assert (dst.(1).(len - 1) = 1.);
assert (dst.(1).(len - 1) = 1.));
assert (dst.(1).!(len - 1) = 1.);
assert (dst.(1).!(len - 1) = 1.));
let src = A.make 2 len 1. in
let buf = Bytes.create (A.S16BE.size 2 len) in
let dst = A.create 2 len in
Expand All @@ -88,8 +88,8 @@ let () =
A.S16BE.of_audio src 0 buf 0 len;
A.S16BE.to_audio (Bytes.unsafe_to_string buf) 0 dst 0 len
done;
assert (dst.(1).(len - 1) = 1.);
assert (dst.(1).(len - 1) = 1.));
assert (dst.(1).!(len - 1) = 1.);
assert (dst.(1).!(len - 1) = 1.));
let src = A.make 2 len 1. in
let buf = Bytes.create (A.S24LE.size 2 len) in
let dst = A.create 2 len in
Expand All @@ -98,8 +98,8 @@ let () =
A.S24LE.of_audio src 0 buf 0 len;
A.S24LE.to_audio (Bytes.unsafe_to_string buf) 0 dst 0 len
done;
assert (dst.(1).(len - 1) = 1.);
assert (dst.(1).(len - 1) = 1.));
assert (dst.(1).!(len - 1) = 1.);
assert (dst.(1).!(len - 1) = 1.));
let src = A.make 2 len 1. in
let buf = Bytes.create (A.S32LE.size 2 len) in
let dst = A.create 2 len in
Expand All @@ -108,7 +108,7 @@ let () =
A.S32LE.of_audio src 0 buf 0 len;
A.S32LE.to_audio (Bytes.unsafe_to_string buf) 0 dst 0 len
done;
assert (dst.(1).(len - 1) = 1.));
assert (dst.(1).!(len - 1) = 1.));
test "s16le with offset" (fun () ->
let chans = 2 in
let src = A.create chans len in
Expand Down Expand Up @@ -286,8 +286,7 @@ let () =
let b = I.YUV420.create 640 480 in
let x = 1280 in
let y = 0 in
I.YUV420.add a ~x ~y b
);
I.YUV420.add a ~x ~y b);
time "many adds" (fun () ->
let r = I.YUV420.create 500 500 in
I.YUV420.fill r (I.Pixel.yuv_of_rgb (0xff, 0, 0));
Expand Down Expand Up @@ -387,7 +386,7 @@ let () =
output_string oc (Video.AVI.Writer.Chunk.video_yuv420 img);
for i = 0 to Audio.length buf - 1 do
for c = 0 to Audio.channels buf - 1 do
buf.(c).(i) <- !osc
buf.(c).!(i) <- !osc
done;
osc := !osc +. (2. *. f /. float samplerate);
while !osc > 1. do
Expand Down
2 changes: 1 addition & 1 deletion external/mm_mad.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class virtual reader =
channels <- c;
rb <- Audio.Ringbuffer_ext.create channels 0

method private decode = Mad.decode_frame_float self#mf
method private decode = Mad.decode_frame_floatarray self#mf
method close = self#stream_close

method read buf ofs len =
Expand Down
2 changes: 1 addition & 1 deletion external/mm_pulseaudio.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ class writer client_name stream_name channels rate =
in
Simple.create ~client_name ~dir:Dir_playback ~stream_name ~sample ()

method write = Simple.write dev
method write = Simple.write_floatarray dev
method close = Simple.free dev
end
Loading