首页
社区
课程
招聘
[原创]Borland C++ 程序中嵌入XM,MOD音乐
发表于: 2006-7-22 13:05 11890

[原创]Borland C++ 程序中嵌入XM,MOD音乐

2006-7-22 13:05
11890

背景:习惯于用borland公司的产品,虽然他的IDE产品要被卖掉了,写了一个注册机,想个性化一点,加入一首好听的音乐,把google翻遍了,却没发现有人将xm整入到程序中的,一大片一大片的都是vc,masm,很郁闷,睁着眼一夜没睡,一大早找到了解决方法

步骤:1。去SourceForge.net下载ufmod for win32,地址:http://sourceforge.net/projects/ufmod

2。解压缩后到ufmodlib 目录中,修改makeomf.bat中的内容
如下:
@echo off

rem Select compiler: TASM, MASM or NASM
rem (Choose TASM or NASM for Delphi compatibility)
SET ASM=NASM

rem Select output platform: WINMM or DIRECTSOUND
SET UFMOD_OUTPUT=WINMM

rem Select mixing rate: 22050, 44100 or 48000 (22.05 KHz, 44.1 KHz or 48 KHz)
SET UFMOD_MIXRATE=44100

rem Select filenames encoding (when using XM_FILE flag): ANSI or UNICODE
SET UFMOD_UFS=ANSI

SET OBJ=ufmod.obj

tasm32 /mx /m4 /zn /q /d%UFMOD_OUTPUT%=1 /df%UFMOD_MIXRATE%=1 /d%UFMOD_UFS%=1 masm.asm, %OBJ%

pause
@echo on
cls

保存,运行,得到ufmod.obj

3。控制台当前目录下:tlib ufmod.lib +ufmod.obj  得到ufmod.lib
4.到visual_c目录下找到winmm\ufmod.h文件,修改一个函数:
HWAVEOUT* __stdcall uFMOD_PlaySong(void*, void*, int); --〉修改成:
void* __stdcall uFMOD_PlaySong(LPVOID lpXM, DWORD  param,DWORD  fdwSong);

保存。

5。将以上  ufmod.lib 和 ufmod.h 文件复制到你自己的程序目录下,工程中添加ufmod.lib,头文件引用 ufmod.h ,调用函数uFMOD_PlaySong,嘿嘿,搞定!

函数uFMOD_PlaySong 的调用方法:

