mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 09:31:34 +11:00
Add support for 18157Hz
This commit is contained in:
parent
26620e850e
commit
c6e7827e34
|
@ -17,6 +17,9 @@ debug = true
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
|
[features]
|
||||||
|
freq18157 = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hound = "3.4.0"
|
hound = "3.4.0"
|
||||||
syn = "1.0.73"
|
syn = "1.0.73"
|
||||||
|
|
|
@ -12,6 +12,11 @@ use std::{
|
||||||
};
|
};
|
||||||
use syn::parse_macro_input;
|
use syn::parse_macro_input;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "freq18157"))]
|
||||||
|
const FREQUENCY: u32 = 10512;
|
||||||
|
#[cfg(feature = "freq18157")]
|
||||||
|
const FREQUENCY: u32 = 18157;
|
||||||
|
|
||||||
#[proc_macro]
|
#[proc_macro]
|
||||||
pub fn include_wav(input: TokenStream) -> TokenStream {
|
pub fn include_wav(input: TokenStream) -> TokenStream {
|
||||||
let input = parse_macro_input!(input as syn::LitStr);
|
let input = parse_macro_input!(input as syn::LitStr);
|
||||||
|
@ -43,8 +48,9 @@ pub fn include_wav(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
wav_reader.spec().sample_rate,
|
wav_reader.spec().sample_rate,
|
||||||
10512,
|
FREQUENCY,
|
||||||
"agb currently only supports sample rate of 10512Hz"
|
"agb currently only supports sample rate of {}Hz",
|
||||||
|
FREQUENCY
|
||||||
);
|
);
|
||||||
|
|
||||||
let samples = samples_from_reader(wav_reader);
|
let samples = samples_from_reader(wav_reader);
|
||||||
|
|
|
@ -17,6 +17,7 @@ debug = true
|
||||||
[features]
|
[features]
|
||||||
default = ["alloc"]
|
default = ["alloc"]
|
||||||
alloc = []
|
alloc = []
|
||||||
|
freq18157 = ["agb_sound_converter/freq18157"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.2"
|
bitflags = "1.2"
|
||||||
|
|
|
@ -91,9 +91,16 @@ impl Mixer {
|
||||||
|
|
||||||
// I've picked one frequency that works nicely. But there are others that work nicely
|
// I've picked one frequency that works nicely. But there are others that work nicely
|
||||||
// which we may want to consider in the future: http://deku.gbadev.org/program/sound1.html
|
// which we may want to consider in the future: http://deku.gbadev.org/program/sound1.html
|
||||||
|
#[cfg(not(feature = "freq18157"))]
|
||||||
const SOUND_FREQUENCY: i32 = 10512;
|
const SOUND_FREQUENCY: i32 = 10512;
|
||||||
|
#[cfg(not(feature = "freq18157"))]
|
||||||
const SOUND_BUFFER_SIZE: usize = 176;
|
const SOUND_BUFFER_SIZE: usize = 176;
|
||||||
|
|
||||||
|
#[cfg(feature = "freq18157")]
|
||||||
|
const SOUND_FREQUENCY: i32 = 18157;
|
||||||
|
#[cfg(feature = "freq18157")]
|
||||||
|
const SOUND_BUFFER_SIZE: usize = 304;
|
||||||
|
|
||||||
fn set_asm_buffer_size() {
|
fn set_asm_buffer_size() {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static mut agb_rs__buffer_size: usize;
|
static mut agb_rs__buffer_size: usize;
|
||||||
|
|
Loading…
Reference in a new issue