• R/O
  • SSH

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

VGM playback library for Common Lisp


Commit MetaInfo

修訂6cc221fe7d63ae26dadcbc00cb86cc8ace1693bd (tree)
時間2023-08-19 22:51:14
作者Remilia Scarlet <remilia@post...>
CommiterRemilia Scarlet

Log Message

Change fill-buffers so that it matches YunoSynth's behavior

Change Summary

差異

diff -r 1c7f18f23b9c -r 6cc221fe7d63 src/vgm-player.lisp
--- a/src/vgm-player.lisp Sat Aug 19 07:50:50 2023 -0600
+++ b/src/vgm-player.lisp Sat Aug 19 07:51:14 2023 -0600
@@ -582,8 +582,11 @@
582582 #-satou-wd40 (safety 1)))
583583
584584 (let ((cur-volume (truncate (%player-output-volume player)))
585- (buf (%player-temp-buf player)))
586- (declare (type fixnum cur-volume))
585+ (buf (%player-temp-buf player))
586+ (out-l 0)
587+ (out-r 0))
588+ (declare (type fixnum cur-volume)
589+ (type t/int32 out-l out-r))
587590
588591 #-satou-wd40 (unless (= (length left) (length right))
589592 (error "Buffer size mismatch"))
@@ -594,14 +597,20 @@
594597 (%player-interpret-file player 1)
595598 (resampler-resample (%player-resampler player) (%player-chip-table player) buf 1)
596599
597- ;; Adjust the volume.
598- (setf (sample-left buf) (ash (coerce-to-int32 (* (ash (sample-left buf) -5) cur-volume)) -11))
599- (setf (sample-right buf) (ash (coerce-to-int32 (* (ash (sample-right buf) -5) cur-volume)) -11))
600+ ;; Adjust the volume for the output
601+ (setf out-l (sdm:clamp (* (sample-left buf) cur-volume) #.(- (expt 2 31)) #.(1- (expt 2 31))))
602+ (setf out-r (sdm:clamp (* (sample-right buf) cur-volume) #.(- (expt 2 31)) #.(1- (expt 2 31))))
600603
601604 ;; Store the new sample
602605 (muffling
603- (setf (aref left sample-num) (* (%player-clamp-int32-to-int16 (sample-left buf)) +inv-int-16+))
604- (setf (aref right sample-num) (* (%player-clamp-int32-to-int16 (sample-right buf)) +inv-int-16+)))))
606+ (setf (aref left sample-num) (* out-l #.(/ 1.0 (1- (expt 2 31)))))
607+ (setf (aref right sample-num) (* out-r #.(/ 1.0 (1- (expt 2 31))))))
608+ ;; (* (%player-clamp-int32-to-int16 (sample-left buf)) +inv-int-16+))
609+ ;;(setf (aref right sample-num) out-r)) ;; (* (%player-clamp-int32-to-int16 (sample-right buf)) +inv-int-16+)))
610+
611+ ;; Still needs to be adjusted for the resampler
612+ (setf (sample-left buf) (ash (coerce-to-int32 (* (ash (sample-left buf) -5) cur-volume)) -11))
613+ (setf (sample-right buf) (ash (coerce-to-int32 (* (ash (sample-right buf) -5) cur-volume)) -11))))
605614 nil)
606615
607616 (define-typed-fn %player-reset-chips ((vgm-player player))