(1)内存中:
char xm []={0x45,0x78,0x74,0x65,0x6E,0x64,0x65,0x64,0x20,0x4D,0x6F,0x64,0x75,0x6C,0x65,0x3A,
                0x20,0x73,0x6F,0x66,0x74,0x20,0x6D,0x61,0x6E,0x69,0x61,0x63,0x2D,0x6D,0x69,0x6E,
                0x69,0x6D,0x61,0x6C,0x00,0x1A,0x46,0x61,0x73,0x74,0x54,0x72,0x61,0x63,0x6B,0x65,
                0x72,0x20,0x76,0x32,0x2E,0x30,0x30,0x20,0x20,0x20,0x04,0x01,0x14,0x01,0x00,0x00,
                0x20,0x00,0x00,0x00,0x02,0x00,0x0D,0x00,0x01,0x00,0x01,0x00,0x0A,0x00,0x91,0x00,
                0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
                0x08,0x09,0x0A,0x0B,0x08,0x09,0x0C,0x0B,0x08,0x09,0x0A,0x0B,0x08,0x09,0x0C,0x0B,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x09,0x00,0x00,0x00,0x00,0x04,0x00,0x15,0x00,0x83,0x16,0x01,0x80,0x80,0x9B,0x2E,
                0x01,0x0E,0x60,0x80,0x9B,0x3A,0x01,0x0E,0x62,0x81,0x61,0x83,0x35,0x01,0x09,0x00,
                0x00,0x00,0x00,0x04,0x00,0x15,0x00,0x83,0x16,0x01,0x80,0x80,0x9B,0x2E,0x01,0x0E,
                0x60,0x80,0x9B,0x35,0x01,0x0E,0x62,0x81,0x61,0x83,0x38,0x01,0x09,0x00,0x00,0x00,
                0x00,0x04,0x00,0x14,0x00,0x83,0x16,0x01,0x80,0x80,0x9B,0x2E,0x01,0x0E,0x60,0x80,
                0x9B,0x38,0x01,0x0E,0x62,0x80,0x83,0x33,0x01,0x09,0x00,0x00,0x00,0x00,0x06,0x00,
                0x1F,0x00,0x83,0x16,0x01,0x80,0x80,0x9B,0x2E,0x01,0x0E,0x60,0x80,0x9B,0x33,0x01,
                0x0E,0x61,0x81,0x61,0x83,0x35,0x01,0x83,0x0D,0x01,0x83,0x36,0x01,0x80,0x83,0x36,
                0x01,0x09,0x00,0x00,0x00,0x00,0x04,0x00,0x15,0x00,0x83,0x0F,0x01,0x80,0x80,0x9B,
                0x2E,0x01,0x0E,0x60,0x80,0x9B,0x36,0x01,0x0E,0x62,0x81,0x61,0x83,0x33,0x01,0x09,
                0x00,0x00,0x00,0x00,0x06,0x00,0x1F,0x00,0x83,0x0F,0x01,0x80,0x80,0x9B,0x2E,0x01,
                0x0E,0x60,0x80,0x9B,0x33,0x01,0x0E,0x61,0x81,0x61,0x83,0x2E,0x01,0x83,0x12,0x01,
                0x83,0x33,0x01,0x80,0x83,0x35,0x01,0x09,0x00,0x00,0x00,0x00,0x06,0x00,0x1F,0x00,
                0x83,0x16,0x01,0x80,0x80,0x9B,0x2E,0x01,0x0E,0x60,0x80,0x9B,0x35,0x01,0x0E,0x61,
                0x81,0x61,0x83,0x2E,0x01,0x83,0x0D,0x01,0x83,0x31,0x01,0x80,0x83,0x2E,0x01,0x09,
                0x00,0x00,0x00,0x00,0x08,0x00,0x24,0x00,0x83,0x12,0x01,0x98,0x0A,0x01,0x83,0x19,
                0x01,0x88,0x0A,0x83,0x1E,0x01,0x81,0x61,0x83,0x12,0x01,0x80,0x83,0x14,0x01,0x80,
                0x83,0x1B,0x01,0x80,0x83,0x20,0x01,0x80,0x83,0x14,0x01,0x80,0x09,0x00,0x00,0x00,
                0x00,0x08,0x00,0x25,0x00,0x83,0x12,0x01,0x81,0x61,0x83,0x19,0x01,0x80,0x83,0x1E,
                0x01,0x80,0x83,0x12,0x01,0x80,0x83,0x19,0x01,0x83,0x31,0x01,0x83,0x1E,0x01,0x80,
                0x83,0x12,0x01,0x83,0x31,0x01,0x83,0x19,0x01,0x80,0x09,0x00,0x00,0x00,0x00,0x08,
                0x00,0x28,0x00,0x83,0x14,0x01,0x83,0x33,0x01,0x83,0x1B,0x01,0x80,0x83,0x20,0x01,
                0x83,0x31,0x01,0x83,0x14,0x01,0x80,0x83,0x1B,0x01,0x83,0x30,0x01,0x83,0x20,0x01,
                0x80,0x83,0x14,0x01,0x83,0x31,0x01,0x83,0x1B,0x01,0x80,0x09,0x00,0x00,0x00,0x00,
                0x08,0x00,0x2A,0x00,0x83,0x16,0x01,0x83,0x30,0x01,0x83,0x1D,0x01,0x83,0x31,0x01,
                0x83,0x22,0x01,0x83,0x35,0x01,0x83,0x16,0x01,0x98,0x0A,0x01,0x83,0x1D,0x01,0x88,
                0x0A,0x83,0x22,0x01,0x81,0x61,0x83,0x16,0x01,0x80,0x83,0x1D,0x01,0x80,0x09,0x00,
                0x00,0x00,0x00,0x08,0x00,0x20,0x00,0x83,0x16,0x01,0x80,0x83,0x1D,0x01,0x80,0x83,
                0x22,0x01,0x80,0x83,0x16,0x01,0x80,0x83,0x18,0x01,0x80,0x83,0x1D,0x01,0x80,0x83,
                0x11,0x01,0x80,0x83,0x18,0x01,0x80,0x09,0x00,0x00,0x00,0x00,0x08,0x00,0x2A,0x00,
                0x83,0x16,0x01,0x83,0x30,0x01,0x83,0x1D,0x01,0x83,0x31,0x01,0x83,0x19,0x01,0x83,
                0x2E,0x01,0x83,0x16,0x01,0x98,0x0A,0x01,0x83,0x1D,0x01,0x88,0x0A,0x83,0x19,0x01,
                0x81,0x61,0x83,0x16,0x01,0x80,0x83,0x1D,0x01,0x80,0x07,0x01,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x27,0x01,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x08,
                0x00,0x2C,0x00,0x0E,0x00,0x08,0x00,0x18,0x00,0x16,0x00,0x20,0x00,0x08,0x00,0x2D,
                0x00,0x0D,0x00,0x32,0x00,0x04,0x00,0x3C,0x00,0x07,0x00,0x44,0x00,0x04,0x00,0x5A,
                0x00,0x00,0x00,0x64,0x00,0x00,0x00,0x6E,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x0A,
                0x00,0x28,0x00,0x1E,0x00,0x18,0x00,0x32,0x00,0x20,0x00,0x3C,0x00,0x20,0x00,0x46,
                0x00,0x20,0x00,0x50,0x00,0x20,0x00,0x5A,0x00,0x20,0x00,0x64,0x00,0x20,0x00,0x6E,
                0x00,0x20,0x00,0x78,0x00,0x20,0x00,0x82,0x00,0x20,0x00,0x09,0x06,0x01,0x02,0x04,
                0x02,0x03,0x05,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x40,0x00,0x01,
                0x80,0xF9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xBF,0x00,0xC3,0x00,0x0A,0x00,0x57,
                0x00,0x6E,0x00,0x23,0x00,0x58,0x54,0x50,0x4D,0x2E,0x2E,0x52,0x56,0x02,0x00,0x00,
                0x00,0x2E,0x50,0x69,0x4D,0x01,0x00,0x00,0x2E,0x2E,0x43,0x4D,0x01,0x00,0x00,0x2E,
                0x2E,0x50,0x4D,0x01,0x00,0x27,0x2E,0x2E,0x42,0x4D,0x02,0x00,0x00,0x00,0x2E,0x2E,
                0x2E,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x2E,0x2E,0x56,0x47,0x04,0x00,0x40,0x00,
                0x00,0x00,0x2E,0x2E,0x4F,0x46,0x04,0x00,0x80,0x00,0x00,0x00,0x2E,0x2E,0x2E,0x52,
                0x04,0x00,0x05,0x00,0x00,0x00,0x2E,0x2E,0x53,0x43,0x01,0x00,0x00,0x2E,0x2E,0x53,
                0x52,0x01,0x00,0x00,0x2E,0x2E,0x4D,0x46,0x01,0x00,0xFF,0x53,0x54,0x50,0x4D,0x2E,
                0x2E,0x54,0x44,0x04,0x00,0x91,0x00,0x00,0x00,0x2E,0x42,0x50,0x52,0x04,0x00,0x04,
                0x00,0x00,0x00,0x2E,0x4D,0x50,0x52,0x04,0x00,0x10,0x00,0x00,0x00,0x2E,0x2E,0x2E,
                0x43,0x04,0x00,0x02,0x00,0x00,0x00,0x2E,0x2E,0x4D,0x54,0x01,0x00,0x00,0x2E,0x4D,
                0x4D,0x50,0x01,0x00,0x02,0x2E,0x56,0x57,0x43,0x04,0x00,0x00,0x00,0x00,0x00,0x56,
                0x57,0x53,0x4C,0x04,0x00,0x28,0x02,0x17,0x01,0x2E,0x41,0x50,0x53,0x04,0x00,0x64,
                0x00,0x00,0x00,0x56,0x54,0x53,0x56,0x04,0x00,0x64,0x00,0x00,0x00,0x2E,0x56,0x47,
                0x44,0x04,0x00,0x00,0x01,0x00,0x00};

