├── .cargo └── config.toml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── presets └── test │ └── reactive.milk ├── rel.sh ├── scripts └── clippy.sh └── src ├── app.rs ├── app ├── audio.rs ├── config.rs ├── main_loop.rs ├── playlist.rs └── video.rs ├── dummy_audio.rs └── main.rs /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [env] 2 | # use pipewire for audio 3 | #SDL_AUDIODRIVER = "pipewire" 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | target/ 3 | .nvim-dap.lua 4 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "1.1.3" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "bindgen" 16 | version = "0.70.1" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" 19 | dependencies = [ 20 | "bitflags", 21 | "cexpr", 22 | "clang-sys", 23 | "itertools", 24 | "log", 25 | "prettyplease", 26 | "proc-macro2", 27 | "quote", 28 | "regex", 29 | "rustc-hash", 30 | "shlex", 31 | "syn", 32 | ] 33 | 34 | [[package]] 35 | name = "bitflags" 36 | version = "2.9.0" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" 39 | 40 | [[package]] 41 | name = "cc" 42 | version = "1.2.19" 43 | source = "registry+https://github.com/rust-lang/crates.io-index" 44 | checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" 45 | dependencies = [ 46 | "shlex", 47 | ] 48 | 49 | [[package]] 50 | name = "cexpr" 51 | version = "0.6.0" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" 54 | dependencies = [ 55 | "nom", 56 | ] 57 | 58 | [[package]] 59 | name = "cfg-if" 60 | version = "1.0.0" 61 | source = "registry+https://github.com/rust-lang/crates.io-index" 62 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 63 | 64 | [[package]] 65 | name = "clang-sys" 66 | version = "1.8.1" 67 | source = "registry+https://github.com/rust-lang/crates.io-index" 68 | checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" 69 | dependencies = [ 70 | "glob", 71 | "libc", 72 | "libloading", 73 | ] 74 | 75 | [[package]] 76 | name = "cmake" 77 | version = "0.1.54" 78 | source = "registry+https://github.com/rust-lang/crates.io-index" 79 | checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" 80 | dependencies = [ 81 | "cc", 82 | ] 83 | 84 | [[package]] 85 | name = "either" 86 | version = "1.15.0" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" 89 | 90 | [[package]] 91 | name = "getrandom" 92 | version = "0.2.15" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" 95 | dependencies = [ 96 | "cfg-if", 97 | "libc", 98 | "wasi", 99 | ] 100 | 101 | [[package]] 102 | name = "glob" 103 | version = "0.3.2" 104 | source = "registry+https://github.com/rust-lang/crates.io-index" 105 | checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" 106 | 107 | [[package]] 108 | name = "include_dir" 109 | version = "0.7.4" 110 | source = "registry+https://github.com/rust-lang/crates.io-index" 111 | checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" 112 | dependencies = [ 113 | "include_dir_macros", 114 | ] 115 | 116 | [[package]] 117 | name = "include_dir_macros" 118 | version = "0.7.4" 119 | source = "registry+https://github.com/rust-lang/crates.io-index" 120 | checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" 121 | dependencies = [ 122 | "proc-macro2", 123 | "quote", 124 | ] 125 | 126 | [[package]] 127 | name = "itertools" 128 | version = "0.13.0" 129 | source = "registry+https://github.com/rust-lang/crates.io-index" 130 | checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" 131 | dependencies = [ 132 | "either", 133 | ] 134 | 135 | [[package]] 136 | name = "lazy_static" 137 | version = "1.5.0" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" 140 | 141 | [[package]] 142 | name = "libc" 143 | version = "0.2.172" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" 146 | 147 | [[package]] 148 | name = "libloading" 149 | version = "0.8.6" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" 152 | dependencies = [ 153 | "cfg-if", 154 | "windows-targets", 155 | ] 156 | 157 | [[package]] 158 | name = "log" 159 | version = "0.4.27" 160 | source = "registry+https://github.com/rust-lang/crates.io-index" 161 | checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" 162 | 163 | [[package]] 164 | name = "memchr" 165 | version = "2.7.4" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 168 | 169 | [[package]] 170 | name = "minimal-lexical" 171 | version = "0.2.1" 172 | source = "registry+https://github.com/rust-lang/crates.io-index" 173 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 174 | 175 | [[package]] 176 | name = "nom" 177 | version = "7.1.3" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" 180 | dependencies = [ 181 | "memchr", 182 | "minimal-lexical", 183 | ] 184 | 185 | [[package]] 186 | name = "ppv-lite86" 187 | version = "0.2.21" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" 190 | dependencies = [ 191 | "zerocopy", 192 | ] 193 | 194 | [[package]] 195 | name = "prettyplease" 196 | version = "0.2.32" 197 | source = "registry+https://github.com/rust-lang/crates.io-index" 198 | checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" 199 | dependencies = [ 200 | "proc-macro2", 201 | "syn", 202 | ] 203 | 204 | [[package]] 205 | name = "proc-macro2" 206 | version = "1.0.95" 207 | source = "registry+https://github.com/rust-lang/crates.io-index" 208 | checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" 209 | dependencies = [ 210 | "unicode-ident", 211 | ] 212 | 213 | [[package]] 214 | name = "projectm" 215 | version = "3.1.2" 216 | source = "registry+https://github.com/rust-lang/crates.io-index" 217 | checksum = "a81ed6e24cd4ca8ceaa5421127abd1b6a0a1ff9a96c397377dfd4a93e867cabb" 218 | dependencies = [ 219 | "libc", 220 | "projectm-sys", 221 | "rand", 222 | ] 223 | 224 | [[package]] 225 | name = "projectm-sys" 226 | version = "1.2.2" 227 | source = "registry+https://github.com/rust-lang/crates.io-index" 228 | checksum = "25cefe874b73cb8da95def230af489949f0b9e77788e1777eaf345c860d6ca5a" 229 | dependencies = [ 230 | "bindgen", 231 | "cmake", 232 | "lazy_static", 233 | ] 234 | 235 | [[package]] 236 | name = "projectm_sdl" 237 | version = "0.1.1" 238 | dependencies = [ 239 | "include_dir", 240 | "libc", 241 | "projectm", 242 | "rand", 243 | "sdl3", 244 | ] 245 | 246 | [[package]] 247 | name = "quote" 248 | version = "1.0.40" 249 | source = "registry+https://github.com/rust-lang/crates.io-index" 250 | checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" 251 | dependencies = [ 252 | "proc-macro2", 253 | ] 254 | 255 | [[package]] 256 | name = "rand" 257 | version = "0.8.5" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 260 | dependencies = [ 261 | "libc", 262 | "rand_chacha", 263 | "rand_core", 264 | ] 265 | 266 | [[package]] 267 | name = "rand_chacha" 268 | version = "0.3.1" 269 | source = "registry+https://github.com/rust-lang/crates.io-index" 270 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 271 | dependencies = [ 272 | "ppv-lite86", 273 | "rand_core", 274 | ] 275 | 276 | [[package]] 277 | name = "rand_core" 278 | version = "0.6.4" 279 | source = "registry+https://github.com/rust-lang/crates.io-index" 280 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 281 | dependencies = [ 282 | "getrandom", 283 | ] 284 | 285 | [[package]] 286 | name = "regex" 287 | version = "1.11.1" 288 | source = "registry+https://github.com/rust-lang/crates.io-index" 289 | checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" 290 | dependencies = [ 291 | "aho-corasick", 292 | "memchr", 293 | "regex-automata", 294 | "regex-syntax", 295 | ] 296 | 297 | [[package]] 298 | name = "regex-automata" 299 | version = "0.4.9" 300 | source = "registry+https://github.com/rust-lang/crates.io-index" 301 | checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" 302 | dependencies = [ 303 | "aho-corasick", 304 | "memchr", 305 | "regex-syntax", 306 | ] 307 | 308 | [[package]] 309 | name = "regex-syntax" 310 | version = "0.8.5" 311 | source = "registry+https://github.com/rust-lang/crates.io-index" 312 | checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" 313 | 314 | [[package]] 315 | name = "rpkg-config" 316 | version = "0.1.2" 317 | source = "registry+https://github.com/rust-lang/crates.io-index" 318 | checksum = "5a2d2f3481209a6b42eec2fbb49063fb4e8d35b57023401495d4fe0f85c817f0" 319 | 320 | [[package]] 321 | name = "rustc-hash" 322 | version = "1.1.0" 323 | source = "registry+https://github.com/rust-lang/crates.io-index" 324 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 325 | 326 | [[package]] 327 | name = "sdl3" 328 | version = "0.14.23" 329 | source = "registry+https://github.com/rust-lang/crates.io-index" 330 | checksum = "6f49aa6ce4bf8663ee4f412166eb8911df72a906c8840ded69a33de5a53951a0" 331 | dependencies = [ 332 | "bitflags", 333 | "lazy_static", 334 | "libc", 335 | "sdl3-image-sys", 336 | "sdl3-sys", 337 | "sdl3-ttf-sys", 338 | ] 339 | 340 | [[package]] 341 | name = "sdl3-image-src" 342 | version = "3.2.4" 343 | source = "registry+https://github.com/rust-lang/crates.io-index" 344 | checksum = "c4d0c6070f236297a8e7931cbe5f652e3f0e5a8a214b12984357bd4904874cc7" 345 | 346 | [[package]] 347 | name = "sdl3-image-sys" 348 | version = "0.1.2" 349 | source = "registry+https://github.com/rust-lang/crates.io-index" 350 | checksum = "0df364a60f4c203e2cfb24e574100ccabb73736d8bf66fcdb40e8064e74537d7" 351 | dependencies = [ 352 | "cmake", 353 | "rpkg-config", 354 | "sdl3-image-src", 355 | "sdl3-sys", 356 | ] 357 | 358 | [[package]] 359 | name = "sdl3-src" 360 | version = "3.2.10" 361 | source = "registry+https://github.com/rust-lang/crates.io-index" 362 | checksum = "e677fa126db179fb8f03c982163321496ddf57a6d8a1e41eeef4600f956038b1" 363 | 364 | [[package]] 365 | name = "sdl3-sys" 366 | version = "0.4.7+SDL3-3.2.10" 367 | source = "registry+https://github.com/rust-lang/crates.io-index" 368 | checksum = "f0d16a8a3623a4cb39a3661c81d9d4c5fd77ada27fc056e320b3651bf7bde1b1" 369 | dependencies = [ 370 | "cmake", 371 | "rpkg-config", 372 | "sdl3-src", 373 | ] 374 | 375 | [[package]] 376 | name = "sdl3-ttf-src" 377 | version = "3.2.3" 378 | source = "registry+https://github.com/rust-lang/crates.io-index" 379 | checksum = "f28923d2ce72ff317d8eb7cec97ddfb8f351c330d7bcbf8c76e91332122c93b3" 380 | 381 | [[package]] 382 | name = "sdl3-ttf-sys" 383 | version = "0.1.2+SDL3-ttf-3.2.2" 384 | source = "registry+https://github.com/rust-lang/crates.io-index" 385 | checksum = "532a0c92efad5a0c32ca27ea6cd2ee9fab3f57015361e1f68310ee3b76f1100b" 386 | dependencies = [ 387 | "cmake", 388 | "rpkg-config", 389 | "sdl3-sys", 390 | "sdl3-ttf-src", 391 | ] 392 | 393 | [[package]] 394 | name = "shlex" 395 | version = "1.3.0" 396 | source = "registry+https://github.com/rust-lang/crates.io-index" 397 | checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" 398 | 399 | [[package]] 400 | name = "syn" 401 | version = "2.0.100" 402 | source = "registry+https://github.com/rust-lang/crates.io-index" 403 | checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" 404 | dependencies = [ 405 | "proc-macro2", 406 | "quote", 407 | "unicode-ident", 408 | ] 409 | 410 | [[package]] 411 | name = "unicode-ident" 412 | version = "1.0.18" 413 | source = "registry+https://github.com/rust-lang/crates.io-index" 414 | checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" 415 | 416 | [[package]] 417 | name = "wasi" 418 | version = "0.11.0+wasi-snapshot-preview1" 419 | source = "registry+https://github.com/rust-lang/crates.io-index" 420 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 421 | 422 | [[package]] 423 | name = "windows-targets" 424 | version = "0.52.6" 425 | source = "registry+https://github.com/rust-lang/crates.io-index" 426 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 427 | dependencies = [ 428 | "windows_aarch64_gnullvm", 429 | "windows_aarch64_msvc", 430 | "windows_i686_gnu", 431 | "windows_i686_gnullvm", 432 | "windows_i686_msvc", 433 | "windows_x86_64_gnu", 434 | "windows_x86_64_gnullvm", 435 | "windows_x86_64_msvc", 436 | ] 437 | 438 | [[package]] 439 | name = "windows_aarch64_gnullvm" 440 | version = "0.52.6" 441 | source = "registry+https://github.com/rust-lang/crates.io-index" 442 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 443 | 444 | [[package]] 445 | name = "windows_aarch64_msvc" 446 | version = "0.52.6" 447 | source = "registry+https://github.com/rust-lang/crates.io-index" 448 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 449 | 450 | [[package]] 451 | name = "windows_i686_gnu" 452 | version = "0.52.6" 453 | source = "registry+https://github.com/rust-lang/crates.io-index" 454 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 455 | 456 | [[package]] 457 | name = "windows_i686_gnullvm" 458 | version = "0.52.6" 459 | source = "registry+https://github.com/rust-lang/crates.io-index" 460 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 461 | 462 | [[package]] 463 | name = "windows_i686_msvc" 464 | version = "0.52.6" 465 | source = "registry+https://github.com/rust-lang/crates.io-index" 466 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 467 | 468 | [[package]] 469 | name = "windows_x86_64_gnu" 470 | version = "0.52.6" 471 | source = "registry+https://github.com/rust-lang/crates.io-index" 472 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 473 | 474 | [[package]] 475 | name = "windows_x86_64_gnullvm" 476 | version = "0.52.6" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 479 | 480 | [[package]] 481 | name = "windows_x86_64_msvc" 482 | version = "0.52.6" 483 | source = "registry+https://github.com/rust-lang/crates.io-index" 484 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 485 | 486 | [[package]] 487 | name = "zerocopy" 488 | version = "0.8.24" 489 | source = "registry+https://github.com/rust-lang/crates.io-index" 490 | checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" 491 | dependencies = [ 492 | "zerocopy-derive", 493 | ] 494 | 495 | [[package]] 496 | name = "zerocopy-derive" 497 | version = "0.8.24" 498 | source = "registry+https://github.com/rust-lang/crates.io-index" 499 | checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" 500 | dependencies = [ 501 | "proc-macro2", 502 | "quote", 503 | "syn", 504 | ] 505 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "projectm_sdl" 3 | version = "0.1.1" 4 | edition = "2021" 5 | rust-version = "1.68.2" 6 | 7 | [dependencies] 8 | libc = "*" 9 | #projectm = { path = "../projectm-rs", version = "3", features = ["playlist", "static"] } 10 | projectm = { version = "3", features = ['playlist', 'static'] } 11 | sdl3 = { version = "0.14.24", features = ["build-from-source-static"] } 12 | #sdl3 = { path = "../../sdl3-rs", version = "0", features = ["build-from-source"] } 13 | rand = "0.8.5" 14 | include_dir = "0.7" 15 | 16 | [features] 17 | static-link = ["sdl3/static-link"] 18 | dummy_audio = [] 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 489 | USA 490 | 491 | Also add information on how to contact you by electronic and paper mail. 492 | 493 | You should also get your employer (if you work as a programmer) or your 494 | school, if any, to sign a "copyright disclaimer" for the library, if 495 | necessary. Here is a sample; alter the names: 496 | 497 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 498 | library `Frob' (a library for tweaking knobs) written by James Random 499 | Hacker. 500 | 501 | , 1 April 1990 502 | Ty Coon, President of Vice 503 | 504 | That's all there is to it! 505 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | [![Contributors][contributors-shield]][contributors-url] 6 | [![Forks][forks-shield]][forks-url] 7 | [![Stargazers][stars-shield]][stars-url] 8 | [![Issues][issues-shield]][issues-url] 9 | [![License][license-shield]][license-url] 10 | 11 |
12 | 13 |

