Well, I've looked long and hard and the furthest I got was looking at a program irrklang. It didn't work.
How do I play an xm song in the background of my vb.net app, im using visual studio 2012 if that matters. It's in literally every keygen on the internet, yet there isn't a single tutorial other than this one horrible video on youtube. XM Play using BassMod plugin - YouTube
This is my last resort, I really want to add some background music to my changelog.. :l it's a small fun feature but a huge pain in the ass.
deployment - How to play background music in a C# Console Application - Stack Overflow
Also check out the media.soundplayer class.
You can convert the code from C# to VB online and both share the same framework (in this case .net)
Oct 26, 2019 09:56 PM
(This post was last modified: Oct 26, 2019 09:58 PM by Eternal Darkness.)
I post my opinions, please try not to be offended... I am not saying I am superior, but my interpretation of what you are saying may be befuddling.
Oct 26, 2019 10:24 PM
(This post was last modified: Oct 26, 2019 10:25 PM by requiredhq.)
(Oct 26, 2019 09:56 PM)Eternal Darkness Wrote: GitHub - veso266/Chip-Player: A Simple Chip Player using BASSMOD.dll to play ChipTunes -> Chip-Player/PlayXM.cs at master veso266/Chip-Player GitHub
More bassmod info: Play XM in C++ - From File and Memory - CodeProject
This is good but it's not in visual studio 2012 vn.net, it's in like C to my knowledge. I know I need to reference the dll and the libraries will either be included or not depending on if it's for .net. Still a bit confused. Then how do I simply play a xm in the background. One command, upon trying to figure this out i know i need to dim some type of player then direct it to my.resources.file.xm but I know different programs have different commands like 2player or soundengine.
Oct 26, 2019 10:47 PM
(This post was last modified: Oct 26, 2019 10:56 PM by Eternal Darkness.)
(Oct 26, 2019 10:24 PM)requiredhq Wrote: This is good but it's not in visual studio 2012 vn.net, it's in like C to my knowledge. I know I need to reference the dll and the libraries will either be included or not depending on if it's for .net. Still a bit confused. Then how do I simply play a xm in the background. One command, upon trying to figure this out i know i need to dim some type of player then direct it to my.resources.file.xm but I know different programs have different commands like 2player or soundengine.
The GitHub link is to a C# file, which is easily converted to VB.NET. VB.NET is what you are writing it in, correct?
Some Converters:
https://converter.telerik.com/
https://www.carlosag.net/tools/codetranslator/
https://codeconverter.icsharpcode.net/
https://www.developerfusion.com/tools/co...arp-to-vb/
https://www.dotnetspider.com/convert/Csharp-To-Vb.aspx
https://www.tangiblesoftwaresolutions.co...erter.html
Likely you will need to touch up the output (conversion is not 100% accurate, but reasonably close).
Look at the other .cs files in the github repo in order to understand how to use the linked class... The class allows you to play xm files, the actual usage is in Program.cs...
I post my opinions, please try not to be offended... I am not saying I am superior, but my interpretation of what you are saying may be befuddling.
(Oct 26, 2019 10:47 PM)Eternal Darkness Wrote: The GitHub link is to a C# file, which is easily converted to VB.NET. VB.NET is what you are writing it in, correct?
Some Converters:
Code Converter C# to VB and VB to C# Telerik
CodeTranslator: Code Translation From VB.NET C# TypeScript Java
Convert VB.NET to/from C# online - Roslyn Code Converter
Convert C# to VB.NET - A free code conversion tool - developer Fusion
Convert C# to VB.NET. Convert C# projects to VB.NET
C# to VB.NET Converter
Likely you will need to touch up the output (conversion is not 100% accurate, but reasonably close).
Look at the other .cs files in the github repo in order to understand how to use the linked class... The class allows you to play xm files, the actual usage is in Program.cs...
Okay, I'm running into a few issues. First, I put song.xm in resources. However I'm having an issue "loading up" the song.
Code Public Sub New(ByVal FileName As String)
data = System.IO.File.ReadAllBytes(FileName)
End Sub
Public Sub New(ByVal XMData As Byte())
data = XMData
End Sub
My Code
Code Dim Data As New String
Dim xmdata As New Byte
Data = System.IO.File.ReadAllBytes(My.Resources.song)
xmdata = My.Resources.song
Simply doesn't work. It's saying 1 dimensional array cannot be converted to byte, etc. Error being my.resources.song and data.
My next error comes with importing the dll and 'using it's library?', don't quote me on that but I think that's what I am trying to do. I've tried doing imports bassmod.dll, which gives me a namespace error. Here's the certain code that I'm trying to reference.
Code <DllImport("BASSMOD.dll")>
Public Shared Function BASSMOD_Init(ByVal device As Integer, ByVal frequency As UInteger, ByVal flags As UInteger) As Integer
<DllImport("BASSMOD.dll", CharSet:=CharSet.Auto)>
<MarshalAs(UnmanagedType.Bool)>
Public Shared Function BASSMOD_Free() As Boolean
<DllImport("BASSMOD.dll")>
Public Shared Function BASSMOD_MusicLoad(
<MarshalAs(UnmanagedType.Bool)> ByVal mem As Boolean,
<[In]>
<MarshalAs(UnmanagedType.LPArray)> ByVal XMfile As Byte(), ByVal offset As UInteger, ByVal length As UInteger, ByVal flags As UInteger) As Integer
<DllImport("BASSMOD.dll")>
Public Shared Function BASSMOD_MusicPlay() As Integer
You're defining xmdata asone byte. You need to define it as an array of byte like this: Dim xmdata As Byte()
Oct 27, 2019 09:52 AM
(This post was last modified: Oct 27, 2019 10:08 AM by MavenGradle.)
(Oct 26, 2019 09:39 PM)Pawnhub Wrote: deployment - How to play background music in a C# Console Application - Stack Overflow
Also check out the media.soundplayer class.
You can convert the code from C# to VB online and both share the same framework (in this case .net)
The System.Media.SoundPlayer does not play XM formats. I quote from the MS docs:
Quote:Controls playback of a sound from a .wav file.
https://docs.microsoft.com/en-us/dotnet/...mework-4.8
(Oct 27, 2019 03:33 AM)requiredhq Wrote: Okay, I'm running into a few issues. First, I put song.xm in resources. However I'm having an issue "loading up" the song.
My Code
Code Dim Data As New String
Dim xmdata As New Byte
Data = System.IO.File.ReadAllBytes(My.Resources.song)
xmdata = My.Resources.song
Simply doesn't work. It's saying 1 dimensional array cannot be converted to byte, etc.error being my.resources.song and data.
Do you actually know the difference between a byte array and a byte? I recommend you to look up how to declare array variables.
Next up, in order to read a resource into a byte array, you do not use
Code System.IO.File.ReadAllBytes()
which evidently takes in the path of a FILE. A project resource is not always a file on your disk nor does providing this method with the actual resource work..
You could use something like this if you marked the file as a resource in your project:
Code Dim xmData() As Byte = My.Resources.I_am_an_idiot
Dim songLyrics As String = My.Resources.songlyrics
(Oct 27, 2019 09:52 AM)MavenGradle Wrote: --snip--
To be fair unless the program has to take in XM by default like from a 3rd party
OP could use a utility like so. Transform XM to WAV audio files online and for free!
Not Visual Basic but easy enough to convert or learn from https://github.com/veso266/Chip-Player
Oct 27, 2019 02:31 PM
(This post was last modified: Oct 27, 2019 03:41 PM by Eternal Darkness.)
(Oct 27, 2019 03:33 AM)requiredhq Wrote: Okay, I'm running into a few issues. First, I put song.xm in resources. However I'm having an issue "loading up" the song.
Code Public Sub New(ByVal FileName As String)
data = System.IO.File.ReadAllBytes(FileName)
End Sub
Public Sub New(ByVal XMData As Byte())
data = XMData
End Sub
My Code
Code Dim Data As New String
Dim xmdata As New Byte
Data = System.IO.File.ReadAllBytes(My.Resources.song)
xmdata = My.Resources.song
Simply doesn't work. It's saying 1 dimensional array cannot be converted to byte, etc.error being my.resources.song and data.
My nexterror comes with importing the dll and 'using it's library?', don't quote me on that but I think that's what I am trying to do. I've tried doing imports bassmod.dll, which gives me a namespace _error_. Here's the certain code that I'm trying to reference.
Code <DllImport("BASSMOD.dll")>
Public Shared Function BASSMOD_Init(ByVal device As Integer, ByVal frequency As UInteger, ByVal flags As UInteger) As Integer
<DllImport("BASSMOD.dll", CharSet:=CharSet.Auto)>
<MarshalAs(UnmanagedType.Bool)>
Public Shared Function BASSMOD_Free() As Boolean
<DllImport("BASSMOD.dll")>
Public Shared Function BASSMOD_MusicLoad(
<MarshalAs(UnmanagedType.Bool)> ByVal mem As Boolean,
<[In]>
<MarshalAs(UnmanagedType.LPArray)> ByVal XMfile As Byte(), ByVal offset As UInteger, ByVal length As UInteger, ByVal flags As UInteger) As Integer
<DllImport("BASSMOD.dll")>
Public Shared Function BASSMOD_MusicPlay() As Integer
System.IO.File.ReadAllBytes returns Byte() not a String. It loads a file from a string, not a Resource ( info).
If you compile the GitHub link I can confirm it works. All about knowing how things work...
If this is too complicated you can use LibVLC as they support xm files. Might be slightly simpler, with a bigger dependency of course. Just hide the "player" from the UI...
Find it funny the same GitHub repo was linked...
Working VB.NET code (this is a console app OP, take the class and set up the main method however you need it implemented in your program). (If you want to test, De-base64 the github audio file, copy the dll file to the debug folder, and compile for x86/32-bit architecture). You can swap in your xm file too...
Code Imports System.Runtime.InteropServices
Module ThisModuleNameDoesntMatter
Class PlayXM
Private data As Byte()
Public Sub New(ByVal FileName As String)
data = System.IO.File.ReadAllBytes(FileName)
End Sub
Public Sub New(ByVal XMData As Byte())
data = XMData
End Sub
Friend Structure BASSMOD_CONSTANTS
Public Const BASS_MUSIC_LOOP As Integer = 4
Public Const BASS_MUSIC_RAMPS As Integer = 2
Public Const BASS_MUSIC_SURROUND As Integer = 512
Public Const BASS_MUSIC_CALCLEN As Integer = 8192
Public Const BASS_SYNC_END As Integer = 2
End Structure
<DllImport("BASSMOD.dll")> Public Shared Function BASSMOD_Init(ByVal device As Integer, ByVal frequency As UInteger, ByVal flags As UInteger) As Integer
End Function
<DllImport("BASSMOD.dll", CharSet:=CharSet.Auto)> Public Shared Function BASSMOD_Free() As Boolean
End Function
<DllImport("BASSMOD.dll")> Public Shared Function BASSMOD_MusicLoad(<MarshalAs(UnmanagedType.Bool)> ByVal mem As Boolean, <[In]> <MarshalAs(UnmanagedType.LPArray)> ByVal XMfile As Byte(), ByVal offset As UInteger, ByVal length As UInteger, ByVal flags As UInteger) As Integer
End Function
<DllImport("BASSMOD.dll")> Public Shared Function BASSMOD_MusicPlay() As Integer
End Function
Public Sub Play()
BASSMOD_Init(-1, 44100, 0)
BASSMOD_MusicLoad(True, data, 0, CUInt(data.Length), BASSMOD_CONSTANTS.BASS_MUSIC_LOOP Or BASSMOD_CONSTANTS.BASS_MUSIC_RAMPS Or BASSMOD_CONSTANTS.BASS_MUSIC_SURROUND Or BASSMOD_CONSTANTS.BASS_MUSIC_CALCLEN)
BASSMOD_MusicPlay()
End Sub
Public Sub [Stop]()
BASSMOD_Free()
End Sub
End Class
Sub Main()
Dim keypress As New ConsoleKeyInfo()
Dim XM As PlayXM
Try
XM = New PlayXM("i_loved_you_by_heart.xm")
XM.Play()
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
keypress = Console.ReadKey(True)
Select Case keypress.Key
Case ConsoleKey.Escape
XM.[Stop]()
End Select
Console.ReadLine()
End Sub
End Module
You should be able to use a resource even, like so: XM = New PlayXM(My.Resources.resourceName)... Just make sure it is File-type:Binary (Properties of Resources Tab)...
I post my opinions, please try not to be offended... I am not saying I am superior, but my interpretation of what you are saying may be befuddling.
Personally I'd use minifmod.. This is the typical library used for most demoscene projects unless you've developed your own minimalistic library which benefits the file reduction techniques used.
The Tutorial is pretty much on point on how to do this.
Whats so stupid is you need it to use x86 not 64 for it to even work properly. also you can play from resources without an issue.
Oct 30, 2019 10:48 AM
(This post was last modified: Oct 30, 2019 10:52 AM by fisica638.)
It took me only a few minutes of basic documentation and 30m to do the program.
Well I have 2 ways to do it:
1) use the original api in c ++ and code a complete Wrapper on vb.net.
R : It will take me longer. So I did not. settle for the wrapper bug I found on the internet.
2) Use a Wrapper on .net that I found on the internet. Go a little bug.
R : Do not debug the program or it will give you an error. (It's the Wrapper, it seems that it doesn't detect the api in c ++ or something)
You have to build it and look for it manually in the debug folder and execute it that way.
Well it works great. It is what you wanted not?
Link : github.com/salsoft2111995/XM-Player/releases/tag/1.0
Please Comment! Thank you. 🤝
(Oct 30, 2019 10:48 AM)fisica638 Wrote: It took me only a few minutes of basic documentation and 30m to do the program.
Well I have 2 ways to do it:
1) use the original api in c ++ and code a complete Wrapper on vb.net.
R : It will take me longer. So I did not. settle for the wrapper bug I found on the internet.
2) Use a Wrapper on .net that I found on the internet. Go a little bug.
R : Do not debug the program or it will give you an _error_. (It's the Wrapper, it seems that it doesn't detect the api in c ++ or something)
You have to build it and look for it manually in the debug folder and execute it that way.
Well it works great. It is what you wanted not?
Link : github.com/salsoft2111995/XM-Player/releases/tag/1.0
Please Comment! Thank you. 🤝
Hey man looks awesome, good work. I'm having trouble importing the dlls into my own project, something about a com reference. I added them as existing items instead, used some of your code and am getting a namespace error on Imports Un4seen.BassMOD.BassMOD.
Any idea whats going on?
|