audio-mixer-ui 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,7 +5,7 @@ Originally developed for a choir practice application, these components provide
5
5
 
6
6
  ## Features
7
7
 
8
- - **Professional Audio Controls**: Custom sliders, buttons, and level meters with haptic feedback
8
+ - **Audio Controls**: Custom sliders, buttons, and level meters with haptic feedback
9
9
  - **Musical Navigation**: Bar/beat input, practice marks, tempo controls with bidirectional time mapping
10
10
  - **Responsive Design**: Optimized layouts for mobile, tablet, and desktop
11
11
  - **Event-Driven Architecture**: Clean separation between UI and audio engine
@@ -16,7 +16,7 @@ Originally developed for a choir practice application, these components provide
16
16
  ## Installation
17
17
 
18
18
  ```bash
19
- npm install audio-mixer-ui
19
+ npm install audio-mixer-ui pinia
20
20
  ```
21
21
 
22
22
  ## Quick Start
@@ -25,96 +25,116 @@ npm install audio-mixer-ui
25
25
  <template>
26
26
  <div class="app">
27
27
  <MixerLayout>
28
- <template #controls>
29
- <MixerControls />
30
- </template>
31
- <template #parts>
32
- <PartControl
33
- v-for="part in parts"
34
- :key="part.name"
35
- :name="part.name"
36
- v-model:volume="part.volume"
37
- v-model:mute="part.mute"
38
- v-model:solo="part.solo"
39
- />
28
+ <template #menu>
29
+ <button @click="selectScore" class="menu-item">Load Score</button>
40
30
  </template>
41
31
  </MixerLayout>
42
32
  </div>
43
33
  </template>
44
34
 
45
35
  <script setup>
46
- import {
47
- MixerLayout,
48
- MixerControls,
49
- PartControl
50
- } from 'audio-mixer-ui'
51
- import { ref } from 'vue'
52
-
53
- const parts = ref([
54
- { name: 'Soprano', volume: 0.8, mute: false, solo: false },
55
- { name: 'Alto', volume: 0.7, mute: false, solo: false },
56
- { name: 'Tenor', volume: 0.75, mute: false, solo: false },
57
- { name: 'Bass', volume: 0.8, mute: false, solo: false }
58
- ])
36
+ import { onMounted } from 'vue'
37
+ import { MixerLayout, useMasterAudioControl } from 'audio-mixer-ui'
38
+ import 'audio-mixer-ui/style.css'
39
+
40
+ const masterAudio = useMasterAudioControl()
41
+
42
+ const musicData = {
43
+ title: "Demo Song",
44
+ parts: [
45
+ { name: 'Soprano', volume: 0.75 },
46
+ { name: 'Alto', volume: 0.75 },
47
+ { name: 'Tenor', volume: 0.75 },
48
+ { name: 'Bass', volume: 0.75 }
49
+ ],
50
+ beats: [
51
+ { bar: 1, beat: 1, repeat: 0, tempo: 80, time: 0, timeSig: 4 },
52
+ { bar: 1, beat: 2, repeat: 0, tempo: 80, time: 0.75, timeSig: 4 },
53
+ // ... more beat data
54
+ ],
55
+ marks: { A: 1, B: 5, C: 9 }
56
+ }
57
+
58
+ onMounted(() => {
59
+ masterAudio.initialize(musicData)
60
+ })
61
+
62
+ function selectScore() {
63
+ console.log('Load different score')
64
+ }
59
65
  </script>
