]> OzVa Git service - rust_fft/commitdiff
Main structure and functions setup
authorwill <greenwoodw50@gmail.com>
Sun, 29 Sep 2024 01:18:46 +0000 (02:18 +0100)
committerwill <greenwoodw50@gmail.com>
Sun, 29 Sep 2024 01:18:46 +0000 (02:18 +0100)
Copied over from python

Cargo.lock
Cargo.toml
src/main.rs

index 86e6c962a4b339f28a80528345d9d3514e6982ff..f20bd0a29627832ff03abc4aa66f7bb89a6367be 100644 (file)
@@ -66,28 +66,6 @@ version = "0.2.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
 
-[[package]]
-name = "alsa"
-version = "0.9.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed7572b7ba83a31e20d1b48970ee402d2e3e0537dcfe0a3ff4d6eb7508617d43"
-dependencies = [
- "alsa-sys",
- "bitflags 2.6.0",
- "cfg-if",
- "libc",
-]
-
-[[package]]
-name = "alsa-sys"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527"
-dependencies = [
- "libc",
- "pkg-config",
-]
-
 [[package]]
 name = "android-activity"
 version = "0.4.3"
@@ -100,9 +78,9 @@ dependencies = [
  "jni-sys",
  "libc",
  "log",
- "ndk 0.7.0",
+ "ndk",
  "ndk-context",
- "ndk-sys 0.4.1+23.1.7779620",
+ "ndk-sys",
  "num_enum 0.6.1",
 ]
 
@@ -148,19 +126,6 @@ version = "1.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
 
-[[package]]
-name = "awedio"
-version = "0.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7a43f992e4c8600bde693d0f0206c55d0c2c3999c8bd9fb5c486e4847c241aa8"
-dependencies = [
- "cpal",
- "log",
- "qoaudio",
- "symphonia",
- "tokio",
-]
-
 [[package]]
 name = "backtrace"
 version = "0.3.74"
