Login
satou
Login

SatouSynth

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.

Buy Me a Coffee at ko-fi.com Donate using Liberapay

Example videos

Comming soon.

Features

Implemented Chips

More chips will be added as time goes on.

Known Issues

Usage

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)

Example Player

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")

Development

Flags for *FEATURES*

SatouSynth supports a few flags that can be put into *FEATURES* prior to compiling it.

File Names

In the chips folder, all files should follow this scheme:

Style info

I use a slightly unorthodox style for my code. Aside from these differences, please use normal Lisp formatting.

How do I contribute?

  1. Go to https://osdn.net/users/yukiraven/pf/satousynth/ and clone the Mercurial repository.
  2. Create a new branch for your feature.
  3. Push locally to the new branch
  4. Create a ticket.

Contributors

Links and Licenses

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.