Lavos Posted March 27, 2011 Author Share Posted March 27, 2011 Alright I've used Damian666 tutorial as a reference to get this working so a big thanks to him for making this possible.~~Keep in mind that it doesn't loop the file after it's done playing. So I'm afraid you are just going to deal with it, until someone can figure this out.~~ Also keep in mind this is my first tutorial so go easy on me. xDIn modGenerals find: Main() and replace it.```Public Sub Main() ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler ' set loading screen loadGUI True frmLoad.Visible = True ' load options Call SetStatus("Loading Options...") LoadOptions ' load main menu Call SetStatus("Loading Menu...") Load frmMenu ' load gui Call SetStatus("Loading interface...") loadGUI ' Check if the directory is there, if its not make it ChkDir App.Path & "\data files\", "graphics" ChkDir App.Path & "\data files\graphics\", "animations" ChkDir App.Path & "\data files\graphics\", "characters" ChkDir App.Path & "\data files\graphics\", "items" ChkDir App.Path & "\data files\graphics\", "paperdolls" ChkDir App.Path & "\data files\graphics\", "resources" ChkDir App.Path & "\data files\graphics\", "spellicons" ChkDir App.Path & "\data files\graphics\", "tilesets" ChkDir App.Path & "\data files\graphics\", "faces" ChkDir App.Path & "\data files\graphics\", "gui" ChkDir App.Path & "\data files\graphics\gui\", "menu" ChkDir App.Path & "\data files\graphics\gui\", "main" ChkDir App.Path & "\data files\graphics\gui\menu\", "buttons" ChkDir App.Path & "\data files\graphics\gui\main\", "buttons" ChkDir App.Path & "\data files\graphics\gui\main\", "bars" ChkDir App.Path & "\data files\", "logs" ChkDir App.Path & "\data files\", "maps" ChkDir App.Path & "\data files\", "music" ChkDir App.Path & "\data files\", "sound" ' Link the dll to the form InitOgg frmMenu.hwnd, 0& InitOgg frmMain.hwnd, 0& ' load the main game (and by extension, pre-load DD7) GettingMap = True vbQuote = ChrW$(34) ' " ' Update the form with the game's name before it's loaded frmMain.Caption = Options.Game_Name ' initialize DirectX If Not InitDirectDraw Then MsgBox "Error Initializing DirectX7 - DirectDraw." DestroyGame End If ' randomize rnd's seed Randomize Call SetStatus("Initializing TCP settings...") Call TcpInit Call InitMessages Call SetStatus("Initializing DirectX...") ' DX7 Master Object is already created, early binding Call CheckTilesets Call CheckCharacters Call CheckPaperdolls Call CheckAnimations Call CheckItems Call CheckResources Call CheckSpellIcons Call CheckFaces ' temp set music/sound vars Music_On = True Sound_On = True ' load music/sound engine InitSound InitMusic ' check if we have main-menu music If Len(Trim$(Options.MenuMusic)) > 0 Then PlayMidi Trim$(Options.MenuMusic) ' Reset values Ping = -1 'Load frmMainMenu Load frmMenu ' cache the buttons then reset & render them Call SetStatus("Loading buttons...") cacheButtons resetButtons_Menu ' we can now see it frmMenu.Visible = True ' hide all pics frmMenu.picCredits.Visible = False frmMenu.picLogin.Visible = False frmMenu.picCharacter.Visible = False frmMenu.picRegister.Visible = False ' set values for directional blocking arrows DirArrowX(1) = 12 ' up DirArrowY(1) = 0 DirArrowX(2) = 12 ' down DirArrowY(2) = 23 DirArrowX(3) = 0 ' left DirArrowY(3) = 12 DirArrowX(4) = 23 ' right DirArrowY(4) = 12 ' set the paperdoll order ReDim PaperdollOrder(1 To Equipment.Equipment_Count - 1) As Long PaperdollOrder(1) = Equipment.Armor PaperdollOrder(2) = Equipment.Helmet PaperdollOrder(3) = Equipment.Shield PaperdollOrder(4) = Equipment.Weapon ' hide the load form frmLoad.Visible = False ' Error handler Exit Suberrorhandler: HandleError "Main", "modGeneral", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```Then find: UnloadAllForms() and replace it.```Public Sub UnloadAllForms()Dim frm As Form ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler For Each frm In VB.Forms CloseOgg frmMain.tmrOgg.Interval = 0 InitOgg frmMenu.hwnd, 0& = False InitOgg frmMain.hwnd, 0& = False Unload frm Next ' Error handler Exit Suberrorhandler: HandleError "UnloadAllForms", "modGeneral", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```Last find: PopulateLists() and replace it.```Public Sub PopulateLists()Dim strLoad As String, i As Long ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler ' Cache music list strLoad = Dir(App.Path & MUSIC_PATH & "*.ogg") i = 1 Do While strLoad > vbNullString ReDim Preserve musicCache(1 To i) As String musicCache(i) = strLoad strLoad = Dir i = i + 1 Loop ' Cache sound list strLoad = Dir(App.Path & SOUND_PATH & "*.wav") i = 1 Do While strLoad > vbNullString ReDim Preserve soundCache(1 To i) As String soundCache(i) = strLoad strLoad = Dir i = i + 1 Loop ' Error handler Exit Suberrorhandler: HandleError "PopulateLists", "modGeneral", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```Now in modSounds add in```Declare Function InitOgg Lib "vbogg.dll" (ByVal hwnd As Long, ByVal IsGlobal As Long) As Long' returns true if bad file, false if okDeclare Function PlayOggFile Lib "vbogg.dll" (ByVal fileName As String) As LongDeclare Function OggIsPlaying Lib "vbogg.dll" () As LongDeclare Function StopOgg Lib "vbogg.dll" () As LongDeclare Function UpdateOgg Lib "vbogg.dll" () As LongDeclare Function CloseOgg Lib "vbogg.dll" () As LongDeclare Function SetOggVolume Lib "vbogg.dll" (ByVal Volume As Long) As LongDeclare Function SetOggPan Lib "vbogg.dll" (ByVal Position As Long) As Long```find: PlayMidi and replace it with this code.```Public Sub PlayMidi(ByVal fileName As String)Dim Splitmusic() As String If Options.Music = 0 Then Exit Sub Splitmusic = Split(fileName, ".", , vbTextCompare) If Performance Is Nothing Then Exit Sub If LenB(Trim$(fileName)) < 1 Then Exit Sub If UBound(Splitmusic) <> 1 Then Exit Sub If Not FileExist(App.Path & MUSIC_PATH & fileName, True) Then Exit Sub If Not Music_On Then Exit Sub If Music_Playing = fileName Then Exit Sub If Splitmusic(1) = "ogg" Then PlayOggFile (App.Path & MUSIC_PATH & fileName) frmMain.tmrOgg.Interval = 250 Exit Sub ElseIf Splitmusic(1) <> "mid" Then Exit Sub End If Set Segment = Nothing Set Segment = Loader.LoadSegment(App.Path & MUSIC_PATH & fileName) ' repeat midi file Segment.SetLoopPoints 0, 0 Segment.SetRepeats 100 Segment.SetStandardMidiFile Performance.PlaySegment Segment, 0, 0 Music_Playing = fileNameEnd Sub```Then find: StopMidi() and replace it.```Public Sub StopMidi() ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler StopOgg frmMain.tmrOgg.Interval = 0 ' Error handler Exit Suberrorhandler: HandleError "StopMidi", "modSound", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```Now make a timer on frmMain and name it tmrOgg. then add the code in.```Private Sub tmrOgg_Timer()Dim MusicFile As String If (OggIsPlaying And 1) = 1 Then UpdateOgg Else ' start music playing MusicFile = Trim$(Map.Music) If Not MusicFile = "None." Then PlayMidi MusicFile End If End IfEnd Sub```Then in frmMapProperites under cmdPlay add Options.Music = 1 and cmdStop add Options.Music = 0Then Download the dll files and add it to your folder.Link: http://www.mediafire.com/?xqvfckf9wfdowo0Done! I hope I didn't miss anything else otherwise send a feed back if there is any problem.=) Link to comment Share on other sites More sharing options...
damian666 Posted March 27, 2011 Share Posted March 27, 2011 what you could do to make it loop, is add a check for if its playing, if not, restart it.just add it in the main loop, something like LoopOgg()```Public sub LoopOgg() if not OggIsPlaying then PlayOggFile(map.music) end ifend sub```please note this is code from the top of my head, and should proberly be adjusted to work, lets call it pseudo code shall we? xdDami Link to comment Share on other sites More sharing options...
Lavos Posted March 28, 2011 Author Share Posted March 28, 2011 PlayOggFile will crash if you try to use it with any other format, but I finally figured it out. I've updated the first post so everything should work fine now. The only issues is that when I name my .ogg files to numbers, it saves it in the map file. Any other names would not save.Its also sloppy but it works :cheesy: Link to comment Share on other sites More sharing options...
Broojo02 Posted April 11, 2011 Share Posted April 11, 2011 Hi there, just tried the tutorial and it works :)Although there are a few things that could do with improving in the topic. Its best not to put code inside a spoiler box as you cant see all of it when you open the box, I like to see what code I'm adding to my source and it can be quite off putting pasting in something you don't know the size of.Another issue is that all of your code requires overwriting subs with your own subs, this is fine if you are working with a fresh copy of Eclipse but not at all good if you have added in your own stuff or used other tutorials. For instance you told us to completely overwite the Sub Main while only adding in 2 extra lines of code.Also you have some code that you have left over from another tutorial or something, "Call CheckBackgrounds" that gives an error. Link to comment Share on other sites More sharing options...
Lavos Posted April 12, 2011 Author Share Posted April 12, 2011 Thanks for pointing that out. I got checkbackground removed from the tutorial. Also sorry about the whole replacing the sub issue. This tutorial was mainly aimed for people who are still new to vb6, but I'm sure with skilled programmers would be able to read what is going on with the code. Link to comment Share on other sites More sharing options...
Broojo02 Posted April 12, 2011 Share Posted April 12, 2011 Cool, thanks looks a lot better now :) Link to comment Share on other sites More sharing options...
EisKeks Posted April 17, 2011 Share Posted April 17, 2011 > Now in modSounds add in> > Code: [Select]> Declare Function InitOgg Lib "vbogg.dll" (ByVal hwnd As Long, ByVal IsGlobal As Long) As Long> > ' returns true if bad file, false if ok> Declare Function PlayOggFile Lib "vbogg.dll" (ByVal fileName As String) As Long> > Declare Function OggIsPlaying Lib "vbogg.dll" () As Long> Declare Function StopOgg Lib "vbogg.dll" () As Long> Declare Function UpdateOgg Lib "vbogg.dll" () As Long> Declare Function CloseOgg Lib "vbogg.dll" () As Long> Declare Function SetOggVolume Lib "vbogg.dll" (ByVal Volume As Long) As Long> Declare Function SetOggPan Lib "vbogg.dll" (ByVal Position As Long) As LongWhere to add in in modSound?? ò.O Link to comment Share on other sites More sharing options...
Ruins of Hell Posted April 17, 2011 Share Posted April 17, 2011 At the top of modSounds. Link to comment Share on other sites More sharing options...
EisKeks Posted April 17, 2011 Share Posted April 17, 2011 Thanks ;D Link to comment Share on other sites More sharing options...
EisKeks Posted April 17, 2011 Share Posted April 17, 2011 So i got the same problem like in the MP3 turtorial i've done all 3 times but nothing happens when i push on play :/ the files are shown up but they dont want to play if i press the play button… :/ can some one help me? i got no error or like that the only thing is that the files make no sound. Link to comment Share on other sites More sharing options...
EisKeks Posted April 18, 2011 Share Posted April 18, 2011 so i added this here```Private Sub cmdStop_Click() ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Add Options.Music = 0 StopMidi ' Error handler Exit Suberrorhandler: HandleError "cmdStop_Click", "frmEditor_MapProperties", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```And the play here```Private Sub cmdPlay_Click() ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Options.Music = 1 StopMidi PlayMidi lstMusic.List(lstMusic.ListIndex) ' Error handler Exit Suberrorhandler: HandleError "cmdPlay_Click", "frmEditor_MapProperties", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```should i have to add something in the server? because itt dont plays my musik >.< Link to comment Share on other sites More sharing options...
Furryfox137 Posted May 12, 2011 Share Posted May 12, 2011 I put in everything where you wanted me to in visual basic 6\. I wasn't sure of where to put Options.Music = 1 and Options.Music = 0 in cmdplay and cmdstop so i put them where i thought they should go. Whenever i go to map properties the .ogg files i have in the music folder don't show up. Link to comment Share on other sites More sharing options...
Lavos Posted May 13, 2011 Author Share Posted May 13, 2011 @Furryfox137:> I put in everything where you wanted me to in visual basic 6\. I wasn't sure of where to put Options.Music = 1 and Options.Music = 0 in cmdplay and cmdstop so i put them where i thought they should go. Whenever i go to map properties the .ogg files i have in the music folder don't show up.Double check everything. You probably not following the tutorial correctly. Look into modGenerals and modSounds to see if you have done everything with each sub. Link to comment Share on other sites More sharing options...
nn22nn22 Posted May 29, 2011 Share Posted May 29, 2011 can you make this so mp3's play? Link to comment Share on other sites More sharing options...
erkro1 Posted May 29, 2011 Share Posted May 29, 2011 @nn22nn22:> can you make this so mp3's play?Damain already made it :http://www.touchofdeathforums.com/smf/index.php/topic,68358.0.html Link to comment Share on other sites More sharing options...
RyokuHasu Posted June 9, 2011 Share Posted June 9, 2011 ~~How would I get this to work with sounds for Items and spells? I have 180 sound effects in OOG format.-_-… as a matter of fact i cant use this thanks to previous mods... can some one please rewrite this to be more fiendly with custom clients and servers. Mine had way too many errors to count.~~I have a converter (found one) XD Link to comment Share on other sites More sharing options...
damian666 Posted June 9, 2011 Share Posted June 9, 2011 problem is, this stuff doezsnt layer the sounds, it plays one at a time.same with my mp3 tut btw, thats why i moved first to fmod, which sucks xd, and then to bass.dll, also sucks, but atleast less then Fmod.Dami Link to comment Share on other sites More sharing options...
Mondo Posted April 9, 2012 Share Posted April 9, 2012 Hello,Awesome tutorial, tried it and works wonders :) However I Noticed that stopmidi deleted the following lines: If Not (Performance Is Nothing) Then Performance.Stop Segment, Nothing, 0, 0 Music_Playing = vbNullStringHence if a midi was playing it will not stop it… if you add that line back it stops both midi and ogg... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now