muses72323
A Rust driver library for the MUSES72323 electronic volume controller IC.
Overview
The MUSES72323 is a high-quality 2-channel electronic volume controller IC manufactured by New Japan Radio Co., Ltd. This crate provides type-safe, zero-cost abstractions for controlling the MUSES72323 via its serial interface.
Key Features
- Volume Control: 0dB to -111.75dB in 0.25dB steps (512 steps)
- Gain Control: 0dB to +21dB in +3dB steps (8 levels)
- Soft Step Function: Reduces zipper noise during volume changes
- Zero-Cross Detection: Minimizes pop noise when changing volume
- Independent or Linked L/R Control: Control channels separately or together
- Type-Safe API: Compile-time guarantees for valid configurations
- No-std Compatible: Works in embedded environments
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage
Basic Volume Control
use ;
// Set volume to -20dB (80 steps of 0.25dB)
let volume_cmd = new
.with_chip_addr // Chip address (ADR0, ADR1 pins)
.with_channel // Control left or both channels
.with_is_soft_step // Enable soft step to reduce zipper noise
.with_volume; // 80 * 0.25dB = -20dB
// Convert to u16 for transmission
let data: u16 = volume_cmd.into;
// Send `data` to MUSES72323 via your serial interface
Gain Control
use ;
// Set gain to +12dB for both channels
let gain_cmd = new
.with_chip_addr
.with_l_gain // Left channel: +12dB
.with_r_gain // Right channel: +12dB
.with_l_r_cont // Link L/R channels
.with_zero_cross_off; // Enable zero-cross detection
let data: u16 = gain_cmd.into;
Clock Configuration
use ;
// Configure soft clock with internal clock and 1/32 division
let clock_cmd = new
.with_chip_addr
.with_internal_clock // Use internal clock
.with_clock_div // 1/32 clock division
.with_zero_window_volt; // Zero-cross detection window
let data: u16 = clock_cmd.into;
Command Reference
SetVolume
Controls the volume level for each channel.
- Volume Range: 0 to 511 (0dB to -111.75dB in 0.25dB steps)
- 0 = 0dB (maximum volume)
- 80 = -20dB
- 511 = -111.75dB (minimum volume)
- Soft Step: Gradually changes volume to reduce zipper noise
- Channel: Control left, right, or both channels (when L/R linked)
SetGain
Controls the gain level for each channel.
Available gain levels:
Gain0= 0dBGain3db= +3dBGain6db= +6dBGain9db= +9dBGain12db= +12dBGain15db= +15dBGain18db= +18dBGain21db= +21dB
Options:
- L/R Control: Link channels for synchronized control
- Zero-Cross Detection: Enable/disable pop noise reduction
SoftClock
Configures the soft step clock and zero-cross detection.
- Clock Source: Internal or external clock
- Clock Division: 1/1, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256
- Zero-Cross Window: Sensitivity of zero-cross detection (1x, 2x, 4x, 8x)
Hardware Interface
The MUSES72323 uses a 3-wire serial interface:
- DATA: Serial data input
- CLOCK: Serial clock input
- LATCH: Data latch signal
Typical transmission sequence:
- Set LATCH low
- Send 16-bit command data (MSB first) on DATA line, clocked by CLOCK
- Set LATCH high to latch the data
Examples
Complete Volume Control System
use ;
// Initialize with soft clock configuration
let clock_cmd = new
.with_chip_addr
.with_internal_clock
.with_clock_div
.with_zero_window_volt;
send_to_muses;
// Set initial gain
let gain_cmd = new
.with_chip_addr
.with_l_gain
.with_r_gain
.with_l_r_cont
.with_zero_cross_off;
send_to_muses;
// Set volume with soft step
let volume_cmd = new
.with_chip_addr
.with_channel
.with_is_soft_step
.with_volume; // -25dB
send_to_muses;
Volume Fade
use ;
Technical Details
Bit Field Layout
All commands are 16-bit values with specific bit layouts:
SetVolume (Command ID: 0b00):
[15:7] Volume (9 bits)
[6:5] Reserved (0b00)
[4] Soft Step Enable
[3:2] Channel Select
[1:0] Chip Address
SetGain (Command ID: 0b000010):
[15] L/R Control
[14:12] L Gain (3 bits)
[11:9] R Gain (3 bits)
[8] Zero-Cross Off
[7:2] Command ID (0b000010)
[1:0] Chip Address
SoftClock (Command ID: 0b0000011):
[15] Reserved (0)
[14:13] Zero Window Voltage (2 bits)
[12:10] Clock Division (3 bits)
[9] Internal Clock Enable
[8:2] Command ID (0b0000011)
[1:0] Chip Address
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
References
Author
Shisei Hanai ruimo.uno@gmail.com