Preparation for BGM

 In KAG, the audio track of the Wave system (no compression Wave and Ogg Vorbis, etc.) and the MIDI sequence data and CD-XA can be played as BGM.
 Please check Preparation for details.

 Here (for the sake of this tutorial), CD-DA is used and change doubleBuffered=false in Config.tjs to play "CDDA" type audio.

 Does cdVolume have to be specified? Shouldn't CD-XA be used? CD-XA has to specify the CD-ROM drive and so cdVolume shouldn't be set, and use CD-XA only when you know how to retrieve the music from the CD-ROM drive.

 Or this error can come up: Please insert a suitable music CD in CD-ROM drive.

Let's play the BGM!

 Use the tag 'playbgm' to play. In addition, use the tag 'stopbgm' to stop playback. Then...

[wait time=200]
*start|Start
[cm]
[playbgm storage="e:3"]
BGM is playing... Click to stop it![l]
[stopbgm]

 For the storage attribute in the playbgm tag, e:3 is specified.e: is a CD-ROM drive letter to play from the CD-ROM. The following '3' is the track number to play.

 The letter e: can also be written in the cdVolume of Config.tjs. KAG automatically goes to look for the CD-ROM drive label specified in cdVolume, if the drive letter(e:) isn't mentioned in the playbgm tag.

 Moreover, except for CD-DA, if you want to playback a MIDI sequence data, for instance, only the filename can be specified for the storage attribute.

Fade-in & fade-out

 To add fade-in and fade-out effects, you can use the 'fadeinbgm' and 'fadeoutbgm' tags.
 In the 'time' attribute, you have to specify the time duration for the fade-in or the fade-out BGM effect.

[wait time=200]
*start|Start
[cm]
[fadeinbgm storage="e:3" time=5000]
BGM is playing... Click to stop it![l]
[fadeoutbgm time=5000]

 Because these tags doesn't wait for the end of the fade-in and fade-out effects, it is necessary to use the [wb] tag to wait for the end.

Other tags concerning BGM

 There is tag named 'xchgbgm' that replaces the BGM tag. In the Wave and the MIDI system, the cross-fade is also possible (Please refer to Config.tjs).

 Please note that the plug-in should be specified when you use OggVorbis, TCWF, and Micsoroft ADPCM in the Wave system(Please refer to the Preparation section). This is for the sound effects too.


Note
 It was made to cross-fade audio data in the MIDI system. However, it is not so realistic (For instance, do not use the same channel for two songs to play at the same time).