ProjectM

14 | 15 |

16 | Reference projectM application in Rust, utilizing the projectM crate 17 |
18 |
19 | Report Bug 20 | · 21 | Request Feature 22 |

23 |
24 | 25 |
26 | 27 | 28 |
29 | Table of Contents 30 |
    31 |
  1. 32 | Getting Started 33 | 36 |
  2. 37 |
  3. Usage
  4. 38 |
  5. Contributing
  6. 39 |
  7. License
  8. 40 |
  9. Support
  10. 41 |
  11. Contact
  12. 42 |
43 |
44 | 45 |
46 | 47 | 48 | 49 | ## Getting Started 50 | 51 | To get this crate up and running properly, you'll need to install some prerequisites. 52 | 53 | ### Prerequisites 54 | 55 | Depending on the OS/distribution and packaging system, libraries might be split into separate packages with binaries and 56 | development files. To build projectM, both binaries and development files need to be installed. 57 | 58 | #### General build dependencies for all platforms: 59 | 60 | - [**Rust**](https://www.rust-lang.org/tools/install) 61 | - A working build toolchain. 62 | - [**CMake**](https://cmake.org/): Used to generate platform-specific build files. 63 | - **OpenGL**: 3D graphics library. Used to render the visualizations. 64 | - or **GLES3**: OpenGL libraries for embedded systems, version 3. Required to build projectM on Android devices, 65 | Raspberry Pi, Emscripten and the Universal Windows Platform. 66 | - [**glm**](https://github.com/g-truc/glm): OpenGL Mathematics library. Optional, will use a bundled version with 67 | autotools or if not installed. 68 | - [**SDL3**](https://github.com/libsdl-org/SDL): Simple Directmedia Layer >= 3. Provided by sdl3-rs. 69 | the test UI. 70 | - [**LLVM**](https://llvm.org/): Low-Level Virtual Machine. Optional and **experimental**, used to speed up preset 71 | execution by leveraging the LLVM JIT compiler. 72 | 73 | #### Only relevant for Windows: 74 | 75 | - [**vcpkg**](https://github.com/microsoft/vcpkg): C++ Library Manager for Windows. _Optional_, but recommended to 76 | install the aforementioned library dependencies. 77 | - [**GLEW**](http://glew.sourceforge.net/): The OpenGL Extension Wrangler Library. Only required if using CMake to 78 | configure the build, the pre-created solutions use a bundled copy of GLEW. 79 |

