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

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

2006-7-22 13:05
12020

背景:习惯于用borland公司的产品,虽然他的IDE产品要被卖掉了

,写了一个注册机,想个性化一点,加入一首好听的音乐,把google翻遍了,却没发现有人将xm整入到程序中的,一大片一大片的都是vc,masm,很郁闷,睁着眼一夜没睡,一大早找到了解决方法



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



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,



[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

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

uFMOD_StopSong();停止播放

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

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

uFMOD_GetTitle(); 返回歌曲播放的标题
2006-7-22 13:11
0
雪    币: 440
活跃值: (867)
能力值: ( 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

cfeK9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4N6%4N6#2)9J5k6i4N6G2N6s2y4A6N6q4)9J5k6h3!0J5k6#2)9J5c8X3k6A6L8r3g2K6N6r3!0J5k6g2)9J5c8Y4S2E0i4K6u0W2P5X3W2H3


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:
8a0K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4y4G2N6i4u0U0k6h3k6G2M7X3N6W2i4K6u0W2L8X3g2@1i4K6u0r3M7s2u0G2K9X3g2U0N6q4)9J5c8Y4y4Z5L8%4N6F1L8%4c8W2M7#2)9J5k6i4m8Z5M7q4)9K6c8Y4u0W2L8r3g2S2M7$3g2Q4y4h3k6A6k6q4)9K6c8o6b7K6y4K6V1$3z5g2)9J5y4X3N6J5L8%4g2H3i4K6g2X3K9h3c8Q4x3@1b7I4y4e0R3@1z5e0R3`.

Download:
e54K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4g2X3L8h3!0V1i4K6u0W2M7$3k6Q4x3X3g2F1k6i4b7`.
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
游客
登录 | 注册 方可回帖
返回