From 56dfd444134acccdb1e9f946292ea4ed2eea2ba0 Mon Sep 17 00:00:00 2001 From: nantonel Date: Wed, 12 May 2021 18:15:57 +0200 Subject: [PATCH 01/22] updating to latest FileIO --- .gitignore | 2 + Manifest.toml | 334 +++++++++++++++++++++++++++++++++------------ Project.toml | 6 + src/LibSndFile.jl | 9 -- test/Manifest.toml | 242 -------------------------------- test/Project.toml | 5 - test/runtests.jl | 13 +- 7 files changed, 261 insertions(+), 350 deletions(-) delete mode 100644 test/Manifest.toml delete mode 100644 test/Project.toml diff --git a/.gitignore b/.gitignore index 4f4255c..9893a0e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ deps/deps.jl deps/build.log *.cov coverage +.DS_Store +/Manifest.toml diff --git a/Manifest.toml b/Manifest.toml index 01737d8..a06ad3c 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -2,42 +2,58 @@ [[AbstractFFTs]] deps = ["LinearAlgebra"] -git-tree-sha1 = "051c95d6836228d120f5f4b984dd5aba1624f716" +git-tree-sha1 = "485ee0867925449198280d4af84bdb46a2a404d0" uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" -version = "0.5.0" +version = "1.0.1" + +[[Adapt]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "f1b523983a58802c4695851926203b36e28f09db" +uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" +version = "3.3.0" + +[[ArgTools]] +uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" + +[[ArrayInterface]] +deps = ["IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"] +git-tree-sha1 = "b09fe16aa9dc587cccce838e6cb6d6e1f4831d7f" +uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" +version = "3.1.12" + +[[Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" [[Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" -[[BinDeps]] -deps = ["Compat", "Libdl", "SHA", "URIParser"] -git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9" -uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" -version = "0.8.10" - -[[BinaryProvider]] -deps = ["Libdl", "SHA"] -git-tree-sha1 = "5b08ed6036d9d3f0ee6369410b830f8873d4024c" -uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" -version = "0.5.8" +[[ChainRulesCore]] +deps = ["Compat", "LinearAlgebra", "SparseArrays"] +git-tree-sha1 = "e6b23566e025d3b0d9ccc397f5c7a134af552e27" +uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" +version = "0.9.42" [[Compat]] -deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] -git-tree-sha1 = "ed2c4abadf84c53d9e58510b5fc48912c2336fbb" +deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] +git-tree-sha1 = "0a817fbe51c976de090aa8c997b7b719b786118d" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "2.2.0" +version = "3.28.0" -[[Conda]] -deps = ["JSON", "VersionParsing"] -git-tree-sha1 = "9a11d428dcdc425072af4aea19ab1e8c3e01c032" -uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" -version = "1.3.0" +[[CompilerSupportLibraries_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" + +[[ConstructionBase]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "1dc43957fb9a1574fa1b7a449e101bd1fd3a9fb7" +uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9" +version = "1.2.1" [[DSP]] -deps = ["FFTW", "LinearAlgebra", "Polynomials", "Random", "Reexport", "SpecialFunctions", "Statistics"] -git-tree-sha1 = "1a9cef3ad5f5d101c62bc114ad77c261964885c5" +deps = ["FFTW", "IterTools", "LinearAlgebra", "Polynomials", "Random", "Reexport", "SpecialFunctions", "Statistics"] +git-tree-sha1 = "2a63cb5fc0e8c1f0f139475ef94228c7441dc7d0" uuid = "717857b8-e6f2-59f4-9121-6e50c889abd2" -version = "0.6.1" +version = "0.6.10" [[Dates]] deps = ["Printf"] @@ -51,51 +67,124 @@ uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" deps = ["Random", "Serialization", "Sockets"] uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" +[[Downloads]] +deps = ["ArgTools", "LibCURL", "NetworkOptions"] +uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" + +[[EllipsisNotation]] +deps = ["ArrayInterface"] +git-tree-sha1 = "8041575f021cba5a099a456b4163c9a08b566a02" +uuid = "da5c29d0-fa7d-589e-88eb-ea29b0a81949" +version = "1.1.0" + +[[ExprTools]] +git-tree-sha1 = "10407a39b87f29d47ebaca8edbc75d7c302ff93e" +uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" +version = "0.1.3" + +[[EzXML]] +deps = ["Printf", "XML2_jll"] +git-tree-sha1 = "0fa3b52a04a4e210aeb1626def9c90df3ae65268" +uuid = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615" +version = "1.1.0" + [[FFTW]] -deps = ["AbstractFFTs", "BinaryProvider", "Conda", "Libdl", "LinearAlgebra", "Reexport"] -git-tree-sha1 = "4cfd3d43819228b9e73ab46600d0af0aa5cedceb" +deps = ["AbstractFFTs", "FFTW_jll", "LinearAlgebra", "MKL_jll", "Preferences", "Reexport"] +git-tree-sha1 = "746f68839306977040653ebbd249e39c15420b8a" uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" -version = "1.1.0" +version = "1.4.1" + +[[FFTW_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "5a0d4b6a22a34d17d53543bd124f4b08ed78e8b0" +uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a" +version = "3.3.9+7" [[FLAC_jll]] deps = ["Libdl", "Ogg_jll", "Pkg"] -git-tree-sha1 = "95538e15bb0328d76a1a886bbb5c8479a3d1edca" +git-tree-sha1 = "cd528d5083a589aab69dc6de73a901efa9d69586" uuid = "1d38b3a6-207b-531b-80e8-c83f48dafa73" -version = "1.3.3+0" +version = "1.3.3+2" [[FileIO]] -deps = ["Pkg"] -git-tree-sha1 = "351f001a78aa1b7ad2696e386e110b5abd071c71" +deps = ["Pkg", "Requires", "UUIDs"] +path = "/Users/nantonel/.julia/dev/FileIO" uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -version = "1.0.7" +version = "1.8.2" [[FixedPointNumbers]] -git-tree-sha1 = "d14a6fa5890ea3a7e5dcab6811114f132fec2b4b" +deps = ["Statistics"] +git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc" uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" -version = "0.6.1" +version = "0.8.4" + +[[IfElse]] +git-tree-sha1 = "28e837ff3e7a6c3cdb252ce49fb412c8eb3caeef" +uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173" +version = "0.1.0" + +[[IntelOpenMP_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "d979e54b71da82f3a65b62553da4fc3d18c9004c" +uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0" +version = "2018.0.3+2" [[InteractiveUtils]] deps = ["Markdown"] uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" [[IntervalSets]] -deps = ["Dates", "Statistics"] -git-tree-sha1 = "4214b48a62eb8f2c292b2ee34a508c256c0cdbc9" +deps = ["Dates", "EllipsisNotation", "Statistics"] +git-tree-sha1 = "3cc368af3f110a767ac786560045dceddfc16758" uuid = "8197267c-284f-5f27-9208-e0e47529a953" -version = "0.3.2" +version = "0.5.3" + +[[Intervals]] +deps = ["Dates", "Printf", "RecipesBase", "Serialization", "TimeZones"] +git-tree-sha1 = "323a38ed1952d30586d0fe03412cde9399d3618b" +uuid = "d8418881-c3e1-53bb-8760-2df7ec849ed5" +version = "1.5.0" + +[[IterTools]] +git-tree-sha1 = "05110a2ab1fc5f932622ffea2a003221f4782c18" +uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e" +version = "1.3.0" + +[[JLLWrappers]] +deps = ["Preferences"] +git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e" +uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" +version = "1.3.0" + +[[LazyArtifacts]] +deps = ["Artifacts", "Pkg"] +uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" + +[[LibCURL]] +deps = ["LibCURL_jll", "MozillaCACerts_jll"] +uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -[[JSON]] -deps = ["Dates", "Mmap", "Parsers", "Unicode"] -git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e" -uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -version = "0.21.0" +[[LibCURL_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] +uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" [[LibGit2]] +deps = ["Base64", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +[[LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "MbedTLS_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" + [[Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +[[Libiconv_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "8e924324b2e9275a51407a4e06deb3455b1e359f" +uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" +version = "1.16.0+7" + [[LinearAlgebra]] deps = ["Libdl"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -103,41 +192,75 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [[Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" +[[MKL_jll]] +deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg"] +git-tree-sha1 = "c253236b0ed414624b083e6b72bfe891fbd2c7af" +uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7" +version = "2021.1.1+1" + [[Markdown]] deps = ["Base64"] uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +[[MbedTLS_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" + [[Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" +[[Mocking]] +deps = ["ExprTools"] +git-tree-sha1 = "916b850daad0d46b8c71f65f719c49957e9513ed" +uuid = "78c3b35d-d492-501b-9361-3d52fe80e533" +version = "0.7.1" + +[[MozillaCACerts_jll]] +uuid = "14a3606d-f60d-562e-9121-12d972cd8159" + +[[NetworkOptions]] +uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" + +[[OffsetArrays]] +deps = ["Adapt"] +git-tree-sha1 = "47b443d2ccc8297a4c538f55f8fd828ad58599ab" +uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" +version = "1.8.0" + [[Ogg_jll]] -deps = ["Libdl", "Pkg"] -git-tree-sha1 = "f4d4d03c562f40652c0baabd3e4cb2e756e157b7" +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "a42c0f138b9ebe8b58eba2271c5053773bde52d0" uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051" -version = "1.3.3+0" +version = "1.3.4+2" -[[Parsers]] -deps = ["Dates", "Test"] -git-tree-sha1 = "a23968e107c0544aca91bfab6f7dd34de1206a54" -uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "0.3.9" +[[OpenSpecFun_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "b9b8b8ed236998f91143938a760c2112dceeb2b4" +uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" +version = "0.5.4+0" [[Pkg]] -deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] +deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" [[Polynomials]] -deps = ["LinearAlgebra", "RecipesBase"] -git-tree-sha1 = "ae71c2329790af97b7682b11241b3609e4d48626" +deps = ["Intervals", "LinearAlgebra", "OffsetArrays", "RecipesBase"] +git-tree-sha1 = "0b15f3597b01eb76764dd03c3c23d6679a3c32c8" uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" -version = "0.6.0" +version = "1.2.1" + +[[Preferences]] +deps = ["TOML"] +git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a" +uuid = "21216c6a-2e73-6563-6e65-726566657250" +version = "1.2.2" [[Printf]] deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" [[REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets"] +deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" [[Random]] @@ -145,24 +268,29 @@ deps = ["Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[RecipesBase]] -git-tree-sha1 = "7bdce29bc9b2f5660a6e5e64d64d91ec941f6aa2" +git-tree-sha1 = "b3fb709f3c97bfc6e948be68beeecb55a0b340ae" uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -version = "0.7.0" +version = "1.1.1" [[Reexport]] -deps = ["Pkg"] -git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0" +git-tree-sha1 = "57d8440b0c7d98fc4f889e478e80f268d534c9d5" uuid = "189a3867-3050-52da-a836-e630ba90ab69" -version = "0.2.0" +version = "1.0.0" + +[[Requires]] +deps = ["UUIDs"] +git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621" +uuid = "ae029012-a4dd-5104-9daa-d747884805df" +version = "1.1.3" [[SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" [[SampledSignals]] -deps = ["Compat", "DSP", "FFTW", "FixedPointNumbers", "IntervalSets", "LinearAlgebra", "TreeViews", "Unitful"] -git-tree-sha1 = "ce5705b342baa4a995ba6fa7ca9aa96e6647ac91" +deps = ["Base64", "Compat", "DSP", "FFTW", "FixedPointNumbers", "IntervalSets", "LinearAlgebra", "Random", "TreeViews", "Unitful"] +git-tree-sha1 = "4b7e413f20fa56fa47b8433c96f96a1acfe372a6" uuid = "bd7594eb-a658-542f-9e75-4c4d8908c167" -version = "2.1.0" +version = "2.1.2" [[Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" @@ -179,31 +307,45 @@ deps = ["LinearAlgebra", "Random"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[SpecialFunctions]] -deps = ["BinDeps", "BinaryProvider", "Libdl"] -git-tree-sha1 = "3bdd374b6fd78faf0119b8c5d538788dbf910c6e" +deps = ["ChainRulesCore", "OpenSpecFun_jll"] +git-tree-sha1 = "5919936c0e92cff40e57d0ddf0ceb667d42e5902" uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "0.8.0" +version = "1.3.0" + +[[Static]] +deps = ["IfElse"] +git-tree-sha1 = "ddec5466a1d2d7e58adf9a427ba69763661aacf6" +uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" +version = "0.2.4" [[Statistics]] deps = ["LinearAlgebra", "SparseArrays"] uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +[[TOML]] +deps = ["Dates"] +uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" + +[[Tar]] +deps = ["ArgTools", "SHA"] +uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" + [[Test]] -deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] +deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +[[TimeZones]] +deps = ["Dates", "EzXML", "LazyArtifacts", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"] +git-tree-sha1 = "960099aed321e05ac649c90d583d59c9309faee1" +uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53" +version = "1.5.5" + [[TreeViews]] deps = ["Test"] git-tree-sha1 = "8d0d7a3fe2f30d6a7f833a5f19f7c7a5b396eae6" uuid = "a2a6695c-b41b-5b7d-aed9-dbfdeacea5d7" version = "0.3.0" -[[URIParser]] -deps = ["Test", "Unicode"] -git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" -uuid = "30578b45-9adc-5946-b283-645ec420af67" -version = "0.4.0" - [[UUIDs]] deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" @@ -212,25 +354,43 @@ uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [[Unitful]] -deps = ["LinearAlgebra", "Random"] -git-tree-sha1 = "92bdf0ccfa9612b167d0adaadef832a09971ceb0" +deps = ["ConstructionBase", "Dates", "LinearAlgebra", "Random"] +git-tree-sha1 = "c6bbc170505c5ea36593a0072b61d3be8bf868ae" uuid = "1986cc42-f94f-5a68-af5c-568840ba703d" -version = "0.17.0" +version = "1.7.0" -[[VersionParsing]] -deps = ["Compat"] -git-tree-sha1 = "c9d5aa108588b978bd859554660c8a5c4f2f7669" -uuid = "81def892-9a0e-5fdd-b105-ffc91e053289" -version = "1.1.3" +[[XML2_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "Zlib_jll"] +git-tree-sha1 = "afd2b541e8fd425cd3b7aa55932a257035ab4a70" +uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a" +version = "2.9.11+0" + +[[Zlib_jll]] +deps = ["Libdl"] +uuid = "83775a58-1f1d-513f-b197-d71354ab007a" + +[[alsa_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "4694a774a3bc66b7c2efd32a2b3e3a128b3f7bc2" +uuid = "45378030-f8ea-5b20-a7c7-1a9d95efb90e" +version = "1.2.4+0" [[libsndfile_jll]] -deps = ["FLAC_jll", "Libdl", "Ogg_jll", "Pkg", "libvorbis_jll"] -git-tree-sha1 = "49d5e44ad9ae11866f456779eeea6d319eb77000" +deps = ["Artifacts", "FLAC_jll", "JLLWrappers", "Libdl", "Ogg_jll", "Pkg", "alsa_jll", "libvorbis_jll"] +git-tree-sha1 = "fc7a0233235d1c4da6dfdf73f480c2619e9ea66d" uuid = "5bf562c0-5a39-5b4f-b979-f64ac885830c" -version = "1.0.28+0" +version = "1.0.28+2" [[libvorbis_jll]] -deps = ["Libdl", "Ogg_jll", "Pkg"] -git-tree-sha1 = "71e54fb89ac3e0344c7185d1876fd96b0f246952" +deps = ["Artifacts", "JLLWrappers", "Libdl", "Ogg_jll", "Pkg"] +git-tree-sha1 = "fa14ac25af7a4b8a7f61b287a124df7aab601bcd" uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a" -version = "1.3.6+2" +version = "1.3.6+6" + +[[nghttp2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" + +[[p7zip_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" diff --git a/Project.toml b/Project.toml index 4727a06..b3e8ce9 100644 --- a/Project.toml +++ b/Project.toml @@ -15,3 +15,9 @@ FileIO = "1" SampledSignals = "2.1.0" julia = "1.3" libsndfile_jll = "1.0.28" + +[extras] +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Test"] diff --git a/src/LibSndFile.jl b/src/LibSndFile.jl index 99a801a..c5ca292 100644 --- a/src/LibSndFile.jl +++ b/src/LibSndFile.jl @@ -18,13 +18,4 @@ include("sourcesink.jl") include("loadsave.jl") include("readwrite.jl") -function __init__() - # ogg currently not in the registry - add_format(format"OGG", "OggS", [".ogg", ".oga"], [:LibSndFile]) - for fmt in supported_formats - add_loader(fmt, :LibSndFile) - add_saver(fmt, :LibSndFile) - end -end - end # module LibSndFile diff --git a/test/Manifest.toml b/test/Manifest.toml deleted file mode 100644 index 237c117..0000000 --- a/test/Manifest.toml +++ /dev/null @@ -1,242 +0,0 @@ -# This file is machine-generated - editing it directly is not advised - -[[AbstractFFTs]] -deps = ["LinearAlgebra"] -git-tree-sha1 = "051c95d6836228d120f5f4b984dd5aba1624f716" -uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" -version = "0.5.0" - -[[Base64]] -uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" - -[[BinDeps]] -deps = ["Compat", "Libdl", "SHA", "URIParser"] -git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9" -uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" -version = "0.8.10" - -[[BinaryProvider]] -deps = ["Libdl", "SHA"] -git-tree-sha1 = "5b08ed6036d9d3f0ee6369410b830f8873d4024c" -uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" -version = "0.5.8" - -[[Compat]] -deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] -git-tree-sha1 = "ed2c4abadf84c53d9e58510b5fc48912c2336fbb" -uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "2.2.0" - -[[Conda]] -deps = ["JSON", "VersionParsing"] -git-tree-sha1 = "9a11d428dcdc425072af4aea19ab1e8c3e01c032" -uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" -version = "1.3.0" - -[[DSP]] -deps = ["FFTW", "LinearAlgebra", "Polynomials", "Random", "Reexport", "SpecialFunctions", "Statistics"] -git-tree-sha1 = "1a9cef3ad5f5d101c62bc114ad77c261964885c5" -uuid = "717857b8-e6f2-59f4-9121-6e50c889abd2" -version = "0.6.1" - -[[Dates]] -deps = ["Printf"] -uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" - -[[DelimitedFiles]] -deps = ["Mmap"] -uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" - -[[Distributed]] -deps = ["Random", "Serialization", "Sockets"] -uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" - -[[FFTW]] -deps = ["AbstractFFTs", "BinaryProvider", "Conda", "Libdl", "LinearAlgebra", "Reexport"] -git-tree-sha1 = "4cfd3d43819228b9e73ab46600d0af0aa5cedceb" -uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" -version = "1.1.0" - -[[FLAC_jll]] -deps = ["Libdl", "Ogg_jll", "Pkg"] -git-tree-sha1 = "95538e15bb0328d76a1a886bbb5c8479a3d1edca" -uuid = "1d38b3a6-207b-531b-80e8-c83f48dafa73" -version = "1.3.3+0" - -[[FileIO]] -deps = ["Pkg"] -git-tree-sha1 = "351f001a78aa1b7ad2696e386e110b5abd071c71" -uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -version = "1.0.7" - -[[FixedPointNumbers]] -git-tree-sha1 = "d14a6fa5890ea3a7e5dcab6811114f132fec2b4b" -uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" -version = "0.6.1" - -[[InteractiveUtils]] -deps = ["Markdown"] -uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" - -[[IntervalSets]] -deps = ["Dates", "Statistics"] -git-tree-sha1 = "4214b48a62eb8f2c292b2ee34a508c256c0cdbc9" -uuid = "8197267c-284f-5f27-9208-e0e47529a953" -version = "0.3.2" - -[[JSON]] -deps = ["Dates", "Mmap", "Parsers", "Unicode"] -git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e" -uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -version = "0.21.0" - -[[LibGit2]] -uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" - -[[LibSndFile]] -deps = ["FileIO", "Libdl", "LinearAlgebra", "Printf", "SampledSignals", "libsndfile_jll"] -path = "/home/sfr/Dropbox/juliadev/LibSndFile" -uuid = "b13ce0c6-77b0-50c6-a2db-140568b8d1a5" -version = "2.1.0" - -[[Libdl]] -uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" - -[[LinearAlgebra]] -deps = ["Libdl"] -uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" - -[[Logging]] -uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" - -[[Markdown]] -deps = ["Base64"] -uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" - -[[Mmap]] -uuid = "a63ad114-7e13-5084-954f-fe012c677804" - -[[Ogg_jll]] -deps = ["Libdl", "Pkg"] -git-tree-sha1 = "f4d4d03c562f40652c0baabd3e4cb2e756e157b7" -uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051" -version = "1.3.3+0" - -[[Parsers]] -deps = ["Dates", "Test"] -git-tree-sha1 = "a23968e107c0544aca91bfab6f7dd34de1206a54" -uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "0.3.9" - -[[Pkg]] -deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] -uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" - -[[Polynomials]] -deps = ["LinearAlgebra", "RecipesBase"] -git-tree-sha1 = "ae71c2329790af97b7682b11241b3609e4d48626" -uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" -version = "0.6.0" - -[[Printf]] -deps = ["Unicode"] -uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" - -[[REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets"] -uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" - -[[Random]] -deps = ["Serialization"] -uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" - -[[RecipesBase]] -git-tree-sha1 = "7bdce29bc9b2f5660a6e5e64d64d91ec941f6aa2" -uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -version = "0.7.0" - -[[Reexport]] -deps = ["Pkg"] -git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0" -uuid = "189a3867-3050-52da-a836-e630ba90ab69" -version = "0.2.0" - -[[SHA]] -uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" - -[[SampledSignals]] -deps = ["Compat", "DSP", "FFTW", "FixedPointNumbers", "IntervalSets", "LinearAlgebra", "TreeViews", "Unitful"] -git-tree-sha1 = "ce5705b342baa4a995ba6fa7ca9aa96e6647ac91" -uuid = "bd7594eb-a658-542f-9e75-4c4d8908c167" -version = "2.1.0" - -[[Serialization]] -uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" - -[[SharedArrays]] -deps = ["Distributed", "Mmap", "Random", "Serialization"] -uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" - -[[Sockets]] -uuid = "6462fe0b-24de-5631-8697-dd941f90decc" - -[[SparseArrays]] -deps = ["LinearAlgebra", "Random"] -uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" - -[[SpecialFunctions]] -deps = ["BinDeps", "BinaryProvider", "Libdl"] -git-tree-sha1 = "3bdd374b6fd78faf0119b8c5d538788dbf910c6e" -uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "0.8.0" - -[[Statistics]] -deps = ["LinearAlgebra", "SparseArrays"] -uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" - -[[Test]] -deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] -uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[[TreeViews]] -deps = ["Test"] -git-tree-sha1 = "8d0d7a3fe2f30d6a7f833a5f19f7c7a5b396eae6" -uuid = "a2a6695c-b41b-5b7d-aed9-dbfdeacea5d7" -version = "0.3.0" - -[[URIParser]] -deps = ["Test", "Unicode"] -git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" -uuid = "30578b45-9adc-5946-b283-645ec420af67" -version = "0.4.0" - -[[UUIDs]] -deps = ["Random", "SHA"] -uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" - -[[Unicode]] -uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" - -[[Unitful]] -deps = ["LinearAlgebra", "Random"] -git-tree-sha1 = "92bdf0ccfa9612b167d0adaadef832a09971ceb0" -uuid = "1986cc42-f94f-5a68-af5c-568840ba703d" -version = "0.17.0" - -[[VersionParsing]] -deps = ["Compat"] -git-tree-sha1 = "c9d5aa108588b978bd859554660c8a5c4f2f7669" -uuid = "81def892-9a0e-5fdd-b105-ffc91e053289" -version = "1.1.3" - -[[libsndfile_jll]] -deps = ["FLAC_jll", "Libdl", "Ogg_jll", "Pkg", "libvorbis_jll"] -git-tree-sha1 = "49d5e44ad9ae11866f456779eeea6d319eb77000" -uuid = "5bf562c0-5a39-5b4f-b979-f64ac885830c" -version = "1.0.28+0" - -[[libvorbis_jll]] -deps = ["Libdl", "Ogg_jll", "Pkg"] -git-tree-sha1 = "71e54fb89ac3e0344c7185d1876fd96b0f246952" -uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a" -version = "1.3.6+2" diff --git a/test/Project.toml b/test/Project.toml deleted file mode 100644 index 9689ba7..0000000 --- a/test/Project.toml +++ /dev/null @@ -1,5 +0,0 @@ -[deps] -FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -LibSndFile = "b13ce0c6-77b0-50c6-a2db-140568b8d1a5" -SampledSignals = "bd7594eb-a658-542f-9e75-4c4d8908c167" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/runtests.jl b/test/runtests.jl index 8a8abed..dd0c93f 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -26,10 +26,10 @@ for f in (:load, :save, :loadstreaming, :savestreaming) for io in ((String, File), (IO, Stream)) for fmt in (("_wav", format"WAV"), ("_ogg", format"OGG"), ("_flac", format"FLAC")) @eval $(Symbol(f, fmt[1]))(io::$(io[1]), args...) = - LibSndFile.$f($(io[2])($(fmt[2]), io), args...) + LibSndFile.$f($(io[2]){$(fmt[2])}( io), args...) if f in (:loadstreaming, :savestreaming) @eval function $(Symbol(f, fmt[1]))(dofunc::Function, io::$(io[1]), args...) - str = LibSndFile.$f($(io[2])($(fmt[2]), io), args...) + str = LibSndFile.$f($(io[2]){$(fmt[2])}( io), args...) try dofunc(str) finally @@ -299,7 +299,7 @@ end io = IOBuffer() show(io, stream) @test String(take!(io)) == """ - LibSndFile.SndFileSink{Float32,String} + LibSndFile.SndFileSink{Float32, String} path: "$fname" channels: 2 samplerate: 44100Hz @@ -308,7 +308,7 @@ end write(stream, testbuf) show(io, stream) @test String(take!(io)) == """ - LibSndFile.SndFileSink{Float32,String} + LibSndFile.SndFileSink{Float32, String} path: "$fname" channels: 2 samplerate: 44100Hz @@ -325,7 +325,7 @@ end io = IOBuffer() show(io, stream) @test String(take!(io)) == """ - LibSndFile.SndFileSource{Float32,String} + LibSndFile.SndFileSource{Float32, String} path: "$fname" channels: 2 samplerate: 44100Hz @@ -334,7 +334,7 @@ end read(stream, 5000) show(io, stream) @test String(take!(io)) == """ - LibSndFile.SndFileSource{Float32,String} + LibSndFile.SndFileSource{Float32, String} path: "$fname" channels: 2 samplerate: 44100Hz @@ -342,7 +342,6 @@ end 0.11 of 0.23 seconds""" end - # TODO: check out what happens when samplerate, channels, etc. are wrong # when reading/writing From 4b73245919f9f3b1f80d2ee22c209768eecc9dc3 Mon Sep 17 00:00:00 2001 From: nantonel Date: Mon, 31 May 2021 10:12:03 +0200 Subject: [PATCH 02/22] rm Manifest, update Project --- .gitignore | 3 ++- Manifest.toml | 52 +++++++++++++++++++++++++++++++-------------------- Project.toml | 2 +- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 9893a0e..874dd76 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ deps/build.log *.cov coverage .DS_Store -/Manifest.toml +Manifest.toml +test/Manifest.toml diff --git a/Manifest.toml b/Manifest.toml index a06ad3c..b4616a5 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -17,9 +17,9 @@ uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" [[ArrayInterface]] deps = ["IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"] -git-tree-sha1 = "b09fe16aa9dc587cccce838e6cb6d6e1f4831d7f" +git-tree-sha1 = "4e988d6883cf3935e267f93f53cfc34792e0700f" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "3.1.12" +version = "3.1.15" [[Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" @@ -29,15 +29,15 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" [[ChainRulesCore]] deps = ["Compat", "LinearAlgebra", "SparseArrays"] -git-tree-sha1 = "e6b23566e025d3b0d9ccc397f5c7a134af552e27" +git-tree-sha1 = "4b28f88cecf5d9a07c85b9ce5209a361ecaff34a" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "0.9.42" +version = "0.9.45" [[Compat]] deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] -git-tree-sha1 = "0a817fbe51c976de090aa8c997b7b719b786118d" +git-tree-sha1 = "e4e2b39db08f967cc1360951f01e8a75ec441cab" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "3.28.0" +version = "3.30.0" [[CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] @@ -67,6 +67,12 @@ uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" deps = ["Random", "Serialization", "Sockets"] uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" +[[DocStringExtensions]] +deps = ["LibGit2", "Markdown", "Pkg", "Test"] +git-tree-sha1 = "9d4f64f79012636741cf01133158a54b24924c32" +uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" +version = "0.8.4" + [[Downloads]] deps = ["ArgTools", "LibCURL", "NetworkOptions"] uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" @@ -110,7 +116,7 @@ version = "1.3.3+2" deps = ["Pkg", "Requires", "UUIDs"] path = "/Users/nantonel/.julia/dev/FileIO" uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -version = "1.8.2" +version = "1.9.0" [[FixedPointNumbers]] deps = ["Statistics"] @@ -181,14 +187,20 @@ uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" [[Libiconv_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "8e924324b2e9275a51407a4e06deb3455b1e359f" +git-tree-sha1 = "8d22e127ea9a0917bc98ebd3755c8bd31989381e" uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" -version = "1.16.0+7" +version = "1.16.1+0" [[LinearAlgebra]] deps = ["Libdl"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +[[LogExpFunctions]] +deps = ["DocStringExtensions", "LinearAlgebra"] +git-tree-sha1 = "1ba664552f1ef15325e68dc4c05c3ef8c2d5d885" +uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" +version = "0.2.4" + [[Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" @@ -223,15 +235,15 @@ uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" [[OffsetArrays]] deps = ["Adapt"] -git-tree-sha1 = "47b443d2ccc8297a4c538f55f8fd828ad58599ab" +git-tree-sha1 = "1381a7142eefd4cd12f052a4d2d790fe21bd1d55" uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -version = "1.8.0" +version = "1.9.2" [[Ogg_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "a42c0f138b9ebe8b58eba2271c5053773bde52d0" +git-tree-sha1 = "7937eda4681660b4d6aeeecc2f7e1c81c8ee4e2f" uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051" -version = "1.3.4+2" +version = "1.3.5+0" [[OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] @@ -307,10 +319,10 @@ deps = ["LinearAlgebra", "Random"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[SpecialFunctions]] -deps = ["ChainRulesCore", "OpenSpecFun_jll"] -git-tree-sha1 = "5919936c0e92cff40e57d0ddf0ceb667d42e5902" +deps = ["ChainRulesCore", "LogExpFunctions", "OpenSpecFun_jll"] +git-tree-sha1 = "371204984184315ed7228bcc604d08e1bbc18f31" uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "1.3.0" +version = "1.4.2" [[Static]] deps = ["IfElse"] @@ -361,9 +373,9 @@ version = "1.7.0" [[XML2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "Zlib_jll"] -git-tree-sha1 = "afd2b541e8fd425cd3b7aa55932a257035ab4a70" +git-tree-sha1 = "1acf5bdf07aa0907e0a37d3718bb88d4b687b74a" uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a" -version = "2.9.11+0" +version = "2.9.12+0" [[Zlib_jll]] deps = ["Libdl"] @@ -383,9 +395,9 @@ version = "1.0.28+2" [[libvorbis_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Ogg_jll", "Pkg"] -git-tree-sha1 = "fa14ac25af7a4b8a7f61b287a124df7aab601bcd" +git-tree-sha1 = "c45f4e40e7aafe9d086379e5578947ec8b95a8fb" uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a" -version = "1.3.6+6" +version = "1.3.7+0" [[nghttp2_jll]] deps = ["Artifacts", "Libdl"] diff --git a/Project.toml b/Project.toml index b3e8ce9..9f25865 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,7 @@ SampledSignals = "bd7594eb-a658-542f-9e75-4c4d8908c167" libsndfile_jll = "5bf562c0-5a39-5b4f-b979-f64ac885830c" [compat] -FileIO = "1" +FileIO = "1.9" SampledSignals = "2.1.0" julia = "1.3" libsndfile_jll = "1.0.28" From f51da4db51c7d14aeb96fbe4fa04fd3f345fa467 Mon Sep 17 00:00:00 2001 From: nantonel Date: Mon, 21 Jun 2021 11:36:42 +0200 Subject: [PATCH 03/22] updated project --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 9f25865..f777690 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,7 @@ SampledSignals = "bd7594eb-a658-542f-9e75-4c4d8908c167" libsndfile_jll = "5bf562c0-5a39-5b4f-b979-f64ac885830c" [compat] -FileIO = "1.9" +FileIO = "1.10" SampledSignals = "2.1.0" julia = "1.3" libsndfile_jll = "1.0.28" From 87f0410d60a199f85b69a6d963c40ec7e5f343c9 Mon Sep 17 00:00:00 2001 From: Robert Luke <748691+rob-luke@users.noreply.github.com> Date: Sun, 27 Jun 2021 23:19:44 +1000 Subject: [PATCH 04/22] Create Tests.yml --- .github/workflows/Tests.yml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/Tests.yml diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml new file mode 100644 index 0000000..594900c --- /dev/null +++ b/.github/workflows/Tests.yml @@ -0,0 +1,43 @@ +name: Tests + +on: + pull_request: + push: + branches: + - master + tags: '*' + + +jobs: + test: + timeout-minutes: 30 + name: ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + version: + - '1.3' + - '1.4' + - '1.5' + - '1' + - 'nightly' + os: + - ubuntu-latest + - macOS-latest + - windows-latest + arch: + - x64 + - x86 + + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + - uses: julia-actions/julia-buildpkg@v1 + - uses: julia-actions/julia-runtest@v1 + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v1 + with: + file: lcov.info From 053ddf7ca849fb70ed773ae08aadef7a3604fd70 Mon Sep 17 00:00:00 2001 From: nantonel Date: Sun, 27 Jun 2021 17:35:49 +0200 Subject: [PATCH 05/22] rm Manifest --- Manifest.toml | 408 -------------------------------------------------- 1 file changed, 408 deletions(-) delete mode 100644 Manifest.toml diff --git a/Manifest.toml b/Manifest.toml deleted file mode 100644 index b4616a5..0000000 --- a/Manifest.toml +++ /dev/null @@ -1,408 +0,0 @@ -# This file is machine-generated - editing it directly is not advised - -[[AbstractFFTs]] -deps = ["LinearAlgebra"] -git-tree-sha1 = "485ee0867925449198280d4af84bdb46a2a404d0" -uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" -version = "1.0.1" - -[[Adapt]] -deps = ["LinearAlgebra"] -git-tree-sha1 = "f1b523983a58802c4695851926203b36e28f09db" -uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" -version = "3.3.0" - -[[ArgTools]] -uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" - -[[ArrayInterface]] -deps = ["IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"] -git-tree-sha1 = "4e988d6883cf3935e267f93f53cfc34792e0700f" -uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "3.1.15" - -[[Artifacts]] -uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" - -[[Base64]] -uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" - -[[ChainRulesCore]] -deps = ["Compat", "LinearAlgebra", "SparseArrays"] -git-tree-sha1 = "4b28f88cecf5d9a07c85b9ce5209a361ecaff34a" -uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "0.9.45" - -[[Compat]] -deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] -git-tree-sha1 = "e4e2b39db08f967cc1360951f01e8a75ec441cab" -uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "3.30.0" - -[[CompilerSupportLibraries_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" - -[[ConstructionBase]] -deps = ["LinearAlgebra"] -git-tree-sha1 = "1dc43957fb9a1574fa1b7a449e101bd1fd3a9fb7" -uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9" -version = "1.2.1" - -[[DSP]] -deps = ["FFTW", "IterTools", "LinearAlgebra", "Polynomials", "Random", "Reexport", "SpecialFunctions", "Statistics"] -git-tree-sha1 = "2a63cb5fc0e8c1f0f139475ef94228c7441dc7d0" -uuid = "717857b8-e6f2-59f4-9121-6e50c889abd2" -version = "0.6.10" - -[[Dates]] -deps = ["Printf"] -uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" - -[[DelimitedFiles]] -deps = ["Mmap"] -uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" - -[[Distributed]] -deps = ["Random", "Serialization", "Sockets"] -uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" - -[[DocStringExtensions]] -deps = ["LibGit2", "Markdown", "Pkg", "Test"] -git-tree-sha1 = "9d4f64f79012636741cf01133158a54b24924c32" -uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" -version = "0.8.4" - -[[Downloads]] -deps = ["ArgTools", "LibCURL", "NetworkOptions"] -uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" - -[[EllipsisNotation]] -deps = ["ArrayInterface"] -git-tree-sha1 = "8041575f021cba5a099a456b4163c9a08b566a02" -uuid = "da5c29d0-fa7d-589e-88eb-ea29b0a81949" -version = "1.1.0" - -[[ExprTools]] -git-tree-sha1 = "10407a39b87f29d47ebaca8edbc75d7c302ff93e" -uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" -version = "0.1.3" - -[[EzXML]] -deps = ["Printf", "XML2_jll"] -git-tree-sha1 = "0fa3b52a04a4e210aeb1626def9c90df3ae65268" -uuid = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615" -version = "1.1.0" - -[[FFTW]] -deps = ["AbstractFFTs", "FFTW_jll", "LinearAlgebra", "MKL_jll", "Preferences", "Reexport"] -git-tree-sha1 = "746f68839306977040653ebbd249e39c15420b8a" -uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" -version = "1.4.1" - -[[FFTW_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "5a0d4b6a22a34d17d53543bd124f4b08ed78e8b0" -uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a" -version = "3.3.9+7" - -[[FLAC_jll]] -deps = ["Libdl", "Ogg_jll", "Pkg"] -git-tree-sha1 = "cd528d5083a589aab69dc6de73a901efa9d69586" -uuid = "1d38b3a6-207b-531b-80e8-c83f48dafa73" -version = "1.3.3+2" - -[[FileIO]] -deps = ["Pkg", "Requires", "UUIDs"] -path = "/Users/nantonel/.julia/dev/FileIO" -uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -version = "1.9.0" - -[[FixedPointNumbers]] -deps = ["Statistics"] -git-tree-sha1 = "335bfdceacc84c5cdf16aadc768aa5ddfc5383cc" -uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" -version = "0.8.4" - -[[IfElse]] -git-tree-sha1 = "28e837ff3e7a6c3cdb252ce49fb412c8eb3caeef" -uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173" -version = "0.1.0" - -[[IntelOpenMP_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "d979e54b71da82f3a65b62553da4fc3d18c9004c" -uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0" -version = "2018.0.3+2" - -[[InteractiveUtils]] -deps = ["Markdown"] -uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" - -[[IntervalSets]] -deps = ["Dates", "EllipsisNotation", "Statistics"] -git-tree-sha1 = "3cc368af3f110a767ac786560045dceddfc16758" -uuid = "8197267c-284f-5f27-9208-e0e47529a953" -version = "0.5.3" - -[[Intervals]] -deps = ["Dates", "Printf", "RecipesBase", "Serialization", "TimeZones"] -git-tree-sha1 = "323a38ed1952d30586d0fe03412cde9399d3618b" -uuid = "d8418881-c3e1-53bb-8760-2df7ec849ed5" -version = "1.5.0" - -[[IterTools]] -git-tree-sha1 = "05110a2ab1fc5f932622ffea2a003221f4782c18" -uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e" -version = "1.3.0" - -[[JLLWrappers]] -deps = ["Preferences"] -git-tree-sha1 = "642a199af8b68253517b80bd3bfd17eb4e84df6e" -uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.3.0" - -[[LazyArtifacts]] -deps = ["Artifacts", "Pkg"] -uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" - -[[LibCURL]] -deps = ["LibCURL_jll", "MozillaCACerts_jll"] -uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" - -[[LibCURL_jll]] -deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] -uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" - -[[LibGit2]] -deps = ["Base64", "NetworkOptions", "Printf", "SHA"] -uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" - -[[LibSSH2_jll]] -deps = ["Artifacts", "Libdl", "MbedTLS_jll"] -uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" - -[[Libdl]] -uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" - -[[Libiconv_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "8d22e127ea9a0917bc98ebd3755c8bd31989381e" -uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" -version = "1.16.1+0" - -[[LinearAlgebra]] -deps = ["Libdl"] -uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" - -[[LogExpFunctions]] -deps = ["DocStringExtensions", "LinearAlgebra"] -git-tree-sha1 = "1ba664552f1ef15325e68dc4c05c3ef8c2d5d885" -uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" -version = "0.2.4" - -[[Logging]] -uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" - -[[MKL_jll]] -deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "Pkg"] -git-tree-sha1 = "c253236b0ed414624b083e6b72bfe891fbd2c7af" -uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7" -version = "2021.1.1+1" - -[[Markdown]] -deps = ["Base64"] -uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" - -[[MbedTLS_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" - -[[Mmap]] -uuid = "a63ad114-7e13-5084-954f-fe012c677804" - -[[Mocking]] -deps = ["ExprTools"] -git-tree-sha1 = "916b850daad0d46b8c71f65f719c49957e9513ed" -uuid = "78c3b35d-d492-501b-9361-3d52fe80e533" -version = "0.7.1" - -[[MozillaCACerts_jll]] -uuid = "14a3606d-f60d-562e-9121-12d972cd8159" - -[[NetworkOptions]] -uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" - -[[OffsetArrays]] -deps = ["Adapt"] -git-tree-sha1 = "1381a7142eefd4cd12f052a4d2d790fe21bd1d55" -uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -version = "1.9.2" - -[[Ogg_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "7937eda4681660b4d6aeeecc2f7e1c81c8ee4e2f" -uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051" -version = "1.3.5+0" - -[[OpenSpecFun_jll]] -deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "b9b8b8ed236998f91143938a760c2112dceeb2b4" -uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" -version = "0.5.4+0" - -[[Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] -uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" - -[[Polynomials]] -deps = ["Intervals", "LinearAlgebra", "OffsetArrays", "RecipesBase"] -git-tree-sha1 = "0b15f3597b01eb76764dd03c3c23d6679a3c32c8" -uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" -version = "1.2.1" - -[[Preferences]] -deps = ["TOML"] -git-tree-sha1 = "00cfd92944ca9c760982747e9a1d0d5d86ab1e5a" -uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.2.2" - -[[Printf]] -deps = ["Unicode"] -uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" - -[[REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] -uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" - -[[Random]] -deps = ["Serialization"] -uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" - -[[RecipesBase]] -git-tree-sha1 = "b3fb709f3c97bfc6e948be68beeecb55a0b340ae" -uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -version = "1.1.1" - -[[Reexport]] -git-tree-sha1 = "57d8440b0c7d98fc4f889e478e80f268d534c9d5" -uuid = "189a3867-3050-52da-a836-e630ba90ab69" -version = "1.0.0" - -[[Requires]] -deps = ["UUIDs"] -git-tree-sha1 = "4036a3bd08ac7e968e27c203d45f5fff15020621" -uuid = "ae029012-a4dd-5104-9daa-d747884805df" -version = "1.1.3" - -[[SHA]] -uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" - -[[SampledSignals]] -deps = ["Base64", "Compat", "DSP", "FFTW", "FixedPointNumbers", "IntervalSets", "LinearAlgebra", "Random", "TreeViews", "Unitful"] -git-tree-sha1 = "4b7e413f20fa56fa47b8433c96f96a1acfe372a6" -uuid = "bd7594eb-a658-542f-9e75-4c4d8908c167" -version = "2.1.2" - -[[Serialization]] -uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" - -[[SharedArrays]] -deps = ["Distributed", "Mmap", "Random", "Serialization"] -uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" - -[[Sockets]] -uuid = "6462fe0b-24de-5631-8697-dd941f90decc" - -[[SparseArrays]] -deps = ["LinearAlgebra", "Random"] -uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" - -[[SpecialFunctions]] -deps = ["ChainRulesCore", "LogExpFunctions", "OpenSpecFun_jll"] -git-tree-sha1 = "371204984184315ed7228bcc604d08e1bbc18f31" -uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "1.4.2" - -[[Static]] -deps = ["IfElse"] -git-tree-sha1 = "ddec5466a1d2d7e58adf9a427ba69763661aacf6" -uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" -version = "0.2.4" - -[[Statistics]] -deps = ["LinearAlgebra", "SparseArrays"] -uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" - -[[TOML]] -deps = ["Dates"] -uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" - -[[Tar]] -deps = ["ArgTools", "SHA"] -uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" - -[[Test]] -deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] -uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[[TimeZones]] -deps = ["Dates", "EzXML", "LazyArtifacts", "Mocking", "Pkg", "Printf", "RecipesBase", "Serialization", "Unicode"] -git-tree-sha1 = "960099aed321e05ac649c90d583d59c9309faee1" -uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53" -version = "1.5.5" - -[[TreeViews]] -deps = ["Test"] -git-tree-sha1 = "8d0d7a3fe2f30d6a7f833a5f19f7c7a5b396eae6" -uuid = "a2a6695c-b41b-5b7d-aed9-dbfdeacea5d7" -version = "0.3.0" - -[[UUIDs]] -deps = ["Random", "SHA"] -uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" - -[[Unicode]] -uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" - -[[Unitful]] -deps = ["ConstructionBase", "Dates", "LinearAlgebra", "Random"] -git-tree-sha1 = "c6bbc170505c5ea36593a0072b61d3be8bf868ae" -uuid = "1986cc42-f94f-5a68-af5c-568840ba703d" -version = "1.7.0" - -[[XML2_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Pkg", "Zlib_jll"] -git-tree-sha1 = "1acf5bdf07aa0907e0a37d3718bb88d4b687b74a" -uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a" -version = "2.9.12+0" - -[[Zlib_jll]] -deps = ["Libdl"] -uuid = "83775a58-1f1d-513f-b197-d71354ab007a" - -[[alsa_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "4694a774a3bc66b7c2efd32a2b3e3a128b3f7bc2" -uuid = "45378030-f8ea-5b20-a7c7-1a9d95efb90e" -version = "1.2.4+0" - -[[libsndfile_jll]] -deps = ["Artifacts", "FLAC_jll", "JLLWrappers", "Libdl", "Ogg_jll", "Pkg", "alsa_jll", "libvorbis_jll"] -git-tree-sha1 = "fc7a0233235d1c4da6dfdf73f480c2619e9ea66d" -uuid = "5bf562c0-5a39-5b4f-b979-f64ac885830c" -version = "1.0.28+2" - -[[libvorbis_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Ogg_jll", "Pkg"] -git-tree-sha1 = "c45f4e40e7aafe9d086379e5578947ec8b95a8fb" -uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a" -version = "1.3.7+0" - -[[nghttp2_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" - -[[p7zip_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" From dedfe528cc3467bf6f1dcae237458caeab96da8f Mon Sep 17 00:00:00 2001 From: nantonel Date: Sun, 27 Jun 2021 18:05:06 +0200 Subject: [PATCH 06/22] sink source display tests not space sensitive --- test/runtests.jl | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index dd0c93f..23fd724 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -298,22 +298,28 @@ end stream = savestreaming_wav(fname, 2, srate, Float32) io = IOBuffer() show(io, stream) - @test String(take!(io)) == """ + @test replace(String(take!(io)), " " => "") == + replace( + """ LibSndFile.SndFileSink{Float32, String} path: "$fname" channels: 2 samplerate: 44100Hz position: 0 of 0 frames 0.00 of 0.00 seconds""" + , " " => "") write(stream, testbuf) show(io, stream) - @test String(take!(io)) == """ + @test replace(String(take!(io)), " " => "") == + replace( + """ LibSndFile.SndFileSink{Float32, String} path: "$fname" channels: 2 samplerate: 44100Hz position: 10000 of 10000 frames 0.23 of 0.23 seconds""" + , " " => "") end @testset "Source Display" begin @@ -324,22 +330,28 @@ end stream = loadstreaming_wav(fname) io = IOBuffer() show(io, stream) - @test String(take!(io)) == """ + @test replace(String(take!(io)), " " => "") == + replace( + """ LibSndFile.SndFileSource{Float32, String} path: "$fname" channels: 2 samplerate: 44100Hz position: 0 of 10000 frames 0.00 of 0.23 seconds""" + , " " => "") read(stream, 5000) show(io, stream) - @test String(take!(io)) == """ + @test replace(String(take!(io)), " " => "") == + replace( + """ LibSndFile.SndFileSource{Float32, String} path: "$fname" channels: 2 samplerate: 44100Hz position: 5000 of 10000 frames 0.11 of 0.23 seconds""" + , " " => "") end # TODO: check out what happens when samplerate, channels, etc. are wrong From 112adf9834b6258669a7fd42342fb9432109ec44 Mon Sep 17 00:00:00 2001 From: nantonel Date: Sun, 27 Jun 2021 18:16:55 +0200 Subject: [PATCH 07/22] rm old yml files and updated badge readme --- .appveyor.yml | 31 ------------------------------- .travis.yml | 16 ---------------- README.md | 3 +-- 3 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .travis.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 3b6eda5..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Documentation: https://github.com/JuliaCI/Appveyor.jl -environment: - matrix: - - julia_version: 1.3 - - julia_version: nightly -platform: - - x86 - - x64 -matrix: - allow_failures: - - julia_version: nightly -branches: - only: - - master - - /release-.*/ -notifications: - - provider: Email - on_build_success: false - on_build_failure: false - on_build_status_changed: true -install: - - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) -build_script: - - echo "%JL_BUILD_SCRIPT%" - - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" -test_script: - - echo "%JL_TEST_SCRIPT%" - - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" -on_success: - - echo "%JL_CODECOV_SCRIPT%" - - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7e5ce42..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Documentation: http://docs.travis-ci.com/user/languages/julia/ -language: julia -os: - - linux - - osx -julia: - - 1.3 - - nightly -matrix: - allow_failures: - - julia: nightly - fast_finish: true -notifications: - email: true -after_success: - - julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())' diff --git a/README.md b/README.md index 6ad6d03..13cd8d7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ LibSndFile.jl ============= -[![Build Status](https://travis-ci.org/JuliaAudio/LibSndFile.jl.svg?branch=master)](https://travis-ci.org/JuliaAudio/LibSndFile.jl) -[![Build status](https://ci.appveyor.com/api/projects/status/1wdo413vf375i1vr/branch/master?svg=true)](https://ci.appveyor.com/project/ssfrr/libsndfile-jl/branch/master) +![CI](https://github.com/JuliaAudio/LibSndFile.jl/workflows/Tests/badge.svg) [![codecov.io](https://codecov.io/github/JuliaAudio/LibSndFile.jl/coverage.svg?branch=master)](https://codecov.io/github/JuliaAudio/LibSndFile.jl?branch=master) LibSndFile.jl is a wrapper for [libsndfile](http://www.mega-nerd.com/libsndfile/), and supports a wide variety of file and sample formats. The package uses the [FileIO](https://github.com/JuliaIO/FileIO.jl) `load` and `save` interface to automatically figure out the file type of the file to be opened, and the file contents are represented as a `SampleBuf`. For streaming I/O we support FileIO's `loadstreaming` and `savestreaming` functions as well. The results are represented as `SampleSource` (for reading), or `SampleSink` (for writing) subtypes. These buffer and stream types are defined in the [SampledSignals](https://github.com/JuliaAudio/SampledSignals.jl) package. From 58b8bda303e093f02226229ad204d9cdde0e7824 Mon Sep 17 00:00:00 2001 From: nantonel Date: Tue, 26 Oct 2021 10:08:06 +0200 Subject: [PATCH 08/22] added version, running tests to check if #47 is due to os --- src/libsndfile_h.jl | 10 ++++++++++ test/runtests.jl | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/libsndfile_h.jl b/src/libsndfile_h.jl index d28b29a..722c7a6 100644 --- a/src/libsndfile_h.jl +++ b/src/libsndfile_h.jl @@ -214,3 +214,13 @@ sf_seek(filePtr, frames::sf_count_t, whence::Integer) = ccall((:sf_seek, libsndfile), Int64, (Ptr{Cvoid}, Int64, Int32), filePtr, frames, whence) + +function version() + SFC_GET_LIB_VERSION = 0x1000 + buf = zeros(Cchar,256) + v = Cstring(pointer(buf)) + ccall((:sf_command, libsndfile), Int64, + (Ptr{Cvoid}, UInt, Cstring, UInt), + C_NULL, SFC_GET_LIB_VERSION, v, sizeof(buf)) + unsafe_string(v) +end diff --git a/test/runtests.jl b/test/runtests.jl index 23fd724..1e38d18 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -64,6 +64,11 @@ reference_buf = gen_reference(srate) # Juno @testset "LibSndFile Tests" begin +@testset "Version" begin + v = LibSndFile.version() + @test v[1:10] == "libsndfile" +end + @testset "Read errors" begin @test_throws ErrorException load_wav("doesnotexist.wav") end From 2b3d7b3a6fb5c0e26a6eefdcc3835ae8ea6ffb33 Mon Sep 17 00:00:00 2001 From: nantonel Date: Tue, 26 Oct 2021 18:57:38 +0200 Subject: [PATCH 09/22] tests on less julia v --- .github/workflows/Tests.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 594900c..f21b7bc 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -17,9 +17,7 @@ jobs: fail-fast: false matrix: version: - - '1.3' - - '1.4' - - '1.5' + - '1.6' - '1' - 'nightly' os: From 4f5fcef0c62b042eca67cb27dbf2611f75674a13 Mon Sep 17 00:00:00 2001 From: nantonel Date: Wed, 27 Oct 2021 10:43:32 +0200 Subject: [PATCH 10/22] clean up of tests --- test/{ => data}/440left_880right_0.5amp.flac | Bin test/{ => data}/440left_880right_0.5amp.ogg | Bin test/{ => data}/440left_880right_0.5amp.wav | Bin .../440left_880right_0.5amp_double.wav | Bin .../440left_880right_0.5amp_float.wav | Bin .../440left_880right_0.5amp_pcm24.wav | Bin test/display.jl | 62 +++ test/file_reading.jl | 63 +++ test/file_writing.jl | 92 ++++ test/fileio.jl | 13 + test/runtests.jl | 440 ++---------------- test/stream.jl | 73 +++ test/testhelpers.jl | 12 - test/utils.jl | 53 +++ 14 files changed, 390 insertions(+), 418 deletions(-) rename test/{ => data}/440left_880right_0.5amp.flac (100%) rename test/{ => data}/440left_880right_0.5amp.ogg (100%) rename test/{ => data}/440left_880right_0.5amp.wav (100%) rename test/{ => data}/440left_880right_0.5amp_double.wav (100%) rename test/{ => data}/440left_880right_0.5amp_float.wav (100%) rename test/{ => data}/440left_880right_0.5amp_pcm24.wav (100%) create mode 100644 test/display.jl create mode 100644 test/file_reading.jl create mode 100644 test/file_writing.jl create mode 100644 test/fileio.jl create mode 100644 test/stream.jl delete mode 100644 test/testhelpers.jl create mode 100644 test/utils.jl diff --git a/test/440left_880right_0.5amp.flac b/test/data/440left_880right_0.5amp.flac similarity index 100% rename from test/440left_880right_0.5amp.flac rename to test/data/440left_880right_0.5amp.flac diff --git a/test/440left_880right_0.5amp.ogg b/test/data/440left_880right_0.5amp.ogg similarity index 100% rename from test/440left_880right_0.5amp.ogg rename to test/data/440left_880right_0.5amp.ogg diff --git a/test/440left_880right_0.5amp.wav b/test/data/440left_880right_0.5amp.wav similarity index 100% rename from test/440left_880right_0.5amp.wav rename to test/data/440left_880right_0.5amp.wav diff --git a/test/440left_880right_0.5amp_double.wav b/test/data/440left_880right_0.5amp_double.wav similarity index 100% rename from test/440left_880right_0.5amp_double.wav rename to test/data/440left_880right_0.5amp_double.wav diff --git a/test/440left_880right_0.5amp_float.wav b/test/data/440left_880right_0.5amp_float.wav similarity index 100% rename from test/440left_880right_0.5amp_float.wav rename to test/data/440left_880right_0.5amp_float.wav diff --git a/test/440left_880right_0.5amp_pcm24.wav b/test/data/440left_880right_0.5amp_pcm24.wav similarity index 100% rename from test/440left_880right_0.5amp_pcm24.wav rename to test/data/440left_880right_0.5amp_pcm24.wav diff --git a/test/display.jl b/test/display.jl new file mode 100644 index 0000000..8a33c41 --- /dev/null +++ b/test/display.jl @@ -0,0 +1,62 @@ +@testset "Sink Display" begin + fname = string(tempname(), ".wav") + testbuf = SampleBuf(rand(Float32, 10000, 2) .- 0.5f0, srate) + # set up a 2-channel Float32 stream + stream = savestreaming_wav(fname, 2, srate, Float32) + io = IOBuffer() + show(io, stream) + @test replace(String(take!(io)), " " => "") == + replace( + """ + LibSndFile.SndFileSink{Float32, String} + path: "$fname" + channels: 2 + samplerate: 44100Hz + position: 0 of 0 frames + 0.00 of 0.00 seconds""" + , " " => "") + write(stream, testbuf) + show(io, stream) + @test replace(String(take!(io)), " " => "") == + replace( + """ + LibSndFile.SndFileSink{Float32, String} + path: "$fname" + channels: 2 + samplerate: 44100Hz + position: 10000 of 10000 frames + 0.23 of 0.23 seconds""" + , " " => "") +end + +@testset "Source Display" begin + fname = string(tempname(), ".wav") + testbuf = SampleBuf(rand(Float32, 10000, 2) .- 0.5f0, srate) + save_wav(fname, testbuf) + # set up a 2-channel Float32 stream + stream = loadstreaming_wav(fname) + io = IOBuffer() + show(io, stream) + @test replace(String(take!(io)), " " => "") == + replace( + """ + LibSndFile.SndFileSource{Float32, String} + path: "$fname" + channels: 2 + samplerate: 44100Hz + position: 0 of 10000 frames + 0.00 of 0.23 seconds""" + , " " => "") + read(stream, 5000) + show(io, stream) + @test replace(String(take!(io)), " " => "") == + replace( + """ + LibSndFile.SndFileSource{Float32, String} + path: "$fname" + channels: 2 + samplerate: 44100Hz + position: 5000 of 10000 frames + 0.11 of 0.23 seconds""" + , " " => "") +end diff --git a/test/file_reading.jl b/test/file_reading.jl new file mode 100644 index 0000000..c3d1903 --- /dev/null +++ b/test/file_reading.jl @@ -0,0 +1,63 @@ +@testset "PCM16 WAV file reading" begin + buf = load_wav(reference_wav) + @test samplerate(buf) == srate + @test nchannels(buf) == 2 + @test nframes(buf) == 100 + @test isapprox(domain(buf), collect(0:99)/(srate)) + @test mse(buf, reference_buf) < 1e-10 + @test eltype(buf) == PCM16Sample +end + +@testset "PCM32 WAV file reading" begin + buf = load_wav(reference_wav_pcm24) + @test samplerate(buf) == srate + @test nchannels(buf) == 2 + @test nframes(buf) == 100 + @test isapprox(domain(buf), collect(0:99)/(srate)) + @test mse(buf, reference_buf) < 1e-10 + @test eltype(buf) == PCM32Sample +end + +@testset "Float32 WAV file reading" begin + buf = load_wav(reference_wav_float) + @test samplerate(buf) == srate + @test nchannels(buf) == 2 + @test nframes(buf) == 100 + @test isapprox(domain(buf), collect(0:99)/(srate)) + @test mse(buf, reference_buf) < 1e-10 + @test eltype(buf) == Float32 +end + +@testset "Float64 WAV file reading" begin + buf = load_wav(reference_wav_double) + @test samplerate(buf) == srate + @test nchannels(buf) == 2 + @test nframes(buf) == 100 + @test isapprox(domain(buf), collect(0:99)/(srate)) + @test mse(buf, reference_buf) < 1e-10 + @test eltype(buf) == Float64 +end + +@testset "FLAC file reading" begin + buf = load_flac(reference_flac) + @test samplerate(buf) == srate + @test nchannels(buf) == 2 + @test nframes(buf) == 100 + @test isapprox(domain(buf), collect(0:99)/srate) + @test mse(buf, reference_buf) < 1e-10 + @test eltype(buf) == PCM16Sample +end + +@testset "OGG file reading" begin + buf = load_ogg(reference_ogg) + @test samplerate(buf) == srate + @test nchannels(buf) == 2 + @test nframes(buf) == 100 + @test isapprox(domain(buf), collect(0:99)/srate) + # lossy compression, so relax the accuracy a bit + @test mse(buf, reference_buf) < 1e-5 +end + +@testset "Read errors" begin + @test_throws ErrorException load_wav("doesnotexist.wav") +end diff --git a/test/file_writing.jl b/test/file_writing.jl new file mode 100644 index 0000000..6a598e0 --- /dev/null +++ b/test/file_writing.jl @@ -0,0 +1,92 @@ +@testset "WAV file writing (float64)" begin + fname = string(tempname(), ".wav") + testbuf = SampleBuf(rand(100, 2) .- 0.5, srate) + save_wav(fname, testbuf) + buf = load_wav(fname) + @test eltype(buf) == eltype(testbuf) + @test samplerate(buf) == srate + @test nchannels(buf) == 2 + @test nframes(buf) == 100 + @test isapprox(domain(buf), collect(0:99)/srate) + @test mse(buf, testbuf) < 1e-10 +end + +@testset "WAV file writing (float32)" begin + fname = string(tempname(), ".wav") + testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5f0, srate) + save_wav(fname, testbuf) + buf = load_wav(fname) + @test eltype(buf) == eltype(testbuf) + @test samplerate(buf) == srate + @test nchannels(buf) == 2 + @test nframes(buf) == 100 + @test isapprox(domain(buf), collect(0:99)/srate) + @test mse(buf, testbuf) < 1e-10 +end + +@testset "OGG file writing" begin + fname = string(tempname(), ".ogg") + testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5, srate) + save_ogg(fname, testbuf) + buf = load_ogg(fname) + @test samplerate(buf) == srate + @test nchannels(buf) == 2 + @test nframes(buf) == 100 + @test isapprox(domain(buf), collect(0:99)/srate) + # noise doesn't compress very well... + @test mse(buf, testbuf) < 0.05 +end + +@testset "FLAC file writing" begin + fname = string(tempname(), ".flac") + arr = map(PCM16Sample, rand(100, 2) .- 0.5) + testbuf = SampleBuf(arr, srate) + save_flac(fname, testbuf) + buf = load_flac(fname) + @test samplerate(buf) == srate + @test nchannels(buf) == 2 + @test nframes(buf) == 100 + @test isapprox(domain(buf), collect(0:99)/srate) + @test mse(buf, testbuf) < 1e-10 +end + +@testset "Writing $T data" for T in [PCM16Sample, PCM32Sample, Float32, Float64] + fname = string(tempname(), ".wav") + arr = map(T, rand(100, 2) .- 0.5) + testbuf = SampleBuf(arr, srate) + save_wav(fname, testbuf) + buf = load_wav(fname) + @test eltype(buf) == T + @test mse(buf, testbuf) < 1e-10 +end + +@testset "Streaming writing" begin + fname = string(tempname(), ".wav") + testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5, srate) + # set up a 2-channel Float32 stream + stream = savestreaming_wav(fname, 2, srate, Float32) + write(stream, testbuf[1:50, :]) + write(stream, testbuf[51:100, :]) + close(stream) + buf = load_wav(fname) + @test mse(buf, testbuf) < 1e-10 + + # now with do syntax + fname = string(tempname(), ".wav") + testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5, srate) + # set up a 2-channel Float32 stream + savestreaming_wav(fname, 2, srate, Float32) do stream + write(stream, testbuf[1:50, :]) + write(stream, testbuf[51:100, :]) + end + buf = load_wav(fname) + @test mse(buf, testbuf) < 1e-10 + +end + +@testset "Write errors" begin + testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5, srate) + flacname = string(tempname(), ".flac") + @test_throws ErrorException save_flac(abspath("doesnotexist.wav"), testbuf) + @test_throws ErrorException save_flac(flacname, testbuf) +end diff --git a/test/fileio.jl b/test/fileio.jl new file mode 100644 index 0000000..97d4ebb --- /dev/null +++ b/test/fileio.jl @@ -0,0 +1,13 @@ +arr = map(PCM16Sample, rand(100, 2) .- 0.5) +testbuf = SampleBuf(arr, srate) +for ext in extensions + fname = string(tempname(), ext) + FileIO.save(fname, testbuf) + buf = FileIO.load(fname) + @test buf isa SampleBuf +end + +# testing with unicode +FileIO.save("β.flac", testbuf) +FileIO.load("β.flac") +rm("β.flac") diff --git a/test/runtests.jl b/test/runtests.jl index 1e38d18..19626c5 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,415 +1,43 @@ #!/usr/bin/env julia - using Test -using FileIO: File, Stream, @format_str -import FileIO -import LibSndFile +using FileIO +using LibSndFile using SampledSignals +using LinearAlgebra -include("testhelpers.jl") - -# define some loaders and savers that bypass FileIO's detection machinery, of -# the form: -# load_wav(io::String, args...) = LibSndFile.load(File(format"WAV", io), args...) -# load_wav(io::IO, args...) = LibSndFile.load(Stream(format"WAV", io), args...) -# also create do-compatible methods of the form: -# function loadstreaming_wav(dofunc::Function, io::IO, args...) -# str = LibSndFile.load(dofunc, Stream(format"WAV", io), args...) -# try -# dofunc(str) -# finally -# close(str) -# end -# end +extensions = (".wav", + ".ogg", + ".flac") -for f in (:load, :save, :loadstreaming, :savestreaming) - for io in ((String, File), (IO, Stream)) - for fmt in (("_wav", format"WAV"), ("_ogg", format"OGG"), ("_flac", format"FLAC")) - @eval $(Symbol(f, fmt[1]))(io::$(io[1]), args...) = - LibSndFile.$f($(io[2]){$(fmt[2])}( io), args...) - if f in (:loadstreaming, :savestreaming) - @eval function $(Symbol(f, fmt[1]))(dofunc::Function, io::$(io[1]), args...) - str = LibSndFile.$f($(io[2]){$(fmt[2])}( io), args...) - try - dofunc(str) - finally - close(str) - end - end - end - end - end -end +formats = [ + ("_wav", format"WAV"), + ("_ogg", format"OGG"), + ("_flac", format"FLAC"), + ] -"""Generates a 100-sample 2-channel signal""" -function gen_reference(srate) - t = collect(0:99) / srate - phase = [2pi*440t 2pi*880t] +include("utils.jl") - 0.5sin.(phase) -end - -srate = 44100 -# reference file generated with Audacity. Careful to turn dithering off -# on export for deterministic output! -reference_wav = joinpath(dirname(@__FILE__), "440left_880right_0.5amp.wav") -reference_wav_float = joinpath(dirname(@__FILE__), "440left_880right_0.5amp_float.wav") -reference_wav_double = joinpath(dirname(@__FILE__), "440left_880right_0.5amp_double.wav") -reference_wav_pcm24 = joinpath(dirname(@__FILE__), "440left_880right_0.5amp_pcm24.wav") -reference_ogg = joinpath(dirname(@__FILE__), "440left_880right_0.5amp.ogg") -reference_flac = joinpath(dirname(@__FILE__), "440left_880right_0.5amp.flac") -reference_buf = gen_reference(srate) - -# don't indent the individual testsets so we can more easily run them from -# Juno @testset "LibSndFile Tests" begin - -@testset "Version" begin - v = LibSndFile.version() - @test v[1:10] == "libsndfile" -end - -@testset "Read errors" begin - @test_throws ErrorException load_wav("doesnotexist.wav") -end - -@testset "WAV file reading" begin - buf = load_wav(reference_wav) - @test samplerate(buf) == srate - @test nchannels(buf) == 2 - @test nframes(buf) == 100 - @test isapprox(domain(buf), collect(0:99)/(srate)) - @test mse(buf, reference_buf) < 1e-10 -end - -@testset "Reading different sample types" begin - buf = load_wav(reference_wav) - @test eltype(buf) == PCM16Sample - - buf_float = load_wav(reference_wav_float) - @test eltype(buf_float) == Float32 - @test mse(buf_float, reference_buf) < 1e-10 - - buf_double = load_wav(reference_wav_double) - @test eltype(buf_double) == Float64 - @test mse(buf_double, reference_buf) < 1e-10 - - buf_pcm24 = load_wav(reference_wav_pcm24) - @test eltype(buf_pcm24) == PCM32Sample - @test mse(buf_pcm24, reference_buf) < 1e-10 -end - -@testset "FLAC file reading" begin - buf = load_flac(reference_flac) - @test samplerate(buf) == srate - @test nchannels(buf) == 2 - @test nframes(buf) == 100 - @test isapprox(domain(buf), collect(0:99)/srate) - @test mse(buf, reference_buf) < 1e-10 -end - -@testset "OGG file reading" begin - buf = load_ogg(reference_ogg) - @test samplerate(buf) == srate - @test nchannels(buf) == 2 - @test nframes(buf) == 100 - @test isapprox(domain(buf), collect(0:99)/srate) - # lossy compression, so relax the accuracy a bit - @test mse(buf, reference_buf) < 1e-5 -end - -@testset "Streaming reading" begin - str = loadstreaming_wav(reference_wav) - @test nframes(str) == 100 - @test position(str) == 1 - @test mse(read(str, 50), reference_buf[1:50, :]) < 1e-10 - @test mse(read(str, 50), reference_buf[51:100, :]) < 1e-10 - close(str) - # now with do syntax - loadstreaming_wav(reference_wav) do str - @test mse(read(str, 50), reference_buf[1:50, :]) < 1e-10 - @test mse(read(str, 50), reference_buf[51:100, :]) < 1e-10 - end - # now try reading all at once - loadstreaming_wav(reference_wav) do str - @test mse(read(str), reference_buf) < 1e-10 - end - - # seeking - loadstreaming_wav(reference_wav) do str - seek(str, 22) - @test mse(read(str), reference_buf[22:end, :]) < 1e-10 - end - - # skipping - loadstreaming_wav(reference_wav) do str - seek(str, 22) - skip(str, 10) - @test mse(read(str), reference_buf[32:end, :]) < 1e-10 - end - + @testset "Version" begin + v = LibSndFile.version() + @test v[1:10] == "libsndfile" + end + @testset "File reading" begin + include("file_reading.jl") + end + @testset "Streaming and IO" begin + include("stream.jl") + end + @testset "File writing" begin + include("file_writing.jl") + end + @testset "FileIO Integration" begin + include("fileio.jl") + end + @testset "Display" begin + include("display.jl") + end + + # TODO: check out what happens when samplerate, channels, etc. are wrong + # when reading/writing end - -@testset "Reading from IO Stream" begin - open(reference_wav) do io - loadstreaming_wav(io) do str - @test nframes(str) == 100 - @test mse(read(str), reference_buf) < 1e-10 - end - end - open(reference_wav) do io - buf = load_wav(io) - @test samplerate(buf) == srate - @test nchannels(buf) == 2 - @test nframes(buf) == 100 - @test isapprox(domain(buf), collect(0:99)/(srate)) - @test mse(buf, reference_buf) < 1e-10 - end -end - -@testset "Writing to IO Streams" begin - fname = string(tempname(), ".wav") - testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5, srate) - open(fname, "w") do io - savestreaming_wav(io, 2, srate, Float32) do str - write(str, testbuf[1:50, :]) - write(str, testbuf[51:100, :]) - end - end - @test load_wav(fname) == testbuf - fname = string(tempname(), ".wav") - open(fname, "w") do io - save_wav(io, testbuf) - end - @test load_wav(fname) == testbuf -end - -@testset "Supports IOBuffer" begin - io = IOBuffer() - testbuf = SampleBuf(rand(100, 2) .- 0.5, srate) - save_wav(io, testbuf) - seek(io, 0) - @test load_wav(io) == testbuf -end - -@testset "WAV file writing (float64)" begin - fname = string(tempname(), ".wav") - testbuf = SampleBuf(rand(100, 2) .- 0.5, srate) - save_wav(fname, testbuf) - buf = load_wav(fname) - @test eltype(buf) == eltype(testbuf) - @test samplerate(buf) == srate - @test nchannels(buf) == 2 - @test nframes(buf) == 100 - @test isapprox(domain(buf), collect(0:99)/srate) - @test mse(buf, testbuf) < 1e-10 -end - -@testset "WAV file writing (float32)" begin - fname = string(tempname(), ".wav") - testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5f0, srate) - save_wav(fname, testbuf) - buf = load_wav(fname) - @test eltype(buf) == eltype(testbuf) - @test samplerate(buf) == srate - @test nchannels(buf) == 2 - @test nframes(buf) == 100 - @test isapprox(domain(buf), collect(0:99)/srate) - @test mse(buf, testbuf) < 1e-10 -end - -@testset "OGG file writing" begin - fname = string(tempname(), ".ogg") - testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5, srate) - save_ogg(fname, testbuf) - buf = load_ogg(fname) - @test samplerate(buf) == srate - @test nchannels(buf) == 2 - @test nframes(buf) == 100 - @test isapprox(domain(buf), collect(0:99)/srate) - # noise doesn't compress very well... - @test mse(buf, testbuf) < 0.05 -end - -@testset "FLAC file writing" begin - fname = string(tempname(), ".flac") - arr = map(PCM16Sample, rand(100, 2) .- 0.5) - testbuf = SampleBuf(arr, srate) - save_flac(fname, testbuf) - buf = load_flac(fname) - @test samplerate(buf) == srate - @test nchannels(buf) == 2 - @test nframes(buf) == 100 - @test isapprox(domain(buf), collect(0:99)/srate) - @test mse(buf, testbuf) < 1e-10 -end - -@testset "Writing $T data" for T in [PCM16Sample, PCM32Sample, Float32, Float64] - fname = string(tempname(), ".wav") - arr = map(T, rand(100, 2) .- 0.5) - testbuf = SampleBuf(arr, srate) - save_wav(fname, testbuf) - buf = load_wav(fname) - @test eltype(buf) == T - @test mse(buf, testbuf) < 1e-10 -end - -@testset "Write errors" begin - testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5, srate) - flacname = string(tempname(), ".flac") - @test_throws ErrorException save_flac(abspath("doesnotexist.wav"), testbuf) - @test_throws ErrorException save_flac(flacname, testbuf) -end - -@testset "Streaming writing" begin - fname = string(tempname(), ".wav") - testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5, srate) - # set up a 2-channel Float32 stream - stream = savestreaming_wav(fname, 2, srate, Float32) - write(stream, testbuf[1:50, :]) - write(stream, testbuf[51:100, :]) - close(stream) - buf = load_wav(fname) - @test mse(buf, testbuf) < 1e-10 - - # now with do syntax - fname = string(tempname(), ".wav") - testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5, srate) - # set up a 2-channel Float32 stream - savestreaming_wav(fname, 2, srate, Float32) do stream - write(stream, testbuf[1:50, :]) - write(stream, testbuf[51:100, :]) - end - buf = load_wav(fname) - @test mse(buf, testbuf) < 1e-10 - -end - -@testset "FileIO Integration" begin - arr = map(PCM16Sample, rand(100, 2) .- 0.5) - testbuf = SampleBuf(arr, srate) - for ext in (".wav", ".ogg", ".flac") - fname = string(tempname(), ext) - FileIO.save(fname, testbuf) - buf = FileIO.load(fname) - @test buf isa SampleBuf - end -end - -@testset "Sink Display" begin - fname = string(tempname(), ".wav") - testbuf = SampleBuf(rand(Float32, 10000, 2) .- 0.5f0, srate) - # set up a 2-channel Float32 stream - stream = savestreaming_wav(fname, 2, srate, Float32) - io = IOBuffer() - show(io, stream) - @test replace(String(take!(io)), " " => "") == - replace( - """ - LibSndFile.SndFileSink{Float32, String} - path: "$fname" - channels: 2 - samplerate: 44100Hz - position: 0 of 0 frames - 0.00 of 0.00 seconds""" - , " " => "") - write(stream, testbuf) - show(io, stream) - @test replace(String(take!(io)), " " => "") == - replace( - """ - LibSndFile.SndFileSink{Float32, String} - path: "$fname" - channels: 2 - samplerate: 44100Hz - position: 10000 of 10000 frames - 0.23 of 0.23 seconds""" - , " " => "") -end - -@testset "Source Display" begin - fname = string(tempname(), ".wav") - testbuf = SampleBuf(rand(Float32, 10000, 2) .- 0.5f0, srate) - save_wav(fname, testbuf) - # set up a 2-channel Float32 stream - stream = loadstreaming_wav(fname) - io = IOBuffer() - show(io, stream) - @test replace(String(take!(io)), " " => "") == - replace( - """ - LibSndFile.SndFileSource{Float32, String} - path: "$fname" - channels: 2 - samplerate: 44100Hz - position: 0 of 10000 frames - 0.00 of 0.23 seconds""" - , " " => "") - read(stream, 5000) - show(io, stream) - @test replace(String(take!(io)), " " => "") == - replace( - """ - LibSndFile.SndFileSource{Float32, String} - path: "$fname" - channels: 2 - samplerate: 44100Hz - position: 5000 of 10000 frames - 0.11 of 0.23 seconds""" - , " " => "") -end - -# TODO: check out what happens when samplerate, channels, etc. are wrong -# when reading/writing - -# -# # test seeking -# -# # test rendering as an AudioNode -# AudioIO.open(fname) do f -# # pretend we have a stream at the same rate as the file -# bufsize = 1024 -# input = zeros(AudioSample, bufsize) -# test_info = DeviceInfo(srate, bufsize) -# node = FilePlayer(f) -# # convert to floating point because that's what AudioIO uses natively -# expected = convert(AudioBuf, reference ./ (2^15)) -# buf = render(node, input, test_info) -# @fact expected[1:bufsize] => buf[1:bufsize] -# buf = render(node, input, test_info) -# @fact expected[bufsize+1:2*bufsize] => buf[1:bufsize] -# end -# end -# -# @testset "Stereo file reading" begin -# fname = Pkg.dir("AudioIO", "test", "440left_880right.wav") -# srate = 44100 -# t = [0 : 2 * srate - 1] / srate -# expected = int16((2^15-1) * hcat(sin(2pi*t*440), sin(2pi*t*880))) -# -# AudioIO.open(fname) do f -# buf = read(f) -# @fact buf => mse(expected, 5) -# end -# end -# -# # note - currently AudioIO just mixes down to Mono. soon we'll support this -# # new-fangled stereo sound stuff -# @testset "Stereo file rendering" begin -# fname = Pkg.dir("AudioIO", "test", "440left_880right.wav") -# srate = 44100 -# bufsize = 1024 -# input = zeros(AudioSample, bufsize) -# test_info = DeviceInfo(srate, bufsize) -# t = [0 : 2 * srate - 1] / srate -# expected = convert(AudioBuf, 0.5 * (sin(2pi*t*440) + sin(2pi*t*880))) -# -# AudioIO.open(fname) do f -# node = FilePlayer(f) -# buf = render(node, input, test_info) -# @fact buf[1:bufsize] => mse(expected[1:bufsize]) -# buf = render(node, input, test_info) -# @fact buf[1:bufsize] => mse(expected[bufsize+1:2*bufsize]) -# end -# end -end # @testset LibSndFile diff --git a/test/stream.jl b/test/stream.jl new file mode 100644 index 0000000..7283623 --- /dev/null +++ b/test/stream.jl @@ -0,0 +1,73 @@ +@testset "Streaming reading" begin + str = loadstreaming_wav(reference_wav) + @test nframes(str) == 100 + @test position(str) == 1 + @test mse(read(str, 50), reference_buf[1:50, :]) < 1e-10 + @test mse(read(str, 50), reference_buf[51:100, :]) < 1e-10 + close(str) + # now with do syntax + loadstreaming_wav(reference_wav) do str + @test mse(read(str, 50), reference_buf[1:50, :]) < 1e-10 + @test mse(read(str, 50), reference_buf[51:100, :]) < 1e-10 + end + # now try reading all at once + loadstreaming_wav(reference_wav) do str + @test mse(read(str), reference_buf) < 1e-10 + end + + # seeking + loadstreaming_wav(reference_wav) do str + seek(str, 22) + @test mse(read(str), reference_buf[22:end, :]) < 1e-10 + end + + # skipping + loadstreaming_wav(reference_wav) do str + seek(str, 22) + skip(str, 10) + @test mse(read(str), reference_buf[32:end, :]) < 1e-10 + end + +end + +@testset "Reading from IO Stream" begin + open(reference_wav) do io + loadstreaming_wav(io) do str + @test nframes(str) == 100 + @test mse(read(str), reference_buf) < 1e-10 + end + end + open(reference_wav) do io + buf = load_wav(io) + @test samplerate(buf) == srate + @test nchannels(buf) == 2 + @test nframes(buf) == 100 + @test isapprox(domain(buf), collect(0:99)/(srate)) + @test mse(buf, reference_buf) < 1e-10 + end +end + +@testset "Writing to IO Streams" begin + fname = string(tempname(), ".wav") + testbuf = SampleBuf(rand(Float32, 100, 2) .- 0.5, srate) + open(fname, "w") do io + savestreaming_wav(io, 2, srate, Float32) do str + write(str, testbuf[1:50, :]) + write(str, testbuf[51:100, :]) + end + end + @test load_wav(fname) == testbuf + fname = string(tempname(), ".wav") + open(fname, "w") do io + save_wav(io, testbuf) + end + @test load_wav(fname) == testbuf +end + +@testset "Supports IOBuffer" begin + io = IOBuffer() + testbuf = SampleBuf(rand(100, 2) .- 0.5, srate) + save_wav(io, testbuf) + seek(io, 0) + @test load_wav(io) == testbuf +end diff --git a/test/testhelpers.jl b/test/testhelpers.jl deleted file mode 100644 index 98a4164..0000000 --- a/test/testhelpers.jl +++ /dev/null @@ -1,12 +0,0 @@ -# convenience function to calculate the mean-squared error -function mse(arr1::AbstractArray, arr2::AbstractArray) - if size(arr1) != size(arr2) - throw(DimensionMismatch("Got $(size(arr1)) and $(size(arr2))")) - end - N = length(arr1) - err = 0.0 - for i in 1:N - err += (arr2[i] - arr1[i])^2 - end - err /= N -end diff --git a/test/utils.jl b/test/utils.jl new file mode 100644 index 0000000..14a8f37 --- /dev/null +++ b/test/utils.jl @@ -0,0 +1,53 @@ +srate = 44100 +# convenience function to calculate the mean-squared error +mse(x,y) = norm(x-y)^2/length(x) + +# Generates a 100-sample 2-channel signal +function gen_reference(srate) + t = collect(0:99) / srate + phase = [2pi*440t 2pi*880t] + 0.5sin.(phase) +end + +# reference file generated with Audacity. Careful to turn dithering off +# on export for deterministic output! +reference_wav = "data/440left_880right_0.5amp.wav" +reference_wav_float = "data/440left_880right_0.5amp_float.wav" +reference_wav_double = "data/440left_880right_0.5amp_double.wav" +reference_wav_pcm24 = "data/440left_880right_0.5amp_pcm24.wav" +reference_ogg = "data/440left_880right_0.5amp.ogg" +reference_flac = "data/440left_880right_0.5amp.flac" +reference_buf = gen_reference(srate) + +# define some loaders and savers that bypass FileIO's detection machinery, of +# the form: +# load_wav(io::String, args...) = LibSndFile.load(File(format"WAV", io), args...) +# load_wav(io::IO, args...) = LibSndFile.load(Stream(format"WAV", io), args...) +# also create do-compatible methods of the form: +# function loadstreaming_wav(dofunc::Function, io::IO, args...) +# str = LibSndFile.load(dofunc, Stream(format"WAV", io), args...) +# try +# dofunc(str) +# finally +# close(str) +# end +# end + +for f in (:load, :save, :loadstreaming, :savestreaming) + for io in ((String, File), (IO, Stream)) + for fmt in formats + @eval $(Symbol(f, fmt[1]))(io::$(io[1]), args...) = + LibSndFile.$f($(io[2]){$(fmt[2])}( io), args...) + if f in (:loadstreaming, :savestreaming) + @eval function $(Symbol(f, fmt[1]))(dofunc::Function, io::$(io[1]), args...) + str = LibSndFile.$f($(io[2]){$(fmt[2])}( io), args...) + try + dofunc(str) + finally + close(str) + end + end + end + end + end +end From 3706b6eee4cc48741d930cea3077051c6a0dc261 Mon Sep 17 00:00:00 2001 From: nantonel Date: Wed, 27 Oct 2021 11:22:06 +0200 Subject: [PATCH 11/22] addressing #35 --- src/LibSndFile.jl | 1 + src/constants.jl | 81 ++++++++++++++++ src/libsndfile_h.jl | 222 +++++++++++++++----------------------------- test/fileio.jl | 6 +- 4 files changed, 158 insertions(+), 152 deletions(-) create mode 100644 src/constants.jl diff --git a/src/LibSndFile.jl b/src/LibSndFile.jl index c5ca292..3992878 100644 --- a/src/LibSndFile.jl +++ b/src/LibSndFile.jl @@ -12,6 +12,7 @@ using libsndfile_jll: libsndfile const supported_formats = (format"WAV", format"FLAC", format"OGG") +include("constants.jl") include("libsndfile_h.jl") include("lengthIO.jl") include("sourcesink.jl") diff --git a/src/constants.jl b/src/constants.jl new file mode 100644 index 0000000..85c0e98 --- /dev/null +++ b/src/constants.jl @@ -0,0 +1,81 @@ +# Masks + +const SF_FORMAT_ENDMASK = 0x30000000 +const SF_FORMAT_TYPEMASK = 0x0FFF0000 +const SF_FORMAT_SUBMASK = 0x0000FFFF + +# Endian-ness options + +const SF_ENDIAN_FILE = 0x00000000 # Default file endian-ness. +const SF_ENDIAN_LITTLE = 0x10000000 # Force little endian-ness. +const SF_ENDIAN_BIG = 0x20000000 # Force big endian-ness. +const SF_ENDIAN_CPU = 0x30000000 # Force CPU endian-ness. + +# Major Formats + +const SF_FORMAT_WAV = 0x00010000 # Microsoft WAV format (little endian). +const SF_FORMAT_AIFF = 0x00020000 # Apple/SGI AIFF format (big endian). +const SF_FORMAT_AU = 0x00030000 # Sun/NeXT AU format (big endian). +const SF_FORMAT_RAW = 0x00040000 # RAW PCM data. +const SF_FORMAT_PAF = 0x00050000 # Ensoniq PARIS file format. +const SF_FORMAT_SVX = 0x00060000 # Amiga IFF / SVX8 / SV16 format. +const SF_FORMAT_NIST = 0x00070000 # Sphere NIST format. +const SF_FORMAT_VOC = 0x00080000 # VOC files. +const SF_FORMAT_IRCAM = 0x000A0000 # Berkeley/IRCAM/CARL +const SF_FORMAT_W64 = 0x000B0000 # Sonic Foundry's 64 bit RIFF/WAV +const SF_FORMAT_MAT4 = 0x000C0000 # Matlab (tm) V4.2 / GNU Octave 2.0 +const SF_FORMAT_MAT5 = 0x000D0000 # Matlab (tm) V5.0 / GNU Octave 2.1 +const SF_FORMAT_PVF = 0x000E0000 # Portable Voice Format +const SF_FORMAT_XI = 0x000F0000 # Fasttracker 2 Extended Instrument +const SF_FORMAT_HTK = 0x00100000 # HMM Tool Kit format +const SF_FORMAT_SDS = 0x00110000 # Midi Sample Dump Standard +const SF_FORMAT_AVR = 0x00120000 # Audio Visual Research +const SF_FORMAT_WAVEX = 0x00130000 # MS WAVE with WAVEFORMATEX +const SF_FORMAT_SD2 = 0x00160000 # Sound Designer 2 +const SF_FORMAT_FLAC = 0x00170000 # FLAC lossless file format +const SF_FORMAT_CAF = 0x00180000 # Core Audio File format +const SF_FORMAT_WVE = 0x00190000 # Psion WVE format +const SF_FORMAT_OGG = 0x00200000 # Xiph OGG container +const SF_FORMAT_MPC2K = 0x00210000 # Akai MPC 2000 sampler +const SF_FORMAT_RF64 = 0x00220000 # RF64 WAV file + +# SubFormats + +const SF_FORMAT_PCM_S8 = 0x00000001 # Signed 8 bit data +const SF_FORMAT_PCM_16 = 0x00000002 # Signed 16 bit data +const SF_FORMAT_PCM_24 = 0x00000003 # Signed 24 bit data +const SF_FORMAT_PCM_32 = 0x00000004 # Signed 32 bit data +const SF_FORMAT_PCM_U8 = 0x00000005 # Unsigned 8 bit data (WAV and RAW only) +const SF_FORMAT_FLOAT = 0x00000006 # 32 bit float data +const SF_FORMAT_DOUBLE = 0x00000007 # 64 bit float data +const SF_FORMAT_ULAW = 0x00000010 # U-Law encoded. +const SF_FORMAT_ALAW = 0x00000011 # A-Law encoded. +const SF_FORMAT_IMA_ADPCM = 0x00000012 # IMA ADPCM. +const SF_FORMAT_MS_ADPCM = 0x00000013 # Microsoft ADPCM. +const SF_FORMAT_GSM610 = 0x00000020 # GSM 6.10 encoding. +const SF_FORMAT_VOX_ADPCM = 0x00000021 # Oki Dialogic ADPCM encoding. +const SF_FORMAT_G721_32 = 0x00000030 # 32kbs G721 ADPCM encoding. +const SF_FORMAT_G723_24 = 0x00000031 # 24kbs G723 ADPCM encoding. +const SF_FORMAT_G723_40 = 0x00000032 # 40kbs G723 ADPCM encoding. +const SF_FORMAT_DWVW_12 = 0x00000040 # 12 bit Delta Width Variable Word encoding. +const SF_FORMAT_DWVW_16 = 0x00000041 # 16 bit Delta Width Variable Word encoding. +const SF_FORMAT_DWVW_24 = 0x00000042 # 24 bit Delta Width Variable Word encoding. +const SF_FORMAT_DWVW_N = 0x00000043 # N bit Delta Width Variable Word encoding. +const SF_FORMAT_DPCM_8 = 0x00000050 # 8 bit differential PCM (XI only) +const SF_FORMAT_DPCM_16 = 0x00000051 # 16 bit differential PCM (XI only) +const SF_FORMAT_VORBIS = 0x00000060 # Xiph Vorbis encoding. + +# Library flags + +# const SF_SEEK_SET = 0 +# const SF_SEEK_CUR = 1 +# const SF_SEEK_END = 2 + +const SFM_READ = Int32(0x10) +const SFM_WRITE = Int32(0x20) + +const SF_SEEK_SET = Int32(0) +const SF_SEEK_CUR = Int32(1) +const SF_SEEK_END = Int32(2) + +const sf_count_t = Int64 diff --git a/src/libsndfile_h.jl b/src/libsndfile_h.jl index 722c7a6..8bcc9b8 100644 --- a/src/libsndfile_h.jl +++ b/src/libsndfile_h.jl @@ -1,83 +1,3 @@ -# Masks - -const SF_FORMAT_ENDMASK = 0x30000000 -const SF_FORMAT_TYPEMASK = 0x0FFF0000 -const SF_FORMAT_SUBMASK = 0x0000FFFF - -# Endian-ness options - -const SF_ENDIAN_FILE = 0x00000000 # Default file endian-ness. -const SF_ENDIAN_LITTLE = 0x10000000 # Force little endian-ness. -const SF_ENDIAN_BIG = 0x20000000 # Force big endian-ness. -const SF_ENDIAN_CPU = 0x30000000 # Force CPU endian-ness. - -# Major Formats - -const SF_FORMAT_WAV = 0x00010000 # Microsoft WAV format (little endian). -const SF_FORMAT_AIFF = 0x00020000 # Apple/SGI AIFF format (big endian). -const SF_FORMAT_AU = 0x00030000 # Sun/NeXT AU format (big endian). -const SF_FORMAT_RAW = 0x00040000 # RAW PCM data. -const SF_FORMAT_PAF = 0x00050000 # Ensoniq PARIS file format. -const SF_FORMAT_SVX = 0x00060000 # Amiga IFF / SVX8 / SV16 format. -const SF_FORMAT_NIST = 0x00070000 # Sphere NIST format. -const SF_FORMAT_VOC = 0x00080000 # VOC files. -const SF_FORMAT_IRCAM = 0x000A0000 # Berkeley/IRCAM/CARL -const SF_FORMAT_W64 = 0x000B0000 # Sonic Foundry's 64 bit RIFF/WAV -const SF_FORMAT_MAT4 = 0x000C0000 # Matlab (tm) V4.2 / GNU Octave 2.0 -const SF_FORMAT_MAT5 = 0x000D0000 # Matlab (tm) V5.0 / GNU Octave 2.1 -const SF_FORMAT_PVF = 0x000E0000 # Portable Voice Format -const SF_FORMAT_XI = 0x000F0000 # Fasttracker 2 Extended Instrument -const SF_FORMAT_HTK = 0x00100000 # HMM Tool Kit format -const SF_FORMAT_SDS = 0x00110000 # Midi Sample Dump Standard -const SF_FORMAT_AVR = 0x00120000 # Audio Visual Research -const SF_FORMAT_WAVEX = 0x00130000 # MS WAVE with WAVEFORMATEX -const SF_FORMAT_SD2 = 0x00160000 # Sound Designer 2 -const SF_FORMAT_FLAC = 0x00170000 # FLAC lossless file format -const SF_FORMAT_CAF = 0x00180000 # Core Audio File format -const SF_FORMAT_WVE = 0x00190000 # Psion WVE format -const SF_FORMAT_OGG = 0x00200000 # Xiph OGG container -const SF_FORMAT_MPC2K = 0x00210000 # Akai MPC 2000 sampler -const SF_FORMAT_RF64 = 0x00220000 # RF64 WAV file - -# SubFormats - -const SF_FORMAT_PCM_S8 = 0x00000001 # Signed 8 bit data -const SF_FORMAT_PCM_16 = 0x00000002 # Signed 16 bit data -const SF_FORMAT_PCM_24 = 0x00000003 # Signed 24 bit data -const SF_FORMAT_PCM_32 = 0x00000004 # Signed 32 bit data -const SF_FORMAT_PCM_U8 = 0x00000005 # Unsigned 8 bit data (WAV and RAW only) -const SF_FORMAT_FLOAT = 0x00000006 # 32 bit float data -const SF_FORMAT_DOUBLE = 0x00000007 # 64 bit float data -const SF_FORMAT_ULAW = 0x00000010 # U-Law encoded. -const SF_FORMAT_ALAW = 0x00000011 # A-Law encoded. -const SF_FORMAT_IMA_ADPCM = 0x00000012 # IMA ADPCM. -const SF_FORMAT_MS_ADPCM = 0x00000013 # Microsoft ADPCM. -const SF_FORMAT_GSM610 = 0x00000020 # GSM 6.10 encoding. -const SF_FORMAT_VOX_ADPCM = 0x00000021 # Oki Dialogic ADPCM encoding. -const SF_FORMAT_G721_32 = 0x00000030 # 32kbs G721 ADPCM encoding. -const SF_FORMAT_G723_24 = 0x00000031 # 24kbs G723 ADPCM encoding. -const SF_FORMAT_G723_40 = 0x00000032 # 40kbs G723 ADPCM encoding. -const SF_FORMAT_DWVW_12 = 0x00000040 # 12 bit Delta Width Variable Word encoding. -const SF_FORMAT_DWVW_16 = 0x00000041 # 16 bit Delta Width Variable Word encoding. -const SF_FORMAT_DWVW_24 = 0x00000042 # 24 bit Delta Width Variable Word encoding. -const SF_FORMAT_DWVW_N = 0x00000043 # N bit Delta Width Variable Word encoding. -const SF_FORMAT_DPCM_8 = 0x00000050 # 8 bit differential PCM (XI only) -const SF_FORMAT_DPCM_16 = 0x00000051 # 16 bit differential PCM (XI only) -const SF_FORMAT_VORBIS = 0x00000060 # Xiph Vorbis encoding. - -# Library flags - -# const SF_SEEK_SET = 0 -# const SF_SEEK_CUR = 1 -# const SF_SEEK_END = 2 - -const SFM_READ = Int32(0x10) -const SFM_WRITE = Int32(0x20) - -const SF_SEEK_SET = Int32(0) -const SF_SEEK_CUR = Int32(1) -const SF_SEEK_END = Int32(2) - formatcode(::Type{format"WAV"}) = SF_FORMAT_WAV formatcode(::Type{format"FLAC"}) = SF_FORMAT_FLAC formatcode(::Type{format"OGG"}) = SF_FORMAT_OGG @@ -89,68 +9,72 @@ subformatcode(::Type{Float64}) = SF_FORMAT_DOUBLE """Take a LibSndFile format code and return a suitable sample type""" function fmt_to_type(fmt) - mapping = Dict{UInt32, Type}( - SF_FORMAT_PCM_S8 => PCM16Sample, - SF_FORMAT_PCM_U8 => PCM16Sample, - SF_FORMAT_PCM_16 => PCM16Sample, - SF_FORMAT_PCM_24 => PCM32Sample, - SF_FORMAT_PCM_32 => PCM32Sample, - SF_FORMAT_FLOAT => Float32, - SF_FORMAT_DOUBLE => Float64, - SF_FORMAT_VORBIS => Float32, - ) - - masked = fmt & SF_FORMAT_SUBMASK - masked in keys(mapping) || error("Format code $masked not recognized by LibSndFile.jl") - - mapping[masked] + mapping = Dict{UInt32, Type}( + SF_FORMAT_PCM_S8 => PCM16Sample, + SF_FORMAT_PCM_U8 => PCM16Sample, + SF_FORMAT_PCM_16 => PCM16Sample, + SF_FORMAT_PCM_24 => PCM32Sample, + SF_FORMAT_PCM_32 => PCM32Sample, + SF_FORMAT_FLOAT => Float32, + SF_FORMAT_DOUBLE => Float64, + SF_FORMAT_VORBIS => Float32, + ) + + masked = fmt & SF_FORMAT_SUBMASK + masked in keys(mapping) || error("Format code $masked not recognized by LibSndFile.jl") + + mapping[masked] end -const sf_count_t = Int64 - mutable struct SF_INFO - frames::sf_count_t - samplerate::Int32 - channels::Int32 - format::Int32 - sections::Int32 - seekable::Int32 + frames::sf_count_t + samplerate::Int32 + channels::Int32 + format::Int32 + sections::Int32 + seekable::Int32 end SF_INFO() = SF_INFO(0, 0, 0, 0, 0, 0) function sf_open(fname::String, mode, sfinfo) + if Sys.iswindows() + filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, + (Cwstring, Int32, Ref{SF_INFO}), + fname, mode, sfinfo) + else filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, (Cstring, Int32, Ref{SF_INFO}), fname, mode, sfinfo) + end - if filePtr == C_NULL - error("LibSndFile.jl error while opening $fname: ", sf_strerror(C_NULL)) - end + if filePtr == C_NULL + error("LibSndFile.jl error while opening $fname: ", sf_strerror(C_NULL)) + end - filePtr + filePtr end # internals to get the virtual IO interface working include("virtualio.jl") function sf_open(io::T, mode, sfinfo) where T <: IO - virtio = SF_VIRTUAL_IO(T) - filePtr = ccall((:sf_open_virtual, libsndfile), Ptr{Cvoid}, - (Ref{SF_VIRTUAL_IO}, Int32, Ref{SF_INFO}, Ptr{T}), - virtio, mode, sfinfo, pointer_from_objref(io)) - if filePtr == C_NULL - error("LibSndFile.jl error while opening stream: ", sf_strerror(C_NULL)) - end - - filePtr + virtio = SF_VIRTUAL_IO(T) + filePtr = ccall((:sf_open_virtual, libsndfile), Ptr{Cvoid}, + (Ref{SF_VIRTUAL_IO}, Int32, Ref{SF_INFO}, Ptr{T}), + virtio, mode, sfinfo, pointer_from_objref(io)) + if filePtr == C_NULL + error("LibSndFile.jl error while opening stream: ", sf_strerror(C_NULL)) + end + + filePtr end function sf_close(filePtr) - err = ccall((:sf_close, libsndfile), Int32, (Ptr{Cvoid},), filePtr) - if err != 0 - error("LibSndFile.jl error: Failed to close file: ", sf_strerror(filePtr)) - end + err = ccall((:sf_close, libsndfile), Int32, (Ptr{Cvoid},), filePtr) + if err != 0 + error("LibSndFile.jl error: Failed to close file: ", sf_strerror(filePtr)) + end end """ @@ -160,24 +84,24 @@ of frames into the given array. Returns the number of frames read. function sf_readf end sf_readf(filePtr, dest::Array{T}, nframes) where T <: Union{Int16, PCM16Sample} = - ccall((:sf_readf_short, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{T}, Int64), - filePtr, dest, nframes) +ccall((:sf_readf_short, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{T}, Int64), + filePtr, dest, nframes) sf_readf(filePtr, dest::Array{T}, nframes) where T <: Union{Int32, PCM32Sample} = - ccall((:sf_readf_int, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{T}, Int64), - filePtr, dest, nframes) +ccall((:sf_readf_int, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{T}, Int64), + filePtr, dest, nframes) sf_readf(filePtr, dest::Array{Float32}, nframes) = - ccall((:sf_readf_float, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{Float32}, Int64), - filePtr, dest, nframes) +ccall((:sf_readf_float, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{Float32}, Int64), + filePtr, dest, nframes) sf_readf(filePtr, dest::Array{Float64}, nframes) = - ccall((:sf_readf_double, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{Float64}, Int64), - filePtr, dest, nframes) +ccall((:sf_readf_double, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{Float64}, Int64), + filePtr, dest, nframes) """ Wrappers for the family of sf_writef_* functions, which write the given number @@ -186,34 +110,34 @@ of frames in the source array to the file. Returns the number of frames written. function sf_writef end sf_writef(filePtr, src::Array{T}, nframes) where T <: Union{Int16, PCM16Sample} = - ccall((:sf_writef_short, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{T}, Int64), - filePtr, src, nframes) +ccall((:sf_writef_short, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{T}, Int64), + filePtr, src, nframes) sf_writef(filePtr, src::Array{T}, nframes) where T <: Union{Int32, PCM32Sample} = - ccall((:sf_writef_int, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{T}, Int64), - filePtr, src, nframes) +ccall((:sf_writef_int, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{T}, Int64), + filePtr, src, nframes) sf_writef(filePtr, src::Array{Float32}, nframes) = - ccall((:sf_writef_float, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{Float32}, Int64), - filePtr, src, nframes) +ccall((:sf_writef_float, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{Float32}, Int64), + filePtr, src, nframes) sf_writef(filePtr, src::Array{Float64}, nframes) = - ccall((:sf_writef_double, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{Float64}, Int64), - filePtr, src, nframes) +ccall((:sf_writef_double, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{Float64}, Int64), + filePtr, src, nframes) function sf_strerror(filePtr) - errmsg = ccall((:sf_strerror, libsndfile), Ptr{UInt8}, (Ptr{Cvoid},), filePtr) - unsafe_string(errmsg) + errmsg = ccall((:sf_strerror, libsndfile), Ptr{UInt8}, (Ptr{Cvoid},), filePtr) + unsafe_string(errmsg) end sf_seek(filePtr, frames::sf_count_t, whence::Integer) = - ccall((:sf_seek, libsndfile), Int64, - (Ptr{Cvoid}, Int64, Int32), - filePtr, frames, whence) +ccall((:sf_seek, libsndfile), Int64, + (Ptr{Cvoid}, Int64, Int32), + filePtr, frames, whence) function version() SFC_GET_LIB_VERSION = 0x1000 diff --git a/test/fileio.jl b/test/fileio.jl index 97d4ebb..1ea45ce 100644 --- a/test/fileio.jl +++ b/test/fileio.jl @@ -8,6 +8,6 @@ for ext in extensions end # testing with unicode -FileIO.save("β.flac", testbuf) -FileIO.load("β.flac") -rm("β.flac") +file = joinpath(tempdir(),"α.flac") +FileIO.save(file, testbuf) +FileIO.load(file) From 54c17da9ddc99b2aa2135d7a7737ca2fba997d5a Mon Sep 17 00:00:00 2001 From: nantonel Date: Wed, 27 Oct 2021 11:29:55 +0200 Subject: [PATCH 12/22] back, rm nightly for the moment --- .github/workflows/Tests.yml | 1 - src/libsndfile_h.jl | 12 +++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index f21b7bc..7eae36b 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -19,7 +19,6 @@ jobs: version: - '1.6' - '1' - - 'nightly' os: - ubuntu-latest - macOS-latest diff --git a/src/libsndfile_h.jl b/src/libsndfile_h.jl index 8bcc9b8..479cf4d 100644 --- a/src/libsndfile_h.jl +++ b/src/libsndfile_h.jl @@ -38,15 +38,9 @@ end SF_INFO() = SF_INFO(0, 0, 0, 0, 0, 0) function sf_open(fname::String, mode, sfinfo) - if Sys.iswindows() - filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, - (Cwstring, Int32, Ref{SF_INFO}), - fname, mode, sfinfo) - else - filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, - (Cstring, Int32, Ref{SF_INFO}), - fname, mode, sfinfo) - end + filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, + (Cstring, Int32, Ref{SF_INFO}), + fname, mode, sfinfo) if filePtr == C_NULL error("LibSndFile.jl error while opening $fname: ", sf_strerror(C_NULL)) From 13fa9c58710960e56fbe1700384908115217ad50 Mon Sep 17 00:00:00 2001 From: nantonel Date: Wed, 27 Oct 2021 12:23:16 +0200 Subject: [PATCH 13/22] trying with Cwstring --- src/libsndfile_h.jl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libsndfile_h.jl b/src/libsndfile_h.jl index 479cf4d..d6ab703 100644 --- a/src/libsndfile_h.jl +++ b/src/libsndfile_h.jl @@ -38,9 +38,16 @@ end SF_INFO() = SF_INFO(0, 0, 0, 0, 0, 0) function sf_open(fname::String, mode, sfinfo) - filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, - (Cstring, Int32, Ref{SF_INFO}), - fname, mode, sfinfo) + if Sys.iswindows() + ptr = pointer(transcode(Cwchar_t,fname)) + filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, + (Cwstring, Int32, Ref{SF_INFO}), + Cwstring(ptr), mode, sfinfo) + else + filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, + (Cstring, Int32, Ref{SF_INFO}), + fname, mode, sfinfo) + end if filePtr == C_NULL error("LibSndFile.jl error while opening $fname: ", sf_strerror(C_NULL)) From f82da81beb0ea19e8ee163cd4c4a7a4c47ea907d Mon Sep 17 00:00:00 2001 From: nantonel Date: Wed, 27 Oct 2021 12:35:12 +0200 Subject: [PATCH 14/22] using sf_wchar_open --- src/libsndfile_h.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsndfile_h.jl b/src/libsndfile_h.jl index d6ab703..817587f 100644 --- a/src/libsndfile_h.jl +++ b/src/libsndfile_h.jl @@ -40,13 +40,13 @@ SF_INFO() = SF_INFO(0, 0, 0, 0, 0, 0) function sf_open(fname::String, mode, sfinfo) if Sys.iswindows() ptr = pointer(transcode(Cwchar_t,fname)) - filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, + filePtr = ccall((:sf_wchar_open, libsndfile), Ptr{Cvoid}, (Cwstring, Int32, Ref{SF_INFO}), - Cwstring(ptr), mode, sfinfo) + Cwstring(ptr), mode, sfinfo) else filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, (Cstring, Int32, Ref{SF_INFO}), - fname, mode, sfinfo) + fname, mode, sfinfo) end if filePtr == C_NULL From 465bf92b711d22bf3fcddcd9a2564c4ec9f2b88a Mon Sep 17 00:00:00 2001 From: nantonel Date: Wed, 27 Oct 2021 13:55:27 +0200 Subject: [PATCH 15/22] using sf_wchar_open 2 --- test/utils.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/utils.jl b/test/utils.jl index 14a8f37..c2e48b4 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -11,12 +11,12 @@ end # reference file generated with Audacity. Careful to turn dithering off # on export for deterministic output! -reference_wav = "data/440left_880right_0.5amp.wav" -reference_wav_float = "data/440left_880right_0.5amp_float.wav" -reference_wav_double = "data/440left_880right_0.5amp_double.wav" -reference_wav_pcm24 = "data/440left_880right_0.5amp_pcm24.wav" -reference_ogg = "data/440left_880right_0.5amp.ogg" -reference_flac = "data/440left_880right_0.5amp.flac" +reference_wav = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp.wav") +reference_wav_float = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp_float.wav") +reference_wav_double = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp_double.wav") +reference_wav_pcm24 = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp_pcm24.wav") +reference_ogg = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp.ogg") +reference_flac = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp.flac") reference_buf = gen_reference(srate) # define some loaders and savers that bypass FileIO's detection machinery, of From 7e0c9f77bdd62f73bdfd38dc27cd19e67a528de2 Mon Sep 17 00:00:00 2001 From: nantonel Date: Wed, 27 Oct 2021 14:25:08 +0200 Subject: [PATCH 16/22] using sf_wchar_open 3 --- test/utils.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/utils.jl b/test/utils.jl index c2e48b4..cecdc8f 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -11,12 +11,12 @@ end # reference file generated with Audacity. Careful to turn dithering off # on export for deterministic output! -reference_wav = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp.wav") -reference_wav_float = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp_float.wav") -reference_wav_double = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp_double.wav") -reference_wav_pcm24 = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp_pcm24.wav") -reference_ogg = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp.ogg") -reference_flac = joinpath(dirname(@__FILE__), "data/440left_880right_0.5amp.flac") +reference_wav = joinpath(dirname(@__FILE__), "data", "440left_880right_0.5amp.wav") +reference_wav_float = joinpath(dirname(@__FILE__), "data", "440left_880right_0.5amp_float.wav") +reference_wav_double = joinpath(dirname(@__FILE__), "data","440left_880right_0.5amp_double.wav") +reference_wav_pcm24 = joinpath(dirname(@__FILE__), "data", "440left_880right_0.5amp_pcm24.wav") +reference_ogg = joinpath(dirname(@__FILE__), "data", "440left_880right_0.5amp.ogg") +reference_flac = joinpath(dirname(@__FILE__), "data", "440left_880right_0.5amp.flac") reference_buf = gen_reference(srate) # define some loaders and savers that bypass FileIO's detection machinery, of From 2416ee895013a7d244142a87f15a88cef5506a6b Mon Sep 17 00:00:00 2001 From: nantonel Date: Wed, 27 Oct 2021 14:56:55 +0200 Subject: [PATCH 17/22] using sf_wchar_open 4 --- src/libsndfile_h.jl | 2 +- test/utils.jl | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libsndfile_h.jl b/src/libsndfile_h.jl index 817587f..5781895 100644 --- a/src/libsndfile_h.jl +++ b/src/libsndfile_h.jl @@ -39,7 +39,7 @@ SF_INFO() = SF_INFO(0, 0, 0, 0, 0, 0) function sf_open(fname::String, mode, sfinfo) if Sys.iswindows() - ptr = pointer(transcode(Cwchar_t,fname)) + ptr = pointer(transcode(UInt8,fname)) filePtr = ccall((:sf_wchar_open, libsndfile), Ptr{Cvoid}, (Cwstring, Int32, Ref{SF_INFO}), Cwstring(ptr), mode, sfinfo) diff --git a/test/utils.jl b/test/utils.jl index cecdc8f..7687f1f 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -11,12 +11,12 @@ end # reference file generated with Audacity. Careful to turn dithering off # on export for deterministic output! -reference_wav = joinpath(dirname(@__FILE__), "data", "440left_880right_0.5amp.wav") -reference_wav_float = joinpath(dirname(@__FILE__), "data", "440left_880right_0.5amp_float.wav") -reference_wav_double = joinpath(dirname(@__FILE__), "data","440left_880right_0.5amp_double.wav") -reference_wav_pcm24 = joinpath(dirname(@__FILE__), "data", "440left_880right_0.5amp_pcm24.wav") -reference_ogg = joinpath(dirname(@__FILE__), "data", "440left_880right_0.5amp.ogg") -reference_flac = joinpath(dirname(@__FILE__), "data", "440left_880right_0.5amp.flac") +reference_wav = joinpath("data", "440left_880right_0.5amp.wav") +reference_wav_float = joinpath("data", "440left_880right_0.5amp_float.wav") +reference_wav_double = joinpath("data","440left_880right_0.5amp_double.wav") +reference_wav_pcm24 = joinpath("data", "440left_880right_0.5amp_pcm24.wav") +reference_ogg = joinpath("data", "440left_880right_0.5amp.ogg") +reference_flac = joinpath("data", "440left_880right_0.5amp.flac") reference_buf = gen_reference(srate) # define some loaders and savers that bypass FileIO's detection machinery, of From 01a0c1bd8f456d0286646965e09b9971df2f2c9d Mon Sep 17 00:00:00 2001 From: nantonel Date: Wed, 27 Oct 2021 15:25:29 +0200 Subject: [PATCH 18/22] giving up on windows --- src/libsndfile_h.jl | 20 +++++++++----------- test/fileio.jl | 10 ++++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libsndfile_h.jl b/src/libsndfile_h.jl index 5781895..35a847b 100644 --- a/src/libsndfile_h.jl +++ b/src/libsndfile_h.jl @@ -38,17 +38,15 @@ end SF_INFO() = SF_INFO(0, 0, 0, 0, 0, 0) function sf_open(fname::String, mode, sfinfo) - if Sys.iswindows() - ptr = pointer(transcode(UInt8,fname)) - filePtr = ccall((:sf_wchar_open, libsndfile), Ptr{Cvoid}, - (Cwstring, Int32, Ref{SF_INFO}), - Cwstring(ptr), mode, sfinfo) - else - filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, - (Cstring, Int32, Ref{SF_INFO}), - fname, mode, sfinfo) - end - + ## this fixes #34 however is unstable and breaks test randomly + ## it's difficult to debug it without a Windows machine + #ptr = pointer(transcode(Cwchar_t,fname)) + #filePtr = ccall((:sf_wchar_open, libsndfile), Ptr{Cvoid}, + # (Cwstring, Int32, Ref{SF_INFO}), + # Cwstring(ptr), mode, sfinfo) + filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, + (Cstring, Int32, Ref{SF_INFO}), + fname, mode, sfinfo) if filePtr == C_NULL error("LibSndFile.jl error while opening $fname: ", sf_strerror(C_NULL)) end diff --git a/test/fileio.jl b/test/fileio.jl index 1ea45ce..fc99e35 100644 --- a/test/fileio.jl +++ b/test/fileio.jl @@ -7,7 +7,9 @@ for ext in extensions @test buf isa SampleBuf end -# testing with unicode -file = joinpath(tempdir(),"α.flac") -FileIO.save(file, testbuf) -FileIO.load(file) +if !Sys.iswindows() + # testing with unicode + file = joinpath(tempdir(),"α.flac") + FileIO.save(file, testbuf) + FileIO.load(file) +end From 654219d2ddf2ea0f6ef5db56bbb04c171da5f568 Mon Sep 17 00:00:00 2001 From: nantonel Date: Wed, 10 Nov 2021 10:07:24 +0100 Subject: [PATCH 19/22] reorganizing --- src/LibSndFile.jl | 2 ++ src/lengthIO.jl | 3 +- src/libsndfile_h.jl | 84 +-------------------------------------------- src/readwrite.jl | 52 ++++++++++++++++++++++++++++ src/utils.jl | 14 ++++++++ src/virtualio.jl | 33 ++++++++++++------ test/fileio.jl | 2 +- 7 files changed, 94 insertions(+), 96 deletions(-) create mode 100644 src/utils.jl diff --git a/src/LibSndFile.jl b/src/LibSndFile.jl index 3992878..4ef92ef 100644 --- a/src/LibSndFile.jl +++ b/src/LibSndFile.jl @@ -13,7 +13,9 @@ using libsndfile_jll: libsndfile const supported_formats = (format"WAV", format"FLAC", format"OGG") include("constants.jl") +include("utils.jl") include("libsndfile_h.jl") +include("virtualio.jl") include("lengthIO.jl") include("sourcesink.jl") include("loadsave.jl") diff --git a/src/lengthIO.jl b/src/lengthIO.jl index 585d101..62842fa 100644 --- a/src/lengthIO.jl +++ b/src/lengthIO.jl @@ -4,10 +4,9 @@ mutable struct LengthIO{T<:IO} <: IO io::T length::Int64 + LengthIO(io::T,length::Integer) where {T} = new{T}(io, Int64(length)) end -LengthIO(io, l::Integer) = LengthIO(io, Int64(l)) - Base.length(io::LengthIO) = io.length for f in (:read, :read!, :write, :readbytes!, :unsafe_read, :unsafe_write, diff --git a/src/libsndfile_h.jl b/src/libsndfile_h.jl index 35a847b..4dd1081 100644 --- a/src/libsndfile_h.jl +++ b/src/libsndfile_h.jl @@ -43,7 +43,7 @@ function sf_open(fname::String, mode, sfinfo) #ptr = pointer(transcode(Cwchar_t,fname)) #filePtr = ccall((:sf_wchar_open, libsndfile), Ptr{Cvoid}, # (Cwstring, Int32, Ref{SF_INFO}), - # Cwstring(ptr), mode, sfinfo) + # Cwstring(ptr), mode, sfinfo filePtr = ccall((:sf_open, libsndfile), Ptr{Cvoid}, (Cstring, Int32, Ref{SF_INFO}), fname, mode, sfinfo) @@ -54,21 +54,6 @@ function sf_open(fname::String, mode, sfinfo) filePtr end -# internals to get the virtual IO interface working -include("virtualio.jl") - -function sf_open(io::T, mode, sfinfo) where T <: IO - virtio = SF_VIRTUAL_IO(T) - filePtr = ccall((:sf_open_virtual, libsndfile), Ptr{Cvoid}, - (Ref{SF_VIRTUAL_IO}, Int32, Ref{SF_INFO}, Ptr{T}), - virtio, mode, sfinfo, pointer_from_objref(io)) - if filePtr == C_NULL - error("LibSndFile.jl error while opening stream: ", sf_strerror(C_NULL)) - end - - filePtr -end - function sf_close(filePtr) err = ccall((:sf_close, libsndfile), Int32, (Ptr{Cvoid},), filePtr) if err != 0 @@ -76,74 +61,7 @@ function sf_close(filePtr) end end -""" -Wrappers for the family of sf_readf_* functions, which read the given number -of frames into the given array. Returns the number of frames read. -""" -function sf_readf end - -sf_readf(filePtr, dest::Array{T}, nframes) where T <: Union{Int16, PCM16Sample} = -ccall((:sf_readf_short, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{T}, Int64), - filePtr, dest, nframes) - -sf_readf(filePtr, dest::Array{T}, nframes) where T <: Union{Int32, PCM32Sample} = -ccall((:sf_readf_int, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{T}, Int64), - filePtr, dest, nframes) - -sf_readf(filePtr, dest::Array{Float32}, nframes) = -ccall((:sf_readf_float, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{Float32}, Int64), - filePtr, dest, nframes) - -sf_readf(filePtr, dest::Array{Float64}, nframes) = -ccall((:sf_readf_double, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{Float64}, Int64), - filePtr, dest, nframes) - -""" -Wrappers for the family of sf_writef_* functions, which write the given number -of frames in the source array to the file. Returns the number of frames written. -""" -function sf_writef end - -sf_writef(filePtr, src::Array{T}, nframes) where T <: Union{Int16, PCM16Sample} = -ccall((:sf_writef_short, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{T}, Int64), - filePtr, src, nframes) - -sf_writef(filePtr, src::Array{T}, nframes) where T <: Union{Int32, PCM32Sample} = -ccall((:sf_writef_int, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{T}, Int64), - filePtr, src, nframes) - -sf_writef(filePtr, src::Array{Float32}, nframes) = -ccall((:sf_writef_float, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{Float32}, Int64), - filePtr, src, nframes) - -sf_writef(filePtr, src::Array{Float64}, nframes) = -ccall((:sf_writef_double, libsndfile), Int64, - (Ptr{Cvoid}, Ptr{Float64}, Int64), - filePtr, src, nframes) - -function sf_strerror(filePtr) - errmsg = ccall((:sf_strerror, libsndfile), Ptr{UInt8}, (Ptr{Cvoid},), filePtr) - unsafe_string(errmsg) -end - sf_seek(filePtr, frames::sf_count_t, whence::Integer) = ccall((:sf_seek, libsndfile), Int64, (Ptr{Cvoid}, Int64, Int32), filePtr, frames, whence) - -function version() - SFC_GET_LIB_VERSION = 0x1000 - buf = zeros(Cchar,256) - v = Cstring(pointer(buf)) - ccall((:sf_command, libsndfile), Int64, - (Ptr{Cvoid}, UInt, Cstring, UInt), - C_NULL, SFC_GET_LIB_VERSION, v, sizeof(buf)) - unsafe_string(v) -end diff --git a/src/readwrite.jl b/src/readwrite.jl index 95f5b1f..2ed092f 100644 --- a/src/readwrite.jl +++ b/src/readwrite.jl @@ -1,3 +1,29 @@ +""" +Wrappers for the family of sf_readf_* functions, which read the given number +of frames into the given array. Returns the number of frames read. +""" +function sf_readf end + +sf_readf(filePtr, dest::Array{T}, nframes) where T <: Union{Int16, PCM16Sample} = +ccall((:sf_readf_short, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{T}, Int64), + filePtr, dest, nframes) + +sf_readf(filePtr, dest::Array{T}, nframes) where T <: Union{Int32, PCM32Sample} = +ccall((:sf_readf_int, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{T}, Int64), + filePtr, dest, nframes) + +sf_readf(filePtr, dest::Array{Float32}, nframes) = +ccall((:sf_readf_float, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{Float32}, Int64), + filePtr, dest, nframes) + +sf_readf(filePtr, dest::Array{Float64}, nframes) = +ccall((:sf_readf_double, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{Float64}, Int64), + filePtr, dest, nframes) + function SampledSignals.unsafe_read!(source::SndFileSource, buf::Array, frameoffset, framecount) total = min(framecount, nframes(source) - source.pos + 1) nread = 0 @@ -20,6 +46,32 @@ function SampledSignals.unsafe_read!(source::SndFileSource, buf::Array, frameoff nread end +""" +Wrappers for the family of sf_writef_* functions, which write the given number +of frames in the source array to the file. Returns the number of frames written. +""" +function sf_writef end + +sf_writef(filePtr, src::Array{T}, nframes) where T <: Union{Int16, PCM16Sample} = +ccall((:sf_writef_short, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{T}, Int64), + filePtr, src, nframes) + +sf_writef(filePtr, src::Array{T}, nframes) where T <: Union{Int32, PCM32Sample} = +ccall((:sf_writef_int, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{T}, Int64), + filePtr, src, nframes) + +sf_writef(filePtr, src::Array{Float32}, nframes) = +ccall((:sf_writef_float, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{Float32}, Int64), + filePtr, src, nframes) + +sf_writef(filePtr, src::Array{Float64}, nframes) = +ccall((:sf_writef_double, libsndfile), Int64, + (Ptr{Cvoid}, Ptr{Float64}, Int64), + filePtr, src, nframes) + # returns the number of samples written function SampledSignals.unsafe_write(sink::SndFileSink, buf::Array, frameoffset, framecount) nwritten = 0 diff --git a/src/utils.jl b/src/utils.jl new file mode 100644 index 0000000..d557831 --- /dev/null +++ b/src/utils.jl @@ -0,0 +1,14 @@ +function version() + SFC_GET_LIB_VERSION = 0x1000 + buf = zeros(Cchar,256) + v = Cstring(pointer(buf)) + ccall((:sf_command, libsndfile), Int64, + (Ptr{Cvoid}, UInt, Cstring, UInt), + C_NULL, SFC_GET_LIB_VERSION, v, sizeof(buf)) + unsafe_string(v) +end + +function sf_strerror(filePtr) + errmsg = ccall((:sf_strerror, libsndfile), Ptr{UInt8}, (Ptr{Cvoid},), filePtr) + unsafe_string(errmsg) +end diff --git a/src/virtualio.jl b/src/virtualio.jl index 2d62336..7d9dcb9 100644 --- a/src/virtualio.jl +++ b/src/virtualio.jl @@ -1,3 +1,13 @@ +# this contains a collection of function pointers that libsndfile uses to +# read and write data in a buffer +struct SF_VIRTUAL_IO + get_filelen::Ptr{Cvoid} + seek::Ptr{Cvoid} + read::Ptr{Cvoid} + write::Ptr{Cvoid} + tell::Ptr{Cvoid} +end + # libsndfile has the ability to define a virtual IO interface where you provide # callbacks for read, write, etc, and whenever the library wants to perform # these operations it calls your functions. See http://www.mega-nerd.com/libsndfile/api.html#open_virtual @@ -46,21 +56,12 @@ function virtual_write(src, count, userdata)::sf_count_t unsafe_write(io, src, count) count end + function virtual_tell(userdata)::sf_count_t io = unsafe_pointer_to_objref(userdata) position(io) end -# this contains a collection of function pointers that libsndfile uses to -# read and write data in a buffer -struct SF_VIRTUAL_IO - get_filelen::Ptr{Cvoid} - seek::Ptr{Cvoid} - read::Ptr{Cvoid} - write::Ptr{Cvoid} - tell::Ptr{Cvoid} -end - # make a struct of function pointers where the userdata argument is a pointer of # the specified type function SF_VIRTUAL_IO(::Type{T}) where T<:IO @@ -72,3 +73,15 @@ function SF_VIRTUAL_IO(::Type{T}) where T<:IO @cfunction(virtual_tell, sf_count_t, (Ptr{T}, )) ) end + +function sf_open(io::T, mode, sfinfo) where T <: IO + virtio = SF_VIRTUAL_IO(T) + filePtr = ccall((:sf_open_virtual, libsndfile), Ptr{Cvoid}, + (Ref{SF_VIRTUAL_IO}, Int32, Ref{SF_INFO}, Ptr{T}), + virtio, mode, sfinfo, pointer_from_objref(io)) + if filePtr == C_NULL + error("LibSndFile.jl error while opening stream: ", sf_strerror(C_NULL)) + end + + filePtr +end diff --git a/test/fileio.jl b/test/fileio.jl index fc99e35..0b1663c 100644 --- a/test/fileio.jl +++ b/test/fileio.jl @@ -1,6 +1,6 @@ arr = map(PCM16Sample, rand(100, 2) .- 0.5) testbuf = SampleBuf(arr, srate) -for ext in extensions +for ext in extensions fname = string(tempname(), ext) FileIO.save(fname, testbuf) buf = FileIO.load(fname) From b31bd740f441e04959d47311d2c9bdcdcc3cd65b Mon Sep 17 00:00:00 2001 From: nantonel Date: Sat, 22 Jan 2022 10:35:07 -0500 Subject: [PATCH 20/22] added 1.7 tests --- .github/workflows/Tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 7eae36b..3ee2bd7 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -17,6 +17,7 @@ jobs: fail-fast: false matrix: version: + - '1.7' - '1.6' - '1' os: From 9feb2f1fcc1dec9153ceb09e33c0f5207cdecf33 Mon Sep 17 00:00:00 2001 From: nantonel Date: Sat, 22 Jan 2022 10:48:04 -0500 Subject: [PATCH 21/22] checking out windows error in #51 --- .github/workflows/Tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 3ee2bd7..c07898d 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -17,8 +17,8 @@ jobs: fail-fast: false matrix: version: - - '1.7' - - '1.6' + - '1.7.0' + - '1.6.2' - '1' os: - ubuntu-latest From 7a4328a0a42a2db62e8471623ed2109222affde5 Mon Sep 17 00:00:00 2001 From: nantonel Date: Sat, 22 Jan 2022 10:58:30 -0500 Subject: [PATCH 22/22] backtrack --- .github/workflows/Tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index c07898d..3ee2bd7 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -17,8 +17,8 @@ jobs: fail-fast: false matrix: version: - - '1.7.0' - - '1.6.2' + - '1.7' + - '1.6' - '1' os: - ubuntu-latest