Compare commits
10 Commits
main
...
c595cab609
| Author | SHA1 | Date | |
|---|---|---|---|
|
c595cab609
|
|||
|
7fb2e6aade
|
|||
|
804c2e221c
|
|||
|
|
08c62c4820 | ||
|
46241cce5f
|
|||
|
f413c43919
|
|||
|
1a679693d3
|
|||
|
690468d0ab
|
|||
|
12132b2798
|
|||
|
20fe694a8f
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
resources/** filter=lfs diff=lfs merge=lfs -text
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v2.3.0
|
rev: v6.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
|
- id: check-toml
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- repo: https://github.com/codespell-project/codespell
|
- repo: https://github.com/codespell-project/codespell
|
||||||
|
|||||||
386
Cargo.lock
generated
386
Cargo.lock
generated
@@ -3,5 +3,389 @@
|
|||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "termix"
|
name = "bitflags"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.19.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "coreaudio-rs"
|
||||||
|
version = "0.13.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1aae284fbaf7d27aa0e292f7677dfbe26503b0d555026f702940805a630eac17"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"libc",
|
||||||
|
"objc2-audio-toolbox",
|
||||||
|
"objc2-core-audio",
|
||||||
|
"objc2-core-audio-types",
|
||||||
|
"objc2-core-foundation",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-channel"
|
||||||
|
version = "0.5.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-utils"
|
||||||
|
version = "0.8.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dispatch2"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.10.0",
|
||||||
|
"objc2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "engine"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"coreaudio-rs",
|
||||||
|
"jack",
|
||||||
|
"lib",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.3.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"r-efi",
|
||||||
|
"wasip2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jack"
|
||||||
|
version = "0.13.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f70ca699f44c04a32d419fc9ed699aaea89657fc09014bf3fa238e91d13041b9"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.10.0",
|
||||||
|
"jack-sys",
|
||||||
|
"lazy_static",
|
||||||
|
"libc",
|
||||||
|
"log",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jack-sine"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-channel",
|
||||||
|
"jack",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jack-sys"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6013b7619b95a22b576dfb43296faa4ecbe40abbdb97dfd22ead520775fc86ab"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"lazy_static",
|
||||||
|
"libc",
|
||||||
|
"libloading",
|
||||||
|
"log",
|
||||||
|
"pkg-config",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.82"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lib"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.177"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libloading"
|
||||||
|
version = "0.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.28"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "objc2"
|
||||||
|
version = "0.6.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b7c2599ce0ec54857b29ce62166b0ed9b4f6f1a70ccc9a71165b6154caca8c05"
|
||||||
|
dependencies = [
|
||||||
|
"objc2-encode",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "objc2-audio-toolbox"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6948501a91121d6399b79abaa33a8aa4ea7857fe019f341b8c23ad6e81b79b08"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.10.0",
|
||||||
|
"libc",
|
||||||
|
"objc2",
|
||||||
|
"objc2-core-audio",
|
||||||
|
"objc2-core-audio-types",
|
||||||
|
"objc2-core-foundation",
|
||||||
|
"objc2-foundation",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "objc2-core-audio"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e1eebcea8b0dbff5f7c8504f3107c68fc061a3eb44932051c8cf8a68d969c3b2"
|
||||||
|
dependencies = [
|
||||||
|
"dispatch2",
|
||||||
|
"objc2",
|
||||||
|
"objc2-core-audio-types",
|
||||||
|
"objc2-core-foundation",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "objc2-core-audio-types"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a89f2ec274a0cf4a32642b2991e8b351a404d290da87bb6a9a9d8632490bd1c"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.10.0",
|
||||||
|
"objc2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "objc2-core-foundation"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.10.0",
|
||||||
|
"dispatch2",
|
||||||
|
"objc2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "objc2-encode"
|
||||||
|
version = "4.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "objc2-foundation"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
|
||||||
|
dependencies = [
|
||||||
|
"objc2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.21.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pkg-config"
|
||||||
|
version = "0.3.32"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.103"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.42"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "r-efi"
|
||||||
|
version = "5.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.22"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.111"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.22"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "1.18.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasip2"
|
||||||
|
version = "1.0.1+wasi-0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
|
||||||
|
dependencies = [
|
||||||
|
"wit-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.105"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"once_cell",
|
||||||
|
"rustversion",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.105"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.105"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.105"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wit-bindgen"
|
||||||
|
version = "0.46.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
[package]
|
[workspace]
|
||||||
name = "termix"
|
resolver = "3"
|
||||||
version = "0.1.0"
|
members = ["engine", "examples/jack-sine", "lib"]
|
||||||
edition = "2024"
|
|
||||||
|
|
||||||
[dependencies]
|
[workspace.dependencies]
|
||||||
|
|||||||
13
engine/Cargo.toml
Normal file
13
engine/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[package]
|
||||||
|
name = "engine"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
coreaudio-rs = { version = "0.13.0", optional = true }
|
||||||
|
jack = {version = "0.13.3", optional = true }
|
||||||
|
lib = { path = "../lib/" }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
jack = ["dep:jack"]
|
||||||
|
coreaudio = ["dep:coreaudio-rs"]
|
||||||
0
engine/src/audio_engine/coreaudio.rs
Normal file
0
engine/src/audio_engine/coreaudio.rs
Normal file
0
engine/src/audio_engine/jack.rs
Normal file
0
engine/src/audio_engine/jack.rs
Normal file
12
engine/src/audio_engine/mod.rs
Normal file
12
engine/src/audio_engine/mod.rs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
mod jack;
|
||||||
|
mod coreaudio;
|
||||||
|
|
||||||
|
trait AudioBackend {
|
||||||
|
// Start a audio backend client
|
||||||
|
// It should be executed either on the startup,
|
||||||
|
// or when the audio backend is switched
|
||||||
|
fn start_client();
|
||||||
|
// Initialization of the client should happen
|
||||||
|
// when a project is opened.
|
||||||
|
fn init_client();
|
||||||
|
}
|
||||||
35
engine/src/main.rs
Normal file
35
engine/src/main.rs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
mod audio_engine;
|
||||||
|
|
||||||
|
use lib::{self, metadata::Metadata, track::Track};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut current_project = lib::project::Project {
|
||||||
|
name: "test".to_string(),
|
||||||
|
tracks: None,
|
||||||
|
regions: None,
|
||||||
|
current_sample: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
let track = Track {
|
||||||
|
metadata: Metadata::new("test".to_string()),
|
||||||
|
track_type: lib::track::TrackType::Audio,
|
||||||
|
active: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
current_project.tracks = Some(vec![track]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Engine should run and wait for commands,
|
||||||
|
* but currently I need to implement the multitrack
|
||||||
|
* audio player somehow
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* for track in tracks {
|
||||||
|
* if track.is_region_playing(now: time) {
|
||||||
|
* let current_region = track.get_current_region(now: time)
|
||||||
|
* let audio = current_region.get_data(now: time)
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
||||||
8
examples/jack-sine/Cargo.toml
Normal file
8
examples/jack-sine/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "jack-sine"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
crossbeam-channel = "0.5.15"
|
||||||
|
jack = "0.13.3"
|
||||||
1
examples/jack-sine/README.md
Normal file
1
examples/jack-sine/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Set this on mac ❯ export DYLD_FALLBACK_LIBRARY_PATH="$(brew --prefix jack)/lib:${DYLD_FALLBACK_LIBRARY_PATH:-}"
|
||||||
94
examples/jack-sine/src/main.rs
Normal file
94
examples/jack-sine/src/main.rs
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
//! Sine wave generator with frequency configuration exposed through standard
|
||||||
|
//! input.
|
||||||
|
|
||||||
|
use crossbeam_channel::bounded;
|
||||||
|
use std::io;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// 1. open a client
|
||||||
|
let (client, _status) =
|
||||||
|
jack::Client::new("rust_jack_sine", jack::ClientOptions::default()).unwrap();
|
||||||
|
|
||||||
|
// 2. register port
|
||||||
|
let out_port = client
|
||||||
|
.register_port("sine_out", jack::AudioOut::default())
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// 3. define process callback handler
|
||||||
|
let (tx, rx) = bounded(1_000_000);
|
||||||
|
struct State {
|
||||||
|
out_port: jack::Port<jack::AudioOut>,
|
||||||
|
rx: crossbeam_channel::Receiver<f64>,
|
||||||
|
frequency: f64,
|
||||||
|
frame_t: f64,
|
||||||
|
time: f64,
|
||||||
|
}
|
||||||
|
let process = jack::contrib::ClosureProcessHandler::with_state(
|
||||||
|
State {
|
||||||
|
out_port,
|
||||||
|
rx,
|
||||||
|
frequency: 220.0,
|
||||||
|
frame_t: 1.0 / client.sample_rate() as f64,
|
||||||
|
time: 0.0,
|
||||||
|
},
|
||||||
|
|state, _, ps| -> jack::Control {
|
||||||
|
// Get output buffer
|
||||||
|
let out = state.out_port.as_mut_slice(ps);
|
||||||
|
|
||||||
|
// Check frequency requests
|
||||||
|
while let Ok(f) = state.rx.try_recv() {
|
||||||
|
state.time = 0.0;
|
||||||
|
state.frequency = f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write output
|
||||||
|
for v in out.iter_mut() {
|
||||||
|
let x = state.frequency * state.time * 2.0 * std::f64::consts::PI;
|
||||||
|
let y = x.sin();
|
||||||
|
*v = y as f32;
|
||||||
|
state.time += state.frame_t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Continue as normal
|
||||||
|
jack::Control::Continue
|
||||||
|
},
|
||||||
|
move |_, _, _| jack::Control::Continue,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 4. Activate the client. Also connect the ports to the system audio.
|
||||||
|
let active_client = client.activate_async((), process).unwrap();
|
||||||
|
active_client
|
||||||
|
.as_client()
|
||||||
|
.connect_ports_by_name("rust_jack_sine:sine_out", "system:playback_1")
|
||||||
|
.unwrap();
|
||||||
|
active_client
|
||||||
|
.as_client()
|
||||||
|
.connect_ports_by_name("rust_jack_sine:sine_out", "system:playback_2")
|
||||||
|
.unwrap();
|
||||||
|
// processing starts here
|
||||||
|
|
||||||
|
// 5. wait or do some processing while your handler is running in real time.
|
||||||
|
println!("Enter an integer value to change the frequency of the sine wave.");
|
||||||
|
while let Some(f) = read_freq() {
|
||||||
|
tx.send(f).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. Optional deactivate. Not required since active_client will deactivate on
|
||||||
|
// drop, though explicit deactivate may help you identify errors in
|
||||||
|
// deactivate.
|
||||||
|
if let Err(err) = active_client.deactivate() {
|
||||||
|
eprintln!("JACK exited with error: {err}");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Attempt to read a frequency from standard in. Will block until there is
|
||||||
|
/// user input. `None` is returned if there was an error reading from standard
|
||||||
|
/// in, or the retrieved string wasn't a compatible u16 integer.
|
||||||
|
fn read_freq() -> Option<f64> {
|
||||||
|
let mut user_input = String::new();
|
||||||
|
match io::stdin().read_line(&mut user_input) {
|
||||||
|
Ok(_) => u16::from_str(user_input.trim()).ok().map(|n| n as f64),
|
||||||
|
Err(_) => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
7
lib/Cargo.toml
Normal file
7
lib/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "lib"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
uuid = { version = "1.18.1", features = ["v4"] }
|
||||||
5
lib/src/lib.rs
Normal file
5
lib/src/lib.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
pub mod metadata;
|
||||||
|
|
||||||
|
pub mod project;
|
||||||
|
pub mod region;
|
||||||
|
pub mod track;
|
||||||
25
lib/src/metadata.rs
Normal file
25
lib/src/metadata.rs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
pub struct Metadata {
|
||||||
|
id: Uuid,
|
||||||
|
name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Metadata {
|
||||||
|
pub fn new(name: String) -> Self {
|
||||||
|
let id = Uuid::new_v4();
|
||||||
|
Self { id, name }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn id(&self) -> Uuid {
|
||||||
|
self.id
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn name(&self) -> &str {
|
||||||
|
&self.name
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_name(&mut self, name: String) {
|
||||||
|
self.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
9
lib/src/project.rs
Normal file
9
lib/src/project.rs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
use crate::{metadata::Metadata, region::Region, track::Track};
|
||||||
|
|
||||||
|
pub struct Project {
|
||||||
|
pub name: String,
|
||||||
|
pub tracks: Option<Vec<Track>>,
|
||||||
|
pub regions: Option<Vec<Region>>,
|
||||||
|
// Current playhead position
|
||||||
|
pub current_sample: u64,
|
||||||
|
}
|
||||||
11
lib/src/region.rs
Normal file
11
lib/src/region.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
use crate::metadata::Metadata;
|
||||||
|
|
||||||
|
pub struct Region {
|
||||||
|
pub metadata: Metadata,
|
||||||
|
// Position of the track on the track
|
||||||
|
pub starts_at: u64,
|
||||||
|
// From which point of the audio source the region starts
|
||||||
|
pub plays_from: u64,
|
||||||
|
// Duration of the region after plays_from
|
||||||
|
pub duration: u64,
|
||||||
|
}
|
||||||
14
lib/src/track.rs
Normal file
14
lib/src/track.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
use crate::metadata::Metadata;
|
||||||
|
|
||||||
|
pub enum TrackType {
|
||||||
|
Audio,
|
||||||
|
Midi,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Track {
|
||||||
|
pub metadata: Metadata,
|
||||||
|
pub track_type: TrackType,
|
||||||
|
pub active: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TrackStatus {}
|
||||||
BIN
resources/audio/session.flac
(Stored with Git LFS)
Normal file
BIN
resources/audio/session.flac
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/audio/session.mp3
(Stored with Git LFS)
Normal file
BIN
resources/audio/session.mp3
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/audio/session.wav
(Stored with Git LFS)
Normal file
BIN
resources/audio/session.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
@@ -1,3 +0,0 @@
|
|||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user