调用:uFMOD_PlaySong(&xm,sizeof(xm),XM_MEMORY);

(2)文件中:
调用:uFMOD_PlaySong("../1.xm",0,XM_FILE);

附件中是已经修改好的 ufmod.lib和ufmod.h,加入程序中可以直接使用


[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)

上传的附件:
收藏
免费 8
支持
分享
最新回复 (18)
雪    币: 462
活跃值: (18)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
2
几个函数补充一下:

uFMOD_StopSong();停止播放

uFMOD_GetStats();返回当前的左右声道

uFMOD_GetTime();返回当前歌曲播放的时间

uFMOD_GetTitle(); 返回歌曲播放的标题
2006-7-22 13:11
0
雪    币: 440
活跃值: (737)
能力值: ( LV9,RANK:690 )
在线值:
发帖
回帖
粉丝
3
很早就用ufmod了
真不错

各种语言都有例子
2006-7-22 14:20
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
不错,我找遍了整个google都没找到方法,在这找到了,真是太好了   
2006-7-23 19:23
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
Very nice example!!! In fact, some older uFMOD releases were compiled using Borland C++.
2006-7-29 02:29
0
雪    币: 462
活跃值: (18)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
6
楼上的兄弟不会是 ufMOD 的作者吧,怎么越看越像呢?
2006-7-29 21:55
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
Originally posted by dododo
楼上的兄弟不会是 ufMOD 的作者吧,怎么越看越像呢?

