Jump to content
Tuts 4 You

Playing An XM From Resource VB 2008 Help Needed!


PiZZAMiN

Recommended Posts

Okay, so I wanted to put an XM in a crack-me, but I can't figure out how to! I have AutoIT source, but playing from resources is very hard and dialogs are very annoying. I don't do vb6, and the .bas file doesn't work so here is the autoit source to play a file to prove i have checked docs and searched the web.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>$filedir = FileOpenDialog('Open the mod file', @ScriptDir, 'Mod files (*.xm)', 1)Global $bassdll = DllOpen("BASSMOD.dll") , $Init[1]
Global $Chan, $Init, $VolLevel
$Init = DllCall($bassdll, "int", "BASSMOD_Init", "int", -1, "int", 44100, "int", 0)
$string = DllStructCreate("char[255]")
DllStructSetData($string, 1, $filedir)$load = DllCall($bassdll, "int", "BASSMOD_MusicLoad", _
"int", 0, _
"ptr", DllStructGetPtr($string), _ ;"ptr", $string, _
"int", 0, _
"int", 0, _
"int", 4 + 1024)
;~ $Chan = 0
;~ $Inst = 0
$VolLevel = 100
;$volume = DllCall($bassdll, "int", "BASSMOD_MusicSetVolume", "int", BitOR(BitAND($Chan, 0xFFFF), BitShift($Inst, -16)), "int", $VolLevel)
$Volume = DllCall($BASSDLL, "int", "BASSMOD_SetVolume", "int", $VolLevel)
DllCall($bassdll, "int", "BASSMOD_MusicPlay")
While 1
$msg = GUIGetMsg()
If $msg = -3 Then OnAutoItExit()
Sleep(10)
WEndFunc OnAutoItExit()
If Not (FileExists("BASSMOD.DLL")) Then
Exit
Else
DllCall($bassdll, "int", "BASSMOD_MusicFree")
DllClose($bassdll)
EndIf
Exit
EndFunc

Thanks in advance, and I thank anyone who can help! :help

Link to comment

Hi!

I can't remember if i ever tried, but i guess you can't play xm files directly from ressources..

However, you can extract it at runtime in the temp folder for example:

Import the xm file you want to play in ressources and name it "xmfile".

Then extract it at runtime (form_load) to the temp folder:

Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim XMFilename as String = "myxmfile.xm" ' name of the xm file after extraction.
Dim TempPath as String = System.IO.Path.GetTempPath() ' get the temp folder path
Dim ExtractPath as string = TempPath & "\" & XMFilename ' file extraction path + xm filename ' extract the xm file to your temp folder
Try
System.IO.File.WriteAllBytes(ExtractPath, My.Resources.xmfile())
Catch ex As Exception
MsgBox(ex.Message) 'if it fails
End Try
End Sub

Once it's extracted you can use DirectX or FMod to play it, here is the FMod way:

Declarations:

Public Declare Function FSOUND_Init Lib "fmod.dll" Alias "_FSOUND_Init@12" (ByVal mixrate As Integer, ByVal maxchannels As Integer, ByVal flags As Integer) As Byte
Public Declare Function FMUSIC_LoadSong Lib "fmod.dll" Alias "_FMUSIC_LoadSong@4" (ByVal name As String) As Integer
Public Declare Function FMUSIC_PlaySong Lib "fmod.dll" Alias "_FMUSIC_PlaySong@4" (ByVal module As Integer) As Byte

Add this to your form_load sub:

FSOUND_Init (44001, 128, 0)

And to play the song:

Dim XMPointer as Integer = 0
XMPointer = FMUSIC_LoadSong(System.IO.Path.GetTempPath() & "\myxmfile.xm") ' path to the xm file in the temp folder
FMUSIC_PlaySong (XMPointer) ' play the music

That's all :) hope this helped, if you need anything else, feel free to ask..

Link to comment

Oh nvm forgot the fmod.dll in same directory, but how do I deinitialize or stop the sound at any time, so when the load is clicked in my trainer, the sound stops?

Link to comment
  • 1 year later...
  • 4 weeks later...

Hello I have made a solution for you.


 


Positive is, it is a full .NET solution.


Negative: most chiptunes don´t work properly, because Sharpmod & NAudio are still under development.


 


I think supported formats were *.s3m, *.xm and *.mod files.


 


Just include the .NET dll´s afterwards with ilmerge and you have a standalone pure .NET chip Player.


 


Cheers dude, I hope it helps.


VB .NET Mod Player from Resource by Freefall.rar

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...