+6
-6
@@ -1,6 +1,6 @@
|
|||||||
# DSP408 hardware test configuration
|
# DSP408 hardware test configuration
|
||||||
|
|
||||||
DSP408_HOST=
|
DSP408_HOST=
|
||||||
DSP_PORT= // Default to 9761 (thomann dsp408 port)
|
DSP_PORT= // Default to 9761 (thomann dsp408 port)
|
||||||
DSP408_DEVICE_ID= // Default to 1
|
DSP408_DEVICE_ID= // Default to 1
|
||||||
DSP_ALLOW_DESTRUCTIVE=false
|
DSP_ALLOW_DESTRUCTIVE=false
|
||||||
|
|||||||
+47
-47
@@ -1,47 +1,47 @@
|
|||||||
name: CI
|
name: CI
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Rust CI
|
name: Rust CI
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
override: true
|
override: true
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
|
|
||||||
- name: Cache Cargo registry
|
- name: Cache Cargo registry
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry
|
~/.cargo/registry
|
||||||
~/.cargo/git
|
~/.cargo/git
|
||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-cargo-
|
${{ runner.os }}-cargo-
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
env:
|
env:
|
||||||
SQLX_OFFLINE: true
|
SQLX_OFFLINE: true
|
||||||
run: cargo test --workspace --verbose --all
|
run: cargo test --workspace --verbose --all
|
||||||
|
|
||||||
- name: Run Clippy (linter)
|
- name: Run Clippy (linter)
|
||||||
run: cargo clippy --all-targets --all-features -- -D warnings
|
run: cargo clippy --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
- name: Run fmt check
|
- name: Run fmt check
|
||||||
run: cargo fmt --all -- --check
|
run: cargo fmt --all -- --check
|
||||||
|
|
||||||
- name: Build project
|
- name: Build project
|
||||||
run: cargo build --workspace --verbose
|
run: cargo build --workspace --verbose
|
||||||
|
|||||||
+41
-41
@@ -1,41 +1,41 @@
|
|||||||
repos:
|
repos:
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
# ─────────────── PRE-COMMIT ───────────────
|
# ─────────────── PRE-COMMIT ───────────────
|
||||||
|
|
||||||
- id: fmt
|
- id: fmt
|
||||||
name: rustfmt
|
name: rustfmt
|
||||||
entry: cargo fmt -- --check
|
entry: cargo fmt -- --check
|
||||||
language: system
|
language: system
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
stages: [pre-commit]
|
stages: [pre-commit]
|
||||||
|
|
||||||
- id: clippy
|
- id: clippy
|
||||||
name: clippy
|
name: clippy
|
||||||
entry: cargo clippy -- -D warnings
|
entry: cargo clippy -- -D warnings
|
||||||
language: system
|
language: system
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
stages: [pre-commit]
|
stages: [pre-commit]
|
||||||
|
|
||||||
# ─────────────── PRE-PUSH ───────────────
|
# ─────────────── PRE-PUSH ───────────────
|
||||||
|
|
||||||
- id: test
|
- id: test
|
||||||
name: cargo test
|
name: cargo test
|
||||||
entry: cargo test --all --features hardware-tests -- --include-ignored
|
entry: cargo test --all --features hardware-tests -- --include-ignored
|
||||||
language: system
|
language: system
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
stages: [pre-push]
|
stages: [pre-push]
|
||||||
|
|
||||||
- id: build
|
- id: build
|
||||||
name: cargo build release
|
name: cargo build release
|
||||||
entry: cargo build --release
|
entry: cargo build --release
|
||||||
language: system
|
language: system
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
stages: [pre-push]
|
stages: [pre-push]
|
||||||
|
|
||||||
- id: audit
|
- id: audit
|
||||||
name: cargo audit
|
name: cargo audit
|
||||||
entry: cargo audit
|
entry: cargo audit
|
||||||
language: system
|
language: system
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
stages: [pre-push]
|
stages: [pre-push]
|
||||||
|
|||||||
+23
-23
@@ -1,23 +1,23 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "dsp_thomann"
|
name = "dsp_thomann"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
dotenvy = "0.15"
|
dotenvy = "0.15"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
thiserror = "2.0.19"
|
thiserror = "2.0.19"
|
||||||
strum = "0.28.0"
|
strum = "0.28.0"
|
||||||
strum_macros = "0.28.0"
|
strum_macros = "0.28.0"
|
||||||
serde = { version = "1", features = ["derive"], optional = true }
|
serde = { version = "1", features = ["derive"], optional = true }
|
||||||
serde_json = { version = "1", optional = true }
|
serde_json = { version = "1", optional = true }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "dsp_thomann"
|
name = "dsp_thomann"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
hardware-tests = []
|
hardware-tests = []
|
||||||
default = []
|
default = []
|
||||||
serialization = ["dep:serde", "dep:serde_json"]
|
serialization = ["dep:serde", "dep:serde_json"]
|
||||||
|
|||||||
@@ -1,73 +1,73 @@
|
|||||||
Apache License
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
http://www.apache.org/licenses/
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
1. Definitions.
|
1. Definitions.
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||||
|
|
||||||
Copyright 2026 Iceberg
|
Copyright 2026 Iceberg
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|||||||
+1892
-1892
File diff suppressed because it is too large
Load Diff
@@ -1,363 +1,363 @@
|
|||||||
# dsp_thomann
|
# dsp_thomann
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- Existing but not implemented commands: 0x19, 0x25, 0x28, 0x2E, 0x50, 0x51, 0x52, 0x53
|
- Existing but not implemented commands: 0x19, 0x25, 0x28, 0x2E, 0x50, 0x51, 0x52, 0x53
|
||||||
- Commands 0x2E, 0x50, 0x51, 0x52, 0x53 seem to be used for firmware update: DO NOT SEND THEM WITHOUT KNOWLEDGE - RISK OF DEVICE BRICK (I brick my device)
|
- Commands 0x2E, 0x50, 0x51, 0x52, 0x53 seem to be used for firmware update: DO NOT SEND THEM WITHOUT KNOWLEDGE - RISK OF DEVICE BRICK (I brick my device)
|
||||||
- Commands: 0x19, 0x24, 0x28 are triggered by upload preset
|
- Commands: 0x19, 0x24, 0x28 are triggered by upload preset
|
||||||
- Identify: 0x2C parameters
|
- Identify: 0x2C parameters
|
||||||
- Implement: if 2 DSP with same ip they need to share same socket since dsp dont accept multiples connections
|
- Implement: if 2 DSP with same ip they need to share same socket since dsp dont accept multiples connections
|
||||||
- In unlock check if first byte is device id
|
- In unlock check if first byte is device id
|
||||||
- This library allows to send commands even if dsp is locked
|
- This library allows to send commands even if dsp is locked
|
||||||
- Convert back data as in 0x38 to display real value
|
- Convert back data as in 0x38 to display real value
|
||||||
- Figure out Meter level encoding
|
- Figure out Meter level encoding
|
||||||
- Full test of client (Improve existing one)
|
- Full test of client (Improve existing one)
|
||||||
- Write correct readme.md
|
- Write correct readme.md
|
||||||
- Make client dsp408 thread safe
|
- Make client dsp408 thread safe
|
||||||
- Absolutely, send command to avoid tcp keep alive, that make the dsp crash
|
- Absolutely, send command to avoid tcp keep alive, that make the dsp crash
|
||||||
|
|
||||||
Rust library for remote LAN control of Thomann DSP408 digital signal processors.
|
Rust library for remote LAN control of Thomann DSP408 digital signal processors.
|
||||||
|
|
||||||
`dsp_thomann` provides a high-level Rust API to connect, configure and monitor a DSP408 device over TCP/IP.
|
`dsp_thomann` provides a high-level Rust API to connect, configure and monitor a DSP408 device over TCP/IP.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- TCP LAN communication with DSP408
|
- TCP LAN communication with DSP408
|
||||||
- Automatic handshake and connection management
|
- Automatic handshake and connection management
|
||||||
- Device state synchronization
|
- Device state synchronization
|
||||||
- Preset management
|
- Preset management
|
||||||
- Channel routing
|
- Channel routing
|
||||||
- Input/output processing control:
|
- Input/output processing control:
|
||||||
- Gain
|
- Gain
|
||||||
- Mute
|
- Mute
|
||||||
- Phase inversion
|
- Phase inversion
|
||||||
- Delay
|
- Delay
|
||||||
- PEQ
|
- PEQ
|
||||||
- GEQ
|
- GEQ
|
||||||
- Crossover filters
|
- Crossover filters
|
||||||
- Compressor
|
- Compressor
|
||||||
- Limiter
|
- Limiter
|
||||||
- Gate
|
- Gate
|
||||||
- Matrix routing and channel linking
|
- Matrix routing and channel linking
|
||||||
- Level meter reading
|
- Level meter reading
|
||||||
- Device locking/unlocking
|
- Device locking/unlocking
|
||||||
- Strong Rust type safety
|
- Strong Rust type safety
|
||||||
- Protocol frame decoding and validation
|
- Protocol frame decoding and validation
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Add the crate to your `Cargo.toml`:
|
Add the crate to your `Cargo.toml`:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dsp_thomann = "0.1"
|
dsp_thomann = "0.1"
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
use dsp_thomann::dsp408::{DSP408, types};
|
use dsp_thomann::dsp408::{DSP408, types};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
let host: IpAddr = "192.168.49.30".parse()?;
|
let host: IpAddr = "192.168.49.30".parse()?;
|
||||||
|
|
||||||
let mut dsp = DSP408::new(
|
let mut dsp = DSP408::new(
|
||||||
host,
|
host,
|
||||||
9761,
|
9761,
|
||||||
1
|
1
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
dsp.connect()?;
|
dsp.connect()?;
|
||||||
|
|
||||||
println!("Connected!");
|
println!("Connected!");
|
||||||
|
|
||||||
dsp.set_mute(
|
dsp.set_mute(
|
||||||
types::Channel::Input(types::InputChannel::InA),
|
types::Channel::Input(types::InputChannel::InA),
|
||||||
true
|
true
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
println!("{:#?}", dsp.state()?);
|
println!("{:#?}", dsp.state()?);
|
||||||
|
|
||||||
dsp.disconnect();
|
dsp.disconnect();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Connection
|
# Connection
|
||||||
|
|
||||||
A DSP device is identified by:
|
A DSP device is identified by:
|
||||||
|
|
||||||
| Parameter | Description |
|
| Parameter | Description |
|
||||||
|---|---|
|
|---|---|
|
||||||
| Host | DSP IP address |
|
| Host | DSP IP address |
|
||||||
| Port | TCP control port |
|
| Port | TCP control port |
|
||||||
| Device ID | DSP device identifier |
|
| Device ID | DSP device identifier |
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
let mut dsp = DSP408::new(
|
let mut dsp = DSP408::new(
|
||||||
"192.168.49.30".parse()?,
|
"192.168.49.30".parse()?,
|
||||||
9761,
|
9761,
|
||||||
1
|
1
|
||||||
)?;
|
)?;
|
||||||
```
|
```
|
||||||
|
|
||||||
The library performs:
|
The library performs:
|
||||||
|
|
||||||
- TCP connection
|
- TCP connection
|
||||||
- DSP handshake
|
- DSP handshake
|
||||||
- Device information retrieval
|
- Device information retrieval
|
||||||
- Preset state loading
|
- Preset state loading
|
||||||
- Configuration synchronization
|
- Configuration synchronization
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Device State
|
# Device State
|
||||||
|
|
||||||
After connection:
|
After connection:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
let state = dsp.state()?;
|
let state = dsp.state()?;
|
||||||
```
|
```
|
||||||
|
|
||||||
The state contains:
|
The state contains:
|
||||||
|
|
||||||
- Device name
|
- Device name
|
||||||
- Lock status
|
- Lock status
|
||||||
- Preset bank
|
- Preset bank
|
||||||
- Current DSP configuration
|
- Current DSP configuration
|
||||||
|
|
||||||
Including:
|
Including:
|
||||||
|
|
||||||
- Input channels
|
- Input channels
|
||||||
- Output channels
|
- Output channels
|
||||||
- Routing
|
- Routing
|
||||||
- EQ
|
- EQ
|
||||||
- Dynamics
|
- Dynamics
|
||||||
- Delay
|
- Delay
|
||||||
- Crossover configuration
|
- Crossover configuration
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Channel Control
|
# Channel Control
|
||||||
|
|
||||||
Channels are strongly typed:
|
Channels are strongly typed:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
types::Channel::Input(
|
types::Channel::Input(
|
||||||
types::InputChannel::InA
|
types::InputChannel::InA
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
types::Channel::Output(
|
types::Channel::Output(
|
||||||
types::OutputChannel::Out1
|
types::OutputChannel::Out1
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Available Channels
|
## Available Channels
|
||||||
|
|
||||||
### Inputs
|
### Inputs
|
||||||
|
|
||||||
- InA
|
- InA
|
||||||
- InB
|
- InB
|
||||||
- InC
|
- InC
|
||||||
- InD
|
- InD
|
||||||
|
|
||||||
### Outputs
|
### Outputs
|
||||||
|
|
||||||
- Out1
|
- Out1
|
||||||
- Out2
|
- Out2
|
||||||
- Out3
|
- Out3
|
||||||
- Out4
|
- Out4
|
||||||
- Out5
|
- Out5
|
||||||
- Out6
|
- Out6
|
||||||
- Out7
|
- Out7
|
||||||
- Out8
|
- Out8
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Audio Processing
|
# Audio Processing
|
||||||
|
|
||||||
## Gain
|
## Gain
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
dsp.set_channel_gain(
|
dsp.set_channel_gain(
|
||||||
types::Channel::Output(types::OutputChannel::Out1),
|
types::Channel::Output(types::OutputChannel::Out1),
|
||||||
-3.0
|
-3.0
|
||||||
)?;
|
)?;
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Delay
|
## Delay
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
dsp.set_channel_delay(
|
dsp.set_channel_delay(
|
||||||
channel,
|
channel,
|
||||||
2.5,
|
2.5,
|
||||||
types::DelayUnit::Millisecond
|
types::DelayUnit::Millisecond
|
||||||
)?;
|
)?;
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## PEQ
|
## PEQ
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
dsp.set_peq_band(
|
dsp.set_peq_band(
|
||||||
channel,
|
channel,
|
||||||
types::PEQBand::B1,
|
types::PEQBand::B1,
|
||||||
3.0,
|
3.0,
|
||||||
1000.0,
|
1000.0,
|
||||||
0.7,
|
0.7,
|
||||||
types::PEQFilter::Peak,
|
types::PEQFilter::Peak,
|
||||||
false
|
false
|
||||||
)?;
|
)?;
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Compressor
|
## Compressor
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
dsp.set_compressor(
|
dsp.set_compressor(
|
||||||
types::OutputChannel::Out1,
|
types::OutputChannel::Out1,
|
||||||
types::Ratio::Ratio1_4,
|
types::Ratio::Ratio1_4,
|
||||||
10,
|
10,
|
||||||
100,
|
100,
|
||||||
3,
|
3,
|
||||||
-10.0
|
-10.0
|
||||||
)?;
|
)?;
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Presets
|
# Presets
|
||||||
|
|
||||||
## Recall a preset
|
## Recall a preset
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
dsp.recall_preset(1)?;
|
dsp.recall_preset(1)?;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Store current configuration
|
## Store current configuration
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
dsp.store_current_configuration(
|
dsp.store_current_configuration(
|
||||||
2,
|
2,
|
||||||
false
|
false
|
||||||
)?;
|
)?;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Rename current preset
|
## Rename current preset
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
dsp.set_current_preset_name(
|
dsp.set_current_preset_name(
|
||||||
"Live Show"
|
"Live Show"
|
||||||
)?;
|
)?;
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Routing
|
# Routing
|
||||||
|
|
||||||
## Matrix routing
|
## Matrix routing
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
dsp.set_matrix_routing(
|
dsp.set_matrix_routing(
|
||||||
types::OutputChannel::Out1,
|
types::OutputChannel::Out1,
|
||||||
vec![
|
vec![
|
||||||
types::InputChannel::InA,
|
types::InputChannel::InA,
|
||||||
types::InputChannel::InB,
|
types::InputChannel::InB,
|
||||||
],
|
],
|
||||||
)?;
|
)?;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Link channels
|
## Link channels
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
dsp.link_channels(
|
dsp.link_channels(
|
||||||
source,
|
source,
|
||||||
vec![destination]
|
vec![destination]
|
||||||
)?;
|
)?;
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Metering
|
# Metering
|
||||||
|
|
||||||
Read signal levels:
|
Read signal levels:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
let meters = dsp.get_meter_levels()?;
|
let meters = dsp.get_meter_levels()?;
|
||||||
|
|
||||||
println!("{:?}", meters.levels);
|
println!("{:?}", meters.levels);
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Error Handling
|
# Error Handling
|
||||||
|
|
||||||
All operations return:
|
All operations return:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
Result<T, DSPError>
|
Result<T, DSPError>
|
||||||
```
|
```
|
||||||
|
|
||||||
Possible errors include:
|
Possible errors include:
|
||||||
|
|
||||||
- Connection failure
|
- Connection failure
|
||||||
- Timeout
|
- Timeout
|
||||||
- Invalid parameters
|
- Invalid parameters
|
||||||
- Protocol errors
|
- Protocol errors
|
||||||
- Invalid responses
|
- Invalid responses
|
||||||
- Encoding/decoding failures
|
- Encoding/decoding failures
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
match dsp.connect() {
|
match dsp.connect() {
|
||||||
Ok(_) => println!("Connected"),
|
Ok(_) => println!("Connected"),
|
||||||
Err(e) => println!("Error: {}", e),
|
Err(e) => println!("Error: {}", e),
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Thread Safety
|
# Thread Safety
|
||||||
|
|
||||||
The library internally protects socket access with a mutex.
|
The library internally protects socket access with a mutex.
|
||||||
|
|
||||||
- Only one command is transmitted at a time per DSP408 instance.
|
- Only one command is transmitted at a time per DSP408 instance.
|
||||||
- Multiple DSP devices can be controlled simultaneously.
|
- Multiple DSP devices can be controlled simultaneously.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Supported DSP Features
|
# Supported DSP Features
|
||||||
|
|
||||||
| Feature | Supported |
|
| Feature | Supported |
|
||||||
|---|---|
|
|---|---|
|
||||||
| LAN connection | ✅ |
|
| LAN connection | ✅ |
|
||||||
| Handshake | ✅ |
|
| Handshake | ✅ |
|
||||||
| Presets | ✅ |
|
| Presets | ✅ |
|
||||||
| Device lock | ✅ |
|
| Device lock | ✅ |
|
||||||
| PEQ | ✅ |
|
| PEQ | ✅ |
|
||||||
| GEQ | ✅ |
|
| GEQ | ✅ |
|
||||||
| Compressor | ✅ |
|
| Compressor | ✅ |
|
||||||
| Limiter | ✅ |
|
| Limiter | ✅ |
|
||||||
| Gate | ✅ |
|
| Gate | ✅ |
|
||||||
| Delay | ✅ |
|
| Delay | ✅ |
|
||||||
| Crossover | ✅ |
|
| Crossover | ✅ |
|
||||||
| Matrix routing | ✅ |
|
| Matrix routing | ✅ |
|
||||||
| Metering | ✅ |
|
| Metering | ✅ |
|
||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "stable"
|
channel = "stable"
|
||||||
components = ["rustfmt", "clippy"]
|
components = ["rustfmt", "clippy"]
|
||||||
+38
-28
@@ -7,18 +7,16 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use strum::IntoEnumIterator;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::errors::{DSPError, ValidationError},
|
common::errors::DSPError,
|
||||||
dsp408::{
|
dsp408::{
|
||||||
mapper::{
|
mapper::{
|
||||||
self,
|
self,
|
||||||
constants::{CONFIG_CHUNK_INDEX_MAX, PRESET_INDEX_MAX},
|
constants::{CONFIG_CHUNK_INDEX_MAX, PRESET_INDEX_MAX, delay_range},
|
||||||
response::map_response,
|
response::map_response,
|
||||||
},
|
},
|
||||||
protocol::{commands, config::decode_config, frame::extract_frame},
|
protocol::{commands, config::decode_config, frame::extract_frame},
|
||||||
types,
|
types::{self},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -154,6 +152,13 @@ impl DSP408 {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn convert_delay_unit(value: f32, from: types::DelayUnit, to: types::DelayUnit) -> f32 {
|
||||||
|
let (_, from_max) = delay_range(from);
|
||||||
|
let (_, to_max) = delay_range(to);
|
||||||
|
|
||||||
|
(value / from_max) * to_max
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- Commands ----------
|
// ---------- Commands ----------
|
||||||
// Command `0x10`
|
// Command `0x10`
|
||||||
pub fn connect(&mut self) -> Result<(), DSPError> {
|
pub fn connect(&mut self) -> Result<(), DSPError> {
|
||||||
@@ -320,7 +325,20 @@ impl DSP408 {
|
|||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.state_mut()?.current_config.delay_unit = unit;
|
let state = self.state_mut()?;
|
||||||
|
let old_unit = state.current_config.delay_unit;
|
||||||
|
|
||||||
|
if old_unit != unit {
|
||||||
|
for input in state.current_config.input_states.values_mut() {
|
||||||
|
input.delay = Self::convert_delay_unit(input.delay, old_unit, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
for output in state.current_config.output_states.values_mut() {
|
||||||
|
output.delay = Self::convert_delay_unit(output.delay, old_unit, unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
state.current_config.delay_unit = unit;
|
||||||
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
@@ -810,8 +828,12 @@ impl DSP408 {
|
|||||||
|
|
||||||
match channel {
|
match channel {
|
||||||
types::Channel::Input(input) => {
|
types::Channel::Input(input) => {
|
||||||
state.current_config.input_state_mut(input).peq_chain.bands
|
state
|
||||||
[band as usize] = peq;
|
.current_config
|
||||||
|
.input_state_mut(input)
|
||||||
|
.peq_chain
|
||||||
|
.bands
|
||||||
|
.insert(band, peq);
|
||||||
}
|
}
|
||||||
|
|
||||||
types::Channel::Output(output) => {
|
types::Channel::Output(output) => {
|
||||||
@@ -819,7 +841,8 @@ impl DSP408 {
|
|||||||
.current_config
|
.current_config
|
||||||
.output_state_mut(output)
|
.output_state_mut(output)
|
||||||
.peq_chain
|
.peq_chain
|
||||||
.bands[band as usize] = peq;
|
.bands
|
||||||
|
.insert(band, peq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,7 +970,7 @@ impl DSP408 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Command `0x38` (Set Delay)
|
// Command `0x38` (Set Delay)
|
||||||
pub fn set_channel_delay(
|
pub fn set_delay(
|
||||||
&mut self,
|
&mut self,
|
||||||
channel: types::Channel,
|
channel: types::Channel,
|
||||||
delay: f32,
|
delay: f32,
|
||||||
@@ -1350,19 +1373,12 @@ impl DSP408 {
|
|||||||
|
|
||||||
let state = self.state_mut()?;
|
let state = self.state_mut()?;
|
||||||
|
|
||||||
let index = types::InputChannel::iter()
|
|
||||||
.position(|x| x == input_channel)
|
|
||||||
.ok_or_else(|| {
|
|
||||||
DSPError::Validation(ValidationError::Value(
|
|
||||||
"Invalid input channel".to_string(),
|
|
||||||
))
|
|
||||||
})?;
|
|
||||||
|
|
||||||
state
|
state
|
||||||
.current_config
|
.current_config
|
||||||
.output_state_mut(output_channel)
|
.output_state_mut(output_channel)
|
||||||
.matrix_routes
|
.matrix_routes
|
||||||
.gains[index] = gain;
|
.gains
|
||||||
|
.insert(input_channel, gain);
|
||||||
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
@@ -1398,19 +1414,13 @@ impl DSP408 {
|
|||||||
|
|
||||||
let state = self.state_mut()?;
|
let state = self.state_mut()?;
|
||||||
|
|
||||||
let index = types::DiscreteFrequency::iter()
|
|
||||||
.position(|x| x == frequency_band)
|
|
||||||
.ok_or_else(|| {
|
|
||||||
DSPError::Validation(ValidationError::Value(
|
|
||||||
"Invalid GEQ frequency band".to_string(),
|
|
||||||
))
|
|
||||||
})?;
|
|
||||||
|
|
||||||
state
|
state
|
||||||
.current_config
|
.current_config
|
||||||
.input_state_mut(input_channel)
|
.input_state_mut(input_channel)
|
||||||
.geq
|
.geq
|
||||||
.gains[index] = gain;
|
.gains
|
||||||
|
.insert(frequency_band, gain);
|
||||||
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,10 +85,6 @@ pub fn map_response(frame: &Frame) -> Result<DeviceResponseType, ProtocolError>
|
|||||||
|
|
||||||
// Command `0x24` (Get Config Chunk)
|
// Command `0x24` (Get Config Chunk)
|
||||||
if cmd == 0x24 {
|
if cmd == 0x24 {
|
||||||
// Mirrors Python's `int.from_bytes(payload[:1], "little")`, which
|
|
||||||
// is `0` for an empty payload rather than an error — Python slices
|
|
||||||
// never panic. `payload.get(1..)` below mirrors the same
|
|
||||||
// forgiving-slice behavior for the remainder.
|
|
||||||
let index = payload.first().copied().unwrap_or(0);
|
let index = payload.first().copied().unwrap_or(0);
|
||||||
|
|
||||||
if index > 0x1c {
|
if index > 0x1c {
|
||||||
@@ -163,8 +159,23 @@ pub fn map_response(frame: &Frame) -> Result<DeviceResponseType, ProtocolError>
|
|||||||
|
|
||||||
// Command `0x40` (Get Level Meters)
|
// Command `0x40` (Get Level Meters)
|
||||||
if cmd == 0x40 {
|
if cmd == 0x40 {
|
||||||
fn float_to_db(v: f32) -> f32 {
|
const X0: f32 = -25.0; // breakpoint, in dB
|
||||||
40.0 * v.abs().max(1e-12).log10()
|
const Y0: f32 = 1.0; // raw value at the breakpoint
|
||||||
|
const K1: f32 = 0.0104; // slope below breakpoint (raw < Y0)
|
||||||
|
const K2: f32 = 0.0208; // slope above breakpoint (raw >= Y0)
|
||||||
|
|
||||||
|
const MIN_DB: f32 = -60.0;
|
||||||
|
const MAX_DB: f32 = 12.0;
|
||||||
|
|
||||||
|
fn float_to_db(raw: f32) -> f32 {
|
||||||
|
let db = if raw < Y0 {
|
||||||
|
X0 + (raw - Y0) / K1
|
||||||
|
} else {
|
||||||
|
X0 + (raw - Y0) / K2
|
||||||
|
};
|
||||||
|
// Clamping naturally absorbs noise-floor outliers (e.g. raw ≈ 0.385
|
||||||
|
// resolves to well below -60 dB here, so it correctly floors to -60).
|
||||||
|
db.clamp(MIN_DB, MAX_DB)
|
||||||
}
|
}
|
||||||
|
|
||||||
if payload.len() != 38 {
|
if payload.len() != 38 {
|
||||||
|
|||||||
@@ -35,12 +35,14 @@ fn read_gate(r: &mut BinaryReader) -> Result<types::Gate, DSPError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn read_geq(r: &mut BinaryReader) -> Result<types::GraphicEQ, DSPError> {
|
fn read_geq(r: &mut BinaryReader) -> Result<types::GraphicEQ, DSPError> {
|
||||||
let gains = types::DiscreteFrequency::iter()
|
let mut gains = std::collections::HashMap::new();
|
||||||
.map(|_| {
|
|
||||||
let raw = r.read_u16()?;
|
for frequency in types::DiscreteFrequency::iter() {
|
||||||
Ok(mapper::raw_to_eq_gain(raw)?)
|
let raw = r.read_u16()?;
|
||||||
})
|
let gain = mapper::raw_to_eq_gain(raw)?;
|
||||||
.collect::<Result<Vec<_>, DSPError>>()?;
|
|
||||||
|
gains.insert(frequency, gain);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(types::GraphicEQ {
|
Ok(types::GraphicEQ {
|
||||||
gains,
|
gains,
|
||||||
@@ -49,17 +51,20 @@ fn read_geq(r: &mut BinaryReader) -> Result<types::GraphicEQ, DSPError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn read_peq_chain(r: &mut BinaryReader, band_count: usize) -> Result<types::PEQChain, DSPError> {
|
fn read_peq_chain(r: &mut BinaryReader, band_count: usize) -> Result<types::PEQChain, DSPError> {
|
||||||
let bands = (0..band_count)
|
let bands = types::PEQBand::iter()
|
||||||
.map(|_| {
|
.take(band_count)
|
||||||
Ok(types::PEQ {
|
.map(|band| {
|
||||||
|
let peq = types::PEQ {
|
||||||
gain: mapper::raw_to_eq_gain(r.read_u16()?)?,
|
gain: mapper::raw_to_eq_gain(r.read_u16()?)?,
|
||||||
frequency: mapper::raw_to_frequency_hz(r.read_u16()?)?,
|
frequency: mapper::raw_to_frequency_hz(r.read_u16()?)?,
|
||||||
q: mapper::raw_to_peq_q(r.read_u8()?)?,
|
q: mapper::raw_to_peq_q(r.read_u8()?)?,
|
||||||
filter_type: mapper::raw_to_peq_filter(r.read_u8()?)?,
|
filter_type: mapper::raw_to_peq_filter(r.read_u8()?)?,
|
||||||
bypass: false,
|
bypass: false,
|
||||||
})
|
};
|
||||||
|
|
||||||
|
Ok((band, peq))
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>, DSPError>>()?;
|
.collect::<Result<HashMap<_, _>, DSPError>>()?;
|
||||||
|
|
||||||
Ok(types::PEQChain {
|
Ok(types::PEQChain {
|
||||||
bands,
|
bands,
|
||||||
@@ -67,6 +72,21 @@ fn read_peq_chain(r: &mut BinaryReader, band_count: usize) -> Result<types::PEQC
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn apply_peq_bypass(
|
||||||
|
r: &mut BinaryReader,
|
||||||
|
bands: &mut HashMap<types::PEQBand, types::PEQ>,
|
||||||
|
) -> Result<(), DSPError> {
|
||||||
|
let bitmap = r.read_u16()?;
|
||||||
|
|
||||||
|
for (index, band) in types::PEQBand::iter().enumerate() {
|
||||||
|
if let Some(peq) = bands.get_mut(&band) {
|
||||||
|
peq.bypass = bitmap & (1 << index) != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn read_crossover(r: &mut BinaryReader) -> Result<types::CrossoverFilters, DSPError> {
|
fn read_crossover(r: &mut BinaryReader) -> Result<types::CrossoverFilters, DSPError> {
|
||||||
let hp_freq = r.read_u16()?;
|
let hp_freq = r.read_u16()?;
|
||||||
let lp_freq = r.read_u16()?;
|
let lp_freq = r.read_u16()?;
|
||||||
@@ -152,7 +172,13 @@ pub fn decode_config(payload: &[u8]) -> Result<types::DSPConfigState, DSPError>
|
|||||||
inp.linked_channels = mapper::raw_to_link_channels(
|
inp.linked_channels = mapper::raw_to_link_channels(
|
||||||
mapper::channel_to_raw(types::Channel::Input(channel))?,
|
mapper::channel_to_raw(types::Channel::Input(channel))?,
|
||||||
r.read_u8()?,
|
r.read_u8()?,
|
||||||
)?;
|
)?
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|link| match link {
|
||||||
|
types::Channel::Input(input) => Some(input),
|
||||||
|
types::Channel::Output(_) => None,
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================
|
// ============================
|
||||||
@@ -162,17 +188,26 @@ pub fn decode_config(payload: &[u8]) -> Result<types::DSPConfigState, DSPError>
|
|||||||
for (channel, out) in types::OutputChannel::iter().zip(output_channels.iter_mut()) {
|
for (channel, out) in types::OutputChannel::iter().zip(output_channels.iter_mut()) {
|
||||||
out.name = mapper::raw_to_channel_name(r.pop(constants::CHANNEL_NAME_LENGTH)?)?;
|
out.name = mapper::raw_to_channel_name(r.pop(constants::CHANNEL_NAME_LENGTH)?)?;
|
||||||
|
|
||||||
r.skip(1)?;
|
|
||||||
|
|
||||||
out.matrix_routes = types::MatrixRoutes {
|
out.matrix_routes = types::MatrixRoutes {
|
||||||
connected: mapper::raw_to_matrix(r.read_u8()?)?,
|
connected: mapper::raw_to_matrix(r.read_u8()?)?,
|
||||||
|
|
||||||
gains: (0..4)
|
gains: {
|
||||||
.map(|_| {
|
r.skip(1)?;
|
||||||
|
|
||||||
|
[
|
||||||
|
types::InputChannel::InA,
|
||||||
|
types::InputChannel::InB,
|
||||||
|
types::InputChannel::InC,
|
||||||
|
types::InputChannel::InD,
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.map(|input| {
|
||||||
let raw = r.read_u16()?;
|
let raw = r.read_u16()?;
|
||||||
Ok::<f32, DSPError>(mapper::raw_to_matrix_gain(raw)?)
|
let gain = mapper::raw_to_matrix_gain(raw)?;
|
||||||
|
Ok::<(types::InputChannel, f32), DSPError>((input, gain))
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>, _>>()?,
|
.collect::<Result<HashMap<_, _>, _>>()?
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
out.crossover = read_crossover(&mut r)?;
|
out.crossover = read_crossover(&mut r)?;
|
||||||
@@ -196,7 +231,13 @@ pub fn decode_config(payload: &[u8]) -> Result<types::DSPConfigState, DSPError>
|
|||||||
out.linked_channels = mapper::raw_to_link_channels(
|
out.linked_channels = mapper::raw_to_link_channels(
|
||||||
mapper::channel_to_raw(types::Channel::Output(channel))?,
|
mapper::channel_to_raw(types::Channel::Output(channel))?,
|
||||||
r.read_u8()?,
|
r.read_u8()?,
|
||||||
)?;
|
)?
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|link| match link {
|
||||||
|
types::Channel::Output(output) => Some(output),
|
||||||
|
types::Channel::Input(_) => None,
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================
|
// ============================
|
||||||
@@ -212,15 +253,11 @@ pub fn decode_config(payload: &[u8]) -> Result<types::DSPConfigState, DSPError>
|
|||||||
// ============================
|
// ============================
|
||||||
|
|
||||||
for inp in &mut input_channels {
|
for inp in &mut input_channels {
|
||||||
apply_flag(&mut r, inp.peq_chain.bands.as_mut_slice(), |band, value| {
|
apply_peq_bypass(&mut r, &mut inp.peq_chain.bands)?;
|
||||||
band.bypass = value
|
|
||||||
})?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for out in &mut output_channels {
|
for out in &mut output_channels {
|
||||||
apply_flag(&mut r, out.peq_chain.bands.as_mut_slice(), |band, value| {
|
apply_peq_bypass(&mut r, &mut out.peq_chain.bands)?;
|
||||||
band.bypass = value
|
|
||||||
})?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================
|
// ============================
|
||||||
@@ -260,7 +297,7 @@ pub fn decode_config(payload: &[u8]) -> Result<types::DSPConfigState, DSPError>
|
|||||||
for (index, inp) in input_channels.iter_mut().enumerate() {
|
for (index, inp) in input_channels.iter_mut().enumerate() {
|
||||||
let bypass = input_peq_bitmap & (1 << index) != 0;
|
let bypass = input_peq_bitmap & (1 << index) != 0;
|
||||||
|
|
||||||
for peq in inp.peq_chain.bands.iter_mut() {
|
for peq in inp.peq_chain.bands.values_mut() {
|
||||||
peq.bypass = bypass;
|
peq.bypass = bypass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,7 +307,7 @@ pub fn decode_config(payload: &[u8]) -> Result<types::DSPConfigState, DSPError>
|
|||||||
for (index, out) in output_channels.iter_mut().enumerate() {
|
for (index, out) in output_channels.iter_mut().enumerate() {
|
||||||
let bypass = output_peq_bitmap & (1 << index) != 0;
|
let bypass = output_peq_bitmap & (1 << index) != 0;
|
||||||
|
|
||||||
for peq in out.peq_chain.bands.iter_mut() {
|
for peq in out.peq_chain.bands.values_mut() {
|
||||||
peq.bypass = bypass;
|
peq.bypass = bypass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -92,6 +92,7 @@ pub enum CrossoverFilter {
|
|||||||
Bl48,
|
Bl48,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EnumIter)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EnumIter)]
|
||||||
pub enum PEQBand {
|
pub enum PEQBand {
|
||||||
B1 = 1,
|
B1 = 1,
|
||||||
@@ -291,7 +292,7 @@ pub struct Limiter {
|
|||||||
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq, Default)]
|
||||||
pub struct GraphicEQ {
|
pub struct GraphicEQ {
|
||||||
pub gains: Vec<f32>,
|
pub gains: HashMap<DiscreteFrequency, f32>,
|
||||||
pub bypass: bool,
|
pub bypass: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,13 +324,13 @@ pub struct Crossover {
|
|||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq, Default)]
|
||||||
pub struct MatrixRoutes {
|
pub struct MatrixRoutes {
|
||||||
pub connected: Vec<InputChannel>,
|
pub connected: Vec<InputChannel>,
|
||||||
pub gains: Vec<f32>,
|
pub gains: HashMap<InputChannel, f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Default)]
|
#[derive(Debug, Clone, PartialEq, Default)]
|
||||||
pub struct PEQChain {
|
pub struct PEQChain {
|
||||||
pub bands: Vec<PEQ>,
|
pub bands: HashMap<PEQBand, PEQ>,
|
||||||
pub bypass: bool,
|
pub bypass: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +361,7 @@ pub struct InputChannelState {
|
|||||||
pub geq: GraphicEQ,
|
pub geq: GraphicEQ,
|
||||||
pub peq_chain: PEQChain,
|
pub peq_chain: PEQChain,
|
||||||
pub crossover: CrossoverFilters,
|
pub crossover: CrossoverFilters,
|
||||||
pub linked_channels: Vec<Channel>,
|
pub linked_channels: Vec<InputChannel>,
|
||||||
pub mute: bool,
|
pub mute: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +377,7 @@ pub struct OutputChannelState {
|
|||||||
pub gain: f32,
|
pub gain: f32,
|
||||||
pub phase_inverted: bool,
|
pub phase_inverted: bool,
|
||||||
pub delay: f32,
|
pub delay: f32,
|
||||||
pub linked_channels: Vec<Channel>,
|
pub linked_channels: Vec<OutputChannel>,
|
||||||
pub mute: bool,
|
pub mute: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,6 +410,5 @@ pub struct DSPState {
|
|||||||
pub(crate) name: String,
|
pub(crate) name: String,
|
||||||
pub(crate) flags: DeviceFlags,
|
pub(crate) flags: DeviceFlags,
|
||||||
pub(crate) presets: PresetBank,
|
pub(crate) presets: PresetBank,
|
||||||
|
|
||||||
pub(crate) current_config: DSPConfigState,
|
pub(crate) current_config: DSPConfigState,
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -3,6 +3,7 @@ use std::str::FromStr;
|
|||||||
|
|
||||||
use dsp_thomann::dsp408::DSP408;
|
use dsp_thomann::dsp408::DSP408;
|
||||||
use dsp_thomann::dsp408::types;
|
use dsp_thomann::dsp408::types;
|
||||||
|
use dsp_thomann::dsp408::types::InputChannel::InA;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let host = IpAddr::from_str("192.168.49.30")?;
|
let host = IpAddr::from_str("192.168.49.30")?;
|
||||||
@@ -22,9 +23,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
println!("DSP connected.");
|
println!("DSP connected.");
|
||||||
|
|
||||||
dsp.set_mute(types::Channel::Input(types::InputChannel::InA), true)?;
|
// dsp.set_mute(types::Channel::Input(types::InputChannel::InA), true)?;
|
||||||
|
|
||||||
dbg!(dsp.state()?);
|
let r = dsp.set_peq_band(types::Channel::Input(InA), types::PEQBand::B1, 3.0, 1400.0, 2.1, types::PEQFilter::LowShelf, false)?;
|
||||||
|
dbg!(r);
|
||||||
|
|
||||||
|
// dbg!(dsp.state()?);
|
||||||
|
|
||||||
|
// let s = &dsp.state()?.current_config.input_states[&InputChannel::InA].peq_chain;
|
||||||
|
// dbg!(s)
|
||||||
|
|
||||||
println!("Disconnecting...");
|
println!("Disconnecting...");
|
||||||
dsp.disconnect()?;
|
dsp.disconnect()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user