changes for testing

This commit is contained in:
TerraMaster85 2024-12-16 11:44:14 -05:00
parent 7d76a0cd5b
commit 1ecdbeb75f

View file

@ -19,6 +19,7 @@ pub fn audio_transmitter_main(
let cpal_output_config = cpal_output.supported_output_configs() let cpal_output_config = cpal_output.supported_output_configs()
.context("could not find a suitable audio output configuration. are you root, trying to use a normal user's audio stack? try setting the capability CAP_NET_ADMIN=ep on this binary, and running as the user who is running the audio stack.")? .context("could not find a suitable audio output configuration. are you root, trying to use a normal user's audio stack? try setting the capability CAP_NET_ADMIN=ep on this binary, and running as the user who is running the audio stack.")?
.max_by_key(|cfg| { .max_by_key(|cfg| {
println!("AVAIL RATE: {:?}, {:?}, {:?}", cfg.sample_format(), cfg.min_sample_rate(), cfg.max_sample_rate());
match cfg.sample_format() { match cfg.sample_format() {
SampleFormat::U8 => 10, SampleFormat::U8 => 10,
SampleFormat::I8 => 11, SampleFormat::I8 => 11,
@ -33,7 +34,7 @@ pub fn audio_transmitter_main(
x => { warn!("Backend offered unknown sample format {x}",); -999 } x => { warn!("Backend offered unknown sample format {x}",); -999 }
} }
}).expect("output device has no supported configurations available") }).expect("output device has no supported configurations available")
.with_max_sample_rate(); .with_sample_rate(cpal::SampleRate(384000));//max_sample_rate();
info!( info!(
"output samples are {} @ {}hz", "output samples are {} @ {}hz",
@ -131,18 +132,18 @@ fn give_output_pcm<T>(pcm: &mut [T], channel: &mut Receiver<PcmSampleMessage>, i
where where
T: Sample + std::fmt::Debug + FromSample<i64> + FromSample<f64>, T: Sample + std::fmt::Debug + FromSample<i64> + FromSample<f64>,
{ {
println!("wanted {} samples", pcm.len()); print!("ALSA wanted {} samples... ", pcm.len());
let mut signal = dasp_signal::rate(384000.0).const_hz(100.0).sine();
for outgoing in pcm.iter_mut() { for outgoing in pcm.iter_mut() {
*outgoing = match channel.try_recv() { *outgoing = match channel.try_recv() {
Ok(sample) => sample.to_sample::<T>(), Ok(sample) => sample.to_sample::<T>(),
//Err(_) => (std::f64::consts::PI * 2.0*(*i)/(384000.0/100.0)).sin().to_sample::<T>(), //T::EQUILIBRIUM, Err(_) => (std::f64::consts::PI * 2.0*(*i)/(384000.0/100.0)).sin().to_sample::<T>(), //T::EQUILIBRIUM,
Err(_) => { /*Err(_) => {
signal.next().to_sample::<T>() signal.next().to_sample::<T>()
} }*/
}; };
*i = *i % 384000.0 + 1.0; *i = *i % 384000.0 + 1.0;
//if *i > 200000.0 { break; } //if *i > 200000.0 { break; }
} }
println!("gave them");
//let mut ctr = 0usize; //let mut ctr = 0usize;
} }