feat: add player audio effects module with real-time pipeline, distortion, fourth density, and UI controls
This commit is contained in:
20 files changed
+698
-70
No files matched your search
@@ -57,6 +57,11 @@ export const api = {
|
||||
setVolume: (volume: number) => post('/api/volume', { volume }),
|
||||
setVolumeBoost: (enabled?: boolean) =>
|
||||
post<{ status: string; volume_boost: boolean }>('/api/volume_boost', { enabled }),
|
||||
toggleEffect: (effectId: string, enabled?: boolean) =>
|
||||
post<{ status: string; effect_id: string; active: boolean; active_effects: string[] }>(
|
||||
'/api/effects/toggle',
|
||||
{ effect_id: effectId, enabled },
|
||||
),
|
||||
cycleLoop: () => post<{ mode: 'off' | 'playlist' | 'single' }>('/api/loop_cycle'),
|
||||
|
||||
jump: (index: number) => post('/api/jump', { index }),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, toRef, watch } from 'vue'
|
||||
import {
|
||||
Activity,
|
||||
ExternalLink,
|
||||
Music4,
|
||||
Pause,
|
||||
@@ -9,17 +10,21 @@ import {
|
||||
Repeat1,
|
||||
SkipBack,
|
||||
SkipForward,
|
||||
SlidersHorizontal,
|
||||
Sparkles,
|
||||
Square,
|
||||
Volume,
|
||||
Volume1,
|
||||
Volume2,
|
||||
VolumeX,
|
||||
Waves,
|
||||
Zap,
|
||||
} from 'lucide-vue-next'
|
||||
import { api } from '@/api/client'
|
||||
import { useToasts } from '@/composables/useToasts'
|
||||
import { formatTime, useTrackProgress } from '@/composables/useTrackProgress'
|
||||
import { loopModeOf, type BotStatus } from '@/types/status'
|
||||
import { loopModeOf, type BotStatus, type PlayerEffect } from '@/types/status'
|
||||
|
||||
|
||||
const props = defineProps<{ status: BotStatus | null }>()
|
||||
|
||||
@@ -88,19 +93,29 @@ async function commitVolume() {
|
||||
draggedVolume.value = null
|
||||
}
|
||||
|
||||
const volumeBoost = computed(() => props.status?.volume_boost ?? false)
|
||||
const volumeBoostMultiplier = computed(() => props.status?.volume_boost_multiplier ?? 10.0)
|
||||
const volumeBoostPercent = computed(() => Math.round(volumeBoostMultiplier.value * 100))
|
||||
const EFFECT_ICONS: Record<string, any> = {
|
||||
zap: Zap,
|
||||
sparkles: Sparkles,
|
||||
waves: Waves,
|
||||
activity: Activity,
|
||||
}
|
||||
|
||||
async function toggleVolumeBoost() {
|
||||
const next = !volumeBoost.value
|
||||
function effectIcon(iconName: string) {
|
||||
return EFFECT_ICONS[iconName] ?? Zap
|
||||
}
|
||||
|
||||
const effects = computed<PlayerEffect[]>(() => props.status?.effects ?? [])
|
||||
|
||||
async function onToggleEffect(fx: PlayerEffect) {
|
||||
const next = !fx.active
|
||||
await run(
|
||||
() => api.setVolumeBoost(next),
|
||||
next ? `Włączono tryb ${volumeBoostPercent.value}% głośności ⚡` : 'Wyłączono podbicie głośności',
|
||||
'Błąd przełączania trybu podbicia głośności',
|
||||
() => api.toggleEffect(fx.id, next),
|
||||
next ? `Włączono efekt: ${fx.name} ✨` : `Wyłączono efekt: ${fx.name}`,
|
||||
`Błąd przełączania efektu ${fx.name}`,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
async function togglePlayback() {
|
||||
if (!current.value) {
|
||||
notify('Nic nie jest obecnie odtwarzane', 'info')
|
||||
@@ -327,20 +342,30 @@ async function cycleLoop() {
|
||||
<span class="volume-value">{{ volume }}%</span>
|
||||
</div>
|
||||
|
||||
<div class="volume-boost-row">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-boost"
|
||||
:class="{ active: volumeBoost }"
|
||||
:title="volumeBoost ? `Wyłącz tryb ${volumeBoostPercent}% głośności` : `Włącz tryb ${volumeBoostPercent}% głośności`"
|
||||
@click="toggleVolumeBoost"
|
||||
>
|
||||
<Zap :size="14" class="boost-icon" />
|
||||
<span class="boost-label">Tryb {{ volumeBoostPercent }}% głośności</span>
|
||||
<span class="boost-badge" :class="{ active: volumeBoost }">
|
||||
{{ volumeBoost ? 'AKTYWNY' : 'WYŁ' }}
|
||||
</span>
|
||||
</button>
|
||||
<div v-if="effects.length" class="effects-container">
|
||||
<div class="effects-header">
|
||||
<SlidersHorizontal :size="13" class="effects-header-icon" />
|
||||
<span class="effects-header-title">Efekty odtwarzacza</span>
|
||||
</div>
|
||||
<div class="effects-grid">
|
||||
<button
|
||||
v-for="fx in effects"
|
||||
:key="fx.id"
|
||||
type="button"
|
||||
class="btn-effect"
|
||||
:class="{ active: fx.active }"
|
||||
:title="`${fx.name} – ${fx.description}`"
|
||||
@click="onToggleEffect(fx)"
|
||||
>
|
||||
<div class="effect-info">
|
||||
<component :is="effectIcon(fx.icon)" :size="14" class="effect-icon" />
|
||||
<span class="effect-name">{{ fx.name }}</span>
|
||||
</div>
|
||||
<span class="effect-badge" :class="{ active: fx.active }">
|
||||
{{ fx.active ? 'WŁ' : fx.badge }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -357,65 +382,106 @@ async function cycleLoop() {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.volume-boost-row {
|
||||
margin-top: 10px;
|
||||
.effects-container {
|
||||
margin-top: 14px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--border-glass, rgba(255, 255, 255, 0.08));
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn-boost {
|
||||
width: 100%;
|
||||
.effects-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 8px 14px;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
border: 1px solid var(--border-glass);
|
||||
border-radius: 12px;
|
||||
gap: 6px;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.8rem;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.7px;
|
||||
}
|
||||
|
||||
.effects-header-icon {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.effects-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn-effect {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
padding: 8px 10px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.08));
|
||||
border-radius: 10px;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: var(--transition-smooth);
|
||||
transition: var(--transition-smooth, all 0.2s ease);
|
||||
}
|
||||
|
||||
.btn-boost:hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-color: rgba(255, 255, 255, 0.2);
|
||||
.btn-effect:hover {
|
||||
background: rgba(255, 255, 255, 0.07);
|
||||
border-color: rgba(255, 255, 255, 0.18);
|
||||
color: var(--text-main);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.btn-boost.active {
|
||||
.btn-effect.active {
|
||||
background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(239, 68, 68, 0.15) 100%);
|
||||
border-color: rgba(245, 158, 11, 0.5);
|
||||
color: #fbbf24;
|
||||
box-shadow: 0 0 14px rgba(245, 158, 11, 0.2);
|
||||
box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
|
||||
}
|
||||
|
||||
.btn-boost.active:hover {
|
||||
.btn-effect.active:hover {
|
||||
background: linear-gradient(135deg, rgba(245, 158, 11, 0.22) 0%, rgba(239, 68, 68, 0.22) 100%);
|
||||
border-color: rgba(245, 158, 11, 0.7);
|
||||
}
|
||||
|
||||
.boost-icon {
|
||||
.effect-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.effect-icon {
|
||||
flex-shrink: 0;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-boost.active .boost-icon {
|
||||
.btn-effect.active .effect-icon {
|
||||
transform: scale(1.15);
|
||||
filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.6));
|
||||
}
|
||||
|
||||
.boost-badge {
|
||||
font-size: 0.65rem;
|
||||
font-weight: 700;
|
||||
padding: 2px 7px;
|
||||
border-radius: 20px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
color: var(--text-muted);
|
||||
letter-spacing: 0.5px;
|
||||
.effect-name {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.boost-badge.active {
|
||||
.effect-badge {
|
||||
font-size: 0.62rem;
|
||||
font-weight: 700;
|
||||
padding: 2px 6px;
|
||||
border-radius: 12px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
color: var(--text-muted);
|
||||
letter-spacing: 0.4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.effect-badge.active {
|
||||
background: #f59e0b;
|
||||
color: #0f172a;
|
||||
box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
|
||||
|
||||
@@ -50,6 +50,15 @@ export interface UploadedFile {
|
||||
mtime: number
|
||||
}
|
||||
|
||||
export interface PlayerEffect {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
badge: string
|
||||
icon: string
|
||||
active: boolean
|
||||
}
|
||||
|
||||
export interface BotStatus {
|
||||
playing: boolean
|
||||
paused: boolean
|
||||
@@ -58,6 +67,8 @@ export interface BotStatus {
|
||||
volume: number
|
||||
volume_boost?: boolean
|
||||
volume_boost_multiplier?: number
|
||||
effects?: PlayerEffect[]
|
||||
active_effects?: string[]
|
||||
current: CurrentTrack | null
|
||||
queue: QueueTrack[]
|
||||
queue_index: number
|
||||
@@ -71,6 +82,7 @@ export interface BotStatus {
|
||||
saved_queue_available: boolean
|
||||
}
|
||||
|
||||
|
||||
export type LoopMode = 'off' | 'playlist' | 'single'
|
||||
|
||||
export function loopModeOf(status: BotStatus | null): LoopMode {
|
||||
|
||||
Reference in new issue
Block a user