onMusic2RgbChange(callback: (data: MusicRgbCallbackData) => void, musicOption?: MusicRgbOption)
Requires:
@ray-js/panel-sdk≥1.7.0
Description
Start music rhythm monitoring and convert microphone audio to HSV color data in real time
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
callback | (data: MusicRgbCallbackData) => void | Yes | Audio RGB change callback, receives music‑rhythm data such as hue/saturation/value |
| No | Rhythm configuration (optional) |
Return Value
Type: Promise<unknown>
Operation result Promise
Referenced Types
type
MusicRgbCallbackDataonMusic2RgbChange callback parameter type| Property | Type | Required | Description |
|---|---|---|---|
mode | number | Yes | Color transition mode: 0 instant switch, 1 gradual transition |
hue | number | Yes | Hue, range 0–360 |
saturation | number | Yes | Saturation, range 0–1000 |
value | number | Yes | Value, range 0–1000 |
bright | number | Yes | Brightness, range 0–1000 |
temperature | number | Yes | Color temperature, range 0–1000 |
db | number | Yes | Decibel value, supported in v1.13.2+ |
index | number | Yes | Sensitivity index, supported in v1.13.2+ |
| Yes | Custom property passthrough, supported in v1.13.2+ |
Valid Values
MusicRgbOption.mode
| Value | Description | Since |
|---|---|---|
0 | - | - |
1 | - | - |
Examples
Basic usage
Custom color list
Notes
- Question 1: How to determine the response status of the music rhythm?
- Solution: You can cache the return values of the previous 5 times (approximate number, adjustable by yourself). If the 5 times are the same, it is considered that the music rhythm response status remains unchanged, so the status is changed to no response, otherwise it is considered that the music rhythm responds.