Skip to content

Commit

Permalink
Used dynwave instead of manual audio
Browse files Browse the repository at this point in the history
  • Loading branch information
Amjad50 committed Jan 29, 2024
1 parent da73e83 commit ab8b5b8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 227 deletions.
14 changes: 12 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ categories = ["emulators"]
mizu-core = { version = "1.0.0", path = "mizu-core" }
sfml = { version = "0.21", default-features = false, features = ["graphics"] }
ringbuf = "0.3"
cpal = "0.15"
clap = { version = "4.0", features = ["string"] }
native-dialog = "0.7"
directories-next = "2.0"
rubato = "0.14"
dynwave = "0.1.0"

[workspace]
members = [
Expand Down
9 changes: 9 additions & 0 deletions mizu-core/src/apu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,15 @@ impl Apu {

// one sample for the right, one for the left

let right_pulse1 = right_pulse1 / 5.0;
let left_pulse1 = left_pulse1 / 5.0;
let right_pulse2 = right_pulse2 / 5.0;
let left_pulse2 = left_pulse2 / 5.0;
let right_wave = right_wave / 5.0;
let left_wave = left_wave / 5.0;
let right_noise = right_noise / 5.0;
let left_noise = left_noise / 5.0;

self.pulse1_buffers.push(right_pulse1);
self.pulse1_buffers.push(left_pulse1);

Expand Down
218 changes: 0 additions & 218 deletions src/audio.rs

This file was deleted.

9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod audio;
mod notification;
mod printer_front;

Expand All @@ -9,8 +8,8 @@ use std::{
path::{Path, PathBuf},
};

use audio::{AudioPlayer, AudioPlayerError};
use directories_next::ProjectDirs;
use dynwave::{error::AudioPlayerError, AudioPlayer, BufferSize};
use notification::Notifications;
use printer_front::MizuPrinter;

Expand Down Expand Up @@ -85,7 +84,7 @@ struct GameboyFront {
gameboy: GameBoy,
window: RenderWindow,
fps: u32,
audio_player: Option<AudioPlayer>,
audio_player: Option<AudioPlayer<f32>>,
pixels_buffer: [u8; TV_HEIGHT as usize * TV_WIDTH as usize * 4],
printer: Option<MizuPrinter>,
notifications: Notifications,
Expand Down Expand Up @@ -113,8 +112,8 @@ impl GameboyFront {
notifications.update_size(size.x, size.y);

let audio_player = if enable_audio {
let a = AudioPlayer::new(44100)?;
a.play();
let a = AudioPlayer::new(44100, BufferSize::QuarterSecond)?;
a.play().unwrap();
Some(a)
} else {
None
Expand Down

0 comments on commit ab8b5b8

Please sign in to comment.