60
66
  ```
61
67
 
68
+ **Setup your app with Pinia:**
69
+
70
+ ```js
71
+ // main.js
72
+ import { createApp } from 'vue'
73
+ import { createPinia } from 'pinia'
74
+ import App from './App.vue'
75
+
76
+ const app = createApp(App)
77
+ app.use(createPinia())
78
+ app.mount('#app')
79
+ ```
80
+
62
81
  ## Core Components
63
82
 
83
+ The library exports components that automatically integrate with Pinia stores:
84
+
64
85
  ### Layout Components
65
- - **`MixerLayout`** - Main responsive container with flexible slot system
66
- - **`MixerControls`** - Transport controls, master volume, and feature toggles
86
+ - **`MixerLayout`** - Responsive container that auto-renders parts from store data
87
+ - **`MixerControls`** - Transport controls connected to audio state
67
88
 
68
89
  ### Audio Controls
69
- - **`AudioSlider`** - Professional audio fader with level indicators
70
- - **`AudioButton`** - Responsive button with visual feedback
71
- - **`PartControl`** - Complete part mixer (volume, mute, solo)
72
- - **`TriState`** - Mute/Solo toggle control
90
+ - **`AudioSlider`** - Professional fader with live level indicators
91
+ - **`AudioButton`** - Button with visual/haptic feedback
92
+ - **`PartControl`** - Complete part mixer (auto-generated from store)
93
+ - **`TriState`** - Mute/Solo toggle
73
94
 
74
95
  ### Musical Navigation
75
- - **`BarInput`** - Bar number input with practice mark navigation
76
- - **`TimeInput`** - Time position display and input
77
- - **`SpeedInput`** - Playback speed control with percentage display
96
+ - **`BarInput`** - Bar navigation with practice mark integration
97
+ - **`TimeInput`** - Time display synced to playback position
98
+ - **`SpeedInput`** - Playback speed control
78
99
 
79
100
  ### Utilities
80
- - **`BaseNumericInput`** - Foundation for all numeric inputs
81
- - **`TitleText`** - Responsive title display
101
+ - **`BaseNumericInput`** - Foundation for numeric inputs
102
+ - **`TitleText`** - Responsive text display
82
103
 
83
104
  ## State Management
84
105
 
85
- The library integrates with Pinia stores for reactive state management:
106
+ Components automatically connect to Pinia stores for reactive state management. The library exports three main stores:
86
107
 
87
108
  ```js
88
- // stores/audioState.js
89
- export const useAudioStateStore = defineStore('audioState', {
90
- state: () => ({
91
- isPlaying: false,
92
- currentTime: 0,
93
- currentBar: 1,
94
- currentBeat: 1,
95
- masterVolume: 0.8
96
- })
97
- })
98
- ```
109
+ import {
110
+ useAudioStateStore, // Current playback state (time, volume, playing)
111
+ useMusicDataStore, // Musical structure (beats, parts, marks)
112
+ usePlaybackStateStore, // Transport settings (loop, metronome)
113
+ useMasterAudioControl // Master composable for audio control
114
+ } from 'audio-mixer-ui'
99
115
 
100
- ## Event System
116
+ // Components automatically connect to stores - no manual wiring needed
117
+ const audioState = useAudioStateStore()
118
+ const musicData = useMusicDataStore()
119
+ const masterAudio = useMasterAudioControl()
101
120
 
102
- Components emit semantic events rather than directly manipulating audio:
121
+ // Initialize with your musical data
122
+ masterAudio.initialize(musicData)
123
+ ```
103
124
 
104
- ```vue
105
- <template>
106
- <MixerControls @play="handlePlay" @stop="handleStop" @set-bar="handleSetBar" />
107
- </template>
125
+ ## Integration Pattern
108
126
 
109
- <script setup>
110
- const handlePlay = () => {
111
- // Start audio playback
112
- }
127
+ Components handle user interactions via the master audio composable:
113
128
 
114
- const handleSetBar = (barNumber) => {
115
- // Navigate to specific bar
116
- }
117
- </script>
129
+ ```js
130
+ // Inside components, actions are coordinated through the master composable
131
+ const masterAudio = useMasterAudioControl()
132
+
133
+ // User interactions trigger master audio methods
134
+ masterAudio.play()
135
+ masterAudio.stop()
136
+ masterAudio.setBar(5, 1) // bar 5, repeat 1
137
+ masterAudio.setPartVolume('Soprano', 0.8)
118
138
  ```
119
139
 
120
140
  ## Musical Data Structure
@@ -185,7 +205,7 @@ The library follows an event-driven layered architecture:
185
205
  ## Browser Support
186
206
 
187
207
  - Modern browsers with ES2020+ support
188
- - Vue 3.4+
208
+ - Vue 3.4+ and Pinia for state management
189
209
  - Web Audio API for audio features
190
210
 
191
211
  ## Contributing