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

## MicMusicDataRawTransformer

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

> 💡 Local microphone music Raw DP for lighting products (e.g., mic_music_data_raw), with an 8-digit hexadecimal string.
> The first byte encodes power (1 bit), id (3 bits), status (2 bits), and style (2 bits) via bit operations.
> The subsequent bytes are speed, sensitivity, and light, one byte each.

### Description

Local microphone music Raw-type DP protocol converter for bidirectional conversion between local music control parameters and the Raw DP hexadecimal protocol

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `uuid` | `string` | No | DP identifier, defaults to 'mic_music_data_raw' |
| `defaultValue` | `IMicMusicData` | No | Default music data returned when parsing fails |

### Return Value

Type: `MicMusicDataRawTransformer`

MicMusicDataRawTransformer instance

#### Methods

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

### Referenced Types

##### `type` IMicMusicData

| Property | Type | Description |
| --- | --- | --- |
| `power` | `number` | Local music switch: 0 = off; 1 = on |
| `id` | `number` | Music mode ID; up to 8 modes supported |
| `status` | `number` | Light state when there is no audio input: 0 = off; 1 = maintain static brightness; 2 = slow fade |
| `style` | `number` | Change mode: 0 = jump; 1 = fade; 2 = breathe; 3 = strobe |
| `speed` | `number` | Change speed, 1–100, default 50 (reserved; not exposed on the panel) |
| `sensitivity` | `number` | Sensitivity, 1–100, default 50 (higher sensitivity corresponds to lower threshold voltage; lower sensitivity corresponds to higher threshold voltage) |
| `light` | `number` | Brightness, 1–100, default 100 (reserved; not exposed on the panel) |


### Examples

#### Example

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

const transformer = new MicMusicDataRawTransformer();
// Parse Raw DP string
const data = transformer.parser('80323264');
// => { power: 1, id: 0, status: 0, style: 0, speed: 50, sensitivity: 50, light: 100 }

// Format to Raw DP string
const dpStr = transformer.formatter({
  power: 1, id: 0, status: 0, style: 0,
  speed: 50, sensitivity: 50, light: 100
});
```
