【娱乐项目】东方八音盒

· · 休闲·娱乐

今日闲来无事,便整了个活。

这是一个内置有 10 首东方二创曲的可供其他程序调用的动态链接库(DLL)。大小仅有 596 KB。

下载

您可以在此处下载到该库的二进制版本。

您还可以在此处下载到一份示例。如果您只想欣赏音乐,也可以下载此示例,该示例中包含一个已编译的播放器。

开发文档

如果您希望在您的程序中调用此库来为您的程序添加音乐,则可以参照此文档编写程序。

使用方法很简单。首先,请将下面的代码插入到您的源代码的头部。

/************ Music Box by BigCookie233 ************/
#include<windows.h>

HINSTANCE musicbox_module;
void (*musicbox_PlaySong)(int);
const char* (*musicbox_GetTitle)(int);
const char* (*musicbox_GetAuthorInfo)(int);

int musicbox_init()
{
    musicbox_module = LoadLibraryA("musicbox.dll");
    if (musicbox_module == NULL) return -1;
    musicbox_PlaySong = (decltype(musicbox_PlaySong))GetProcAddress(musicbox_module, "PlaySong");
    musicbox_GetTitle = (decltype(musicbox_GetTitle))GetProcAddress(musicbox_module, "GetTitle");
    musicbox_GetAuthorInfo = (decltype(musicbox_GetAuthorInfo))GetProcAddress(musicbox_module, "GetAuthorInfo");
    return 0;
}

int musicbox_cleanup()
{
    musicbox_PlaySong = NULL;
    musicbox_GetTitle = NULL;
    musicbox_GetAuthorInfo = NULL;
    FreeLibrary(musicbox_module);
    return 0; 
}
/***************************************************/

然后,在程序的入口处调用 musicbox_init() 加载此动态链接库。

使用 musicbox_PlaySong(id) 来播放音乐。

您可以在下面的表格中找到每个音乐的 ID。

最后,在程序结束前调用 musicbox_cleanup() 释放资源。

例如:

signed main()
{
    musicbox_init();
    while(true)
    {
        int t;
        printf(">>> ");
        scanf("%d",&t);
        musicbox_PlaySong(t);
    }
    musicbox_cleanup();
    return 0;
}

函数原型如下:

/* 播放音乐 */
void PlaySong(int id);
/* 获取音乐标题 */
const char* GetTitle(int id);
/* 获取音乐作者 */
const char* GetAuthorInfo(int id);

音乐来源

这些音乐来源于 Mod Archive,感谢这些才华横溢的作曲家免费分享他们的音乐!

ID 曲名 作者
0 Welcome to the Disk Pigu
1 Eternal Shrine Maiden Susumu Takajima
2 High Prayer Response Susumu Takajima
3 Shrine of the Wind Susumu Takajima
4 Eastern Mystical Dream Susumu Takajima
5 Love-Colored Master Spark Susumu Takajima
6 Faith for the Transient Susumu Takajima
7 Bad Apple!!ft.nomico Torvald
8 UN Owen (REMIX) 240-185
9 Souls Resting Place spaztron64
10 Blade of Banishment Susumu Takajima