1use bevy::prelude::*;
2use felix_audio::{FelixAudioListener, source::{FelixAudioSource, stream_source::StreamAudioSource}, utils::wav};
3
4use crate::debug_camera;
5
6pub fn setup(
7 mut commands: Commands,
8 mut meshes: ResMut<Assets<Mesh>>,
9 mut materials: ResMut<Assets<StandardMaterial>>
10){
11 let samples = wav::load_wav_file("out.wav");
12 let mut samples_index = 0;
13
14 commands.spawn((
15 Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
16 MeshMaterial3d(materials.add(Color::WHITE)),
17 Transform::from_xyz(5.0, 0.0, 0.0),
18 FelixAudioSource::from(StreamAudioSource::new(48_000, move | length | {
19 let mono = &samples[samples_index..(samples_index + length)];
20 samples_index += length;
21
22 mono.to_vec()
23 }))
24 ));
25
26 commands.spawn((
27 Mesh3d(meshes.add(Cuboid::new(0.5, 0.5, 0.5))),
28 MeshMaterial3d(materials.add(Color::WHITE)),
29 Transform::from_xyz(-5.0, 0.0, 0.0)
30 ));
31
32 commands.spawn((
33 Mesh3d(meshes.add(Cuboid::new(0.5, 0.5, 0.5))),
34 MeshMaterial3d(materials.add(Color::WHITE)),
35 Transform::from_xyz(0.0, 0.0, 5.0)
36 ));
37
38 commands.spawn((
39 Mesh3d(meshes.add(Cuboid::new(0.5, 0.5, 0.5))),
40 MeshMaterial3d(materials.add(Color::WHITE)),
41 Transform::from_xyz(0.0, 0.0, -5.0)
42 ));
43
44 commands.spawn((
45 debug_camera::DebugCamera::default(),
46 Camera3d::default(),
47 Transform::from_xyz(0.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
48 FelixAudioListener
49 ));
50}