Compare commits
248 Commits
5b3252cc31
...
v0.1.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 82d51a9add | |||
| fed7781bae | |||
| d055d2bfc6 | |||
| f273470eaf | |||
| b2a089fb0c | |||
| 04b68850d0 | |||
| 77364dddae | |||
| 5a72e4cef4 | |||
| 0097777449 | |||
| 4743c33916 | |||
| 2c8a6794a3 | |||
| 60fb62829f | |||
| 35370a6f2c | |||
| 4e1c04f9c7 | |||
| 80a3d91f76 | |||
| f130c9b54a | |||
| bdd2f9210e | |||
| 1fb599f574 | |||
| e8cf8c506b | |||
| 16d6d76422 | |||
| cf1d2be140 | |||
| cc89021cc0 | |||
| 470f62df89 | |||
| 88cb43a760 | |||
| eeefb7d54d | |||
| cfd7d31d3d | |||
| e9f5d8bb6d | |||
| 17643b3332 | |||
| 95879c852d | |||
| 3ad82a1954 | |||
| 4718248ee6 | |||
| 6fd844cdf6 | |||
| 2d3094464f | |||
| db44f9b98e | |||
| ecb559e556 | |||
| 5a59937cc7 | |||
| 11cc925faf | |||
| b72c782b2b | |||
| 6cd20732ed | |||
| d30ef8bb5b | |||
| e73ee1eb1e | |||
| 19bb3e0820 | |||
| cb7fcdb74a | |||
| 651ed1219d | |||
| ec98274dfe | |||
| 66abc4f961 | |||
| ca08074686 | |||
| 81fb174d7e | |||
| 7ae3f255b0 | |||
| 511726b65b | |||
| 052a6caa1a | |||
| fb62b121c1 | |||
| 0ecc4dae11 | |||
| 6b56655661 | |||
| f618f47811 | |||
| 47099a6eef | |||
| 70032acc75 | |||
| e1cf57918e | |||
| 71bd09d5ea | |||
| 6dd265067f | |||
| aa607a78d8 | |||
| 03c8187359 | |||
| c219b4efab | |||
| 0119988d7c | |||
| a6ff19bb08 | |||
| 2de49bdeba | |||
| 848d0e773f | |||
| 8f131b46cc | |||
| 8b745a77a6 | |||
| 502f7afe8f | |||
| e7137cc7ed | |||
| d9e6505e07 | |||
| 009d68087d | |||
| f47285385c | |||
| 81f475a75b | |||
| 3d552ec072 | |||
| 3093b40dbc | |||
| e2f3bcd4a9 | |||
| d3b27e8245 | |||
| c9c8fe4117 | |||
| a7a1f9e759 | |||
| 2ba957f2d4 | |||
| 7207a5fefe | |||
| 4526156c37 | |||
| 7a95207c58 | |||
| ab353edc0b | |||
| 77d5235d92 | |||
| e9bca2548c | |||
| 5ef988382b | |||
| 2d734c471f | |||
| 6216b9341b | |||
| bf361d3ab9 | |||
| 8fcc0f4e54 | |||
| 524e686b3a | |||
| 540f59dcf5 | |||
| 773c7bbd1c | |||
| b60703aa16 | |||
| c749ed6f85 | |||
| af6732db1c | |||
| b23dd85d0f | |||
| 160546d64d | |||
| cfaadd9d33 | |||
| 5e7fd8b79c | |||
| d56fa58157 | |||
| c803591ebb | |||
| d2e28b0415 | |||
| 38fad92f2e | |||
| d010392a3c | |||
| 80c392c24b | |||
| 60bc7618d3 | |||
| 55878707f2 | |||
| f6132bdd70 | |||
| 2c1765effa | |||
| f6e7330ad6 | |||
| af6016b9a9 | |||
| c7fabf3424 | |||
| 152536901b | |||
| dbd17a7946 | |||
| 83c756618f | |||
| e0d338a030 | |||
| 9a769518f9 | |||
| f1af4d2cdb | |||
| 3c518e4c5a | |||
| 53167e35b6 | |||
| 5a83c4c1d1 | |||
| 3fe837653b | |||
| 636126e7c6 | |||
| b46b65ed2a | |||
| 122d88c48d | |||
| 07523a49e7 | |||
| fb751c8691 | |||
| 5af536dea2 | |||
| b342595a09 | |||
| c92a29ab85 | |||
| 53fb3eb759 | |||
| b75b9562af | |||
| 8d249cf89b | |||
| a943d9622e | |||
| 467c504071 | |||
| 3bb1fa6e51 | |||
| ed70b47c81 | |||
| c95c82169f | |||
| bbbd8ff64a | |||
| 65736ccf84 | |||
| 75336656c2 | |||
| 96489c8f72 | |||
| 9b5759d794 | |||
| 3284354f40 | |||
| 266a625cf3 | |||
| 243f76ce05 | |||
| e01014a89a | |||
| 9d9dd5be38 | |||
| 9ff024cf9b | |||
| e337eb35e7 | |||
| a07a87a35f | |||
| 5c805c60d7 | |||
| b305df3d79 | |||
| 33ee1822a5 | |||
| 2cee1ba686 | |||
| c283887ada | |||
| 4235862d86 | |||
| 74fe999496 | |||
| cd8182425a | |||
| 7626f97695 | |||
| 19555be975 | |||
| 0aaa3efbb0 | |||
| f1902e18d3 | |||
| 39ca7de169 | |||
| 7c14ce7634 | |||
| d382c9e83a | |||
| d54d9218c1 | |||
| 7348bd38b1 | |||
| 2af0b67714 | |||
| 3e8076e416 | |||
| ceee3228c3 | |||
| 255cd34380 | |||
| 83fd4d028e | |||
| efacda2976 | |||
| ccce0df79d | |||
| 8452033473 | |||
| bc66f0a34c | |||
| cda987c2cb | |||
| ea202a2ab0 | |||
| dd77f6d92d | |||
| c356aebfde | |||
| 5b4a6ddd14 | |||
| 96e7fb6bc4 | |||
| dfd024cab7 | |||
| 03c0baf5b5 | |||
| b5fe6a1437 | |||
| 2e94bd90b0 | |||
| 92d80d1dfe | |||
| 971f40813f | |||
| 55383a2aa4 | |||
| 07287d2939 | |||
| c3f8ab5fb4 | |||
| 1903d77ac1 | |||
| 029b228025 | |||
| 9b730c310e | |||
| 8cd0ec92c0 | |||
| e1c4987db5 | |||
| bdba58312c | |||
| 6c9ec9a05f | |||
| f6679c5d66 | |||
| 2aa58670e3 | |||
| eb3969b952 | |||
| 44d1e9af24 | |||
| c2e6dfe88b | |||
| 17027b3968 | |||
| f841d8ba06 | |||
| aac9524316 | |||
| aee7433641 | |||
| 7729868939 | |||
| 89e4795e86 | |||
| 00a90f1c15 | |||
| 845c1134fe | |||
| 4d0d837e14 | |||
| f1f1b28b31 | |||
| 7e4f8d0e46 | |||
| db5237480a | |||
| 4c633a895f | |||
| 0520ef872e | |||
| 556058bfe9 | |||
| c7a9f7bc5a | |||
| 322885b908 | |||
| a9ce70d292 | |||
| 4dfb81af89 | |||
| 5fa2c5b6b0 | |||
| 324d1feda1 | |||
| 5456c9414a | |||
| 66933433d1 | |||
| 1b32a91b0d | |||
| bde64e7dc5 | |||
| 4ae8e28b2f | |||
| 87fd59549d | |||
| 016d050678 | |||
| 2d609f6b7a | |||
| 73470ded79 | |||
| ac83ceb2cb | |||
| b1a982aaa0 | |||
| 6f5fa762a4 | |||
| 04f5e19ab2 | |||
| f75ea4bb97 | |||
| a1ddb4a170 | |||
| 1433e07066 | |||
| 74f178f271 | |||
| a88904ed0f | |||
| 1bb5ba0061 |
10
.cargo/config.toml
Normal file
10
.cargo/config.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[env]
|
||||
MACOSX_DEPLOYMENT_TARGET = "12.0"
|
||||
|
||||
[alias]
|
||||
xtask = "run --package xtask --release --"
|
||||
|
||||
[target.x86_64-pc-windows-gnu]
|
||||
rustflags = [
|
||||
"-C", "link-args=-Wl,-Bstatic -lstdc++ -lgcc -lgcc_eh -lpthread -Wl,-Bdynamic -lmingwex -lmsvcrt -lws2_32 -liphlpapi -lwinmm -lole32 -loleaut32 -luuid -lkernel32",
|
||||
]
|
||||
135
.github/workflows/assemble-macos.yml
vendored
Normal file
135
.github/workflows/assemble-macos.yml
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
name: Assemble macOS Universal
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
assemble:
|
||||
runs-on: macos-14
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Download macOS artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: cagire-macos-*
|
||||
path: artifacts
|
||||
|
||||
- name: Create universal CLI binary
|
||||
run: |
|
||||
lipo -create \
|
||||
artifacts/cagire-macos-x86_64/cagire \
|
||||
artifacts/cagire-macos-aarch64/cagire \
|
||||
-output cagire
|
||||
chmod +x cagire
|
||||
lipo -info cagire
|
||||
|
||||
- name: Create universal app bundle
|
||||
run: |
|
||||
cd artifacts/cagire-macos-aarch64-desktop
|
||||
unzip Cagire.app.zip
|
||||
cd ../cagire-macos-x86_64-desktop
|
||||
unzip Cagire.app.zip
|
||||
cd ../..
|
||||
cp -R artifacts/cagire-macos-aarch64-desktop/Cagire.app Cagire.app
|
||||
lipo -create \
|
||||
artifacts/cagire-macos-x86_64-desktop/Cagire.app/Contents/MacOS/cagire-desktop \
|
||||
artifacts/cagire-macos-aarch64-desktop/Cagire.app/Contents/MacOS/cagire-desktop \
|
||||
-output Cagire.app/Contents/MacOS/cagire-desktop
|
||||
lipo -info Cagire.app/Contents/MacOS/cagire-desktop
|
||||
zip -r Cagire.app.zip Cagire.app
|
||||
|
||||
- name: Create universal CLAP plugin
|
||||
run: |
|
||||
mkdir -p cagire-plugins.clap/Contents/MacOS
|
||||
cp artifacts/cagire-macos-aarch64-clap/cagire-plugins.clap/Contents/Info.plist \
|
||||
cagire-plugins.clap/Contents/ 2>/dev/null || true
|
||||
cp artifacts/cagire-macos-aarch64-clap/cagire-plugins.clap/Contents/PkgInfo \
|
||||
cagire-plugins.clap/Contents/ 2>/dev/null || true
|
||||
lipo -create \
|
||||
artifacts/cagire-macos-x86_64-clap/cagire-plugins.clap/Contents/MacOS/cagire-plugins \
|
||||
artifacts/cagire-macos-aarch64-clap/cagire-plugins.clap/Contents/MacOS/cagire-plugins \
|
||||
-output cagire-plugins.clap/Contents/MacOS/cagire-plugins
|
||||
lipo -info cagire-plugins.clap/Contents/MacOS/cagire-plugins
|
||||
|
||||
- name: Create universal VST3 plugin
|
||||
run: |
|
||||
mkdir -p cagire-plugins.vst3/Contents/MacOS
|
||||
cp -R artifacts/cagire-macos-aarch64-vst3/cagire-plugins.vst3/Contents/Info.plist \
|
||||
cagire-plugins.vst3/Contents/ 2>/dev/null || true
|
||||
cp artifacts/cagire-macos-aarch64-vst3/cagire-plugins.vst3/Contents/PkgInfo \
|
||||
cagire-plugins.vst3/Contents/ 2>/dev/null || true
|
||||
cp -R artifacts/cagire-macos-aarch64-vst3/cagire-plugins.vst3/Contents/Resources \
|
||||
cagire-plugins.vst3/Contents/ 2>/dev/null || true
|
||||
lipo -create \
|
||||
artifacts/cagire-macos-x86_64-vst3/cagire-plugins.vst3/Contents/MacOS/cagire-plugins \
|
||||
artifacts/cagire-macos-aarch64-vst3/cagire-plugins.vst3/Contents/MacOS/cagire-plugins \
|
||||
-output cagire-plugins.vst3/Contents/MacOS/cagire-plugins
|
||||
lipo -info cagire-plugins.vst3/Contents/MacOS/cagire-plugins
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
assets/DMG-README.txt
|
||||
scripts/make-dmg.sh
|
||||
clean: false
|
||||
|
||||
- name: Create DMG
|
||||
run: |
|
||||
chmod +x scripts/make-dmg.sh
|
||||
scripts/make-dmg.sh Cagire.app .
|
||||
|
||||
- name: Build .pkg installer
|
||||
run: |
|
||||
VERSION="${GITHUB_REF_NAME#v}"
|
||||
mkdir -p pkg-root/Applications pkg-root/usr/local/bin
|
||||
cp -R Cagire.app pkg-root/Applications/
|
||||
cp cagire pkg-root/usr/local/bin/
|
||||
pkgbuild --analyze --root pkg-root component.plist
|
||||
plutil -replace BundleIsRelocatable -bool NO component.plist
|
||||
pkgbuild --root pkg-root --identifier com.sova.cagire \
|
||||
--version "$VERSION" --install-location / \
|
||||
--component-plist component.plist \
|
||||
"Cagire-${VERSION}-universal.pkg"
|
||||
|
||||
- name: Upload universal CLI
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-macos-universal
|
||||
path: cagire
|
||||
|
||||
- name: Upload universal app bundle
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-macos-universal-desktop
|
||||
path: Cagire.app.zip
|
||||
|
||||
- name: Prepare universal plugin staging
|
||||
run: |
|
||||
mkdir -p staging/clap staging/vst3
|
||||
cp -R cagire-plugins.clap staging/clap/
|
||||
cp -R cagire-plugins.vst3 staging/vst3/
|
||||
|
||||
- name: Upload universal CLAP plugin
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-macos-universal-clap
|
||||
path: staging/clap/
|
||||
|
||||
- name: Upload universal VST3 plugin
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-macos-universal-vst3
|
||||
path: staging/vst3/
|
||||
|
||||
- name: Upload DMG
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-macos-universal-dmg
|
||||
path: Cagire-*.dmg
|
||||
|
||||
- name: Upload .pkg installer
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-macos-universal-pkg
|
||||
path: Cagire-*-universal.pkg
|
||||
49
.github/workflows/build-cross.yml
vendored
Normal file
49
.github/workflows/build-cross.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
name: Build Cross (Linux ARM64)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: aarch64-unknown-linux-gnu
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: aarch64-unknown-linux-gnu
|
||||
|
||||
- name: Install cross
|
||||
run: cargo install cross --git https://github.com/cross-rs/cross
|
||||
|
||||
- name: Build
|
||||
run: cross build --release --target aarch64-unknown-linux-gnu
|
||||
|
||||
- name: Build desktop
|
||||
run: cross build --release --features desktop --bin cagire-desktop --target aarch64-unknown-linux-gnu
|
||||
|
||||
- name: Upload CLI artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-linux-aarch64
|
||||
path: target/aarch64-unknown-linux-gnu/release/cagire
|
||||
|
||||
- name: Upload desktop artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-linux-aarch64-desktop
|
||||
path: target/aarch64-unknown-linux-gnu/release/cagire-desktop
|
||||
131
.github/workflows/build-linux.yml
vendored
Normal file
131
.github/workflows/build-linux.yml
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
name: Build Linux
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
run-tests:
|
||||
type: boolean
|
||||
default: false
|
||||
run-clippy:
|
||||
type: boolean
|
||||
default: false
|
||||
build-packages:
|
||||
type: boolean
|
||||
default: false
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
run-tests:
|
||||
type: boolean
|
||||
default: true
|
||||
run-clippy:
|
||||
type: boolean
|
||||
default: true
|
||||
build-packages:
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: x86_64-unknown-linux-gnu
|
||||
components: clippy
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential cmake pkg-config libasound2-dev libclang-dev libjack-dev \
|
||||
libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev libgl1-mesa-dev \
|
||||
libx11-dev libx11-xcb-dev libxcursor-dev libxrandr-dev libxi-dev libwayland-dev
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release --target x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Build desktop
|
||||
run: cargo build --release --features desktop --bin cagire-desktop --target x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Test
|
||||
if: inputs.run-tests
|
||||
run: cargo test --target x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Clippy
|
||||
if: inputs.run-clippy
|
||||
run: cargo clippy --target x86_64-unknown-linux-gnu -- -D warnings
|
||||
|
||||
- name: Install cargo-bundle
|
||||
if: inputs.build-packages
|
||||
run: cargo install cargo-bundle
|
||||
|
||||
- name: Bundle desktop app
|
||||
if: inputs.build-packages
|
||||
run: cargo bundle --release --features desktop --bin cagire-desktop --target x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Build AppImages
|
||||
if: inputs.build-packages
|
||||
run: |
|
||||
mkdir -p target/releases
|
||||
scripts/make-appimage.sh target/x86_64-unknown-linux-gnu/release/cagire x86_64 target/releases
|
||||
scripts/make-appimage.sh target/x86_64-unknown-linux-gnu/release/cagire-desktop x86_64 target/releases
|
||||
|
||||
- name: Bundle CLAP plugin
|
||||
if: inputs.build-packages
|
||||
run: cargo xtask bundle cagire-plugins --release --target x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Upload CLI artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-linux-x86_64
|
||||
path: target/x86_64-unknown-linux-gnu/release/cagire
|
||||
|
||||
- name: Upload desktop artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-linux-x86_64-desktop
|
||||
path: target/x86_64-unknown-linux-gnu/release/bundle/deb/*.deb
|
||||
|
||||
- name: Upload AppImage artifacts
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-linux-x86_64-appimage
|
||||
path: target/releases/*.AppImage
|
||||
|
||||
- name: Prepare plugin artifacts
|
||||
if: inputs.build-packages
|
||||
run: |
|
||||
mkdir -p staging/clap staging/vst3
|
||||
cp -R target/bundled/cagire-plugins.clap staging/clap/
|
||||
cp -R target/bundled/cagire-plugins.vst3 staging/vst3/
|
||||
|
||||
- name: Upload CLAP artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-linux-x86_64-clap
|
||||
path: staging/clap/
|
||||
|
||||
- name: Upload VST3 artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-linux-x86_64-vst3
|
||||
path: staging/vst3/
|
||||
127
.github/workflows/build-macos.yml
vendored
Normal file
127
.github/workflows/build-macos.yml
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
name: Build macOS
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
run-tests:
|
||||
type: boolean
|
||||
default: false
|
||||
run-clippy:
|
||||
type: boolean
|
||||
default: false
|
||||
build-packages:
|
||||
type: boolean
|
||||
default: false
|
||||
matrix:
|
||||
type: string
|
||||
default: '[{"os":"macos-14","target":"aarch64-apple-darwin","artifact":"cagire-macos-aarch64"}]'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
run-tests:
|
||||
type: boolean
|
||||
default: true
|
||||
run-clippy:
|
||||
type: boolean
|
||||
default: true
|
||||
build-packages:
|
||||
type: boolean
|
||||
default: false
|
||||
matrix:
|
||||
type: string
|
||||
default: '[{"os":"macos-14","target":"aarch64-apple-darwin","artifact":"cagire-macos-aarch64"}]'
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
MACOSX_DEPLOYMENT_TARGET: "12.0"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: ${{ fromJSON(inputs.matrix) }}
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
components: clippy
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: ${{ matrix.target }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: brew list cmake &>/dev/null || brew install cmake
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Build desktop
|
||||
run: cargo build --release --features desktop --bin cagire-desktop --target ${{ matrix.target }}
|
||||
|
||||
- name: Test
|
||||
if: inputs.run-tests
|
||||
run: cargo test --target ${{ matrix.target }}
|
||||
|
||||
- name: Clippy
|
||||
if: inputs.run-clippy
|
||||
run: cargo clippy --target ${{ matrix.target }} -- -D warnings
|
||||
|
||||
- name: Bundle desktop app
|
||||
if: inputs.build-packages
|
||||
run: scripts/make-app-bundle.sh ${{ matrix.target }}
|
||||
|
||||
- name: Bundle CLAP plugin
|
||||
if: inputs.build-packages
|
||||
run: cargo xtask bundle cagire-plugins --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Zip macOS app bundle
|
||||
if: inputs.build-packages
|
||||
run: |
|
||||
cd target/${{ matrix.target }}/release/bundle/osx
|
||||
zip -r Cagire.app.zip Cagire.app
|
||||
|
||||
- name: Upload CLI artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}
|
||||
path: target/${{ matrix.target }}/release/cagire
|
||||
|
||||
- name: Upload desktop artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}-desktop
|
||||
path: target/${{ matrix.target }}/release/bundle/osx/Cagire.app.zip
|
||||
|
||||
- name: Prepare plugin artifacts
|
||||
if: inputs.build-packages
|
||||
run: |
|
||||
mkdir -p staging/clap staging/vst3
|
||||
cp -R target/bundled/cagire-plugins.clap staging/clap/
|
||||
cp -R target/bundled/cagire-plugins.vst3 staging/vst3/
|
||||
|
||||
- name: Upload CLAP artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}-clap
|
||||
path: staging/clap/
|
||||
|
||||
- name: Upload VST3 artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}-vst3
|
||||
path: staging/vst3/
|
||||
56
.github/workflows/build-plugins-linux.yml
vendored
Normal file
56
.github/workflows/build-plugins-linux.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
name: Build Plugins Linux
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: x86_64-unknown-linux-gnu-plugins
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential cmake pkg-config libasound2-dev libclang-dev libjack-dev \
|
||||
libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev libgl1-mesa-dev \
|
||||
libx11-dev libx11-xcb-dev libxcursor-dev libxrandr-dev libxi-dev libwayland-dev
|
||||
|
||||
- name: Build plugins
|
||||
run: cargo xtask bundle cagire-plugins --release --target x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Prepare plugin artifacts
|
||||
run: |
|
||||
mkdir -p staging/clap staging/vst3
|
||||
cp -R target/bundled/cagire-plugins.clap staging/clap/
|
||||
cp -R target/bundled/cagire-plugins.vst3 staging/vst3/
|
||||
|
||||
- name: Upload CLAP artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: plugins-linux-x86_64-clap
|
||||
path: staging/clap/
|
||||
|
||||
- name: Upload VST3 artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: plugins-linux-x86_64-vst3
|
||||
path: staging/vst3/
|
||||
66
.github/workflows/build-plugins-macos.yml
vendored
Normal file
66
.github/workflows/build-plugins-macos.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
name: Build Plugins macOS
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
matrix:
|
||||
type: string
|
||||
default: '[{"os":"macos-14","target":"aarch64-apple-darwin","artifact":"plugins-macos-aarch64"},{"os":"macos-15-intel","target":"x86_64-apple-darwin","artifact":"plugins-macos-x86_64"}]'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
matrix:
|
||||
type: string
|
||||
default: '[{"os":"macos-14","target":"aarch64-apple-darwin","artifact":"plugins-macos-aarch64"}]'
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
MACOSX_DEPLOYMENT_TARGET: "12.0"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include: ${{ fromJSON(inputs.matrix) }}
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: ${{ matrix.target }}-plugins
|
||||
|
||||
- name: Install dependencies
|
||||
run: brew list cmake &>/dev/null || brew install cmake
|
||||
|
||||
- name: Build plugins
|
||||
run: cargo xtask bundle cagire-plugins --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Prepare plugin artifacts
|
||||
run: |
|
||||
mkdir -p staging/clap staging/vst3
|
||||
cp -R target/bundled/cagire-plugins.clap staging/clap/
|
||||
cp -R target/bundled/cagire-plugins.vst3 staging/vst3/
|
||||
|
||||
- name: Upload CLAP artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}-clap
|
||||
path: staging/clap/
|
||||
|
||||
- name: Upload VST3 artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}-vst3
|
||||
path: staging/vst3/
|
||||
59
.github/workflows/build-plugins-rpi.yml
vendored
Normal file
59
.github/workflows/build-plugins-rpi.yml
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
name: Build Plugins RPi
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: aarch64-unknown-linux-gnu
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: aarch64-unknown-linux-gnu-plugins
|
||||
|
||||
- name: Install cross
|
||||
run: cargo install cross --git https://github.com/cross-rs/cross
|
||||
|
||||
- name: Build plugins
|
||||
run: cross build --release -p cagire-plugins --target aarch64-unknown-linux-gnu
|
||||
|
||||
- name: Prepare plugin artifacts
|
||||
run: |
|
||||
mkdir -p target/bundled
|
||||
# CLAP: single .so renamed to .clap
|
||||
cp target/aarch64-unknown-linux-gnu/release/libcagire_plugins.so target/bundled/cagire-plugins.clap
|
||||
# VST3: correct directory structure
|
||||
mkdir -p "target/bundled/cagire-plugins.vst3/Contents/aarch64-linux"
|
||||
cp target/aarch64-unknown-linux-gnu/release/libcagire_plugins.so "target/bundled/cagire-plugins.vst3/Contents/aarch64-linux/cagire-plugins.so"
|
||||
|
||||
mkdir -p staging/clap staging/vst3
|
||||
cp -R target/bundled/cagire-plugins.clap staging/clap/
|
||||
cp -R target/bundled/cagire-plugins.vst3 staging/vst3/
|
||||
|
||||
- name: Upload CLAP artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: plugins-linux-aarch64-clap
|
||||
path: staging/clap/
|
||||
|
||||
- name: Upload VST3 artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: plugins-linux-aarch64-vst3
|
||||
path: staging/vst3/
|
||||
59
.github/workflows/build-plugins-windows.yml
vendored
Normal file
59
.github/workflows/build-plugins-windows.yml
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
name: Build Plugins Windows
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: x86_64-pc-windows-msvc
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: x86_64-pc-windows-msvc-plugins
|
||||
|
||||
- name: Install dependencies
|
||||
shell: pwsh
|
||||
run: |
|
||||
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
|
||||
echo "C:\Program Files\CMake\bin" >> $env:GITHUB_PATH
|
||||
|
||||
- name: Build plugins
|
||||
run: cargo xtask bundle cagire-plugins --release --target x86_64-pc-windows-msvc
|
||||
|
||||
- name: Prepare plugin artifacts
|
||||
run: |
|
||||
mkdir -p staging/clap staging/vst3
|
||||
cp -R target/bundled/cagire-plugins.clap staging/clap/
|
||||
cp -R target/bundled/cagire-plugins.vst3 staging/vst3/
|
||||
|
||||
- name: Upload CLAP artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: plugins-windows-x86_64-clap
|
||||
path: staging/clap/
|
||||
|
||||
- name: Upload VST3 artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: plugins-windows-x86_64-vst3
|
||||
path: staging/vst3/
|
||||
18
.github/workflows/build-plugins.yml
vendored
Normal file
18
.github/workflows/build-plugins.yml
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
name: Build Plugins
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
uses: ./.github/workflows/build-plugins-linux.yml
|
||||
|
||||
macos:
|
||||
uses: ./.github/workflows/build-plugins-macos.yml
|
||||
|
||||
windows:
|
||||
uses: ./.github/workflows/build-plugins-windows.yml
|
||||
|
||||
rpi:
|
||||
uses: ./.github/workflows/build-plugins-rpi.yml
|
||||
133
.github/workflows/build-windows.yml
vendored
Normal file
133
.github/workflows/build-windows.yml
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
name: Build Windows
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
run-tests:
|
||||
type: boolean
|
||||
default: false
|
||||
run-clippy:
|
||||
type: boolean
|
||||
default: false
|
||||
build-packages:
|
||||
type: boolean
|
||||
default: false
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
run-tests:
|
||||
type: boolean
|
||||
default: true
|
||||
run-clippy:
|
||||
type: boolean
|
||||
default: true
|
||||
build-packages:
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: x86_64-pc-windows-msvc
|
||||
components: clippy
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: x86_64-pc-windows-msvc
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
|
||||
echo "C:\Program Files\CMake\bin" >> $env:GITHUB_PATH
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release --target x86_64-pc-windows-msvc
|
||||
|
||||
- name: Build desktop
|
||||
run: cargo build --release --features desktop --bin cagire-desktop --target x86_64-pc-windows-msvc
|
||||
|
||||
- name: Test
|
||||
if: inputs.run-tests
|
||||
run: cargo test --target x86_64-pc-windows-msvc
|
||||
|
||||
- name: Clippy
|
||||
if: inputs.run-clippy
|
||||
run: cargo clippy --target x86_64-pc-windows-msvc -- -D warnings
|
||||
|
||||
- name: Bundle CLAP plugin
|
||||
if: inputs.build-packages
|
||||
run: cargo xtask bundle cagire-plugins --release --target x86_64-pc-windows-msvc
|
||||
|
||||
- name: Install NSIS
|
||||
if: inputs.build-packages
|
||||
run: choco install nsis
|
||||
|
||||
- name: Build NSIS installer
|
||||
if: inputs.build-packages
|
||||
shell: pwsh
|
||||
run: |
|
||||
$version = (Select-String -Path Cargo.toml -Pattern '^version\s*=\s*"(.+)"' | Select-Object -First 1).Matches.Groups[1].Value
|
||||
$root = (Get-Location).Path
|
||||
$target = "x86_64-pc-windows-msvc"
|
||||
& "C:\Program Files (x86)\NSIS\makensis.exe" `
|
||||
"-DVERSION=$version" `
|
||||
"-DCLI_EXE=$root\target\$target\release\cagire.exe" `
|
||||
"-DDESKTOP_EXE=$root\target\$target\release\cagire-desktop.exe" `
|
||||
"-DICON=$root\assets\Cagire.ico" `
|
||||
"-DOUTDIR=$root\target" `
|
||||
nsis/cagire.nsi
|
||||
|
||||
- name: Upload CLI artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-windows-x86_64
|
||||
path: target/x86_64-pc-windows-msvc/release/cagire.exe
|
||||
|
||||
- name: Upload desktop artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-windows-x86_64-desktop
|
||||
path: target/x86_64-pc-windows-msvc/release/cagire-desktop.exe
|
||||
|
||||
- name: Upload installer artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-windows-x86_64-installer
|
||||
path: target/cagire-*-setup.exe
|
||||
|
||||
- name: Prepare plugin artifacts
|
||||
if: inputs.build-packages
|
||||
run: |
|
||||
mkdir -p staging/clap staging/vst3
|
||||
cp -R target/bundled/cagire-plugins.clap staging/clap/
|
||||
cp -R target/bundled/cagire-plugins.vst3 staging/vst3/
|
||||
|
||||
- name: Upload CLAP artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-windows-x86_64-clap
|
||||
path: staging/clap/
|
||||
|
||||
- name: Upload VST3 artifact
|
||||
if: inputs.build-packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-windows-x86_64-vst3
|
||||
path: staging/vst3/
|
||||
307
.github/workflows/ci.yml
vendored
307
.github/workflows/ci.yml
vendored
@@ -1,305 +1,28 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags: ['v*']
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-gnu
|
||||
artifact: cagire-linux-x86_64
|
||||
- os: macos-15-intel
|
||||
target: x86_64-apple-darwin
|
||||
artifact: cagire-macos-x86_64
|
||||
- os: macos-14
|
||||
target: aarch64-apple-darwin
|
||||
artifact: cagire-macos-aarch64
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
artifact: cagire-windows-x86_64
|
||||
linux:
|
||||
uses: ./.github/workflows/build-linux.yml
|
||||
with:
|
||||
run-tests: true
|
||||
run-clippy: true
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 30
|
||||
macos:
|
||||
uses: ./.github/workflows/build-macos.yml
|
||||
with:
|
||||
run-tests: true
|
||||
run-clippy: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Cache Rust dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
key: ${{ matrix.target }}
|
||||
|
||||
- name: Install dependencies (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential cmake pkg-config libasound2-dev libclang-dev libjack-dev \
|
||||
libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev libgl1-mesa-dev
|
||||
cargo install cargo-bundle
|
||||
|
||||
- name: Install dependencies (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
brew list cmake &>/dev/null || brew install cmake
|
||||
cargo install cargo-bundle
|
||||
|
||||
- name: Install dependencies (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
run: |
|
||||
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
|
||||
echo "C:\Program Files\CMake\bin" >> $env:GITHUB_PATH
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Build desktop
|
||||
run: cargo build --release --features desktop --bin cagire-desktop --target ${{ matrix.target }}
|
||||
|
||||
- name: Bundle desktop app
|
||||
if: runner.os != 'Windows'
|
||||
run: cargo bundle --release --features desktop --bin cagire-desktop --target ${{ matrix.target }}
|
||||
|
||||
- name: Bundle CLAP plugin
|
||||
run: cargo xtask bundle cagire-plugins --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Zip macOS app bundle
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
cd target/${{ matrix.target }}/release/bundle/osx
|
||||
zip -r Cagire.app.zip Cagire.app
|
||||
|
||||
- name: Upload artifact (Unix)
|
||||
if: runner.os != 'Windows'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}
|
||||
path: target/${{ matrix.target }}/release/cagire
|
||||
|
||||
- name: Upload artifact (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}
|
||||
path: target/${{ matrix.target }}/release/cagire.exe
|
||||
|
||||
- name: Upload desktop artifact (Linux deb)
|
||||
if: runner.os == 'Linux'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}-desktop
|
||||
path: target/${{ matrix.target }}/release/bundle/deb/*.deb
|
||||
|
||||
- name: Upload desktop artifact (macOS app bundle)
|
||||
if: runner.os == 'macOS'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}-desktop
|
||||
path: target/${{ matrix.target }}/release/bundle/osx/Cagire.app.zip
|
||||
|
||||
- name: Upload desktop artifact (Windows exe)
|
||||
if: runner.os == 'Windows'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}-desktop
|
||||
path: target/${{ matrix.target }}/release/cagire-desktop.exe
|
||||
|
||||
- name: Upload CLAP artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}-clap
|
||||
path: target/bundled/cagire-plugins.clap
|
||||
|
||||
- name: Upload VST3 artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}-vst3
|
||||
path: target/bundled/cagire-plugins.vst3
|
||||
|
||||
universal-macos:
|
||||
needs: build
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
runs-on: macos-14
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Download macOS artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: cagire-macos-*
|
||||
path: artifacts
|
||||
|
||||
- name: Create universal CLI binary
|
||||
run: |
|
||||
lipo -create \
|
||||
artifacts/cagire-macos-x86_64/cagire \
|
||||
artifacts/cagire-macos-aarch64/cagire \
|
||||
-output cagire
|
||||
chmod +x cagire
|
||||
lipo -info cagire
|
||||
|
||||
- name: Create universal app bundle
|
||||
run: |
|
||||
cd artifacts/cagire-macos-aarch64-desktop
|
||||
unzip Cagire.app.zip
|
||||
cd ../cagire-macos-x86_64-desktop
|
||||
unzip Cagire.app.zip
|
||||
cd ../..
|
||||
cp -R artifacts/cagire-macos-aarch64-desktop/Cagire.app Cagire.app
|
||||
lipo -create \
|
||||
artifacts/cagire-macos-x86_64-desktop/Cagire.app/Contents/MacOS/cagire-desktop \
|
||||
artifacts/cagire-macos-aarch64-desktop/Cagire.app/Contents/MacOS/cagire-desktop \
|
||||
-output Cagire.app/Contents/MacOS/cagire-desktop
|
||||
lipo -info Cagire.app/Contents/MacOS/cagire-desktop
|
||||
zip -r Cagire.app.zip Cagire.app
|
||||
|
||||
- name: Create universal CLAP plugin
|
||||
run: |
|
||||
mkdir -p cagire-plugins.clap/Contents/MacOS
|
||||
cp artifacts/cagire-macos-aarch64-clap/cagire-plugins.clap/Contents/Info.plist \
|
||||
cagire-plugins.clap/Contents/ 2>/dev/null || true
|
||||
cp artifacts/cagire-macos-aarch64-clap/cagire-plugins.clap/Contents/PkgInfo \
|
||||
cagire-plugins.clap/Contents/ 2>/dev/null || true
|
||||
lipo -create \
|
||||
artifacts/cagire-macos-x86_64-clap/cagire-plugins.clap/Contents/MacOS/cagire-plugins \
|
||||
artifacts/cagire-macos-aarch64-clap/cagire-plugins.clap/Contents/MacOS/cagire-plugins \
|
||||
-output cagire-plugins.clap/Contents/MacOS/cagire-plugins
|
||||
lipo -info cagire-plugins.clap/Contents/MacOS/cagire-plugins
|
||||
|
||||
- name: Create universal VST3 plugin
|
||||
run: |
|
||||
mkdir -p cagire-plugins.vst3/Contents/MacOS
|
||||
cp -R artifacts/cagire-macos-aarch64-vst3/cagire-plugins.vst3/Contents/Info.plist \
|
||||
cagire-plugins.vst3/Contents/ 2>/dev/null || true
|
||||
cp artifacts/cagire-macos-aarch64-vst3/cagire-plugins.vst3/Contents/PkgInfo \
|
||||
cagire-plugins.vst3/Contents/ 2>/dev/null || true
|
||||
cp -R artifacts/cagire-macos-aarch64-vst3/cagire-plugins.vst3/Contents/Resources \
|
||||
cagire-plugins.vst3/Contents/ 2>/dev/null || true
|
||||
lipo -create \
|
||||
artifacts/cagire-macos-x86_64-vst3/cagire-plugins.vst3/Contents/MacOS/cagire-plugins \
|
||||
artifacts/cagire-macos-aarch64-vst3/cagire-plugins.vst3/Contents/MacOS/cagire-plugins \
|
||||
-output cagire-plugins.vst3/Contents/MacOS/cagire-plugins
|
||||
lipo -info cagire-plugins.vst3/Contents/MacOS/cagire-plugins
|
||||
|
||||
- name: Build .pkg installer
|
||||
run: |
|
||||
VERSION="${GITHUB_REF_NAME#v}"
|
||||
mkdir -p pkg-root/Applications pkg-root/usr/local/bin
|
||||
cp -R Cagire.app pkg-root/Applications/
|
||||
cp cagire pkg-root/usr/local/bin/
|
||||
pkgbuild --analyze --root pkg-root component.plist
|
||||
plutil -replace BundleIsRelocatable -bool NO component.plist
|
||||
pkgbuild --root pkg-root --identifier com.sova.cagire \
|
||||
--version "$VERSION" --install-location / \
|
||||
--component-plist component.plist \
|
||||
"Cagire-${VERSION}-universal.pkg"
|
||||
|
||||
- name: Upload universal CLI
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-macos-universal
|
||||
path: cagire
|
||||
|
||||
- name: Upload universal app bundle
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-macos-universal-desktop
|
||||
path: Cagire.app.zip
|
||||
|
||||
- name: Upload universal CLAP plugin
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-macos-universal-clap
|
||||
path: cagire-plugins.clap
|
||||
|
||||
- name: Upload universal VST3 plugin
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-macos-universal-vst3
|
||||
path: cagire-plugins.vst3
|
||||
|
||||
- name: Upload .pkg installer
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cagire-macos-universal-pkg
|
||||
path: Cagire-*-universal.pkg
|
||||
|
||||
release:
|
||||
needs: [build, universal-macos]
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Prepare release files
|
||||
run: |
|
||||
mkdir -p release
|
||||
for dir in artifacts/*/; do
|
||||
name=$(basename "$dir")
|
||||
if [[ "$name" == "cagire-macos-universal-pkg" ]]; then
|
||||
cp "$dir"/*.pkg release/
|
||||
elif [[ "$name" == "cagire-macos-universal-desktop" ]]; then
|
||||
cp "$dir/Cagire.app.zip" "release/cagire-macos-universal-desktop.app.zip"
|
||||
elif [[ "$name" == "cagire-macos-universal" ]]; then
|
||||
cp "$dir/cagire" "release/cagire-macos-universal"
|
||||
elif [[ "$name" == "cagire-macos-universal-clap" ]]; then
|
||||
cd "$dir" && zip -r "../../release/cagire-macos-universal-clap.zip" cagire-plugins.clap && cd ../..
|
||||
elif [[ "$name" == "cagire-macos-universal-vst3" ]]; then
|
||||
cd "$dir" && zip -r "../../release/cagire-macos-universal-vst3.zip" cagire-plugins.vst3 && cd ../..
|
||||
elif [[ "$name" == *-clap ]]; then
|
||||
base="${name%-clap}"
|
||||
cd "$dir" && zip -r "../../release/${base}-clap.zip" cagire-plugins.clap && cd ../..
|
||||
elif [[ "$name" == *-vst3 ]]; then
|
||||
base="${name%-vst3}"
|
||||
cd "$dir" && zip -r "../../release/${base}-vst3.zip" cagire-plugins.vst3 && cd ../..
|
||||
elif [[ "$name" == *-desktop ]]; then
|
||||
base="${name%-desktop}"
|
||||
if ls "$dir"/*.deb 1>/dev/null 2>&1; then
|
||||
cp "$dir"/*.deb "release/${base}-desktop.deb"
|
||||
elif [ -f "$dir/Cagire.app.zip" ]; then
|
||||
cp "$dir/Cagire.app.zip" "release/${base}-desktop.app.zip"
|
||||
elif [ -f "$dir/cagire-desktop.exe" ]; then
|
||||
cp "$dir/cagire-desktop.exe" "release/${base}-desktop.exe"
|
||||
fi
|
||||
else
|
||||
if [ -f "$dir/cagire.exe" ]; then
|
||||
cp "$dir/cagire.exe" "release/${name}.exe"
|
||||
elif [ -f "$dir/cagire" ]; then
|
||||
cp "$dir/cagire" "release/${name}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: release/*
|
||||
generate_release_notes: true
|
||||
windows:
|
||||
uses: ./.github/workflows/build-windows.yml
|
||||
with:
|
||||
run-tests: true
|
||||
run-clippy: true
|
||||
|
||||
1
.github/workflows/pages.yml
vendored
1
.github/workflows/pages.yml
vendored
@@ -16,6 +16,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
if: github.server_url == 'https://github.com'
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
|
||||
107
.github/workflows/release.yml
vendored
Normal file
107
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags: ['v*']
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
if: github.server_url == 'https://github.com'
|
||||
uses: ./.github/workflows/build-linux.yml
|
||||
with:
|
||||
build-packages: true
|
||||
|
||||
macos:
|
||||
if: github.server_url == 'https://github.com'
|
||||
uses: ./.github/workflows/build-macos.yml
|
||||
with:
|
||||
build-packages: true
|
||||
matrix: >-
|
||||
[
|
||||
{"os":"macos-14","target":"aarch64-apple-darwin","artifact":"cagire-macos-aarch64"},
|
||||
{"os":"macos-15-intel","target":"x86_64-apple-darwin","artifact":"cagire-macos-x86_64"}
|
||||
]
|
||||
|
||||
windows:
|
||||
if: github.server_url == 'https://github.com'
|
||||
uses: ./.github/workflows/build-windows.yml
|
||||
with:
|
||||
build-packages: true
|
||||
|
||||
cross:
|
||||
if: github.server_url == 'https://github.com'
|
||||
uses: ./.github/workflows/build-cross.yml
|
||||
|
||||
assemble-macos:
|
||||
needs: macos
|
||||
uses: ./.github/workflows/assemble-macos.yml
|
||||
|
||||
release:
|
||||
needs: [linux, macos, windows, cross, assemble-macos]
|
||||
if: startsWith(github.ref, 'refs/tags/v') && github.server_url == 'https://github.com'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Prepare release files
|
||||
run: |
|
||||
mkdir -p release
|
||||
for dir in artifacts/*/; do
|
||||
name=$(basename "$dir")
|
||||
if [[ "$name" == "cagire-macos-universal-dmg" ]]; then
|
||||
cp "$dir"/*.dmg release/
|
||||
elif [[ "$name" == "cagire-macos-universal-pkg" ]]; then
|
||||
cp "$dir"/*.pkg release/
|
||||
elif [[ "$name" == "cagire-macos-universal-desktop" ]]; then
|
||||
cp "$dir/Cagire.app.zip" "release/cagire-macos-universal-desktop.app.zip"
|
||||
elif [[ "$name" == "cagire-macos-universal" ]]; then
|
||||
cp "$dir/cagire" "release/cagire-macos-universal"
|
||||
elif [[ "$name" == "cagire-macos-universal-clap" ]]; then
|
||||
cd "$dir" && zip -r "../../release/cagire-macos-universal-clap.zip" cagire-plugins.clap && cd ../..
|
||||
elif [[ "$name" == "cagire-macos-universal-vst3" ]]; then
|
||||
cd "$dir" && zip -r "../../release/cagire-macos-universal-vst3.zip" cagire-plugins.vst3 && cd ../..
|
||||
elif [[ "$name" == *-clap ]]; then
|
||||
base="${name%-clap}"
|
||||
cd "$dir" && zip -r "../../release/${base}-clap.zip" cagire-plugins.clap && cd ../..
|
||||
elif [[ "$name" == *-vst3 ]]; then
|
||||
base="${name%-vst3}"
|
||||
cd "$dir" && zip -r "../../release/${base}-vst3.zip" cagire-plugins.vst3 && cd ../..
|
||||
elif [[ "$name" == *-installer ]]; then
|
||||
cp "$dir"/*-setup.exe release/
|
||||
elif [[ "$name" == *-appimage ]]; then
|
||||
cp "$dir"/*.AppImage release/
|
||||
elif [[ "$name" == *-desktop ]]; then
|
||||
base="${name%-desktop}"
|
||||
if ls "$dir"/*.deb 1>/dev/null 2>&1; then
|
||||
cp "$dir"/*.deb "release/${base}-desktop.deb"
|
||||
elif [ -f "$dir/Cagire.app.zip" ]; then
|
||||
cp "$dir/Cagire.app.zip" "release/${base}-desktop.app.zip"
|
||||
elif [ -f "$dir/cagire-desktop.exe" ]; then
|
||||
cp "$dir/cagire-desktop.exe" "release/${base}-desktop.exe"
|
||||
fi
|
||||
else
|
||||
if [ -f "$dir/cagire.exe" ]; then
|
||||
cp "$dir/cagire.exe" "release/${name}.exe"
|
||||
elif [ -f "$dir/cagire" ]; then
|
||||
cp "$dir/cagire" "release/${name}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: release/*
|
||||
generate_release_notes: true
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,10 +1,11 @@
|
||||
/target
|
||||
Cargo.lock
|
||||
/.cache
|
||||
*.prof
|
||||
.DS_Store
|
||||
releases/
|
||||
|
||||
# Cargo config
|
||||
.cargo/config.toml
|
||||
# Local cargo overrides (doux path patch)
|
||||
.cargo/config.local.toml
|
||||
|
||||
# Claude
|
||||
.claude/
|
||||
|
||||
96
BUILDING.md
96
BUILDING.md
@@ -1,5 +1,15 @@
|
||||
# Building Cagire
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Bubobubobubobubo/cagire
|
||||
cd cagire
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
The `doux` audio engine is fetched automatically from git. No local path setup needed.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
**Rust** (stable toolchain): https://rustup.rs
|
||||
@@ -68,6 +78,14 @@ Desktop (egui window):
|
||||
cargo build --release --features desktop --bin cagire-desktop
|
||||
```
|
||||
|
||||
Plugins (CLAP/VST3):
|
||||
|
||||
```bash
|
||||
cargo xtask bundle cagire-plugins --release
|
||||
```
|
||||
|
||||
The xtask alias is defined in `.cargo/config.toml` (committed). Plugin bundles are output to `target/bundled/`.
|
||||
|
||||
## Run
|
||||
|
||||
Terminal (default):
|
||||
@@ -89,3 +107,81 @@ cargo run --release --features desktop --bin cagire-desktop
|
||||
| `-i, --input <device>` | Input audio device |
|
||||
| `-c, --channels <n>` | Output channel count |
|
||||
| `-b, --buffer <size>` | Audio buffer size |
|
||||
|
||||
## Cross-Compilation
|
||||
|
||||
[cross](https://github.com/cross-rs/cross) uses Docker to build for other platforms without installing their toolchains locally. It works on any OS that runs Docker.
|
||||
|
||||
### Targets
|
||||
|
||||
| Target | Method | Binaries |
|
||||
|--------|--------|----------|
|
||||
| aarch64-apple-darwin | Native (macOS ARM only) | `cagire`, `cagire-desktop` |
|
||||
| x86_64-apple-darwin | Native (macOS only) | `cagire`, `cagire-desktop` |
|
||||
| x86_64-unknown-linux-gnu | `cross build` | `cagire`, `cagire-desktop` |
|
||||
| aarch64-unknown-linux-gnu (RPi 64-bit) | `cross build` | `cagire`, `cagire-desktop` |
|
||||
| x86_64-pc-windows-gnu | `cross build` | `cagire`, `cagire-desktop` |
|
||||
|
||||
macOS targets can only be built on macOS — Apple does not support cross-compilation to macOS from other platforms. Linux and Windows targets can be cross-compiled from any OS. The aarch64-unknown-linux-gnu target covers Raspberry Pi (64-bit OS).
|
||||
|
||||
### Windows ABI
|
||||
|
||||
CI produces `x86_64-pc-windows-msvc` binaries (native Windows build, better compatibility). Local cross-compilation from non-Windows hosts produces `x86_64-pc-windows-gnu` binaries (MinGW via Docker). Both work; MSVC is preferred for releases.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
1. **Docker**: https://docs.docker.com/get-docker/
|
||||
2. **cross**: `cargo install cross --git https://github.com/cross-rs/cross`
|
||||
3. On macOS, add the Intel target: `rustup target add x86_64-apple-darwin`
|
||||
|
||||
Docker must be running before invoking `cross` or `scripts/build-all.sh`.
|
||||
|
||||
### Building Individual Targets
|
||||
|
||||
```bash
|
||||
# Linux x86_64
|
||||
cross build --release --target x86_64-unknown-linux-gnu
|
||||
cross build --release --features desktop --bin cagire-desktop --target x86_64-unknown-linux-gnu
|
||||
|
||||
# Linux aarch64
|
||||
cross build --release --target aarch64-unknown-linux-gnu
|
||||
cross build --release --features desktop --bin cagire-desktop --target aarch64-unknown-linux-gnu
|
||||
|
||||
# Windows x86_64
|
||||
cross build --release --target x86_64-pc-windows-gnu
|
||||
cross build --release --features desktop --bin cagire-desktop --target x86_64-pc-windows-gnu
|
||||
```
|
||||
|
||||
### Building All Targets (macOS only)
|
||||
|
||||
```bash
|
||||
# Interactive (prompts for platform/target selection):
|
||||
scripts/build-all.sh
|
||||
|
||||
# Non-interactive:
|
||||
scripts/build-all.sh --platforms macos-arm64,linux-x86_64 --targets cli,desktop --yes
|
||||
scripts/build-all.sh --all --yes
|
||||
```
|
||||
|
||||
Builds selected targets, producing binaries in `releases/`.
|
||||
|
||||
Platform aliases: `macos-arm64`, `macos-x86_64`, `linux-x86_64`, `linux-aarch64`, `windows-x86_64`.
|
||||
Target aliases: `cli`, `desktop`, `plugins`.
|
||||
|
||||
### Linux AppImage Packaging
|
||||
|
||||
Linux releases ship as AppImages — self-contained executables that bundle all shared library dependencies (ALSA, JACK, X11, OpenGL). No runtime dependencies required.
|
||||
|
||||
After building a Linux target, produce an AppImage with:
|
||||
|
||||
```bash
|
||||
scripts/make-appimage.sh target/x86_64-unknown-linux-gnu/release/cagire x86_64 releases
|
||||
```
|
||||
|
||||
`scripts/build-all.sh` does this automatically for every Linux target selected. The CI pipeline produces AppImages for the x86_64 Linux build. Cross-arch AppImage building (e.g. aarch64 on x86_64) is not supported — run on a matching host or in CI.
|
||||
|
||||
### Notes
|
||||
|
||||
- Custom Dockerfiles in `cross/` install the native libraries Cagire depends on (ALSA, JACK, X11, cmake, libclang, etc.). `Cross.toml` maps each target to its Dockerfile.
|
||||
- The first build per target downloads Docker base images and installs packages. Subsequent builds use cached layers.
|
||||
- Cross-architecture Docker builds (e.g. aarch64 on x86_64 or vice versa) run under QEMU emulation and are significantly slower.
|
||||
|
||||
194
CHANGELOG.md
194
CHANGELOG.md
@@ -2,110 +2,172 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [0.1.2]
|
||||
|
||||
### Forth Language
|
||||
- Single-letter envelope aliases: `a` (attack), `d` (decay), `s` (sustain), `r` (release).
|
||||
- `sound` alias changed from `s` to `snd` (frees `s` for sustain).
|
||||
- New `partials` word: set number of active harmonics for additive oscillator.
|
||||
- Velocity parameter normalized to 0–1 float range (was 0–127 integer).
|
||||
|
||||
### UI / UX
|
||||
- **Sample Explorer as dedicated page**: the side panel is now a full page (Tab key), with keyboard navigation (j/k, search with `/`, preview with Enter), replacing the old collapsible side panel.
|
||||
- **Pulsing armed-changes bar** on patterns page: staged play/stop/mute/solo changes shown in a launch bar with animated feedback ("c to launch").
|
||||
- Pulsing highlight on banks and patterns with staged changes.
|
||||
- Sample browser shows child count on collapsed folders and uses `+`/`-` tree icons.
|
||||
- File browser modal: shows audio file counts per directory, colored path segments, and hint bar.
|
||||
- Audio devices refreshed automatically when entering the Engine page.
|
||||
- Bank prelude field added to data model (foundation for bank-level Forth scripts).
|
||||
|
||||
### Engine
|
||||
- Audio timing switched from float seconds to integer tick-based scheduling, improving timing precision.
|
||||
- Stream error handling refined: only `DeviceNotAvailable` and `StreamInvalidated` trigger device-lost recovery (non-fatal errors no longer restart the stream).
|
||||
- Step traces use `Arc` for cheaper cloning between threads.
|
||||
|
||||
### Packaging
|
||||
- **Windows: NSIS installer** replaces cargo-wix MSI. Includes optional PATH registration, Start Menu shortcut, and proper Add/Remove Programs entry with uninstaller.
|
||||
- Improved Windows cross-compilation from Unix hosts (MinGW toolchain detection).
|
||||
- CI build timeouts increased to 60 minutes across all platforms.
|
||||
- Website download matrix updated.
|
||||
|
||||
## [0.1.1]
|
||||
|
||||
### Forth Language
|
||||
- `map` word: apply a quotation to each stack element (`1 2 3 ( 10 * ) map => 10 20 30`).
|
||||
- `loop` fix: now operates in steps instead of beats, uses `step_duration()` for correct timing.
|
||||
|
||||
### Fixed
|
||||
- Crash on missing sample directories: sample path scanning now validates directories exist before scanning.
|
||||
- Audio channel minimum enforced to 2, preventing crash on devices reporting fewer channels.
|
||||
- Audio device disconnect: automatic stream restart when device is lost (terminal and desktop).
|
||||
- Live keys (e.g. `f` for fill) no longer trigger while searching in dictionary or help views.
|
||||
- Side panel always uses horizontal layout (removed broken vertical fallback for narrow terminals).
|
||||
|
||||
### Changed
|
||||
- Runtime highlight enabled by default.
|
||||
|
||||
### Packaging
|
||||
- Modular CI: split monolithic release workflow into per-platform builds (Linux, macOS, Windows, cross-compilation).
|
||||
- Separate CI workflows for CLAP/VST plugin builds (Linux, macOS, Windows, Raspberry Pi).
|
||||
- Windows MSI installer workflow fixes.
|
||||
- Website download matrix updated.
|
||||
|
||||
## [0.1.0]
|
||||
|
||||
### Breaking
|
||||
- **Quotation syntax changed from `{ }` to `( )`** — all deferred code blocks now use parentheses.
|
||||
|
||||
### Forth Language
|
||||
|
||||
**Bracket syntax `[ ... ]`**
|
||||
- `[ v1 v2 v3 ]` pushes all items plus their count. Sugar for `v1 v2 v3 3`.
|
||||
**Syntax:**
|
||||
- `[ v1 v2 v3 ]` bracket lists with implicit count.
|
||||
- `( ... )` quotation syntax (replaces `{ }`).
|
||||
- `,varname` assignment syntax (SetKeep): assign without consuming.
|
||||
- `case/of/endof/endcase` control flow.
|
||||
- `print` — debug word, outputs top-of-stack as text.
|
||||
- Arithmetic and unary ops now lift over ArpList and CycleList element-wise.
|
||||
|
||||
**New words:**
|
||||
- `index` — select item at explicit index (wraps with modulo).
|
||||
- `pbounce` — ping-pong cycle keyed by pattern iteration (vs `bounce` which is step-keyed).
|
||||
- `except` — inverse of `every`: run quotation on all iterations except every nth.
|
||||
- `every+` / `except+` — `every`/`except` with a phase offset.
|
||||
- `all` / `noall` — apply current params globally to all emitted sounds; clear global params.
|
||||
- `slice` / `pick` — sample slicing: divide a sample into N equal parts and select which slice to play.
|
||||
- `wave` / `waveform` — set drum synthesis waveform (0=sine, 0.5=triangle, 1=saw).
|
||||
- `pbounce` — ping-pong cycle keyed by pattern iteration.
|
||||
- `except` — inverse of `every`.
|
||||
- `every+` / `except+` — phase-offset variants.
|
||||
- `bjork` / `pbjork` — euclidean rhythm gates using quotations.
|
||||
- `arp` — arpeggio list type (spreads notes across time).
|
||||
- `all` / `noall` — apply params globally to all emitted sounds.
|
||||
- `linmap` / `expmap` — linear and exponential range mapping.
|
||||
- `rec` / `overdub` (`dub`) — toggle recording/overdubbing master audio to a named sample.
|
||||
- `orec` / `odub` — toggle recording/overdubbing a single orbit to a named sample.
|
||||
- `rec` / `overdub` (`dub`) — record/overdub master audio to a named sample.
|
||||
- `orec` / `odub` — record/overdub a single orbit.
|
||||
|
||||
**Harmony and voicing words:**
|
||||
- `key!` — set tonal center for scale operations.
|
||||
- `triad` / `seventh` — diatonic triad/seventh from scale degree (follows a scale word).
|
||||
**Harmony and voicing:**
|
||||
- `key!` — set tonal center.
|
||||
- `triad` / `seventh` — diatonic chord from scale degree.
|
||||
- `inv` / `dinv` — chord inversion / down inversion.
|
||||
- `drop2` / `drop3` — drop-2 / drop-3 voicings.
|
||||
- `drop2` / `drop3` — drop voicings.
|
||||
- `tp` — transpose all ints on stack by N semitones.
|
||||
|
||||
**New chord types:**
|
||||
- `pwr`, `augmaj7`, `7sus4`, `9sus4`, `maj69`, `min69`, `maj11`, `maj13`, `min13`, `dom7s11`.
|
||||
|
||||
**Ducking compressor params:**
|
||||
- `comp`, `compattack`/`cattack`, `comprelease`/`crelease`, `comporbit`/`corbit`.
|
||||
**Effect parameters:**
|
||||
- Ducking compressor: `comp`, `compattack`/`cattack`, `comprelease`/`crelease`, `comporbit`/`corbit`.
|
||||
- Smear effect: `smear`, `smearfreq`, `smearfb`.
|
||||
- Reverb: `verbtype`, `verbchorus`, `verbchorusfreq`, `verbprelow`, `verbprehigh`, `verblowcut`, `verbhighcut`, `verblowgain`.
|
||||
|
||||
**Behavior changes:**
|
||||
- All parameter words now accept varargs (100+ words updated to consume the full stack).
|
||||
- `every` reworked to accept quotations.
|
||||
- Removed `chain` word (replaced by pattern-level Follow Up setting).
|
||||
|
||||
### Engine
|
||||
- SF2 soundfont support: auto-scans sample directories for `.sf2` files and loads them.
|
||||
- Audio stream errors surfaced as flash messages instead of printing to stderr.
|
||||
- SF2 soundfont support: auto-scans sample directories for `.sf2` files.
|
||||
- Follow-up actions: patterns have configurable follow-up (Loop, Stop, Chain). Replaces the `chain` word with a declarative UI setting (`e` key).
|
||||
- Delta-time MIDI scheduling for tighter timing.
|
||||
- Audio stream errors surfaced as flash messages.
|
||||
- Prelude script evaluated on application startup (not only on play).
|
||||
- Global periodic script: a hidden script page runs alongside all patterns at its own speed/length.
|
||||
- RestartAll command: reset all active patterns to step 0 and clear state.
|
||||
- Tempo and current beat exposed in sequencer snapshot.
|
||||
- Spectrum analyzer rescaling.
|
||||
|
||||
### UI / Visualization
|
||||
- Lissajous XY scope: stereo phase display using Braille characters, togglable via Options.
|
||||
### UI / UX
|
||||
- **Engine page redesign**: responsive narrow/wide layout, Link/MIDI/device settings moved here from Options.
|
||||
- **Patterns view redesign**: banks column with pattern counts, expandable detail rows, bottom preview strip with mini step grid.
|
||||
- **Mouse support**: click navigation on header/grid/panels/modals, text selection in code editor (click+drag), double-click on scope/spectrum/lissajous to cycle display modes.
|
||||
- Smooth playback progress bar interpolated between steps.
|
||||
- Dynamic step grid sizing adapts to terminal height.
|
||||
- Lissajous XY scope with Braille rendering and thermal trail mode.
|
||||
- Gain boost (1x–16x) and normalize toggle for scope/lissajous/spectrum.
|
||||
- Pattern description field: editable via `d` on Patterns page, shown in pattern row and properties.
|
||||
- Pattern description field: editable via `d`, shown in pattern list and properties.
|
||||
- Bank/pattern import and export via clipboard (base64 serialization for sharing).
|
||||
- Mute/solo on main page now apply immediately (no staging).
|
||||
- Step name automatically cleared when deleting a step.
|
||||
- F1–F6 page navigation across the 3×2 page grid.
|
||||
- Collapsible help sections with code block copy.
|
||||
- Onboarding system for first-time users.
|
||||
- Show/hide preview pane toggle and zoom factor setting.
|
||||
- Reduced UI lag: sequencer snapshot moved after render call.
|
||||
- 10 bundled demo projects loaded on fresh startup (togglable in Options).
|
||||
- Options page: each option shows a description line below when focused.
|
||||
- Dictionary page: word list uses full page height (removed description box).
|
||||
|
||||
### Themes
|
||||
- 5 new themes: Iceberg, Everforest, Fauve, Tropicalia, Jaipur.
|
||||
- Palette-based generation: all 18 themes derived from a 14-field Palette via Oklab color space (definitions reduced from ~300 to ~20 lines each).
|
||||
|
||||
### Desktop (egui)
|
||||
- Fixed Alt/Option key on macOS (dead-key composition now works).
|
||||
- Fixed multi-character text paste.
|
||||
- Extended function key support (F13–F20).
|
||||
- No console window on Windows desktop build.
|
||||
|
||||
### Packaging
|
||||
- macOS: `.dmg` disk image with `.app` bundle (Intel + Apple Silicon fat binaries via `lipo`).
|
||||
- Windows: `.msi` installer via WiX.
|
||||
- Linux: improved AppImage build scripts and Docker cross-compilation.
|
||||
|
||||
### CLAP Plugin (experimental)
|
||||
- Early CLAP plugin support via nih-plug, baseview, and egui. Feature-gated builds separate CLI from plugin targets.
|
||||
|
||||
### Documentation
|
||||
- Complete reorganization into `docs/` subdirectories.
|
||||
- 10 getting-started guides, 5 interactive tutorials.
|
||||
- New tutorials: Recording, Soundfonts, Sharing (import/export).
|
||||
- New topics: control flow, generators, harmony, randomness, variables, timing, bracket syntax.
|
||||
- Crate-level READMEs for forth, markdown, project, ratatui.
|
||||
|
||||
### Fixed
|
||||
- CycleList + ArpList index collision: arp uses timing index, cycle uses polyphony slot.
|
||||
- Scope widget not drawing completely in some terminal sizes.
|
||||
|
||||
### Documentation
|
||||
- New tutorials: Recording (`docs/tutorials/recording.md`), Soundfonts (`docs/tutorials/soundfont.md`).
|
||||
|
||||
### UI / UX (breaking cosmetic changes)
|
||||
- **Options page**: Each option now shows a short description line below when focused, replacing the static header box.
|
||||
- **Dictionary page**: Removed the Forth description box at the top. The word list now uses the full page height.
|
||||
|
||||
### CLAP Plugin (experimental)
|
||||
- Early CLAP plugin support via nih-plug, baseview, and egui. Feature-gated builds separate CLI from plugin targets.
|
||||
|
||||
### Forth Language
|
||||
- Removed `chain` word (replaced by pattern-level Follow Up setting).
|
||||
- `case/of/endof/endcase` control flow for pattern-matching dispatch.
|
||||
- `bjork` / `pbjork` — euclidean rhythm gates using quotations: execute a block only on Bjorklund-distributed hits.
|
||||
- `arp` — arpeggio list type that spreads notes across time positions instead of stacking them simultaneously.
|
||||
- `,varname` assignment syntax (SetKeep): assign to a variable without consuming the value from the stack.
|
||||
- `every` reworked to accept quotations for cleaner conditional step logic.
|
||||
- All parameter words now accept varargs — over 100 words updated to consume the full stack.
|
||||
- Reverb parameter words added.
|
||||
|
||||
### Engine
|
||||
- Follow-up actions: patterns now have a configurable follow-up behavior (Loop, Stop, or Chain to another pattern). Replaces the Forth `chain` word with a declarative setting in the Pattern Properties modal (`e` key). Chain targets specify bank and pattern via UI fields.
|
||||
- Delta-time MIDI scheduling for tighter, sample-accurate timing.
|
||||
- Tempo and current beat exposed in sequencer snapshot.
|
||||
- Spectrum analyzer rescaling.
|
||||
|
||||
### UI / UX
|
||||
- Patterns view redesign: new layout with banks column (showing pattern counts), expandable detail rows for the focused pattern (quantization, sync mode, progress bar), and a bottom preview strip with mini step grid and pattern properties.
|
||||
- Smooth playback progress: playing patterns display a real-time progress bar interpolated between steps.
|
||||
- Dynamic step grid sizing: `steps_per_page` adapts to terminal height instead of using a fixed constant.
|
||||
- Mouse support: click navigation on the pattern grid, panels, and modals.
|
||||
- F1–F6 page navigation across the 3×2 page grid.
|
||||
- Collapsible help sections with code block copy.
|
||||
- Onboarding system for first-time users.
|
||||
- New reusable widgets: CategoryList, HintBar, PropsForm, ScrollIndicators, SearchBar, SectionHeader.
|
||||
- Show/hide preview pane toggle and zoom factor setting.
|
||||
|
||||
### Documentation
|
||||
- Complete reorganization into `docs/` subdirectories.
|
||||
- 10 getting-started guides, 5 interactive tutorials.
|
||||
- New topics: control flow, generators, harmony, randomness, variables, timing.
|
||||
|
||||
### Theme System
|
||||
- Palette-based generation: all 18 themes now derived from a 14-field Palette via Oklab color space.
|
||||
- Theme definitions reduced from ~300 lines each to ~20 lines.
|
||||
|
||||
### Codebase
|
||||
- `src/app.rs` split into 10 focused modules (dispatch, clipboard, editing, navigation, persistence, scripting, sequencer, staging, undo).
|
||||
- `src/app.rs` split into 10 focused modules.
|
||||
- `src/input.rs` split into 8 page-specific handlers.
|
||||
- Undo/redo system with scope-based tracking.
|
||||
- Feature-gated CLI vs plugin builds.
|
||||
- New reusable widgets: CategoryList, HintBar, PropsForm, ScrollIndicators, SearchBar, SectionHeader.
|
||||
|
||||
## [0.0.9]
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ Contributions are welcome. There are many ways to contribute beyond code:
|
||||
## Prerequisites
|
||||
|
||||
- **Rust** (stable toolchain) - [rustup.rs](https://rustup.rs/)
|
||||
- **System libraries** - See [BUILDING.md](BUILDING.md) for platform-specific packages (cmake, ALSA, etc.)
|
||||
|
||||
## Quick start
|
||||
|
||||
|
||||
7363
Cargo.lock
generated
Normal file
7363
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
12
Cargo.toml
@@ -2,7 +2,7 @@
|
||||
members = ["crates/forth", "crates/markdown", "crates/project", "crates/ratatui", "plugins/cagire-plugins", "plugins/baseview", "plugins/egui-baseview", "plugins/nih-plug-egui", "xtask"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.0.9"
|
||||
version = "0.1.2"
|
||||
edition = "2021"
|
||||
authors = ["Raphaël Forment <raphael.forment@gmail.com>"]
|
||||
license = "AGPL-3.0"
|
||||
@@ -51,11 +51,11 @@ cagire-forth = { path = "crates/forth" }
|
||||
cagire-markdown = { path = "crates/markdown" }
|
||||
cagire-project = { path = "crates/project" }
|
||||
cagire-ratatui = { path = "crates/ratatui" }
|
||||
doux = { path = "/Users/bubo/doux", features = ["native", "soundfont"] }
|
||||
doux = { git = "https://github.com/sova-org/doux", features = ["native", "soundfont"] }
|
||||
rusty_link = "0.4"
|
||||
ratatui = "0.30"
|
||||
crossterm = "0.29"
|
||||
cpal = { version = "0.17", features = ["jack"], optional = true }
|
||||
cpal = { version = "0.17", optional = true }
|
||||
clap = { version = "4", features = ["derive"], optional = true }
|
||||
rand = "0.8"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
@@ -83,7 +83,10 @@ rustc-hash = { version = "2", optional = true }
|
||||
image = { version = "0.25", default-features = false, features = ["png"], optional = true }
|
||||
|
||||
|
||||
[target.'cfg(windows)'.build-dependencies]
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
cpal = { version = "0.17", optional = true, features = ["jack"] }
|
||||
|
||||
[build-dependencies]
|
||||
winres = "0.1"
|
||||
|
||||
[profile.release]
|
||||
@@ -109,3 +112,4 @@ icon = ["assets/Cagire.icns", "assets/Cagire.ico", "assets/Cagire.png"]
|
||||
copyright = "Copyright (c) 2025 Raphaël Forment"
|
||||
category = "Music"
|
||||
short_description = "Forth-based music sequencer"
|
||||
minimum_system_version = "12.0"
|
||||
|
||||
11
Cross.toml
11
Cross.toml
@@ -1,5 +1,8 @@
|
||||
[build]
|
||||
volumes = ["/Users/bubo/doux:/Users/bubo/doux"]
|
||||
|
||||
[target.aarch64-unknown-linux-gnu]
|
||||
dockerfile = "./cross/aarch64-linux.Dockerfile"
|
||||
dockerfile = "./scripts/cross/aarch64-linux.Dockerfile"
|
||||
|
||||
[target.x86_64-unknown-linux-gnu]
|
||||
dockerfile = "./scripts/cross/x86_64-linux.Dockerfile"
|
||||
|
||||
[target.x86_64-pc-windows-gnu]
|
||||
dockerfile = "./scripts/cross/x86_64-windows.Dockerfile"
|
||||
|
||||
89
README.md
89
README.md
@@ -1,37 +1,84 @@
|
||||
<h1 align="center">Cagire</h1>
|
||||
|
||||
<p align="center"><em>A Forth Music Sequencer</em></p>
|
||||
<p align="center"><em>A Forth-based live coding sequencer</em></p>
|
||||
|
||||
<p align="center">
|
||||
<img src="cagire_pixel.png" alt="Cagire" width="256">
|
||||
<img src="assets/Cagire.png" alt="Cagire" width="256">
|
||||
</p>
|
||||
|
||||
Cagire is a terminal-based step sequencer for live coding music. Each step in a pattern contains a **Forth** script that produces sound and create events.
|
||||
<p align="center">
|
||||
<a href="https://cagire.raphaelforment.fr">Website</a> ·
|
||||
<a href="https://github.com/Bubobubobubobubo/cagire">GitHub</a> ·
|
||||
AGPL-3.0
|
||||
</p>
|
||||
|
||||
## Build
|
||||
Cagire is a terminal based step sequencer and live coding platform. Each step in a sequence is represented by a **Forth** script. It ships with a self-contained audio engine. No external software is needed, Cagire is a fully autonomous musical instrument that provides everything you need to perform.
|
||||
|
||||
Terminal version:
|
||||
```
|
||||
cargo build --release
|
||||
### Examples
|
||||
|
||||
A filtered sawtooth with reverb:
|
||||
|
||||
```forth
|
||||
saw sound
|
||||
200 199 freq
|
||||
400 lpf
|
||||
.8 lpq .3 verb
|
||||
.
|
||||
```
|
||||
|
||||
Desktop version (with egui window):
|
||||
```
|
||||
cargo build --release --features desktop --bin cagire-desktop
|
||||
A generative pattern using randomness, scales, and effects:
|
||||
|
||||
```forth
|
||||
sine sound 2 fm 0.5 fmh
|
||||
0 7 rand minor 50 + note
|
||||
.1 .8 rrand cutoff
|
||||
1 4 irand 10 * delay .5 delayfb
|
||||
.
|
||||
```
|
||||
|
||||
## Run
|
||||
### Features
|
||||
|
||||
Terminal version:
|
||||
```
|
||||
cargo run --release
|
||||
```
|
||||
- **Cagire's Forth**: a stack-based language made for live coding
|
||||
- Forth has almost no syntax, only words, numbers and spaces. Very easy to learn for beginners, quite deep for experienced programmers.
|
||||
- Nondeterminism and generative: randomness, probabilities, patterns thought as first-class features.
|
||||
- Quotations: code blocks `( ... )` that compose with probability, cycling, euclidean, and conditional words.
|
||||
- User-defined words: extend (or redefine) the language on the fly with `:name ... ;` definitions.
|
||||
- Interactive documentation: built-in tutorials with runnable examples.
|
||||
- **Audio engine** (powered by [Doux](https://doux.livecoding.fr)):
|
||||
- Synthesis: classic waveforms (saw, pulse, tri, sine), additive, FM (2-op, 3 algorithms), additive synthesis, wavetables, 7-voice spread, Mutable Instruments Plaits models: modal, granular, waveshaping, chord, swarm, etc.
|
||||
- Drum models: seven drum models with timbral morphing.
|
||||
- Sampling: disk-loaded samples with slicing, looping, pitch tracking, wavetable mode, and live recording from engine output or line input.
|
||||
- Filters: biquad LP/HP/BP and ladder filters, each with independent envelope. Filters can be modulated, stacked, etc.
|
||||
- Effects: phaser, flanger, chorus, smear, distortion, wavefolder, wavewrapper, bitcrusher, sample-rate reduction, 3-band EQ, tilt EQ, Haas stereo.
|
||||
- Bus effects: delay (standard, ping-pong, tape, multitap), two reverb engines (Dattorro plate, Vital Space), comb filter, feedback delay with LFO, sidechain compressor.
|
||||
- Modulation: vibrato, AM, ring mod, pitch envelope, FM envelope, glide — all with selectable LFO shapes (sine, tri, saw, square, sample & hold).
|
||||
- **Sequencing**: probabilities, patterns, euclidean structures, sub-step timing, pattern chaining and a lot more.
|
||||
- **MIDI**: receive or send MIDI messages across up to 4 inputs and 4 outputs.
|
||||
- **Ableton Link**: tempo and phase sync with any Link-enabled software or hardware.
|
||||
- **Cross-platform**: terminal and desktop interfaces on macOS, Linux, and Windows.
|
||||
- **Plugins**: run Cagire as a CLAP or VST3 plugin inside your DAW (separate version).
|
||||
|
||||
Desktop version:
|
||||
```
|
||||
cargo run --release --features desktop --bin cagire-desktop
|
||||
```
|
||||
### Getting started
|
||||
|
||||
## License
|
||||
Download the latest release for your platform from the [website](https://cagire.raphaelforment.fr).
|
||||
|
||||
AGPL-3.0
|
||||
To build from source instead, see [BUILDING.md](BUILDING.md).
|
||||
|
||||
### Documentation
|
||||
|
||||
Cagire includes interactive documentation with runnable code examples. Press **F1** in the application to open it.
|
||||
|
||||
- [Website](https://cagire.raphaelforment.fr)
|
||||
- [BUILDING.md](BUILDING.md) — build instructions and CLI flags
|
||||
- [CHANGELOG.md](CHANGELOG.md)
|
||||
|
||||
### Credits
|
||||
|
||||
Cagire is developed by [BuboBubo](https://raphaelforment.fr) (Raphael Forment).
|
||||
|
||||
- **[Doux](https://doux.livecoding.fr)** (audio engine) — Rust port of Dough, originally written in C by Felix Roos
|
||||
- **mi-plaits-dsp-rs** — Rust port of Mutable Instruments Plaits DSP by Oliver Rockstedt, original code by Emilie Gillet
|
||||
|
||||
### License
|
||||
|
||||
[AGPL-3.0](LICENSE)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 72 KiB |
18
assets/DMG-README.txt
Normal file
18
assets/DMG-README.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
# Cagire - A Forth-based music sequencer
|
||||
|
||||
## Installation
|
||||
|
||||
Drag Cagire.app into the Applications folder.
|
||||
|
||||
## Unquarantine
|
||||
|
||||
Since this app is not signed with an Apple Developer certificate,
|
||||
macOS will block it from running. Thanks Apple! To fix this, open
|
||||
Terminal and run:
|
||||
|
||||
xattr -cr /Applications/Cagire.app
|
||||
|
||||
## Support
|
||||
|
||||
If you enjoy this software, consider supporting development:
|
||||
https://ko-fi.com/raphaelbubo
|
||||
7
assets/cagire.desktop
Normal file
7
assets/cagire.desktop
Normal file
@@ -0,0 +1,7 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Cagire
|
||||
Comment=Forth-based music sequencer
|
||||
Exec=cagire
|
||||
Icon=cagire
|
||||
Categories=Audio;Music;AudioVideo;
|
||||
31
build.rs
31
build.rs
@@ -1,13 +1,38 @@
|
||||
//! Build script — embeds Windows application resources (icon, metadata).
|
||||
|
||||
fn main() {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
||||
|
||||
if target_os == "windows" {
|
||||
// C++ runtime (stdc++, gcc, gcc_eh, pthread) linked statically via .cargo/config.toml
|
||||
// using -Wl,-Bstatic. Only Windows system DLLs go here.
|
||||
println!("cargo:rustc-link-lib=ws2_32");
|
||||
println!("cargo:rustc-link-lib=iphlpapi");
|
||||
println!("cargo:rustc-link-lib=winmm");
|
||||
println!("cargo:rustc-link-lib=ole32");
|
||||
println!("cargo:rustc-link-lib=oleaut32");
|
||||
}
|
||||
|
||||
if target_os == "windows" {
|
||||
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
let icon = format!("{manifest_dir}/assets/Cagire.ico");
|
||||
let mut res = winres::WindowsResource::new();
|
||||
res.set_icon("assets/Cagire.ico")
|
||||
// Cross-compiling from Unix: use prefixed MinGW tools
|
||||
if cfg!(unix) {
|
||||
res.set_windres_path("x86_64-w64-mingw32-windres");
|
||||
res.set_ar_path("x86_64-w64-mingw32-ar");
|
||||
res.set_toolkit_path("/");
|
||||
}
|
||||
res.set_icon(&icon)
|
||||
.set("ProductName", "Cagire")
|
||||
.set("FileDescription", "Forth-based music sequencer")
|
||||
.set("LegalCopyright", "Copyright (c) 2025 Raphaël Forment");
|
||||
res.compile().expect("Failed to compile Windows resources");
|
||||
// GNU ld discards unreferenced sections from static archives,
|
||||
// so link the resource object directly to ensure .rsrc is kept.
|
||||
if cfg!(unix) {
|
||||
let out_dir = std::env::var("OUT_DIR").unwrap();
|
||||
println!("cargo:rustc-link-arg-bins={out_dir}/resource.o");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
crates/forth/README.md
Normal file
22
crates/forth/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# cagire-forth
|
||||
|
||||
Stack-based Forth VM for the Cagire sequencer. Tokenizes, compiles, and executes step scripts to produce audio and MIDI commands.
|
||||
|
||||
## Modules
|
||||
|
||||
| Module | Description |
|
||||
|--------|-------------|
|
||||
| `vm` | Interpreter loop, `Forth::evaluate()` entry point |
|
||||
| `compiler` | Tokenization (with source spans) and single-pass compilation to ops |
|
||||
| `ops` | `Op` enum (~90 variants) |
|
||||
| `types` | `Value`, `StepContext`, shared state types |
|
||||
| `words/` | Built-in word definitions: `core`, `sound`, `music`, `midi`, `effects`, `sequencing`, `compile` |
|
||||
| `theory/` | Music theory lookups: `scales` (~200 patterns), `chords` (interval arrays) |
|
||||
|
||||
## Key Types
|
||||
|
||||
- **`Forth`** — VM instance, holds stacks and compilation state
|
||||
- **`Value`** — Stack value (int, float, string, list, quotation, ...)
|
||||
- **`StepContext`** — Per-step evaluation context (step index, tempo, variables, ...)
|
||||
- **`Op`** — Compiled operation; nondeterministic variants carry `Option<SourceSpan>` for tracing
|
||||
- **`ExecutionTrace`** — Records executed/selected spans and resolved values during evaluation
|
||||
@@ -31,7 +31,7 @@ fn tokenize(input: &str) -> Vec<Token> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if c == '(' || c == ')' {
|
||||
if c == '{' || c == '}' {
|
||||
chars.next();
|
||||
continue;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ fn compile(tokens: &[Token], dict: &Dictionary) -> Result<Vec<Op>, String> {
|
||||
Token::Str(s, span) => ops.push(Op::PushStr(Arc::from(s.as_str()), Some(*span))),
|
||||
Token::Word(w, span) => {
|
||||
let word = w.as_str();
|
||||
if word == "{" {
|
||||
if word == "(" {
|
||||
let (quote_ops, consumed, end_span) =
|
||||
compile_quotation(&tokens[i + 1..], dict)?;
|
||||
i += consumed;
|
||||
@@ -142,8 +142,8 @@ fn compile(tokens: &[Token], dict: &Dictionary) -> Result<Vec<Op>, String> {
|
||||
end: end_span.end,
|
||||
};
|
||||
ops.push(Op::Quotation(Arc::from(quote_ops), Some(body_span)));
|
||||
} else if word == "}" {
|
||||
return Err("unexpected }".into());
|
||||
} else if word == ")" {
|
||||
return Err("unexpected )".into());
|
||||
} else if word == "[" {
|
||||
let (bracket_ops, consumed, end_span) =
|
||||
compile_bracket(&tokens[i + 1..], dict)?;
|
||||
@@ -203,8 +203,8 @@ fn compile_quotation(
|
||||
for (i, tok) in tokens.iter().enumerate() {
|
||||
if let Token::Word(w, _) = tok {
|
||||
match w.as_str() {
|
||||
"{" => depth += 1,
|
||||
"}" => {
|
||||
"(" => depth += 1,
|
||||
")" => {
|
||||
depth -= 1;
|
||||
if depth == 0 {
|
||||
end_idx = Some(i);
|
||||
@@ -216,7 +216,7 @@ fn compile_quotation(
|
||||
}
|
||||
}
|
||||
|
||||
let end_idx = end_idx.ok_or("missing }")?;
|
||||
let end_idx = end_idx.ok_or("missing )")?;
|
||||
let end_span = match &tokens[end_idx] {
|
||||
Token::Word(_, span) => *span,
|
||||
_ => unreachable!(),
|
||||
|
||||
@@ -65,6 +65,7 @@ pub enum Op {
|
||||
NewCmd,
|
||||
SetParam(&'static str),
|
||||
Emit,
|
||||
Print,
|
||||
Get,
|
||||
Set,
|
||||
SetKeep,
|
||||
@@ -117,6 +118,7 @@ pub enum Op {
|
||||
Euclid,
|
||||
EuclidRot,
|
||||
Times,
|
||||
Map,
|
||||
Chord(&'static [i64]),
|
||||
Transpose,
|
||||
Invert,
|
||||
|
||||
@@ -112,7 +112,7 @@ impl Forth {
|
||||
let vars_snapshot = self.vars.load_full();
|
||||
let mut var_writes: HashMap<String, Value> = HashMap::new();
|
||||
|
||||
cmd.set_global(self.global_params.lock().clone());
|
||||
cmd.set_global(std::mem::take(&mut *self.global_params.lock()));
|
||||
|
||||
self.execute_ops(
|
||||
ops,
|
||||
@@ -315,7 +315,7 @@ impl Forth {
|
||||
|
||||
Op::Dup => {
|
||||
ensure(stack, 1)?;
|
||||
let v = stack.last().unwrap().clone();
|
||||
let v = stack.last().expect("stack non-empty after ensure").clone();
|
||||
stack.push(v);
|
||||
}
|
||||
Op::Dupn => {
|
||||
@@ -328,6 +328,16 @@ impl Forth {
|
||||
Op::Drop => {
|
||||
pop(stack)?;
|
||||
}
|
||||
Op::Print => {
|
||||
let val = pop(stack)?;
|
||||
let text = match &val {
|
||||
Value::Int(n, _) => n.to_string(),
|
||||
Value::Float(f, _) => format!("{f}"),
|
||||
Value::Str(s, _) => s.to_string(),
|
||||
_ => format!("{val:?}"),
|
||||
};
|
||||
outputs.push(format!("print:{text}"));
|
||||
}
|
||||
Op::Swap => {
|
||||
ensure(stack, 2)?;
|
||||
let len = stack.len();
|
||||
@@ -449,7 +459,7 @@ impl Forth {
|
||||
if b.as_float().map_or(true, |v| v == 0.0) {
|
||||
return Err("division by zero".into());
|
||||
}
|
||||
stack.push(lift_binary(a, b, |x, y| x / y)?);
|
||||
stack.push(lift_binary(&a, &b, |x, y| x / y)?);
|
||||
}
|
||||
Op::Mod => {
|
||||
let b = pop(stack)?;
|
||||
@@ -457,47 +467,47 @@ impl Forth {
|
||||
if b.as_float().map_or(true, |v| v == 0.0) {
|
||||
return Err("modulo by zero".into());
|
||||
}
|
||||
let result = lift_binary(a, b, |x, y| (x as i64 % y as i64) as f64)?;
|
||||
let result = lift_binary(&a, &b, |x, y| (x as i64 % y as i64) as f64)?;
|
||||
stack.push(result);
|
||||
}
|
||||
Op::Neg => {
|
||||
let v = pop(stack)?;
|
||||
stack.push(lift_unary(v, |x| -x)?);
|
||||
stack.push(lift_unary(&v, |x| -x)?);
|
||||
}
|
||||
Op::Abs => {
|
||||
let v = pop(stack)?;
|
||||
stack.push(lift_unary(v, |x| x.abs())?);
|
||||
stack.push(lift_unary(&v, |x| x.abs())?);
|
||||
}
|
||||
Op::Floor => {
|
||||
let v = pop(stack)?;
|
||||
stack.push(lift_unary(v, |x| x.floor())?);
|
||||
stack.push(lift_unary(&v, |x| x.floor())?);
|
||||
}
|
||||
Op::Ceil => {
|
||||
let v = pop(stack)?;
|
||||
stack.push(lift_unary(v, |x| x.ceil())?);
|
||||
stack.push(lift_unary(&v, |x| x.ceil())?);
|
||||
}
|
||||
Op::Round => {
|
||||
let v = pop(stack)?;
|
||||
stack.push(lift_unary(v, |x| x.round())?);
|
||||
stack.push(lift_unary(&v, |x| x.round())?);
|
||||
}
|
||||
Op::Min => binary_op(stack, |a, b| a.min(b))?,
|
||||
Op::Max => binary_op(stack, |a, b| a.max(b))?,
|
||||
Op::Pow => binary_op(stack, |a, b| a.powf(b))?,
|
||||
Op::Sqrt => {
|
||||
let v = pop(stack)?;
|
||||
stack.push(lift_unary(v, |x| x.sqrt())?);
|
||||
stack.push(lift_unary(&v, |x| x.sqrt())?);
|
||||
}
|
||||
Op::Sin => {
|
||||
let v = pop(stack)?;
|
||||
stack.push(lift_unary(v, |x| x.sin())?);
|
||||
stack.push(lift_unary(&v, |x| x.sin())?);
|
||||
}
|
||||
Op::Cos => {
|
||||
let v = pop(stack)?;
|
||||
stack.push(lift_unary(v, |x| x.cos())?);
|
||||
stack.push(lift_unary(&v, |x| x.cos())?);
|
||||
}
|
||||
Op::Log => {
|
||||
let v = pop(stack)?;
|
||||
stack.push(lift_unary(v, |x| x.ln())?);
|
||||
stack.push(lift_unary(&v, |x| x.ln())?);
|
||||
}
|
||||
|
||||
Op::Eq => cmp_op(stack, |a, b| (a - b).abs() < f64::EPSILON)?,
|
||||
@@ -558,7 +568,10 @@ impl Forth {
|
||||
|
||||
Op::NewCmd => {
|
||||
ensure(stack, 1)?;
|
||||
let values = std::mem::take(stack);
|
||||
let values = drain_skip_quotations(stack);
|
||||
if values.is_empty() {
|
||||
return Err("expected sound name".into());
|
||||
}
|
||||
let val = if values.len() == 1 {
|
||||
values.into_iter().next().unwrap()
|
||||
} else {
|
||||
@@ -568,7 +581,10 @@ impl Forth {
|
||||
}
|
||||
Op::SetParam(param) => {
|
||||
ensure(stack, 1)?;
|
||||
let values = std::mem::take(stack);
|
||||
let values = drain_skip_quotations(stack);
|
||||
if values.is_empty() {
|
||||
return Err("expected parameter value".into());
|
||||
}
|
||||
let val = if values.len() == 1 {
|
||||
values.into_iter().next().unwrap()
|
||||
} else {
|
||||
@@ -1039,7 +1055,7 @@ impl Forth {
|
||||
let key = read_key(&var_writes_cell, vars_snapshot);
|
||||
let values = std::mem::take(stack);
|
||||
for val in values {
|
||||
let result = lift_unary_int(val, |degree| {
|
||||
let result = lift_unary_int(&val, |degree| {
|
||||
let octave_offset = degree.div_euclid(len);
|
||||
let idx = degree.rem_euclid(len) as usize;
|
||||
key + octave_offset * 12 + pattern[idx]
|
||||
@@ -1139,7 +1155,7 @@ impl Forth {
|
||||
Op::Oct => {
|
||||
let shift = pop(stack)?;
|
||||
let note = pop(stack)?;
|
||||
let result = lift_binary(note, shift, |n, s| n + s * 12.0)?;
|
||||
let result = lift_binary(¬e, &shift, |n, s| n + s * 12.0)?;
|
||||
stack.push(result);
|
||||
}
|
||||
|
||||
@@ -1164,11 +1180,11 @@ impl Forth {
|
||||
}
|
||||
|
||||
Op::Loop => {
|
||||
let beats = pop_float(stack)?;
|
||||
let steps = pop_float(stack)?;
|
||||
if ctx.tempo == 0.0 || ctx.speed == 0.0 {
|
||||
return Err("tempo and speed must be non-zero".into());
|
||||
}
|
||||
let dur = beats * 60.0 / ctx.tempo / ctx.speed;
|
||||
let dur = steps * ctx.step_duration();
|
||||
cmd.set_param("fit", Value::Float(dur, None));
|
||||
cmd.set_param("dur", Value::Float(dur, None));
|
||||
}
|
||||
@@ -1358,6 +1374,15 @@ impl Forth {
|
||||
}
|
||||
}
|
||||
|
||||
Op::Map => {
|
||||
let quot = pop(stack)?;
|
||||
let items = std::mem::take(stack);
|
||||
for item in items {
|
||||
stack.push(item);
|
||||
run_quotation(quot.clone(), stack, outputs, cmd)?;
|
||||
}
|
||||
}
|
||||
|
||||
Op::GeomRange => {
|
||||
let count = pop_int(stack)?;
|
||||
let ratio = pop_float(stack)?;
|
||||
@@ -1548,7 +1573,7 @@ impl Forth {
|
||||
} else {
|
||||
let note = get_int("note").unwrap_or(60).clamp(0, 127) as u8;
|
||||
let velocity =
|
||||
get_int("velocity").unwrap_or(100).clamp(0, 127) as u8;
|
||||
(get_float("velocity").unwrap_or(0.8) * 127.0).clamp(0.0, 127.0) as u8;
|
||||
let dur = get_float("dur").unwrap_or(1.0);
|
||||
let dur_secs = dur * ctx.step_duration();
|
||||
outputs.push(format!(
|
||||
@@ -1804,8 +1829,8 @@ fn euclidean_rhythm(k: usize, n: usize, rotation: usize) -> Vec<i64> {
|
||||
groups.into_iter().partition(|g| g[0]);
|
||||
|
||||
for _ in 0..min_count {
|
||||
let mut one = ones.pop().unwrap();
|
||||
one.extend(zeros.pop().unwrap());
|
||||
let mut one = ones.pop().expect("ones sufficient for min_count");
|
||||
one.extend(zeros.pop().expect("zeros sufficient for min_count"));
|
||||
new_groups.push(one);
|
||||
}
|
||||
new_groups.extend(ones);
|
||||
@@ -1866,6 +1891,21 @@ fn pop_bool(stack: &mut Vec<Value>) -> Result<bool, String> {
|
||||
Ok(pop(stack)?.is_truthy())
|
||||
}
|
||||
|
||||
/// Drain the stack, returning non-quotation values.
|
||||
/// Quotations are pushed back onto the stack (transparent).
|
||||
fn drain_skip_quotations(stack: &mut Vec<Value>) -> Vec<Value> {
|
||||
let values = std::mem::take(stack);
|
||||
let mut result = Vec::new();
|
||||
for v in values {
|
||||
if matches!(v, Value::Quotation(..)) {
|
||||
stack.push(v);
|
||||
} else {
|
||||
result.push(v);
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn ensure(stack: &[Value], n: usize) -> Result<(), String> {
|
||||
if stack.len() < n {
|
||||
return Err("stack underflow".into());
|
||||
@@ -1881,65 +1921,65 @@ fn float_to_value(result: f64) -> Value {
|
||||
}
|
||||
}
|
||||
|
||||
fn lift_unary<F>(val: Value, f: F) -> Result<Value, String>
|
||||
fn lift_unary<F>(val: &Value, f: F) -> Result<Value, String>
|
||||
where
|
||||
F: Fn(f64) -> f64 + Copy,
|
||||
{
|
||||
match val {
|
||||
Value::ArpList(items) => {
|
||||
let mapped: Result<Vec<_>, _> = items.iter().map(|x| lift_unary(x.clone(), f)).collect();
|
||||
let mapped: Result<Vec<_>, _> = items.iter().map(|x| lift_unary(x, f)).collect();
|
||||
Ok(Value::ArpList(Arc::from(mapped?)))
|
||||
}
|
||||
Value::CycleList(items) => {
|
||||
let mapped: Result<Vec<_>, _> = items.iter().map(|x| lift_unary(x.clone(), f)).collect();
|
||||
let mapped: Result<Vec<_>, _> = items.iter().map(|x| lift_unary(x, f)).collect();
|
||||
Ok(Value::CycleList(Arc::from(mapped?)))
|
||||
}
|
||||
v => Ok(float_to_value(f(v.as_float()?))),
|
||||
}
|
||||
}
|
||||
|
||||
fn lift_unary_int<F>(val: Value, f: F) -> Result<Value, String>
|
||||
fn lift_unary_int<F>(val: &Value, f: F) -> Result<Value, String>
|
||||
where
|
||||
F: Fn(i64) -> i64 + Copy,
|
||||
{
|
||||
match val {
|
||||
Value::ArpList(items) => {
|
||||
let mapped: Result<Vec<_>, _> =
|
||||
items.iter().map(|x| lift_unary_int(x.clone(), f)).collect();
|
||||
items.iter().map(|x| lift_unary_int(x, f)).collect();
|
||||
Ok(Value::ArpList(Arc::from(mapped?)))
|
||||
}
|
||||
Value::CycleList(items) => {
|
||||
let mapped: Result<Vec<_>, _> =
|
||||
items.iter().map(|x| lift_unary_int(x.clone(), f)).collect();
|
||||
items.iter().map(|x| lift_unary_int(x, f)).collect();
|
||||
Ok(Value::CycleList(Arc::from(mapped?)))
|
||||
}
|
||||
v => Ok(Value::Int(f(v.as_int()?), None)),
|
||||
}
|
||||
}
|
||||
|
||||
fn lift_binary<F>(a: Value, b: Value, f: F) -> Result<Value, String>
|
||||
fn lift_binary<F>(a: &Value, b: &Value, f: F) -> Result<Value, String>
|
||||
where
|
||||
F: Fn(f64, f64) -> f64 + Copy,
|
||||
{
|
||||
match (a, b) {
|
||||
(Value::ArpList(items), b) => {
|
||||
let mapped: Result<Vec<_>, _> =
|
||||
items.iter().map(|x| lift_binary(x.clone(), b.clone(), f)).collect();
|
||||
items.iter().map(|x| lift_binary(x, b, f)).collect();
|
||||
Ok(Value::ArpList(Arc::from(mapped?)))
|
||||
}
|
||||
(a, Value::ArpList(items)) => {
|
||||
let mapped: Result<Vec<_>, _> =
|
||||
items.iter().map(|x| lift_binary(a.clone(), x.clone(), f)).collect();
|
||||
items.iter().map(|x| lift_binary(a, x, f)).collect();
|
||||
Ok(Value::ArpList(Arc::from(mapped?)))
|
||||
}
|
||||
(Value::CycleList(items), b) => {
|
||||
let mapped: Result<Vec<_>, _> =
|
||||
items.iter().map(|x| lift_binary(x.clone(), b.clone(), f)).collect();
|
||||
items.iter().map(|x| lift_binary(x, b, f)).collect();
|
||||
Ok(Value::CycleList(Arc::from(mapped?)))
|
||||
}
|
||||
(a, Value::CycleList(items)) => {
|
||||
let mapped: Result<Vec<_>, _> =
|
||||
items.iter().map(|x| lift_binary(a.clone(), x.clone(), f)).collect();
|
||||
items.iter().map(|x| lift_binary(a, x, f)).collect();
|
||||
Ok(Value::CycleList(Arc::from(mapped?)))
|
||||
}
|
||||
(a, b) => Ok(float_to_value(f(a.as_float()?, b.as_float()?))),
|
||||
@@ -1952,7 +1992,7 @@ where
|
||||
{
|
||||
let b = pop(stack)?;
|
||||
let a = pop(stack)?;
|
||||
stack.push(lift_binary(a, b, f)?);
|
||||
stack.push(lift_binary(&a, &b, f)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ pub(super) fn simple_op(name: &str) -> Option<Op> {
|
||||
"dup" => Op::Dup,
|
||||
"dupn" => Op::Dupn,
|
||||
"drop" => Op::Drop,
|
||||
"print" => Op::Print,
|
||||
"swap" => Op::Swap,
|
||||
"over" => Op::Over,
|
||||
"rot" => Op::Rot,
|
||||
@@ -58,7 +59,7 @@ pub(super) fn simple_op(name: &str) -> Option<Op> {
|
||||
"nand" => Op::Nand,
|
||||
"nor" => Op::Nor,
|
||||
"ifelse" => Op::IfElse,
|
||||
"pick" => Op::Pick,
|
||||
"select" => Op::Pick,
|
||||
"sound" => Op::NewCmd,
|
||||
"." => Op::Emit,
|
||||
"rand" => Op::Rand(None),
|
||||
@@ -109,6 +110,7 @@ pub(super) fn simple_op(name: &str) -> Option<Op> {
|
||||
"euclid" => Op::Euclid,
|
||||
"euclidrot" => Op::EuclidRot,
|
||||
"times" => Op::Times,
|
||||
"map" => Op::Map,
|
||||
"m." => Op::MidiEmit,
|
||||
"ccval" => Op::GetMidiCC,
|
||||
"mclock" => Op::MidiClock,
|
||||
|
||||
@@ -33,6 +33,16 @@ pub(super) const WORDS: &[Word] = &[
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
Word {
|
||||
name: "print",
|
||||
aliases: &[],
|
||||
category: "Stack",
|
||||
stack: "(x --)",
|
||||
desc: "Print top of stack to footer bar",
|
||||
example: "42 print",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
Word {
|
||||
name: "swap",
|
||||
aliases: &[],
|
||||
@@ -502,17 +512,17 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Logic",
|
||||
stack: "(true-quot false-quot bool --)",
|
||||
desc: "Execute true-quot if true, else false-quot",
|
||||
example: "{ 1 } { 2 } coin ifelse",
|
||||
example: "( 1 ) ( 2 ) coin ifelse",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
Word {
|
||||
name: "pick",
|
||||
name: "select",
|
||||
aliases: &[],
|
||||
category: "Logic",
|
||||
stack: "(..quots n --)",
|
||||
desc: "Execute nth quotation (0-indexed)",
|
||||
example: "{ 1 } { 2 } { 3 } 2 pick => 3",
|
||||
example: "( 1 ) ( 2 ) ( 3 ) 2 select => 3",
|
||||
compile: Simple,
|
||||
varargs: true,
|
||||
},
|
||||
@@ -522,7 +532,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Logic",
|
||||
stack: "(quot bool --)",
|
||||
desc: "Execute quotation if true",
|
||||
example: "{ 2 distort } 0.5 chance ?",
|
||||
example: "( 2 distort ) 0.5 chance ?",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -532,7 +542,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Logic",
|
||||
stack: "(quot bool --)",
|
||||
desc: "Execute quotation if false",
|
||||
example: "{ 1 distort } 0.5 chance !?",
|
||||
example: "( 1 distort ) 0.5 chance !?",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -542,7 +552,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Logic",
|
||||
stack: "(quot --)",
|
||||
desc: "Execute quotation unconditionally",
|
||||
example: "{ 2 * } apply",
|
||||
example: "( 2 * ) apply",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -553,7 +563,17 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Control",
|
||||
stack: "(n quot --)",
|
||||
desc: "Execute quotation n times, @i holds current index",
|
||||
example: "4 { @i . } times => 0 1 2 3",
|
||||
example: "4 ( @i . ) times => 0 1 2 3",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
Word {
|
||||
name: "map",
|
||||
aliases: &[],
|
||||
category: "Control",
|
||||
stack: "(..vals quot -- ..results)",
|
||||
desc: "Apply quotation to each stack element",
|
||||
example: "1 2 3 ( 10 * ) map => 10 20 30",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
|
||||
@@ -28,14 +28,14 @@ pub(super) const WORDS: &[Word] = &[
|
||||
aliases: &[],
|
||||
category: "Envelope",
|
||||
stack: "(v.. --)",
|
||||
desc: "Set velocity",
|
||||
example: "100 velocity",
|
||||
desc: "Set velocity (0-1)",
|
||||
example: "0.8 velocity",
|
||||
compile: Param,
|
||||
varargs: true,
|
||||
},
|
||||
Word {
|
||||
name: "attack",
|
||||
aliases: &["att"],
|
||||
aliases: &["att", "a"],
|
||||
category: "Envelope",
|
||||
stack: "(v.. --)",
|
||||
desc: "Set attack time",
|
||||
@@ -45,7 +45,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
},
|
||||
Word {
|
||||
name: "decay",
|
||||
aliases: &["dec"],
|
||||
aliases: &["dec", "d"],
|
||||
category: "Envelope",
|
||||
stack: "(v.. --)",
|
||||
desc: "Set decay time",
|
||||
@@ -55,7 +55,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
},
|
||||
Word {
|
||||
name: "sustain",
|
||||
aliases: &["sus"],
|
||||
aliases: &["sus", "s"],
|
||||
category: "Envelope",
|
||||
stack: "(v.. --)",
|
||||
desc: "Set sustain level",
|
||||
@@ -65,7 +65,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
},
|
||||
Word {
|
||||
name: "release",
|
||||
aliases: &["rel"],
|
||||
aliases: &["rel", "r"],
|
||||
category: "Envelope",
|
||||
stack: "(v.. --)",
|
||||
desc: "Set release time",
|
||||
|
||||
@@ -60,7 +60,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Probability",
|
||||
stack: "(quot prob --)",
|
||||
desc: "Execute quotation with probability (0.0-1.0)",
|
||||
example: "{ 2 distort } 0.75 chance",
|
||||
example: "( 2 distort ) 0.75 chance",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -70,7 +70,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Probability",
|
||||
stack: "(quot pct --)",
|
||||
desc: "Execute quotation with probability (0-100)",
|
||||
example: "{ 2 distort } 75 prob",
|
||||
example: "( 2 distort ) 75 prob",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -150,7 +150,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Probability",
|
||||
stack: "(quot --)",
|
||||
desc: "Always execute quotation",
|
||||
example: "{ 2 distort } always",
|
||||
example: "( 2 distort ) always",
|
||||
compile: Probability(1.0),
|
||||
varargs: false,
|
||||
},
|
||||
@@ -160,7 +160,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Probability",
|
||||
stack: "(quot --)",
|
||||
desc: "Never execute quotation",
|
||||
example: "{ 2 distort } never",
|
||||
example: "( 2 distort ) never",
|
||||
compile: Probability(0.0),
|
||||
varargs: false,
|
||||
},
|
||||
@@ -170,7 +170,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Probability",
|
||||
stack: "(quot --)",
|
||||
desc: "Execute quotation 75% of the time",
|
||||
example: "{ 2 distort } often",
|
||||
example: "( 2 distort ) often",
|
||||
compile: Probability(0.75),
|
||||
varargs: false,
|
||||
},
|
||||
@@ -180,7 +180,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Probability",
|
||||
stack: "(quot --)",
|
||||
desc: "Execute quotation 50% of the time",
|
||||
example: "{ 2 distort } sometimes",
|
||||
example: "( 2 distort ) sometimes",
|
||||
compile: Probability(0.5),
|
||||
varargs: false,
|
||||
},
|
||||
@@ -190,7 +190,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Probability",
|
||||
stack: "(quot --)",
|
||||
desc: "Execute quotation 25% of the time",
|
||||
example: "{ 2 distort } rarely",
|
||||
example: "( 2 distort ) rarely",
|
||||
compile: Probability(0.25),
|
||||
varargs: false,
|
||||
},
|
||||
@@ -200,7 +200,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Probability",
|
||||
stack: "(quot --)",
|
||||
desc: "Execute quotation 10% of the time",
|
||||
example: "{ 2 distort } almostNever",
|
||||
example: "( 2 distort ) almostNever",
|
||||
compile: Probability(0.1),
|
||||
varargs: false,
|
||||
},
|
||||
@@ -210,7 +210,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Probability",
|
||||
stack: "(quot --)",
|
||||
desc: "Execute quotation 90% of the time",
|
||||
example: "{ 2 distort } almostAlways",
|
||||
example: "( 2 distort ) almostAlways",
|
||||
compile: Probability(0.9),
|
||||
varargs: false,
|
||||
},
|
||||
@@ -221,7 +221,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Time",
|
||||
stack: "(quot n --)",
|
||||
desc: "Execute quotation every nth iteration",
|
||||
example: "{ 2 distort } 4 every",
|
||||
example: "( 2 distort ) 4 every",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -231,7 +231,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Time",
|
||||
stack: "(quot n --)",
|
||||
desc: "Execute quotation on all iterations except every nth",
|
||||
example: "{ 2 distort } 4 except",
|
||||
example: "( 2 distort ) 4 except",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -241,7 +241,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Time",
|
||||
stack: "(quot n offset --)",
|
||||
desc: "Execute quotation every nth iteration with phase offset",
|
||||
example: "{ snare } 4 2 every+ => fires at iter 2, 6, 10...",
|
||||
example: "( snare ) 4 2 every+ => fires at iter 2, 6, 10...",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -251,7 +251,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Time",
|
||||
stack: "(quot n offset --)",
|
||||
desc: "Skip quotation every nth iteration with phase offset",
|
||||
example: "{ snare } 4 2 except+ => skips at iter 2, 6, 10...",
|
||||
example: "( snare ) 4 2 except+ => skips at iter 2, 6, 10...",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -261,7 +261,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Time",
|
||||
stack: "(quot k n --)",
|
||||
desc: "Execute quotation using Euclidean distribution over step runs",
|
||||
example: "{ 2 distort } 3 8 bjork",
|
||||
example: "( 2 distort ) 3 8 bjork",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -271,7 +271,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Time",
|
||||
stack: "(quot k n --)",
|
||||
desc: "Execute quotation using Euclidean distribution over pattern iterations",
|
||||
example: "{ 2 distort } 3 8 pbjork",
|
||||
example: "( 2 distort ) 3 8 pbjork",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -280,8 +280,8 @@ pub(super) const WORDS: &[Word] = &[
|
||||
aliases: &[],
|
||||
category: "Time",
|
||||
stack: "(n --)",
|
||||
desc: "Fit sample to n beats",
|
||||
example: "\"break\" s 4 loop @",
|
||||
desc: "Fit sample to n steps",
|
||||
example: "\"break\" s 16 loop @",
|
||||
compile: Simple,
|
||||
varargs: false,
|
||||
},
|
||||
@@ -456,7 +456,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Desktop",
|
||||
stack: "(-- bool)",
|
||||
desc: "1 when mouse button held, 0 otherwise",
|
||||
example: "mdown { \"crash\" s . } ?",
|
||||
example: "mdown ( \"crash\" s . ) ?",
|
||||
compile: Context("mdown"),
|
||||
varargs: false,
|
||||
},
|
||||
@@ -487,7 +487,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
category: "Generator",
|
||||
stack: "(quot n -- results...)",
|
||||
desc: "Execute quotation n times, push all results",
|
||||
example: "{ 1 6 rand } 4 gen => 4 random values",
|
||||
example: "( 1 6 rand ) 4 gen => 4 random values",
|
||||
compile: Simple,
|
||||
varargs: true,
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@ pub(super) const WORDS: &[Word] = &[
|
||||
// Sound
|
||||
Word {
|
||||
name: "sound",
|
||||
aliases: &["s"],
|
||||
aliases: &["snd"],
|
||||
category: "Sound",
|
||||
stack: "(name --)",
|
||||
desc: "Begin sound command",
|
||||
@@ -186,6 +186,26 @@ pub(super) const WORDS: &[Word] = &[
|
||||
compile: Param,
|
||||
varargs: true,
|
||||
},
|
||||
Word {
|
||||
name: "slice",
|
||||
aliases: &[],
|
||||
category: "Sample",
|
||||
stack: "(v.. --)",
|
||||
desc: "Divide sample into N equal slices",
|
||||
example: r#""break" s 8 slice 3 pick ."#,
|
||||
compile: Param,
|
||||
varargs: true,
|
||||
},
|
||||
Word {
|
||||
name: "pick",
|
||||
aliases: &[],
|
||||
category: "Sample",
|
||||
stack: "(v.. --)",
|
||||
desc: "Select which slice to play (0-indexed, wraps)",
|
||||
example: r#""break" s 8 slice 3 pick ."#,
|
||||
compile: Param,
|
||||
varargs: true,
|
||||
},
|
||||
Word {
|
||||
name: "voice",
|
||||
aliases: &[],
|
||||
@@ -357,6 +377,16 @@ pub(super) const WORDS: &[Word] = &[
|
||||
compile: Param,
|
||||
varargs: true,
|
||||
},
|
||||
Word {
|
||||
name: "partials",
|
||||
aliases: &[],
|
||||
category: "Oscillator",
|
||||
stack: "(v.. --)",
|
||||
desc: "Set number of active harmonics (add source only)",
|
||||
example: "16 partials",
|
||||
compile: Param,
|
||||
varargs: true,
|
||||
},
|
||||
Word {
|
||||
name: "coarse",
|
||||
aliases: &[],
|
||||
|
||||
15
crates/markdown/README.md
Normal file
15
crates/markdown/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# cagire-markdown
|
||||
|
||||
Markdown parser and renderer that produces ratatui-styled lines. Used for the built-in help/documentation views.
|
||||
|
||||
## Modules
|
||||
|
||||
| Module | Description |
|
||||
|--------|-------------|
|
||||
| `parser` | Markdown-to-styled-lines conversion |
|
||||
| `highlighter` | `CodeHighlighter` trait for syntax highlighting in fenced code blocks |
|
||||
| `theme` | Color mappings for markdown elements |
|
||||
|
||||
## Key Trait
|
||||
|
||||
- **`CodeHighlighter`** — Implement to provide language-specific syntax highlighting. Returns `Vec<(Style, String)>` per line.
|
||||
22
crates/project/README.md
Normal file
22
crates/project/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# cagire-project
|
||||
|
||||
Project data model and persistence for Cagire.
|
||||
|
||||
## Modules
|
||||
|
||||
| Module | Description |
|
||||
|--------|-------------|
|
||||
| `project` | `Project`, `Bank`, `Pattern`, `Step` structs and constants |
|
||||
| `file` | File I/O (save/load) |
|
||||
| `share` | Project sharing/export |
|
||||
|
||||
## Key Types
|
||||
|
||||
- **`Project`** — Top-level container: banks of patterns
|
||||
- **`Bank`** — Collection of patterns
|
||||
- **`Pattern`** — Sequence of steps with metadata
|
||||
- **`Step`** — Single step holding a Forth script
|
||||
|
||||
## Constants
|
||||
|
||||
`MAX_BANKS=32`, `MAX_PATTERNS=32`, `MAX_STEPS=1024`
|
||||
@@ -170,6 +170,17 @@ impl LaunchQuantization {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn short_label(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Immediate => "Imm",
|
||||
Self::Beat => "Bt",
|
||||
Self::Bar => "1B",
|
||||
Self::Bars2 => "2B",
|
||||
Self::Bars4 => "4B",
|
||||
Self::Bars8 => "8B",
|
||||
}
|
||||
}
|
||||
|
||||
/// Cycle to the next longer quantization, clamped at `Bars8`.
|
||||
pub fn next(&self) -> Self {
|
||||
match self {
|
||||
@@ -212,6 +223,13 @@ impl SyncMode {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn short_label(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Reset => "Rst",
|
||||
Self::PhaseLock => "Plk",
|
||||
}
|
||||
}
|
||||
|
||||
/// Toggle between Reset and PhaseLock.
|
||||
pub fn toggle(&self) -> Self {
|
||||
match self {
|
||||
@@ -525,6 +543,8 @@ pub struct Bank {
|
||||
pub patterns: Vec<Pattern>,
|
||||
#[serde(default)]
|
||||
pub name: Option<String>,
|
||||
#[serde(default)]
|
||||
pub prelude: String,
|
||||
}
|
||||
|
||||
impl Bank {
|
||||
@@ -542,6 +562,7 @@ impl Default for Bank {
|
||||
Self {
|
||||
patterns: (0..MAX_PATTERNS).map(|_| Pattern::default()).collect(),
|
||||
name: None,
|
||||
prelude: String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,9 +96,9 @@ mod tests {
|
||||
#[test]
|
||||
fn roundtrip_empty() {
|
||||
let pattern = Pattern::default();
|
||||
let encoded = export(&pattern).unwrap();
|
||||
let encoded = export(&pattern).expect("export pattern");
|
||||
assert!(encoded.starts_with("cgr:"));
|
||||
let decoded = import(&encoded).unwrap();
|
||||
let decoded = import(&encoded).expect("import pattern");
|
||||
assert_eq!(decoded.length, pattern.length);
|
||||
assert_eq!(decoded.steps.len(), pattern.steps.len());
|
||||
}
|
||||
@@ -127,8 +127,8 @@ mod tests {
|
||||
pattern.length = 8;
|
||||
pattern.name = Some("Test".to_string());
|
||||
|
||||
let encoded = export(&pattern).unwrap();
|
||||
let decoded = import(&encoded).unwrap();
|
||||
let encoded = export(&pattern).expect("export pattern");
|
||||
let decoded = import(&encoded).expect("import pattern");
|
||||
|
||||
assert_eq!(decoded.length, 8);
|
||||
assert_eq!(decoded.name.as_deref(), Some("Test"));
|
||||
@@ -152,9 +152,9 @@ mod tests {
|
||||
#[test]
|
||||
fn whitespace_trimming() {
|
||||
let pattern = Pattern::default();
|
||||
let encoded = export(&pattern).unwrap();
|
||||
let encoded = export(&pattern).expect("export pattern");
|
||||
let padded = format!(" {encoded} \n");
|
||||
let decoded = import(&padded).unwrap();
|
||||
let decoded = import(&padded).expect("import padded pattern");
|
||||
assert_eq!(decoded.length, pattern.length);
|
||||
}
|
||||
|
||||
@@ -172,15 +172,15 @@ mod tests {
|
||||
pattern.length = 16;
|
||||
|
||||
// Current (msgpack+brotli)
|
||||
let new_encoded = export(&pattern).unwrap();
|
||||
let new_encoded = export(&pattern).expect("export pattern");
|
||||
|
||||
// Old pipeline (json+deflate) for comparison
|
||||
use std::io::Write;
|
||||
let json = serde_json::to_vec(&pattern).unwrap();
|
||||
let json = serde_json::to_vec(&pattern).expect("serialize json");
|
||||
let mut encoder =
|
||||
flate2::write::DeflateEncoder::new(Vec::new(), flate2::Compression::best());
|
||||
encoder.write_all(&json).unwrap();
|
||||
let old_compressed = encoder.finish().unwrap();
|
||||
encoder.write_all(&json).expect("write to encoder");
|
||||
let old_compressed = encoder.finish().expect("finish encoder");
|
||||
let old_encoded = format!("cgr:{}", URL_SAFE_NO_PAD.encode(&old_compressed));
|
||||
|
||||
assert!(
|
||||
@@ -203,9 +203,9 @@ mod tests {
|
||||
bank.patterns[0].length = 8;
|
||||
bank.name = Some("Drums".to_string());
|
||||
|
||||
let encoded = export_bank(&bank).unwrap();
|
||||
let encoded = export_bank(&bank).expect("export bank");
|
||||
assert!(encoded.starts_with("cgrb:"));
|
||||
let decoded = import_bank(&encoded).unwrap();
|
||||
let decoded = import_bank(&encoded).expect("import bank");
|
||||
|
||||
assert_eq!(decoded.name.as_deref(), Some("Drums"));
|
||||
assert_eq!(decoded.patterns[0].length, 8);
|
||||
|
||||
@@ -11,4 +11,4 @@ description = "TUI components for cagire sequencer"
|
||||
rand = "0.8"
|
||||
ratatui = "0.30"
|
||||
regex = "1"
|
||||
tui-textarea = { git = "https://github.com/phsym/tui-textarea", branch = "main", features = ["search"] }
|
||||
tui-textarea = { git = "https://github.com/phsym/tui-textarea", rev = "e2ec4d3", features = ["search"] }
|
||||
|
||||
25
crates/ratatui/README.md
Normal file
25
crates/ratatui/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# cagire-ratatui
|
||||
|
||||
TUI widget library and theme system for Cagire.
|
||||
|
||||
## Widgets
|
||||
|
||||
`category_list`, `confirm`, `editor`, `file_browser`, `hint_bar`, `lissajous`, `list_select`, `modal`, `nav_minimap`, `props_form`, `sample_browser`, `scope`, `scroll_indicators`, `search_bar`, `section_header`, `sparkles`, `spectrum`, `text_input`, `vu_meter`, `waveform`
|
||||
|
||||
## Theme System
|
||||
|
||||
The `theme/` module provides a palette-based theming system using Oklab color space.
|
||||
|
||||
| Module | Description |
|
||||
|--------|-------------|
|
||||
| `mod` | `THEMES` array, `CURRENT_THEME` thread-local, `get()`/`set()` |
|
||||
| `palette` | `Palette` (14 fields), color manipulation helpers (`shift`, `mix`, `tint_bg`, ...) |
|
||||
| `build` | Derives ~190 `ThemeColors` fields from a `Palette` |
|
||||
| `transform` | HSV-based hue rotation for generated palettes |
|
||||
|
||||
25 built-in themes.
|
||||
|
||||
## Key Types
|
||||
|
||||
- **`Palette`** — 14-field color definition, input to theme generation
|
||||
- **`ThemeColors`** — ~190 derived semantic colors used throughout the UI
|
||||
@@ -1,6 +1,7 @@
|
||||
//! Script editor widget with completion, search, and sample finder popups.
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::theme;
|
||||
use ratatui::{
|
||||
@@ -25,7 +26,7 @@ pub struct CompletionCandidate {
|
||||
}
|
||||
|
||||
struct CompletionState {
|
||||
candidates: Vec<CompletionCandidate>,
|
||||
candidates: Arc<[CompletionCandidate]>,
|
||||
matches: Vec<usize>,
|
||||
cursor: usize,
|
||||
prefix: String,
|
||||
@@ -37,7 +38,7 @@ struct CompletionState {
|
||||
impl CompletionState {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
candidates: Vec::new(),
|
||||
candidates: Arc::from([]),
|
||||
matches: Vec::new(),
|
||||
cursor: 0,
|
||||
prefix: String::new(),
|
||||
@@ -171,7 +172,7 @@ impl Editor {
|
||||
self.scroll_offset.set(0);
|
||||
}
|
||||
|
||||
pub fn set_candidates(&mut self, candidates: Vec<CompletionCandidate>) {
|
||||
pub fn set_candidates(&mut self, candidates: Arc<[CompletionCandidate]>) {
|
||||
self.completion.candidates = candidates;
|
||||
}
|
||||
|
||||
@@ -487,7 +488,7 @@ impl Editor {
|
||||
if is_cursor {
|
||||
cursor_style
|
||||
} else if is_selected {
|
||||
base_style.bg(selection_style.bg.unwrap())
|
||||
base_style.bg(selection_style.bg.expect("selection style has bg"))
|
||||
} else {
|
||||
base_style
|
||||
}
|
||||
|
||||
@@ -14,11 +14,14 @@ pub struct FileBrowserModal<'a> {
|
||||
title: &'a str,
|
||||
input: &'a str,
|
||||
entries: &'a [(String, bool, bool)],
|
||||
audio_counts: &'a [Option<usize>],
|
||||
selected: usize,
|
||||
scroll_offset: usize,
|
||||
border_color: Option<Color>,
|
||||
width: u16,
|
||||
height: u16,
|
||||
hints: Option<Line<'a>>,
|
||||
color_path: bool,
|
||||
}
|
||||
|
||||
impl<'a> FileBrowserModal<'a> {
|
||||
@@ -27,11 +30,14 @@ impl<'a> FileBrowserModal<'a> {
|
||||
title,
|
||||
input,
|
||||
entries,
|
||||
audio_counts: &[],
|
||||
selected: 0,
|
||||
scroll_offset: 0,
|
||||
border_color: None,
|
||||
width: 60,
|
||||
height: 16,
|
||||
hints: None,
|
||||
color_path: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +66,21 @@ impl<'a> FileBrowserModal<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn hints(mut self, hints: Line<'a>) -> Self {
|
||||
self.hints = Some(hints);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn audio_counts(mut self, counts: &'a [Option<usize>]) -> Self {
|
||||
self.audio_counts = counts;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn color_path(mut self) -> Self {
|
||||
self.color_path = true;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn render_centered(self, frame: &mut Frame, term: Rect) -> Rect {
|
||||
let colors = theme::get();
|
||||
let border_color = self.border_color.unwrap_or(colors.ui.text_primary);
|
||||
@@ -70,37 +91,61 @@ impl<'a> FileBrowserModal<'a> {
|
||||
.border_color(border_color)
|
||||
.render_centered(frame, term);
|
||||
|
||||
let rows = Layout::vertical([Constraint::Length(1), Constraint::Min(1)]).split(inner);
|
||||
let has_hints = self.hints.is_some();
|
||||
let constraints = if has_hints {
|
||||
vec![
|
||||
Constraint::Length(1),
|
||||
Constraint::Min(1),
|
||||
Constraint::Length(1),
|
||||
]
|
||||
} else {
|
||||
vec![Constraint::Length(1), Constraint::Min(1)]
|
||||
};
|
||||
let rows = Layout::vertical(constraints).split(inner);
|
||||
|
||||
// Input line
|
||||
frame.render_widget(
|
||||
Paragraph::new(Line::from(vec![
|
||||
let input_spans = if self.color_path {
|
||||
let (path_part, filter_part) = match self.input.rfind('/') {
|
||||
Some(pos) => (&self.input[..=pos], &self.input[pos + 1..]),
|
||||
None => ("", self.input),
|
||||
};
|
||||
vec![
|
||||
Span::raw("> "),
|
||||
Span::styled(path_part.to_string(), Style::new().fg(colors.browser.directory)),
|
||||
Span::styled(filter_part.to_string(), Style::new().fg(colors.input.text)),
|
||||
Span::styled("█", Style::new().fg(colors.input.cursor)),
|
||||
]
|
||||
} else {
|
||||
vec![
|
||||
Span::raw("> "),
|
||||
Span::styled(self.input, Style::new().fg(colors.input.text)),
|
||||
Span::styled("█", Style::new().fg(colors.input.cursor)),
|
||||
])),
|
||||
rows[0],
|
||||
);
|
||||
]
|
||||
};
|
||||
frame.render_widget(Paragraph::new(Line::from(input_spans)), rows[0]);
|
||||
|
||||
// Hints bar
|
||||
if let Some(hints) = self.hints {
|
||||
let hint_row = rows[2];
|
||||
frame.render_widget(
|
||||
Paragraph::new(hints).alignment(ratatui::layout::Alignment::Right),
|
||||
hint_row,
|
||||
);
|
||||
}
|
||||
|
||||
// Entries list
|
||||
let visible_height = rows[1].height as usize;
|
||||
let visible_entries = self
|
||||
.entries
|
||||
.iter()
|
||||
.enumerate()
|
||||
.skip(self.scroll_offset)
|
||||
.take(visible_height);
|
||||
|
||||
let lines: Vec<Line> = visible_entries
|
||||
.enumerate()
|
||||
.map(|(i, (name, is_dir, is_cagire))| {
|
||||
let abs_idx = i + self.scroll_offset;
|
||||
.map(|(abs_idx, (name, is_dir, is_cagire))| {
|
||||
let is_selected = abs_idx == self.selected;
|
||||
let prefix = if is_selected { "> " } else { " " };
|
||||
let display = if *is_dir {
|
||||
format!("{prefix}{name}/")
|
||||
} else {
|
||||
format!("{prefix}{name}")
|
||||
};
|
||||
let color = if is_selected {
|
||||
colors.browser.selected
|
||||
} else if *is_dir {
|
||||
@@ -110,7 +155,21 @@ impl<'a> FileBrowserModal<'a> {
|
||||
} else {
|
||||
colors.browser.file
|
||||
};
|
||||
Line::from(Span::styled(display, Style::new().fg(color)))
|
||||
let display = if *is_dir {
|
||||
format!("{prefix}{name}/")
|
||||
} else {
|
||||
format!("{prefix}{name}")
|
||||
};
|
||||
let mut spans = vec![Span::styled(display, Style::new().fg(color))];
|
||||
if *is_dir && name != ".." {
|
||||
if let Some(Some(count)) = self.audio_counts.get(abs_idx) {
|
||||
spans.push(Span::styled(
|
||||
format!(" ({count})"),
|
||||
Style::new().fg(colors.browser.file),
|
||||
));
|
||||
}
|
||||
}
|
||||
Line::from(spans)
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ pub use scroll_indicators::{render_scroll_indicators, IndicatorAlign};
|
||||
pub use search_bar::render_search_bar;
|
||||
pub use section_header::render_section_header;
|
||||
pub use sparkles::Sparkles;
|
||||
pub use spectrum::Spectrum;
|
||||
pub use spectrum::{Spectrum, SpectrumStyle};
|
||||
pub use text_input::TextInputModal;
|
||||
pub use vu_meter::VuMeter;
|
||||
pub use waveform::Waveform;
|
||||
|
||||
@@ -9,6 +9,13 @@ use std::cell::RefCell;
|
||||
|
||||
thread_local! {
|
||||
static PATTERNS: RefCell<Vec<u8>> = const { RefCell::new(Vec::new()) };
|
||||
static TRAIL: RefCell<TrailState> = const { RefCell::new(TrailState { fine_w: 0, fine_h: 0, heat: Vec::new() }) };
|
||||
}
|
||||
|
||||
struct TrailState {
|
||||
fine_w: usize,
|
||||
fine_h: usize,
|
||||
heat: Vec<f32>,
|
||||
}
|
||||
|
||||
/// XY oscilloscope plotting left vs right channels as a Lissajous curve.
|
||||
@@ -17,6 +24,7 @@ pub struct Lissajous<'a> {
|
||||
right: &'a [f32],
|
||||
color: Option<Color>,
|
||||
gain: f32,
|
||||
trails: bool,
|
||||
}
|
||||
|
||||
impl<'a> Lissajous<'a> {
|
||||
@@ -26,9 +34,15 @@ impl<'a> Lissajous<'a> {
|
||||
right,
|
||||
color: None,
|
||||
gain: 1.0,
|
||||
trails: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trails(mut self, enabled: bool) -> Self {
|
||||
self.trails = enabled;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn color(mut self, c: Color) -> Self {
|
||||
self.color = Some(c);
|
||||
self
|
||||
@@ -46,6 +60,16 @@ impl Widget for Lissajous<'_> {
|
||||
return;
|
||||
}
|
||||
|
||||
if self.trails {
|
||||
self.render_trails(area, buf);
|
||||
} else {
|
||||
self.render_normal(area, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Lissajous<'_> {
|
||||
fn render_normal(self, area: Rect, buf: &mut Buffer) {
|
||||
let color = self.color.unwrap_or_else(|| theme::get().meter.low);
|
||||
let width = area.width as usize;
|
||||
let height = area.height as usize;
|
||||
@@ -63,7 +87,6 @@ impl Widget for Lissajous<'_> {
|
||||
let l = (self.left[i] * self.gain).clamp(-1.0, 1.0);
|
||||
let r = (self.right[i] * self.gain).clamp(-1.0, 1.0);
|
||||
|
||||
// X = right channel, Y = left channel (inverted so up = positive)
|
||||
let fine_x = ((r + 1.0) * 0.5 * (fine_width - 1) as f32).round() as usize;
|
||||
let fine_y = ((1.0 - l) * 0.5 * (fine_height - 1) as f32).round() as usize;
|
||||
let fine_x = fine_x.min(fine_width - 1);
|
||||
@@ -74,19 +97,7 @@ impl Widget for Lissajous<'_> {
|
||||
let dot_x = fine_x % 2;
|
||||
let dot_y = fine_y % 4;
|
||||
|
||||
let bit = match (dot_x, dot_y) {
|
||||
(0, 0) => 0x01,
|
||||
(0, 1) => 0x02,
|
||||
(0, 2) => 0x04,
|
||||
(0, 3) => 0x40,
|
||||
(1, 0) => 0x08,
|
||||
(1, 1) => 0x10,
|
||||
(1, 2) => 0x20,
|
||||
(1, 3) => 0x80,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
patterns[char_y * width + char_x] |= bit;
|
||||
patterns[char_y * width + char_x] |= braille_bit(dot_x, dot_y);
|
||||
}
|
||||
|
||||
for cy in 0..height {
|
||||
@@ -102,4 +113,122 @@ impl Widget for Lissajous<'_> {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn render_trails(self, area: Rect, buf: &mut Buffer) {
|
||||
let theme = theme::get();
|
||||
let width = area.width as usize;
|
||||
let height = area.height as usize;
|
||||
let fine_w = width * 2;
|
||||
let fine_h = height * 4;
|
||||
let len = self.left.len().min(self.right.len());
|
||||
|
||||
TRAIL.with(|t| {
|
||||
let mut trail = t.borrow_mut();
|
||||
|
||||
// Reset if dimensions changed
|
||||
if trail.fine_w != fine_w || trail.fine_h != fine_h {
|
||||
trail.fine_w = fine_w;
|
||||
trail.fine_h = fine_h;
|
||||
trail.heat.clear();
|
||||
trail.heat.resize(fine_w * fine_h, 0.0);
|
||||
}
|
||||
|
||||
// Decay existing heat
|
||||
for h in trail.heat.iter_mut() {
|
||||
*h *= 0.85;
|
||||
}
|
||||
|
||||
// Plot new sample points
|
||||
for i in 0..len {
|
||||
let l = (self.left[i] * self.gain).clamp(-1.0, 1.0);
|
||||
let r = (self.right[i] * self.gain).clamp(-1.0, 1.0);
|
||||
|
||||
let fx = ((r + 1.0) * 0.5 * (fine_w - 1) as f32).round() as usize;
|
||||
let fy = ((1.0 - l) * 0.5 * (fine_h - 1) as f32).round() as usize;
|
||||
let fx = fx.min(fine_w - 1);
|
||||
let fy = fy.min(fine_h - 1);
|
||||
|
||||
trail.heat[fy * fine_w + fx] = 1.0;
|
||||
}
|
||||
|
||||
// Convert heat map to braille
|
||||
PATTERNS.with(|p| {
|
||||
let mut patterns = p.borrow_mut();
|
||||
patterns.clear();
|
||||
patterns.resize(width * height, 0);
|
||||
|
||||
// Track brightest color per cell
|
||||
let mut colors: Vec<Option<Color>> = vec![None; width * height];
|
||||
|
||||
for fy in 0..fine_h {
|
||||
for fx in 0..fine_w {
|
||||
let h = trail.heat[fy * fine_w + fx];
|
||||
if h < 0.05 {
|
||||
continue;
|
||||
}
|
||||
|
||||
let cx = fx / 2;
|
||||
let cy = fy / 4;
|
||||
let dx = fx % 2;
|
||||
let dy = fy % 4;
|
||||
|
||||
let idx = cy * width + cx;
|
||||
patterns[idx] |= braille_bit(dx, dy);
|
||||
|
||||
let dot_color = if h > 0.7 {
|
||||
theme.meter.high
|
||||
} else if h > 0.25 {
|
||||
theme.meter.mid
|
||||
} else {
|
||||
theme.meter.low
|
||||
};
|
||||
|
||||
let replace = match colors[idx] {
|
||||
None => true,
|
||||
Some(cur) => {
|
||||
rank_color(dot_color, &theme) > rank_color(cur, &theme)
|
||||
}
|
||||
};
|
||||
if replace {
|
||||
colors[idx] = Some(dot_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for cy in 0..height {
|
||||
for cx in 0..width {
|
||||
let idx = cy * width + cx;
|
||||
let pattern = patterns[idx];
|
||||
if pattern != 0 {
|
||||
let ch = char::from_u32(0x2800 + pattern as u32).unwrap_or(' ');
|
||||
let color = colors[idx].unwrap_or(theme.meter.low);
|
||||
buf[(area.x + cx as u16, area.y + cy as u16)]
|
||||
.set_char(ch)
|
||||
.set_fg(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn braille_bit(dot_x: usize, dot_y: usize) -> u8 {
|
||||
match (dot_x, dot_y) {
|
||||
(0, 0) => 0x01,
|
||||
(0, 1) => 0x02,
|
||||
(0, 2) => 0x04,
|
||||
(0, 3) => 0x40,
|
||||
(1, 0) => 0x08,
|
||||
(1, 1) => 0x10,
|
||||
(1, 2) => 0x20,
|
||||
(1, 3) => 0x80,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn rank_color(c: Color, theme: &crate::theme::ThemeColors) -> u8 {
|
||||
if c == theme.meter.high { 2 }
|
||||
else if c == theme.meter.mid { 1 }
|
||||
else { 0 }
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::theme;
|
||||
use ratatui::layout::{Constraint, Layout, Rect};
|
||||
use ratatui::style::{Modifier, Style};
|
||||
use ratatui::text::{Line, Span};
|
||||
use ratatui::widgets::{Block, Borders, Paragraph};
|
||||
use ratatui::widgets::{Block, Borders, Paragraph, Wrap};
|
||||
use ratatui::Frame;
|
||||
|
||||
/// Node type in the sample tree.
|
||||
@@ -23,6 +23,7 @@ pub struct TreeLine {
|
||||
pub label: String,
|
||||
pub folder: String,
|
||||
pub index: usize,
|
||||
pub child_count: usize,
|
||||
}
|
||||
|
||||
/// Tree-view browser for navigating sample folders.
|
||||
@@ -116,13 +117,13 @@ impl<'a> SampleBrowser<'a> {
|
||||
fn render_tree(&self, frame: &mut Frame, area: Rect, colors: &theme::ThemeColors) {
|
||||
let height = area.height as usize;
|
||||
if self.entries.is_empty() {
|
||||
let msg = if self.search_query.is_empty() {
|
||||
"No samples loaded"
|
||||
if self.search_query.is_empty() {
|
||||
self.render_empty_guide(frame, area, colors);
|
||||
} else {
|
||||
"No matches"
|
||||
};
|
||||
let line = Line::from(Span::styled(msg, Style::new().fg(colors.browser.empty_text)));
|
||||
frame.render_widget(Paragraph::new(vec![line]), area);
|
||||
let line =
|
||||
Line::from(Span::styled("No matches", Style::new().fg(colors.browser.empty_text)));
|
||||
frame.render_widget(Paragraph::new(vec![line]), area);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -136,10 +137,10 @@ impl<'a> SampleBrowser<'a> {
|
||||
|
||||
let (icon, icon_color) = match entry.kind {
|
||||
TreeLineKind::Root { expanded: true } | TreeLineKind::Folder { expanded: true } => {
|
||||
("\u{25BC} ", colors.browser.folder_icon)
|
||||
("\u{2212} ", colors.browser.folder_icon)
|
||||
}
|
||||
TreeLineKind::Root { expanded: false }
|
||||
| TreeLineKind::Folder { expanded: false } => ("\u{25B6} ", colors.browser.folder_icon),
|
||||
| TreeLineKind::Folder { expanded: false } => ("+ ", colors.browser.folder_icon),
|
||||
TreeLineKind::File => ("\u{266A} ", colors.browser.file_icon),
|
||||
};
|
||||
|
||||
@@ -163,15 +164,43 @@ impl<'a> SampleBrowser<'a> {
|
||||
Style::new().fg(icon_color)
|
||||
};
|
||||
|
||||
let prefix_width = indent.len() + 2; // indent + icon
|
||||
let suffix = match entry.kind {
|
||||
TreeLineKind::File => format!(" {}", entry.index),
|
||||
TreeLineKind::Root { expanded: false }
|
||||
| TreeLineKind::Folder { expanded: false }
|
||||
if entry.child_count > 0 =>
|
||||
{
|
||||
format!(" ({})", entry.child_count)
|
||||
}
|
||||
_ => String::new(),
|
||||
};
|
||||
let max_label = (area.width as usize)
|
||||
.saturating_sub(prefix_width)
|
||||
.saturating_sub(suffix.len());
|
||||
let label: std::borrow::Cow<str> = if entry.label.len() > max_label && max_label > 1 {
|
||||
let truncated: String = entry.label.chars().take(max_label - 1).collect();
|
||||
format!("{}\u{2026}", truncated).into()
|
||||
} else {
|
||||
(&entry.label).into()
|
||||
};
|
||||
|
||||
let mut spans = vec![
|
||||
Span::raw(indent),
|
||||
Span::styled(icon, icon_style),
|
||||
Span::styled(&entry.label, label_style),
|
||||
Span::styled(label, label_style),
|
||||
];
|
||||
|
||||
if matches!(entry.kind, TreeLineKind::File) {
|
||||
let idx_style = Style::new().fg(colors.browser.empty_text);
|
||||
spans.push(Span::styled(format!(" {}", entry.index), idx_style));
|
||||
match entry.kind {
|
||||
TreeLineKind::File => {
|
||||
let idx_style = Style::new().fg(colors.browser.empty_text);
|
||||
spans.push(Span::styled(suffix, idx_style));
|
||||
}
|
||||
_ if !suffix.is_empty() => {
|
||||
let dim_style = Style::new().fg(colors.browser.empty_text);
|
||||
spans.push(Span::styled(suffix, dim_style));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
lines.push(Line::from(spans));
|
||||
@@ -179,4 +208,47 @@ impl<'a> SampleBrowser<'a> {
|
||||
|
||||
frame.render_widget(Paragraph::new(lines), area);
|
||||
}
|
||||
|
||||
fn render_empty_guide(&self, frame: &mut Frame, area: Rect, colors: &theme::ThemeColors) {
|
||||
let muted = Style::new().fg(colors.browser.empty_text);
|
||||
let heading = Style::new().fg(colors.ui.text_primary);
|
||||
let key = Style::new().fg(colors.hint.key);
|
||||
let desc = Style::new().fg(colors.hint.text);
|
||||
let code = Style::new().fg(colors.ui.accent);
|
||||
|
||||
let lines = vec![
|
||||
Line::from(Span::styled(" No samples loaded.", muted)),
|
||||
Line::from(""),
|
||||
Line::from(Span::styled(" Load from the Engine page:", heading)),
|
||||
Line::from(""),
|
||||
Line::from(vec![
|
||||
Span::styled(" F6 ", key),
|
||||
Span::styled("Go to Engine page", desc),
|
||||
]),
|
||||
Line::from(vec![
|
||||
Span::styled(" A ", key),
|
||||
Span::styled("Add a sample folder", desc),
|
||||
]),
|
||||
Line::from(""),
|
||||
Line::from(Span::styled(" Organize samples like this:", heading)),
|
||||
Line::from(""),
|
||||
Line::from(Span::styled(" samples/", code)),
|
||||
Line::from(Span::styled(" \u{251C}\u{2500}\u{2500} kick/", code)),
|
||||
Line::from(Span::styled(" \u{2502} \u{2514}\u{2500}\u{2500} kick.wav", code)),
|
||||
Line::from(Span::styled(" \u{251C}\u{2500}\u{2500} snare/", code)),
|
||||
Line::from(Span::styled(" \u{2502} \u{2514}\u{2500}\u{2500} snare.wav", code)),
|
||||
Line::from(Span::styled(" \u{2514}\u{2500}\u{2500} hats/", code)),
|
||||
Line::from(Span::styled(" \u{251C}\u{2500}\u{2500} closed.wav", code)),
|
||||
Line::from(Span::styled(" \u{251C}\u{2500}\u{2500} open.wav", code)),
|
||||
Line::from(Span::styled(" \u{2514}\u{2500}\u{2500} pedal.wav", code)),
|
||||
Line::from(""),
|
||||
Line::from(Span::styled(" Folders become Forth words:", heading)),
|
||||
Line::from(""),
|
||||
Line::from(Span::styled(" kick sound .", code)),
|
||||
Line::from(Span::styled(" hats sound 2 n .", code)),
|
||||
Line::from(Span::styled(" snare sound 0.5 speed .", code)),
|
||||
];
|
||||
|
||||
frame.render_widget(Paragraph::new(lines).wrap(Wrap { trim: false }), area);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,59 @@
|
||||
//! 32-band frequency spectrum bar display.
|
||||
//! 32-band frequency spectrum display with optional peak hold.
|
||||
|
||||
use crate::theme;
|
||||
use ratatui::buffer::Buffer;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::style::Color;
|
||||
use ratatui::widgets::Widget;
|
||||
use std::cell::RefCell;
|
||||
|
||||
const BLOCKS: [char; 8] = ['\u{2581}', '\u{2582}', '\u{2583}', '\u{2584}', '\u{2585}', '\u{2586}', '\u{2587}', '\u{2588}'];
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum SpectrumStyle {
|
||||
#[default]
|
||||
Bars,
|
||||
Line,
|
||||
Filled,
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
static PEAKS: RefCell<[f32; 32]> = const { RefCell::new([0.0; 32]) };
|
||||
static PATTERNS: RefCell<Vec<u8>> = const { RefCell::new(Vec::new()) };
|
||||
}
|
||||
|
||||
/// 32-band spectrum analyzer using block characters.
|
||||
pub struct Spectrum<'a> {
|
||||
data: &'a [f32; 32],
|
||||
gain: f32,
|
||||
style: SpectrumStyle,
|
||||
peaks: bool,
|
||||
}
|
||||
|
||||
impl<'a> Spectrum<'a> {
|
||||
pub fn new(data: &'a [f32; 32]) -> Self {
|
||||
Self { data, gain: 1.0 }
|
||||
Self {
|
||||
data,
|
||||
gain: 1.0,
|
||||
style: SpectrumStyle::Bars,
|
||||
peaks: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gain(mut self, g: f32) -> Self {
|
||||
self.gain = g;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn style(mut self, s: SpectrumStyle) -> Self {
|
||||
self.style = s;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn peaks(mut self, enabled: bool) -> Self {
|
||||
self.peaks = enabled;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for Spectrum<'_> {
|
||||
@@ -31,45 +62,177 @@ impl Widget for Spectrum<'_> {
|
||||
return;
|
||||
}
|
||||
|
||||
let colors = theme::get();
|
||||
let height = area.height as f32;
|
||||
let base = area.width as usize / 32;
|
||||
let remainder = area.width as usize % 32;
|
||||
if base == 0 && remainder == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut x_start = area.x;
|
||||
for (band, &mag) in self.data.iter().enumerate() {
|
||||
let w = base + if band < remainder { 1 } else { 0 };
|
||||
if w == 0 {
|
||||
continue;
|
||||
}
|
||||
let bar_height = (mag * self.gain).min(1.0) * height;
|
||||
let full_cells = bar_height as usize;
|
||||
let frac = bar_height - full_cells as f32;
|
||||
let frac_idx = (frac * 8.0) as usize;
|
||||
|
||||
for row in 0..area.height as usize {
|
||||
let y = area.y + area.height - 1 - row as u16;
|
||||
let ratio = row as f32 / area.height as f32;
|
||||
let color = if ratio < 0.33 {
|
||||
Color::Rgb(colors.meter.low_rgb.0, colors.meter.low_rgb.1, colors.meter.low_rgb.2)
|
||||
} else if ratio < 0.66 {
|
||||
Color::Rgb(colors.meter.mid_rgb.0, colors.meter.mid_rgb.1, colors.meter.mid_rgb.2)
|
||||
} else {
|
||||
Color::Rgb(colors.meter.high_rgb.0, colors.meter.high_rgb.1, colors.meter.high_rgb.2)
|
||||
};
|
||||
for dx in 0..w as u16 {
|
||||
let x = x_start + dx;
|
||||
if row < full_cells {
|
||||
buf[(x, y)].set_char(BLOCKS[7]).set_fg(color);
|
||||
} else if row == full_cells && frac_idx > 0 {
|
||||
buf[(x, y)].set_char(BLOCKS[frac_idx - 1]).set_fg(color);
|
||||
// Update peak hold state
|
||||
let peak_values = if self.peaks {
|
||||
Some(PEAKS.with(|p| {
|
||||
let mut peaks = p.borrow_mut();
|
||||
for (i, &mag) in self.data.iter().enumerate() {
|
||||
let v = (mag * self.gain).min(1.0);
|
||||
if v >= peaks[i] {
|
||||
peaks[i] = v;
|
||||
} else {
|
||||
peaks[i] = (peaks[i] - 0.02).max(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
x_start += w as u16;
|
||||
*peaks
|
||||
}))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
match self.style {
|
||||
SpectrumStyle::Bars => render_bars(self.data, area, buf, self.gain, peak_values.as_ref()),
|
||||
SpectrumStyle::Line => render_braille(self.data, area, buf, self.gain, false, peak_values.as_ref()),
|
||||
SpectrumStyle::Filled => render_braille(self.data, area, buf, self.gain, true, peak_values.as_ref()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn band_color(ratio: f32, colors: &theme::ThemeColors) -> Color {
|
||||
if ratio < 0.33 {
|
||||
Color::Rgb(colors.meter.low_rgb.0, colors.meter.low_rgb.1, colors.meter.low_rgb.2)
|
||||
} else if ratio < 0.66 {
|
||||
Color::Rgb(colors.meter.mid_rgb.0, colors.meter.mid_rgb.1, colors.meter.mid_rgb.2)
|
||||
} else {
|
||||
Color::Rgb(colors.meter.high_rgb.0, colors.meter.high_rgb.1, colors.meter.high_rgb.2)
|
||||
}
|
||||
}
|
||||
|
||||
fn render_bars(data: &[f32; 32], area: Rect, buf: &mut Buffer, gain: f32, peaks: Option<&[f32; 32]>) {
|
||||
let colors = theme::get();
|
||||
let height = area.height as f32;
|
||||
let base = area.width as usize / 32;
|
||||
let remainder = area.width as usize % 32;
|
||||
if base == 0 && remainder == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut x_start = area.x;
|
||||
for (band, &mag) in data.iter().enumerate() {
|
||||
let w = base + if band < remainder { 1 } else { 0 };
|
||||
if w == 0 {
|
||||
continue;
|
||||
}
|
||||
let bar_height = (mag * gain).min(1.0) * height;
|
||||
let full_cells = bar_height as usize;
|
||||
let frac = bar_height - full_cells as f32;
|
||||
let frac_idx = (frac * 8.0) as usize;
|
||||
|
||||
// Peak hold row
|
||||
let peak_row = peaks.map(|p| {
|
||||
let ph = p[band] * height;
|
||||
let row = (height - ph).max(0.0) as usize;
|
||||
row.min(area.height as usize - 1)
|
||||
});
|
||||
|
||||
for row in 0..area.height as usize {
|
||||
let y = area.y + area.height - 1 - row as u16;
|
||||
let ratio = row as f32 / area.height as f32;
|
||||
let color = band_color(ratio, &colors);
|
||||
|
||||
for dx in 0..w as u16 {
|
||||
let x = x_start + dx;
|
||||
if row < full_cells {
|
||||
buf[(x, y)].set_char(BLOCKS[7]).set_fg(color);
|
||||
} else if row == full_cells && frac_idx > 0 {
|
||||
buf[(x, y)].set_char(BLOCKS[frac_idx - 1]).set_fg(color);
|
||||
} else if let Some(pr) = peak_row {
|
||||
// peak_row is from top (0 = top), row is from bottom
|
||||
let from_top = area.height as usize - 1 - row;
|
||||
if from_top == pr {
|
||||
buf[(x, y)].set_char('─').set_fg(colors.meter.high);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
x_start += w as u16;
|
||||
}
|
||||
}
|
||||
|
||||
fn render_braille(
|
||||
data: &[f32; 32],
|
||||
area: Rect,
|
||||
buf: &mut Buffer,
|
||||
gain: f32,
|
||||
filled: bool,
|
||||
peaks: Option<&[f32; 32]>,
|
||||
) {
|
||||
let colors = theme::get();
|
||||
let width = area.width as usize;
|
||||
let height = area.height as usize;
|
||||
let fine_w = width * 2;
|
||||
let fine_h = height * 4;
|
||||
|
||||
PATTERNS.with(|p| {
|
||||
let mut patterns = p.borrow_mut();
|
||||
patterns.clear();
|
||||
patterns.resize(width * height, 0);
|
||||
|
||||
// Interpolate 32 bands across fine_w columns
|
||||
for fx in 0..fine_w {
|
||||
let band_f = fx as f32 * 31.0 / (fine_w - 1).max(1) as f32;
|
||||
let lo = band_f as usize;
|
||||
let hi = (lo + 1).min(31);
|
||||
let t = band_f - lo as f32;
|
||||
let mag = ((data[lo] * (1.0 - t) + data[hi] * t) * gain).min(1.0);
|
||||
let fy = ((1.0 - mag) * (fine_h - 1) as f32).round() as usize;
|
||||
let fy = fy.min(fine_h - 1);
|
||||
|
||||
if filled {
|
||||
for y in fy..fine_h {
|
||||
let cy = y / 4;
|
||||
let dy = y % 4;
|
||||
let cx = fx / 2;
|
||||
let dx = fx % 2;
|
||||
patterns[cy * width + cx] |= braille_bit(dx, dy);
|
||||
}
|
||||
} else {
|
||||
let cy = fy / 4;
|
||||
let dy = fy % 4;
|
||||
let cx = fx / 2;
|
||||
let dx = fx % 2;
|
||||
patterns[cy * width + cx] |= braille_bit(dx, dy);
|
||||
}
|
||||
|
||||
// Peak dots
|
||||
if let Some(pk) = peaks {
|
||||
let pv = (pk[lo] * (1.0 - t) + pk[hi] * t).min(1.0);
|
||||
let py = ((1.0 - pv) * (fine_h - 1) as f32).round() as usize;
|
||||
let py = py.min(fine_h - 1);
|
||||
let cy = py / 4;
|
||||
let dy = py % 4;
|
||||
let cx = fx / 2;
|
||||
let dx = fx % 2;
|
||||
patterns[cy * width + cx] |= braille_bit(dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
for cy in 0..height {
|
||||
for cx in 0..width {
|
||||
let pattern = patterns[cy * width + cx];
|
||||
if pattern != 0 {
|
||||
let ratio = 1.0 - (cy as f32 / height as f32);
|
||||
let color = band_color(ratio, &colors);
|
||||
let ch = char::from_u32(0x2800 + pattern as u32).unwrap_or(' ');
|
||||
buf[(area.x + cx as u16, area.y + cy as u16)]
|
||||
.set_char(ch)
|
||||
.set_fg(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn braille_bit(dot_x: usize, dot_y: usize) -> u8 {
|
||||
match (dot_x, dot_y) {
|
||||
(0, 0) => 0x01,
|
||||
(0, 1) => 0x02,
|
||||
(0, 2) => 0x04,
|
||||
(0, 3) => 0x40,
|
||||
(1, 0) => 0x08,
|
||||
(1, 1) => 0x10,
|
||||
(1, 2) => 0x20,
|
||||
(1, 3) => 0x80,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
8376
demos/02.cagire
8376
demos/02.cagire
File diff suppressed because it is too large
Load Diff
8371
demos/03.cagire
8371
demos/03.cagire
File diff suppressed because it is too large
Load Diff
@@ -9,8 +9,8 @@ All time values are in **steps**, just like `attack`, `decay`, and `release`. At
|
||||
Oscillate a parameter between two values.
|
||||
|
||||
```forth
|
||||
saw s 200 4000 4 lfo lpf . ( sweep filter over 4 steps )
|
||||
saw s 0.3 0.7 2 tlfo pan . ( triangle pan over 2 steps )
|
||||
saw snd 200 4000 4 lfo lpf . ( sweep filter over 4 steps )
|
||||
saw snd 0.3 0.7 2 tlfo pan . ( triangle pan over 2 steps )
|
||||
```
|
||||
|
||||
| Word | Shape | Output |
|
||||
@@ -27,8 +27,8 @@ Stack effect: `( min max period -- str )`
|
||||
Transition from one value to another over a duration.
|
||||
|
||||
```forth
|
||||
saw s 0 1 0.5 slide gain . ( fade in over half a step )
|
||||
saw s 200 4000 8 sslide lpf . ( smooth sweep over 8 steps )
|
||||
saw snd 0 1 0.5 slide gain . ( fade in over half a step )
|
||||
saw snd 200 4000 8 sslide lpf . ( smooth sweep over 8 steps )
|
||||
```
|
||||
|
||||
| Word | Curve | Output |
|
||||
@@ -44,9 +44,9 @@ Stack effect: `( start end dur -- str )`
|
||||
Randomize a parameter within a range, retriggering at a given period.
|
||||
|
||||
```forth
|
||||
saw s 200 4000 2 jit lpf . ( new random value every 2 steps )
|
||||
saw s 200 4000 2 sjit lpf . ( same but smoothly interpolated )
|
||||
saw s 200 4000 1 drunk lpf . ( random walk, each step )
|
||||
saw snd 200 4000 2 jit lpf . ( new random value every 2 steps )
|
||||
saw snd 200 4000 2 sjit lpf . ( same but smoothly interpolated )
|
||||
saw snd 200 4000 1 drunk lpf . ( random walk, each step )
|
||||
```
|
||||
|
||||
| Word | Behavior | Output |
|
||||
@@ -62,7 +62,7 @@ Stack effect: `( min max period -- str )`
|
||||
Define a multi-segment envelope for a parameter. Provide a start value, then pairs of target and duration.
|
||||
|
||||
```forth
|
||||
saw s 0 1 0.1 0.7 0.5 0 8 env gain .
|
||||
saw snd 0 1 0.1 0.7 0.5 0 8 env gain .
|
||||
```
|
||||
|
||||
This creates: start at `0`, rise to `1` in `0.1` steps, drop to `0.7` in `0.5` steps, fall to `0` in `8` steps.
|
||||
@@ -74,7 +74,7 @@ Stack effect: `( start target1 dur1 [target2 dur2 ...] -- str )`
|
||||
Modulation words return strings, so they compose naturally with the rest of the language. Use them anywhere a parameter value is expected.
|
||||
|
||||
```forth
|
||||
saw s
|
||||
saw snd
|
||||
200 4000 4 lfo lpf
|
||||
0.3 0.7 8 tlfo pan
|
||||
0 1 0.1 0.7 0.5 0 8 env gain
|
||||
|
||||
@@ -7,7 +7,7 @@ Cagire includes an audio engine called `Doux`. No external software is needed to
|
||||
When you write a Forth script and emit (`.`), the script produces a command string. This command travels to the audio engine, which interprets it and creates a voice. The voice plays until its envelope finishes or until it is killed by another voice. You can also spawn infinite voices, but you will need to manage their lifecycle manually, otherwise they will never stop.
|
||||
|
||||
```forth
|
||||
saw s c4 note 0.8 gain 0.3 verb .
|
||||
saw snd c4 note 0.8 gain 0.3 verb .
|
||||
```
|
||||
|
||||
## Voices
|
||||
@@ -24,7 +24,7 @@ Press `r` on the Engine page to reset the peak counter.
|
||||
After selecting a sound source, you add parameters. Each parameter word takes a value from the stack and stores it in the command register:
|
||||
|
||||
```forth
|
||||
saw s
|
||||
saw snd
|
||||
c4 note ;; pitch
|
||||
0.5 gain ;; volume
|
||||
0.1 attack ;; envelope attack time
|
||||
@@ -42,14 +42,14 @@ Use `all` to apply parameters globally. Global parameters persist across all pat
|
||||
```forth
|
||||
;; Prospective: set params before emitting
|
||||
500 lpf 0.5 verb all
|
||||
kick s 60 note . ;; gets lpf=500 verb=0.5
|
||||
hat s 70 note . ;; gets lpf=500 verb=0.5
|
||||
kick snd 60 note . ;; gets lpf=500 verb=0.5
|
||||
hat snd 70 note . ;; gets lpf=500 verb=0.5
|
||||
```
|
||||
|
||||
```forth
|
||||
;; Retroactive: patch already-emitted sounds
|
||||
kick s 60 note .
|
||||
hat s 70 note .
|
||||
kick snd 60 note .
|
||||
hat snd 70 note .
|
||||
500 lpf 0.5 verb all ;; both outputs get lpf and verb
|
||||
```
|
||||
|
||||
@@ -57,17 +57,17 @@ Per-sound parameters override global ones:
|
||||
|
||||
```forth
|
||||
500 lpf all
|
||||
kick s 2000 lpf . ;; lpf=2000 (per-sound wins)
|
||||
hat s . ;; lpf=500 (global)
|
||||
kick snd 2000 lpf . ;; lpf=2000 (per-sound wins)
|
||||
hat snd . ;; lpf=500 (global)
|
||||
```
|
||||
|
||||
Use `noall` to clear global parameters:
|
||||
|
||||
```forth
|
||||
500 lpf all
|
||||
kick s . ;; gets lpf
|
||||
kick snd . ;; gets lpf
|
||||
noall
|
||||
hat s . ;; no lpf
|
||||
hat snd . ;; no lpf
|
||||
```
|
||||
|
||||
## Controlling Existing Voices
|
||||
|
||||
@@ -20,15 +20,17 @@ The engine scans these directories and builds a registry of available samples. S
|
||||
|
||||
```
|
||||
samples/
|
||||
├── kick.wav → "kick"
|
||||
├── snare.wav → "snare"
|
||||
├── kick/ → "kick"
|
||||
│ └── kick.wav
|
||||
├── snare/ → "snare"
|
||||
│ └── snare.wav
|
||||
└── hats/
|
||||
├── closed.wav → "hats" n 0
|
||||
├── open.wav → "hats" n 1
|
||||
└── pedal.wav → "hats" n 2
|
||||
```
|
||||
|
||||
Folders at the root of your directory are used as the name of a sample bank. Folders create sample banks where each file gets an index. Files are sorted alphabetically and assigned indices starting from `0`.
|
||||
Folders at the root of your sample directory become sample banks named after the folder. Each file within a folder gets an index. Files are sorted alphabetically and assigned indices starting from `0`.
|
||||
|
||||
## Playing Samples
|
||||
|
||||
@@ -45,6 +47,8 @@ snare sound 0.5 speed . ( play snare at half speed )
|
||||
| `n` | 0+ | Sample index within a folder (wraps around) |
|
||||
| `begin` | 0-1 | Playback start position |
|
||||
| `end` | 0-1 | Playback end position |
|
||||
| `slice` | 1+ | Divide sample into N equal slices |
|
||||
| `pick` | 0+ | Select which slice to play (0-indexed, wraps) |
|
||||
| `speed` | any | Playback speed multiplier |
|
||||
| `freq` | Hz | Base frequency for pitch tracking |
|
||||
| `fit` | seconds | Stretch/compress sample to fit duration |
|
||||
@@ -62,6 +66,21 @@ kick sound 0.5 end . ( play first half )
|
||||
|
||||
If begin is greater than end, they swap automatically.
|
||||
|
||||
## Slice and Pick
|
||||
|
||||
For evenly-spaced slicing, `slice` divides the sample into N equal parts and `pick` selects which one (0-indexed, wraps around).
|
||||
|
||||
```forth
|
||||
break sound 8 slice 3 pick . ( play the 4th eighth of the sample )
|
||||
break sound 16 slice step pick . ( scan through 16 slices by step )
|
||||
```
|
||||
|
||||
Combine with `fit` to time-stretch each slice to a target duration. `fit` accounts for the sliced range automatically.
|
||||
|
||||
```forth
|
||||
break sound 4 slice 2 pick 1 loop . ( quarter of the sample, fitted to 1 beat )
|
||||
```
|
||||
|
||||
## Speed and Pitch
|
||||
|
||||
The `speed` parameter affects both tempo and pitch. A speed of 2 plays twice as fast and an octave higher.
|
||||
|
||||
@@ -79,16 +79,16 @@ Top-level files are named by their filename (without extension). Files inside fo
|
||||
Reference samples by name:
|
||||
|
||||
```forth
|
||||
kick s . ;; play kick.wav
|
||||
snare s 0.5 gain . ;; play snare at half volume
|
||||
kick snd . ;; play kick.wav
|
||||
snare snd 0.5 gain . ;; play snare at half volume
|
||||
```
|
||||
|
||||
For samples in folders, use `n` to select which one:
|
||||
|
||||
```forth
|
||||
hats s 0 n . ;; play hats/closed.wav (index 0)
|
||||
hats s 1 n . ;; play hats/open.wav (index 1)
|
||||
hats s 2 n . ;; play hats/pedal.wav (index 2)
|
||||
hats snd 0 n . ;; play hats/closed.wav (index 0)
|
||||
hats snd 1 n . ;; play hats/open.wav (index 1)
|
||||
hats snd 2 n . ;; play hats/pedal.wav (index 2)
|
||||
```
|
||||
|
||||
The index wraps around. If you have 3 samples and request `5 n`, you get index 2 (because 5 % 3 = 2).
|
||||
@@ -106,9 +106,9 @@ samples/
|
||||
```
|
||||
|
||||
```forth
|
||||
kick s . ;; plays kick.wav
|
||||
kick s a bank . ;; plays kick_a.wav
|
||||
kick s hard bank . ;; plays kick_hard.wav
|
||||
kick snd . ;; plays kick.wav
|
||||
kick snd a bank . ;; plays kick_a.wav
|
||||
kick snd hard bank . ;; plays kick_hard.wav
|
||||
```
|
||||
|
||||
If the banked version does not exist, it falls back to the default.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Sources
|
||||
|
||||
The audio engine provides a variety of sound sources. Use the `sound` word (or `s` for short) to select one.
|
||||
The audio engine provides a variety of sound sources. Use the `sound` word (or `snd` for short) to select one.
|
||||
|
||||
## Basic Oscillators
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Word definitions let you abstract sound design into reusable units.
|
||||
## Defining Sounds
|
||||
|
||||
```forth
|
||||
: lead "saw" s 0.3 gain 1200 lpf ;
|
||||
: lead "saw" snd 0.3 gain 1200 lpf ;
|
||||
```
|
||||
|
||||
Use it with different notes:
|
||||
@@ -20,8 +20,8 @@ e4 note lead .
|
||||
Include the emit to make the word play directly:
|
||||
|
||||
```forth
|
||||
: kk "kick" s 1 decay . ;
|
||||
: hh "hihat" s 0.5 gain 0.5 decay . ;
|
||||
: kk "kick" snd 1 decay . ;
|
||||
: hh "hihat" snd 0.5 gain 0.5 decay . ;
|
||||
```
|
||||
|
||||
Steps become simple:
|
||||
@@ -39,5 +39,5 @@ kk
|
||||
```
|
||||
|
||||
```forth
|
||||
c4 note saw s dark wet .
|
||||
c4 note saw snd dark wet .
|
||||
```
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
# About Forth
|
||||
|
||||
Forth is a _stack-based_ programming language created by Charles H. Moore in the early 1970s. It was designed with simplicity, directness, and interactive exploration in mind. Forth has been used for scientific work and embedded systems: it controlled telescopes and even ran on hardware aboard space missions. It evolved into many implementations targeting various architectures, but none of them really caught on. Nonetheless, the ideas behind Forth continue to attract people from very different, often unrelated fields. Today, Forth languages are used by hackers and artists for their unconventional nature. Forth is simple, direct, and beautiful to implement. Forth is an elegant, minimal language, easy to understand, extend, and tailor to a specific task. The Forth we use in Cagire is specialized in making live music. It is used as a DSL: a _Domain Specific Language_.
|
||||
Forth is a _stack-based_ programming language created by Charles H. Moore in the early 1970s. It was designed with simplicity, directness, and interactive exploration in mind. Forth has been used for scientific work and embedded systems: it controlled telescopes and even ran on hardware aboard space missions. It evolved into many implementations targeting various architectures, but none of them really caught on. Nonetheless, the ideas behind Forth continue to attract people from very different, often unrelated fields. Today, Forth languages are used by hackers and artists for their unconventional nature. Forth is simple, direct, and beautiful to implement. Forth is an elegant, minimal language, easy to understand, extend, and tailor to a specific task. The Forth we use in Cagire is specialized in making live music. It is used as a DSL: a _Domain Specific Language_.
|
||||
|
||||
**TLDR:** Forth is a really nice language to play music with.
|
||||
|
||||
## Why Forth?
|
||||
|
||||
Most programming languages rely on a complex syntax of `variables`, `expressions` and `statements` like `x = 3 + 4` or `do_something(()=>bob(4))`. Forth works differently. It has almost no syntax at all. Instead, you push values onto a `stack` and apply `words` that transform them:
|
||||
|
||||
```forth
|
||||
3 4 +
|
||||
3 4 + print
|
||||
```
|
||||
|
||||
The program above leaves the number `7` on the stack. There are no variables, no parentheses, no syntax to remember. You just end up with words and numbers separated by spaces. For live coding music, this directness is quite exciting. All you do is think in terms of transformations and add things to the stack: take a note, shift it up, add reverb, play it.
|
||||
@@ -20,6 +22,7 @@ The stack is where values live. When you type a number, it goes on the stack. Wh
|
||||
3 ;; stack: 3
|
||||
4 ;; stack: 3 4
|
||||
+ ;; stack: 7
|
||||
print
|
||||
```
|
||||
|
||||
The stack is `last-in, first-out`. The most recent value is always on top. This means that it's often better to read Forth programs from right to left, bottom to top.
|
||||
@@ -38,7 +41,7 @@ Words compose naturally on the stack. To double a number:
|
||||
|
||||
```forth
|
||||
;; 3 3 +
|
||||
3 dup +
|
||||
3 dup + print
|
||||
```
|
||||
|
||||
Forth has a large vocabulary, so Cagire includes a `Dictionary` directly in the application. You can also create your own words. They will work just like existing words. The only difference is that these words will not be included in the dictionary. There are good reasons to create new words on-the-fly:
|
||||
@@ -54,19 +57,28 @@ Four basic types of values can live on the stack:
|
||||
- **Integers**: `42`, `-7`, `0`
|
||||
- **Floats**: `0.5`, `3.14`, `-1.0`
|
||||
- **Strings**: `"kick"`, `"hello"`
|
||||
- **Quotations**: `{ dup + }` (code as data)
|
||||
- **Quotations**: `( dup + )` (code as data)
|
||||
|
||||
Floats can omit the leading zero: `.25` is the same as `0.25`, and `-.5` is `-0.5`.
|
||||
|
||||
Parentheses are ignored by the parser. You can use them freely for visual grouping without affecting execution:
|
||||
Parentheses are used to "quote" a section of a program. The code inside does not run immediately — it is pushed onto the stack as a value. A quotation only runs when a consuming word decides to execute it. This is how conditionals and loops work:
|
||||
|
||||
```forth
|
||||
(c4 note) (0.5 gain) "sine" s .
|
||||
( 60 note 0.3 verb ) 1 ?
|
||||
```
|
||||
|
||||
Quotations are special. They let you pass code around as a value. This is how conditionals and loops work. Don't worry about them for now — you'll learn how to use them later.
|
||||
Here `?` pops the quotation and the condition. The code inside runs only when the condition is truthy. Words like `?`, `!?`, `times`, `cycle`, `choose`, `ifelse`, `every`, `chance`, and `apply` all consume quotations this way.
|
||||
|
||||
Any word that is not recognized as a built-in or a user definition becomes a string on the stack. This means `kick s` and `"kick" s` are equivalent. You only need quotes when the string contains spaces or when it conflicts with an existing word name.
|
||||
Because parentheses defer execution, wrapping code in `( ... )` without a consuming word means it never runs. Quotations are transparent to sound and parameter words — they stay on the stack untouched. This is a useful trick for temporarily disabling part of a step:
|
||||
|
||||
```forth
|
||||
( 0.5 gain ) ;; this quotation is ignored
|
||||
"kick" sound
|
||||
0.3 decay
|
||||
.
|
||||
```
|
||||
|
||||
Any word that is not recognized as a built-in or a user definition becomes a string on the stack. This means `kick snd` and `"kick" snd` are equivalent. You only need quotes when the string contains spaces or when it conflicts with an existing word name.
|
||||
|
||||
## The Command Register
|
||||
|
||||
@@ -82,7 +94,7 @@ kick sound ;; sets the sound name
|
||||
. ;; emits the command and clears the register
|
||||
```
|
||||
|
||||
The word `sound` (or its shorthand `s`) sets what sound to play. Parameter words like `gain`, `freq`, `decay`, or `verb` add key-value pairs to the register. Nothing happens until you emit with `.` (dot). At that moment, the register is packaged into a command and sent to the audio engine.
|
||||
The word `sound` (or its shorthand `snd`) sets what sound to play. Parameter words like `gain`, `freq`, `decay`, or `verb` add key-value pairs to the register. Nothing happens until you emit with `.` (dot). At that moment, the register is packaged into a command and sent to the audio engine.
|
||||
|
||||
This design lets you build sounds incrementally:
|
||||
|
||||
@@ -98,14 +110,14 @@ c4 note
|
||||
Each line adds something to the register. The final `.` triggers the sound. You can also write it all on one line:
|
||||
|
||||
```forth
|
||||
"sine" s c4 note 0.5 gain 0.3 decay 0.4 verb .
|
||||
"sine" snd c4 note 0.5 gain 0.3 decay 0.4 verb .
|
||||
```
|
||||
|
||||
The order of parameters does not matter. You can even emit multiple times in a single step. If you need to discard the register without emitting, use `clear`:
|
||||
|
||||
```forth
|
||||
"kick" s 0.5 gain clear ;; nothing plays, register is emptied
|
||||
"hat" s . ;; only the hat plays
|
||||
"kick" snd 0.5 gain clear ;; nothing plays, register is emptied
|
||||
"hat" snd . ;; only the hat plays
|
||||
```
|
||||
|
||||
This is useful when conditionals might cancel a sound before it emits.
|
||||
|
||||
108
docs/forth/brackets.md
Normal file
108
docs/forth/brackets.md
Normal file
@@ -0,0 +1,108 @@
|
||||
# Brackets
|
||||
|
||||
Cagire uses three bracket forms. Each one behaves differently.
|
||||
|
||||
## ( ... ) — Quotations
|
||||
|
||||
Parentheses create quotations: deferred code. The contents are not executed immediately — they are pushed onto the stack as a single value.
|
||||
|
||||
```forth
|
||||
( dup + )
|
||||
```
|
||||
|
||||
This pushes a block of code. You can store it in a variable, pass it to other words, or execute it later. Quotations are what make Cagire's control flow work.
|
||||
|
||||
### Words that consume quotations
|
||||
|
||||
Many built-in words expect a quotation on the stack:
|
||||
|
||||
| Word | Effect |
|
||||
|------|--------|
|
||||
| `?` | Execute if condition is truthy |
|
||||
| `!?` | Execute if condition is falsy |
|
||||
| `ifelse` | Choose between two quotations |
|
||||
| `select` | Pick the nth quotation from a list |
|
||||
| `apply` | Execute unconditionally |
|
||||
| `times` | Loop n times |
|
||||
| `cycle` / `pcycle` | Rotate through quotations |
|
||||
| `choose` | Pick one at random |
|
||||
| `every` | Execute on every nth iteration |
|
||||
| `chance` / `prob` | Execute with probability |
|
||||
| `bjork` / `pbjork` | Euclidean rhythm gate |
|
||||
|
||||
When a word like `cycle` or `choose` selects a quotation, it executes it. When it selects a plain value, it pushes it.
|
||||
|
||||
### Nesting
|
||||
|
||||
Quotations nest freely:
|
||||
|
||||
```forth
|
||||
( ( c4 note ) ( e4 note ) coin ifelse ) 4 every
|
||||
```
|
||||
|
||||
The outer quotation runs every 4th iteration. Inside, a coin flip picks the note.
|
||||
|
||||
### The mute trick
|
||||
|
||||
Wrapping code in a quotation without consuming it is a quick way to disable it:
|
||||
|
||||
```forth
|
||||
( kick snd . )
|
||||
```
|
||||
|
||||
Nothing will execute this quotation — it just sits on the stack and gets discarded. Useful for temporarily silencing a line while editing.
|
||||
|
||||
## [ ... ] — Square Brackets
|
||||
|
||||
Square brackets execute their contents immediately, then push a count of how many values were produced. The values themselves stay on the stack.
|
||||
|
||||
```forth
|
||||
[ 60 64 67 ]
|
||||
```
|
||||
|
||||
After this runs, the stack holds `60 64 67 3` — three values plus the count `3`. This is useful with words that need to know how many items precede them:
|
||||
|
||||
```forth
|
||||
[ 60 64 67 ] cycle note sine snd .
|
||||
```
|
||||
|
||||
The `cycle` word reads the count to know how many values to rotate through. Without brackets you would write `60 64 67 3 cycle` — the brackets save you from counting manually.
|
||||
|
||||
Square brackets work with any word that takes a count:
|
||||
|
||||
```forth
|
||||
[ c4 e4 g4 ] choose note saw snd . ;; random note from the list
|
||||
[ 60 64 67 ] note sine snd . ;; 3-note chord (note consumes all)
|
||||
```
|
||||
|
||||
### Nesting
|
||||
|
||||
Square brackets can nest. Each pair produces its own count:
|
||||
|
||||
```forth
|
||||
[ [ 60 64 67 ] cycle [ 0.3 0.5 0.8 ] cycle ] choose
|
||||
```
|
||||
|
||||
### Expressions inside brackets
|
||||
|
||||
The contents are compiled and executed normally, so you can use any Forth code:
|
||||
|
||||
```forth
|
||||
[ c4 c4 3 + c4 7 + ] note sine snd . ;; root, minor third, fifth
|
||||
```
|
||||
|
||||
## { ... } — Curly Braces
|
||||
|
||||
Curly braces are ignored by the compiler. They do nothing. Use them as a visual aid to group related code:
|
||||
|
||||
```forth
|
||||
{ kick snd } { 0.5 gain } { 0.3 verb } .
|
||||
```
|
||||
|
||||
This compiles to exactly the same thing as:
|
||||
|
||||
```forth
|
||||
kick snd 0.5 gain 0.3 verb .
|
||||
```
|
||||
|
||||
They can help readability in dense one-liners but have no semantic meaning.
|
||||
@@ -1,140 +1,143 @@
|
||||
# Control Flow
|
||||
|
||||
Sometimes a step should behave differently depending on context — a coin flip, a fill, which iteration of the pattern is playing. Control flow words let you branch, choose, and repeat inside a step's script. Control structures are essential for programming and allow you to create complex and dynamic patterns.
|
||||
Control flow in Cagire's Forth comes in two families. The first is compiled syntax — `if/then` and `case` — which the compiler handles directly as branch instructions. The second is quotation words — `?`, `!?`, `ifelse`, `select`, `apply` — which pop `( ... )` quotations from the stack and decide whether to run them. Probability and periodic execution (`chance`, `every`, `bjork`) are covered in the Randomness tutorial.
|
||||
|
||||
## if / else / then
|
||||
## Branching with if / else / then
|
||||
|
||||
The simplest branch. Push a condition, then `if`:
|
||||
Push a condition, then `if`. Everything between `if` and `then` runs only when the condition is truthy:
|
||||
|
||||
```forth
|
||||
coin if 0.8 gain then
|
||||
saw s c4 note .
|
||||
;; degrade sound if true
|
||||
coin if
|
||||
7 crush
|
||||
then
|
||||
sine sound
|
||||
c4 note
|
||||
1 decay
|
||||
.
|
||||
```
|
||||
|
||||
The gain is applied if the coin flip is true. The sound will always plays. Add `else` for a two-way split:
|
||||
The crush is applied on half the hits. The sound always plays. Add `else` for a two-way split:
|
||||
|
||||
```forth
|
||||
coin if
|
||||
c4 note
|
||||
c5 note
|
||||
else
|
||||
c3 note
|
||||
then
|
||||
saw s 0.6 gain .
|
||||
saw sound
|
||||
0.3 verb
|
||||
0.5 decay
|
||||
0.6 gain
|
||||
.
|
||||
```
|
||||
|
||||
These are compiled directly into branch instructions. For that reason, these words will not appear in the dictionary.
|
||||
These are compiled directly into branch instructions — they will not appear in the dictionary. This is a "low level" way to use conditionals in Cagire.
|
||||
|
||||
## ? and !?
|
||||
|
||||
When you already have a quotation, `?` executes it if the condition is truthy:
|
||||
|
||||
```forth
|
||||
{ 0.4 verb } coin ?
|
||||
saw s c4 note 0.5 gain . ;; reverb on half the hits
|
||||
```
|
||||
|
||||
`!?` is the opposite — executes when falsy:
|
||||
|
||||
```forth
|
||||
{ 0.2 gain } coin !?
|
||||
saw s c4 note . ;; quiet on half the hits
|
||||
```
|
||||
|
||||
These pair well with `chance`, `prob`, and the other probability words:
|
||||
|
||||
```forth
|
||||
{ 0.5 verb } 0.3 chance ? ;; occasional reverb wash
|
||||
{ 12 + } fill ? ;; octave up during fills
|
||||
```
|
||||
|
||||
## ifelse
|
||||
|
||||
Two quotations, one condition. The true branch comes first:
|
||||
|
||||
```forth
|
||||
{ c3 note } { c4 note } coin ifelse
|
||||
saw s 0.6 gain . ;; bass or lead, coin flip
|
||||
```
|
||||
|
||||
Reads naturally: "c3 or c4, depending on the coin."
|
||||
|
||||
```forth
|
||||
{ 0.8 gain } { 0.3 gain } fill ifelse
|
||||
tri s c4 note 0.2 decay . ;; loud during fills, quiet otherwise
|
||||
```
|
||||
|
||||
## pick
|
||||
|
||||
Choose the nth option from a list of quotations:
|
||||
|
||||
```forth
|
||||
{ c4 } { e4 } { g4 } { b4 } iter 4 mod pick
|
||||
note sine s 0.5 decay .
|
||||
```
|
||||
|
||||
Four notes cycling through a major seventh chord, one per pattern iteration. The index is 0-based.
|
||||
|
||||
## apply
|
||||
|
||||
When you have a quotation and want to execute it unconditionally, use `apply`:
|
||||
|
||||
```forth
|
||||
{ dup + } apply ;; doubles the top value
|
||||
```
|
||||
|
||||
This is simpler than `?` when there is no condition to check. It pops the quotation and runs it.
|
||||
|
||||
## case / of / endof / endcase
|
||||
## Matching with case
|
||||
|
||||
For matching a value against several options. Cleaner than a chain of `if`s when you have more than two branches:
|
||||
|
||||
```forth
|
||||
iter 4 mod case
|
||||
1 8 rand 4 mod case
|
||||
0 of c3 note endof
|
||||
1 of e3 note endof
|
||||
2 of g3 note endof
|
||||
3 of a3 note endof
|
||||
endcase
|
||||
saw s 0.6 gain 800 lpf .
|
||||
tri s
|
||||
2 fm 0.99 fmh
|
||||
0.6 gain 0.2 chorus
|
||||
1 decay
|
||||
800 lpf
|
||||
.
|
||||
```
|
||||
|
||||
A different root note each time the pattern loops.
|
||||
|
||||
The last line before `endcase` is the default — it runs when no `of` matched:
|
||||
A different root note each time the pattern loops. The last line before `endcase` is the default — it runs when no `of` matched:
|
||||
|
||||
```forth
|
||||
iter 3 mod case
|
||||
0 of 0.9 gain endof
|
||||
0.4 gain ;; default: quieter
|
||||
0.4 gain
|
||||
endcase
|
||||
saw s c4 note .
|
||||
saw s
|
||||
.5 decay
|
||||
c4 note
|
||||
.
|
||||
```
|
||||
|
||||
## times
|
||||
Like `if/then`, `case` is compiled syntax and does not appear in the dictionary.
|
||||
|
||||
Repeat a quotation n times. The variable `@i` is automatically set to the current iteration index (starting from 0):
|
||||
## Quotation Words
|
||||
|
||||
The remaining control flow words operate on quotations — `( ... )` blocks sitting on the stack. Each word pops one or more quotations and decides whether or how to execute them.
|
||||
|
||||
### ? and !?
|
||||
|
||||
`?` executes a quotation if the condition is truthy:
|
||||
|
||||
```forth
|
||||
3 { c4 @i 4 * + note } times
|
||||
sine s 0.4 gain 0.5 verb . ;; c4, e4, g#4 — a chord
|
||||
( 0.4 verb 6 crush ) coin ?
|
||||
tri sound 2 fm 0.5 fmh
|
||||
c3 note 0.5 gain 2 decay
|
||||
.
|
||||
```
|
||||
|
||||
Subdivide with `at`:
|
||||
Reverb on half the hits. `!?` is the opposite — executes when falsy:
|
||||
|
||||
```forth
|
||||
4 { @i 4 / at sine s c4 note 0.3 gain . } times
|
||||
( 0.5 delay 0.9 delayfeedback ) coin !?
|
||||
saw sound
|
||||
c4 note
|
||||
500 lpf
|
||||
0.5 decay
|
||||
0.5 gain
|
||||
.
|
||||
```
|
||||
|
||||
Four evenly spaced notes within the step.
|
||||
Quiet on half the hits. These pair well with `chance` and `fill` from the Randomness tutorial.
|
||||
|
||||
Vary intensity per iteration:
|
||||
### ifelse
|
||||
|
||||
Two quotations, one condition. The true branch comes first:
|
||||
|
||||
```forth
|
||||
8 {
|
||||
@i 8 / at
|
||||
@i 4 mod 0 = if 0.7 else 0.2 then gain
|
||||
tri s c5 note 0.1 decay .
|
||||
} times
|
||||
( c3 note ) ( c5 note ) coin ifelse
|
||||
saw sound 0.3 verb
|
||||
0.5 decay 0.6 gain
|
||||
.
|
||||
```
|
||||
|
||||
Eight notes per step. Every fourth one louder.
|
||||
Reads naturally: "c3 or c5, depending on the coin."
|
||||
|
||||
```forth
|
||||
( 0.8 gain ) ( 0.3 gain ) fill ifelse
|
||||
tri snd c4 note 0.2 decay .
|
||||
```
|
||||
|
||||
Loud during fills, quiet otherwise.
|
||||
|
||||
### select
|
||||
|
||||
Choose the nth quotation from a list. The index is 0-based:
|
||||
|
||||
```forth
|
||||
( c4 ) ( e4 ) ( g4 ) ( b4 ) 0 3 rand select
|
||||
note sine snd 0.5 decay .
|
||||
```
|
||||
|
||||
Four notes of a major seventh chord picked randomly. Note that this is unnecessarily complex :)
|
||||
|
||||
### apply
|
||||
|
||||
When you have a quotation and want to execute it unconditionally:
|
||||
|
||||
```forth
|
||||
( dup + ) apply
|
||||
```
|
||||
|
||||
Pops the quotation and runs it. Simpler than `?` when there is no condition to check.
|
||||
|
||||
## More!
|
||||
|
||||
For probability gates, periodic execution, and euclidean rhythms, see the Randomness tutorial. For generators and ranges, see the Generators tutorial.
|
||||
|
||||
92
docs/forth/cycling.md
Normal file
92
docs/forth/cycling.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# Cycling & Selection
|
||||
|
||||
These words all share a pattern: push values onto the stack, then select one. If the selected item is a quotation, it gets executed. If it is a plain value, it gets pushed. All of them support `[ ]` brackets for auto-counting.
|
||||
|
||||
## cycle / pcycle
|
||||
|
||||
Sequential rotation through values.
|
||||
|
||||
`cycle` advances based on `runs` — how many times this particular step has played:
|
||||
|
||||
```forth
|
||||
60 64 67 3 cycle note sine snd . ;; 60, 64, 67, 60, 64, 67, ...
|
||||
```
|
||||
|
||||
`pcycle` advances based on `iter` — the pattern iteration count:
|
||||
|
||||
```forth
|
||||
kick snare 2 pcycle snd . ;; kick on even iterations, snare on odd
|
||||
```
|
||||
|
||||
The distinction matters when patterns have different lengths or when multiple steps share the same script. `cycle` gives each step its own independent counter. `pcycle` ties all steps to the same global pattern position.
|
||||
|
||||
## bounce / pbounce
|
||||
|
||||
Ping-pong instead of wrapping. With 4 values the sequence is 0, 1, 2, 3, 2, 1, 0, 1, 2, ...
|
||||
|
||||
```forth
|
||||
60 64 67 72 4 bounce note sine snd . ;; ping-pong by step runs
|
||||
60 64 67 72 4 pbounce note sine snd . ;; ping-pong by pattern iteration
|
||||
```
|
||||
|
||||
Same `runs` vs `iter` split as `cycle` / `pcycle`.
|
||||
|
||||
## choose
|
||||
|
||||
Uniform random selection:
|
||||
|
||||
```forth
|
||||
kick snare hat 3 choose snd . ;; random drum hit each time
|
||||
```
|
||||
|
||||
Unlike the cycling words, `choose` is nondeterministic — every evaluation picks independently.
|
||||
|
||||
## wchoose
|
||||
|
||||
Weighted random. Push value/weight pairs, then the count:
|
||||
|
||||
```forth
|
||||
kick 0.5 snare 0.3 hat 0.2 3 wchoose snd .
|
||||
```
|
||||
|
||||
Kick plays 50% of the time, snare 30%, hat 20%. Weights are normalized automatically — they don't need to sum to 1.
|
||||
|
||||
## index
|
||||
|
||||
Direct lookup by an explicit index. The index wraps with modulo, so it never goes out of bounds. Negative indices count from the end:
|
||||
|
||||
```forth
|
||||
[ c4 e4 g4 ] step index note sine snd . ;; step number picks the note
|
||||
[ c4 e4 g4 ] iter index note sine snd . ;; pattern iteration picks the note
|
||||
```
|
||||
|
||||
This is useful when you want full control over which value is selected, driven by any expression you like.
|
||||
|
||||
## Using with brackets
|
||||
|
||||
All these words take a count argument `n`. Square brackets compute that count for you:
|
||||
|
||||
```forth
|
||||
[ 60 64 67 ] cycle note sine snd . ;; no need to write "3"
|
||||
[ kick snare hat ] choose snd .
|
||||
[ c4 e4 g4 b4 ] bounce note sine snd .
|
||||
```
|
||||
|
||||
Without brackets: `60 64 67 3 cycle`. With brackets: `[ 60 64 67 ] cycle`. Same result, less counting.
|
||||
|
||||
## Quotations
|
||||
|
||||
When any of these words selects a quotation, it executes it instead of pushing it:
|
||||
|
||||
```forth
|
||||
[ ( c4 note ) ( e4 note ) ( g4 note ) ] cycle
|
||||
sine snd .
|
||||
```
|
||||
|
||||
On the first run the quotation `( c4 note )` executes, setting the note to C4. Next run, E4. Then G4. Then back to C4.
|
||||
|
||||
This works with all selection words. Mix plain values and quotations freely:
|
||||
|
||||
```forth
|
||||
[ ( hat snd 0.3 gain . ) ( snare snd . ) ( kick snd . ) ] choose
|
||||
```
|
||||
@@ -13,8 +13,7 @@ Use `:` to start a definition and `;` to end it:
|
||||
This creates a word called `double` that duplicates the top value and adds it to itself. Now you can use it:
|
||||
|
||||
```forth
|
||||
3 double ;; leaves 6 on the stack
|
||||
5 double ;; leaves 10 on the stack
|
||||
3 double print ;; leaves 6 on the stack
|
||||
```
|
||||
|
||||
The definition is simple: everything between `:` and `;` becomes the body of the word.
|
||||
@@ -25,7 +24,7 @@ When you define a word in one step, it becomes available to all other steps. Thi
|
||||
|
||||
Step 0:
|
||||
```forth
|
||||
: bass "saw" s 0.8 gain 800 lpf ;
|
||||
: bass "saw" snd 0.8 gain 800 lpf ;
|
||||
```
|
||||
|
||||
Step 4:
|
||||
@@ -76,7 +75,7 @@ This only affects words you defined with `:` ... `;`. Built-in words cannot be f
|
||||
**Synth definitions** save you from repeating sound design:
|
||||
|
||||
```forth
|
||||
: pad "sine" s 0.3 gain 2 attack 0.5 verb ;
|
||||
: pad "sine" snd 0.3 gain 2 attack 0.5 verb ;
|
||||
```
|
||||
|
||||
**Transpositions** and musical helpers:
|
||||
@@ -91,8 +90,8 @@ This only affects words you defined with `:` ... `;`. Built-in words cannot be f
|
||||
A word can contain `.` to emit sounds directly:
|
||||
|
||||
```forth
|
||||
: kick "kick" s . ;
|
||||
: hat "hat" s 0.4 gain . ;
|
||||
: kick "kick" snd . ;
|
||||
: hat "hat" snd 0.4 gain . ;
|
||||
```
|
||||
|
||||
Then a step becomes trivial:
|
||||
|
||||
@@ -33,4 +33,4 @@ Each word entry shows:
|
||||
- **Description**: What the word does
|
||||
- **Example**: How to use it
|
||||
|
||||
Press `/` to search across all words. The search matches word names, aliases, and descriptions. Press `Esc` to clear and return to browsing. Use the dictionary while writing scripts to check stack effects and study their behavior. Some words also come with shorter aliases (e.g., `sound` → `s`). You will learn aliases quite naturally, because aliases are usually reserved for very common words.
|
||||
Press `/` to search across all words. The search matches word names, aliases, and descriptions. Press `Esc` to clear and return to browsing. Use the dictionary while writing scripts to check stack effects and study their behavior. Some words also come with shorter aliases (e.g., `sound` → `snd`). You will learn aliases quite naturally, because aliases are usually reserved for very common words.
|
||||
|
||||
@@ -10,7 +10,7 @@ Classic Forth uses parentheses for comments:
|
||||
( this is a comment )
|
||||
```
|
||||
|
||||
Cagire uses double semicolons:
|
||||
In Cagire, parentheses create quotations, so comments use double semicolons instead:
|
||||
|
||||
```forth
|
||||
;; this is a comment
|
||||
@@ -18,18 +18,6 @@ Cagire uses double semicolons:
|
||||
|
||||
Everything after `;;` until the end of the line is ignored.
|
||||
|
||||
## Quotations
|
||||
|
||||
Classic Forth has no quotations. Code is not a value you can pass around.
|
||||
|
||||
Cagire has first-class quotations using curly braces:
|
||||
|
||||
```forth
|
||||
{ dup + }
|
||||
```
|
||||
|
||||
This pushes a block of code onto the stack. You can store it, pass it to other words, and execute it later. Quotations enable conditionals, probability, and cycling.
|
||||
|
||||
## Conditionals
|
||||
|
||||
Classic Forth uses `IF ... ELSE ... THEN`:
|
||||
@@ -41,14 +29,14 @@ x 0 > IF 1 ELSE -1 THEN
|
||||
Cagire supports this syntax but also provides quotation-based conditionals:
|
||||
|
||||
```forth
|
||||
{ 1 } { -1 } x 0 > ifelse
|
||||
( 1 ) ( -1 ) x 0 > ifelse
|
||||
```
|
||||
|
||||
The words `?` and `!?` execute a quotation based on a condition:
|
||||
|
||||
```forth
|
||||
{ "kick" s . } coin ? ;; execute if coin is 1
|
||||
{ "snare" s . } coin !? ;; execute if coin is 0
|
||||
( "kick" snd . ) coin ? ;; execute if coin is 1
|
||||
( "snare" snd . ) coin !? ;; execute if coin is 0
|
||||
```
|
||||
|
||||
## Strings
|
||||
@@ -68,7 +56,7 @@ Cagire has first-class strings:
|
||||
This pushes a string value onto the stack. Strings are used for sound names, sample names, and variable keys. You often do not need quotes at all. Any unrecognized word becomes a string automatically:
|
||||
|
||||
```forth
|
||||
kick s . ;; "kick" is not a word, so it becomes the string "kick"
|
||||
kick snd . ;; "kick" is not a word, so it becomes the string "kick"
|
||||
myweirdname ;; pushes "myweirdname" onto the stack
|
||||
```
|
||||
|
||||
@@ -116,21 +104,21 @@ Classic Forth has `DO ... LOOP`:
|
||||
Cagire uses a quotation-based loop with `times`:
|
||||
|
||||
```forth
|
||||
4 { @i . } times ;; prints 0 1 2 3
|
||||
4 ( @i . ) times ;; prints 0 1 2 3
|
||||
```
|
||||
|
||||
The loop counter is stored in the variable `i`, accessed with `@i`. This fits Cagire's style where control flow uses quotations.
|
||||
|
||||
```forth
|
||||
4 { @i 4 / at hat s . } times ;; hat at 0, 0.25, 0.5, 0.75
|
||||
4 { c4 @i + note sine s . } times ;; ascending notes
|
||||
4 ( @i 4 / at hat snd . ) times ;; hat at 0, 0.25, 0.5, 0.75
|
||||
4 ( c4 @i + note sine snd . ) times ;; ascending notes
|
||||
```
|
||||
|
||||
For generating sequences without side effects, use `..` or `gen`:
|
||||
|
||||
```forth
|
||||
1 5 .. ;; pushes 1 2 3 4 5
|
||||
{ dup * } 4 gen ;; pushes 0 1 4 9 (squares)
|
||||
( dup * ) 4 gen ;; pushes 0 1 4 9 (squares)
|
||||
```
|
||||
|
||||
## The Command Register
|
||||
@@ -167,11 +155,11 @@ These have no equivalent in classic Forth. They connect your script to the seque
|
||||
Classic Forth is deterministic. Cagire has built-in randomness:
|
||||
|
||||
```forth
|
||||
{ "snare" s . } 50 prob ;; 50% chance
|
||||
{ "clap" s . } 0.25 chance ;; 25% chance
|
||||
{ "hat" s . } often ;; 75% chance
|
||||
{ "rim" s . } sometimes ;; 50% chance
|
||||
{ "tom" s . } rarely ;; 25% chance
|
||||
( "snare" snd . ) 50 prob ;; 50% chance
|
||||
( "clap" snd . ) 0.25 chance ;; 25% chance
|
||||
( "hat" snd . ) often ;; 75% chance
|
||||
( "rim" snd . ) sometimes ;; 50% chance
|
||||
( "tom" snd . ) rarely ;; 25% chance
|
||||
```
|
||||
|
||||
These words take a quotation and execute it probabilistically.
|
||||
@@ -181,52 +169,27 @@ These words take a quotation and execute it probabilistically.
|
||||
Execute a quotation on specific iterations:
|
||||
|
||||
```forth
|
||||
{ "snare" s . } 4 every ;; every 4th pattern iteration
|
||||
{ "hat" s . } 3 8 bjork ;; Euclidean: 3 hits across 8 step runs
|
||||
{ "hat" s . } 5 8 pbjork ;; Euclidean: 5 hits across 8 pattern iterations
|
||||
( "snare" snd . ) 4 every ;; every 4th pattern iteration
|
||||
( "hat" snd . ) 3 8 bjork ;; Euclidean: 3 hits across 8 step runs
|
||||
( "hat" snd . ) 5 8 pbjork ;; Euclidean: 5 hits across 8 pattern iterations
|
||||
```
|
||||
|
||||
`every` checks the pattern iteration count. On iteration 0, 4, 8, 12... the quotation runs. On all other iterations it is skipped.
|
||||
|
||||
`bjork` and `pbjork` use Bjorklund's algorithm to distribute k hits as evenly as possible across n positions. `bjork` counts by step runs, `pbjork` counts by pattern iterations. Classic Euclidean rhythms: tresillo (3,8), cinquillo (5,8), son clave (5,16).
|
||||
|
||||
## Cycling
|
||||
|
||||
Cagire has built-in support for cycling through values. Push values onto the stack, then select one based on pattern state:
|
||||
|
||||
```forth
|
||||
60 64 67 3 cycle note
|
||||
```
|
||||
|
||||
Each time the step runs, a different note is selected. The `3` tells `cycle` how many values to pick from.
|
||||
|
||||
You can also use quotations if you need to execute code:
|
||||
|
||||
```forth
|
||||
{ c4 note } { e4 note } { g4 note } 3 cycle
|
||||
```
|
||||
|
||||
When the selected value is a quotation, it gets executed. When it is a plain value, it gets pushed onto the stack.
|
||||
|
||||
Two cycling words exist:
|
||||
|
||||
- `cycle` - selects based on `runs` (how many times this step has played)
|
||||
- `pcycle` - selects based on `iter` (how many times the pattern has looped)
|
||||
|
||||
The difference between `cycle` and `pcycle` matters when patterns have different lengths. `cycle` counts per-step, `pcycle` counts per-pattern.
|
||||
|
||||
## Polyphonic Parameters
|
||||
|
||||
Parameter words like `note`, `freq`, and `gain` consume the entire stack. If you push multiple values before a param word, you get polyphony:
|
||||
|
||||
```forth
|
||||
60 64 67 note sine s . ;; emits 3 voices with notes 60, 64, 67
|
||||
60 64 67 note sine snd . ;; emits 3 voices with notes 60, 64, 67
|
||||
```
|
||||
|
||||
This works for any param and for the sound word itself:
|
||||
|
||||
```forth
|
||||
440 880 freq sine tri s . ;; 2 voices: sine at 440, tri at 880
|
||||
440 880 freq sine tri snd . ;; 2 voices: sine at 440, tri at 880
|
||||
```
|
||||
|
||||
When params have different lengths, shorter lists cycle:
|
||||
@@ -234,7 +197,7 @@ When params have different lengths, shorter lists cycle:
|
||||
```forth
|
||||
60 64 67 note ;; 3 notes
|
||||
0.5 1.0 gain ;; 2 gains (cycles: 0.5, 1.0, 0.5)
|
||||
sine s . ;; emits 3 voices
|
||||
sine snd . ;; emits 3 voices
|
||||
```
|
||||
|
||||
Polyphony multiplies with `at` deltas:
|
||||
@@ -242,7 +205,7 @@ Polyphony multiplies with `at` deltas:
|
||||
```forth
|
||||
0 0.5 at ;; 2 time points
|
||||
60 64 note ;; 2 notes
|
||||
sine s . ;; emits 4 voices (2 notes × 2 times)
|
||||
sine snd . ;; emits 4 voices (2 notes × 2 times)
|
||||
```
|
||||
|
||||
## Summary
|
||||
|
||||
@@ -1,18 +1,57 @@
|
||||
# The Prelude
|
||||
# Preludes
|
||||
|
||||
You can define words in any step and they become available to all other steps. But as a project grows, definitions get scattered across steps and become hard to find and maintain. The **prelude** is a dedicated place for this. It is a project-wide Forth script that runs once before the first step plays. Definitions, variables, settings — everything in one place. Press `d` to open the prelude editor. Press `Esc` to save and close. Press `D` (Shift+d) to re-evaluate it without opening the editor.
|
||||
Cagire has two levels of prelude: a **project prelude** shared by all banks, and **bank preludes** that travel with each bank.
|
||||
|
||||
## Bank Prelude
|
||||
|
||||
Each bank can carry its own prelude script. Press `p` to open the current bank's prelude editor. Press `Esc` to save, evaluate, and close.
|
||||
|
||||
Bank preludes make banks self-contained. When you share a bank, its prelude travels with it — recipients get all the definitions they need without merging anything into their own project.
|
||||
|
||||
```forth
|
||||
: bass pulse sound 0.8 gain 400 lpf 1 lpd 8 lpe 0.6 width . ;
|
||||
: pad sine sound 0.5 gain 2 spread 1.5 attack 0.4 verb . ;
|
||||
```
|
||||
|
||||
Every step in that bank can now use `bass` and `pad`. Share the bank and the recipient gets these definitions automatically.
|
||||
|
||||
## Project Prelude
|
||||
|
||||
The project prelude is a global script shared across all banks. Press `P` (Shift+p) to open it. Use it for truly project-wide definitions, variables, and settings that every bank should see.
|
||||
|
||||
```forth
|
||||
c2 !root
|
||||
0 !mode
|
||||
42 seed
|
||||
```
|
||||
|
||||
## Evaluation Order
|
||||
|
||||
When preludes are evaluated (on playback start, project load, or pressing `d`):
|
||||
|
||||
1. **Project prelude** runs first
|
||||
2. **Bank 0 prelude** runs next (if non-empty)
|
||||
3. **Bank 1 prelude**, then **Bank 2**, ... up to **Bank 31**
|
||||
|
||||
Only non-empty bank preludes are evaluated. Last-evaluated wins for name collisions — a bank prelude can override a project-level definition.
|
||||
|
||||
## Keybindings
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `p` | Open current bank's prelude editor |
|
||||
| `P` | Open project prelude editor |
|
||||
| `d` | Re-evaluate all preludes (project + all banks) |
|
||||
|
||||
## Naming Your Sounds
|
||||
|
||||
The most common use of the prelude is to define words for your instruments. Without a prelude, every step that plays a bass has to spell out the full sound design or to create a new word before using it:
|
||||
The most common use of a bank prelude is to define words for your instruments. Without a prelude, every step that plays a bass has to spell out the full sound design:
|
||||
|
||||
```forth
|
||||
pulse sound 0.8 gain 400 lpf 1 lpd 8 lpe 0.6 width .
|
||||
pulse sound c2 note 0.8 gain 400 lpf 1 lpd 8 lpe 0.6 width .
|
||||
```
|
||||
|
||||
Repeat this across eight steps without making a new word and you have eight copies of the same thing. Change the filter? Change it eight times.
|
||||
|
||||
In the prelude, define it once:
|
||||
In the bank prelude, define it once:
|
||||
|
||||
```forth
|
||||
: bass pulse sound 0.8 gain 400 lpf 1 lpd 8 lpe 0.6 width . ;
|
||||
@@ -20,22 +59,8 @@ In the prelude, define it once:
|
||||
|
||||
Now every step just writes `c2 note bass`. Change the sound in one place, every step follows.
|
||||
|
||||
A step that used to read:
|
||||
|
||||
```forth
|
||||
pulse sound c2 note 0.8 gain 400 lpf 1 lpd 8 lpe 0.6 width .
|
||||
```
|
||||
|
||||
Becomes:
|
||||
|
||||
```forth
|
||||
c2 note bass
|
||||
```
|
||||
|
||||
## Building a Vocabulary
|
||||
|
||||
The prelude is where you build the vocabulary for your music. Not just instruments but any combination of code / words you want to reuse:
|
||||
|
||||
```forth
|
||||
;; instruments
|
||||
: bass pulse sound 0.8 gain 400 lpf 1 lpd 8 lpe 0.6 width . ;
|
||||
@@ -49,11 +74,11 @@ The prelude is where you build the vocabulary for your music. Not just instrumen
|
||||
: loud 0.9 gain ;
|
||||
```
|
||||
|
||||
By using the prelude and predefined words, steps become expressive and short. The prelude carries the design decisions; steps carry the composition.
|
||||
Steps become expressive and short. The prelude carries the design decisions; steps carry the composition.
|
||||
|
||||
## Setting Initial State
|
||||
|
||||
The prelude also runs plain Forth, not just definitions. You can use it to set variables and seed the random generator:
|
||||
The project prelude is the right place for global state:
|
||||
|
||||
```forth
|
||||
c2 !root
|
||||
@@ -61,18 +86,18 @@ c2 !root
|
||||
42 seed
|
||||
```
|
||||
|
||||
Every step can then read `@root` and `@mode`. And `42 seed` makes randomness reproducible — same seed, same sequence every time you hit play.
|
||||
Every step can then read `@root` and `@mode`. And `42 seed` makes randomness reproducible.
|
||||
|
||||
## When It Runs
|
||||
## When Preludes Run
|
||||
|
||||
The prelude evaluates at three moments:
|
||||
Preludes evaluate at three moments:
|
||||
|
||||
1. When you press **Space** to start playback
|
||||
2. When you **load** a project
|
||||
3. When you press **D** manually
|
||||
3. When you press **d** manually
|
||||
|
||||
It runs once at these moments, not on every step. This makes it the right place for definitions and initial values. If you edit the prelude while playing, press `D` to push changes into the running session. New definitions take effect immediately; the next time a step runs, it sees the updated words.
|
||||
They run once at these moments, not on every step. If you edit a prelude while playing, press `d` to push changes into the running session.
|
||||
|
||||
## What Not to Put Here
|
||||
|
||||
The prelude has no access to sequencer state. Words like `step`, `beat`, `iter`, and `phase` are meaningless here because no step is playing yet. Use the prelude for definitions and setup, not for logic that depends on timing. The prelude also should not emit sounds. It runs silently — any `.` calls here would fire before the sequencer clock is running and produce nothing useful.
|
||||
Preludes have no access to sequencer state. Words like `step`, `beat`, `iter`, and `phase` are meaningless here because no step is playing yet. Use preludes for definitions and setup, not for logic that depends on timing. Preludes also should not emit sounds — any `.` calls here would fire before the sequencer clock is running.
|
||||
|
||||
@@ -89,7 +89,7 @@ The fix is simple: make sure you push enough values before calling a word. Check
|
||||
* **Leftover values** are the opposite problem: values remain on the stack after your script finishes. This is less critical but indicates sloppy code. If your script leaves unused values behind, you probably made a mistake somewhere.
|
||||
|
||||
```forth
|
||||
3 4 5 + . ;; plays a sound, but 3 is still on the stack
|
||||
3 4 5 + ;; 3 is still on the stack, unconsumed
|
||||
```
|
||||
|
||||
The `3` was never used. Either it should not be there, or you forgot a word that consumes it.
|
||||
|
||||
@@ -6,6 +6,8 @@ Cagire organizes all your patterns and data following a strict hierarchy:
|
||||
- **Banks** contain **Patterns**.
|
||||
- **Patterns** contain **Steps**.
|
||||
|
||||
If strict organization isn't your style, don't worry, you can ignore banks entirely and just work in a single pattern. You can also escape the strict metric using sub-step timing and randomness.
|
||||
|
||||
## Structure
|
||||
|
||||
```
|
||||
@@ -15,7 +17,7 @@ Project
|
||||
└── 1024 Steps (per pattern)
|
||||
```
|
||||
|
||||
A single project gives you 32 banks, each holding 32 patterns. You get 1024 patterns in each project, ~1.048.000 steps. This means that you can create a staggering amount of things. Don't hesitate to create copies, variations, and explore the pattern system thoroughly.
|
||||
A single project gives you 32 banks, each holding 32 patterns. You get 1024 patterns in each project, ~1.048.000 steps. This means that you can create a staggering amount of music. Don't hesitate to create copies, variations, and explore the pattern system thoroughly. The more you add, the more surprising it becomes.
|
||||
|
||||
## Patterns
|
||||
|
||||
@@ -29,7 +31,7 @@ Each pattern is an independent sequence of steps with its own properties:
|
||||
| Sync Mode | Reset or Phase-Lock on re-trigger | `Reset` |
|
||||
| Follow Up | What happens when the pattern finishes an iteration | `Loop` |
|
||||
|
||||
Press `e` in the patterns view to edit these settings.
|
||||
Press `e` in the patterns view to edit these settings. After editing properties, you will have to hit the `c` key to _launch_ these changes. More about that later!
|
||||
|
||||
### Follow Up
|
||||
|
||||
@@ -44,22 +46,26 @@ The follow-up action determines what happens when a pattern reaches the end of i
|
||||
Access the patterns view with `F2` (or `Ctrl+Up` from the sequencer). The view shows all banks and patterns in a grid. Indicators show pattern state:
|
||||
|
||||
- `>` Currently playing
|
||||
- `+` Staged to play
|
||||
- `-` Staged to stop
|
||||
- `+` Armed to play
|
||||
- `-` Armed to stop
|
||||
- `M` Muted
|
||||
- `S` Soloed
|
||||
|
||||
It is quite essential for you to understand the arm / launch system in order to use patterns. Please read the next section carefully!
|
||||
|
||||
### Keybindings
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `Arrows` | Navigate banks and patterns |
|
||||
| `Enter` | Select and return to sequencer |
|
||||
| `p` | Stage pattern to play/stop |
|
||||
| `c` | Commit staged changes |
|
||||
| `m` / `x` | Stage mute / solo toggle |
|
||||
| `p` | Arm pattern to play/stop |
|
||||
| `c` | Launch armed changes |
|
||||
| `m` / `x` | Arm mute / solo toggle |
|
||||
| `e` | Edit pattern properties |
|
||||
| `r` | Rename bank or pattern |
|
||||
| `Ctrl+c` / `Ctrl+v` | Copy / Paste |
|
||||
| `Delete` | Reset to empty pattern |
|
||||
| `Esc` | Cancel staged changes |
|
||||
| `Esc` | Cancel armed changes |
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# Big Picture
|
||||
|
||||
Let's answer some basic questions: what exactly is Cagire? What purpose does it serve? Cagire is a small and simple piece of software that allows you to create music live while playing with scripts. At heart, it is really nothing more than a classic step sequencer, the kind you can buy in a music store. It is deliberately kept small and simple. Adding the Forth language to program steps allows you to create patterns and behaviors of any complexity. Forth also makes it super easy to extend and to customize Cagire while keeping the core mechanisms and the logic simple.
|
||||
> **What exactly is Cagire? What purpose does it serve?**
|
||||
|
||||
Cagire is a small and simple software that allows you to create music live while programming short scripts. At heart, it is really nothing more than a classic step sequencer, the kind you can buy in a music store. It is deliberately kept small and simple in form, but it goes rather deep if you take the time to discover the audio engine and all its capabilities. Adding the Forth language to program steps allows you to create patterns and behaviors of any complexity. Forth also makes it easy to extend and to customize Cagire while keeping the core mechanisms and the logic simple.
|
||||
|
||||
Cagire is not complex, it is just very peculiar. It has been created as a hybrid between a step sequencer and a programming environment. It allows you to create music live and to extend and customize it using the power of Forth. It has been designed to be fast and responsive, low-tech in the sense that you can run it on any decent computer. You can think of it as a musical instrument. You learn it by getting into the flow and practicing. What you ultimately do with it is up to you: improvisation, composition, etc. Cagire is also made to be autonomous, self-contained, and self-sustaining: it contains all the necessary components to make music without relying on external software or hardware.
|
||||
|
||||
@@ -8,29 +10,40 @@ Cagire is not complex, it is just very peculiar. It has been created as a hybrid
|
||||
|
||||
A traditional step sequencer would offer the musician a grid where each step represents a note or a single musical event. Cagire replaces notes and/or events in favour of **Forth scripts**. When the sequencer reaches a step to play, it runs the script associated with it. A script can do whatever it is programmed to do: play a note, trigger a sample, apply effects, generate randomness, or all of the above. Scripts can share code and data with each other. Everything else works like a regular step sequencer: you can toggle, copy, paste, and rearrange steps freely.
|
||||
|
||||
```forth
|
||||
0.0 8.0 rand at
|
||||
sine sound
|
||||
200 2000 rand 100 4000 rand
|
||||
4 slide freq 0.6 verb 2 vib
|
||||
0.125 vibmod 0.2 chorus
|
||||
0.4 0.6 rand gain
|
||||
.
|
||||
```
|
||||
|
||||
## What Does a Script Look Like?
|
||||
|
||||
A Forth script is generally kind of small, and it solves a simple problem: playing a chord, tweaking some parameters, etc. The more focused it is, the better. Using Forth doesn't feel like programming at all. It feels more like juggling with words and numbers or writing bad computer poetry. Here is a program that plays a middle C note using a sine wave:
|
||||
A Forth script is generally kind of small, and it solves a simple problem: playing a chord, tweaking some parameters, etc. The more focused it is, the better. Using Forth doesn't feel like programming at all. It feels more like juggling with words and numbers or writing bad computer poetry. Here is a program that plays a middle C note for two steps using a sine wave:
|
||||
|
||||
```forth
|
||||
c4 note sine sound .
|
||||
c4 note sine sound 2 decay .
|
||||
```
|
||||
|
||||
Read it backwards and you will understand what it does:
|
||||
|
||||
- `.` — play a sound.
|
||||
- `2 decay` — the sound takes two steps to die.
|
||||
- `sine sound` — the sound is a sine wave.
|
||||
- `c4 note` — the pitch is C4 (middle C).
|
||||
|
||||
Five tokens separated by spaces. There is pretty much no syntax to learn, just three rules:
|
||||
There is pretty much no syntax to learn, just three rules:
|
||||
|
||||
- There are `words` and `numbers`.
|
||||
- A `word` is anything that is not a space or a number.
|
||||
- A `word` is anything that is not a space or a number (can include symbols).
|
||||
- A `number` is anything that is not a space or a word.
|
||||
- They are separated by spaces.
|
||||
- Everything piles up on the **stack**.
|
||||
|
||||
The stack is what makes Forth tick. Think of it as a pile of things. `c4` puts a pitch on the pile. `note` picks it up. `sine` chooses a waveform. `sound` assembles everything into a voice. `.` plays it. Each word picks up what the previous ones left behind and leaves something for the next. Scripts can be simple one-liners or complex programs with conditionals, loops, and randomness. You will need to understand the stack, but it will take five minutes. See the **Forth** section for details.
|
||||
The stack is what makes Forth tick. Think of it as a pile of things. `c4` puts a pitch on the pile. `note` picks it up. `sine` chooses a waveform. `sound` assembles everything into a voice. `.` plays it. Each word picks up what the previous ones left behind and leaves something for the next. Scripts can be simple one-liners or complex programs with conditionals, loops, and randomness. Cagire requires you to understand what the stack is. The good thing is that it will take five minutes for you to make sense of it. See the **Forth** section for details.
|
||||
|
||||
## The Audio Engine
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Editing a Step
|
||||
|
||||
Each step in Cagire contains a Forth script. When the sequencer reaches that step, it runs the script to produce sound. This is where you write your music. Press `Enter` when hovering over any step to open the code editor. The editor appears as a modal overlay with the step number in the title bar. If the step is a linked step (shown with an arrow like `→05`), pressing `Enter` navigates to the source step instead.
|
||||
Each step in Cagire contains a Forth script. When the sequencer reaches that step, it runs the script to produce sound. This is where you write your music. Press `Enter` when hovering over any step to open the code editor. The editor appears as a modal overlay with the step number in the title bar. If the step is a mirrored step (shown with an arrow like `→05`), pressing `Enter` navigates to the source step instead.
|
||||
|
||||
## Writing Scripts
|
||||
|
||||
@@ -18,7 +18,7 @@ Add parameters before words to modify them:
|
||||
c4 note 0.75 decay sine sound .
|
||||
```
|
||||
|
||||
Writing long lines is not recommended because it can become quite unmanageable. Instead, break them into multiple lines for clarity:
|
||||
Writing long lines can become tedious. Instead, break your code into multiple lines for clarity:
|
||||
|
||||
```forth
|
||||
;; the same sound on multiple lines
|
||||
@@ -29,6 +29,12 @@ sine sound
|
||||
.
|
||||
```
|
||||
|
||||
Forth has no special rule about what a line should look like and space has no meaning.
|
||||
|
||||
## Adding comments to your code
|
||||
|
||||
You can comment a line using `;;`. This is not very common for people that are used to Forth. There are no multiline comments.
|
||||
|
||||
## Saving
|
||||
|
||||
- `Esc` — Save, compile, and close the editor.
|
||||
@@ -64,27 +70,6 @@ Press `Ctrl+F` to open the search bar. Type your query, then navigate matches:
|
||||
- `Enter` — Confirm and close search.
|
||||
- `Esc` — Cancel search.
|
||||
|
||||
## Debugging
|
||||
## Script preview
|
||||
|
||||
Press `Ctrl+S` to toggle the stack display. This shows the stack state evaluated up to the cursor line, useful for understanding how values flow through your script.
|
||||
|
||||
Press `Ctrl+R` to execute the script immediately as a one-shot, without waiting for the sequencer to reach the step. A green flash indicates success, red indicates an error.
|
||||
|
||||
## Keybindings
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `Esc` | Save and close |
|
||||
| `Ctrl+E` | Evaluate (save + compile in place) |
|
||||
| `Ctrl+R` | Execute script once |
|
||||
| `Ctrl+S` | Toggle stack display |
|
||||
| `Ctrl+B` | Open sample finder |
|
||||
| `Ctrl+F` | Search |
|
||||
| `Ctrl+N` | Next match / next suggestion |
|
||||
| `Ctrl+P` | Previous match / previous suggestion |
|
||||
| `Ctrl+A` | Select all |
|
||||
| `Ctrl+C` | Copy |
|
||||
| `Ctrl+X` | Cut |
|
||||
| `Ctrl+V` | Paste |
|
||||
| `Shift+Arrows` | Extend selection |
|
||||
| `Tab` | Accept completion / sample |
|
||||
Press `Ctrl+R` to execute the script immediately as a one-shot, without waiting for the sequencer to reach the step. A green flash indicates success, red indicates an error. This is super useful for sound design. It also works when hovering on a step with the editor closed.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# The Audio Engine
|
||||
|
||||
The Engine page (`F6`) is where you configure audio hardware, adjust performance settings, and manage your sample library. The right side of the page shows a real-time oscilloscope and spectrum analyzer. The page is divided into three sections. Press `Tab` to move between them, `Shift+Tab` to go back.
|
||||
The Engine page (`F6`) is where you configure audio hardware, manage MIDI connections, set up Ableton Link, and manage your sample library. The left column holds six configuration sections — press `Tab` to move between them, `Shift+Tab` to go back. The right column is a read-only monitoring panel with VU meters, status metrics, and an oscilloscope.
|
||||
|
||||
## Devices
|
||||
|
||||
@@ -17,11 +17,29 @@ Four audio parameters are adjustable with `Left`/`Right`:
|
||||
| Voices | 1–128 | Maximum polyphony (simultaneous sounds) |
|
||||
| Nudge | -100 to +100 ms | Timing offset to compensate for latency |
|
||||
|
||||
The last two rows — sample rate and audio host — are read-only values reported by your system. After changing the buffer size or channel count, press `Shift+r` to restart the audio engine for changes to take effect.
|
||||
After changing the buffer size or channel count, press `Shift+r` to restart the audio engine for changes to take effect.
|
||||
|
||||
## Link
|
||||
|
||||
Ableton Link synchronizes tempo across devices and applications on the same network. Three settings are adjustable with `Left`/`Right`:
|
||||
|
||||
- **Enabled** — Turn Link on or off. A status badge next to the header shows DISABLED, LISTENING, or CONNECTED.
|
||||
- **Start/Stop Sync** — Whether play/stop commands are shared with other Link peers.
|
||||
- **Quantum** — Number of beats per phrase, used for phase alignment.
|
||||
|
||||
Below the settings, three read-only session values update in real time: Tempo, Beat, and Phase.
|
||||
|
||||
## MIDI Outputs
|
||||
|
||||
Four output slots (0–3). Browse with `Up`/`Down`, cycle available devices with `Left`/`Right`. A slot shows "(not connected)" until you assign a device.
|
||||
|
||||
## MIDI Inputs
|
||||
|
||||
Same layout as outputs — four input slots (0–3) with the same navigation.
|
||||
|
||||
## Samples
|
||||
|
||||
This section shows how many sample directories are registered and how many files have been indexed. Press `A` to open a file browser and add a new sample directory. Press `D` to remove the last one. Cagire indexes audio files (wav, mp3, ogg, flac, aac, m4a) from all registered paths.
|
||||
This section shows how many sample directories are registered and how many files have been indexed. Browse existing paths with `Up`/`Down`. Press `A` to open a file browser and add a new sample directory. Press `D` to remove the selected path. Cagire indexes audio files (wav, mp3, ogg, flac, aac, m4a) from all registered paths.
|
||||
|
||||
Sample directories must be added here before you can use the sample browser or reference samples in your scripts.
|
||||
|
||||
@@ -30,23 +48,17 @@ Sample directories must be added here before you can use the sample browser or r
|
||||
A few keys work from anywhere on the Engine page:
|
||||
|
||||
- `h` — Hush. Silence all audio immediately.
|
||||
- `p` — Panic. Hard stop, clears all active voices.
|
||||
- `p` — Panic. Hard stop, clears all active voices, stop all patterns.
|
||||
- `t` — Test tone. Plays a brief sine wave to verify audio output.
|
||||
- `r` — Reset the peak voice counter.
|
||||
- `Shift+r` — Restart the audio engine.
|
||||
|
||||
## Keybindings
|
||||
## Monitoring
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `Tab` / `Shift+Tab` | Next / previous section |
|
||||
| `Up` / `Down` | Navigate within section |
|
||||
| `Left` / `Right` | Switch device column / adjust setting |
|
||||
| `PageUp` / `PageDown` | Scroll device list |
|
||||
| `Enter` | Select device |
|
||||
| `D` | Refresh devices / remove last sample path |
|
||||
| `A` | Add sample directory |
|
||||
| `Shift+r` | Restart audio engine |
|
||||
| `h` | Hush |
|
||||
| `p` | Panic |
|
||||
| `t` | Test tone |
|
||||
| `r` | Reset peak voices |
|
||||
The right column displays a live overview of the engine state. Everything here is read-only.
|
||||
|
||||
- **VU Meters** — Left and right channel levels with horizontal bars and dB readouts. Green below -12 dB, yellow approaching 0 dB, red above.
|
||||
|
||||
- **Status** — CPU load (with bar graph), active voices and peak count, scheduled events, schedule depth, nudge offset, sample rate, audio host, and Link peers (when connected).
|
||||
|
||||
- **Scope** — An oscilloscope showing the current audio output waveform.
|
||||
|
||||
@@ -1,43 +1,49 @@
|
||||
# The Sequencer Grid
|
||||
|
||||
The sequencer grid is the main view of Cagire (`F5`). This is the one you see when you open the application. On this view, you can see the step sequencer grid and edit each step using the code editor. You can optionally display the following widgets:
|
||||
- **an oscilloscope**: visualize the current audio output.
|
||||
- **a spectrum analyzer**: 32 bands spectrum analyze (mostly cosmetic).
|
||||
- **a step preview**: visualize the content of the hovered script.
|
||||
|
||||
You can press `o` to cycle through layouts. It will basically rotate the sequencer around. Use it to find the view that makes the more sense for you.
|
||||
The sequencer grid (`F5`) is where you spend most of your time in Cagire. It shows the step sequencer and lets you edit each step using the code editor. This is the first view you see when you open the application. Optional widgets — oscilloscope, spectrum analyzer, goniometer, prelude preview, and step preview — can be toggled on for visual feedback while you work.
|
||||
|
||||
## Navigation
|
||||
|
||||
Use arrow keys to move between steps. The grid wraps around at pattern boundaries. Press `:` to jump directly to a step by number. This keybinding is useful for very long patterns.
|
||||
Use arrow keys to move between steps. `Shift+arrows` selects multiple steps, and `Esc` clears any selection. The grid wraps around at pattern boundaries. Press `:` to jump directly to a step by number.
|
||||
|
||||
## Preview
|
||||
|
||||
Press `p` to enter preview mode. A read-only code editor opens showing the script of the step under the cursor. You can still navigate the grid while previewing. Press `Esc` to exit preview mode.
|
||||
|
||||
## Selection
|
||||
|
||||
Hold `Shift` while pressing arrow keys to select multiple steps. Press `Esc` to clear the selection.
|
||||
- `Alt+Up` / `Alt+Down` — Previous / next pattern
|
||||
- `Alt+Left` / `Alt+Right` — Previous / next bank
|
||||
|
||||
## Editing Steps
|
||||
|
||||
- `Enter` — Open the script editor
|
||||
- `t` — Toggle step active/inactive
|
||||
- `t` — Make a step active / inactive
|
||||
- `r` — Rename a step
|
||||
- `Del` — Delete selected steps
|
||||
|
||||
## Mirrored Steps
|
||||
|
||||
Imagine a drum pattern where four steps play the same kick script. You tweak the sound on one of them — now you have to find and edit all four. Mirrored steps solve this: one step is the source, the others are mirrors that always reflect its script. Edit the source once, every mirror follows.
|
||||
|
||||
On the grid, mirrors are easy to spot. They show an arrow prefix like `→05`, meaning "I mirror step 05." Steps that share a source also share a background color, so clusters of linked steps are visible at a glance.
|
||||
|
||||
To create mirrors: copy a step with `Ctrl+C`, then paste with `Ctrl+B` instead of `Ctrl+V`. The pasted steps become mirrors of the original. Pressing `Enter` on a mirror jumps to its source and opens the editor there. If you want to break the link and make a mirror independent again, press `Ctrl+H` to harden it back into a regular copy.
|
||||
|
||||
## Copy & Paste
|
||||
|
||||
- `Ctrl+C` — Copy selected steps
|
||||
- `Ctrl+V` — Paste as copies
|
||||
- `Ctrl+B` — Paste as linked steps
|
||||
- `Ctrl+V` — Paste as independent copies
|
||||
- `Ctrl+B` — Paste as mirrored steps
|
||||
- `Ctrl+D` — Duplicate selection
|
||||
- `Ctrl+H` — Harden links (convert to independent copies)
|
||||
- `Ctrl+H` — Harden mirrors (convert to independent copies)
|
||||
|
||||
Linked steps share the same script as their source. When you edit the source, all linked steps update automatically. This is an extremely important and powerful feature. It allows you to create complex patterns with minimal effort. `Ctrl+H` converts linked steps back to independent copies.
|
||||
## Preludes
|
||||
|
||||
Each bank has its own prelude — a Forth script for definitions and setup that travels with the bank when shared. There is also a project-wide prelude for global configuration.
|
||||
|
||||
- `p` — Open current bank's prelude editor
|
||||
- `P` — Open project prelude editor
|
||||
- `d` — Evaluate all preludes (project + all banks)
|
||||
|
||||
## Pattern Controls
|
||||
|
||||
Each pattern has its own length and speed. Length sets how many steps it cycles through. Speed is a multiplier on the global tempo.
|
||||
|
||||
- `<` / `>` — Decrease / increase pattern length
|
||||
- `[` / `]` — Decrease / increase pattern speed
|
||||
- `L` — Set length directly
|
||||
@@ -45,6 +51,8 @@ Linked steps share the same script as their source. When you edit the source, al
|
||||
|
||||
## Playback
|
||||
|
||||
Playback starts and stops globally across all unmuted patterns. The highlighted cell on the grid marks the currently playing step.
|
||||
|
||||
- `Space` — Toggle play / stop
|
||||
- `+` / `-` — Adjust tempo
|
||||
- `T` — Set tempo directly
|
||||
@@ -52,57 +60,24 @@ Linked steps share the same script as their source. When you edit the source, al
|
||||
|
||||
## Mute & Solo
|
||||
|
||||
Mute silences a pattern; solo silences everything except it. Both work while playing.
|
||||
|
||||
- `m` — Mute current pattern
|
||||
- `x` — Solo current pattern
|
||||
- `Shift+m` — Clear all mutes
|
||||
- `Shift+x` — Clear all solos
|
||||
|
||||
## Prelude
|
||||
## Project
|
||||
|
||||
The prelude is a Forth script that runs before every step, useful for defining shared variables and setup code.
|
||||
|
||||
- `d` — Open the prelude editor
|
||||
- `Shift+d` — Evaluate the prelude
|
||||
- `s` — Save project
|
||||
- `l` — Load project
|
||||
- `q` — Quit
|
||||
|
||||
## Tools
|
||||
|
||||
A few utilities accessible from the grid.
|
||||
|
||||
- `e` — Euclidean rhythm distribution
|
||||
- `?` — Show keybindings help
|
||||
- `o` — Cycle layout
|
||||
- `Tab` — Toggle sample browser panel
|
||||
|
||||
## Visual Indicators
|
||||
|
||||
- **Highlighted cell** — Currently playing step
|
||||
- **Colored backgrounds** — Linked steps share colors by source
|
||||
- **Arrow prefix** (`→05`) — Step is linked to step 05
|
||||
|
||||
## Keybindings
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `Arrows` | Navigate grid |
|
||||
| `Shift+Arrows` | Extend selection |
|
||||
| `:` | Jump to step |
|
||||
| `Enter` | Open editor |
|
||||
| `p` | Preview step |
|
||||
| `t` | Toggle step active |
|
||||
| `r` | Rename step |
|
||||
| `Del` | Delete steps |
|
||||
| `Ctrl+C` / `Ctrl+V` | Copy / Paste |
|
||||
| `Ctrl+B` | Paste as links |
|
||||
| `Ctrl+D` | Duplicate |
|
||||
| `Ctrl+H` | Harden links |
|
||||
| `<` / `>` | Pattern length |
|
||||
| `[` / `]` | Pattern speed |
|
||||
| `L` / `S` | Set length / speed |
|
||||
| `Space` | Play / Stop |
|
||||
| `+` / `-` | Tempo up / down |
|
||||
| `T` | Set tempo |
|
||||
| `Ctrl+R` | Execute step once |
|
||||
| `m` / `x` | Mute / Solo |
|
||||
| `d` | Prelude editor |
|
||||
| `e` | Euclidean distribution |
|
||||
| `o` | Cycle layout |
|
||||
| `Tab` | Sample browser |
|
||||
| `Ctrl+Z` | Undo |
|
||||
| `Ctrl+Shift+Z` | Redo |
|
||||
| `?` | Show keybindings |
|
||||
|
||||
@@ -1,41 +1,6 @@
|
||||
# Navigation
|
||||
|
||||
Cagire's interface is organized as a 3x2 grid of six views:
|
||||
|
||||
```
|
||||
Dict Patterns Options
|
||||
Help Sequencer Engine
|
||||
```
|
||||
|
||||
- *Dict* : Forth dictionary — learn about the language.
|
||||
- *Help* : Help and tutorials — learn about the tool.
|
||||
- *Patterns* : Manage your current session / project.
|
||||
- *Sequencer* : The main view, where you edit sequences and play music.
|
||||
- *Options* : Configuration settings for the application.
|
||||
- *Engine* : Configuration settings for the audio engine.
|
||||
|
||||
## Switching Views
|
||||
|
||||
Use `Ctrl+Arrow` keys to move between views. A minimap will briefly appear to show your position in the grid. You can also click on the view name at the bottom left to open the switch view panel.
|
||||
|
||||
- `Ctrl+Left` / `Ctrl+Right` — move horizontally (wraps around)
|
||||
- `Ctrl+Up` / `Ctrl+Down` — move vertically (does not wrap)
|
||||
- `Click` at bottom left — select a view
|
||||
|
||||
You can also jump directly to any view with the F-keys:
|
||||
|
||||
| Key | View |
|
||||
|------|------------|
|
||||
| `F1` | Dict |
|
||||
| `F2` | Patterns |
|
||||
| `F3` | Options |
|
||||
| `F4` | Help |
|
||||
| `F5` | Sequencer |
|
||||
| `F6` | Engine |
|
||||
|
||||
## Common Keys
|
||||
|
||||
These shortcuts work on every view:
|
||||
Press `?` on any view to see its keybindings. The most important shortcuts are always displayed in the footer bar. Press `Esc` to close the keybindings panel. These shortcuts work on every view:
|
||||
|
||||
| Key | Action |
|
||||
|---------|---------------------------|
|
||||
@@ -45,6 +10,29 @@ These shortcuts work on every view:
|
||||
| `l` | Load project |
|
||||
| `?` | Show keybindings for view |
|
||||
|
||||
## Getting Help
|
||||
## Views
|
||||
|
||||
Press `?` on any view to see the associated keybindings. This shows all available shortcuts for the current context. The most important keybindings are displayed in the footer bar. Press `Esc` to close the keybindings panel.
|
||||
Cagire's interface is organized as a 3x2 grid of six views. Jump to any view with its F-key or `Ctrl+Arrow` keys:
|
||||
|
||||
```
|
||||
F1 Dict F2 Patterns F3 Options
|
||||
F4 Help F5 Sequencer F6 Engine
|
||||
```
|
||||
|
||||
| Key | View | Description |
|
||||
|------|------------|-------------|
|
||||
| `F1` | Dict | Forth dictionary — learn about the language |
|
||||
| `F2` | Patterns | Manage your current session / project |
|
||||
| `F3` | Options | Configuration settings for the application |
|
||||
| `F4` | Help | Help and tutorials — learn about the tool |
|
||||
| `F5` | Sequencer | The main view, where you edit sequences and play music |
|
||||
| `F6` | Engine | Configuration settings for the audio engine |
|
||||
|
||||
Use `Ctrl+Arrow` keys to move between adjacent views. A minimap will briefly appear to show your position in the grid. You can also click on the view name at the bottom left or in the top left corner of the header bar to open the switch view panel.
|
||||
|
||||
- `Ctrl+Left` / `Ctrl+Right` — move horizontally (wraps around)
|
||||
- `Ctrl+Up` / `Ctrl+Down` — move vertically (does not wrap)
|
||||
|
||||
## Secrets
|
||||
|
||||
There is a hidden seventh view: the **Periodic Script**. Press `F11` to open it. The periodic script is a free-running Forth script evaluated at every step, independent of any pattern. It is useful for drones, global effects, control logic, and experimentation. See the **Periodic Script** tutorial for details.
|
||||
|
||||
@@ -1,45 +1,28 @@
|
||||
# Options
|
||||
|
||||
The Options page (`F3`) gathers all configuration settings in one place: display, synchronization and MIDI. Navigate options with `Up`/`Down` or `Tab`, change values with `Left`/`Right`. All changes are saved automatically.
|
||||
The Options page (`F3`) gathers display and onboarding settings in one place. Navigate with `Up`/`Down` or `Tab`, change values with `Left`/`Right`. All changes are saved automatically. A description line appears below the focused option to explain what it does.
|
||||
|
||||
## Display
|
||||
|
||||
| Option | Values | Description |
|
||||
|--------|--------|-------------|
|
||||
| Theme | (cycle) | Color scheme for the entire interface |
|
||||
| Hue rotation | 0–360° | Shift theme colors by a hue angle (±5° per step) |
|
||||
| Hue rotation | 0–360° | Shift all theme colors by a hue angle (±5° per step) |
|
||||
| Refresh rate | 60 / 30 / 15 fps | Lower values reduce CPU usage |
|
||||
| Runtime highlight | on / off | Highlight executed code spans during playback |
|
||||
| Show scope | on / off | Oscilloscope on the engine page |
|
||||
| Show spectrum | on / off | Spectrum analyzer on the engine page |
|
||||
| Show scope | on / off | Oscilloscope on the main view |
|
||||
| Show spectrum | on / off | Spectrum analyzer on the main view |
|
||||
| Show lissajous | on / off | XY stereo phase scope |
|
||||
| Gain boost | 1x – 16x | Amplify scope and lissajous waveforms |
|
||||
| Normalize | on / off | Auto-scale visualizations to fill the display |
|
||||
| Completion | on / off | Word completion popup in the editor |
|
||||
| Show preview | on / off | Step script preview on the sequencer grid |
|
||||
| Performance mode | on / off | Hide header and footer bars |
|
||||
| Font | 6x13 – 10x20 | Bitmap font size (plugin mode only) |
|
||||
| Zoom | 0.5x – 2.0x | Interface zoom factor (plugin mode only) |
|
||||
| Zoom | 50% – 200% | Interface zoom factor (plugin mode only) |
|
||||
| Window | (presets) | Window size presets (plugin mode only) |
|
||||
|
||||
## Ableton Link
|
||||
|
||||
Cagire uses Ableton Link to synchronize tempo with other applications on the same network. Three settings control the connection:
|
||||
|
||||
- **Enabled** — Turn Link on or off. When enabled, Cagire listens for peers and shares its tempo.
|
||||
- **Start/Stop sync** — When on, pressing play or stop in one app affects all peers.
|
||||
- **Quantum** — The beat subdivision used for phase alignment.
|
||||
|
||||
Below these settings, a read-only session display shows the current tempo, beat position, and phase. The status line at the top shows the connection state: disabled, listening, or connected with peer count.
|
||||
|
||||
## MIDI
|
||||
|
||||
Four output slots and four input slots let you connect to MIDI devices. Cycle through available devices with `Left`/`Right`. Each slot can hold one device, and the same device cannot be assigned to multiple slots.
|
||||
|
||||
## Onboarding
|
||||
|
||||
At the bottom, you can reset the onboarding guides if you dismissed them earlier and want to see them again.
|
||||
|
||||
## Keybindings
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `Up` / `Down` / `Tab` | Navigate options |
|
||||
| `Left` / `Right` | Change value |
|
||||
- **Reset guides** — Re-enable all dismissed guide popups.
|
||||
- **Demo on startup** — Load a rotating demo song on fresh startup.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# The Sample Browser
|
||||
|
||||
Press `Tab` on the sequencer grid to open the sample browser. It appears as a side panel showing a tree of all your sample directories and files. Press `Tab` again to close it. Before using the browser, you need to register at least one sample directory on the Engine page (`F6`). Cagire indexes audio files (wav, mp3, ogg, flac, aac, m4a) from all registered paths.
|
||||
Press `Tab` on the sequencer grid to open the sample browser. It appears as a side panel showing a tree of all your sample directories and files. Press `Tab` again to close it. Before using the browser, you need to register at least one sample directory on the Engine page (`F6`). Cagire indexes audio files (`.wav`, `.mp3`, `.ogg`, `.flac`, `.aac`, `.m4a`) from all registered paths.
|
||||
|
||||
## Browsing
|
||||
|
||||
@@ -28,15 +28,3 @@ kick sound .
|
||||
|
||||
See the **Samples** section in the Audio Engine documentation for details on how sample playback works.
|
||||
|
||||
## Keybindings
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `Tab` | Open / close browser |
|
||||
| `Up` / `Down` | Navigate |
|
||||
| `Right` | Expand folder / play file |
|
||||
| `Left` | Collapse folder |
|
||||
| `Enter` | Play file |
|
||||
| `PageUp` / `PageDown` | Fast scroll |
|
||||
| `/` | Search |
|
||||
| `Esc` | Clear search / close |
|
||||
|
||||
@@ -23,15 +23,3 @@ When saving, type a filename and press `Enter`. Parent directories are created a
|
||||
|
||||
When loading, browse to a `.cagire` file and press `Enter`. The project replaces the current session entirely.
|
||||
|
||||
## Keybindings
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `s` | Save (from any view) |
|
||||
| `l` | Load (from any view) |
|
||||
| `Up` / `Down` | Browse entries |
|
||||
| `Right` | Enter directory |
|
||||
| `Left` | Parent directory |
|
||||
| `Tab` | Autocomplete path |
|
||||
| `Enter` | Confirm |
|
||||
| `Esc` | Cancel |
|
||||
|
||||
@@ -1,46 +1,58 @@
|
||||
# Stage / Commit
|
||||
# Arm / Launch
|
||||
|
||||
Cagire requires you to `stage` changes you wish to make to the playback state and then `commit` it. It is way more simple than it seems. For instance, you mark pattern `04` and `05` to start playing, and _then_ you send the order to start the playback (`commit`). The same goes for stopping patterns. You mark which pattern to stop (`stage`) and then you give the order to stop them (`commit`). Why is staging useful? Here are some reasons why this design choice was made:
|
||||
In Cagire, changes to playback happen in two steps. First you **arm**: you mark what you want to happen. Then you **launch**: you apply all armed changes at once. Nothing changes until you launch. It is simpler than it sounds.
|
||||
|
||||
- **To apply multiple changes**: Queue several patterns to start/stop, commit them together.
|
||||
- **To get clean timing**: All changes happen on beat/bar boundaries.
|
||||
- **To help with live performance**: Prepare the next section without affecting current playback.
|
||||
Say you want patterns `04` and `05` to start playing together. You arm both (`p` on each), then launch (`c`). Both start at the same time. Want to stop them later? Arm them again, launch again. That's it.
|
||||
|
||||
Staging is an essential feature to understand to be effective when doing live performances:
|
||||
This two-step process exists for good reasons:
|
||||
|
||||
- **Multiple changes at once**: queue several patterns to start/stop, launch them together.
|
||||
- **Clean timing**: all changes land on beat or bar boundaries, never mid-step.
|
||||
- **Safe preparation**: set up the next section while the current one keeps playing.
|
||||
|
||||
## Arm changes, then launch
|
||||
|
||||
Arming is an essential feature to understand to be effective when doing live performances:
|
||||
|
||||
1. Open the **Patterns** view (`F2` or `Ctrl+Up` from sequencer)
|
||||
2. Navigate to a pattern you wish to change/play
|
||||
3. Press `p` to stage it. The pending change is going to be displayed:
|
||||
- `+` (staged to play)
|
||||
- `-` (staged to stop)
|
||||
3. Press `p` to arm it. The pending change is going to be displayed:
|
||||
- `+` (armed to play)
|
||||
- `-` (armed to stop)
|
||||
- `m` (armed to mute)
|
||||
- `s` (armed to solo)
|
||||
- etc.
|
||||
4. Repeat for other patterns you want to change
|
||||
5. Press `c` to commit all changes
|
||||
5. Press `c` to launch all changes
|
||||
6. Or press `Esc` to cancel
|
||||
|
||||
You can also stage mute/solo changes:
|
||||
You can also arm mute/solo changes:
|
||||
|
||||
- Press `m` to stage a mute toggle
|
||||
- Press `x` to stage a solo toggle
|
||||
- Press `m` to arm a mute toggle
|
||||
- Press `x` to arm a solo toggle
|
||||
- Press `Shift+m` to clear all mutes
|
||||
- Press `Shift+x` to clear all solos
|
||||
|
||||
A pattern might not start immediately depending on the sync mode you have chosen. It might wait for the next beat/bar boundary.
|
||||
A pattern might not start immediately depending on the sync mode you have chosen.
|
||||
It might wait for the next beat/bar boundary.
|
||||
|
||||
## Status Indicators
|
||||
|
||||
| Indicator | Meaning |
|
||||
|-----------|---------|
|
||||
| `>` | Currently playing |
|
||||
| `+` | Staged to play |
|
||||
| `-` | Staged to stop |
|
||||
| `+` | Armed to play |
|
||||
| `-` | Armed to stop |
|
||||
| `M` | Muted |
|
||||
| `S` | Soloed |
|
||||
|
||||
A pattern can show combined indicators, e.g. `>` (playing) and `-` (staged to stop), or `>M` (playing and muted).
|
||||
A pattern can show combined indicators, e.g. `>` (playing) and `-` (armed to stop), or `>M` (playing and muted).
|
||||
|
||||
Armed patterns blink to make pending changes impossible to miss.
|
||||
|
||||
## Quantization
|
||||
|
||||
Committed changes don't execute immediately. They wait for a quantization boundary:
|
||||
Launched changes don't execute immediately. They wait for a quantization boundary:
|
||||
|
||||
| Setting | Behavior |
|
||||
|---------|----------|
|
||||
|
||||
@@ -42,8 +42,8 @@ Crossfade between two sounds:
|
||||
|
||||
```forth
|
||||
1 1 ccval 127 / ;; normalize to 0.0-1.0
|
||||
dup saw s swap gain .
|
||||
1 swap - tri s swap gain .
|
||||
dup saw snd swap gain .
|
||||
1 swap - tri snd swap gain .
|
||||
```
|
||||
|
||||
## Scaling Values
|
||||
|
||||
@@ -15,7 +15,7 @@ Configure your MIDI devices in the **Options** view. Select input and output dev
|
||||
The audio engine (`Doux`) and MIDI are independent systems. Use `.` to emit audio commands, use `m.` to emit MIDI messages. You can use both in the same script:
|
||||
|
||||
```forth
|
||||
saw s c4 note 0.5 gain . ;; audio
|
||||
saw snd c4 note 0.5 gain . ;; audio
|
||||
60 note 100 velocity m. ;; MIDI
|
||||
```
|
||||
|
||||
|
||||
@@ -7,24 +7,31 @@ Every step has a duration. By default, sounds emit at the very start of that dur
|
||||
`at` drains the entire stack and stores the values as timing offsets. Each value is a fraction of the step duration: 0 = start, 0.5 = halfway, 1.0 = next step boundary.
|
||||
|
||||
```forth
|
||||
0.5 at kick s . ;; kick at the midpoint
|
||||
0.5 at kick snd . ;; kick at the midpoint
|
||||
```
|
||||
|
||||
Push multiple values before calling `at` to get multiple emits from a single `.`:
|
||||
|
||||
```forth
|
||||
0 0.5 at kick s . ;; two kicks: one at start, one at midpoint
|
||||
0 0.25 0.5 0.75 at hat s . ;; four hats, evenly spaced
|
||||
0 0.5 at kick snd .
|
||||
```
|
||||
|
||||
Two kicks: one at start, one at midpoint.
|
||||
|
||||
```forth
|
||||
0 0.25 0.5 0.75 at hat snd .
|
||||
```
|
||||
|
||||
Four hats, evenly spaced.
|
||||
|
||||
The deltas persist across multiple `.` calls until `clear` or a new `at`:
|
||||
|
||||
```forth
|
||||
0 0.5 at
|
||||
kick s . ;; 2 kicks
|
||||
hat s . ;; 2 hats (same timing)
|
||||
kick snd . ;; 2 kicks
|
||||
hat snd . ;; 2 hats (same timing)
|
||||
clear
|
||||
snare s . ;; 1 snare (deltas cleared)
|
||||
snare snd . ;; 1 snare (deltas cleared)
|
||||
```
|
||||
|
||||
## Cross-product: at Without arp
|
||||
@@ -33,10 +40,10 @@ Without `arp`, deltas multiply with polyphonic voices. If you have 3 notes and 2
|
||||
|
||||
```forth
|
||||
0 0.5 at
|
||||
c4 e4 g4 note sine s . ;; 6 emits: 3 notes x 2 deltas
|
||||
c4 e4 g4 note 1.5 decay sine snd .
|
||||
```
|
||||
|
||||
This is a chord played twice per step.
|
||||
6 emits: 3 notes x 2 deltas. A chord played twice per step.
|
||||
|
||||
## 1:1 Pairing: at With arp
|
||||
|
||||
@@ -44,16 +51,20 @@ This is a chord played twice per step.
|
||||
|
||||
```forth
|
||||
0 0.33 0.66 at
|
||||
c4 e4 g4 arp note sine s . ;; c4 at 0, e4 at 0.33, g4 at 0.66
|
||||
c4 e4 g4 arp note 0.5 decay sine snd .
|
||||
```
|
||||
|
||||
C4 at 0, E4 at 0.33, G4 at 0.66.
|
||||
|
||||
If the lists differ in length, the shorter one wraps around:
|
||||
|
||||
```forth
|
||||
0 0.25 0.5 0.75 at
|
||||
c4 e4 arp note sine s . ;; c4, e4, c4, e4 at 4 time points
|
||||
c4 e4 arp note 0.3 decay sine snd .
|
||||
```
|
||||
|
||||
C4, E4, C4, E4 — the shorter list wraps to fill 4 time points.
|
||||
|
||||
This is THE key distinction. Without `arp`: every note at every time. With `arp`: one note per time slot.
|
||||
|
||||
## Generating Deltas
|
||||
@@ -63,25 +74,25 @@ You rarely type deltas by hand. Use generators:
|
||||
Evenly spaced via `.,`:
|
||||
|
||||
```forth
|
||||
0 1 0.25 ., at hat s . ;; 0 0.25 0.5 0.75 1.0
|
||||
0 1 0.25 ., at hat snd . ;; 0 0.25 0.5 0.75 1.0
|
||||
```
|
||||
|
||||
Euclidean distribution via `euclid`:
|
||||
|
||||
```forth
|
||||
3 8 euclid at hat s . ;; 3 hats at positions 0, 3, 5
|
||||
3 8 euclid at hat snd . ;; 3 hats at positions 0, 3, 5
|
||||
```
|
||||
|
||||
Random timing via `gen`:
|
||||
|
||||
```forth
|
||||
{ 0.0 1.0 rand } 4 gen at hat s . ;; 4 hats at random positions
|
||||
( 0.0 1.0 rand ) 4 gen at hat snd . ;; 4 hats at random positions
|
||||
```
|
||||
|
||||
Geometric spacing via `geom..`:
|
||||
|
||||
```forth
|
||||
0.0 2.0 4 geom.. at hat s . ;; exponentially spaced
|
||||
0.0 2.0 4 geom.. at hat snd . ;; exponentially spaced
|
||||
```
|
||||
|
||||
## Gating at
|
||||
@@ -89,12 +100,18 @@ Geometric spacing via `geom..`:
|
||||
Wrap `at` expressions in quotations for conditional timing:
|
||||
|
||||
```forth
|
||||
{ 0 0.25 0.5 0.75 at } 2 every ;; 16th-note hats every other bar
|
||||
hat s .
|
||||
|
||||
{ 0 0.5 at } 0.5 chance ;; 50% chance of double-hit
|
||||
kick s .
|
||||
( 0 0.25 0.5 0.75 at ) 2 every
|
||||
hat snd .
|
||||
```
|
||||
|
||||
16th-note hats every other bar.
|
||||
|
||||
```forth
|
||||
( 0 0.5 at ) 0.5 chance
|
||||
kick snd .
|
||||
```
|
||||
|
||||
50% chance of double-hit.
|
||||
|
||||
When the quotation doesn't execute, no deltas are set -- you get the default single emit at beat start.
|
||||
|
||||
|
||||
@@ -40,15 +40,15 @@ That gives you 110, 220, 440, 880, 1760 (reversed), ready to feed into `freq`.
|
||||
`gen` executes a quotation n times and collects all results. The quotation must push exactly one value per call:
|
||||
|
||||
```forth
|
||||
{ 1 6 rand } 4 gen ;; 4 random values between 1 and 6
|
||||
{ coin } 8 gen ;; 8 random 0s and 1s
|
||||
( 1 6 rand ) 4 gen ;; 4 random values between 1 and 6
|
||||
( coin ) 8 gen ;; 8 random 0s and 1s
|
||||
```
|
||||
|
||||
Contrast with `times`, which executes for side effects and does not collect. `times` sets `@i` to the current index:
|
||||
|
||||
```forth
|
||||
4 { @i } times ;; 0 1 2 3 (pushes @i each iteration)
|
||||
4 { @i 60 + note sine s . } times ;; plays 4 notes, collects nothing
|
||||
4 ( @i ) times ;; 0 1 2 3 (pushes @i each iteration)
|
||||
4 ( @i 60 + note sine snd . ) times ;; plays 4 notes, collects nothing
|
||||
```
|
||||
|
||||
The distinction: `gen` is for building data. `times` is for doing things.
|
||||
@@ -109,7 +109,7 @@ c4 e4 g4 b4 4 shuffle ;; random permutation each time
|
||||
Useful for computing averages or accumulating values:
|
||||
|
||||
```forth
|
||||
{ 1 6 rand } 4 gen 4 sum ;; sum of 4 dice rolls
|
||||
( 1 6 rand ) 4 gen 4 sum ;; sum of 4 dice rolls
|
||||
```
|
||||
|
||||
## Replication
|
||||
@@ -124,9 +124,9 @@ c4 4 dupn ;; c4 c4 c4 c4
|
||||
Build a drone chord -- same note, different octaves:
|
||||
|
||||
```forth
|
||||
c3 note 0.5 gain sine s .
|
||||
c3 note 12 + 0.5 gain sine s .
|
||||
c3 note 24 + 0.3 gain sine s .
|
||||
c3 note 0.5 gain sine snd .
|
||||
c3 note 12 + 0.5 gain sine snd .
|
||||
c3 note 24 + 0.3 gain sine snd .
|
||||
```
|
||||
|
||||
Or replicate a value for batch processing:
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
# Notes & Harmony
|
||||
|
||||
Cagire speaks music theory. Notes, intervals, chords, and scales are all first-class words that compile to stack operations on MIDI values. This tutorial covers every pitch-related feature.
|
||||
This tutorial covers everything pitch-related: notes, intervals, chords, voicings, transposition, scales, and diatonic harmony. Each section builds on the previous one.
|
||||
|
||||
## MIDI Notes
|
||||
## Notes
|
||||
|
||||
Write a note name followed by an octave number. It compiles to a MIDI integer:
|
||||
A note name followed by an octave number compiles to a MIDI integer:
|
||||
|
||||
```forth
|
||||
c4 ;; 60 (middle C)
|
||||
a4 ;; 69 (concert A)
|
||||
e3 ;; 52
|
||||
c4 note sine snd .
|
||||
```
|
||||
|
||||
Sharps use `s` or `#`. Flats use `b`:
|
||||
That plays middle C (MIDI 60). `a4` is concert A (69), `e3` is 52. Sharps use `s` or `#`, flats use `b`:
|
||||
|
||||
```forth
|
||||
fs4 ;; 66 (F sharp 4)
|
||||
f#4 ;; 66 (same thing)
|
||||
bb3 ;; 58 (B flat 3)
|
||||
eb4 ;; 63
|
||||
fs4 note 0.5 decay saw snd .
|
||||
```
|
||||
|
||||
Octave range is -1 to 9. The formula is `(octave + 1) * 12 + base + modifier`, where C=0, D=2, E=4, F=5, G=7, A=9, B=11.
|
||||
|
||||
Note literals push a single integer onto the stack, just like writing `60` directly. They work everywhere an integer works:
|
||||
|
||||
```forth
|
||||
c4 note sine s . ;; play middle C as a sine
|
||||
a4 note 0.5 gain modal s . ;; concert A, quieter
|
||||
eb4 note 0.8 decay tri snd .
|
||||
```
|
||||
|
||||
`fs4` and `f#4` both mean F sharp 4 (MIDI 66). `bb3` is B flat 3 (58). Octave range is -1 to 9.
|
||||
|
||||
Notes are just integers. They work anywhere an integer works — you can do arithmetic on them, store them in variables, pass them to any word that expects a number.
|
||||
|
||||
## Intervals
|
||||
|
||||
An interval duplicates the top of the stack and adds semitones. This lets you build chords by stacking:
|
||||
An interval duplicates the top of the stack and adds semitones. Stack two intervals to build a chord by hand:
|
||||
|
||||
```forth
|
||||
c4 M3 P5 ;; stack: 60 64 67 (C major triad)
|
||||
c4 m3 P5 ;; stack: 60 63 67 (C minor triad)
|
||||
a3 P5 ;; stack: 57 64 (A plus a fifth)
|
||||
c4 M3 P5 note 1.5 decay sine snd .
|
||||
```
|
||||
|
||||
Simple intervals (within one octave):
|
||||
That builds a C major triad from scratch: C4 (60), then a major third above (64), then a perfect fifth above the root (67). Three notes on the stack, all played together.
|
||||
|
||||
```forth
|
||||
a3 m3 P5 note 1.2 decay va snd .
|
||||
```
|
||||
|
||||
A minor triad: A3, C4, E4.
|
||||
|
||||
**Simple intervals** (within one octave):
|
||||
|
||||
| Interval | Semitones | Name |
|
||||
|----------|-----------|------|
|
||||
@@ -58,7 +58,7 @@ Simple intervals (within one octave):
|
||||
| `M7` | 11 | Major 7th |
|
||||
| `P8` | 12 | Octave |
|
||||
|
||||
Compound intervals (beyond one octave):
|
||||
**Compound intervals** (beyond one octave):
|
||||
|
||||
| Interval | Semitones |
|
||||
|----------|-----------|
|
||||
@@ -75,108 +75,333 @@ Compound intervals (beyond one octave):
|
||||
| `M14` | 23 |
|
||||
| `P15` | 24 |
|
||||
|
||||
## Chords
|
||||
|
||||
Chord words take a root note and push all the chord tones. They eat the root and replace it with the full voicing:
|
||||
Custom voicings with wide intervals:
|
||||
|
||||
```forth
|
||||
c4 maj ;; stack: 60 64 67
|
||||
c4 min7 ;; stack: 60 63 67 70
|
||||
c4 dom9 ;; stack: 60 64 67 70 74
|
||||
c3 P5 P8 M10 note 1.5 decay sine snd .
|
||||
```
|
||||
|
||||
**Triads:**
|
||||
C3, G3, C4, E4 — an open-voiced C major spread across two octaves.
|
||||
|
||||
| Word | Intervals | Example (C4) |
|
||||
|------|-----------|-------------|
|
||||
| `maj` | 0 4 7 | 60 64 67 |
|
||||
| `m` | 0 3 7 | 60 63 67 |
|
||||
| `dim` | 0 3 6 | 60 63 66 |
|
||||
| `aug` | 0 4 8 | 60 64 68 |
|
||||
| `sus2` | 0 2 7 | 60 62 67 |
|
||||
| `sus4` | 0 5 7 | 60 65 67 |
|
||||
## Chords
|
||||
|
||||
**Seventh chords:**
|
||||
|
||||
| Word | Intervals | Example (C4) |
|
||||
|------|-----------|-------------|
|
||||
| `maj7` | 0 4 7 11 | 60 64 67 71 |
|
||||
| `min7` | 0 3 7 10 | 60 63 67 70 |
|
||||
| `dom7` | 0 4 7 10 | 60 64 67 70 |
|
||||
| `dim7` | 0 3 6 9 | 60 63 66 69 |
|
||||
| `m7b5` | 0 3 6 10 | 60 63 66 70 |
|
||||
| `minmaj7` | 0 3 7 11 | 60 63 67 71 |
|
||||
| `aug7` | 0 4 8 10 | 60 64 68 70 |
|
||||
|
||||
**Sixth chords:**
|
||||
|
||||
| Word | Intervals | Example (C4) |
|
||||
|------|-----------|-------------|
|
||||
| `maj6` | 0 4 7 9 | 60 64 67 69 |
|
||||
| `min6` | 0 3 7 9 | 60 63 67 69 |
|
||||
|
||||
**Extended chords:**
|
||||
|
||||
| Word | Intervals | Example (C4) |
|
||||
|------|-----------|-------------|
|
||||
| `dom9` | 0 4 7 10 14 | 60 64 67 70 74 |
|
||||
| `maj9` | 0 4 7 11 14 | 60 64 67 71 74 |
|
||||
| `min9` | 0 3 7 10 14 | 60 63 67 70 74 |
|
||||
| `dom11` | 0 4 7 10 14 17 | 60 64 67 70 74 77 |
|
||||
| `min11` | 0 3 7 10 14 17 | 60 63 67 70 74 77 |
|
||||
| `dom13` | 0 4 7 10 14 21 | 60 64 67 70 74 81 |
|
||||
|
||||
**Add chords:**
|
||||
|
||||
| Word | Intervals | Example (C4) |
|
||||
|------|-----------|-------------|
|
||||
| `add9` | 0 4 7 14 | 60 64 67 74 |
|
||||
| `add11` | 0 4 7 17 | 60 64 67 77 |
|
||||
| `madd9` | 0 3 7 14 | 60 63 67 74 |
|
||||
|
||||
**Altered dominants:**
|
||||
|
||||
| Word | Intervals | Example (C4) |
|
||||
|------|-----------|-------------|
|
||||
| `dom7b9` | 0 4 7 10 13 | 60 64 67 70 73 |
|
||||
| `dom7s9` | 0 4 7 10 15 | 60 64 67 70 75 |
|
||||
| `dom7b5` | 0 4 6 10 | 60 64 66 70 |
|
||||
| `dom7s5` | 0 4 8 10 | 60 64 68 70 |
|
||||
|
||||
Chord tones are varargs -- they eat the entire stack. So a chord word should come right after the root note:
|
||||
Chord words replace a root note with all the chord tones. They're shortcuts for what intervals do manually:
|
||||
|
||||
```forth
|
||||
c4 maj note sine s . ;; plays all 3 notes as one chord
|
||||
c4 maj note 1.5 decay sine snd .
|
||||
```
|
||||
|
||||
That's the same C major triad, but in one word instead of `M3 P5`. A few more:
|
||||
|
||||
```forth
|
||||
d3 min7 note 1.5 decay va snd .
|
||||
```
|
||||
|
||||
```forth
|
||||
e3 dom9 note 1.2 decay saw snd .
|
||||
```
|
||||
|
||||
```forth
|
||||
a3 sus2 note 1.5 decay tri snd .
|
||||
```
|
||||
|
||||
Common triads:
|
||||
|
||||
| Word | Intervals |
|
||||
|------|-----------|
|
||||
| `maj` | 0 4 7 |
|
||||
| `m` | 0 3 7 |
|
||||
| `dim` | 0 3 6 |
|
||||
| `aug` | 0 4 8 |
|
||||
| `sus2` | 0 2 7 |
|
||||
| `sus4` | 0 5 7 |
|
||||
| `pwr` | 0 7 |
|
||||
|
||||
Common seventh chords:
|
||||
|
||||
| Word | Intervals |
|
||||
|------|-----------|
|
||||
| `maj7` | 0 4 7 11 |
|
||||
| `min7` | 0 3 7 10 |
|
||||
| `dom7` | 0 4 7 10 |
|
||||
| `dim7` | 0 3 6 9 |
|
||||
| `m7b5` | 0 3 6 10 |
|
||||
| `minmaj7` | 0 3 7 11 |
|
||||
| `aug7` | 0 4 8 10 |
|
||||
| `augmaj7` | 0 4 8 11 |
|
||||
| `7sus4` | 0 5 7 10 |
|
||||
|
||||
Extended, add, altered, and other chord types are listed in the Reference section at the end.
|
||||
|
||||
## Voicings
|
||||
|
||||
Four words reshape chord voicings without changing the harmony.
|
||||
|
||||
`inv` moves the bottom note up an octave (inversion):
|
||||
|
||||
```forth
|
||||
c4 maj inv note 1.5 decay sine snd .
|
||||
```
|
||||
|
||||
The root C goes up, giving E4 G4 C5 — first inversion. Apply it twice for second inversion:
|
||||
|
||||
```forth
|
||||
c4 maj inv inv note 1.5 decay sine snd .
|
||||
```
|
||||
|
||||
G4 C5 E5. `dinv` does the opposite — moves the top note down an octave:
|
||||
|
||||
```forth
|
||||
c4 maj dinv note 1.5 decay sine snd .
|
||||
```
|
||||
|
||||
G3 C4 E4. The fifth drops below the root.
|
||||
|
||||
`drop2` and `drop3` are jazz voicing techniques for four-note chords. `drop2` takes the second-from-top note and drops it an octave:
|
||||
|
||||
```forth
|
||||
c4 maj7 drop2 note 1.2 decay va snd .
|
||||
```
|
||||
|
||||
From C4 E4 G4 B4, the G drops to G3: G3 C4 E4 B4. `drop3` drops the third-from-top:
|
||||
|
||||
```forth
|
||||
c4 maj7 drop3 note 1.2 decay va snd .
|
||||
```
|
||||
|
||||
E drops to E3: E3 C4 G4 B4. These create wider, more open voicings common in jazz guitar and piano.
|
||||
|
||||
## Transposition
|
||||
|
||||
`tp` shifts every note on the stack by N semitones:
|
||||
|
||||
```forth
|
||||
c4 maj 3 tp note 1.5 decay sine snd .
|
||||
```
|
||||
|
||||
C major transposed up 3 semitones becomes Eb major. Works with any number of notes:
|
||||
|
||||
```forth
|
||||
c4 min7 -2 tp note 1.5 decay va snd .
|
||||
```
|
||||
|
||||
Shifts the whole chord down 2 semitones (Bb minor 7).
|
||||
|
||||
`oct` shifts a single note by octaves:
|
||||
|
||||
```forth
|
||||
c4 1 oct note 0.3 decay sine snd .
|
||||
```
|
||||
|
||||
C5 (one octave up). Useful for bass lines:
|
||||
|
||||
```forth
|
||||
0 2 4 5 7 5 4 2 8 cycle minor note
|
||||
-2 oct 0.8 gain sine snd .
|
||||
```
|
||||
|
||||
## Scales
|
||||
|
||||
Scale words convert a degree index into a MIDI note. The base note is C4 (MIDI 60). Degrees wrap around with octave transposition:
|
||||
Scale words convert a degree index into a MIDI note. By default the root is C4 (MIDI 60):
|
||||
|
||||
```forth
|
||||
0 major ;; 60 (C4 -- degree 0)
|
||||
4 major ;; 67 (G4 -- degree 4)
|
||||
7 major ;; 72 (C5 -- degree 7, wraps to next octave)
|
||||
-1 major ;; 59 (B3 -- negative degrees go down)
|
||||
0 major note 0.5 decay sine snd .
|
||||
```
|
||||
|
||||
Use scales with `cycle` or `rand` to walk through pitches:
|
||||
Degree 0 of the major scale: C4. Degrees wrap with octave transposition — degree 7 gives C5 (72), degree -1 gives B3 (59).
|
||||
|
||||
Walk through a scale with `cycle`:
|
||||
|
||||
```forth
|
||||
0 1 2 3 4 5 6 7 8 cycle minor note sine s .
|
||||
0 1 2 3 4 5 6 7 8 cycle minor note 0.5 decay sine snd .
|
||||
```
|
||||
|
||||
**Standard modes:**
|
||||
Random notes from a scale:
|
||||
|
||||
| Word | Pattern (semitones) |
|
||||
|------|-------------------|
|
||||
```forth
|
||||
0 7 rand pentatonic note 0.8 decay va snd .
|
||||
```
|
||||
|
||||
### Setting the key
|
||||
|
||||
By default scales are rooted at C4. Use `key!` to change the tonal center:
|
||||
|
||||
```forth
|
||||
g3 key! 0 major note 0.5 decay sine snd .
|
||||
```
|
||||
|
||||
Now degree 0 is G3 (55) instead of C4. The key persists across steps until changed again:
|
||||
|
||||
```forth
|
||||
a3 key! 0 3 5 7 3 cycle minor note 0.8 decay tri snd .
|
||||
```
|
||||
|
||||
A minor melody starting from A3.
|
||||
|
||||
**Common modes:**
|
||||
|
||||
| Word | Pattern |
|
||||
|------|---------|
|
||||
| `major` | 0 2 4 5 7 9 11 |
|
||||
| `minor` | 0 2 3 5 7 8 10 |
|
||||
| `dorian` | 0 2 3 5 7 9 10 |
|
||||
| `phrygian` | 0 1 3 5 7 8 10 |
|
||||
| `lydian` | 0 2 4 6 7 9 11 |
|
||||
| `mixolydian` | 0 2 4 5 7 9 10 |
|
||||
| `aeolian` | 0 2 3 5 7 8 10 |
|
||||
| `pentatonic` | 0 2 4 7 9 |
|
||||
| `minpent` | 0 3 5 7 10 |
|
||||
| `blues` | 0 3 5 6 7 10 |
|
||||
| `harmonicminor` | 0 2 3 5 7 8 11 |
|
||||
| `melodicminor` | 0 2 3 5 7 9 11 |
|
||||
|
||||
Jazz, symmetric, and modal variant scales are listed in the Reference section.
|
||||
|
||||
## Diatonic Harmony
|
||||
|
||||
`triad` and `seventh` build chords from scale degrees. Instead of specifying a chord type, you get whatever chord the scale produces at that degree:
|
||||
|
||||
```forth
|
||||
0 major triad note 1.5 decay sine snd .
|
||||
```
|
||||
|
||||
Degree 0 of the major scale, stacked in thirds: C E G — a major triad. The scale determines the chord quality automatically. Degree 1 gives D F A (minor), degree 4 gives G B D (major):
|
||||
|
||||
```forth
|
||||
4 major triad note 1.5 decay sine snd .
|
||||
```
|
||||
|
||||
`seventh` adds a fourth note:
|
||||
|
||||
```forth
|
||||
0 major seventh note 1.2 decay va snd .
|
||||
```
|
||||
|
||||
C E G B — Cmaj7. Degree 1 gives Dm7, degree 4 gives G7 (dominant). The diatonic context determines everything.
|
||||
|
||||
Combine with `key!` to play diatonic chords in any key:
|
||||
|
||||
```forth
|
||||
g3 key! 0 major triad note 1.5 decay sine snd .
|
||||
```
|
||||
|
||||
G major triad rooted at G3.
|
||||
|
||||
A I-vi-IV-V chord progression using `pcycle`:
|
||||
|
||||
```forth
|
||||
( 0 major seventh ) ( 5 major seventh )
|
||||
( 3 major seventh ) ( 4 major seventh ) 4 pcycle
|
||||
note 1.2 decay va snd .
|
||||
```
|
||||
|
||||
Combine with voicings for smoother voice leading:
|
||||
|
||||
```forth
|
||||
( 0 major seventh ) ( 5 major seventh inv )
|
||||
( 3 major seventh ) ( 4 major seventh drop2 ) 4 pcycle
|
||||
note 1.5 decay va snd .
|
||||
```
|
||||
|
||||
Arpeggiate diatonic chords using `arp` (see the *Timing with at* tutorial for details on `arp`):
|
||||
|
||||
```forth
|
||||
0 major seventh arp note 0.5 decay sine snd .
|
||||
```
|
||||
|
||||
## Frequency Conversion
|
||||
|
||||
`mtof` converts a MIDI note to frequency in Hz. `ftom` does the reverse:
|
||||
|
||||
```forth
|
||||
c4 mtof freq sine snd .
|
||||
```
|
||||
|
||||
Useful when a synth parameter expects Hz rather than MIDI.
|
||||
|
||||
## Reference
|
||||
|
||||
### All Chords
|
||||
|
||||
**Triads:**
|
||||
|
||||
| Word | Intervals |
|
||||
|------|-----------|
|
||||
| `maj` | 0 4 7 |
|
||||
| `m` | 0 3 7 |
|
||||
| `dim` | 0 3 6 |
|
||||
| `aug` | 0 4 8 |
|
||||
| `sus2` | 0 2 7 |
|
||||
| `sus4` | 0 5 7 |
|
||||
| `pwr` | 0 7 |
|
||||
|
||||
**Seventh chords:**
|
||||
|
||||
| Word | Intervals |
|
||||
|------|-----------|
|
||||
| `maj7` | 0 4 7 11 |
|
||||
| `min7` | 0 3 7 10 |
|
||||
| `dom7` | 0 4 7 10 |
|
||||
| `dim7` | 0 3 6 9 |
|
||||
| `m7b5` | 0 3 6 10 |
|
||||
| `minmaj7` | 0 3 7 11 |
|
||||
| `aug7` | 0 4 8 10 |
|
||||
| `augmaj7` | 0 4 8 11 |
|
||||
| `7sus4` | 0 5 7 10 |
|
||||
|
||||
**Sixth chords:**
|
||||
|
||||
| Word | Intervals |
|
||||
|------|-----------|
|
||||
| `maj6` | 0 4 7 9 |
|
||||
| `min6` | 0 3 7 9 |
|
||||
| `maj69` | 0 4 7 9 14 |
|
||||
| `min69` | 0 3 7 9 14 |
|
||||
|
||||
**Extended chords:**
|
||||
|
||||
| Word | Intervals |
|
||||
|------|-----------|
|
||||
| `dom9` | 0 4 7 10 14 |
|
||||
| `maj9` | 0 4 7 11 14 |
|
||||
| `min9` | 0 3 7 10 14 |
|
||||
| `9sus4` | 0 5 7 10 14 |
|
||||
| `dom11` | 0 4 7 10 14 17 |
|
||||
| `maj11` | 0 4 7 11 14 17 |
|
||||
| `min11` | 0 3 7 10 14 17 |
|
||||
| `dom13` | 0 4 7 10 14 21 |
|
||||
| `maj13` | 0 4 7 11 14 21 |
|
||||
| `min13` | 0 3 7 10 14 21 |
|
||||
|
||||
**Add chords:**
|
||||
|
||||
| Word | Intervals |
|
||||
|------|-----------|
|
||||
| `add9` | 0 4 7 14 |
|
||||
| `add11` | 0 4 7 17 |
|
||||
| `madd9` | 0 3 7 14 |
|
||||
|
||||
**Altered dominants:**
|
||||
|
||||
| Word | Intervals |
|
||||
|------|-----------|
|
||||
| `dom7b9` | 0 4 7 10 13 |
|
||||
| `dom7s9` | 0 4 7 10 15 |
|
||||
| `dom7b5` | 0 4 6 10 |
|
||||
| `dom7s5` | 0 4 8 10 |
|
||||
| `dom7s11` | 0 4 7 10 18 |
|
||||
|
||||
### All Scales
|
||||
|
||||
**Modes:**
|
||||
|
||||
| Word | Pattern |
|
||||
|------|---------|
|
||||
| `major` | 0 2 4 5 7 9 11 |
|
||||
| `minor` / `aeolian` | 0 2 3 5 7 8 10 |
|
||||
| `dorian` | 0 2 3 5 7 9 10 |
|
||||
| `phrygian` | 0 1 3 5 7 8 10 |
|
||||
| `lydian` | 0 2 4 6 7 9 11 |
|
||||
| `mixolydian` | 0 2 4 5 7 9 10 |
|
||||
| `locrian` | 0 1 3 5 6 8 10 |
|
||||
|
||||
**Pentatonic and blues:**
|
||||
@@ -187,13 +412,6 @@ Use scales with `cycle` or `rand` to walk through pitches:
|
||||
| `minpent` | 0 3 5 7 10 |
|
||||
| `blues` | 0 3 5 6 7 10 |
|
||||
|
||||
**Chromatic and whole tone:**
|
||||
|
||||
| Word | Pattern |
|
||||
|------|---------|
|
||||
| `chromatic` | 0 1 2 3 4 5 6 7 8 9 10 11 |
|
||||
| `wholetone` | 0 2 4 6 8 10 |
|
||||
|
||||
**Harmonic and melodic minor:**
|
||||
|
||||
| Word | Pattern |
|
||||
@@ -201,6 +419,13 @@ Use scales with `cycle` or `rand` to walk through pitches:
|
||||
| `harmonicminor` | 0 2 3 5 7 8 11 |
|
||||
| `melodicminor` | 0 2 3 5 7 9 11 |
|
||||
|
||||
**Chromatic and whole tone:**
|
||||
|
||||
| Word | Pattern |
|
||||
|------|---------|
|
||||
| `chromatic` | 0 1 2 3 4 5 6 7 8 9 10 11 |
|
||||
| `wholetone` | 0 2 4 6 8 10 |
|
||||
|
||||
**Jazz / Bebop:**
|
||||
|
||||
| Word | Pattern |
|
||||
@@ -229,74 +454,3 @@ Use scales with `cycle` or `rand` to walk through pitches:
|
||||
| `lydianaug` | 0 2 4 6 8 9 11 |
|
||||
| `mixb6` | 0 2 4 5 7 8 10 |
|
||||
| `locrian2` | 0 2 3 5 6 8 10 |
|
||||
|
||||
## Octave Shifting
|
||||
|
||||
`oct` transposes a note by octaves:
|
||||
|
||||
```forth
|
||||
c4 1 oct ;; 72 (C5)
|
||||
c4 -1 oct ;; 48 (C3)
|
||||
c4 2 oct ;; 84 (C6)
|
||||
```
|
||||
|
||||
Stack effect: `(note shift -- transposed)`. The shift is multiplied by 12 and added to the note.
|
||||
|
||||
## Frequency Conversion
|
||||
|
||||
`mtof` converts a MIDI note to frequency in Hz. `ftom` does the reverse:
|
||||
|
||||
```forth
|
||||
69 mtof ;; 440.0 (A4)
|
||||
60 mtof ;; 261.63 (C4)
|
||||
440 ftom ;; 69.0
|
||||
```
|
||||
|
||||
Useful when a synth parameter expects Hz rather than MIDI:
|
||||
|
||||
```forth
|
||||
c4 mtof freq sine s .
|
||||
```
|
||||
|
||||
## Putting It Together
|
||||
|
||||
A chord progression cycling every pattern iteration:
|
||||
|
||||
```forth
|
||||
{ c3 maj7 } { f3 maj7 } { g3 dom7 } { c3 maj7 } 4 pcycle
|
||||
note sine s .
|
||||
```
|
||||
|
||||
Arpeggiate a chord across the step's time divisions:
|
||||
|
||||
```forth
|
||||
c4 min7 arp note 0.5 decay sine s .
|
||||
```
|
||||
|
||||
Random notes from a scale:
|
||||
|
||||
```forth
|
||||
0 7 rand minor note sine s .
|
||||
```
|
||||
|
||||
A bass line walking scale degrees:
|
||||
|
||||
```forth
|
||||
0 2 4 5 7 5 4 2 8 cycle minor note
|
||||
-2 oct 0.8 gain sine s .
|
||||
```
|
||||
|
||||
Chord voicings with random inversion:
|
||||
|
||||
```forth
|
||||
e3 min9
|
||||
{ } { 1 oct } 2 choose
|
||||
note modal s .
|
||||
```
|
||||
|
||||
Stacked intervals for custom voicings:
|
||||
|
||||
```forth
|
||||
c3 P5 P8 M10 ;; C3, G3, C4, E4
|
||||
note sine s .
|
||||
```
|
||||
43
docs/tutorials/periodic_script.md
Normal file
43
docs/tutorials/periodic_script.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# The Periodic Script
|
||||
|
||||
The periodic script is a hidden seventh view accessible with `F11`. It is a Forth script that runs continuously alongside your patterns, evaluated at every step like a pattern would be. Think of it as a free-running pattern with no grid — just code.
|
||||
|
||||
## What is it for?
|
||||
|
||||
The periodic script is useful for things that don't belong to any specific pattern:
|
||||
|
||||
- **Global effects**: apply a filter sweep or reverb tail across everything.
|
||||
- **Drones**: run a sustained sound that keeps going regardless of which patterns are playing.
|
||||
- **Control logic**: update variables, send MIDI clock, or modulate global parameters.
|
||||
- **Experimentation**: sketch ideas without touching your pattern grid.
|
||||
|
||||
## Opening the Script
|
||||
|
||||
Press `F11` from any view. The script page appears with an editor on the left and visualizations on the right (scope, spectrum, prelude preview). The script is saved with your project.
|
||||
|
||||
## Editing
|
||||
|
||||
Press `Enter` to focus the editor. Write Forth code as you would in any step. Press `Esc` to unfocus and save. Press `Ctrl+E` to evaluate without unfocusing.
|
||||
|
||||
```forth
|
||||
;; a simple drone
|
||||
saw snd c2 note 0.3 gain 0.4 verb .
|
||||
```
|
||||
|
||||
## Speed and Length
|
||||
|
||||
The periodic script has its own speed and length settings, independent of any pattern. Press `S` (unfocused) to set the speed and `L` to set the length (1-256 steps). Speed and length are displayed in the editor title bar.
|
||||
|
||||
The script loops over its length just like a pattern. Context words like `step`, `iter`, and `phase` work as expected, counting within the script's own cycle.
|
||||
|
||||
## Keybindings
|
||||
|
||||
| Key | Action |
|
||||
|-----|--------|
|
||||
| `F11` | Open periodic script view |
|
||||
| `Enter` | Focus editor |
|
||||
| `Esc` | Unfocus and save |
|
||||
| `Ctrl+E` | Evaluate |
|
||||
| `Ctrl+S` | Toggle stack display |
|
||||
| `S` | Set speed (unfocused) |
|
||||
| `L` | Set length (unfocused) |
|
||||
@@ -7,21 +7,25 @@ Music needs surprise. A pattern that plays identically every time gets boring fa
|
||||
`coin` pushes 0 or 1 with equal probability:
|
||||
|
||||
```forth
|
||||
coin note sine s . ;; either 0 or 1 as the note
|
||||
;; sometimes, reverb
|
||||
sine sound
|
||||
( 0.5 verb ) coin ?
|
||||
1 decay
|
||||
.
|
||||
```
|
||||
|
||||
`rand` takes a range and returns a random value. If both bounds are integers, the result is an integer. If either is a float, you get a float:
|
||||
|
||||
```forth
|
||||
60 72 rand note sine s . ;; random MIDI note from 60 to 72
|
||||
0.3 0.9 rand gain sine s . ;; random gain between 0.3 and 0.9
|
||||
60 72 rand note sine snd 0.5 decay . ;; random MIDI note from 60 to 72
|
||||
0.3 0.9 rand gain sine snd 0.5 decay . ;; random gain between 0.3 and 0.9
|
||||
```
|
||||
|
||||
`exprand` and `logrand` give you weighted distributions. `exprand` is biased toward the low end, `logrand` toward the high end:
|
||||
|
||||
```forth
|
||||
200.0 8000.0 exprand freq sine s . ;; mostly low frequencies
|
||||
200.0 8000.0 logrand freq sine s . ;; mostly high frequencies
|
||||
200.0 8000.0 exprand freq sine snd 0.5 decay . ;; mostly low frequencies
|
||||
200.0 8000.0 logrand freq sine snd 0.5 decay . ;; mostly high frequencies
|
||||
```
|
||||
|
||||
These are useful for parameters where perception is logarithmic, like frequency and duration.
|
||||
@@ -31,8 +35,8 @@ These are useful for parameters where perception is logarithmic, like frequency
|
||||
The probability words take a quotation and execute it with some chance. `chance` takes a float from 0.0 to 1.0, `prob` takes a percentage from 0 to 100:
|
||||
|
||||
```forth
|
||||
{ hat s . } 0.25 chance ;; 25% chance
|
||||
{ hat s . } 75 prob ;; 75% chance
|
||||
( hat snd . ) 0.25 chance ;; 25% chance
|
||||
( kick snd . ) 75 prob ;; 75% chance
|
||||
```
|
||||
|
||||
Named probability words save you from remembering numbers:
|
||||
@@ -48,9 +52,9 @@ Named probability words save you from remembering numbers:
|
||||
| `never` | 0% |
|
||||
|
||||
```forth
|
||||
{ hat s . } often ;; 75%
|
||||
{ snare s . } sometimes ;; 50%
|
||||
{ clap s . } rarely ;; 25%
|
||||
( hat snd . ) often ;; 75%
|
||||
( snare snd . ) sometimes ;; 50%
|
||||
( clap snd . ) rarely ;; 25%
|
||||
```
|
||||
|
||||
`always` and `never` are useful when you want to temporarily mute or unmute a voice without deleting code. Change `sometimes` to `never` to silence it, `always` to bring it back.
|
||||
@@ -58,8 +62,8 @@ Named probability words save you from remembering numbers:
|
||||
Use `?` and `!?` with `coin` for quick coin-flip decisions:
|
||||
|
||||
```forth
|
||||
{ hat s . } coin ? ;; execute if coin is 1
|
||||
{ rim s . } coin !? ;; execute if coin is 0
|
||||
( hat snd . ) coin ? ;; execute if coin is 1
|
||||
( rim snd . ) coin !? ;; execute if coin is 0
|
||||
```
|
||||
|
||||
## Selection
|
||||
@@ -67,21 +71,21 @@ Use `?` and `!?` with `coin` for quick coin-flip decisions:
|
||||
`choose` picks randomly from n items on the stack:
|
||||
|
||||
```forth
|
||||
kick snare hat 3 choose s . ;; random drum hit
|
||||
60 64 67 72 4 choose note sine s . ;; random note from a set
|
||||
kick snare hat 3 choose snd . ;; random drum hit
|
||||
60 64 67 72 4 choose note sine snd 0.5 decay . ;; random note from a set
|
||||
```
|
||||
|
||||
When a chosen item is a quotation, it gets executed:
|
||||
|
||||
```forth
|
||||
{ 0.1 decay } { 0.5 decay } { 0.9 decay } 3 choose
|
||||
sine s .
|
||||
( 0.1 decay ) ( 0.5 decay ) ( 0.9 decay ) 3 choose
|
||||
sine snd .
|
||||
```
|
||||
|
||||
`wchoose` lets you assign weights to each option. Push value/weight pairs:
|
||||
|
||||
```forth
|
||||
kick 0.5 snare 0.3 hat 0.2 3 wchoose s .
|
||||
kick 0.5 snare 0.3 hat 0.2 3 wchoose snd .
|
||||
```
|
||||
|
||||
Kick plays 50% of the time, snare 30%, hat 20%. Weights don't need to sum to 1 -- they're normalized automatically.
|
||||
@@ -94,56 +98,39 @@ Kick plays 50% of the time, snare 30%, hat 20%. Weights don't need to sum to 1 -
|
||||
|
||||
Combined with `note`, this gives you a random permutation of a chord every time the step runs.
|
||||
|
||||
## Cycling
|
||||
|
||||
Cycling steps through values deterministically. No randomness -- pure rotation.
|
||||
|
||||
`cycle` selects based on how many times this step has played (its `runs` count):
|
||||
|
||||
```forth
|
||||
60 64 67 3 cycle note sine s . ;; 60, 64, 67, 60, 64, 67, ...
|
||||
```
|
||||
|
||||
`pcycle` selects based on the pattern iteration count (`iter`):
|
||||
|
||||
```forth
|
||||
kick snare 2 pcycle s . ;; kick on even iterations, snare on odd
|
||||
```
|
||||
|
||||
The difference matters when patterns have different lengths. `cycle` counts per-step, `pcycle` counts per-pattern.
|
||||
|
||||
Quotations work here too:
|
||||
|
||||
```forth
|
||||
{ c4 note } { e4 note } { g4 note } 3 cycle
|
||||
sine s .
|
||||
```
|
||||
|
||||
`bounce` ping-pongs instead of wrapping around:
|
||||
|
||||
```forth
|
||||
60 64 67 72 4 bounce note sine s . ;; 60, 64, 67, 72, 67, 64, 60, 64, ...
|
||||
```
|
||||
|
||||
## Periodic Execution
|
||||
|
||||
`every` runs a quotation once every n pattern iterations:
|
||||
|
||||
```forth
|
||||
{ crash s . } 4 every ;; crash cymbal every 4th iteration
|
||||
( crash snd . ) 4 every ;; crash cymbal every 4th iteration
|
||||
```
|
||||
|
||||
`except` is the inverse -- it runs a quotation on all iterations *except* every nth:
|
||||
|
||||
```forth
|
||||
{ 2 distort } 4 except ;; distort on all iterations except every 4th
|
||||
( 2 distort ) 4 except ;; distort on all iterations except every 4th
|
||||
```
|
||||
|
||||
`every+` and `except+` take an extra offset argument to shift the phase:
|
||||
|
||||
```forth
|
||||
( snare snd . ) 4 2 every+ ;; fires at iter 2, 6, 10, 14...
|
||||
( snare snd . ) 4 2 except+ ;; skips at iter 2, 6, 10, 14...
|
||||
```
|
||||
|
||||
Without the offset, `every` fires at 0, 4, 8... The offset shifts that by 2, so it fires at 2, 6, 10... This lets you interleave patterns that share the same period:
|
||||
|
||||
```forth
|
||||
( kick snd . ) 4 every ;; kick at 0, 4, 8...
|
||||
( snare snd . ) 4 2 every+ ;; snare at 2, 6, 10...
|
||||
```
|
||||
|
||||
`bjork` and `pbjork` use Bjorklund's algorithm to distribute k hits across n positions as evenly as possible. Classic Euclidean rhythms:
|
||||
|
||||
```forth
|
||||
{ hat s . } 3 8 bjork ;; tresillo: x..x..x. (by step runs)
|
||||
{ hat s . } 5 8 pbjork ;; cinquillo: x.xx.xx. (by pattern iterations)
|
||||
( hat snd . ) 3 8 bjork ;; tresillo: x..x..x. (by step runs)
|
||||
( hat snd . ) 5 8 pbjork ;; cinquillo: x.xx.xx. (by pattern iterations)
|
||||
```
|
||||
|
||||
`bjork` counts by step runs (how many times this particular step has played). `pbjork` counts by pattern iterations. Some classic patterns:
|
||||
@@ -161,7 +148,7 @@ By default, every run produces different random values. Use `seed` to make rando
|
||||
|
||||
```forth
|
||||
42 seed
|
||||
60 72 rand note sine s . ;; always the same "random" note
|
||||
60 72 rand note sine snd . ;; always the same "random" note
|
||||
```
|
||||
|
||||
The seed is set at the start of the script. Same seed, same sequence. Useful when you want a specific random pattern to repeat.
|
||||
@@ -171,8 +158,8 @@ The seed is set at the start of the script. Same seed, same sequence. Useful whe
|
||||
The real power comes from mixing techniques. A hi-hat pattern with ghost notes:
|
||||
|
||||
```forth
|
||||
hat s
|
||||
{ 0.3 0.6 rand gain } { 0.8 gain } 2 cycle
|
||||
hat snd
|
||||
( 0.3 0.6 rand gain ) ( 0.8 gain ) 2 cycle
|
||||
.
|
||||
```
|
||||
|
||||
@@ -181,18 +168,18 @@ Full volume on even runs, random quiet on odd runs.
|
||||
A bass line that changes every 4 bars:
|
||||
|
||||
```forth
|
||||
{ c2 note } { e2 note } { g2 note } { a2 note } 4 pcycle
|
||||
{ 0.5 decay } often
|
||||
sine s .
|
||||
( c2 note ) ( e2 note ) ( g2 note ) ( a2 note ) 4 pcycle
|
||||
( 0.5 decay ) often
|
||||
sine snd .
|
||||
```
|
||||
|
||||
Layered percussion with different densities:
|
||||
|
||||
```forth
|
||||
{ kick s . } always
|
||||
{ snare s . } 2 every
|
||||
{ hat s . } 5 8 bjork
|
||||
{ rim s . } rarely
|
||||
( kick snd . ) always
|
||||
( snare snd . ) 2 every
|
||||
( hat snd . ) 5 8 bjork
|
||||
( rim snd . ) rarely
|
||||
```
|
||||
|
||||
A melodic step with weighted note selection and random timbre:
|
||||
@@ -201,7 +188,7 @@ A melodic step with weighted note selection and random timbre:
|
||||
c4 0.4 e4 0.3 g4 0.2 b4 0.1 4 wchoose note
|
||||
0.3 0.7 rand decay
|
||||
1.0 4.0 exprand harmonics
|
||||
modal s .
|
||||
modal snd .
|
||||
```
|
||||
|
||||
The root note plays most often. Higher chord tones are rarer. Decay and harmonics vary continuously.
|
||||
The root note plays most often. Higher chord tones are rarer. Decay and harmonics vary continuously.
|
||||
|
||||
@@ -19,7 +19,7 @@ Play something -- a pattern, a live input, anything that makes sound. When you'r
|
||||
The recording is now available as a sample:
|
||||
|
||||
```forth
|
||||
drums s .
|
||||
drums snd .
|
||||
```
|
||||
|
||||
## Playback
|
||||
@@ -27,10 +27,10 @@ drums s .
|
||||
Recorded samples are ordinary samples. Everything you can do with a loaded sample works here:
|
||||
|
||||
```forth
|
||||
drums s 0.5 speed . ;; half speed
|
||||
drums s 0.25 begin 0.5 end . ;; slice the middle quarter
|
||||
drums s 800 lpf 0.3 verb . ;; filter and reverb
|
||||
drums s -1 speed . ;; reverse
|
||||
drums snd 0.5 speed . ;; half speed
|
||||
drums snd 0.25 begin 0.5 end . ;; slice the middle quarter
|
||||
drums snd 800 lpf 0.3 verb . ;; filter and reverb
|
||||
drums snd -1 speed . ;; reverse
|
||||
```
|
||||
|
||||
## Overdub
|
||||
@@ -70,7 +70,7 @@ Record a foundation, then overdub to build up:
|
||||
"loop" dub
|
||||
|
||||
;; 4. play the result
|
||||
loop s .
|
||||
loop snd .
|
||||
```
|
||||
|
||||
Each overdub pass adds to what's already there. The buffer wraps, so longer passes layer cyclically over the original length.
|
||||
@@ -80,16 +80,16 @@ Each overdub pass adds to what's already there. The buffer wraps, so longer pass
|
||||
Once you have a recording, carve it up:
|
||||
|
||||
```forth
|
||||
loop s 0.0 begin 0.25 end . ;; first quarter
|
||||
loop s 0.25 begin 0.5 end . ;; second quarter
|
||||
loop s 0.5 begin 0.75 end . ;; third quarter
|
||||
loop s 0.75 begin 1.0 end . ;; last quarter
|
||||
loop snd 0.0 begin 0.25 end . ;; first quarter
|
||||
loop snd 0.25 begin 0.5 end . ;; second quarter
|
||||
loop snd 0.5 begin 0.75 end . ;; third quarter
|
||||
loop snd 0.75 begin 1.0 end . ;; last quarter
|
||||
```
|
||||
|
||||
Combine with randomness for variation:
|
||||
|
||||
```forth
|
||||
loop s
|
||||
loop snd
|
||||
0.0 0.25 0.5 0.75 4 choose begin
|
||||
0.5 speed
|
||||
.
|
||||
|
||||
@@ -11,9 +11,9 @@ Drop an `.sf2` file into one of your samples directories. The engine finds and l
|
||||
Use `gm` as the sound source. The `n` parameter selects a program by name or number (0-127):
|
||||
|
||||
```forth
|
||||
gm s piano n . ;; acoustic piano
|
||||
gm s strings n c4 note . ;; strings playing middle C
|
||||
gm s 0 n e4 note . ;; program 0 (piano) playing E4
|
||||
gm snd piano n . ;; acoustic piano
|
||||
gm snd strings n c4 note . ;; strings playing middle C
|
||||
gm snd 0 n e4 note . ;; program 0 (piano) playing E4
|
||||
```
|
||||
|
||||
## Drums
|
||||
@@ -21,10 +21,10 @@ gm s 0 n e4 note . ;; program 0 (piano) playing E4
|
||||
Drums live on a separate bank. Use `drums` or `percussion` as the `n` value. Each MIDI note triggers a different instrument:
|
||||
|
||||
```forth
|
||||
gm s drums n 36 note . ;; kick
|
||||
gm s drums n 38 note . ;; snare
|
||||
gm s drums n 42 note . ;; closed hi-hat
|
||||
gm s percussion n 49 note . ;; crash cymbal
|
||||
gm snd drums n 36 note . ;; kick
|
||||
gm snd drums n 38 note . ;; snare
|
||||
gm snd drums n 42 note . ;; closed hi-hat
|
||||
gm snd percussion n 49 note . ;; crash cymbal
|
||||
```
|
||||
|
||||
## Envelope
|
||||
@@ -32,8 +32,8 @@ gm s percussion n 49 note . ;; crash cymbal
|
||||
The soundfont embeds ADSR envelope data per preset. The engine applies it automatically. Override any parameter explicitly:
|
||||
|
||||
```forth
|
||||
gm s piano n 0.01 attack 0.3 decay .
|
||||
gm s strings n 0.5 attack 2.0 release .
|
||||
gm snd piano n 0.01 attack 0.3 decay .
|
||||
gm snd strings n 0.5 attack 2.0 release .
|
||||
```
|
||||
|
||||
If you set `attack`, `decay`, `sustain`, or `release`, your value wins. Unspecified parameters keep the soundfont default.
|
||||
@@ -43,9 +43,9 @@ If you set `attack`, `decay`, `sustain`, or `release`, your value wins. Unspecif
|
||||
All standard engine parameters work on GM voices. Filter, distort, spatialize:
|
||||
|
||||
```forth
|
||||
gm s bass n 800 lpf 0.3 verb .
|
||||
gm s epiano n 0.5 delay 1.5 distort .
|
||||
gm s choir n 0.8 pan 2000 hpf .
|
||||
gm snd bass n 800 lpf 0.3 verb .
|
||||
gm snd epiano n 0.5 delay 1.5 distort .
|
||||
gm snd choir n 0.8 pan 2000 hpf .
|
||||
```
|
||||
|
||||
## Preset Names
|
||||
@@ -79,22 +79,22 @@ A simple GM drum pattern across four steps:
|
||||
|
||||
```forth
|
||||
;; step 1: kick
|
||||
gm s drums n 36 note .
|
||||
gm snd drums n 36 note .
|
||||
|
||||
;; step 2: closed hat
|
||||
gm s drums n 42 note 0.6 gain .
|
||||
gm snd drums n 42 note 0.6 gain .
|
||||
|
||||
;; step 3: snare
|
||||
gm s drums n 38 note .
|
||||
gm snd drums n 38 note .
|
||||
|
||||
;; step 4: closed hat
|
||||
gm s drums n 42 note 0.6 gain .
|
||||
gm snd drums n 42 note 0.6 gain .
|
||||
```
|
||||
|
||||
Layer piano chords with randomness:
|
||||
|
||||
```forth
|
||||
gm s piano n
|
||||
gm snd piano n
|
||||
c4 e4 g4 3 choose note
|
||||
0.3 0.8 rand gain
|
||||
0.1 0.4 rand verb
|
||||
@@ -104,7 +104,7 @@ c4 e4 g4 3 choose note
|
||||
A bass line with envelope override:
|
||||
|
||||
```forth
|
||||
gm s bass n
|
||||
gm snd bass n
|
||||
c2 e2 g2 a2 4 cycle note
|
||||
0.01 attack 0.2 decay 0.0 sustain
|
||||
.
|
||||
|
||||
@@ -17,13 +17,13 @@ Variables let you name values and share data between steps. They are global -- a
|
||||
`,name` stores just like `!name` but keeps the value on the stack. Useful when you want to name something and keep using it:
|
||||
|
||||
```forth
|
||||
440 ,freq sine s . ;; stores 440 in freq AND passes it to the pipeline
|
||||
440 ,freq sine snd . ;; stores 440 in freq AND passes it to the pipeline
|
||||
```
|
||||
|
||||
Without `,`, you'd need `dup`:
|
||||
|
||||
```forth
|
||||
440 dup !freq sine s . ;; equivalent, but noisier
|
||||
440 dup !freq sine snd . ;; equivalent, but noisier
|
||||
```
|
||||
|
||||
## Sharing Between Steps
|
||||
@@ -35,7 +35,7 @@ Variables are shared across all steps. One step can store a value that another r
|
||||
c4 iter 7 mod + !root
|
||||
|
||||
;; step 4: read it
|
||||
@root 7 + note sine s .
|
||||
@root 7 + note sine snd .
|
||||
```
|
||||
|
||||
Every time the pattern loops, step 0 picks a new root. Step 4 always harmonizes with it.
|
||||
@@ -46,14 +46,14 @@ Fetch, modify, store back. A classic pattern for evolving values:
|
||||
|
||||
```forth
|
||||
@n 1 + !n ;; increment n each time this step runs
|
||||
@n 12 mod note sine s . ;; cycle through 12 notes
|
||||
@n 12 mod note sine snd . ;; cycle through 12 notes
|
||||
```
|
||||
|
||||
Reset on some condition:
|
||||
|
||||
```forth
|
||||
@n 1 + !n
|
||||
{ 0 !n } @n 16 > ? ;; reset after 16
|
||||
( 0 !n ) @n 16 > ? ;; reset after 16
|
||||
```
|
||||
|
||||
## When Changes Take Effect
|
||||
@@ -69,7 +69,7 @@ Store a sound name in a variable, reuse it across steps:
|
||||
"sine" !synth
|
||||
|
||||
;; step 1, 2, 3...
|
||||
c4 note @synth s .
|
||||
c4 note @synth snd .
|
||||
```
|
||||
|
||||
Change one step, all steps follow.
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
# Welcome to Cagire
|
||||
|
||||
Cagire is a live-codable step sequencer. Each sequencer step is defined by a **Forth** script that gets evaluated at the right time. **Forth** is a minimal, fun and rewarding programming language. It has almost no syntax but provides infinite fun. It rewards exploration, creativity and curiosity. This documentation is both a _tutorial_ and a _reference_. All the code examples in the documentation are interactive. **You can run them!** Use `n` and `p` (next/previous) to navigate through the examples. Press `Enter` to evaluate an example! Try to evaluate the following example using `n`, `p` and `Enter`:
|
||||
Cagire is a live-codable step sequencer. Each sequencer step is defined by a **Forth** script that gets evaluated at the right time. **Forth** is a minimal, fun and rewarding programming language. It has almost no syntax but provides infinite fun. It rewards exploration, creativity and curiosity.
|
||||
|
||||
This documentation is both a _tutorial_ and a _reference_. All the code examples in the documentation are interactive. **You can run them!** Use `n` and `p` (next/previous) to navigate through the examples. Press `Enter` to evaluate an example! Try to evaluate the following example using `n`, `p` and `Enter`:
|
||||
|
||||
```forth
|
||||
saw sound
|
||||
400 freq
|
||||
1 decay
|
||||
c4 note
|
||||
0.5 decay
|
||||
.
|
||||
```
|
||||
|
||||
## What is live coding?
|
||||
|
||||
Live coding is a technique where you write code in real-time to create audiovisual performances. Most often, it is practiced in front of an audience. Live coding is a way to experiment with code, to share things and thoughts openly, to think through code. It can be technical, poetic, weird, preferably all at once. Live coding can be used to create music, visual art, and other forms of media with a strong emphasis on _improvisation_. Learn more about live coding on [https://toplap.org](https://toplap.org) or [https://livecoding.fr](https://livecoding.fr). Live coding is an autotelic activity: the act of doing it is its own reward. There are no errors, only fun.
|
||||
Live coding is a technique where you write code in real-time to create audiovisual performances. Most often, it is practiced in front of an audience. Live coding is a way to experiment with code, to share things and thoughts openly, to think through code. It can be technical, poetic, weird, preferably all at once. Live coding can be used to create music, visual art, and other forms of media with a strong emphasis on _improvisation_. Learn more about live coding on [toplap.org](https://toplap.org) or [livecoding.fr](https://livecoding.fr). Live coding is an autotelic activity: the act of doing it is its own reward. There are no errors, only fun.
|
||||
|
||||
## About
|
||||
|
||||
Cagire is mainly developed by BuboBubo (Raphaël Maurice Forment, [https://raphaelforment.fr](https://raphaelforment.fr)). It is a free and open-source project licensed under the `AGPL-3.0 License`. You are free to contribute to the project by contributing to the codebase or by sharing feedback. Help and feedback are welcome!
|
||||
Cagire is mainly developed by BuboBubo (Raphaël Maurice Forment, [raphaelforment.fr](https://raphaelforment.fr)). It is a free and open-source project licensed under the `AGPL-3.0 License`. You are free to contribute to the project by contributing to the codebase or by sharing feedback. Help and feedback are welcome!
|
||||
|
||||
### Credits
|
||||
|
||||
* **Doux** (audio engine) is a Rust port of Dough, originally written in C by Felix Roos.
|
||||
* **mi-plaits-dsp-rs** is a Rust port of the code used by the Mutable Instruments Plaits.
|
||||
* **Author**: Oliver Rockstedt [info@sourcebox.de](info@sourcebox.de).
|
||||
* **Original author**: Emilie Gillet [emilie.o.gillet@gmail.com](emilie.o.gillet@gmail.com).
|
||||
* **mi-plaits-dsp-rs** is a Rust port of the code used by the Mutable Instruments Plaits (Emilie Gillet). Rust port by Oliver Rockstedt.
|
||||
|
||||
98
nsis/cagire.nsi
Normal file
98
nsis/cagire.nsi
Normal file
@@ -0,0 +1,98 @@
|
||||
; Cagire NSIS Installer Script
|
||||
; Receives defines from command line:
|
||||
; -DVERSION=x.y.z
|
||||
; -DCLI_EXE=/path/to/cagire.exe
|
||||
; -DDESKTOP_EXE=/path/to/cagire-desktop.exe
|
||||
; -DICON=/path/to/Cagire.ico
|
||||
; -DOUTDIR=/path/to/releases
|
||||
|
||||
!include "MUI2.nsh"
|
||||
!include "WordFunc.nsh"
|
||||
|
||||
Name "Cagire ${VERSION}"
|
||||
OutFile "${OUTDIR}\cagire-${VERSION}-windows-x86_64-setup.exe"
|
||||
InstallDir "$PROGRAMFILES64\Cagire"
|
||||
InstallDirRegKey HKLM "Software\Cagire" "InstallDir"
|
||||
RequestExecutionLevel admin
|
||||
Unicode True
|
||||
|
||||
!define MUI_ICON "${ICON}"
|
||||
!define MUI_UNICON "${ICON}"
|
||||
!define MUI_ABORTWARNING
|
||||
|
||||
!define MUI_HEADERIMAGE
|
||||
!define MUI_HEADERIMAGE_BITMAP "header.bmp"
|
||||
!define MUI_WELCOMEFINISHPAGE_BITMAP "sidebar.bmp"
|
||||
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "sidebar.bmp"
|
||||
|
||||
!insertmacro MUI_PAGE_WELCOME
|
||||
!insertmacro MUI_PAGE_COMPONENTS
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
!insertmacro MUI_PAGE_FINISH
|
||||
|
||||
!insertmacro MUI_UNPAGE_CONFIRM
|
||||
!insertmacro MUI_UNPAGE_INSTFILES
|
||||
|
||||
!insertmacro MUI_LANGUAGE "English"
|
||||
|
||||
Section "Cagire (required)" SecCore
|
||||
SectionIn RO
|
||||
SetOutPath "$INSTDIR"
|
||||
File "/oname=cagire.exe" "${CLI_EXE}"
|
||||
File "/oname=cagire-desktop.exe" "${DESKTOP_EXE}"
|
||||
|
||||
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||
WriteRegStr HKLM "Software\Cagire" "InstallDir" "$INSTDIR"
|
||||
|
||||
; Add/Remove Programs entry
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "DisplayName" "Cagire"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "DisplayVersion" "${VERSION}"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "Publisher" "Raphael Forment"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "DisplayIcon" '"$INSTDIR\cagire-desktop.exe"'
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "URLInfoAbout" "https://github.com/Bubobubobubobubo/cagire"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "HelpLink" "https://cagire.raphaelforment.fr"
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "NoModify" 1
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire" "NoRepair" 1
|
||||
SectionEnd
|
||||
|
||||
Section "Add to PATH" SecPath
|
||||
ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
|
||||
StrCpy $0 "$0;$INSTDIR"
|
||||
WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$0"
|
||||
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
||||
SectionEnd
|
||||
|
||||
Section "Start Menu Shortcut" SecStartMenu
|
||||
CreateDirectory "$SMPROGRAMS\Cagire"
|
||||
CreateShortCut "$SMPROGRAMS\Cagire\Cagire.lnk" "$INSTDIR\cagire-desktop.exe" "" "$INSTDIR\cagire-desktop.exe" 0
|
||||
CreateShortCut "$SMPROGRAMS\Cagire\Uninstall.lnk" "$INSTDIR\uninstall.exe"
|
||||
SectionEnd
|
||||
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "Installs Cagire CLI and Desktop binaries."
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SecPath} "Add the install location to the PATH system environment variable."
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} "Add a Cagire shortcut to the Start Menu."
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
|
||||
Section "Uninstall"
|
||||
Delete "$INSTDIR\cagire.exe"
|
||||
Delete "$INSTDIR\cagire-desktop.exe"
|
||||
Delete "$INSTDIR\uninstall.exe"
|
||||
RMDir "$INSTDIR"
|
||||
|
||||
Delete "$SMPROGRAMS\Cagire\Cagire.lnk"
|
||||
Delete "$SMPROGRAMS\Cagire\Uninstall.lnk"
|
||||
RMDir "$SMPROGRAMS\Cagire"
|
||||
|
||||
; Remove from PATH
|
||||
ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path"
|
||||
; Remove ";$INSTDIR" from the path string
|
||||
${WordReplace} $0 ";$INSTDIR" "" "+" $0
|
||||
WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "Path" "$0"
|
||||
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
||||
|
||||
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cagire"
|
||||
DeleteRegKey HKLM "Software\Cagire"
|
||||
SectionEnd
|
||||
BIN
nsis/header.bmp
Normal file
BIN
nsis/header.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
BIN
nsis/sidebar.bmp
Normal file
BIN
nsis/sidebar.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 151 KiB |
@@ -14,7 +14,7 @@ cagire = { path = "../..", default-features = false, features = ["block-renderer
|
||||
cagire-forth = { path = "../../crates/forth" }
|
||||
cagire-project = { path = "../../crates/project" }
|
||||
cagire-ratatui = { path = "../../crates/ratatui" }
|
||||
doux = { path = "/Users/bubo/doux", features = ["native", "soundfont"] }
|
||||
doux = { git = "https://github.com/sova-org/doux", features = ["native", "soundfont"] }
|
||||
nih_plug = { git = "https://github.com/robbert-vdh/nih-plug", features = ["standalone"] }
|
||||
nih_plug_egui = { git = "https://github.com/robbert-vdh/nih-plug" }
|
||||
egui_ratatui = "2.1"
|
||||
|
||||
@@ -219,7 +219,6 @@ impl Plugin for CagirePlugin {
|
||||
source: s.source,
|
||||
})
|
||||
.collect(),
|
||||
quantization: pat.quantization,
|
||||
sync_mode: pat.sync_mode,
|
||||
follow_up: pat.follow_up,
|
||||
};
|
||||
@@ -280,8 +279,6 @@ impl Plugin for CagirePlugin {
|
||||
};
|
||||
let lookahead_end = beat + lookahead_beats;
|
||||
|
||||
let engine_time = self.sample_pos as f64 / self.sample_rate as f64;
|
||||
|
||||
// Drain commands from the editor
|
||||
let commands: Vec<SeqCommand> = self.bridge.cmd_rx.try_iter().collect();
|
||||
|
||||
@@ -295,7 +292,8 @@ impl Plugin for CagirePlugin {
|
||||
fill: false,
|
||||
nudge_secs: 0.0,
|
||||
current_time_us: 0,
|
||||
engine_time,
|
||||
audio_sample_pos: self.sample_pos,
|
||||
sr: self.sample_rate as f64,
|
||||
mouse_x: 0.5,
|
||||
mouse_y: 0.5,
|
||||
mouse_down: 0.0,
|
||||
@@ -311,12 +309,12 @@ impl Plugin for CagirePlugin {
|
||||
// Drain audio commands from the editor (preview, hush, load samples, etc.)
|
||||
for audio_cmd in self.bridge.audio_cmd_rx.try_iter() {
|
||||
match audio_cmd {
|
||||
AudioCommand::Evaluate { ref cmd, time } => {
|
||||
let cmd_ref = match time {
|
||||
AudioCommand::Evaluate { ref cmd, tick } => {
|
||||
let cmd_ref = match tick {
|
||||
Some(t) => {
|
||||
self.cmd_buffer.clear();
|
||||
use std::fmt::Write;
|
||||
let _ = write!(&mut self.cmd_buffer, "{cmd}/time/{t:.6}");
|
||||
let _ = write!(&mut self.cmd_buffer, "{cmd}/tick/{t}");
|
||||
self.cmd_buffer.as_str()
|
||||
}
|
||||
None => cmd.as_str(),
|
||||
@@ -420,11 +418,11 @@ impl Plugin for CagirePlugin {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let cmd_ref = match tsc.time {
|
||||
let cmd_ref = match tsc.tick {
|
||||
Some(t) => {
|
||||
self.cmd_buffer.clear();
|
||||
use std::fmt::Write;
|
||||
let _ = write!(&mut self.cmd_buffer, "{}/time/{t:.6}", tsc.cmd);
|
||||
let _ = write!(&mut self.cmd_buffer, "{}/tick/{t}", tsc.cmd);
|
||||
self.cmd_buffer.as_str()
|
||||
}
|
||||
None => &tsc.cmd,
|
||||
|
||||
@@ -1,7 +1 @@
|
||||
allow-branch = ["main"]
|
||||
sign-commit = false
|
||||
sign-tag = false
|
||||
push = true
|
||||
push-remote = "github"
|
||||
publish = false
|
||||
tag-name = "v{{version}}"
|
||||
|
||||
473
scripts/build-all.sh
Executable file
473
scripts/build-all.sh
Executable file
@@ -0,0 +1,473 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
export MACOSX_DEPLOYMENT_TARGET="12.0"
|
||||
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
|
||||
PLUGIN_NAME="cagire-plugins"
|
||||
LIB_NAME="cagire_plugins" # cargo converts hyphens to underscores
|
||||
OUT="releases"
|
||||
|
||||
PLATFORMS=(
|
||||
"aarch64-apple-darwin"
|
||||
"x86_64-apple-darwin"
|
||||
"x86_64-unknown-linux-gnu"
|
||||
"aarch64-unknown-linux-gnu"
|
||||
"x86_64-pc-windows-gnu"
|
||||
)
|
||||
|
||||
PLATFORM_LABELS=(
|
||||
"macOS aarch64 (native)"
|
||||
"macOS x86_64 (native)"
|
||||
"Linux x86_64 (cross)"
|
||||
"Linux aarch64 (cross)"
|
||||
"Windows x86_64 (cross)"
|
||||
)
|
||||
|
||||
PLATFORM_ALIASES=(
|
||||
"macos-arm64"
|
||||
"macos-x86_64"
|
||||
"linux-x86_64"
|
||||
"linux-aarch64"
|
||||
"windows-x86_64"
|
||||
)
|
||||
|
||||
# --- CLI argument parsing ---
|
||||
|
||||
cli_platforms=""
|
||||
cli_targets=""
|
||||
cli_yes=false
|
||||
cli_all=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--platforms) cli_platforms="$2"; shift 2 ;;
|
||||
--targets) cli_targets="$2"; shift 2 ;;
|
||||
--yes) cli_yes=true; shift ;;
|
||||
--all) cli_all=true; shift ;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --platforms <list> Comma-separated: macos-arm64,macos-x86_64,linux-x86_64,linux-aarch64,windows-x86_64"
|
||||
echo " --targets <list> Comma-separated: cli,desktop,plugins"
|
||||
echo " --all Build all platforms and targets"
|
||||
echo " --yes Skip confirmation prompt"
|
||||
echo ""
|
||||
echo "Without options, runs interactively."
|
||||
exit 0
|
||||
;;
|
||||
*) echo "Unknown option: $1"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
resolve_platform_alias() {
|
||||
local alias="$1"
|
||||
for i in "${!PLATFORM_ALIASES[@]}"; do
|
||||
if [[ "${PLATFORM_ALIASES[$i]}" == "$alias" ]]; then
|
||||
echo "$i"
|
||||
return
|
||||
fi
|
||||
done
|
||||
echo "Unknown platform: $alias" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# --- Helpers ---
|
||||
|
||||
prompt_platforms() {
|
||||
echo "Select platform (0=all, comma-separated):"
|
||||
echo " 0) All"
|
||||
for i in "${!PLATFORMS[@]}"; do
|
||||
echo " $((i+1))) ${PLATFORM_LABELS[$i]}"
|
||||
done
|
||||
read -rp "> " choice
|
||||
|
||||
if [[ "$choice" == "0" || -z "$choice" ]]; then
|
||||
selected_platforms=("${PLATFORMS[@]}")
|
||||
selected_labels=("${PLATFORM_LABELS[@]}")
|
||||
else
|
||||
IFS=',' read -ra indices <<< "$choice"
|
||||
selected_platforms=()
|
||||
selected_labels=()
|
||||
for idx in "${indices[@]}"; do
|
||||
idx="${idx// /}"
|
||||
idx=$((idx - 1))
|
||||
if (( idx < 0 || idx >= ${#PLATFORMS[@]} )); then
|
||||
echo "Invalid platform index: $((idx+1))"
|
||||
exit 1
|
||||
fi
|
||||
selected_platforms+=("${PLATFORMS[$idx]}")
|
||||
selected_labels+=("${PLATFORM_LABELS[$idx]}")
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_targets() {
|
||||
echo ""
|
||||
echo "Select targets (0=all, comma-separated):"
|
||||
echo " 0) All"
|
||||
echo " 1) cagire"
|
||||
echo " 2) cagire-desktop"
|
||||
echo " 3) cagire-plugins (CLAP/VST3)"
|
||||
read -rp "> " choice
|
||||
|
||||
build_cagire=false
|
||||
build_desktop=false
|
||||
build_plugins=false
|
||||
|
||||
if [[ "$choice" == "0" || -z "$choice" ]]; then
|
||||
build_cagire=true
|
||||
build_desktop=true
|
||||
build_plugins=true
|
||||
else
|
||||
IFS=',' read -ra targets <<< "$choice"
|
||||
for t in "${targets[@]}"; do
|
||||
t="${t// /}"
|
||||
case "$t" in
|
||||
1) build_cagire=true ;;
|
||||
2) build_desktop=true ;;
|
||||
3) build_plugins=true ;;
|
||||
*) echo "Invalid target: $t"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
confirm_summary() {
|
||||
echo ""
|
||||
echo "=== Build Summary ==="
|
||||
echo ""
|
||||
echo "Platforms:"
|
||||
for label in "${selected_labels[@]}"; do
|
||||
echo " - $label"
|
||||
done
|
||||
echo ""
|
||||
echo "Targets:"
|
||||
$build_cagire && echo " - cagire"
|
||||
$build_desktop && echo " - cagire-desktop"
|
||||
$build_plugins && echo " - cagire-plugins (CLAP/VST3)"
|
||||
echo ""
|
||||
read -rp "Proceed? [Y/n] " yn
|
||||
case "${yn,,}" in
|
||||
n|no) echo "Aborted."; exit 0 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_os() {
|
||||
case "$1" in
|
||||
*windows*) echo "windows" ;;
|
||||
*linux*) echo "linux" ;;
|
||||
*apple*) echo "macos" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_arch() {
|
||||
case "$1" in
|
||||
aarch64*) echo "aarch64" ;;
|
||||
x86_64*) echo "x86_64" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
platform_suffix() {
|
||||
case "$1" in
|
||||
*windows*) echo ".exe" ;;
|
||||
*) echo "" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
is_cross_target() {
|
||||
case "$1" in
|
||||
*linux*|*windows*) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
native_target() {
|
||||
[[ "$1" == "aarch64-apple-darwin" ]]
|
||||
}
|
||||
|
||||
release_dir() {
|
||||
if native_target "$1"; then
|
||||
echo "target/release"
|
||||
else
|
||||
echo "target/$1/release"
|
||||
fi
|
||||
}
|
||||
|
||||
target_flag() {
|
||||
if native_target "$1"; then
|
||||
echo ""
|
||||
else
|
||||
echo "--target $1"
|
||||
fi
|
||||
}
|
||||
|
||||
builder_for() {
|
||||
if is_cross_target "$1"; then
|
||||
echo "cross"
|
||||
else
|
||||
echo "cargo"
|
||||
fi
|
||||
}
|
||||
|
||||
build_binary() {
|
||||
local platform="$1"
|
||||
shift
|
||||
local builder
|
||||
builder=$(builder_for "$platform")
|
||||
local tf
|
||||
tf=$(target_flag "$platform")
|
||||
# shellcheck disable=SC2086
|
||||
$builder build --release $tf "$@"
|
||||
}
|
||||
|
||||
bundle_plugins_native() {
|
||||
local platform="$1"
|
||||
local tf
|
||||
tf=$(target_flag "$platform")
|
||||
# shellcheck disable=SC2086
|
||||
cargo xtask bundle "$PLUGIN_NAME" --release $tf
|
||||
}
|
||||
|
||||
bundle_desktop_native() {
|
||||
local platform="$1"
|
||||
local tf
|
||||
tf=$(target_flag "$platform")
|
||||
# shellcheck disable=SC2086
|
||||
cargo bundle --release --features desktop --bin cagire-desktop $tf
|
||||
}
|
||||
|
||||
bundle_plugins_cross() {
|
||||
local platform="$1"
|
||||
local rd
|
||||
rd=$(release_dir "$platform")
|
||||
local os
|
||||
os=$(platform_os "$platform")
|
||||
local arch
|
||||
arch=$(platform_arch "$platform")
|
||||
|
||||
# Build the cdylib with cross
|
||||
# shellcheck disable=SC2046
|
||||
build_binary "$platform" -p "$PLUGIN_NAME"
|
||||
|
||||
# Determine source library file
|
||||
local src_lib
|
||||
case "$os" in
|
||||
linux) src_lib="$rd/lib${LIB_NAME}.so" ;;
|
||||
windows) src_lib="$rd/${LIB_NAME}.dll" ;;
|
||||
esac
|
||||
|
||||
if [[ ! -f "$src_lib" ]]; then
|
||||
echo " ERROR: Expected library not found: $src_lib"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Assemble CLAP bundle (flat file)
|
||||
local clap_out="$OUT/${PLUGIN_NAME}-${os}-${arch}.clap"
|
||||
cp "$src_lib" "$clap_out"
|
||||
echo " CLAP -> $clap_out"
|
||||
|
||||
# Assemble VST3 bundle (directory tree)
|
||||
local vst3_dir="$OUT/${PLUGIN_NAME}-${os}-${arch}.vst3"
|
||||
local vst3_contents
|
||||
case "$os" in
|
||||
linux)
|
||||
vst3_contents="$vst3_dir/Contents/${arch}-linux"
|
||||
mkdir -p "$vst3_contents"
|
||||
cp "$src_lib" "$vst3_contents/${PLUGIN_NAME}.so"
|
||||
;;
|
||||
windows)
|
||||
vst3_contents="$vst3_dir/Contents/${arch}-win"
|
||||
mkdir -p "$vst3_contents"
|
||||
cp "$src_lib" "$vst3_contents/${PLUGIN_NAME}.vst3"
|
||||
;;
|
||||
esac
|
||||
echo " VST3 -> $vst3_dir/"
|
||||
}
|
||||
|
||||
copy_artifacts() {
|
||||
local platform="$1"
|
||||
local rd
|
||||
rd=$(release_dir "$platform")
|
||||
local os
|
||||
os=$(platform_os "$platform")
|
||||
local arch
|
||||
arch=$(platform_arch "$platform")
|
||||
local suffix
|
||||
suffix=$(platform_suffix "$platform")
|
||||
|
||||
if $build_cagire; then
|
||||
local src="$rd/cagire${suffix}"
|
||||
local dst="$OUT/cagire-${os}-${arch}${suffix}"
|
||||
cp "$src" "$dst"
|
||||
echo " cagire -> $dst"
|
||||
fi
|
||||
|
||||
if $build_desktop; then
|
||||
local src="$rd/cagire-desktop${suffix}"
|
||||
local dst="$OUT/cagire-desktop-${os}-${arch}${suffix}"
|
||||
cp "$src" "$dst"
|
||||
echo " cagire-desktop -> $dst"
|
||||
|
||||
# macOS .app bundle
|
||||
if [[ "$os" == "macos" ]]; then
|
||||
local app_src="$rd/bundle/osx/Cagire.app"
|
||||
if [[ ! -d "$app_src" ]]; then
|
||||
echo " ERROR: .app bundle not found at $app_src"
|
||||
echo " Did 'cargo bundle' succeed?"
|
||||
return 1
|
||||
fi
|
||||
local app_dst="$OUT/Cagire-${arch}.app"
|
||||
rm -rf "$app_dst"
|
||||
cp -R "$app_src" "$app_dst"
|
||||
echo " Cagire.app -> $app_dst"
|
||||
scripts/make-dmg.sh "$app_dst" "$OUT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# NSIS installer for Windows targets
|
||||
if [[ "$os" == "windows" ]] && command -v makensis &>/dev/null; then
|
||||
echo " Building NSIS installer..."
|
||||
local version
|
||||
version=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
|
||||
local abs_root
|
||||
abs_root=$(pwd)
|
||||
makensis -DVERSION="$version" \
|
||||
-DCLI_EXE="$abs_root/$rd/cagire.exe" \
|
||||
-DDESKTOP_EXE="$abs_root/$rd/cagire-desktop.exe" \
|
||||
-DICON="$abs_root/assets/Cagire.ico" \
|
||||
-DOUTDIR="$abs_root/$OUT" \
|
||||
nsis/cagire.nsi
|
||||
echo " Installer -> $OUT/cagire-${version}-windows-x86_64-setup.exe"
|
||||
fi
|
||||
|
||||
# AppImage for Linux targets
|
||||
if [[ "$os" == "linux" ]]; then
|
||||
if $build_cagire; then
|
||||
scripts/make-appimage.sh "$rd/cagire" "$arch" "$OUT"
|
||||
fi
|
||||
if $build_desktop; then
|
||||
scripts/make-appimage.sh "$rd/cagire-desktop" "$arch" "$OUT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Plugin artifacts for native targets (cross handled in bundle_plugins_cross)
|
||||
if $build_plugins && ! is_cross_target "$platform"; then
|
||||
local bundle_dir="target/bundled"
|
||||
|
||||
# CLAP
|
||||
local clap_src="$bundle_dir/${PLUGIN_NAME}.clap"
|
||||
if [[ -e "$clap_src" ]]; then
|
||||
local clap_dst="$OUT/${PLUGIN_NAME}-${os}-${arch}.clap"
|
||||
cp -r "$clap_src" "$clap_dst"
|
||||
echo " CLAP -> $clap_dst"
|
||||
fi
|
||||
|
||||
# VST3
|
||||
local vst3_src="$bundle_dir/${PLUGIN_NAME}.vst3"
|
||||
if [[ -d "$vst3_src" ]]; then
|
||||
local vst3_dst="$OUT/${PLUGIN_NAME}-${os}-${arch}.vst3"
|
||||
rm -rf "$vst3_dst"
|
||||
cp -r "$vst3_src" "$vst3_dst"
|
||||
echo " VST3 -> $vst3_dst/"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Main ---
|
||||
|
||||
if $cli_all; then
|
||||
selected_platforms=("${PLATFORMS[@]}")
|
||||
selected_labels=("${PLATFORM_LABELS[@]}")
|
||||
build_cagire=true
|
||||
build_desktop=true
|
||||
build_plugins=true
|
||||
elif [[ -n "$cli_platforms" || -n "$cli_targets" ]]; then
|
||||
# Resolve platforms from CLI
|
||||
if [[ -n "$cli_platforms" ]]; then
|
||||
selected_platforms=()
|
||||
selected_labels=()
|
||||
IFS=',' read -ra aliases <<< "$cli_platforms"
|
||||
for alias in "${aliases[@]}"; do
|
||||
alias="${alias// /}"
|
||||
idx=$(resolve_platform_alias "$alias")
|
||||
selected_platforms+=("${PLATFORMS[$idx]}")
|
||||
selected_labels+=("${PLATFORM_LABELS[$idx]}")
|
||||
done
|
||||
else
|
||||
selected_platforms=("${PLATFORMS[@]}")
|
||||
selected_labels=("${PLATFORM_LABELS[@]}")
|
||||
fi
|
||||
|
||||
# Resolve targets from CLI
|
||||
build_cagire=false
|
||||
build_desktop=false
|
||||
build_plugins=false
|
||||
if [[ -n "$cli_targets" ]]; then
|
||||
IFS=',' read -ra tgts <<< "$cli_targets"
|
||||
for t in "${tgts[@]}"; do
|
||||
t="${t// /}"
|
||||
case "$t" in
|
||||
cli) build_cagire=true ;;
|
||||
desktop) build_desktop=true ;;
|
||||
plugins) build_plugins=true ;;
|
||||
*) echo "Unknown target: $t (expected: cli, desktop, plugins)"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
build_cagire=true
|
||||
build_desktop=true
|
||||
build_plugins=true
|
||||
fi
|
||||
else
|
||||
prompt_platforms
|
||||
prompt_targets
|
||||
fi
|
||||
|
||||
if ! $cli_yes && [[ -z "$cli_platforms" ]] && ! $cli_all; then
|
||||
confirm_summary
|
||||
fi
|
||||
|
||||
mkdir -p "$OUT"
|
||||
|
||||
step=0
|
||||
total=${#selected_platforms[@]}
|
||||
|
||||
for platform in "${selected_platforms[@]}"; do
|
||||
step=$((step + 1))
|
||||
echo ""
|
||||
echo "=== [$step/$total] $platform ==="
|
||||
|
||||
if $build_cagire; then
|
||||
echo " -> cagire"
|
||||
build_binary "$platform"
|
||||
fi
|
||||
|
||||
if $build_desktop; then
|
||||
echo " -> cagire-desktop"
|
||||
build_binary "$platform" --features desktop --bin cagire-desktop
|
||||
if ! is_cross_target "$platform"; then
|
||||
echo " -> bundling cagire-desktop .app"
|
||||
bundle_desktop_native "$platform"
|
||||
fi
|
||||
fi
|
||||
|
||||
if $build_plugins; then
|
||||
echo " -> cagire-plugins"
|
||||
if is_cross_target "$platform"; then
|
||||
bundle_plugins_cross "$platform"
|
||||
else
|
||||
bundle_plugins_native "$platform"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo " Copying artifacts..."
|
||||
copy_artifacts "$platform"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "=== Done ==="
|
||||
echo ""
|
||||
ls -lhR "$OUT/"
|
||||
@@ -7,9 +7,15 @@ RUN dpkg --add-architecture arm64 && \
|
||||
libclang-dev \
|
||||
libasound2-dev:arm64 \
|
||||
libjack-dev:arm64 \
|
||||
libx11-dev:arm64 \
|
||||
libx11-xcb-dev:arm64 \
|
||||
libxcb-render0-dev:arm64 \
|
||||
libxcb-shape0-dev:arm64 \
|
||||
libxcb-xfixes0-dev:arm64 \
|
||||
libxkbcommon-dev:arm64 \
|
||||
libgl1-mesa-dev:arm64 \
|
||||
libxcursor-dev:arm64 \
|
||||
libxrandr-dev:arm64 \
|
||||
libxi-dev:arm64 \
|
||||
libwayland-dev:arm64 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
20
scripts/cross/x86_64-linux.Dockerfile
Normal file
20
scripts/cross/x86_64-linux.Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
||||
FROM ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
cmake \
|
||||
libclang-dev \
|
||||
libasound2-dev \
|
||||
libjack-dev \
|
||||
libx11-dev \
|
||||
libx11-xcb-dev \
|
||||
libxcb-render0-dev \
|
||||
libxcb-shape0-dev \
|
||||
libxcb-xfixes0-dev \
|
||||
libxkbcommon-dev \
|
||||
libgl1-mesa-dev \
|
||||
libxcursor-dev \
|
||||
libxrandr-dev \
|
||||
libxi-dev \
|
||||
libwayland-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
19
scripts/cross/x86_64-windows.Dockerfile
Normal file
19
scripts/cross/x86_64-windows.Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
FROM ghcr.io/cross-rs/x86_64-pc-windows-gnu:main
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
cmake \
|
||||
clang \
|
||||
libclang-dev \
|
||||
mingw-w64-tools \
|
||||
mingw-w64-x86-64-dev \
|
||||
g++-mingw-w64-x86-64 \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& ln -sf windows.h /usr/x86_64-w64-mingw32/include/Windows.h \
|
||||
&& ln -sf winsock2.h /usr/x86_64-w64-mingw32/include/WinSock2.h \
|
||||
&& ln -sf ws2tcpip.h /usr/x86_64-w64-mingw32/include/WS2tcpip.h \
|
||||
&& GCCDIR=$(ls -d /usr/lib/gcc/x86_64-w64-mingw32/*-posix 2>/dev/null | head -1) \
|
||||
&& ln -sf "$GCCDIR/libstdc++.a" /usr/x86_64-w64-mingw32/lib/libstdc++.a \
|
||||
&& ln -sf "$GCCDIR/libgcc.a" /usr/x86_64-w64-mingw32/lib/libgcc.a \
|
||||
&& rm -f /usr/x86_64-w64-mingw32/lib/libstdc++.dll.a \
|
||||
&& rm -f /usr/lib/gcc/x86_64-w64-mingw32/*/libstdc++.dll.a
|
||||
66
scripts/make-app-bundle.sh
Executable file
66
scripts/make-app-bundle.sh
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Usage: scripts/make-app-bundle.sh <target>
|
||||
# Creates a macOS .app bundle at target/<target>/release/bundle/osx/Cagire.app
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <target>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARGET="$1"
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
||||
BINARY="$REPO_ROOT/target/$TARGET/release/cagire-desktop"
|
||||
ICON="$REPO_ROOT/assets/Cagire.icns"
|
||||
VERSION="0.1.0"
|
||||
|
||||
if [[ ! -f "$BINARY" ]]; then
|
||||
echo "ERROR: binary not found at $BINARY"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
APP_DIR="$REPO_ROOT/target/$TARGET/release/bundle/osx/Cagire.app"
|
||||
CONTENTS="$APP_DIR/Contents"
|
||||
rm -rf "$APP_DIR"
|
||||
mkdir -p "$CONTENTS/MacOS" "$CONTENTS/Resources"
|
||||
|
||||
cp "$BINARY" "$CONTENTS/MacOS/cagire-desktop"
|
||||
[[ -f "$ICON" ]] && cp "$ICON" "$CONTENTS/Resources/Cagire.icns"
|
||||
|
||||
cat > "$CONTENTS/Info.plist" <<PLIST
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleName</key>
|
||||
<string>Cagire</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Cagire</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.sova.cagire</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${VERSION}</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${VERSION}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>cagire-desktop</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Cagire.icns</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>12.0</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.music</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright (c) 2025 Raphaël Forment</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>Cagire needs microphone access for audio input.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
|
||||
echo " APP -> $APP_DIR"
|
||||
141
scripts/make-appimage.sh
Executable file
141
scripts/make-appimage.sh
Executable file
@@ -0,0 +1,141 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Usage: scripts/make-appimage.sh <binary-path> <arch> <output-dir>
|
||||
# Produces an AppImage from a Linux binary.
|
||||
# On native Linux with matching arch: uses linuxdeploy.
|
||||
# Otherwise (cross-compilation): builds AppImage via mksquashfs in Docker.
|
||||
|
||||
if [[ $# -ne 3 ]]; then
|
||||
echo "Usage: $0 <binary-path> <arch> <output-dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BINARY="$1"
|
||||
ARCH="$2"
|
||||
OUTDIR="$3"
|
||||
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
||||
CACHE_DIR="$REPO_ROOT/.cache"
|
||||
APP_NAME="$(basename "$BINARY")"
|
||||
|
||||
RUNTIME_URL="https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-${ARCH}"
|
||||
RUNTIME="$CACHE_DIR/runtime-${ARCH}"
|
||||
|
||||
build_appdir() {
|
||||
local appdir="$1"
|
||||
mkdir -p "$appdir/usr/bin"
|
||||
cp "$BINARY" "$appdir/usr/bin/cagire"
|
||||
chmod +x "$appdir/usr/bin/cagire"
|
||||
|
||||
mkdir -p "$appdir/usr/share/icons/hicolor/512x512/apps"
|
||||
cp "$REPO_ROOT/assets/Cagire.png" "$appdir/usr/share/icons/hicolor/512x512/apps/cagire.png"
|
||||
|
||||
cp "$REPO_ROOT/assets/cagire.desktop" "$appdir/cagire.desktop"
|
||||
|
||||
# AppRun entry point
|
||||
cat > "$appdir/AppRun" <<'APPRUN'
|
||||
#!/bin/sh
|
||||
SELF="$(readlink -f "$0")"
|
||||
HERE="$(dirname "$SELF")"
|
||||
exec "$HERE/usr/bin/cagire" "$@"
|
||||
APPRUN
|
||||
chmod +x "$appdir/AppRun"
|
||||
|
||||
# Symlink icon at root for AppImage spec
|
||||
ln -sf usr/share/icons/hicolor/512x512/apps/cagire.png "$appdir/cagire.png"
|
||||
ln -sf cagire.desktop "$appdir/.DirIcon" 2>/dev/null || true
|
||||
}
|
||||
|
||||
download_runtime() {
|
||||
mkdir -p "$CACHE_DIR"
|
||||
if [[ ! -f "$RUNTIME" ]]; then
|
||||
echo " Downloading AppImage runtime for $ARCH..."
|
||||
curl -fSL "$RUNTIME_URL" -o "$RUNTIME"
|
||||
fi
|
||||
}
|
||||
|
||||
run_native() {
|
||||
local linuxdeploy_url="https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-${ARCH}.AppImage"
|
||||
local linuxdeploy="$CACHE_DIR/linuxdeploy-${ARCH}.AppImage"
|
||||
|
||||
mkdir -p "$CACHE_DIR"
|
||||
if [[ ! -f "$linuxdeploy" ]]; then
|
||||
echo " Downloading linuxdeploy for $ARCH..."
|
||||
curl -fSL "$linuxdeploy_url" -o "$linuxdeploy"
|
||||
chmod +x "$linuxdeploy"
|
||||
fi
|
||||
|
||||
local appdir
|
||||
appdir="$(mktemp -d)/AppDir"
|
||||
build_appdir "$appdir"
|
||||
|
||||
export ARCH
|
||||
export LDAI_RUNTIME_FILE="$RUNTIME"
|
||||
"$linuxdeploy" \
|
||||
--appimage-extract-and-run \
|
||||
--appdir "$appdir" \
|
||||
--desktop-file "$appdir/cagire.desktop" \
|
||||
--icon-file "$appdir/usr/share/icons/hicolor/512x512/apps/cagire.png" \
|
||||
--output appimage
|
||||
|
||||
local appimage
|
||||
appimage=$(ls -1t ./*.AppImage 2>/dev/null | head -1 || true)
|
||||
if [[ -z "$appimage" ]]; then
|
||||
echo " ERROR: No AppImage produced"
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$OUTDIR"
|
||||
mv "$appimage" "$OUTDIR/${APP_NAME}-linux-${ARCH}.AppImage"
|
||||
echo " AppImage -> $OUTDIR/${APP_NAME}-linux-${ARCH}.AppImage"
|
||||
}
|
||||
|
||||
run_docker() {
|
||||
local platform
|
||||
case "$ARCH" in
|
||||
x86_64) platform="linux/amd64" ;;
|
||||
aarch64) platform="linux/arm64" ;;
|
||||
*) echo "Unsupported arch: $ARCH"; exit 1 ;;
|
||||
esac
|
||||
|
||||
local appdir
|
||||
appdir="$(mktemp -d)/AppDir"
|
||||
build_appdir "$appdir"
|
||||
|
||||
local image_tag="cagire-appimage-${ARCH}"
|
||||
|
||||
echo " Building Docker image $image_tag ($platform)..."
|
||||
docker build --platform "$platform" -q -t "$image_tag" - <<'DOCKERFILE'
|
||||
FROM ubuntu:22.04
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
squashfs-tools \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
DOCKERFILE
|
||||
|
||||
echo " Creating squashfs via Docker ($image_tag)..."
|
||||
docker run --rm --platform "$platform" \
|
||||
-v "$appdir:/appdir:ro" \
|
||||
-v "$CACHE_DIR:/cache" \
|
||||
"$image_tag" \
|
||||
mksquashfs /appdir /cache/appimage-${ARCH}.squashfs \
|
||||
-root-owned -noappend -comp gzip -no-progress
|
||||
|
||||
mkdir -p "$OUTDIR"
|
||||
local final="$OUTDIR/${APP_NAME}-linux-${ARCH}.AppImage"
|
||||
cat "$RUNTIME" "$CACHE_DIR/appimage-${ARCH}.squashfs" > "$final"
|
||||
chmod +x "$final"
|
||||
rm -f "$CACHE_DIR/appimage-${ARCH}.squashfs"
|
||||
echo " AppImage -> $final"
|
||||
}
|
||||
|
||||
HOST_ARCH="$(uname -m)"
|
||||
|
||||
download_runtime
|
||||
|
||||
echo " Building AppImage for ${APP_NAME} ($ARCH)..."
|
||||
|
||||
if [[ "$HOST_ARCH" == "$ARCH" ]] && [[ "$(uname -s)" == "Linux" ]]; then
|
||||
run_native
|
||||
else
|
||||
run_docker
|
||||
fi
|
||||
52
scripts/make-dmg.sh
Executable file
52
scripts/make-dmg.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Usage: scripts/make-dmg.sh <app-path> <output-dir>
|
||||
# Produces a .dmg from a macOS .app bundle using only hdiutil.
|
||||
|
||||
if [[ $# -ne 2 ]]; then
|
||||
echo "Usage: $0 <app-path> <output-dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
APP_PATH="$1"
|
||||
OUTDIR="$2"
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
if [[ ! -d "$APP_PATH" ]]; then
|
||||
echo "ERROR: $APP_PATH is not a directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LIPO_OUTPUT=$(lipo -info "$APP_PATH/Contents/MacOS/cagire-desktop" 2>/dev/null)
|
||||
|
||||
if [[ -z "$LIPO_OUTPUT" ]]; then
|
||||
echo "ERROR: could not determine architecture from $APP_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if echo "$LIPO_OUTPUT" | grep -q "Architectures in the fat file"; then
|
||||
ARCH="universal"
|
||||
else
|
||||
ARCH=$(echo "$LIPO_OUTPUT" | awk '{print $NF}')
|
||||
case "$ARCH" in
|
||||
arm64) ARCH="aarch64" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
STAGING="$(mktemp -d)"
|
||||
trap 'rm -rf "$STAGING"' EXIT
|
||||
|
||||
cp -R "$APP_PATH" "$STAGING/Cagire.app"
|
||||
ln -s /Applications "$STAGING/Applications"
|
||||
cp "$REPO_ROOT/assets/DMG-README.txt" "$STAGING/README.txt"
|
||||
|
||||
DMG_NAME="Cagire-${ARCH}.dmg"
|
||||
mkdir -p "$OUTDIR"
|
||||
|
||||
hdiutil create -volname "Cagire" \
|
||||
-srcfolder "$STAGING" \
|
||||
-ov -format UDZO \
|
||||
"$OUTDIR/$DMG_NAME"
|
||||
|
||||
echo " DMG -> $OUTDIR/$DMG_NAME"
|
||||
26
src/README.md
Normal file
26
src/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# cagire (main application)
|
||||
|
||||
Terminal UI application — ties together the Forth VM, audio engine, and project model.
|
||||
|
||||
## Modules
|
||||
|
||||
| Module | Description |
|
||||
|--------|-------------|
|
||||
| `app/` | `App` struct and submodules: dispatch, editing, navigation, persistence, scripting, sequencer, clipboard, staging, undo |
|
||||
| `engine/` | Audio engine: `sequencer`, `audio`, `link` (Ableton Link), `dispatcher`, `realtime`, `timing` |
|
||||
| `input/` | Keyboard/mouse handling: per-page handlers, modal input, `InputContext` |
|
||||
| `views/` | Pure rendering functions taking `&App` |
|
||||
| `state/` | UI state modules (audio, editor, modals, panels, playback, ...) |
|
||||
| `services/` | Domain logic: clipboard, dict navigation, euclidean, help navigation, pattern editor, stack preview |
|
||||
| `model/` | Domain models: docs, categories, onboarding, script |
|
||||
| `commands` | `AppCommand` enum (~150 variants) |
|
||||
| `page` | `Page` navigation enum |
|
||||
| `midi` | MIDI I/O (up to 4 inputs/outputs) |
|
||||
| `settings` | Confy-based persistent settings |
|
||||
|
||||
## Key Types
|
||||
|
||||
- **`App`** — Central application state, coordinates all subsystems
|
||||
- **`AppCommand`** — Enum of all user actions, dispatched via `App::dispatch()`
|
||||
- **`InputContext`** — Holds `&mut App` + channel senders, bridges input to commands
|
||||
- **`Page`** — 3x2 page grid (Dict, Patterns, Options, Help, Main, Engine)
|
||||
@@ -70,8 +70,8 @@ impl App {
|
||||
pub fn shift_patterns_up(&mut self) {
|
||||
let bank = self.patterns_nav.bank_cursor;
|
||||
let patterns = self.patterns_nav.selected_patterns();
|
||||
let start = *patterns.first().unwrap();
|
||||
let end = *patterns.last().unwrap();
|
||||
let start = *patterns.first().expect("selected_patterns non-empty");
|
||||
let end = *patterns.last().expect("selected_patterns non-empty");
|
||||
if let Some(dirty) = clipboard::shift_patterns_up(
|
||||
&mut self.project_state.project,
|
||||
bank,
|
||||
@@ -90,8 +90,8 @@ impl App {
|
||||
pub fn shift_patterns_down(&mut self) {
|
||||
let bank = self.patterns_nav.bank_cursor;
|
||||
let patterns = self.patterns_nav.selected_patterns();
|
||||
let start = *patterns.first().unwrap();
|
||||
let end = *patterns.last().unwrap();
|
||||
let start = *patterns.first().expect("selected_patterns non-empty");
|
||||
let end = *patterns.last().expect("selected_patterns non-empty");
|
||||
if let Some(dirty) = clipboard::shift_patterns_down(
|
||||
&mut self.project_state.project,
|
||||
bank,
|
||||
@@ -175,7 +175,7 @@ impl App {
|
||||
match model::share::export(pattern_data) {
|
||||
Ok(encoded) => {
|
||||
let len = encoded.len();
|
||||
if let Some(clip) = &mut self.clipboard {
|
||||
if let Ok(mut clip) = arboard::Clipboard::new() {
|
||||
let _ = clip.set_text(encoded);
|
||||
}
|
||||
if len > 2000 {
|
||||
@@ -201,7 +201,7 @@ impl App {
|
||||
match model::share::export_bank(bank_data) {
|
||||
Ok(encoded) => {
|
||||
let len = encoded.len();
|
||||
if let Some(clip) = &mut self.clipboard {
|
||||
if let Ok(mut clip) = arboard::Clipboard::new() {
|
||||
let _ = clip.set_text(encoded);
|
||||
}
|
||||
if len > 2000 {
|
||||
@@ -223,7 +223,7 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn import_bank(&mut self, bank: usize) {
|
||||
let text = match self.clipboard.as_mut().and_then(|c| c.get_text().ok()) {
|
||||
let text = match arboard::Clipboard::new().ok().and_then(|mut c| c.get_text().ok()) {
|
||||
Some(t) => t,
|
||||
None => {
|
||||
self.ui.flash("Clipboard empty", 150, FlashKind::Error);
|
||||
@@ -250,7 +250,7 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn import_pattern(&mut self, bank: usize, pattern: usize) {
|
||||
let text = match self.clipboard.as_mut().and_then(|c| c.get_text().ok()) {
|
||||
let text = match arboard::Clipboard::new().ok().and_then(|mut c| c.get_text().ok()) {
|
||||
Some(t) => t,
|
||||
None => {
|
||||
self.ui
|
||||
@@ -305,7 +305,7 @@ impl App {
|
||||
&indices,
|
||||
);
|
||||
let count = copied.steps.len();
|
||||
if let Some(clip) = &mut self.clipboard {
|
||||
if let Ok(mut clip) = arboard::Clipboard::new() {
|
||||
let text: String = copied.steps.iter().map(|s| s.script.as_str()).collect::<Vec<_>>().join("\n");
|
||||
let _ = clip.set_text(text);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user