Index

Audio Output with Harmony

Harmony is an independent audio server system. It is capable of creating complex audio routing systems and also provides a variety of audio effects, outputs, and inputs out of the box. Please see its documentation for more details. In this section we briefly outline how the integration system trial-harmony can help you bridge the gap with Trial.

First, you will want to inherit from org.shirakumo.fraf.trial.harmony:settings-main. This main subclass will take care of initializing and finalizing the audio server when the game is started up, and will also automatically interpret the audio-related settings. If you would like to customise how the server builds its pipeline or provide other customisations outside the settings, you can do so with server-initargs:

(defmethod org.shirakumo.fraf.trial.harmony:serveri-initargs append ((main main))
  '(:effects ((mixed:biquad-filter :filter :lowpass :name :lowpass))))

See harmony:make-simple-server for more information on accepted initargs.

Second, you will want to pre-load sound files. The trial-harmony system provides assets and resources to encapsulate the Harmony objects you need to manage. To import sounds and simple music tracks, use the org.shirakumo.fraf.trial.harmony:sound to define your assets. If you want to use Harmony's environments system to do horizontal mixing, define the environment using the org.shirakumo.fraf.trial.harmony:environment asset.

In order to play back a sound, just access its resource and play it back:

(org.shirakumo.fraf.harmony:play (// 'my-project 'sound))

Note that each asset generates exactly one voice instance. You thus cannot play the same sound twice at the same time. Usually this is not an issue, as you can pass :reset T to play to restart the effect instead. In the rare cases where it is vital that the sound effect be played back multiple times simultaneously, you can either define the same sound as multiple assets, or use close before playing it back.