From 0f5bcb8e4673c6e5dff23ecf9c1e3767b8c38916 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Sun, 19 Feb 2023 19:10:49 +1100 Subject: [PATCH] remove saving audio --- Cargo.lock | 7 ------ Cargo.toml | 1 - src/processor/memory/mmio/apu.rs | 37 -------------------------------- 3 files changed, 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4708065..87493da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -413,7 +413,6 @@ dependencies = [ "cpal", "futures", "gilrs", - "hound", "minifb", "rand", "ringbuf", @@ -492,12 +491,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hound" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d13cdbd5dbb29f9c88095bbdc2590c9cba0d0a1269b983fef6b2cdd7e9f4db1" - [[package]] name = "indexmap" version = "1.9.2" diff --git a/Cargo.toml b/Cargo.toml index 9a20096..8f5958c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,4 +16,3 @@ cpal = "0.15.0" ringbuf = "0.3.2" async-ringbuf = "0.1.2" futures = "0.3.26" -hound = "3.5.0" diff --git a/src/processor/memory/mmio/apu.rs b/src/processor/memory/mmio/apu.rs index ba95fdb..6c79bd7 100644 --- a/src/processor/memory/mmio/apu.rs +++ b/src/processor/memory/mmio/apu.rs @@ -1,5 +1,3 @@ -use std::{fs::File, io::BufWriter, path::Path}; - use self::{ channels::EnvelopeMode, types::{Channels, DacSample, Mixer, VinEnable, Volume}, @@ -18,7 +16,6 @@ use cpal::{ Device, Stream, StreamConfig, }; use futures::executor; -use hound::WavWriter; use samplerate::{ConverterType, Samplerate}; mod channels; @@ -59,11 +56,8 @@ pub struct Apu { stream: Option, send_rb: Option>, converter: Samplerate, - writer: Option>>, } -const IS_SAVING: bool = true; - impl Default for Apu { fn default() -> Self { let host = cpal::default_host(); @@ -80,31 +74,6 @@ impl Default for Apu { .expect("no supported config?!") .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( ConverterType::SincBestQuality, CLOCK_SPEED as u32, @@ -128,7 +97,6 @@ impl Default for Apu { stream: None, send_rb: None, converter, - writer, } } } @@ -215,11 +183,6 @@ impl Apu { ) .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(); - } - } } }