Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: zawran on August 14, 2006
-
I am trying to finish my pak library and all that is missing is playing a mod tune from memory. From what I gather in the BASS help file, it should be able to load a tune from memory if setting the first parameter to TRUE and providing a pointer instead of a string as the second parameter. But I can't get that to work. Have anyone here made a tune load from memory using BASS or have everyone switched to that ufmod? I would like to stick with BASS since it can play anything without having to convert things to XM.
The help file of BASS have the following info on the MusicLoad function:
HMUSIC BASS_MusicLoad(
BOOL mem,
void *file,
DWORD offset,
DWORD length,
DWORD flags,
DWORD freq
);
Parameters
mem TRUE = load the MOD music from memory.
file Filename (mem = FALSE) or a memory location (mem = TRUE).
As you can see, it should be able to load from memory. In the BASS.BI include, it have the second paramter set up as zstring, so its probably a question of knowing how to convert the memory pointer, or something like that. Any input is appreciated.
-
Zawran, you'll be better off using Ufmod, check my step by step guide in this freebasic forum, it contains all you'll need to get your music working in Freebasic and it's much smaller than bass. The guide shows how to include the mod as part of your exe.
-
Hello Zawran, take a look at this topic Loading Tracker music as a resource (http://dbfinteractive.com/index.php?PHPSESSID=3ceee56160e08132c585a8af3f188773&topic=156.0)
I hope it help you :cheers:
-
I have already tried using ufmod, so I know how to get that working, but what I am doing is a packing library where all data resources, gfx, music, object data, etc. is packed into one file from which the data is extracted when loaded. So I don't really want to add each resource individually to the exe, but instead have one PAK file with everything inside. This is why I need to figure out, how to pass a pointer to the music store in memory. But when looking at the bass.bi file in the freebasic folder, it looks like the second parameter is a zstring pointer, not an integer pointer. So what I wanted to know is if someone knew how to pass the memory pointer to the bassload function, or if I could change the second parameter to something else since the help file seems to suggest that it should be able to accept a memory pointer as well. It could be that the freebasic bass.bi file wasn't made to support this, and that I will need to make changes in it to make it work.
-
Ok, here's an example to how to do that.
'---------------------------------------------------------
'
' Bass Music Player - Loading from Memory using Bin2Bas
'
' Code : Rbraz - 2006
'
'--------------------------------------------------------
option explicit
'Includes
#include once "bass.bi"
#include once "windows.bi"
'Include Music
#include "music.bas
Dim Shared module as HMUSIC
'Initialyze Bass system
if( BASS_GetVersion( ) < MAKELONG(2,2) ) then
MessageBox( NULL, "Error: BASS version 2.2 or above required", "Bass Music Player", MB_ICONERROR )
BASS_Free()
end -1
end if
if( not BASS_Init( -1, 44100, 0, 0, 0 ) ) then
MessageBox( NULL, "Error: BASS_Init failed", "Bass Music Player", MB_ICONERROR )
BASS_Free()
end -1
end if
'Load module from memory
module = BASS_MusicLoad( TRUE, _ ' BOOL mem,
@music(0) , _ ' void *file,
0, _ ' DWORD offset,
50601, _ ' DWORD length,
BASS_MUSIC_AUTOFREE or _ ' DWORD flags,
BASS_MUSIC_RAMPS or _ '
BASS_MUSIC_PRESCAN or _ '
BASS_MUSIC_SURROUND, _ '
0 ) ' DWORD freq
if( module = 0 ) then
MessageBox( NULL, "Can't load music " , "Bass Music Player", MB_ICONERROR )
BASS_Free()
end -1
else
BASS_ChannelPlay(module, TRUE)
end if
MessageBox( NULL, "Playing :) ..." , "Bass Music Player", MB_ICONEXCLAMATION )
BASS_Free()
-
@zawran: any news, do you got it working?
And I can't wait to see a new demo/intro from you :cheers:
-
I miss Zawrans demos too. A new one is long overdue, I know he comes here still but doesn't post much any more :(
-
I didn't get it to work. I haven't touched code for months now, which is really sad. Been spending my time working, playing online game, watching tv series. Just haven't had the motivation needed to code really. But I would like to think that I will get back into it soonish. I have had periods of absense from coding before, and always ended up getting back to it. Hopefully, I will soon find the inspiration and motivation. I already have an almost complete graphics library written for FreeBasic which can handle sprites, fonts and everything needed for demo stuff. Just never finished something using it.
I haven't been very active in posting, but I do check the forum just about each day to see whats going on. I also visit the official blitz forum to keep myself updated. So its not like I am totally gone, just in hibernation :)
-
Perhaps you can have a go at the next competition. It won't be for a little while but it should be a laugh and it might help to get you motivated again. :)
-
Yes that might be whats needed to push me back into it. Looking forward to see what its all about.
-
It's still in it's early stages, but we're thinking of doing an online style of comp, nothing has been decided yet though. We want to make sure that this one works out really well.