I'm afraid I can't understand your question. Babel Fish couldn't understand either. Gotta learn chinesse someday.
2006-7-29 23:40
0
雪    币: 462
活跃值: (18)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
8
are you the ufmod 's author? nice to meet you
2006-7-30 00:33
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
Originally posted by dododo
are you the ufmod 's author?

Actually, uFMOD has 2 developers by now. I'm one of 'em. The other guy is Asterix. Nice to meet you too.
2006-7-30 01:06
0
雪    币: 462
活跃值: (18)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
10
it is a great honor to know you, can i talk with you on msn or skype or any other way?

And I hope it will contain Borland C++ builder simple programs in the next version.

I want to know some information about XM structure and how to extract the data used for array,Just like "char xm []={...}"
2006-7-30 21:34
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
11
Originally posted by dododo
can i talk with you on msn or skype or any other way?

Had some technical issues with ICQ recently, so, if you don't mind, let's use good old e-mail for now: ufmod@users.sf.net


And I hope it will contain Borland C++ builder simple programs in the next version.

I'd be glad to include your example. Could you, please, make a complete sample source for both WINMM and DX?


I want to know some information about XM structure

http://www.wotsit.org/filestore/xm.zip


and how to extract the data used for array,Just like "char xm []={...}"

Using the included eff.exe tool.
2006-7-31 01:03
0
雪    币: 462
活跃值: (18)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
12
with pleasure!

The BCB folder contains WINMM and DirectX projects.

上传的附件:
2006-7-31 21:47
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
13
Cool! Thanks! I'll include it in next release. The only thing I don't like is the size of those executables. Asterix says he've seen 8Kb BCB exes or so.
2006-8-2 01:56
0
雪    币: 462
活跃值: (18)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
14
i did not pay attention to the size of the file,and
i modified the program into simple application without windows,and compressed with upx,but i still can't deflate the size.
上传的附件:
2006-8-2 22:11
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
15
I don't have BCB to test it. So, let's leave it as it is, for now. Next release is almost complete. Your examples already there.
2006-8-2 23:05
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
16
uFMOD v 1.19 for Win32 is available for download.

Release notes and changes:
http://sourceforge.net/project/shownotes.php?release_id=437969&group_id=158498

Download:
http://ufmod.sf.net
2006-8-8 23:02
0
雪    币: 462
活跃值: (18)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
17
congratulation !
2006-8-11 12:24
0
雪    币: 220
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
18
看来看雪不仅卧虎藏龙,还吸引外国同行……HOHO~~

Welcome!
2006-8-11 16:25
0
雪    币: 372
活跃值: (31)
能力值: ( LV12,RANK:410 )
在线值:
发帖
回帖
粉丝
19
有没有For Delphi的?
2006-9-16 09:08
0
游客
登录 | 注册 方可回帖
返回
//