(back to top)

80 | 81 | 82 | 83 | ## Usage 84 | 85 | ``` 86 | // run app 87 | cargo run 88 | 89 | // build app 90 | cargo build 91 | ``` 92 | 93 | ### If using SDL installed via Homebrew 94 | 95 | ``` 96 | RUSTFLAGS="-L$(brew --prefix sdl3)/lib" cargo build 97 | RUSTFLAGS="-L$(brew --prefix sdl3)/lib" cargo run 98 | ``` 99 | 100 | ### Optimized build 101 | 102 | ``` 103 | cargo run --release 104 | ``` 105 | 106 |

(back to top)

107 | 108 | 109 | 110 | ## Contributing 111 | 112 | Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. 113 | 114 | If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". 115 | Don't forget to give the project a star! Thanks again! 116 | 117 | 1. Fork the Project 118 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 119 | 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 120 | 4. Push to the Branch (`git push origin feature/AmazingFeature`) 121 | 5. Open a Pull Request 122 | 123 |

(back to top)

124 | 125 | 126 | 127 | ## License 128 | 129 | Distributed under the LGPL-2.1 license. See `LICENSE` for more information. 130 | 131 |

(back to top)

132 | 133 | 134 | 135 | ## Support 136 | 137 | [![Discord][discord-shield]][discord-url] 138 | 139 |

(back to top)

140 | 141 | 142 | 143 | ## Contact 144 | 145 | Blaquewithaq (Discord: SoFloppy#1289) - [@anomievision](https://twitter.com/anomievision) - anomievision@gmail.com 146 | 147 |

(back to top)

