Difference between revisions of "Modules/ndp/ndp player/Usage"
From MSX Game Library
< Modules | ndp/ndp player
(→SFX) |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | Before using any functions of this module, you must call <tt>NDP_Initialize()</tt> first. | ||
+ | |||
=== Music === | === Music === | ||
You can play back music generated with the [https://ndp.squares.net/web NDP editor] (the music is created using the MML language). The editor is currently only available in Japanese. | You can play back music generated with the [https://ndp.squares.net/web NDP editor] (the music is created using the MML language). The editor is currently only available in Japanese. | ||
+ | MSXgl use .NDP binary file data. It can be generated from the editor pressing <tt>ALT+F</tt> (ファイル) then <tt>ALT+B</tt> (名前を付けて曲データをBSAVE形式で保存). | ||
+ | This binary file include a 7 bytes header used by BASIC's BSAVE/BLOAD instructions. You have to either cut this header or just pass the starting address of binary data offset by 7 bytes. | ||
+ | Example: <syntaxhighlight lang="C"> | ||
+ | #include "mymusic.h" // NDP file converted to .H file using MSXbin | ||
+ | |||
+ | void main() | ||
+ | { | ||
+ | /* ... */ | ||
+ | NDP_SetMusicData(g_MusicData); // or g_MusicData+7 if data include header | ||
+ | NDP_Play(); | ||
+ | /* ... */ | ||
+ | } | ||
+ | </syntaxhighlight> | ||
=== SFX === | === SFX === | ||
+ | For sound effects, you have to export .NDS file from the [https://ndp.squares.net/web NDP editor]. It can be generated from the editor pressing <tt>ALT+F</tt> (ファイル) then <tt>ALT+S</tt>. Like .NDP files, .NDS files contain the 7-byte header that must be removed or skipped. | ||
+ | |||
+ | Frist, you must call the <tt>NDP_SetSFXData()</tt> with the address of the NDS sound bank. They you can play an sound using its index into the bank (from 0 to <tt>NDP_GetSFXNumber()-1</tt>). | ||
+ | |||
+ | Example: <syntaxhighlight lang="C"> | ||
+ | #include "mysoundbank.h" // NDS file converted to .H file using MSXbin | ||
+ | |||
+ | void main() | ||
+ | { | ||
+ | /* ... */ | ||
+ | NDP_SetSFXData(g_SFXData); // or g_SFXData+7 if data include header | ||
+ | NDP_PlaySFX(0); // play first sound | ||
+ | /* ... */ | ||
+ | } | ||
+ | </syntaxhighlight> |
Latest revision as of 23:24, 12 October 2025
Before using any functions of this module, you must call NDP_Initialize() first.
Music
You can play back music generated with the NDP editor (the music is created using the MML language). The editor is currently only available in Japanese.
MSXgl use .NDP binary file data. It can be generated from the editor pressing ALT+F (ファイル) then ALT+B (名前を付けて曲データをBSAVE形式で保存).
This binary file include a 7 bytes header used by BASIC's BSAVE/BLOAD instructions. You have to either cut this header or just pass the starting address of binary data offset by 7 bytes.
Example:#include "mymusic.h" // NDP file converted to .H file using MSXbin void main() { /* ... */ NDP_SetMusicData(g_MusicData); // or g_MusicData+7 if data include header NDP_Play(); /* ... */ }
SFX
For sound effects, you have to export .NDS file from the NDP editor. It can be generated from the editor pressing ALT+F (ファイル) then ALT+S. Like .NDP files, .NDS files contain the 7-byte header that must be removed or skipped.
Frist, you must call the NDP_SetSFXData() with the address of the NDS sound bank. They you can play an sound using its index into the bank (from 0 to NDP_GetSFXNumber()-1).
Example:#include "mysoundbank.h" // NDS file converted to .H file using MSXbin void main() { /* ... */ NDP_SetSFXData(g_SFXData); // or g_SFXData+7 if data include header NDP_PlaySFX(0); // play first sound /* ... */ }