X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/1059e1cc0c2ecfa237406949aa26155b6a5b9154..66f23d4fabf89ad09adbd4dfc15ac6b5b2b7da83:/interpretor/lib/src/libsndfile-ocaml/test_sndfile_bigarray.ml diff --git a/interpretor/lib/src/libsndfile-ocaml/test_sndfile_bigarray.ml b/interpretor/lib/src/libsndfile-ocaml/test_sndfile_bigarray.ml deleted file mode 100644 index f6caa1c..0000000 --- a/interpretor/lib/src/libsndfile-ocaml/test_sndfile_bigarray.ml +++ /dev/null @@ -1,46 +0,0 @@ -(* Rudimentary testing of the Ocaml libsndfile wrapper. *) - -let write_test filename = - let fmt = Sndfile.format Sndfile.MAJOR_WAV Sndfile.MINOR_PCM_16 in - let file = Sndfile.openfile filename ~info:(Sndfile.WRITE, fmt, 2, 44100) () in - if Sndfile.error file != 0 then - Printf.printf "Error writing '%s' : %s\n" filename (Sndfile.strerror file) - else - let writecount = Sndfile_bigarray.write_short file [| 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.5 |] in - Printf.printf "Wrote %d items.\n" writecount ; - Sndfile.close file - -let read_test filename = - let file = Sndfile.openfile filename () in - Printf.printf "File contains %Ld frames.\n" (Sndfile.frames file) ; - let data = Array.create 100 0.0 in - let readcount = Sndfile_bigarray.read_short file data in - Printf.printf "Read %d items.\n" readcount ; - Sndfile.close file - -let finalize_test filename = - let sub_open_file = - let file = Sndfile.openfile filename () in - ignore file - in - (* Compact the heap. *) - Gc.compact () ; - let pre_stat = Gc.stat () in - sub_open_file ; - (* Compact the heap again. *) - Gc.compact () ; - (* Compare before and after. *) - let post_stat = Gc.stat () in - if pre_stat.Gc.heap_words != post_stat.Gc.heap_words then - ( Printf.printf "\nFinalize not working : before %d -> after %d\n\n" pre_stat.Gc.heap_words post_stat.Gc.heap_words ; - exit 1 - ) - else () - - -let _ = - print_endline "------------------------" ; - let filename = "a.wav" in - write_test filename ; - read_test filename ; - finalize_test filename