@@ -178,22 +143,25 @@ dependencies = [
 
 [[package]]
 name = "bindgen"
-version = "0.69.4"
+version = "0.65.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
+checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5"
 dependencies = [
- "bitflags 2.6.0",
+ "bitflags 1.3.2",
  "cexpr",
  "clang-sys",
- "itertools",
  "lazy_static",
  "lazycell",
+ "log",
+ "peeking_take_while",
+ "prettyplease",
  "proc-macro2",
  "quote",
  "regex",
  "rustc-hash",
  "shlex",
  "syn 2.0.77",
+ "which",
 ]
 
 [[package]]
@@ -266,12 +234,6 @@ version = "1.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
 
-[[package]]
-name = "bytes"
-version = "1.7.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
-
 [[package]]
 name = "calloop"
 version = "0.10.6"
@@ -297,12 +259,6 @@ dependencies = [
  "shlex",
 ]
 
-[[package]]
-name = "cesu8"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
-
 [[package]]
 name = "cexpr"
 version = "0.6.0"
@@ -335,12 +291,6 @@ dependencies = [
  "libloading 0.8.5",
 ]
 
-[[package]]
-name = "claxon"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4bfbf56724aa9eca8afa4fcfadeb479e722935bb2a0900c2d37e0cc477af0688"
-
 [[package]]
 name = "codespan-reporting"
 version = "0.11.1"
@@ -357,16 +307,6 @@ version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "bf43edc576402991846b093a7ca18a3477e0ef9c588cde84964b5d3e43016642"
 
-[[package]]
-name = "combine"
-version = "4.6.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd"
-dependencies = [
- "bytes",
- "memchr",
-]
-
 [[package]]
 name = "core-foundation"
 version = "0.9.4"
@@ -407,49 +347,6 @@ dependencies = [
  "libc",
 ]
 
-[[package]]
-name = "coreaudio-rs"
-version = "0.11.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace"
-dependencies = [
- "bitflags 1.3.2",
- "core-foundation-sys",
- "coreaudio-sys",
-]
-
-[[package]]
-name = "coreaudio-sys"
-version = "0.2.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f01585027057ff5f0a5bf276174ae4c1594a2c5bde93d5f46a016d76270f5a9"
-dependencies = [
- "bindgen",
-]
-
-[[package]]
-name = "cpal"
-version = "0.15.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779"
-dependencies = [
- "alsa",
- "core-foundation-sys",
- "coreaudio-rs",
- "dasp_sample",
- "jni",
- "js-sys",
- "libc",
- "mach2",
- "ndk 0.8.0",
- "ndk-context",
- "oboe",
- "wasm-bindgen",
- "wasm-bindgen-futures",
- "web-sys",
- "windows 0.54.0",
-]
-
 [[package]]
 name = "crc32fast"
 version = "1.4.2"
@@ -470,12 +367,6 @@ dependencies = [
  "winapi",
 ]
 
-[[package]]
-name = "dasp_sample"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
-
 [[package]]
 name = "dispatch"
 version = "0.2.0"
@@ -503,15 +394,6 @@ version = "1.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
 
-[[package]]
-name = "encoding_rs"
-version = "0.8.34"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"
-dependencies = [
- "cfg-if",
-]
-
 [[package]]
 name = "equivalent"
 version = "1.0.1"
@@ -519,10 +401,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
 
 [[package]]
-name = "extended"
-version = "0.1.0"
+name = "errno"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
+dependencies = [
+ "libc",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "fastrand"
+version = "2.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365"
+checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
 
 [[package]]
 name = "fdeflate"
@@ -709,6 +601,16 @@ dependencies = [
  "web-sys",
 ]
 
+[[package]]
+name = "gnuplot"
+version = "0.0.43"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ce70b22788c02857a6436b96744f9030dd89e17c8482ddf674523c0a1f8ab6c"
+dependencies = [
+ "byteorder",
+ "tempfile",
+]
+
 [[package]]
 name = "gpu-alloc"
 version = "0.6.0"
@@ -738,7 +640,7 @@ dependencies = [
  "log",
  "thiserror",
  "winapi",
- "windows 0.44.0",
+ "windows",
 ]
 
 [[package]]
@@ -798,6 +700,15 @@ version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
 
+[[package]]
+name = "home"
+version = "0.5.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
+dependencies = [
+ "windows-sys 0.52.0",
+]
+
 [[package]]
 name = "hound"
 version = "3.5.1"
@@ -836,31 +747,6 @@ dependencies = [
  "web-sys",
 ]
 
-[[package]]
-name = "itertools"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
-dependencies = [
- "either",
-]
-
-[[package]]
-name = "jni"
-version = "0.21.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97"
-dependencies = [
- "cesu8",
- "cfg-if",
- "combine",
- "jni-sys",
- "log",
- "thiserror",
- "walkdir",
- "windows-sys 0.45.0",
-]
-
 [[package]]
 name = "jni-sys"
 version = "0.3.0"
@@ -908,17 +794,6 @@ version = "1.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
 
-[[package]]
-name = "lewton"
-version = "0.10.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "777b48df9aaab155475a83a7df3070395ea1ac6902f5cd062b8f2b028075c030"
-dependencies = [
- "byteorder",
- "ogg",
- "tinyvec",
-]
-
 [[package]]
 name = "libc"
 version = "0.2.158"
@@ -956,6 +831,12 @@ dependencies = [
  "redox_syscall 0.4.1",
 ]
 
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
+
 [[package]]
 name = "lock_api"
 version = "0.4.12"
@@ -972,15 +853,6 @@ version = "0.4.22"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
 
-[[package]]
-name = "mach2"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709"
-dependencies = [
- "libc",
-]
-
 [[package]]
 name = "malloc_buf"
 version = "0.0.6"
@@ -1095,26 +967,12 @@ checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0"
 dependencies = [
  "bitflags 1.3.2",
  "jni-sys",
- "ndk-sys 0.4.1+23.1.7779620",
+ "ndk-sys",
  "num_enum 0.5.11",
  "raw-window-handle",
  "thiserror",
 ]
 
-[[package]]
-name = "ndk"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7"
-dependencies = [
- "bitflags 2.6.0",
- "jni-sys",
- "log",
- "ndk-sys 0.5.0+25.2.9519653",
- "num_enum 0.7.3",
- "thiserror",
-]
-
 [[package]]
 name = "ndk-context"
 version = "0.1.1"
@@ -1130,15 +988,6 @@ dependencies = [
  "jni-sys",
 ]
 
-[[package]]
-name = "ndk-sys"
-version = "0.5.0+25.2.9519653"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691"
-dependencies = [
- "jni-sys",
-]
-
 [[package]]
 name = "nix"
 version = "0.24.3"
@@ -1183,17 +1032,6 @@ dependencies = [
  "num-traits",
 ]
 
-[[package]]
-name = "num-derive"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.77",
-]
-
 [[package]]
 name = "num-integer"
 version = "0.1.46"
@@ -1230,22 +1068,13 @@ dependencies = [
  "num_enum_derive 0.6.1",
 ]
 
-[[package]]
-name = "num_enum"
-version = "0.7.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179"
-dependencies = [
- "num_enum_derive 0.7.3",
-]
-
 [[package]]
 name = "num_enum_derive"
 version = "0.5.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799"
 dependencies = [
- "proc-macro-crate 1.3.1",
+ "proc-macro-crate",
  "proc-macro2",
  "quote",
  "syn 1.0.109",
@@ -1257,19 +1086,7 @@ version = "0.6.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6"
 dependencies = [
- "proc-macro-crate 1.3.1",
- "proc-macro2",
- "quote",
- "syn 2.0.77",
-]
-
-[[package]]
-name = "num_enum_derive"
-version = "0.7.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
-dependencies = [
- "proc-macro-crate 3.2.0",
+ "proc-macro-crate",
  "proc-macro2",
  "quote",
  "syn 2.0.77",
@@ -1329,38 +1146,6 @@ dependencies = [
  "memchr",
 ]
 
-[[package]]
-name = "oboe"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb"
-dependencies = [
- "jni",
- "ndk 0.8.0",
- "ndk-context",
- "num-derive",
- "num-traits",
- "oboe-sys",
-]
-
-[[package]]
-name = "oboe-sys"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d"
-dependencies = [
- "cc",
-]
-
-[[package]]
-name = "ogg"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6951b4e8bf21c8193da321bcce9c9dd2e13c858fe078bf9054a288b419ae5d6e"
-dependencies = [
- "byteorder",
-]
-
 [[package]]
 name = "once_cell"
 version = "1.19.0"
@@ -1414,6 +1199,12 @@ version = "1.0.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
 
+[[package]]
+name = "peeking_take_while"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
+
 [[package]]
 name = "percent-encoding"
 version = "2.3.1"
@@ -1470,6 +1261,16 @@ dependencies = [
  "zerocopy",
 ]
 
+[[package]]
+name = "prettyplease"
+version = "0.2.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba"
+dependencies = [
+ "proc-macro2",
+ "syn 2.0.77",
+]
+
 [[package]]
 name = "primal-check"
 version = "0.3.4"
@@ -1486,16 +1287,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
 dependencies = [
  "once_cell",
- "toml_edit 0.19.15",
-]
-
-[[package]]
-name = "proc-macro-crate"
-version = "3.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b"
-dependencies = [
- "toml_edit 0.22.20",
+ "toml_edit",
 ]
 
 [[package]]
@@ -1513,12 +1305,6 @@ version = "1.0.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58"
 
-[[package]]
-name = "qoaudio"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bf46b47dc3906b2c2bc928a04398dd483e66e3d0cc56913355ba236ab9fa2441"
-
 [[package]]
 name = "quote"
 version = "1.0.37"
@@ -1632,31 +1418,16 @@ version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832"
 
-[[package]]
-name = "rodio"
-version = "0.19.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6006a627c1a38d37f3d3a85c6575418cfe34a5392d60a686d0071e1c8d427acb"
-dependencies = [
- "claxon",
- "cpal",
- "hound",
- "lewton",
- "symphonia",
- "thiserror",
-]
-
 [[package]]
 name = "rust_fft"
 version = "0.1.0"
 dependencies = [
- "awedio",
- "cpal",
+ "gnuplot",
  "hound",
  "rand",
- "rodio",
  "rustfft",
  "show-image",
+ "v4l",
 ]
 
 [[package]]
@@ -1696,12 +1467,16 @@ dependencies = [
 ]
 
 [[package]]
-name = "same-file"
-version = "1.0.6"
+name = "rustix"
+version = "0.38.37"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
+checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
 dependencies = [
- "winapi-util",
+ "bitflags 2.6.0",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.52.0",
 ]
 
 [[package]]
@@ -1844,201 +1619,6 @@ version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
 
-[[package]]
-name = "symphonia"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "815c942ae7ee74737bb00f965fa5b5a2ac2ce7b6c01c0cc169bbeaf7abd5f5a9"
-dependencies = [
- "lazy_static",
- "symphonia-bundle-flac",
- "symphonia-bundle-mp3",
- "symphonia-codec-aac",
- "symphonia-codec-adpcm",
- "symphonia-codec-alac",
- "symphonia-codec-pcm",
- "symphonia-codec-vorbis",
- "symphonia-core",
- "symphonia-format-caf",
- "symphonia-format-isomp4",
- "symphonia-format-mkv",
- "symphonia-format-ogg",
- "symphonia-format-riff",
- "symphonia-metadata",
-]
-
-[[package]]
-name = "symphonia-bundle-flac"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "72e34f34298a7308d4397a6c7fbf5b84c5d491231ce3dd379707ba673ab3bd97"
-dependencies = [
- "log",
- "symphonia-core",
- "symphonia-metadata",
- "symphonia-utils-xiph",
-]
-
-[[package]]
-name = "symphonia-bundle-mp3"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c01c2aae70f0f1fb096b6f0ff112a930b1fb3626178fba3ae68b09dce71706d4"
-dependencies = [
- "lazy_static",
- "log",
- "symphonia-core",
- "symphonia-metadata",
-]
-
-[[package]]
-name = "symphonia-codec-aac"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cdbf25b545ad0d3ee3e891ea643ad115aff4ca92f6aec472086b957a58522f70"
-dependencies = [
- "lazy_static",
- "log",
- "symphonia-core",
-]
-
-[[package]]
-name = "symphonia-codec-adpcm"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c94e1feac3327cd616e973d5be69ad36b3945f16b06f19c6773fc3ac0b426a0f"
-dependencies = [
- "log",
- "symphonia-core",
-]
-
-[[package]]
-name = "symphonia-codec-alac"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2d8a6666649a08412906476a8b0efd9b9733e241180189e9f92b09c08d0e38f3"
-dependencies = [
- "log",
- "symphonia-core",
-]
-
-[[package]]
-name = "symphonia-codec-pcm"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f395a67057c2ebc5e84d7bb1be71cce1a7ba99f64e0f0f0e303a03f79116f89b"
-dependencies = [
- "log",
- "symphonia-core",
-]
-
-[[package]]
-name = "symphonia-codec-vorbis"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a98765fb46a0a6732b007f7e2870c2129b6f78d87db7987e6533c8f164a9f30"
-dependencies = [
- "log",
- "symphonia-core",
- "symphonia-utils-xiph",
-]
-
-[[package]]
-name = "symphonia-core"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "798306779e3dc7d5231bd5691f5a813496dc79d3f56bf82e25789f2094e022c3"
-dependencies = [
- "arrayvec",
- "bitflags 1.3.2",
- "bytemuck",
- "lazy_static",
- "log",
-]
-
-[[package]]
-name = "symphonia-format-caf"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e43c99c696a388295a29fe71b133079f5d8b18041cf734c5459c35ad9097af50"
-dependencies = [
- "log",
- "symphonia-core",
- "symphonia-metadata",
-]
-
-[[package]]
-name = "symphonia-format-isomp4"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "abfdf178d697e50ce1e5d9b982ba1b94c47218e03ec35022d9f0e071a16dc844"
-dependencies = [
- "encoding_rs",
- "log",
- "symphonia-core",
- "symphonia-metadata",
- "symphonia-utils-xiph",
-]
-
-[[package]]
-name = "symphonia-format-mkv"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1bb43471a100f7882dc9937395bd5ebee8329298e766250b15b3875652fe3d6f"
-dependencies = [
- "lazy_static",
- "log",
- "symphonia-core",
- "symphonia-metadata",
- "symphonia-utils-xiph",
-]
-
-[[package]]
-name = "symphonia-format-ogg"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ada3505789516bcf00fc1157c67729eded428b455c27ca370e41f4d785bfa931"
-dependencies = [
- "log",
- "symphonia-core",
- "symphonia-metadata",
- "symphonia-utils-xiph",
-]
-
-[[package]]
-name = "symphonia-format-riff"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "05f7be232f962f937f4b7115cbe62c330929345434c834359425e043bfd15f50"
-dependencies = [
- "extended",
- "log",
- "symphonia-core",
- "symphonia-metadata",
-]
-
-[[package]]
-name = "symphonia-metadata"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bc622b9841a10089c5b18e99eb904f4341615d5aa55bbf4eedde1be721a4023c"
-dependencies = [
- "encoding_rs",
- "lazy_static",
- "log",
- "symphonia-core",
-]
-
-[[package]]
-name = "symphonia-utils-xiph"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "484472580fa49991afda5f6550ece662237b00c6f562c7d9638d1b086ed010fe"
-dependencies = [
- "symphonia-core",
- "symphonia-metadata",
-]
-
 [[package]]
 name = "syn"
 version = "1.0.109"
@@ -2061,6 +1641,19 @@ dependencies = [
  "unicode-ident",
 ]
 
+[[package]]
+name = "tempfile"
+version = "3.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64"
+dependencies = [
+ "cfg-if",
+ "fastrand",
+ "once_cell",
+ "rustix",
+ "windows-sys 0.59.0",
+]
+
 [[package]]
 name = "termcolor"
 version = "1.4.1"
@@ -2115,31 +1708,6 @@ dependencies = [
  "strict-num",
 ]
 
-[[package]]
-name = "tinyvec"
-version = "1.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938"
-dependencies = [
- "tinyvec_macros",
-]
-
-[[package]]
-name = "tinyvec_macros"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
-
-[[package]]
-name = "tokio"
-version = "1.40.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998"
-dependencies = [
- "backtrace",
- "pin-project-lite",
-]
-
 [[package]]
 name = "toml_datetime"
 version = "0.6.8"
@@ -2154,18 +1722,7 @@ checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
 dependencies = [
  "indexmap 2.5.0",
  "toml_datetime",
- "winnow 0.5.40",
-]
-
-[[package]]
-name = "toml_edit"
-version = "0.22.20"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d"
-dependencies = [
- "indexmap 2.5.0",
- "toml_datetime",
- "winnow 0.6.18",
+ "winnow",
 ]
 
 [[package]]
@@ -2202,6 +1759,26 @@ version = "0.2.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a"
 
+[[package]]
+name = "v4l"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8fbfea44a46799d62c55323f3c55d06df722fbe577851d848d328a1041c3403"
+dependencies = [
+ "bitflags 1.3.2",
+ "libc",
+ "v4l2-sys-mit",
+]
+
+[[package]]
+name = "v4l2-sys-mit"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6779878362b9bacadc7893eac76abe69612e8837ef746573c4a5239daf11990b"
+dependencies = [
+ "bindgen",
+]
+
 [[package]]
 name = "vec_map"
 version = "0.8.2"
@@ -2214,16 +1791,6 @@ version = "0.9.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
 
-[[package]]
-name = "walkdir"
-version = "2.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
-dependencies = [
- "same-file",
- "winapi-util",
-]
-
 [[package]]
 name = "wasi"
 version = "0.11.0+wasi-snapshot-preview1"
@@ -2479,6 +2046,18 @@ dependencies = [
  "web-sys",
 ]
 
+[[package]]
+name = "which"
+version = "4.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
+dependencies = [
+ "either",
+ "home",
+ "once_cell",
+ "rustix",
+]
+
 [[package]]
 name = "widestring"
 version = "1.1.0"
@@ -2525,35 +2104,6 @@ dependencies = [
  "windows-targets 0.42.2",
 ]
 
-[[package]]
-name = "windows"
-version = "0.54.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49"
-dependencies = [
- "windows-core",
- "windows-targets 0.52.6",
-]
-
-[[package]]
-name = "windows-core"
-version = "0.54.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65"
-dependencies = [
- "windows-result",
- "windows-targets 0.52.6",
-]
-
-[[package]]
-name = "windows-result"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
-dependencies = [
- "windows-targets 0.52.6",
-]
-
 [[package]]
 name = "windows-sys"
 version = "0.45.0"
@@ -2572,6 +2122,15 @@ dependencies = [
  "windows-targets 0.48.5",
 ]
 
+[[package]]
+name = "windows-sys"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
+dependencies = [
+ "windows-targets 0.52.6",
+]
+
 [[package]]
 name = "windows-sys"
 version = "0.59.0"
@@ -2775,7 +2334,7 @@ dependencies = [
  "libc",
  "log",
  "mio",
- "ndk 0.7.0",
+ "ndk",
  "objc2",
  "once_cell",
  "orbclient",
@@ -2803,15 +2362,6 @@ dependencies = [
  "memchr",
 ]
 
-[[package]]
-name = "winnow"
-version = "0.6.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f"
-dependencies = [
- "memchr",
-]
-
 [[package]]
 name = "x11-dl"
 version = "2.21.0"
index ca63b99e283e57577bff3d0a5133a0a7c7fd0a66..d199849f484beb49afb743268edc6ad6abe8cd9c 100644 (file)
@@ -6,8 +6,7 @@ edition = "2021"
 [dependencies]
 rustfft = "6.2.0"
 show-image = "0.14.0"
-hound = "3.5.1"
-rodio = "0.19.0"
-cpal = "0.15.3"
-awedio = "0.4.1"
+v4l = "0.14.0"
 rand = "0.8.4"
+gnuplot = "0.0.43"
+hound = "3.5.1"
index 641ef7ede0d32c514861997b982f9cb2ff5a4533..43bd41f23bad09201ffe7a345e90871cb432df1f 100644 (file)
@@ -1,18 +1,13 @@
 use rustfft::algorithm::Radix4;
-use rand::Rng;
 use rustfft::{Fft, FftDirection};
 use rustfft::num_complex::Complex;
-use show_image::{Image, BoxImage, ImageInfo, PixelFormat};
+use show_image::{ImageView, ImageInfo, create_window};
+use hound;
+use gnuplot::{Figure, Caption, Color};
 
 const WINDOW_SIZE: usize = 128;
 const CHUNK_SIZE: usize = 72;
-
-const DISPLAY_WIDTH: usize = 1920;
-const DISPLAY_HEIGHT: usize = 1080;
-const DISPLAY_AREA: usize = DISPLAY_WIDTH * DISPLAY_HEIGHT;
-
-const WIDTH_SCALING: f32 = WINDOW_SIZE as f32 / DISPLAY_WIDTH as f32;
-const HEIGHT_SCALING: f32 = CHUNK_SIZE as f32 / DISPLAY_HEIGHT as f32;
+const SPECTOGRAM_AREA: usize = WINDOW_SIZE * CHUNK_SIZE;
 
 const AMPLITUDE_MAX: f32 = 255.0;
 const AMPLITUDE_MIN: f32 = 0.0;
@@ -22,7 +17,7 @@ const ANGLE_MAX: f32 = 255.0;
 const ANGLE_MIN: f32 = 0.0;
 const ANGLE_REL: f32 = ANGLE_MAX - ANGLE_MIN;
 
-const VOLUME_MAX: f32 = 65.0;
+const VOLUME_MAX: f32 = 100.0; // 60 - 65
 const VOLUME_MIN: f32 = -40.0;
 const VOLUME_REL: f32 = VOLUME_MAX - VOLUME_MIN;
 
@@ -30,59 +25,36 @@ const VOLUME_REL: f32 = VOLUME_MAX - VOLUME_MIN;
 const SQRT3_2: f32 = 0.86602540378443;
 
 struct ImageArray {
-       rgb: Box<[u8]>,
-       hsv: Box<[u8]>
+       data: [u8; SPECTOGRAM_AREA * 3],
+       chunks: usize
 }
 
 impl ImageArray {
        fn new () -> Self {
                Self {
-                       rgb: Box::new([0u8; DISPLAY_AREA]),
-                       hsv: Box::new([0u8; DISPLAY_AREA])
+                       data: [0u8; SPECTOGRAM_AREA * 3],
+                       chunks: SPECTOGRAM_AREA
                }
        }
 
-       fn from_buffer (&mut self, buffer: &[Complex<f32>]) -> () {
-               for (i, color) in self.hsv.chunks(3).enumerate() {
-                       let buffer_y = ((i / DISPLAY_HEIGHT) as f32 * HEIGHT_SCALING) as usize;
-                       let buffer_x =  ((i % DISPLAY_HEIGHT) as f32 * WIDTH_SCALING) as usize;
-                       let (r, theta): (f32, f32) = buffer[buffer_y + buffer_x].to_polar();
+       fn from_buffer (&mut self, buffer: &Vec<Complex<f32>>) -> () {
+               for i in 0..self.chunks {
+                       let (r, theta): (f32, f32) = buffer[i].to_polar();
 
                        let amplitude = 20f32 * r.log10();
                        let amplitude = ((amplitude - VOLUME_MIN) / (VOLUME_REL / AMPLITUDE_REL)) + AMPLITUDE_MIN;
 
-                       let hue = (180f32 / 255f32) * amplitude as f32;
-                       let angle = (theta.to_degrees() + 180f32) * (360f32 / ANGLE_REL) + ANGLE_MIN;
+                       let hue = (180f32 / 255f32) * amplitude;
 
-                       let color = [hue as i8, angle as i8, amplitude as i8];
-               }
-       }
+                       let angle = (theta.to_degrees() + 180f32) / (360f32 / ANGLE_REL) + ANGLE_MIN;
 
-       fn to_buffer (&mut self, buffer: &mut [Complex<f32>]) -> () {
-               for (i, color) in self.hsv.chunks(3).enumerate() {
-                       let buffer_y = ((i / DISPLAY_HEIGHT) as f32 * HEIGHT_SCALING) as usize;
-                       let buffer_x =  ((i % DISPLAY_HEIGHT) as f32 * WIDTH_SCALING) as usize;
-
-                       let amplitude = (color[2] as f32 - AMPLITUDE_MIN) / (AMPLITUDE_REL / VOLUME_REL) + VOLUME_MIN;
-                       let amplitude = 10f32.powi({amplitude / 20f32} as i32);
-
-                       let angle = (color[1] as f32 - ANGLE_MIN) * (ANGLE_REL / 360f32) - 180f32;
-                       let angle = angle.to_radians();
-
-                       buffer[buffer_y + buffer_x] = Complex::from_polar(amplitude, angle);
-               }
-       }
-
-       fn to_rgb (&mut self) -> () {
-               for (i, color) in self.hsv.chunks(3).enumerate() {
-                       let h = color[0] as f32 * 2f32;
-                       let s = color[1] as f32 / 255f32;
-                       let v = color[2] as f32 / 255f32;
+                       let d = hue * (1f32 / 30f32);
+                       let s = angle / 255f32;
+                       let v = amplitude / 255f32;
 
                        let c = s * v;
                        let m = v - c;
-                       let d = h / 60f32;
-                       let x = c * (1f32 - (d.div_euclid(2f32) - 1f32).abs());
+                       let x = c * (1f32 - (d.rem_euclid(2f32) - 1f32).abs());
 
                        let (r, g, b) = match d.floor() {
                                0.0 => (c, x, 0f32),
@@ -90,46 +62,39 @@ impl ImageArray {
                                2.0 => (0f32, c, x),
                                3.0 => (0f32, x, c),
                                4.0 => (x, 0f32, c),
-                               5.0 => (c, 0f32, x),
-                               _ => (0f32, 0f32, 0f32)
+                               _ => (c, 0f32, x)
                        };
 
-                       let mut rgb = self.rgb[i*3..(i*3)+3].try_into().expect("slice with incorrect length");
-                       rgb = [
-                               (r + m) as u8,
-                               (g + m) as u8,
-                               (b + m) as u8
-                       ];
+                       self.data[i*3] = ((r + m) * 255f32) as u8;
+                       self.data[i*3+1] = ((g + m) * 255f32) as u8;
+                       self.data[i*3+2] = ((b + m) * 255f32) as u8;
                }
        }
 
-       fn from_rgb (&mut self) -> () {
-               for (i, color) in self.rgb.chunks(3).enumerate() {
-                       let r = color[0] as f32;
-                       let g = color[1] as f32;
-                       let b = color[2] as f32;
+       fn to_buffer (&mut self, buffer: &mut Vec<Complex<f32>>) -> () {
+               for i in 0..self.chunks {
+                       let r = self.data[i*3] as f32;
+                       let g = self.data[i*3+1] as f32;
+                       let b = self.data[i*3+2] as f32;
 
                        let alpha = r - (g / 2f32) - (b / 2f32);
                        let beta = SQRT3_2 * (g - b);
                        let c = beta.hypot(alpha);
 
-                       let h = beta.atan2(alpha) as u8;
-                       let v = *color.iter().max().unwrap();
-                       let s = if v == 0 { 0f32 } else { c / v as f32 } as u8;
+                       // let h = beta.atan2(alpha).to_degrees() + 180f32;
+                       let v = r.max(g).max(b);
+                       let s = if v == 0f32 { 0f32 } else { c * (255f32) / v };
 
-                       let mut hsv = self.hsv[i*3..(i*3)+3].try_into().expect("slice with incorrect length");
-                       hsv = [h, s, v];
-               }
-       }
-}
+                       let amplitude = (v - AMPLITUDE_MIN) / (AMPLITUDE_REL / VOLUME_REL) + VOLUME_MIN;
+
+                       let amplitude = 10f32.powf(amplitude / 20f32);
+
+                       let angle = (s - ANGLE_MIN) * (ANGLE_REL / 360f32) - 180f32;
+                       let angle = angle.to_radians();
 
-fn get_data () -> Vec<Complex<f32>> {
-       let mut data: Vec<Complex<f32>> = Vec::new();
-       for _ in 1..10_000 {
-               let point = rand::thread_rng().gen_range(1.0f32..=10000.0f32);
-               data.push(Complex{re: point, im: 0.0});
+                       buffer[i] = Complex::from_polar(amplitude, angle);
+               }
        }
-       data
 }
 
 fn process <'a, T: Fft<f32>> (transform: T, buffer: &'a mut [Complex<f32>], scratch: &'a mut [Complex<f32>]) -> () {
@@ -143,25 +108,70 @@ fn process <'a, T: Fft<f32>> (transform: T, buffer: &'a mut [Complex<f32>], scra
        }
 }
 
-fn main () {
+#[show_image::main]
+fn main () -> Result<(), Box<dyn std::error::Error>> {
+
        // register the fft transformers
        let forward_transform = Radix4::<f32>::new(WINDOW_SIZE, FftDirection::Forward);
-       // let inverse_transform = Radix4::<f32>::new(WINDOW_SIZE, FftDirection::Inverse);
+       let inverse_transform = Radix4::<f32>::new(WINDOW_SIZE, FftDirection::Inverse);
        let scratch_space = forward_transform.get_inplace_scratch_len();
 
        // register the buffer and scratch space
-       let mut data = get_data();
-       let mut buffer = &mut data[0..WINDOW_SIZE * CHUNK_SIZE]; //vec![Complex{ re: 0.0f32, im: 0.0f32 }; WINDOW_SIZE * CHUNK_SIZE];
-       let mut scratch = vec![Complex{ re: 10000.0f32, im: 0.0f32 }; scratch_space];
+       let mut origional = [0i16; SPECTOGRAM_AREA];
+       let mut buffer = vec![Complex{re: 0f32, im: 0f32}; SPECTOGRAM_AREA];
+       let mut scratch = vec![Complex{re: 0f32, im: 0f32}; scratch_space];
+
+       let mut reader = hound::WavReader::open("/home/will/Downloads/Adducci - Around the Horn.wav").unwrap();
+               for (i, sample) in reader.samples::<i16>().enumerate() {
+                       if i >= SPECTOGRAM_AREA {break;}
+                       let value = match sample {
+                               Ok(t) => t,
+                               Err(_) => 0i16
+                       };
+                       origional[i] = value;
+                       buffer[i] = Complex{re: value as f32, im: 0f32};
+               }
 
        // register the image
        let mut image_array = ImageArray::new();
-       let image_info = ImageInfo::new(PixelFormat::Rgb8, DISPLAY_WIDTH as u32, DISPLAY_HEIGHT as u32);
 
        process(forward_transform, &mut buffer, &mut scratch);
 
-       image_array.from_buffer(buffer);
+       image_array.from_buffer(&buffer);
+       image_array.to_buffer(&mut buffer);
+
+       process(inverse_transform, &mut buffer, &mut scratch);
+
+       let mut processed = [0i16; SPECTOGRAM_AREA];
+       for i in 0..SPECTOGRAM_AREA {
+               processed[i] = buffer[i].re as i16;
+       }
+
+       let mut time = [0i16; SPECTOGRAM_AREA];
+       for i in 0..SPECTOGRAM_AREA {
+               time[i] = i as i16;
+       }
 
-       let newimage = Image::Box(BoxImage::new(image_info, image_array.rgb));
+       let image = ImageView::new(ImageInfo::rgb8(WINDOW_SIZE as u32, CHUNK_SIZE as u32), &image_array.data);
+
+       // Create a window with default options and display the image.
+       let window = create_window("image", Default::default())?;
+       window.set_image("image-001", image)?;
+
+       let mut fg = Figure::new();
+       fg.axes2d()
+               .lines(
+                       &time,
+                       &origional,
+                       &[Caption("Origional"), Color("blue")]
+               )
+               .lines(
+                       &time,
+                       &processed,
+                       &[Caption("Processed"), Color("red")]
+               );
+       fg.show().unwrap();
+
+       Ok(())
 
 }