remove saving audio

This commit is contained in:
Alex Janka 2023-02-19 19:10:49 +11:00
parent 75578786e4
commit 0f5bcb8e46
3 changed files with 0 additions and 45 deletions

7
Cargo.lock generated
View file

@ -413,7 +413,6 @@ dependencies = [
"cpal", "cpal",
"futures", "futures",
"gilrs", "gilrs",
"hound",
"minifb", "minifb",
"rand", "rand",
"ringbuf", "ringbuf",
@ -492,12 +491,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "hound"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d13cdbd5dbb29f9c88095bbdc2590c9cba0d0a1269b983fef6b2cdd7e9f4db1"
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.9.2" version = "1.9.2"

View file

@ -16,4 +16,3 @@ cpal = "0.15.0"
ringbuf = "0.3.2" ringbuf = "0.3.2"
async-ringbuf = "0.1.2" async-ringbuf = "0.1.2"
futures = "0.3.26" futures = "0.3.26"
hound = "3.5.0"

View file

@ -1,5 +1,3 @@
use std::{fs::File, io::BufWriter, path::Path};
use self::{ use self::{
channels::EnvelopeMode, channels::EnvelopeMode,
types::{Channels, DacSample, Mixer, VinEnable, Volume}, types::{Channels, DacSample, Mixer, VinEnable, Volume},
@ -18,7 +16,6 @@ use cpal::{
Device, Stream, StreamConfig, Device, Stream, StreamConfig,
}; };
use futures::executor; use futures::executor;
use hound::WavWriter;
use samplerate::{ConverterType, Samplerate}; use samplerate::{ConverterType, Samplerate};
mod channels; mod channels;
@ -59,11 +56,8 @@ pub struct Apu {
stream: Option<Stream>, stream: Option<Stream>,
send_rb: Option<AsyncHeapProducer<f32>>, send_rb: Option<AsyncHeapProducer<f32>>,
converter: Samplerate, converter: Samplerate,
writer: Option<WavWriter<BufWriter<File>>>,
} }
const IS_SAVING: bool = true;
impl Default for Apu { impl Default for Apu {
fn default() -> Self { fn default() -> Self {
let host = cpal::default_host(); let host = cpal::default_host();
@ -80,31 +74,6 @@ impl Default for Apu {
.expect("no supported config?!") .expect("no supported config?!")
.with_max_sample_rate(); .with_max_sample_rate();
let base_filename = "wavs/out";
let mut filename = format!("{base_filename}.wav");
let mut i = 0;
while Path::new(filename.as_str()).exists() {
i += 1;
filename = format!("{base_filename} ({i}).wav");
}
let writer = if IS_SAVING {
Some(
hound::WavWriter::create(
filename,
hound::WavSpec {
channels: config.channels(),
sample_rate: config.sample_rate().0,
bits_per_sample: (config.sample_format().sample_size() * 8) as u16,
sample_format: hound::SampleFormat::Float,
},
)
.unwrap(),
)
} else {
None
};
let converter = Samplerate::new( let converter = Samplerate::new(
ConverterType::SincBestQuality, ConverterType::SincBestQuality,
CLOCK_SPEED as u32, CLOCK_SPEED as u32,
@ -128,7 +97,6 @@ impl Default for Apu {
stream: None, stream: None,
send_rb: None, send_rb: None,
converter, converter,
writer,
} }
} }
} }
@ -215,11 +183,6 @@ impl Apu {
) )
.unwrap(); .unwrap();
executor::block_on(send.push_slice(&converted)).unwrap(); executor::block_on(send.push_slice(&converted)).unwrap();
if let Some(ref mut writer) = self.writer {
for v in converted {
writer.write_sample(v).unwrap();
}
}
} }
} }