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

## MusicDataRawTransformer

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

> 💡 Music rhythm Raw DP for lighting products (e.g., music_data_raw), which differs as follows:
> - Protocol format: mode (2 digits) + h (4 digits) + s (2 digits) + v (2 digits), totaling 10 hexadecimal characters
> - h/s/v use their original ranges (h: 0–360, s: 0–100, v: 0–100)

### Description

Music rhythm Raw-type DP protocol converter for bidirectional conversion between music rhythm data and the Raw DP hexadecimal protocol

### Parameters

`Params`

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

### Return Value

Type: `MusicDataRawTransformer`

MusicDataRawTransformer instance

#### Methods

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

### Referenced Types

##### `type` IMusicData

| Property | Type | Description |
| --- | --- | --- |
| `mode` | `number` | MSB: 0 = direct output; 1 = fade |
| `h` | `number` | Hue: 0–360 |
| `s` | `number` | Saturation: 0–100 |
| `v` | `number` | Value: 0–100 |


### Examples

#### Example

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

const transformer = new MusicDataRawTransformer();
// Parse Raw DP string
const data = transformer.parser('0000dc6464');
// => { mode: 0, h: 220, s: 100, v: 100 }

// Format to Raw DP string
const dpStr = transformer.formatter({ mode: 0, h: 120, s: 80, v: 90 });
```
