Mega PCM 2's sample table consists of sample record definitions (dcSample
) and must be terminated by the end marker (dc.w -1
). Actual samples are usually included after the table in the same file (via incdac
), though they can be located anywhere in the ROM.
Note
If you wish to convert your old Mega PCM 1.x sample tables to the new format, check out Migrating from MegaPCM 1.x guide.
Table is loaded by calling MegaPCM_LoadSampleTable
. With Mega PCM 2, you can use more than one sample table and swap them on the fly.
Example:
SampleTable:
; type pointer Hz flags? ; sample id
dcSample TYPE_DPCM, Kick, 8000 ; $81
dcSample TYPE_PCM, Snare, 0 ; $82
dcSample TYPE_DPCM, Timpani, 7250 ; $83
dcSample TYPE_PCM_TURBO, MySFX, 0, FLAGS_SFX ; $84
dc.w -1 ; end marker
; ---------------------------------------------------------------
incdac Kick, "dac/kick.dpcm"
incdac Snare, "dac/snare.wav"
incdac Timpani, "dac/timpani.dpcm"
incdac MySFX, "dac/sfx/mysfx.wav"
even
dcSample
is a macro to represent a sample record in the table (think of it as a header describing sample's type, location, flags etc).
Usage:
dcSample TYPE_PCM, MySampleName, 22050, FLAGS_LOOP+FLAGS_SFX
Syntax:
dcSample <Type>, <Name>[, <SampleRateHz>, <Flags>]
Arguments:
<Type>
- sample type:TYPE_PCM
(for raw PCM and WAV files);TYPE_DPCM
(for raw DPCM files);TYPE_PCM_TURBO
(for raw PCM and WAV files at 32000 Hz);
<Name>
- sample pointer/name, the one you specify for theindac
macro, so sample table can reference it;<SampleRateHz>
(optional) - sample rate in Hz, supported rates are:- For
TYPE_PCM_TURBO
: Only 32000 Hz; - For
TYPE_PCM
: Anything between 0 and 25100 Hz; - For
TYPE_DPCM
: Anything between 0 and 20500 Hz; - If set to
0
or not specified, Mega PCM will try to detect sample rate automatically (WARNING! This only works for .WAV files);
- For
<Flags>
(optional) - special playback flags or combination thereof:FLAGS_LOOP
- loops sample indefinitely;FLAGS_SFX
- sample is considered an SFX sample and has priority over "normal" samples (without this flag). No other samples can interrupt its playback (even other SFX). It also uses separate volume and pan settings (seeMegaPCM_SetSFXVolume
andMegaPCM_SetSFXPan
in API docs)
incdac
is a convenience macro to include sample itself.
Usage:
incdac MySampleName, "path/to/sample/mycoolsample.wav"
Syntax:
incdac <Name>, <Path>
Arguments:
<Name>
- sample pointer name, so it can be referenced indcSample
;<Path>
- string representing path to the sample.