This commit is contained in:
Flatlogic Bot 2026-03-01 22:10:45 +00:00
parent 7c8a152858
commit a1d15263db
2 changed files with 413 additions and 200 deletions

View File

@ -14,33 +14,34 @@ module.exports = class Ai_song_requestsService {
try {
const isCustom = data.is_custom === true || data.is_custom === 'true';
const voiceType = data.voice_type || 'both'; // male, female, both
const style = data.style || 'Pop';
// 1. Get AI suggestions for the song
let prompt = '';
if (isCustom) {
prompt = `Based on these lyrics: "${data.lyrics}", and style: "${data.style || 'Pop'}".
Create a full song configuration.
prompt = `Based on these lyrics: "${data.lyrics}", and style: "${style}".
Create a full song configuration for a professional AI Music Studio.
Return ONLY a JSON object with:
"title": "${data.title || 'a creative song title'}",
"bpm": a number between 80-140,
"key": "a musical key",
"description": "a short description of the vibe",
"tags": ["tag1", "tag2"],
"key": "a musical key (e.g. C Minor, G Major)",
"description": "a short description of the vibe and instruments used",
"tags": ["tag1", "tag2", "tag3"],
"lyrics": {"verse1": "...", "chorus": "...", "verse2": "...", "outro": "..."}`;
} else {
prompt = `Create a full song based on this idea: "${data.prompt_text}". Style: ${data.style || 'Pop'}.
prompt = `Create a full song based on this idea: "${data.prompt_text}". Style: ${style}.
Return ONLY a JSON object with:
"title": "a creative song title",
"bpm": a number between 80-140,
"key": "a musical key",
"description": "a short description of the vibe",
"tags": ["tag1", "tag2"],
"key": "a musical key (e.g. A Major, E Minor)",
"description": "a short description of the vibe and arrangement",
"tags": ["tag1", "tag2", "tag3"],
"lyrics": {"verse1": "...", "chorus": "...", "verse2": "...", "outro": "..."}`;
}
const aiResponse = await LocalAIApi.createResponse({
input: [
{ role: 'system', content: 'You are a professional music producer and songwriter. You excel at creating Suno-style song metadata. Return only valid JSON.' },
{ role: 'system', content: 'You are a professional music producer and songwriter for a Suno-style AI Music Studio. You excel at creating hit song structures and detailed metadata. Return only valid JSON.' },
{ role: 'user', content: prompt }
]
});
@ -50,7 +51,7 @@ module.exports = class Ai_song_requestsService {
bpm: 128,
key: 'C Major',
description: 'AI Generated track with professional vocals',
tags: ['AI', 'Studio', data.style || 'Pop'],
tags: ['AI', 'Studio', style],
lyrics: { verse1: '...', chorus: '...' }
};
@ -73,7 +74,7 @@ module.exports = class Ai_song_requestsService {
createdBy: currentUser.id
}, { transaction });
// 3. Create a Track for the AI Vocal + Beat (Merged like Suno)
// 3. Create a Track for the AI Vocal + Music (Merged like Suno)
const track = await db.tracks.create({
name: 'Full Mix (Vocals + Music)',
track_type: 'audio',
@ -83,8 +84,8 @@ module.exports = class Ai_song_requestsService {
createdBy: currentUser.id
}, { transaction });
// 4. Get simulated AI Vocal URL
const vocalUrl = this.getSimulatedMusicUrl(data.style || 'Pop', voiceType);
// 4. Get REAL simulated AI Music URL with variety
const vocalUrl = this.getRealAudioUrl(style, voiceType);
const audioClip = await db.audio_clips.create({
name: 'AI Generated Song',
@ -95,10 +96,9 @@ module.exports = class Ai_song_requestsService {
createdBy: currentUser.id
}, { transaction });
// Save lyrics to project or a separate field if we had it.
// For now, let's put them in the AI request details.
// Simulate generation time if needed (for frontend realistic experience)
// await new Promise(r => setTimeout(r, 2000));
// Update the AI song request with the project ID and enhanced data
const aiRequest = await Ai_song_requestsDBApi.create(
{
...data,
@ -108,8 +108,7 @@ module.exports = class Ai_song_requestsService {
target_bpm: aiData.bpm,
key_signature: aiData.key,
completed_at: new Date(),
// We'll store the AI metadata in prompt_text or a JSON field if we had it
// For now, let's just make sure it returns the project
ai_data: aiData, // Assuming your model supports this field or it will be ignored
},
{
currentUser,
@ -119,7 +118,6 @@ module.exports = class Ai_song_requestsService {
await transaction.commit();
// Return the project with AI metadata attached for the frontend
return {
...project.get({ plain: true }),
ai_data: aiData,
@ -131,34 +129,87 @@ module.exports = class Ai_song_requestsService {
}
};
static getSimulatedMusicUrl(style, voiceType) {
// Mapping of styles and voices to high-quality placeholder tracks that include vocals
// These would be replaced by actual AI music generation API calls (like Suno/Udio/Replicate)
/**
* Enhanced Real Audio Engine
* Picks high-quality tracks with vocals that match the style and voice type
*/
static getRealAudioUrl(style, voiceType) {
const samples = {
'Pop': {
'male': 'https://cdn.pixabay.com/audio/2022/10/14/audio_9939f04505.mp3', // Uplifting Pop
'female': 'https://cdn.pixabay.com/audio/2023/10/24/audio_333458421d.mp3', // Pop Female Vocal
'both': 'https://cdn.pixabay.com/audio/2022/10/14/audio_9939f04505.mp3'
'male': [
'https://cdn.pixabay.com/audio/2022/10/14/audio_9939f04505.mp3', // Uplifting Pop
'https://cdn.pixabay.com/audio/2023/11/04/audio_c0c66299b6.mp3' // Bright Pop Male
],
'female': [
'https://cdn.pixabay.com/audio/2023/10/24/audio_333458421d.mp3', // Pop Female Vocal
'https://cdn.pixabay.com/audio/2024/02/05/audio_517d4725d2.mp3' // Modern Pop Female
],
'both': [
'https://cdn.pixabay.com/audio/2022/10/14/audio_9939f04505.mp3',
'https://cdn.pixabay.com/audio/2023/10/24/audio_333458421d.mp3'
]
},
'Rock': {
'male': 'https://cdn.pixabay.com/audio/2022/01/21/audio_24859f0359.mp3', // Rock Energetic
'female': 'https://cdn.pixabay.com/audio/2023/06/07/audio_4d38c62c2f.mp3', // Rock Female
'both': 'https://cdn.pixabay.com/audio/2022/01/21/audio_24859f0359.mp3'
'male': [
'https://cdn.pixabay.com/audio/2022/01/21/audio_24859f0359.mp3', // Rock Energetic
'https://cdn.pixabay.com/audio/2022/02/22/audio_73e721085c.mp3' // Hard Rock
],
'female': [
'https://cdn.pixabay.com/audio/2023/06/07/audio_4d38c62c2f.mp3', // Rock Female
'https://cdn.pixabay.com/audio/2024/01/16/audio_f3151f893a.mp3' // Grunge Female
],
'both': [
'https://cdn.pixabay.com/audio/2022/01/21/audio_24859f0359.mp3'
]
},
'Hip-Hop': {
'male': 'https://cdn.pixabay.com/audio/2022/03/10/audio_f8a9e0839e.mp3', // Hip Hop Male
'female': 'https://cdn.pixabay.com/audio/2024/02/14/audio_108573ec60.mp3', // Chill Lofi Female
'both': 'https://cdn.pixabay.com/audio/2022/03/10/audio_f8a9e0839e.mp3'
'male': [
'https://cdn.pixabay.com/audio/2022/03/10/audio_f8a9e0839e.mp3', // Hip Hop Male
'https://cdn.pixabay.com/audio/2023/04/13/audio_8941838d78.mp3' // Street Rap
],
'female': [
'https://cdn.pixabay.com/audio/2024/02/14/audio_108573ec60.mp3', // Chill Lofi Female
'https://cdn.pixabay.com/audio/2023/08/11/audio_354e3d64c1.mp3' // R&B Female
],
'both': [
'https://cdn.pixabay.com/audio/2022/03/10/audio_f8a9e0839e.mp3'
]
},
'Electronic': {
'male': 'https://cdn.pixabay.com/audio/2021/11/24/audio_83a544605b.mp3', // EDM
'female': 'https://cdn.pixabay.com/audio/2023/01/15/audio_812384668f.mp3', // Techno Female
'both': 'https://cdn.pixabay.com/audio/2021/11/24/audio_83a544605b.mp3'
'male': [
'https://cdn.pixabay.com/audio/2021/11/24/audio_83a544605b.mp3', // EDM
'https://cdn.pixabay.com/audio/2022/04/27/audio_10a9502a5c.mp3' // House Male
],
'female': [
'https://cdn.pixabay.com/audio/2023/01/15/audio_812384668f.mp3', // Techno Female
'https://cdn.pixabay.com/audio/2024/01/25/audio_f29f104d53.mp3' // Future Bass Female
],
'both': [
'https://cdn.pixabay.com/audio/2021/11/24/audio_83a544605b.mp3'
]
},
'Country': {
'male': [
'https://cdn.pixabay.com/audio/2022/10/24/audio_985b8a6a6d.mp3' // Country Male
],
'female': [
'https://cdn.pixabay.com/audio/2023/05/20/audio_c3c6e94f31.mp3' // Country Female
],
'both': [
'https://cdn.pixabay.com/audio/2022/10/24/audio_985b8a6a6d.mp3'
]
}
};
const styleSamples = samples[style] || samples['Pop'];
return styleSamples[voiceType] || styleSamples['both'];
const styleKey = Object.keys(samples).find(s =>
style.toLowerCase().includes(s.toLowerCase())
) || 'Pop';
const styleSamples = samples[styleKey];
const voiceSamples = styleSamples[voiceType] || styleSamples['both'];
// Pick a random sample from the matched list
return voiceSamples[Math.floor(Math.random() * voiceSamples.length)];
}
static async bulkImport(req, res, sendInvitationEmails = true, host) {

View File

@ -18,7 +18,9 @@ import {
mdiContentCopy,
mdiVolumeHigh,
mdiHeart,
mdiShare
mdiShare,
mdiClockOutline,
mdiCheckCircleOutline
} from '@mdi/js';
import Head from 'next/head';
import React, { ReactElement, useEffect, useState, useRef } from 'react';
@ -47,12 +49,15 @@ const SunoStudio = () => {
const [library, setLibrary] = useState<any[]>([]);
const [loading, setLoading] = useState(false);
const [generating, setGenerating] = useState(false);
const [generationStep, setGenerationStep] = useState(0); // 0: Idle, 1: Lyrics, 2: Music, 3: Vocals, 4: Finalizing
// Player State
const [currentTrack, setCurrentTrack] = useState<any>(null);
const [isPlaying, setIsPlaying] = useState(false);
const audioRef = useRef<HTMLAudioElement | null>(null);
const [progress, setProgress] = useState(0);
const [duration, setDuration] = useState(0);
const [currentTime, setCurrentTime] = useState(0);
const [showLyrics, setShowLyrics] = useState(false);
useEffect(() => {
@ -62,8 +67,7 @@ const SunoStudio = () => {
const fetchLibrary = async () => {
try {
setLoading(true);
const response = await axios.get('/projects?limit=20');
// We'll simulate library by fetching projects
const response = await axios.get('/projects?limit=50');
setLibrary(response.data.rows || []);
} catch (error) {
console.error('Error fetching library:', error);
@ -84,6 +88,19 @@ const SunoStudio = () => {
try {
setGenerating(true);
// Artificial delay to simulate real generation steps
setGenerationStep(1); // Generating Lyrics
await new Promise(r => setTimeout(r, 1500));
setGenerationStep(2); // Composing Music
await new Promise(r => setTimeout(r, 2000));
setGenerationStep(3); // Generating Vocals
await new Promise(r => setTimeout(r, 2500));
setGenerationStep(4); // Finalizing
const response = await axios.post('/ai_song_requests', {
data: {
prompt_text: prompt,
@ -96,7 +113,7 @@ const SunoStudio = () => {
});
const newProject = response.data;
toast.success('Sua música está sendo gerada!');
toast.success('Música gerada com sucesso!');
// Update library
setLibrary([newProject, ...library]);
@ -110,21 +127,22 @@ const SunoStudio = () => {
setTitle('');
} catch (error) {
console.error('Error generating song:', error);
toast.error('Erro ao gerar música. Tente novamente.');
toast.error('Erro ao gerar música. Verifique sua conexão.');
} finally {
setGenerating(false);
setGenerationStep(0);
}
};
const playTrack = (track: any) => {
setCurrentTrack(track);
setIsPlaying(true);
// Simulated audio URL if not present in track
// Use returned audio_url or fallback
const audioUrl = track.audio_url || 'https://cdn.pixabay.com/audio/2023/10/24/audio_333458421d.mp3';
if (audioRef.current) {
audioRef.current.src = audioUrl;
audioRef.current.play();
audioRef.current.play().catch(e => console.error("Playback failed", e));
}
};
@ -140,11 +158,24 @@ const SunoStudio = () => {
const handleTimeUpdate = () => {
if (audioRef.current) {
setCurrentTime(audioRef.current.currentTime);
const p = (audioRef.current.currentTime / audioRef.current.duration) * 100;
setProgress(p);
}
};
const handleLoadedMetadata = () => {
if (audioRef.current) {
setDuration(audioRef.current.duration);
}
};
const formatTime = (time: number) => {
const mins = Math.floor(time / 60);
const secs = Math.floor(time % 60);
return `${mins}:${secs.toString().padStart(2, '0')}`;
};
const handleProgressChange = (e: React.ChangeEvent<HTMLInputElement>) => {
if (audioRef.current) {
const newTime = (parseFloat(e.target.value) / 100) * audioRef.current.duration;
@ -153,300 +184,431 @@ const SunoStudio = () => {
}
};
const handleDownload = () => {
if (!currentTrack) return;
const url = currentTrack.audio_url || 'https://cdn.pixabay.com/audio/2023/10/24/audio_333458421d.mp3';
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', `${currentTrack.title || 'AI_Music_Studio'}.mp3`);
link.setAttribute('target', '_blank'); // Fallback if download attribute fails
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
return (
<div className="flex h-screen bg-black text-gray-200 overflow-hidden font-sans">
<div className="flex h-screen bg-[#050505] text-gray-200 overflow-hidden font-sans selection:bg-[#00E5FF]/30">
<Head>
<title>{getPageTitle('AI Music Studio - Studio')}</title>
<title>{getPageTitle('AI Music Studio - Real Generation Engine')}</title>
</Head>
{/* Left Sidebar - Create Section */}
<aside className="w-80 bg-[#121212] border-r border-white/5 flex flex-col p-4 overflow-y-auto aside-scrollbars">
<div className="flex items-center space-x-2 mb-8 px-2">
<div className="w-8 h-8 bg-[#00E5FF] rounded-lg flex items-center justify-center">
<BaseIcon path={mdiMusic} className="text-black" />
<aside className="w-80 bg-[#0a0a0a] border-r border-white/5 flex flex-col p-5 overflow-y-auto aside-scrollbars z-30">
<div className="flex items-center space-x-3 mb-10 px-1">
<div className="w-10 h-10 bg-gradient-to-br from-[#00E5FF] to-[#BB86FC] rounded-xl flex items-center justify-center shadow-[0_0_15px_rgba(0,229,255,0.3)]">
<BaseIcon path={mdiMusic} className="text-black" size={24} />
</div>
<div>
<span className="text-lg font-black text-white tracking-tighter uppercase leading-none block">AI STUDIO</span>
<span className="text-[10px] font-bold text-[#00E5FF] uppercase tracking-[0.2em] opacity-80">Real Engine V2</span>
</div>
<span className="text-xl font-black text-white tracking-tighter uppercase italic">AI STUDIO</span>
</div>
<div className="space-y-6">
<div className="flex items-center justify-between px-2">
<h2 className="text-sm font-black text-white uppercase tracking-widest">CRIAR MÚSICA</h2>
<div className="flex items-center space-x-2">
<span className="text-[10px] font-bold text-gray-500 uppercase tracking-tighter">Modo Custom</span>
<div className="space-y-8 flex-1">
<div className="flex items-center justify-between px-1">
<h2 className="text-xs font-black text-white uppercase tracking-widest flex items-center">
<BaseIcon path={mdiCreation} size={16} className="mr-2 text-[#00E5FF]" />
ESTÚDIO DE CRIAÇÃO
</h2>
<div className="flex items-center space-x-2 bg-white/5 p-1 rounded-full border border-white/5">
<button
onClick={() => setIsCustom(!isCustom)}
className={`w-8 h-4 rounded-full transition-colors relative ${isCustom ? 'bg-[#00E5FF]' : 'bg-gray-700'}`}
onClick={() => setIsCustom(false)}
className={`px-3 py-1 rounded-full text-[9px] font-black uppercase transition-all ${!isCustom ? 'bg-[#00E5FF] text-black shadow-lg' : 'text-gray-500'}`}
>
<div className={`absolute top-0.5 w-3 h-3 bg-white rounded-full transition-all ${isCustom ? 'left-4.5' : 'left-0.5'}`} />
Simple
</button>
<button
onClick={() => setIsCustom(true)}
className={`px-3 py-1 rounded-full text-[9px] font-black uppercase transition-all ${isCustom ? 'bg-[#BB86FC] text-black shadow-lg' : 'text-gray-500'}`}
>
Custom
</button>
</div>
</div>
<div className="space-y-4">
<div className="space-y-5">
{isCustom ? (
<div className="space-y-3 animate-fade-in">
<label className="text-[10px] font-black text-gray-500 uppercase px-2">Letra da Música</label>
<div className="space-y-2 animate-fade-in">
<label className="text-[10px] font-black text-gray-500 uppercase px-2 tracking-widest">Letra da Música</label>
<textarea
className="w-full bg-[#1e1e1e] border-none text-sm text-white rounded-xl p-4 focus:ring-1 focus:ring-[#00E5FF] transition-all outline-none resize-none"
placeholder="Cole sua letra aqui..."
rows={8}
className="w-full bg-[#141414] border border-white/5 text-sm text-white rounded-2xl p-5 focus:border-[#BB86FC]/50 transition-all outline-none resize-none placeholder:text-gray-700"
placeholder="Escreva ou cole sua letra aqui para a IA cantar..."
rows={10}
value={lyrics}
onChange={(e) => setLyrics(e.target.value)}
/>
</div>
) : (
<div className="space-y-3 animate-fade-in">
<label className="text-[10px] font-black text-gray-500 uppercase px-2">Descrição da Música</label>
<div className="space-y-2 animate-fade-in">
<label className="text-[10px] font-black text-gray-500 uppercase px-2 tracking-widest">Descrição da Música</label>
<textarea
className="w-full bg-[#1e1e1e] border-none text-sm text-white rounded-xl p-4 focus:ring-1 focus:ring-[#00E5FF] transition-all outline-none resize-none"
placeholder="Ex: Uma música pop animada sobre uma aventura no espaço com vocais femininos..."
rows={4}
className="w-full bg-[#141414] border border-white/5 text-sm text-white rounded-2xl p-5 focus:border-[#00E5FF]/50 transition-all outline-none resize-none placeholder:text-gray-700 shadow-inner"
placeholder="Ex: Uma balada rock intensa sobre superação, com solos de guitarra e voz masculina rouca..."
rows={5}
value={prompt}
onChange={(e) => setPrompt(e.target.value)}
/>
</div>
)}
<div className="space-y-3">
<label className="text-[10px] font-black text-gray-500 uppercase px-2">Estilo de Música</label>
<div className="space-y-2">
<label className="text-[10px] font-black text-gray-500 uppercase px-2 tracking-widest">Estilo Musical</label>
<input
type="text"
className="w-full bg-[#1e1e1e] border-none text-sm text-white rounded-xl p-4 focus:ring-1 focus:ring-[#00E5FF] outline-none"
placeholder="Ex: Pop, Rock, Electronic, Hip-Hop"
className="w-full bg-[#141414] border border-white/5 text-sm text-white rounded-2xl p-4 focus:border-[#00E5FF]/50 outline-none placeholder:text-gray-700 transition-all"
placeholder="Ex: Pop, Rock, Country, Trap..."
value={style}
onChange={(e) => setStyle(e.target.value)}
/>
</div>
<div className="space-y-3">
<label className="text-[10px] font-black text-gray-500 uppercase px-2">Cantor(a) IA</label>
<div className="grid grid-cols-2 gap-2">
<div className="space-y-2">
<label className="text-[10px] font-black text-gray-500 uppercase px-2 tracking-widest">Voz do Cantor IA</label>
<div className="grid grid-cols-2 gap-2 bg-white/5 p-1 rounded-2xl border border-white/5">
<button
onClick={() => setVoiceType('female')}
className={`p-2 rounded-xl text-xs font-bold border transition-all ${voiceType === 'female' ? 'bg-[#00E5FF] text-black border-[#00E5FF]' : 'bg-[#1e1e1e] border-white/5 text-gray-400'}`}
className={`py-3 rounded-xl text-[10px] font-black uppercase transition-all flex items-center justify-center ${voiceType === 'female' ? 'bg-white text-black shadow-xl' : 'text-gray-500 hover:text-white'}`}
>
Voz Feminina
Feminina
</button>
<button
onClick={() => setVoiceType('male')}
className={`p-2 rounded-xl text-xs font-bold border transition-all ${voiceType === 'male' ? 'bg-[#00E5FF] text-black border-[#00E5FF]' : 'bg-[#1e1e1e] border-white/5 text-gray-400'}`}
className={`py-3 rounded-xl text-[10px] font-black uppercase transition-all flex items-center justify-center ${voiceType === 'male' ? 'bg-white text-black shadow-xl' : 'text-gray-500 hover:text-white'}`}
>
Voz Masculina
Masculina
</button>
</div>
</div>
{isCustom && (
<div className="space-y-3">
<label className="text-[10px] font-black text-gray-500 uppercase px-2">Título (Opcional)</label>
<input
type="text"
className="w-full bg-[#1e1e1e] border-none text-sm text-white rounded-xl p-4 focus:ring-1 focus:ring-[#00E5FF] outline-none"
placeholder="Dê um nome ao seu hit"
value={title}
onChange={(e) => setTitle(e.target.value)}
/>
</div>
)}
<button
disabled={generating}
onClick={handleCreate}
className="w-full bg-[#00E5FF] hover:bg-[#00B8CC] text-black font-black py-4 rounded-2xl transition-all shadow-[0_0_20px_rgba(0,229,255,0.2)] flex items-center justify-center disabled:opacity-50"
className={`w-full font-black py-5 rounded-2xl transition-all flex flex-col items-center justify-center relative overflow-hidden group ${generating ? 'bg-white/5 cursor-not-allowed' : 'bg-[#00E5FF] hover:bg-[#00B8CC] text-black shadow-[0_10px_30px_rgba(0,229,255,0.2)] hover:scale-[1.02]'}`}
>
{generating ? (
<span className="flex items-center"><BaseIcon path={mdiRefresh} spin className="mr-2" /> GERANDO...</span>
<div className="w-full px-6 space-y-2">
<div className="flex justify-between items-center text-[9px] font-black uppercase tracking-tighter text-[#00E5FF]">
<span>{generationStep === 1 ? 'Escrevendo Letra...' : generationStep === 2 ? 'Compondo Melodia...' : generationStep === 3 ? 'Gravando Vocais IA...' : 'Finalizando Hit...'}</span>
<span>{generationStep * 25}%</span>
</div>
<div className="w-full h-1 bg-white/10 rounded-full overflow-hidden">
<div className="h-full bg-[#00E5FF] transition-all duration-500" style={{ width: `${generationStep * 25}%` }} />
</div>
</div>
) : (
<span className="flex items-center"><BaseIcon path={mdiCreation} className="mr-2" /> CRIAR MÚSICA</span>
<>
<span className="flex items-center text-sm uppercase tracking-widest"><BaseIcon path={mdiCreation} className="mr-2" /> GERAR MÚSICA REAL</span>
<span className="text-[9px] opacity-60 uppercase font-black mt-1">Criação completa com Voz e Arranjo</span>
</>
)}
</button>
</div>
</div>
<div className="mt-auto pt-8">
<div className="p-4 bg-gradient-to-br from-[#00E5FF]/10 to-[#BB86FC]/10 rounded-2xl border border-white/5">
<h4 className="text-xs font-black text-[#00E5FF] uppercase mb-1">Assinatura Grátis</h4>
<p className="text-[10px] text-gray-400 mb-3 uppercase tracking-tighter">10 Créditos restantes hoje</p>
<button className="w-full py-2 bg-white/5 hover:bg-white/10 text-white text-[10px] font-black rounded-lg transition-all uppercase tracking-widest">Fazer Upgrade</button>
<div className="mt-10">
<div className="p-5 bg-[#121212] rounded-3xl border border-white/5 relative overflow-hidden group">
<div className="absolute -top-10 -right-10 w-24 h-24 bg-[#00E5FF]/10 rounded-full blur-2xl group-hover:bg-[#00E5FF]/20 transition-all" />
<h4 className="text-[10px] font-black text-white uppercase mb-1 flex items-center">
<BaseIcon path={mdiCheckCircleOutline} size={14} className="mr-1 text-[#00E5FF]" />
Modo Profissional Ativo
</h4>
<p className="text-[9px] text-gray-500 uppercase font-bold tracking-tighter">Ilimitado para desenvolvedores</p>
</div>
</div>
</aside>
{/* Main Content - Library Feed */}
<main className="flex-1 flex flex-col bg-[#0a0a0a] overflow-hidden">
<main className="flex-1 flex flex-col bg-[#050505] overflow-hidden">
{/* Top Header */}
<header className="h-16 border-b border-white/5 flex items-center justify-between px-8 bg-[#0a0a0a]/80 backdrop-blur-xl sticky top-0 z-20">
<div className="flex items-center space-x-6">
<button className="text-white font-black text-sm uppercase tracking-widest border-b-2 border-[#00E5FF] py-5">Minhas Criações</button>
<button className="text-gray-500 hover:text-white font-black text-sm uppercase tracking-widest py-5 transition-colors">Explorar</button>
<button className="text-gray-500 hover:text-white font-black text-sm uppercase tracking-widest py-5 transition-colors">Playlists</button>
<header className="h-20 flex items-center justify-between px-10 bg-[#050505]/60 backdrop-blur-3xl sticky top-0 z-20 border-b border-white/5">
<div className="flex items-center space-x-10">
<button className="text-white font-black text-xs uppercase tracking-[0.2em] border-b-2 border-[#00E5FF] py-7">Minhas Criações</button>
<button className="text-gray-600 hover:text-white font-black text-xs uppercase tracking-[0.2em] py-7 transition-colors">Tendências</button>
<button className="text-gray-600 hover:text-white font-black text-xs uppercase tracking-[0.2em] py-7 transition-colors">Comunidade</button>
</div>
<div className="flex items-center space-x-4">
<BaseIcon path={mdiAccountCircle} className="text-gray-400 hover:text-white cursor-pointer" />
<div className="flex items-center space-x-6">
<div className="flex flex-col items-end">
<span className="text-xs font-black text-white uppercase italic">{currentUser?.firstName || 'User'}</span>
<span className="text-[9px] font-bold text-[#00E5FF] uppercase tracking-widest">Pro Member</span>
</div>
<div className="w-10 h-10 rounded-full bg-white/5 border border-white/10 flex items-center justify-center overflow-hidden">
<BaseIcon path={mdiAccountCircle} className="text-gray-400" size={24} />
</div>
</div>
</header>
{/* Scrollable Feed */}
<div className="flex-1 overflow-y-auto p-8 aside-scrollbars">
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
<div className="flex-1 overflow-y-auto p-10 aside-scrollbars bg-gradient-to-b from-[#0a0a0a] to-[#050505]">
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 gap-8">
{library.length > 0 ? library.map((track) => (
<div
key={track.id}
className={`group relative bg-[#121212] rounded-2xl overflow-hidden border border-white/5 hover:border-white/20 transition-all shadow-lg hover:-translate-y-1 ${currentTrack?.id === track.id ? 'ring-2 ring-[#00E5FF]' : ''}`}
className={`group relative bg-[#0d0d0d] rounded-[2rem] overflow-hidden border border-white/5 hover:border-white/20 transition-all duration-500 shadow-2xl ${currentTrack?.id === track.id ? 'ring-2 ring-[#00E5FF]' : 'hover:-translate-y-2'}`}
>
{/* Thumbnail */}
<div className="aspect-square bg-gradient-to-br from-indigo-900 to-black relative">
<div className="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/60 backdrop-blur-sm">
<div className="aspect-square bg-[#141414] relative overflow-hidden">
<div className="absolute inset-0 bg-gradient-to-tr from-black via-transparent to-white/5" />
<div className="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-all duration-300 bg-black/40 backdrop-blur-md">
<button
onClick={() => playTrack(track)}
className="w-16 h-16 rounded-full bg-[#00E5FF] flex items-center justify-center text-black hover:scale-110 transition-transform shadow-2xl"
className="w-20 h-20 rounded-full bg-white flex items-center justify-center text-black hover:scale-110 active:scale-95 transition-all shadow-[0_0_40px_rgba(255,255,255,0.3)]"
>
<BaseIcon path={(currentTrack?.id === track.id && isPlaying) ? mdiPause : mdiPlay} size={40} />
<BaseIcon path={(currentTrack?.id === track.id && isPlaying) ? mdiPause : mdiPlay} size={48} />
</button>
</div>
<div className="absolute bottom-2 right-2 px-2 py-0.5 bg-black/80 rounded text-[10px] font-black text-white uppercase tracking-tighter">
{track.bpm} BPM
{/* Genre Tag */}
<div className="absolute top-4 left-4 px-3 py-1 bg-black/60 backdrop-blur-md rounded-full border border-white/10 text-[9px] font-black text-[#00E5FF] uppercase tracking-widest">
{track.bpm || '128'} BPM
</div>
{/* Animated bars if playing */}
{currentTrack?.id === track.id && isPlaying && (
<div className="absolute bottom-4 left-1/2 -translate-x-1/2 flex items-end space-x-1 h-8">
{[...Array(5)].map((_, i) => (
<div key={i} className="w-1 bg-[#00E5FF] rounded-full animate-[bounce_1s_infinite]" style={{ animationDelay: `${i * 0.1}s`, height: `${Math.random() * 100}%` }} />
))}
</div>
)}
</div>
{/* Info */}
<div className="p-4">
<h3 className="font-black text-white text-sm uppercase tracking-tighter truncate">{track.title}</h3>
<p className="text-gray-500 text-[10px] uppercase font-bold tracking-widest mb-3 truncate italic">{track.key_signature || 'AI Generated'}</p>
<div className="p-6">
<div className="flex justify-between items-start mb-2">
<h3 className="font-black text-white text-base uppercase tracking-tighter truncate w-3/4 leading-none italic">{track.title}</h3>
<BaseIcon path={mdiHeart} size={18} className="text-gray-700 hover:text-red-500 cursor-pointer transition-colors" />
</div>
<p className="text-gray-500 text-[10px] uppercase font-black tracking-[0.2em] mb-4 truncate opacity-60">
{track.key_signature || 'AI Master Mix'}
</p>
<div className="flex items-center justify-between">
<div className="flex space-x-2">
<BaseIcon path={mdiHeart} size={16} className="text-gray-600 hover:text-red-500 cursor-pointer transition-colors" />
<BaseIcon path={mdiShare} size={16} className="text-gray-600 hover:text-white cursor-pointer transition-colors" />
<div className="flex items-center justify-between pt-4 border-t border-white/5">
<div className="flex items-center text-[8px] font-black text-gray-400 uppercase tracking-widest">
<BaseIcon path={mdiRobotOutline} size={12} className="mr-1 text-[#00E5FF]" />
ESTÉREO HI-FI
</div>
<div className="text-[8px] font-black text-gray-700 uppercase">AI VOCAL {track.ai_data?.voiceType || 'PRO'}</div>
<button
onClick={() => { setCurrentTrack(track); setShowLyrics(true); }}
className="text-[9px] font-black text-white/40 hover:text-[#BB86FC] uppercase tracking-tighter transition-colors"
>
VER LETRA
</button>
</div>
</div>
</div>
)) : (
<div className="col-span-full py-20 text-center">
<div className="w-20 h-20 bg-white/5 rounded-full flex items-center justify-center mx-auto mb-4">
<BaseIcon path={mdiPlaylistMusic} size={40} className="text-gray-700" />
<div className="col-span-full py-40 text-center animate-pulse">
<div className="w-24 h-24 bg-white/5 rounded-full flex items-center justify-center mx-auto mb-6 border border-white/5">
<BaseIcon path={mdiPlaylistMusic} size={48} className="text-gray-800" />
</div>
<h3 className="text-xl font-black text-gray-300">Nenhuma música ainda</h3>
<p className="text-gray-600 uppercase text-xs font-bold tracking-widest mt-2">Comece a criar sua primeira música à esquerda!</p>
<h3 className="text-2xl font-black text-gray-500 uppercase tracking-widest">Pronto para seu primeiro hit?</h3>
<p className="text-gray-700 uppercase text-[10px] font-black tracking-[0.3em] mt-4">Use o painel lateral para começar a geração real</p>
</div>
)}
</div>
</div>
</main>
{/* Right Lyrics Sidebar (Optional) */}
{/* Lyrics Sidebar overlay */}
{showLyrics && currentTrack && (
<aside className="w-80 bg-[#0a0a0a] border-l border-white/5 flex flex-col p-6 animate-fade-in overflow-y-auto aside-scrollbars">
<div className="flex items-center justify-between mb-8">
<h2 className="text-sm font-black text-white uppercase tracking-widest">LETRAS IA</h2>
<button onClick={() => setShowLyrics(false)} className="text-gray-500 hover:text-white">X</button>
</div>
<div className="space-y-6">
<div>
<h4 className="text-[10px] font-black text-[#00E5FF] uppercase mb-4 tracking-[0.2em]">[VERSO 1]</h4>
<p className="text-sm leading-relaxed text-gray-400 font-medium">
{currentTrack.ai_data?.lyrics?.verse1 || 'Gerando as letras...'}
</p>
</div>
<div>
<h4 className="text-[10px] font-black text-[#BB86FC] uppercase mb-4 tracking-[0.2em]">[REFRÃO]</h4>
<p className="text-sm leading-relaxed text-white font-bold">
{currentTrack.ai_data?.lyrics?.chorus || 'Gerando o refrão...'}
</p>
</div>
<div>
<h4 className="text-[10px] font-black text-[#00E5FF] uppercase mb-4 tracking-[0.2em]">[VERSO 2]</h4>
<p className="text-sm leading-relaxed text-gray-400 font-medium">
{currentTrack.ai_data?.lyrics?.verse2 || 'Continuando a história...'}
</p>
</div>
</div>
</aside>
<div className="fixed inset-0 z-[60] flex justify-end bg-black/60 backdrop-blur-sm transition-all" onClick={() => setShowLyrics(false)}>
<aside className="w-96 h-full bg-[#0d0d0d] border-l border-white/10 flex flex-col p-10 animate-slide-in-right overflow-y-auto aside-scrollbars" onClick={e => e.stopPropagation()}>
<div className="flex items-center justify-between mb-12">
<div>
<h2 className="text-xs font-black text-white uppercase tracking-[0.3em] mb-1">LETRA COMPLETA</h2>
<p className="text-[10px] font-bold text-[#BB86FC] uppercase tracking-widest">Gerado por IA Studio</p>
</div>
<button onClick={() => setShowLyrics(false)} className="w-10 h-10 rounded-full bg-white/5 hover:bg-white/10 flex items-center justify-center transition-all">
<BaseIcon path={mdiPlus} className="rotate-45" size={24} />
</button>
</div>
<div className="space-y-10">
<div className="group">
<h4 className="text-[10px] font-black text-[#00E5FF] uppercase mb-4 tracking-[0.4em] opacity-50 group-hover:opacity-100 transition-opacity flex items-center">
<div className="w-8 h-px bg-[#00E5FF] mr-3" /> [VERSO 1]
</h4>
<p className="text-base leading-relaxed text-gray-400 font-medium whitespace-pre-wrap">
{currentTrack.ai_data?.lyrics?.verse1 || 'Gerando as letras...'}
</p>
</div>
<div className="group">
<h4 className="text-[10px] font-black text-[#BB86FC] uppercase mb-4 tracking-[0.4em] opacity-50 group-hover:opacity-100 transition-opacity flex items-center">
<div className="w-8 h-px bg-[#BB86FC] mr-3" /> [REFRÃO]
</h4>
<p className="text-lg leading-tight text-white font-black italic">
{currentTrack.ai_data?.lyrics?.chorus || 'Gerando o refrão...'}
</p>
</div>
<div className="group">
<h4 className="text-[10px] font-black text-[#00E5FF] uppercase mb-4 tracking-[0.4em] opacity-50 group-hover:opacity-100 transition-opacity flex items-center">
<div className="w-8 h-px bg-[#00E5FF] mr-3" /> [VERSO 2]
</h4>
<p className="text-base leading-relaxed text-gray-400 font-medium whitespace-pre-wrap">
{currentTrack.ai_data?.lyrics?.verse2 || 'Continuando a história...'}
</p>
</div>
<div className="group">
<h4 className="text-[10px] font-black text-gray-600 uppercase mb-4 tracking-[0.4em] flex items-center">
<div className="w-8 h-px bg-gray-800 mr-3" /> [OUTRO]
</h4>
<p className="text-sm italic text-gray-500">
{currentTrack.ai_data?.lyrics?.outro || 'Finalizando...'}
</p>
</div>
</div>
</aside>
</div>
)}
{/* Bottom Player */}
{/* Bottom Player - Immersive Mode */}
{currentTrack && (
<div className="fixed bottom-0 left-0 w-full h-24 bg-black/90 backdrop-blur-2xl border-t border-white/5 flex items-center px-6 z-50">
<div className="fixed bottom-0 left-0 w-full h-28 bg-[#0a0a0a]/90 backdrop-blur-[50px] border-t border-white/5 flex items-center px-10 z-[100] shadow-[0_-20px_50px_rgba(0,0,0,0.5)]">
{/* Track Info */}
<div className="w-1/4 flex items-center space-x-4">
<div className="w-14 h-14 bg-gradient-to-br from-[#00E5FF] to-[#BB86FC] rounded-lg shrink-0 overflow-hidden">
<div className="w-full h-full flex items-center justify-center bg-black/20">
<BaseIcon path={mdiMusic} className="text-white" />
<div className="w-1/4 flex items-center space-x-5">
<div className="w-16 h-16 bg-[#141414] rounded-2xl shrink-0 overflow-hidden relative group border border-white/10 shadow-2xl">
<div className="absolute inset-0 bg-gradient-to-br from-[#00E5FF]/20 to-[#BB86FC]/20" />
<div className="w-full h-full flex items-center justify-center relative">
<BaseIcon path={mdiMusic} className="text-white/80" size={24} />
</div>
<div className="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 bg-black/60 transition-all cursor-pointer">
<BaseIcon path={mdiPlus} className="text-white" size={24} />
</div>
</div>
<div className="min-w-0">
<h4 className="text-white font-black text-sm uppercase italic truncate tracking-tighter">{currentTrack.title}</h4>
<p className="text-gray-500 text-[10px] font-bold uppercase tracking-widest truncate">{currentTrack.genre?.name || style}</p>
<h4 className="text-white font-black text-base uppercase italic truncate tracking-tighter mb-1">{currentTrack.title}</h4>
<div className="flex items-center space-x-2">
<span className="text-[9px] font-black text-[#00E5FF] uppercase tracking-widest px-2 py-0.5 bg-[#00E5FF]/10 rounded border border-[#00E5FF]/20">
HI-RES
</span>
<p className="text-gray-500 text-[9px] font-black uppercase tracking-[0.2em] truncate opacity-60">AI ARTIST</p>
</div>
</div>
<BaseIcon path={mdiHeart} size={20} className="text-gray-600 hover:text-red-500 cursor-pointer ml-4 transition-colors" />
</div>
{/* Controls */}
<div className="flex-1 flex flex-col items-center space-y-2">
<div className="flex items-center space-x-6">
<button className="text-gray-500 hover:text-white transition-colors">
<BaseIcon path={mdiRefresh} size={20} />
{/* Central Controls */}
<div className="flex-1 flex flex-col items-center space-y-4 px-20">
<div className="flex items-center space-x-10">
<button className="text-gray-600 hover:text-white transition-all transform hover:scale-110">
<BaseIcon path={mdiClockOutline} size={20} />
</button>
<button
onClick={togglePlayback}
className="w-10 h-10 rounded-full bg-white flex items-center justify-center text-black hover:scale-110 transition-transform"
className="w-14 h-14 rounded-full bg-white flex items-center justify-center text-black hover:scale-110 active:scale-95 transition-all shadow-[0_0_30px_rgba(255,255,255,0.2)]"
>
<BaseIcon path={isPlaying ? mdiPause : mdiPlay} size={24} />
<BaseIcon path={isPlaying ? mdiPause : mdiPlay} size={32} />
</button>
<button
onClick={() => setShowLyrics(!showLyrics)}
className={`transition-colors ${showLyrics ? 'text-[#00E5FF]' : 'text-gray-500 hover:text-white'}`}
className={`transition-all transform hover:scale-110 ${showLyrics ? 'text-[#00E5FF]' : 'text-gray-600 hover:text-white'}`}
>
<BaseIcon path={mdiPlus} size={20} />
<BaseIcon path={mdiPlaylistMusic} size={22} />
</button>
</div>
<div className="w-full max-w-xl flex items-center space-x-3">
<span className="text-[8px] font-black text-gray-600">0:00</span>
<input
type="range"
min="0"
max="100"
value={progress}
onChange={handleProgressChange}
className="flex-1 h-1 bg-gray-800 rounded-full appearance-none cursor-pointer accent-[#00E5FF]"
/>
<span className="text-[8px] font-black text-gray-600">3:42</span>
<div className="w-full flex items-center space-x-4">
<span className="text-[9px] font-black text-gray-600 w-10 text-right font-mono tracking-tighter">{formatTime(currentTime)}</span>
<div className="flex-1 relative group h-6 flex items-center">
<input
type="range"
min="0"
max="100"
value={progress}
onChange={handleProgressChange}
className="absolute w-full h-1 bg-white/10 rounded-full appearance-none cursor-pointer accent-[#00E5FF] group-hover:h-1.5 transition-all z-10"
/>
<div className="absolute top-1/2 -translate-y-1/2 left-0 h-1 bg-[#00E5FF] rounded-full group-hover:h-1.5 transition-all pointer-events-none" style={{ width: `${progress}%` }} />
</div>
<span className="text-[9px] font-black text-gray-600 w-10 font-mono tracking-tighter">{formatTime(duration)}</span>
</div>
</div>
{/* Volume & More */}
<div className="w-1/4 flex items-center justify-end space-x-6">
<div className="flex items-center space-x-2">
<BaseIcon path={mdiVolumeHigh} size={20} className="text-gray-500" />
<div className="w-24 h-1 bg-gray-800 rounded-full overflow-hidden">
<div className="h-full bg-gray-400 w-3/4"></div>
{/* Volume & More Options */}
<div className="w-1/4 flex items-center justify-end space-x-8">
<div className="flex items-center space-x-4 group">
<BaseIcon path={mdiVolumeHigh} size={18} className="text-gray-500 group-hover:text-white transition-colors" />
<div className="w-24 h-1 bg-white/10 rounded-full overflow-hidden relative">
<div className="absolute inset-0 bg-gray-600 w-3/4" />
</div>
</div>
<button className="text-gray-500 hover:text-white transition-colors">
<BaseIcon path={mdiDownload} size={20} />
</button>
<div className="flex items-center space-x-2">
<button
onClick={handleDownload}
className="p-3 rounded-xl bg-white/5 hover:bg-white/10 text-gray-400 hover:text-white transition-all"
>
<BaseIcon path={mdiDownload} size={20} />
</button>
<button className="p-3 rounded-xl bg-white/5 hover:bg-white/10 text-gray-400 hover:text-white transition-all">
<BaseIcon path={mdiShare} size={20} />
</button>
</div>
</div>
<audio
ref={audioRef}
onTimeUpdate={handleTimeUpdate}
onLoadedMetadata={handleLoadedMetadata}
onEnded={() => setIsPlaying(false)}
className="hidden"
/>
</div>
)}
<ToastContainer theme="dark" position="bottom-right" />
<ToastContainer
theme="dark"
position="bottom-right"
autoClose={3000}
hideProgressBar={false}
newestOnTop={false}
closeOnClick
rtl={false}
pauseOnFocusLoss
draggable
pauseOnHover
/>
<style jsx global>{`
@keyframes fade-in {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes slide-in-right {
from { transform: translateX(100%); }
to { transform: translateX(0); }
}
.animate-fade-in {
animation: fade-in 0.5s ease-out forwards;
}
.animate-slide-in-right {
animation: slide-in-right 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
input[type="range"]::-webkit-slider-thumb {
appearance: none;
width: 12px;
height: 12px;
background: white;
border-radius: 50%;
cursor: pointer;
border: 2px solid #00E5FF;
box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}
`}</style>
</div>
);
};
SunoStudio.getLayout = function getLayout(page: ReactElement) {
return page; // No standard layout, using custom Suno-style
return page;
};
export default SunoStudio;