## General-Music Rhythm

### Function Introduction

1. Device Music Rhythm (Local Music Rhythm)
   Concept: The volume signal is collected through the local microphone, and the voltage value of the signal is calculated to achieve the effect of music rhythm. Since there is no unified implementation logic for this solution, there are two local music rhythm logics for lighting. For details, please refer to.
   Note: If the light switch is turned on in music mode, the firmware reports the music dp, and the music status is turned on.

2. App Music Rhythm
   The mobile phone microphone collects audio information of external music, and the Tuya Smart App converts the audio information into time domain and frequency domain, outputs HSV, and realizes the effect of the light changing with the rhythm of the music.
   The App combines the control panel of the product and collects the surrounding sound through the peripherals of the mobile phone. The App capability is responsible for receiving the sound and providing it to the interface of the panel related capabilities. The panel is responsible for sending the music rhythm dp to the firmware at an interval of 300ms according to the specified mode. The device parses the control command according to the specified protocol to let the device display the corresponding color.

### DP protocol

- dpCode: mic_music_data (For DP parsing details, see [MicMusicTransformer](/en/miniapp/solution-ai/ability/lamp-solution/lamp/ability-set/dp-parser/MicMusicTransformer))

| Serial number | Name                    | Number of bytes | Identifier  | Data type | Field attributes                                                                                                                                                    | Field description |
| ------------- | ----------------------- | --------------- | ----------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| 1             | Version number          | 1               | version     | Value     | Maximum value: 255 Minimum value: 0 Step: 1 Multiple: 0                                                                                                             | None              |
| 2             | Local microphone switch | 2               | switch      | Value     | Maximum value: 255 Minimum value: 0 Step: 1 Multiple: 0                                                                                                             | None              |
| 3             | Music mode number       | 1               | ID          | Value     | Maximum value: 255 Minimum value: 0 Step: 1 Multiple: 0                                                                                                             | None              |
| 4             | Change mode             | 1               | mode        | Bit       | Inverse calculation Bit0: Change mode identification: style1 0: Change mode 1: Change mode Bit1: Change mode identification: style2 0: Change mode 1: Change mode … | None              |
| 5             | Change speed            | 1               | speed       | Value     | Maximum value: 100 Minimum value: 1 Step: 1 Multiple: 0                                                                                                             | None              |
| 6             | Sensitivity             | 1               | sensitivity | Value     | Maximum value: 100 Minimum value: 1 Step: 1 Multiple: 0                                                                                                             | None              |
| 7             | Setting item A          | 1               | setting_A   | Value     | Maximum value: 255 Minimum value: 0 Step: 1 Multiple: 0                                                                                                             | None              |
| 8             | Setting item B          | 1               | setting_B   | Value     | Maximum value: 255 Minimum value: 0 Step: 1 Multiple: 0                                                                                                             | None              |
| 9             | Setting item C          | 1               | setting_C   | Value     | Maximum value: 255 Minimum value: 0 Step: 1 Multiple: 0                                                                                                             | None              |
| 10            | Brightness              | 1               | V           | Value     | Maximum value: 100 Minimum value: 0 Step: 1 Multiple: 0                                                                                                             | None              |
| 11            | Chroma                  | 2               | H           | Value     | Maximum value: 360 Minimum value: 0 Step: 1 Multiple: 0                                                                                                             | None              |
| 12            | Saturation              | 1               | S           | Value     | Maximum value: 100 Minimum value: 0 Step: 1 Multiple: 0                                                                                                             | None              |

### How to develop

- Monitor and report DP according to UI interaction

  - [Specific monitoring and sending examples](/en/miniapp/solution-panel/ability#device-function-point-management)

- Going a step further, we provide extension plug-ins on Tuya MiniApp IDE to assist development. Click `Extension Management` to see `Panel IDE Lighting rhythm library extension, download and use it according to the instructions on the extension.

### Notes

None

### Related materials

- [Function page]:
  - None
- [Component]:
  1. [Music rhythm component](https://developer.tuya.com/material/library_oHEKLjj0/component?code=ComponentsTyLamp&subCode=LampMusicCard)
- [Tutorial]:
  - None
- [SDK]:
  1. Monitor App music pickup => [onMusic2RgbChange](/en/miniapp/develop/ray/api/light/music-rhythms/onMusic2RgbChange)
  2. Cancel App music pickup => [offMusic2RgbChange](/en/miniapp/develop/ray/api/light/music-rhythms/offMusic2RgbChange)
- [API]:
  - None
