use std::sync::Arc; use toid::data::music_info::{Beat, Instrument}; use toid::high_layer_trial::music_language::num_lang::send_num_lang; use toid::music_state::states::{MusicState, MusicStateEvent, SchedulingStateEvent}; use toid::music_state::wave_reader::{WaveReader, WaveReaderEvent}; use toid::outputters::portaudio_outputter::PortAudioOutputter; use toid::players::local_player::LocalPlayer; use toid::players::player::Player; fn main() { let player = LocalPlayer::new(); let player = Arc::new(player); player .get_resource_manager() .register(String::from("./toid-sample-resource/sf2/sf2.toml")) .unwrap(); player .get_resource_manager() .register(String::from("./toid-sample-resource/samples/samples.toml")) .unwrap(); let mut portaudio_outputter = PortAudioOutputter::new(Arc::clone(&player) as Arc< dyn Player< MusicState, MusicStateEvent, WaveReader, (Vec, Vec), WaveReaderEvent, >, >) .unwrap(); portaudio_outputter.set_volume(0.3); player .send_event(MusicStateEvent::SchedulingStateEvent( SchedulingStateEvent::ChangeBPM(Beat::from(0), 120.0), )) .unwrap(); send_num_lang( "12345 643 2 1 ".to_string(), 1.0, 0.0, Beat::from(0), "main".to_string(), Instrument::SF2(String::from("example_sf2"), 0), 1.0, -0.5, Arc::clone(&player) as Arc< dyn Player< MusicState, MusicStateEvent, WaveReader, (Vec, Vec), WaveReaderEvent, >, >, ) .unwrap(); send_num_lang( "1 4 5 1 ".to_string(), -1.0, 0.0, Beat::from(0), "sub".to_string(), Instrument::SF2(String::from("example_sf2"), 0), 0.7, 0.5, Arc::clone(&player) as Arc< dyn Player< MusicState, MusicStateEvent, WaveReader, (Vec, Vec), WaveReaderEvent, >, >, ) .unwrap(); portaudio_outputter.run().unwrap(); portaudio_outputter.sleep(12000); player.save_state("states.json".to_string()).unwrap(); }