Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Playing/Embedding XM and MOD files in Visual Basic 6

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Radiation
Grandmaster Cheater
Reputation: 14

Joined: 17 Jun 2009
Posts: 842
Location: Chernobyl

PostPosted: Sat Mar 12, 2011 5:35 pm    Post subject: Playing/Embedding XM and MOD files in Visual Basic 6 Reply with quote

Alright, this is done with BASS 2.4

Code:
http://www.un4seen.com/


Below, I have posted a link for project download.

This brief tutorial will teach you how to embed XM files into your Visual Basic 6 application and play them in the background. The modules and functions used in this project are NOT made by me. I simply reshaped the existing project found on the website to fit the need of playing files from resource.

You need to copy the Bass.dll file to your System 32 folder and register it.

This project is actually quite simple.



Enabling VB6 Resource Editor:

First of all, you need to add resources to your VB6 project.
Go to Add-Ins>Add-In Manager> Scroll down and click on VB 6 Resource Editor> Check Loaded/Unloaded> OK

A window should pop up. Also, a new green button that looks like a registry cube with a hand over it should pop up in the toolbar.



Adding Resources to your Project:
In the VB Resource Editor window, click on the Add Custom Resource button. (To the right of the image button)

Now add your resource XM files one by one.



Adding the appropriate Modules:
Below, in this post, I have a link that has the modules needed to play XM files. (You can also download the project containing the modules from the original BASS website.)

Add these modules to the project:
modBass (Bass.bas)
SYNCtest (SYNCtest.bas)
cbass_time (cbass_time.cls)



Setting up the form:


Double-Click on the form, Scroll down to the very bottom, and paste this code:

http://pastebin.com/KB9RV7SQ

The first sub is the "main function" that plays the file.
The second one checks if the correct BASS dll was loaded, and starts digital output.
The third one will check if you're running in IDE or EXE modes.
And the last one will make sure it's unloaded properly.

Also, add this API at the top of the project:

http://pastebin.com/ABqzU1z2

It's used for detecting if the project is running in IDE or EXE mode/container.



Go back to your form, create a button, paste this code inside the button:

Code:
Play_File (101)


This will play resource index 101 of the "CUSTOM" branch of resources.



Stopping the music:
If you want to stop the music, simply call these functions:

Code:
Call BASS_StreamFree(chan)
Call BASS_MusicFree(chan)




How Play_File Sub works:

Three variables are used here: chan, DataLength, and DataStore

DataLength is the size of the music file. It is needed to properly allocate the size of the array of bytes.

DataStore is an array of bytes that holds the music file. It retrieves the resource as an array of bytes which will be used in playing the file.

chan is a stream or music handle that holds the music stream. It is then used in the function BASS_ChannelPlay to finally output the music.



Download Project (Contains Source Files + Modules + XM Music + Bass.dll + EXE)


http://dl.dropbox.com/u/4461017/XM%20MOD%20Player.zip

_________________
Jesus loves you, Hitler! Smile

Playing/Embedding XM and MOD files in Visual Basic 6

.erutangis ruoy ni siht esu neht ,sdrawkcab siht daer ot hguone trams erew uoy fI
I can spell your name backwards: ‮Hitler
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites