1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2025-11-30 00:03:33 +00:00

make organya sound more like in original game

This commit is contained in:
Alula 2020-12-25 23:37:57 +01:00
parent 8603086694
commit 63bfce689d
No known key found for this signature in database
GPG key ID: 3E00485503A1D8BA
4 changed files with 11 additions and 12 deletions

View file

@ -103,7 +103,7 @@ impl SoundManager {
}
pub fn play_sfx(&mut self, id: u8) {
self.tx.send(PlaybackMessage::PlaySample(id));
let _ = self.tx.send(PlaybackMessage::PlaySample(id));
}
pub fn play_song(&mut self, song_id: usize, constants: &EngineConstants, ctx: &mut Context) -> GameResult {
@ -197,7 +197,7 @@ fn run<T>(rx: Receiver<PlaybackMessage>, bank: SoundBank,
org_engine.set_sample_rate(sample_rate as usize);
org_engine.loops = usize::MAX;
let buf_size = sample_rate as usize * 15 / 1000;
let buf_size = sample_rate as usize * 10 / 1000;
let mut bgm_buf = vec![0x8080; buf_size];
let mut pxt_buf = vec![0x8000; buf_size];
let mut bgm_index = 0;

View file

@ -4,7 +4,6 @@ use crate::sound::organya::Song as Organya;
use crate::sound::stuff::*;
use crate::sound::wav::*;
use crate::sound::wave_bank::SoundBank;
use num_traits::real::Real;
pub struct PlaybackEngine {
song: Organya,
@ -73,7 +72,7 @@ impl PlaybackEngine {
}
}
for (idx, (track, buf)) in song.tracks[8..].iter().zip(buffers[128..].iter_mut()).enumerate() {
for (idx, (_track, buf)) in song.tracks[8..].iter().zip(buffers[128..].iter_mut()).enumerate() {
*buf =
MaybeUninit::new(
RenderBuffer::new(
@ -145,8 +144,8 @@ impl PlaybackEngine {
}
}
for (inst, buf) in song.tracks[8..].iter().zip(self.track_buffers[128..].iter_mut()) {
*buf = RenderBuffer::new(samples.samples[inst.inst.inst as usize].clone());
for (idx, (_track, buf)) in song.tracks[8..].iter().zip(self.track_buffers[128..].iter_mut()).enumerate() {
*buf = RenderBuffer::new(samples.samples[idx].clone());
}
self.song = song;

View file

@ -1,25 +1,25 @@
pub const FRQ_TBL: [i16; 12] = [
261,278,294,311,329,349,371,391,414,440,466,494
262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494
];
pub const PAN_TBL: [i16; 13] = [
0,43,86,129,172,215,256,297,340,383,426,469,512
0, 43, 86, 129, 172, 215, 256, 297, 340, 383, 426, 469, 512
];
pub const OCT_TBL: [i16; 8] = [
32,64,64,128,128,128,128,128
32, 64, 64, 128, 128, 128, 128, 128
];
pub fn org_key_to_freq(key: u8, a: i16) -> i32 {
let (oct, pitch) = org_key_to_oct_pitch(key);
let freq = FRQ_TBL[pitch as usize] as f32;
let oct = OCT_TBL[oct as usize] as f32;
let oct = OCT_TBL[oct as usize] as f32;
(freq * oct) as i32 + (a as i32 - 1000)
}
pub fn org_key_to_drum_freq(key: u8) -> i32 {
pub fn org_key_to_drum_freq(key: u8) -> i32 {
key as i32 * 800 + 100
}
@ -32,7 +32,7 @@ pub fn org_vol_to_vol(vol: u8) -> i32 {
}
pub fn org_key_to_oct_pitch(key: u8) -> (u8, u8) {
(key/12, key%12)
(key / 12, key % 12)
}
// s1: sample 1