MicMusicTransformer(uuid?: string, 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[] })

Requires:
@ray-js/panel-sdk≥1.0.0

Description

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

Parameters

ParameterTypeRequiredDescription
uuidstringNoDP 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[] }NoDefault music data returned when parsing fails

Return Value

Type: MicMusicTransformer
MicMusicTransformer instance

Referenced Types

interfaceUnit
PropertyTypeRequiredDescription
huenumberYesHue
saturationnumberYesSaturation

Methods

MethodDescription
parserParse the DP hexadecimal string into a local music rhythm data object
formatterFormat the local music rhythm data object into a DP hexadecimal string

Examples

Example

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 }],
});