Skip to main content

useAudioMixerStore

Welcome to the documentation for the useAudioMixerStore.ts file. This file is part of a project utilizing Zustand to manage state for an audio mixer interface, particularly focusing on audio parameters for bees.

Overview

The useAudioMixerStore allows you to manage and control audio parameters for a collection of bees. This includes the master audio settings as well as individual settings for each bee.

Interfaces and Types

AudioMixerState

This type defines the state structure for the audio mixer store.

PropertyTypeDescription
masterVolumenumberVolume level for the master.
masterMidnumberMid-level for the master.
masterHighnumberHigh-level for the master.
masterLownumberLow-level for the master.
beeAudioParamsArray<{ bee: IBee; low: number; high: number; mid: number; volume: number; }>Array holding audio settings for each bee.

AudioMixerAction

This type defines the actions that can be performed on the audio mixer state.

ActionParametersDescription
setMasterVolumevalue: numberSets the master volume across all bees.
setMasterMidvalue: numberSets the master mid parameter across all bees.
setMasterHighvalue: numberSets the master high parameter across all bees.
setMasterLowvalue: numberSets the master low parameter across all bees.
setBeeVolumebee: IBee, value: numberSets the volume for a specific bee.
setBeeMidbee: IBee, value: numberSets the mid parameter for a specific bee.
setBeeHighbee: IBee, value: numberSets the high parameter for a specific bee.
setBeeLowbee: IBee, value: numberSets the low parameter for a specific bee.

Code Usage

The primary eort of this file is the useAudioMixerStore, which is a Zustand store combining both state and actions. Below is an example of how to use this store:

import { useAudioMixerStore } from "./useAudioMixerStore";

// Set the master volume to 75
useAudioMixerStore.getState().setMasterVolume(75);

// Set specific bee audio parameters
const bee = { id: "bee1", name: "Buzz" }; // Assume this bee conforms to IBee
useAudioMixerStore.getState().setBeeVolume(bee, 60);

Methods and Implementation

Master Audio Controls

These methods affect all bees in terms of volume, mid, high, and low.

  • setMasterVolume(value):

    • Adjusts the master volume control.
  • setMasterMid(value):

    • Adjusts the master mid control.
  • setMasterHigh(value):

    • Adjusts the master high control.
  • setMasterLow(value):

    • Adjusts the master low control.

Individual Bee Controls

These methods allow for control of audio parameters for individual bees:

  • setBeeVolume(bee, value):

    • Adjusts the volume for a specific bee.
  • setBeeMid(bee, value):

    • Adjusts the mid-level for a specific bee.
  • setBeeHigh(bee, value):

    • Adjusts the high-level for a specific bee.
  • setBeeLow(bee, value):

    • Adjusts the low-level for a specific bee.

Enums and Dependencies

PDAudioParam

An enum used for specifying audio parameters:

  • VOLUME
  • MID
  • HIGH
  • LOW

Dependencies

  • zustand: For state management.
  • @shared/interfaces: Contains the IBee interface.
  • @shared/enums: Contains the PDAudioParam enum.

This documentation provides a comprehensive overview of how to use and extend the useAudioMixerStore for audio parameter management.