VGM playback library for Common Lisp
リビジョン | c079b91d9219c21a4aefeab9d6e0fb4915325a53 (tree) |
---|---|
日時 | 2023-08-18 19:04:31 |
作者 | ![]() |
コミッター | Remilia Scarlet |
Fix noise not being played correctly
@@ -312,7 +312,7 @@ | ||
312 | 312 | (setf bit1 (ash (logand reg 2) -1)) |
313 | 313 | (setf bit14 (logxor bit0 bit1)) |
314 | 314 | (setf reg (ash reg -1)) |
315 | - (setf reg (logior reg (coerce-to-uint32 (ash bit14 14)))) | |
315 | + (setf reg (coerce-to-uint32 (logior reg (ash bit14 14)))) | |
316 | 316 | (setf (aref (%ootake-noise-table emu) i) (if (zerop bit0) -1 -18))) |
317 | 317 | nil) |
318 | 318 |
@@ -364,7 +364,7 @@ | ||
364 | 364 | |
365 | 365 | (dotimes (j 32) |
366 | 366 | ;; ch3は最大値で初期化。F1トリプルバトル。v2.65 |
367 | - (setf (aref (%psg-wave (aref (%ootake-psg emu) 3)) j) -17)) | |
367 | + (setf (aref (%psg-wave (aref (%ootake-psg emu) 3)) j) 17)) | |
368 | 368 | nil) |
369 | 369 | |
370 | 370 | (define-typed-fn ootake-read ((emu-ootake emu) (fixnum reg)) |
@@ -531,13 +531,14 @@ | ||
531 | 531 | (7 ;; Noise on, noise frequency |
532 | 532 | (when (>= (%ootake-channel emu) 4) |
533 | 533 | (let ((psg-chan (aref (%ootake-psg emu) (%ootake-channel emu)))) |
534 | - (setf (%psg-noise-on-p psg-chan) (/= (logand data #x80) 0)) | |
534 | + (setf (%psg-noise-on-p psg-chan) (flag? data #x80)) | |
535 | 535 | (setf (%psg-noise-freq psg-chan) (- #x1F (logand data #x1F))) |
536 | 536 | (setf (%psg-delta-noise-phase psg-chan) |
537 | - (if (zerop (%psg-noise-freq psg-chan)) | |
538 | - (coerce-to-uint32 (truncate (+ (* 2048.0d0 (%ootake-resample-rate emu)) 0.5d0))) | |
539 | - (coerce-to-uint32 (truncate (/ (* 2048.0d0 (%ootake-resample-rate emu)) | |
540 | - (+ (%psg-noise-freq psg-chan) 0.5d0))))))))) | |
537 | + (coerce-to-uint32 | |
538 | + (if (zerop (%psg-noise-freq psg-chan)) | |
539 | + (truncate (+ (* 2048.0d0 (%ootake-resample-rate emu)) 0.5d0)) | |
540 | + (truncate (/ (* 2048.0d0 (%ootake-resample-rate emu)) | |
541 | + (+ (%psg-noise-freq psg-chan) 0.5d0))))))))) | |
541 | 542 | |
542 | 543 | (8 ;; LFO frequency |
543 | 544 | (setf (%ootake-lfo-freq emu) data)) |
@@ -557,7 +558,7 @@ | ||
557 | 558 | (define-typed-fn ootake-write ((emu-ootake emu) (fixnum reg) (fixnum data)) |
558 | 559 | (null t) |
559 | 560 | (declare (optimize (speed 3) (debug 1) (safety 0) (compilation-speed 0))) |
560 | - (ootake-write-reg emu reg data)) | |
561 | + (ootake-write-reg emu (logand reg #xFF) data)) | |
561 | 562 | |
562 | 563 | (define-typed-fn ootake-update ((emu-ootake emu) (satou-chips::t/output-buffer outputs) (t/uint32 start samples)) |
563 | 564 | (null) |
@@ -619,11 +620,11 @@ | ||
619 | 620 | ;; 1/16384 + 1/32768)。この"+1/32768"で絶妙(主観。大魔 |
620 | 621 | ;; 界村,ソルジャーブレイドなど)になる。v2.62更新 |
621 | 622 | (setf smp (* sample (%psg-out-volume-l psg-chan))) |
622 | - (incf sample-all-l (+ (ash smp -11) (ash smp -14) (ash smp -15))) | |
623 | + (incf sample-all-l (+ smp (ash smp -11) (ash smp -14) (ash smp -15))) | |
623 | 624 | |
624 | 625 | ;; Kitao更新。ノイズの音量を実機並みに調整 |
625 | 626 | (setf smp (* sample (%psg-out-volume-r psg-chan))) |
626 | - (incf sample-all-r (+ (ash smp -11) (ash smp -14) (ash smp -15))))) | |
627 | + (incf sample-all-r (+ smp (ash smp -11) (ash smp -14) (ash smp -15))))) | |
627 | 628 | |
628 | 629 | (setf (%psg-phase psg-chan) |
629 | 630 | (coerce-to-uint32 (+ (%psg-phase psg-chan) (%psg-delta-noise-phase psg-chan))))) |