148 | 149 | 150 | 151 | 152 | [contributors-shield]: https://img.shields.io/github/contributors/projectM-visualizer/projectm-rs.svg?style=for-the-badge 153 | [contributors-url]: https://github.com/projectM-visualizer/frontend-sdl-rust/graphs/contributors 154 | [forks-shield]: https://img.shields.io/github/forks/projectM-visualizer/projectm-rs.svg?style=for-the-badge 155 | [forks-url]: https://github.com/projectM-visualizer/frontend-sdl-rust/network/members 156 | [stars-shield]: https://img.shields.io/github/stars/projectM-visualizer/projectm-rs.svg?style=for-the-badge 157 | [stars-url]: https://github.com/projectM-visualizer/frontend-sdl-rust/stargazers 158 | [issues-shield]: https://img.shields.io/github/issues/projectM-visualizer/projectm-rs.svg?style=for-the-badge 159 | [issues-url]: https://github.com/projectM-visualizer/frontend-sdl-rust/issues 160 | [license-shield]: https://img.shields.io/github/license/projectM-visualizer/projectm-rs.svg?style=for-the-badge 161 | [license-url]: https://github.com/projectM-visualizer/frontend-sdl-rust/blob/master/LICENSE 162 | [crates-shield]: https://img.shields.io/crates/v/projectm-rs?style=for-the-badge 163 | [crates-url]: https://crates.io/crates/projectm-rs 164 | [crates-dl-shield]: https://img.shields.io/crates/d/projectm-rs?style=for-the-badge 165 | [crates-dl-url]: https://crates.io/crates/projectm-rs 166 | [discord-shield]: https://img.shields.io/discord/737206408482914387?style=for-the-badge 167 | [discord-url]: https://discord.gg/7fQXN43n9W 168 | -------------------------------------------------------------------------------- /presets/test/reactive.milk: -------------------------------------------------------------------------------- 1 | [preset00] 2 | fDecay=0.75 3 | fWarpScale=2.853000 4 | fZoomExponent=1.000000 5 | warp=0.000000 6 | wave_a=0 7 | cy=1.0 8 | cx=0.5 9 | sx=1 10 | sy=1 11 | dx=0 12 | dy=0.02 13 | zoom=1.0 14 | ob_size=0 15 | ib_size=0.0 16 | 17 | per_pixel_1=cx=x 18 | 19 | wavecode_0_enabled=1 20 | wavecode_0_r=1 21 | wavecode_0_g=0 22 | wavecode_0_b=0 23 | wavecode_0_mode=0 24 | wavecode_0_bDrawThick=0 25 | wavecode_0_bAdditive=1 26 | wavecode_0_scaling=1.0 27 | wavecode_0_smoothing=0.0 28 | wavecode_0_r=0.000000 29 | wavecode_0_g=1.000000 30 | wavecode_0_b=1.000000 31 | wavecode_0_a=1.000000 32 | wave_0_per_frame1=t1=if(above(bass,9.5),0.95,bass/10) 33 | wave_0_per_point1=x=0.01666 + 0.3*sample; 34 | wave_0_per_point2=y=t1 + value1/20; 35 | 36 | 37 | wavecode_1_enabled=1 38 | wavecode_1_r=0 39 | wavecode_1_g=1 40 | wavecode_1_b=0 41 | wavecode_1_mode=0 42 | wavecode_1_bDrawThick=0 43 | wavecode_1_bAdditive=1 44 | wavecode_1_scaling=1.0 45 | wavecode_1_smoothing=0.0 46 | wavecode_1_r=0.000000 47 | wavecode_1_g=1.000000 48 | wavecode_1_b=1.000000 49 | wavecode_1_a=1.000000 50 | wave_1_per_frame1=t1=if(above(mid,9.5),0.95,mid/10) 51 | wave_1_per_point1=x=0.35 + 0.3*sample; 52 | wave_1_per_point2=y=t1 + value2/20; 53 | 54 | 55 | wavecode_2_enabled=1 56 | wavecode_2_r=0 57 | wavecode_2_g=0 58 | wavecode_2_b=1 59 | wavecode_2_mode=0 60 | wavecode_2_bDrawThick=0 61 | wavecode_2_bAdditive=1 62 | wavecode_2_scaling=1.0 63 | wavecode_2_smoothing=0.0 64 | wavecode_2_r=0.000000 65 | wavecode_2_g=1.000000 66 | wavecode_2_b=1.000000 67 | wavecode_2_a=1.000000 68 | wave_2_per_frame1=t1=if(above(treb,9.5),0.95,treb/10) 69 | wave_2_per_point1=x=0.6833 + 0.3*sample; 70 | wave_2_per_point2=y=t1 + value1/20; 71 | -------------------------------------------------------------------------------- /rel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | ####################################### 6 | # Variables 7 | ####################################### 8 | APP_NAME="projectm_sdl" 9 | BUNDLE_ID="projectM" 10 | DEVELOPER_ID="Developer ID Application: Mischa Spiegelmock (5926VBQM6Y)" 11 | TEAM_ID="5926VBQM6Y" 12 | KEYCHAIN_PROFILE="projectm" 13 | 14 | BUILD_DIR="target" 15 | OUTPUT_DIR="${PWD}/dist" 16 | 17 | # Paths for universal binary 18 | UNIVERSAL_BINARY="${OUTPUT_DIR}/${APP_NAME}" 19 | 20 | # .app bundle paths 21 | APP_BUNDLE_NAME="${APP_NAME}.app" 22 | APP_BUNDLE_PATH="${OUTPUT_DIR}/${APP_BUNDLE_NAME}" 23 | APP_EXECUTABLE_PATH="${APP_BUNDLE_PATH}/Contents/MacOS" 24 | INFO_PLIST_PATH="${APP_BUNDLE_PATH}/Contents/Info.plist" 25 | RESOURCES_PATH="${APP_BUNDLE_PATH}/Contents/Resources" 26 | 27 | # Entitlements file (if sandboxing is needed) 28 | ENTITLEMENTS_FILE="${OUTPUT_DIR}/entitlements.plist" 29 | 30 | # Zip paths 31 | PRE_NOTARIZATION_ZIP="${OUTPUT_DIR}/${APP_NAME}-pre-notarization.zip" 32 | FINAL_ZIP="${OUTPUT_DIR}/${APP_NAME}.zip" 33 | 34 | ####################################### 35 | # 1) Build Rust Binaries (x86_64 + arm64) 36 | ####################################### 37 | echo "==> Building for x86_64" 38 | cargo build --release --target x86_64-apple-darwin 39 | 40 | echo "==> Building for arm64" 41 | cargo build --release --target aarch64-apple-darwin 42 | 43 | ####################################### 44 | # 2) Create Universal Binary 45 | ####################################### 46 | mkdir -p "${OUTPUT_DIR}" 47 | echo "==> Creating universal binary" 48 | lipo -create -output "${UNIVERSAL_BINARY}" \ 49 | "${BUILD_DIR}/x86_64-apple-darwin/release/${APP_NAME}" \ 50 | "${BUILD_DIR}/aarch64-apple-darwin/release/${APP_NAME}" 51 | 52 | ####################################### 53 | # 3) Create .app Bundle Structure 54 | ####################################### 55 | echo "==> Creating .app bundle structure" 56 | rm -rf "${APP_BUNDLE_PATH}" || true 57 | mkdir -p "${APP_EXECUTABLE_PATH}" 58 | mkdir -p "${RESOURCES_PATH}" 59 | 60 | # Move the universal binary into MacOS/ 61 | mv "${UNIVERSAL_BINARY}" "${APP_EXECUTABLE_PATH}/${APP_NAME}" 62 | 63 | ####################################### 64 | # 4) Create Info.plist with Microphone Access 65 | ####################################### 66 | echo "==> Creating Info.plist" 67 | cat > "${INFO_PLIST_PATH}" < 69 | 71 | 72 | 73 | CFBundleName 74 | ${APP_NAME} 75 | CFBundleIdentifier 76 | ${BUNDLE_ID} 77 | CFBundleVersion 78 | 1.0 79 | CFBundleExecutable 80 | ${APP_NAME} 81 | CFBundlePackageType 82 | APPL 83 | LSMinimumSystemVersion 84 | 10.12 85 | NSMicrophoneUsageDescription 86 | This app requires microphone access for audio input. 87 | 88 | 89 | EOL 90 | 91 | ####################################### 92 | # 5) (Optional) Create Entitlements File for Sandboxing 93 | ####################################### 94 | echo "==> Creating entitlements file for sandboxing (optional)" 95 | cat > "${ENTITLEMENTS_FILE}" < 97 | 99 | 100 | 101 | com.apple.security.app-sandbox 102 | 103 | com.apple.security.device.audio-input 104 | 105 | 106 | 107 | EOL 108 | 109 | ####################################### 110 | # 6) Clone and Copy Presets/Textures 111 | ####################################### 112 | echo "==> Cloning preset repositories" 113 | TEMP_DIR="$(mktemp -d)" 114 | pushd "$TEMP_DIR" >/dev/null 115 | 116 | # cream-of-the-crop 117 | git clone git@github.com:projectM-visualizer/presets-cream-of-the-crop.git 118 | mkdir -p "${RESOURCES_PATH}/presets" 119 | cp -R presets-cream-of-the-crop/"." "${RESOURCES_PATH}/presets/" 120 | 121 | # milkdrop-texture-pack 122 | git clone git@github.com:projectM-visualizer/presets-milkdrop-texture-pack.git 123 | mkdir -p "${RESOURCES_PATH}/textures" 124 | cp -R presets-milkdrop-texture-pack/textures/"." "${RESOURCES_PATH}/textures/" 125 | 126 | popd >/dev/null 127 | rm -rf "$TEMP_DIR" 128 | 129 | ####################################### 130 | # 7) Sign the .app Bundle with Entitlements 131 | ####################################### 132 | echo "==> Signing the .app with hardened runtime and entitlements" 133 | codesign --deep --verbose --force --options runtime \ 134 | --entitlements "${ENTITLEMENTS_FILE}" \ 135 | --sign "${DEVELOPER_ID}" "${APP_BUNDLE_PATH}" 136 | 137 | ####################################### 138 | # 8) Zip the Signed .app for Notarization 139 | ####################################### 140 | echo "==> Creating zip for notarization" 141 | rm -f "${PRE_NOTARIZATION_ZIP}" 142 | ditto -c -k --sequesterRsrc --keepParent \ 143 | "${APP_BUNDLE_PATH}" \ 144 | "${PRE_NOTARIZATION_ZIP}" 145 | 146 | ####################################### 147 | # 9) Submit the Zip File for Notarization 148 | ####################################### 149 | echo "==> Submitting for notarization" 150 | xcrun notarytool submit "${PRE_NOTARIZATION_ZIP}" \ 151 | --keychain-profile "${KEYCHAIN_PROFILE}" \ 152 | --team-id "${TEAM_ID}" \ 153 | --wait 154 | 155 | ####################################### 156 | # 10) Staple the Now-Notarized .app 157 | ####################################### 158 | echo "==> Stapling notarization ticket to .app" 159 | xcrun stapler staple "${APP_BUNDLE_PATH}" 160 | 161 | ####################################### 162 | # 11) (Optional) Create Final Zip with Stapled .app 163 | ####################################### 164 | echo "==> Creating final zip of stapled .app" 165 | rm -f "${FINAL_ZIP}" 166 | ditto -c -k --sequesterRsrc --keepParent \ 167 | "${APP_BUNDLE_PATH}" \ 168 | "${FINAL_ZIP}" 169 | 170 | ####################################### 171 | # 12) Verify with Gatekeeper 172 | ####################################### 173 | echo "==> Verifying with spctl" 174 | spctl --assess --verbose=4 "${APP_BUNDLE_PATH}" 175 | 176 | rm "${PRE_NOTARIZATION_ZIP}" 177 | rm "${ENTITLEMENTS_FILE}" 178 | 179 | echo "✅ Build, sign, notarize, staple, and package completed successfully!" -------------------------------------------------------------------------------- /scripts/clippy.sh: -------------------------------------------------------------------------------- 1 | cargo clippy --all-features --all-targets -- -D warnings 2 | -------------------------------------------------------------------------------- /src/app.rs: -------------------------------------------------------------------------------- 1 | use projectm::core::ProjectM; 2 | use sdl3::video::{GLProfile, WindowPos}; 3 | use std::convert::TryInto; 4 | use std::rc::Rc; 5 | 6 | pub mod audio; 7 | pub mod config; 8 | pub mod main_loop; 9 | pub mod playlist; 10 | pub mod video; 11 | 12 | pub type ProjectMWrapped = Rc; 13 | 14 | /// Application state 15 | pub struct App { 16 | pm: ProjectMWrapped, 17 | playlist: projectm::playlist::Playlist, 18 | sdl_context: sdl3::Sdl, 19 | window: sdl3::video::Window, 20 | config: config::Config, 21 | audio: audio::Audio, 22 | _gl_context: sdl3::video::GLContext, 23 | } 24 | 25 | pub fn default_config() -> config::Config { 26 | config::Config::default() 27 | } 28 | 29 | impl App { 30 | pub fn new(config: Option) -> Self { 31 | // setup sdl 32 | let sdl_context = sdl3::init().unwrap(); 33 | // print SDL version 34 | let version = sdl3::version::version(); 35 | println!( 36 | "SDL version: {}.{}.{}", 37 | version.major, version.minor, version.patch 38 | ); 39 | let video_subsystem = sdl_context.video().unwrap(); 40 | 41 | // request GL version 42 | // TODO: deal with OpenGL ES here 43 | let gl_attr = video_subsystem.gl_attr(); 44 | gl_attr.set_context_profile(GLProfile::Core); 45 | gl_attr.set_context_version(3, 3); 46 | gl_attr.set_context_flags().debug().set(); 47 | assert_eq!(gl_attr.context_profile(), GLProfile::Core); 48 | assert_eq!(gl_attr.context_version(), (3, 3)); 49 | 50 | // create window 51 | let mut window = video_subsystem 52 | .window("ProjectM", 1024, 768) 53 | .build() 54 | .expect("could not initialize video subsystem"); 55 | 56 | // create openGL context 57 | let gl_context = window.gl_create_context().unwrap(); 58 | window.gl_make_current(&gl_context).unwrap(); 59 | 60 | // initialize projectM 61 | let pm = Rc::new(ProjectM::create()); 62 | 63 | // and a preset playlist 64 | let playlist = projectm::playlist::Playlist::create(&pm); 65 | 66 | // make window full-size 67 | let primary_display_id = video_subsystem.get_primary_display_id(); 68 | let display_bounds = video_subsystem 69 | .display_usable_bounds(primary_display_id) 70 | .unwrap(); 71 | window 72 | .set_size(display_bounds.width(), display_bounds.height()) 73 | .unwrap(); 74 | window.set_position(WindowPos::Centered, WindowPos::Centered); 75 | window 76 | .set_display_mode(None) 77 | .expect("could not set display mode"); 78 | 79 | // initialize audio 80 | let audio = audio::Audio::new(&sdl_context, Rc::clone(&pm)); 81 | 82 | Self { 83 | pm, 84 | playlist, 85 | sdl_context, 86 | window, 87 | config: config.unwrap_or_else(default_config), 88 | audio, 89 | _gl_context: gl_context, // keep this around to keep the context alive 90 | } 91 | } 92 | 93 | pub fn init(&mut self) { 94 | // load config 95 | self.load_config(&self.config); 96 | 97 | // initialize audio 98 | self.audio.init(self.get_frame_rate()); 99 | 100 | self.update_projectm_window_size(); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/app/audio.rs: -------------------------------------------------------------------------------- 1 | use projectm::core::ProjectM; 2 | use sdl3::audio::{AudioDevice, AudioDeviceID, AudioSpec, AudioStream}; 3 | 4 | use super::config::FrameRate; 5 | use super::ProjectMWrapped; 6 | 7 | type SampleFormat = f32; // Format of audio samples 8 | const CHANNELS: u32 = 2; // Number of audio channels 9 | 10 | pub struct Audio { 11 | audio_subsystem: sdl3::AudioSubsystem, 12 | recording_stream: Option>, 13 | is_capturing: bool, 14 | frame_rate: Option, 15 | projectm: ProjectMWrapped, 16 | current_device_id: Option, 17 | current_device_name: Option, // Store device name for comparison 18 | } 19 | 20 | impl Audio { 21 | pub fn new(sdl_context: &sdl3::Sdl, projectm: ProjectMWrapped) -> Self { 22 | let audio_subsystem = sdl_context.audio().unwrap(); 23 | println!( 24 | "Using audio driver: {}", 25 | audio_subsystem.current_audio_driver() 26 | ); 27 | 28 | Self { 29 | is_capturing: false, 30 | audio_subsystem, 31 | frame_rate: None, 32 | current_device_id: None, 33 | current_device_name: None, 34 | recording_stream: None, 35 | projectm, 36 | } 37 | } 38 | 39 | pub fn init(&mut self, frame_rate: FrameRate) { 40 | self.list_devices(); 41 | 42 | self.frame_rate = Some(frame_rate); 43 | 44 | #[cfg(not(feature = "dummy_audio"))] 45 | self.begin_audio_recording(None); 46 | } 47 | 48 | pub fn list_devices(&self) { 49 | let devices = self.get_device_list(); 50 | 51 | println!("Audio Devices:"); 52 | for device in devices { 53 | println!(" - {} [{}]", device.name(), device.id()); 54 | } 55 | } 56 | 57 | /// Start capturing audio from device_id. 58 | pub fn begin_audio_recording(&mut self, device_id: Option) { 59 | // Stop capturing from current stream/device 60 | self.stop_audio_recording(); 61 | 62 | let sample_rate: u32 = 44100; 63 | 64 | let desired_spec = AudioSpec { 65 | freq: Some(sample_rate as i32), 66 | channels: Some(CHANNELS.try_into().unwrap()), 67 | format: Some(sdl3::audio::AudioFormat::f32_sys()), // Assuming F32SYS is the correct format 68 | }; 69 | 70 | // Open audio device for recording (use default device if none specified) 71 | let device_id = device_id 72 | .or_else(|| Some(self.get_default_recording_device().id())) 73 | .unwrap(); // Ensure device_id is Some 74 | 75 | let audio_stream = match AudioStream::open_device_stream(device_id, Some(&desired_spec)) { 76 | Ok(stream) => stream, 77 | Err(e) => { 78 | println!("Failed to open audio stream: {}", e); 79 | return; 80 | } 81 | }; 82 | println!("Capturing audio from device {:?}", audio_stream); 83 | 84 | // Get the actual device ID and name from the stream 85 | let actual_device_id = audio_stream.device_id(); 86 | let actual_device_name = audio_stream.device_name(); 87 | 88 | if actual_device_id.is_none() { 89 | println!("Failed to get device ID from audio stream: {:?}", audio_stream); 90 | return; 91 | } 92 | 93 | let actual_device_id = actual_device_id.unwrap(); 94 | let actual_device_name = actual_device_name.unwrap_or_else(|| "unknown".to_string()); 95 | 96 | // Start capturing 97 | if let Err(e) = audio_stream.resume() { 98 | println!("Failed to start audio capture: {}", e); 99 | return; 100 | } 101 | 102 | // Take ownership of the stream and store device information 103 | self.recording_stream = Some(Box::new(audio_stream)); 104 | self.current_device_id = Some(actual_device_id); 105 | self.current_device_name = Some(actual_device_name); 106 | self.is_capturing = true; 107 | } 108 | 109 | fn get_default_recording_device(&self) -> AudioDevice { 110 | self.audio_subsystem.default_recording_device() 111 | } 112 | 113 | /// Select a new audio device and start capturing audio from it. 114 | pub fn open_next_device(&mut self) { 115 | let current_device_name = self.recording_device_name(); 116 | 117 | let device_list = self.get_device_list(); 118 | 119 | println!("Device list: {:?}", device_list); 120 | println!("Current device name: {:?}", current_device_name); 121 | 122 | // Find the index of the current device by name 123 | let current_device_index = current_device_name.as_ref().and_then(|name| { 124 | device_list 125 | .iter() 126 | .position(|d| d.name() == *name) 127 | }); 128 | 129 | let current_device_index = current_device_index.unwrap_or_else(|| { 130 | println!("Current device not found in device list. Starting from the first device."); 131 | 0 132 | }); 133 | 134 | // Select next device index 135 | let next_device_index = (current_device_index + 1) % device_list.len(); 136 | let next_device_id = device_list[next_device_index]; 137 | 138 | println!( 139 | "Switching from device '{}' to '{}'", 140 | current_device_name.unwrap_or_else(|| "unknown".to_string()), 141 | next_device_id.name() 142 | ); 143 | 144 | // Start capturing from next device 145 | self.begin_audio_recording(Some(next_device_id)); 146 | } 147 | 148 | 149 | pub fn stop_audio_recording(&mut self) { 150 | if let Some(stream) = self.recording_stream.take() { 151 | // Retrieve the device name before dropping the stream 152 | let current_device_name = stream.device_name().unwrap_or_else(|| "unknown".to_string()); 153 | 154 | println!( 155 | "Stopping audio capture for device {}", 156 | current_device_name 157 | ); 158 | 159 | // The recording device will be closed when the stream is dropped 160 | self.is_capturing = false; 161 | drop(stream); 162 | } 163 | } 164 | 165 | /// Read all available audio samples from the recording stream and feed them to ProjectM. 166 | /// This method should be called once per frame. 167 | pub fn process_frame_samples(&mut self) { 168 | if !self.is_capturing || self.recording_stream.is_none() { 169 | return; 170 | } 171 | 172 | let stream = self.recording_stream.as_mut().unwrap(); 173 | let available_bytes = stream.available_bytes(); 174 | if available_bytes.is_err() || available_bytes.unwrap() == 0 { 175 | // nothing to read 176 | return; 177 | } 178 | 179 | // Retrieve the maximum number of PCM samples ProjectM can handle 180 | let max_samples: usize = ProjectM::pcm_get_max_samples() 181 | .try_into() 182 | .expect("Failed to convert max samples to usize"); 183 | 184 | // Allocate the sample buffer once to reuse in the loop 185 | let mut sample_buf = vec![0.0f32; max_samples]; 186 | 187 | // Start the loop to read and process samples 188 | loop { 189 | // Attempt to read samples into the buffer 190 | match stream.read_f32_samples(&mut sample_buf) { 191 | Ok(samples_read) => { 192 | if samples_read == 0 { 193 | // No more data to read; exit the loop 194 | break; 195 | } 196 | 197 | // Add the read samples to ProjectM for processing 198 | self.projectm 199 | .pcm_add_float(&sample_buf[..samples_read], CHANNELS); 200 | } 201 | Err(e) => { 202 | // Handle any read errors 203 | println!("Failed to read audio samples: {}", e); 204 | break; // Exit the loop on error 205 | } 206 | } 207 | } 208 | 209 | } 210 | 211 | fn get_device_list(&self) -> Vec { 212 | self.audio_subsystem.audio_recording_device_ids().unwrap_or_else(|e| { 213 | println!("Failed to get audio device list: {}", e); 214 | Vec::new() 215 | }) 216 | } 217 | 218 | pub fn recording_device_name(&self) -> Option { 219 | self.current_device_name.clone() 220 | } 221 | } -------------------------------------------------------------------------------- /src/app/config.rs: -------------------------------------------------------------------------------- 1 | use crate::app::App; 2 | use std::path::Path; 3 | 4 | pub type FrameRate = u32; 5 | 6 | /// Configuration for the application 7 | /// TODO: use config crate to support loading from env/CLI/file. 8 | /// Parameters are defined here: https://github.com/projectM-visualizer/projectm/blob/master/src/api/include/projectM-4/parameters.h 9 | pub struct Config { 10 | /// Frame rate to render at. Defaults to 60. 11 | pub frame_rate: Option, 12 | 13 | /// Path to the preset directory. Defaults to /usr/local/share/projectM/presets 14 | pub preset_path: Option, 15 | 16 | /// Path to the texture directory. Defaults to /usr/local/share/projectM/textures 17 | pub texture_path: Option, 18 | 19 | /// How sensitive the beat detection is. 1.0 is default. 20 | pub beat_sensitivity: Option, 21 | 22 | /// How long to play a preset before switching to a new one (seconds). 23 | pub preset_duration: Option, 24 | } 25 | 26 | #[cfg(target_os = "macos")] 27 | fn default_resource_dir() -> std::path::PathBuf { 28 | // current_exe() => /Path/To/projectm_sdl.app/Contents/MacOS/projectm_sdl 29 | let exe_path = std::env::current_exe().unwrap(); 30 | // Jump up two levels to Contents/, then into Resources 31 | exe_path 32 | .parent() // MacOS 33 | .unwrap() 34 | .parent() // Contents 35 | .unwrap() 36 | .join("Resources") 37 | } 38 | 39 | #[cfg(not(target_os = "macos"))] 40 | fn default_resource_dir() -> std::path::PathBuf { 41 | // On Linux, Windows, etc., do as you wish 42 | "/usr/local/share/projectM".into() 43 | } 44 | 45 | impl Default for Config { 46 | fn default() -> Self { 47 | #[cfg(target_os = "macos")] 48 | let resource_dir = default_resource_dir(); // points to .app/Contents/Resources 49 | 50 | #[cfg(not(target_os = "macos"))] 51 | let resource_dir = std::path::PathBuf::from("/usr/local/share/projectM"); 52 | 53 | // Construct paths 54 | let presets_path = resource_dir.join("presets"); 55 | let textures_path = resource_dir.join("textures"); 56 | 57 | Self { 58 | preset_path: presets_path.exists().then(|| presets_path.to_string_lossy().to_string()), 59 | texture_path: textures_path.exists().then(|| textures_path.to_string_lossy().to_string()), 60 | frame_rate: Some(60), 61 | beat_sensitivity: Some(1.0), 62 | preset_duration: Some(10.0), 63 | } 64 | } 65 | } 66 | 67 | impl App { 68 | pub fn load_config(&self, config: &Config) { 69 | let pm = &self.pm; 70 | 71 | // load presets if provided 72 | if let Some(preset_path) = &config.preset_path { 73 | self.add_preset_path(preset_path); 74 | } 75 | 76 | // set frame rate if provided 77 | if let Some(frame_rate) = config.frame_rate { 78 | pm.set_fps(frame_rate); 79 | } 80 | 81 | // load textures if provided 82 | if let Some(texture_path) = &config.texture_path { 83 | let mut paths: Vec = Vec::new(); 84 | paths.push(texture_path.into()); 85 | pm.set_texture_search_paths(&paths, 1); 86 | } 87 | 88 | // set beat sensitivity if provided 89 | if let Some(beat_sensitivity) = config.beat_sensitivity { 90 | pm.set_beat_sensitivity(beat_sensitivity); 91 | } 92 | 93 | // set preset duration if provided 94 | if let Some(preset_duration) = config.preset_duration { 95 | pm.set_preset_duration(preset_duration); 96 | } 97 | 98 | // set preset shuffle mode 99 | // self.playlist.set_shuffle(true); 100 | } 101 | 102 | pub fn get_frame_rate(&self) -> FrameRate { 103 | self.pm.get_fps() 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/app/main_loop.rs: -------------------------------------------------------------------------------- 1 | use crate::app::App; 2 | use sdl3::event::Event; 3 | use sdl3::keyboard::Keycode; 4 | use sdl3::timer::{delay, ticks}; 5 | 6 | #[cfg(feature = "dummy_audio")] 7 | use crate::dummy_audio; 8 | 9 | impl App { 10 | pub fn main_loop(&mut self) { 11 | let config = &self.config; 12 | let frame_rate = config.frame_rate.unwrap(); 13 | 14 | // events 15 | let mut event_pump = self.sdl_context.event_pump().unwrap(); 16 | 17 | // renderLoop 18 | 'running: loop { 19 | // get start time 20 | let start_time = ticks(); 21 | 22 | // check for event 23 | for event in event_pump.poll_iter() { 24 | match event { 25 | // quit (Esc) 26 | Event::Quit { .. } 27 | | Event::KeyDown { 28 | keycode: Some(Keycode::Escape), 29 | .. 30 | } => { 31 | break 'running; 32 | } 33 | 34 | // Next preset (N, right-arrow) 35 | Event::KeyUp { 36 | keycode: Some(Keycode::N), 37 | .. 38 | } => { 39 | self.playlist_play_next(); 40 | } 41 | // XXX: how to collapse these into one case? 42 | Event::KeyUp { 43 | keycode: Some(Keycode::Right), 44 | .. 45 | } => { 46 | self.playlist_play_next(); 47 | } 48 | 49 | // Previous preset (P, left-arrow) 50 | Event::KeyUp { 51 | keycode: Some(Keycode::P), 52 | .. 53 | } => { 54 | self.playlist_play_prev(); 55 | } 56 | Event::KeyUp { 57 | keycode: Some(Keycode::Left), 58 | .. 59 | } => { 60 | self.playlist_play_prev(); 61 | } 62 | 63 | // Random preset (R) 64 | Event::KeyUp { 65 | keycode: Some(Keycode::R), 66 | .. 67 | } => { 68 | self.playlist_play_random(); 69 | } 70 | 71 | // Toggle fullscreen (F) 72 | Event::KeyUp { 73 | keycode: Some(Keycode::F), 74 | .. 75 | } => { 76 | self.toggle_fullscreen(); 77 | } 78 | 79 | // Next audio capture input device (ctl-I, cmd-I) 80 | Event::KeyUp { 81 | keycode: Some(Keycode::I), 82 | keymod: 83 | sdl3::keyboard::Mod::LCTRLMOD 84 | | sdl3::keyboard::Mod::RCTRLMOD 85 | | sdl3::keyboard::Mod::LGUIMOD 86 | | sdl3::keyboard::Mod::RGUIMOD, 87 | .. 88 | } => { 89 | self.audio.open_next_device(); 90 | } 91 | 92 | // default 93 | _ => {} 94 | } 95 | } 96 | 97 | // generate random audio 98 | #[cfg(feature = "dummy_audio")] 99 | dummy_audio::generate_random_audio_data(&self.pm); 100 | 101 | // Feed audio data from capture device to projectM 102 | #[cfg(not(feature = "dummy_audio"))] 103 | self.audio.process_frame_samples(); 104 | 105 | // render a frame 106 | self.pm.render_frame(); 107 | 108 | // swap buffers 109 | self.window.gl_swap_window(); 110 | 111 | if frame_rate > 0 { 112 | // calculate frame time 113 | let frame_time: i32 = (ticks() - start_time).try_into().unwrap(); 114 | // what do we need to hit target frame rate? 115 | let frame_rate_i32: i32 = frame_rate.try_into().unwrap(); 116 | let delay_needed: i32 = 1000 / frame_rate_i32 - frame_time; 117 | if delay_needed > 0 { 118 | // sleep the remaining frame time 119 | delay(delay_needed.try_into().unwrap()); 120 | } 121 | } 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/app/playlist.rs: -------------------------------------------------------------------------------- 1 | use crate::app::App; 2 | 3 | impl App { 4 | /// Add presets to the playlist recursively skipping duplicates. 5 | pub fn add_preset_path(&self, preset_path: &str) { 6 | self.playlist.add_path(preset_path, true); 7 | println!("added preset path: {}", preset_path); 8 | println!("playlist size: {}", self.playlist.len()); 9 | } 10 | 11 | pub fn playlist_play_next(&mut self) { 12 | self.playlist.play_next(); 13 | } 14 | pub fn playlist_play_prev(&mut self) { 15 | self.playlist.play_prev(); 16 | } 17 | pub fn playlist_play_random(&mut self) { 18 | self.playlist.play_random(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/app/video.rs: -------------------------------------------------------------------------------- 1 | use crate::app::App; 2 | 3 | impl App { 4 | pub fn toggle_fullscreen(&mut self) { 5 | let is_fullscreen = self.window.fullscreen_state(); 6 | self.window 7 | .set_fullscreen(match is_fullscreen { 8 | sdl3::video::FullscreenType::True => false, 9 | _ => true, 10 | }) 11 | .unwrap(); 12 | self.update_projectm_window_size(); 13 | } 14 | 15 | pub fn update_projectm_window_size(&mut self) { 16 | let (width, height) = self.window.size(); 17 | self.pm.set_window_size(width as usize, height as usize); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/dummy_audio.rs: -------------------------------------------------------------------------------- 1 | use crate::app::ProjectMWrapped; 2 | 3 | #[allow(dead_code)] 4 | pub fn generate_random_audio_data(pm: &ProjectMWrapped) { 5 | // Create a Vec with 1024 elements 6 | // two channels of 512 samples each 7 | let mut pcm_data: Vec = vec![0; 1024]; 8 | 9 | for i in 0..512 { 10 | if i % 2 == 1 { 11 | pcm_data[i * 2] = -(pcm_data[i * 2] as i32) as i16; 12 | pcm_data[i * 2 + 1] = -(pcm_data[i * 2 + 1] as i32) as i16; 13 | } 14 | } 15 | 16 | pm.pcm_add_int16(&pcm_data, 2); 17 | } 18 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | mod app; 2 | mod dummy_audio; 3 | 4 | fn main() -> Result<(), String> { 5 | let config = app::default_config(); 6 | // TODO: parse args here for config 7 | // config.preset_path = Some("./presets/test".to_string()); 8 | 9 | let mut app = app::App::new(Some(config)); 10 | app.init(); 11 | 12 | app.main_loop(); 13 | 14 | Ok(()) 15 | } 16 | --------------------------------------------------------------------------------