Login Register






[VB.NET+MusicString] MusicString DLL - use it from VB.NET! (source included) filter_list
Author
Message
[VB.NET+MusicString] MusicString DLL - use it from VB.NET! (source included) #1
[Image: logotext200px.png]
Hi there,
If you don't know about my project called MusicString yet, head to this thread and also check the Visual MusicString IDE. Simply put, it's a language that allows you to write music and tunes with just a few characters!

I now packaged it into a DLL library and made a simple API, that allows you to use MusicString in your own projects, including in VB.NET applications! It supports real-time playing and also compiling into a WAV file, all with a simple interface!

Download MusicString DLL + VB.NET sourcecode example

Here's a screenie from the example:

[Image: MusicStringVB.NET.png]

Here's the source of the Form:
Code:
' MusicString, MusicStringDLL and this VB.NET example are ' Written by Tomas "Frooxius" Mariancik ' http://frooxius.solirax.org/fromVBNET_MSTR ' http://musicstring.solirax.org/fromVBNET_MSTR ' This code and MusicString DLL are to use for non-commercial purposes Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' It is important to initialize the DLL first, so we can use its methods Dim something As Boolean = MusicStringAPI.Init() End Sub Private Sub buttPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttPlay.Click ' First, we must load the MusicString code to the DLL MusicStringAPI.SetMusicString(textCode.Text) ' Now Set the samplerate from the spinbox MusicStringAPI.SetSampleRate(spinPlayRate.Value) ' Now we call method that will start Playing the MusicString, could it be easier? :3 MusicStringAPI.Play() End Sub Private Sub buttPause_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttPause.Click ' Yaaawn... Do you really want me to explain this? MusicStringAPI.Pause() End Sub Private Sub buttStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttStop.Click ' Seriously, you should feel bad that I made it so simple for you by doing all the complex stuff in C++ x3 Nah, just kidding MusicStringAPI.StopPlaying() End Sub Private Sub buttGen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttGen.Click buttGen.Enabled = False ' Disable the button first ' Let's get a filename from user first Dim result As DialogResult = saveWAV.ShowDialog() If Not result = Windows.Forms.DialogResult.OK Then ' User didn't confirm the filename, so let's just call the whole thing off buttGen.Enabled = True ' Enable it again! Return End If ' Okay, we have a name, let's generate! ' First, set the samplerate MusicStringAPI.SetSampleRate(spinGenRate.Value) ' Now set the time limit (maximum length of generated audio) MusicStringAPI.SetSeconds(spinMaxTime.Value) ' Set the output file to a temporary file, we move it to user location later MusicStringAPI.SetOutFile("temp.wav") ' Don't forget to load the MusicString to generate too! MusicStringAPI.SetMusicString(textCode.Text) ' We're read to generate, we use phase compile, to show messages during compiling! Dim compileStatus As Integer Do While compileStatus = 0 compileStatus = MusicStringAPI.PhaseCompile() ' Update the message with current status labelStatus.Text = MusicStringAPI.GetStatus() Update() ' Update the form Loop ' Check if everything's fine, status 1 means everything went okay If compileStatus <> 1 Then MessageBox.Show("Sorry folks, something went wrong!") buttGen.Enabled = True ' Enable it again! Return End If ' Everything's fine, we can continue and move the generated file to user location IO.File.Move("temp.wav", saveWAV.FileName) buttGen.Enabled = True ' Enable it again! ' We're done! ^^ *bubbles* End Sub Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked System.Diagnostics.Process.Start("http://musicstring.solirax.org/fromVBNET_MSTR") End Sub Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked System.Diagnostics.Process.Start("http://frooxius.solirax.org/fromVBNET_MSTR") End Sub End Class

And here's the API header that links it with the methods from the DLL, you need to include this in every VB.NET project where you want to use the DLL library. Make sure to include both MusicStringDLL.dll and SDL.dll libraries with your VB.NET app!

Code:
' MusicString, MusicStringDLL and this VB.NET example are ' Written by Tomas "Frooxius" Mariancik ' http://frooxius.solirax.org/fromVBNET_MSTR ' http://musicstring.solirax.org/fromVBNET_MSTR ' This code and MusicString DLL are to use for non-commercial purposes Imports System.Runtime.InteropServices Public Class MusicStringAPI <DllImport("MusicStringDLL.dll", CallingConvention:=CallingConvention.Cdecl)> Public Shared Function Init() As Boolean End Function <DllImport("MusicStringDLL.dll", CallingConvention:=CallingConvention.Cdecl)> Public Shared Sub SetMusicString(ByVal musstr As String) End Sub <DllImport("MusicStringDLL.dll", CallingConvention:=CallingConvention.Cdecl)> Public Shared Sub SetOutFile(ByVal filename As String) End Sub <DllImport("MusicStringDLL.dll", CallingConvention:=CallingConvention.Cdecl)> Public Shared Sub SetSampleRate(ByVal rate As UInteger) End Sub <DllImport("MusicStringDLL.dll", CallingConvention:=CallingConvention.Cdecl)> Public Shared Sub SetSeconds(ByVal seconds As UInteger) End Sub <DllImport("MusicStringDLL.dll", CallingConvention:=CallingConvention.Cdecl)> Public Shared Function Play() As Boolean End Function <DllImport("MusicStringDLL.dll", CallingConvention:=CallingConvention.Cdecl)> Public Shared Sub Pause() End Sub <DllImport("MusicStringDLL.dll", CallingConvention:=CallingConvention.Cdecl, EntryPoint:="Stop")> Public Shared Sub StopPlaying() End Sub <DllImport("MusicStringDLL.dll", CallingConvention:=CallingConvention.Cdecl)> Public Shared Function GetStatus() As String End Function <DllImport("MusicStringDLL.dll", CallingConvention:=CallingConvention.Cdecl)> Public Shared Function PhaseCompile() As Integer End Function <DllImport("MusicStringDLL.dll", CallingConvention:=CallingConvention.Cdecl)> Public Shared Function Compile(ByVal musstr As String, ByVal filename As String, ByVal samplerate As UInteger, ByVal seconds As UInteger) As Boolean End Function End Class
I love creativity and creating, I love science and rational thought, I am an open atheist and avid self-learner.

Reply

RE: [VB.NET+MusicString] MusicString DLL - use it from VB.NET! (source included) #2
No replies ? o.o howcome! This is awesome share! Thank you!
Staff will never ever ask you for your personal information.
We know everything about you anyway.

Reply

RE: [VB.NET+MusicString] MusicString DLL - use it from VB.NET! (source included) #3
Frooxius, you keep amazing me! Nice work!
[Image: Signature.png]

Chek Out My Tutorials
| Set Up A Pentest Lab | How To Make Bitcoins |

Reply

RE: [VB.NET+MusicString] MusicString DLL - use it from VB.NET! (source included) #4
Oh thanks O.O Did/are you going to use it in any projects? :3
I love creativity and creating, I love science and rational thought, I am an open atheist and avid self-learner.

Reply