rustboy_core/
audio.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Copy, Clone)]
4pub struct PulseOptions {
5  pub frequency: f32,
6  pub duty_cycle: f32,
7}
8
9#[derive(Copy, Clone)]
10pub struct CustomWaveOptions {
11  pub data: [u8;16]
12}
13
14#[derive(Copy, Clone)]
15pub struct NoiseOptions {
16  pub frequency: f32,
17  pub short: bool
18}
19
20#[derive(Copy, Clone, Serialize, Deserialize)]
21pub enum Channel {
22  CH1,
23  CH2,
24  CH3,
25  CH4,
26}
27
28#[derive(Copy, Clone)]
29pub enum StereoChannel {
30  Left,
31  Right,
32}
33
34pub trait AudioDriver {
35  fn play_pulse(&mut self, channel: Channel, pulse_options: PulseOptions);
36  fn play_custom_wave(&mut self, channel: Channel, wave_options: CustomWaveOptions);
37  fn play_noise(&mut self, channel: Channel, noise_options: NoiseOptions);
38  fn stop(&mut self, channel: Channel);
39  fn set_gain(&mut self, channel: Channel, gain: f32);
40  fn set_stereo_gain(&mut self, channel: Channel, stereo_channel: StereoChannel, gain: f32);
41  fn set_frequency(&mut self, channel: Channel, frequency: f32);
42
43  fn mute_all(&mut self);
44  fn unmute_all(&mut self);
45  fn set_master_volume(&mut self, value: u8);
46}