import 'package:flutter/material.dart';
import 'package:atomic_x_core/atomicxcore.dart';
class AudioEffectPage extends StatelessWidget {
const AudioEffectPage({super.key});
@override
Widget build(BuildContext context) {
final audioEffectStore = AudioEffectStore.shared;
final deviceStore = DeviceStore.shared;
return Scaffold(
appBar: AppBar(title: const Text('Sound effect settings')),
body: ListView(
children: [
const Padding(
padding: EdgeInsets.all(16),
child: Text('Voice volume', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
),
ValueListenableBuilder<int>(
valueListenable: deviceStore.state.captureVolume,
builder: (context, volume, child) {
return ListTile(
title: const Text('Capture Volume'),
subtitle: Slider(
value: volume.toDouble(),
min: 0,
max: 150,
divisions: 150,
onChanged: (value) {
deviceStore.setCaptureVolume(value.toInt());
},
),
trailing: Text('$volume'),
);
},
),
const Divider(),
const Padding(
padding: EdgeInsets.all(16),
child: Text('Ear monitoring', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
),
ValueListenableBuilder<bool>(
valueListenable: audioEffectStore.audioEffectState.isEarMonitorOpened,
builder: (context, isOpened, child) {
return SwitchListTile(
title: const Text('Enable Ear Monitoring'),
subtitle: const Text('Insert a headset')
value: isOpened,
onChanged: (value) {
audioEffectStore.setVoiceEarMonitorEnable(value);
},
);
},
),
ValueListenableBuilder<int>(
valueListenable: audioEffectStore.audioEffectState.earMonitorVolume,
builder: (context, volume, child) {
return ListTile(
title: const Text('Ear Monitoring Volume'),
subtitle: Slider(
value: volume.toDouble(),
min: 0,
max: 150,
divisions: 150,
onChanged: (value) {
audioEffectStore.setVoiceEarMonitorVolume(value.toInt());
},
),
trailing: Text('$volume'),
);
},
),
const Divider(),
const Padding(
padding: EdgeInsets.all(16),
child: Text('Voice-changing', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
),
ValueListenableBuilder<AudioChangerType>(
valueListenable: audioEffectStore.audioEffectState.audioChangerType,
builder: (context, changerType, child) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Wrap(
spacing: 8,
runSpacing: 8,
children: AudioChangerType.values.map((type) {
return ChoiceChip(
label: Text(_getChangerTypeName(type)),
selected: changerType == type,
onSelected: (selected) {
if (selected) {
audioEffectStore.setAudioChangerType(type);
}
},
);
}).toList(),
),
);
},
),
const SizedBox(height: 16),
const Divider(),
const Padding(
padding: EdgeInsets.all(16),
child: Text('Reverb', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
),
ValueListenableBuilder<AudioReverbType>(
valueListenable: audioEffectStore.audioEffectState.audioReverbType,
builder: (context, reverbType, child) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Wrap(
spacing: 8,
runSpacing: 8,
children: AudioReverbType.values.map((type) {
return ChoiceChip(
label: Text(_getReverbTypeName(type)),
selected: reverbType == type,
onSelected: (selected) {
if (selected) {
audioEffectStore.setAudioReverbType(type);
}
},
);
}).toList(),
),
);
},
),
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.all(16),
child: ElevatedButton(
onPressed: () {
audioEffectStore.reset();
deviceStore.reset();
},
child: const Text('Reset sound effect settings'),
),
),
],
),
);
}
String _getChangerTypeName(AudioChangerType type) {
switch (type) {
case AudioChangerType.none:
return 'Disable';
case AudioChangerType.child:
return 'mischievous child';
case AudioChangerType.girl:
return 'loli';
case AudioChangerType.uncle:
return 'uncle';
case AudioChangerType.ethereal:
return 'ethereal';
}
}
String _getReverbTypeName(AudioReverbType type) {
switch (type) {
case AudioReverbType.none:
return 'Disable';
case AudioReverbType.ktv:
return 'KTV';
case AudioReverbType.room:
return 'Small room';
case AudioReverbType.hall:
return 'Great hall';
case AudioReverbType.deep:
return 'deep';
case AudioReverbType.loud:
return 'resonant';
case AudioReverbType.metallic:
return 'metallic sound';
case AudioReverbType.magnetic:
return 'magnetic';
case AudioReverbType.recordingStudio:
return 'studio';
}
}
}