VGM playback library for Common Lisp
Rev. | Zeit | Autor | Nachricht |
---|---|---|---|
7d8ca9425b41 | 2023-08-20 16:47:44 | ![]() |
tip Add a note that the repo has moved to https://chiselapp.c... |
102459d057a9 | 2023-08-19 22:51:56 | ![]() |
Fix a few typos, clean up some lines |
223b236c1baa | 2023-08-19 22:51:32 | ![]() |
DATA should always be 8-bit |
6cc221fe7d63 | 2023-08-19 22:51:14 | ![]() |
Change fill-buffers so that it matches YunoSynth's behavior |
1c7f18f23b9c | 2023-08-19 22:50:50 | ![]() |
Quit playing when the VGM has ended |
8c1a80832907 | 2023-08-18 19:06:44 | ![]() |
Add a very simple example player. |
fa90ff7c6cda | 2023-08-18 19:06:35 | ![]() |
Add missing exports |
399f3002950f | 2023-08-18 19:06:13 | ![]() |
Add T/CHIP->NAME, T/CHIP->LONG-NAME, SUPPORTED-CHIPS, and... |
bbcf16770da5 | 2023-08-18 19:05:08 | ![]() |
Render to float32 |
7e2489948f56 | 2023-08-18 19:04:52 | ![]() |
Export some more thing |
Name | Rev. | Zeit | Autor |
---|---|---|---|
tip | 7d8ca9425b41 | 2023-08-20 16:47:44 | ![]() |
Name | Rev. | Zeit | Autor | Nachricht |
---|---|---|---|---|
default | 7d8ca9425b41 | 2023-08-20 16:47:44 | ![]() |
Add a note that the repo ha... |
NOTE: Moved to https://chiselapp.com/user/MistressRemilia/repository/satou/
SatouSynth is a high-performance VGM playback library written entirely in Common Lisp. The goal is to provide native VGM playback in Common Lisp without bindings, a cleaned-up version of VGMPlay's code, and performance on par with my YunoSynth library.
Wanna support me? Buy me a coffee on Ko-Fi, or support me through Liberapay.
Comming soon.
More chips will be added as time goes on.
This currently only supports SBCL.
Most dependencies can be installed using QuickLisp (though this hasn't been tested). The exception is the CL-SDM library, which can be obtained here.
Place this library (and the CL-SDM dependency) somewhere where ASDF can find them, then run this in your REPL:
(asdf:load-system :satou)
This uses the CL-PortAudio for playback.
(defun play-vgm (filename)
(let* ((buf-l (cl-sdm:new-array 1024 cl-sdm:t/int16))
(buf-r (cl-sdm:new-array 1024 cl-sdm:t/int16))
(buf (cl-sdm:new-array 2048 single-float 0.0))
;; Read VGM, then make a player.
(vgm (satou:read-vgm-file filename))
(player (satou:make-vgm-player vgm)))
;; Start PortAudio
(pa:with-audio
(pa:with-default-audio-stream (out 0 2 :sample-rate 44100.0d0
:sample-format :float
:frames-per-buffer 1024)
;; Start playback
(satou:vgm-player-play player)
(sdm:gc t)
;; Render loop
(loop until (or (satou:vgm-player-at-end-p player)
(>= (satou:vgm-player-times-played player) 2))
do ;; Render
(satou:vgm-player-render player buf-l buf-r)
;; Interleave the buffers and convert to float32 for PortAudio
(loop for i fixnum from 0 below 1024
for j fixnum from 0 by 2
do (setf (aref buf j) (/ (aref buf-l i) 32768.0)
(aref buf (1+ j)) (/ (aref buf-r i) 32768.0)))
;; Write to putput
(pa:write-stream out buf))))))
(play-vgm #P"/path/to/your/song.vgm")
*FEATURES*
SatouSynth supports a few flags that can be put into *FEATURES*
prior to
compiling it.
:SATOU-DEBUG
: Print various debug information to the console.:SATOU-SUPER-DEBUG
: Print even more debug information to the console.:SATOU-WD40
: Enable various micro-optimizations that may possibly do unsafe
things in exchange for some small speed boosts.In the chips
folder, all files should follow this scheme:
chip-[CHIPNAME].lisp
: This is the public interface for the chip. Replace
[CHIPNAME]
with the name of the chip (e.g. chip-ym2151.lisp
).emu-[CHIPNAME]-[BASE].lisp
: This is the private emulator for the chip.
Replace [CHIPNAME]
with the name of the chip, and [BASE]
with the code
that the emulator is based on (e.g. emu-ym2151-mame.lisp
).I use a slightly unorthodox style for my code. Aside from these differences, please use normal Lisp formatting.
T/....
. For example, T/SOME-NEAT-TYPE
. For
predicates on these, use SOME-NEAT-TYPE-P
.SatouSynth itself is under the GNU Affero General Public License version 3.
The emulation cores, which were all ported by hand to Common Lisp, have various
other licenses, which can be found in the docs/licenses
folder in this
repository. Most of them are from the MAME project.
Much of the playback code is indirectly based on heavily modified code from VGMPlay by Valley Bell, et al. via my YunoSynth library.