---
name: "MicMusicTransformer"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "MicMusicTransformer"
summary: "MicMusicTransformer is used to parse the lighting `mic_music_data` DP and provides parsing and formatting for music data."
questions:
  - "What is MicMusicTransformer used for?"
  - "How does MicMusicTransformer parse music data?"
  - "What are the input and output of MicMusicTransformer?"
  - "What are the transformation rules of MicMusicTransformer?"
---

## MicMusicTransformer

> [VERSION] @ray-js/panel-sdk >= 1.0.0

> 💡 Local microphone music DP for light-strip products (e.g., mic_music), supporting multiple music transition modes (jump, fade, breathing, flash)
> and multi-color unit configuration. The protocol includes power switch, mode ID, light state, speed, sensitivity, brightness, and color list, etc.
> Each color unit is hue (4 digits) + saturation (4 digits).

### Description

Local microphone music rhythm standard DP protocol converter for bidirectional conversion between local music rhythm settings and the DP hexadecimal protocol

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `uuid` | `string` | No | DP identifier, defaults to the standard mic_music DP code |
| `defaultValue` | `{ v: number, power: boolean, id: number, isLight: number, mode: number, speed: number, sensitivity: number, a: number, b: number, c: number, brightness: number, colors: Unit[] }` | No | Default music data returned when parsing fails |

### Return Value

Type: `MicMusicTransformer`

MicMusicTransformer instance

#### Methods

| Method | Description |
| --- | --- |
| `parser` | Parse the DP hexadecimal string into a local music rhythm data object |
| `formatter` | Format the local music rhythm data object into a DP hexadecimal string |

### Referenced Types

##### `interface` Unit

| Property | Type | Description |
| --- | --- | --- |
| `hue` | `number` | Hue |
| `saturation` | `number` | Saturation |


### Examples

#### Example

```ts
import { MicMusicTransformer } from '@ray-js/panel-sdk';

const transformer = new MicMusicTransformer();
// Parse local music DP string
const data = transformer.parser('0101003364320000006400000064007800640078006400f0006400500064011800640190006401180064');

// Format to DP string
const dpStr = transformer.formatter({
  v: 1, power: true, id: 0, isLight: 0, mode: 3,
  speed: 100, sensitivity: 50, a: 0, b: 0, c: 0,
  brightness: 100,
  colors: [{ hue: 0, saturation: 100 }, { hue: 120, saturation: 100 }],
});
```
