Author Topic: Storing Mod / XM Music to be read by Bass  (Read 5496 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Storing Mod / XM Music to be read by Bass
« on: August 25, 2007 »
I know there's a way of converting a Mod / XM tune into data and for use with UFMod. But is there a way to do this with Bass?

Cheers and all the very best,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline slippy

  • Atari ST
  • ***
  • Posts: 172
  • Karma: 42
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #1 on: August 25, 2007 »
Hey,

as far as I know it relies only on the capability of a player - if it supports in-mem loading  you may easily use the tool bin2bas by rbraz (http://www.rbraz.com/tools.htm)

or did I get your question wrong?

Cheers,
  SLiPPY


Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Storing Mod / XM Music to be read by Bass
« Reply #2 on: August 25, 2007 »
Nope I think you got the question right Slippy.

Aaand There's s bug in your sig :P I just tried to squash the ant crawling on my monitor. hehe.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #3 on: August 25, 2007 »
You could also try using voodooattack's incfile macro: http://www.freebasic.net/forum/viewtopic.php?t=8504

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #4 on: August 25, 2007 »
Thanks for that dudes, how'd I load that with Bass and not UFMod?

Cheers,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #5 on: August 25, 2007 »
I couldn't figure out how to get the incfile macro working with the full BASS library, however if you are using the the mod only bassmod.dll, this should work:

Code: [Select]
#include once "bassmod.bi"
#include once "incfile.bi"

incfile(cuteball, "cuteball.xm", share)

BASSMOD_Init(-1,44100,BASS_MUSIC_LOOP)


BASSMOD_MusicLoad(1, cuteball,0,0,0)

BASSMOD_MusicPlay()
?BASSMOD_ErrorGetCode

sleep

BASSMOD_MusicFree

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #6 on: August 25, 2007 »
Cheers Merick.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #7 on: August 25, 2007 »
oops, I made a little mistake. With incfile(handle, file, share), share should be either "true" or "false" depending on whether you want the handle for the incfile'd file to be dimmed as shared or not

Offline .:] Druid [:.

  • freebasic n00b
  • Pentium
  • *****
  • Posts: 563
  • Karma: 47
    • View Profile
    • Intro-Inferno
Re: Storing Mod / XM Music to be read by Bass
« Reply #8 on: August 25, 2007 »
Aaand There's s bug in your sig :P I just tried to squash the ant crawling on my monitor. hehe.

me too lol
[sheep]: im sure he wants to goto prison.. they didnt get him last time.. he was promised a big cock up his arse.. and no doubt looking forward to it.. lets hope he gets his wish this year.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #9 on: August 25, 2007 »
Ok cheers Merick. Going to try this abit later.
I was wondering if this can be done with the full bass lib.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #10 on: August 25, 2007 »
I've been trying to figure out how to use it with the full bass lib, but there's a problem with bass_musicload:

Code: [Select]
#include once "bass.bi"
#include once "incfile.bi"

incfile(cuteball, "cuteball.xm", true)

BASS_Init(-1,44100,0,0,0)

dim as hmusic music = BASS_MusicLoad(true, cuteball, 0, cuteball_len, BASS_MUSIC_FT2MOD, 44100)


?BASS_ChannelPlay(false, music)
?BASS_ErrorGetCode


sleep

BASS_Free

When I run this, "?BASS_ErrorGetCode" prints out 5, which is the code assigned to a bad handle, which means that BASS_MusicLoad is failing. I think the problem is that I don't really know what you're supposed to put in for the 3rd argument - "offset"

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2750
  • Karma: 493
    • View Profile
    • http://www.rbraz.com/
Re: Storing Mod / XM Music to be read by Bass
« Reply #11 on: August 25, 2007 »
Here's an example about loading music from memory

Code: [Select]
'---------------------------------------------------------
'
'   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()
   
Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #12 on: August 26, 2007 »
Ah, looks like the problem isn't with Bass_MusicLoad, but rather it's that BASS_init fails :(

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #13 on: August 26, 2007 »
Cheers Rbraz :)

Gonna try this tommorrow with Bin2Bas. :D
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #14 on: August 26, 2007 »
rbraz, with "not" being a bitwise operator, in your example, you will need to change this line:

if( not BASS_Init( -1, 44100, 0, 0, 0 ) ) then

to this:

if BASS_Init( -1, 44100, 0, 0, 0 ) = False then

or it will always show the bass_init failure popup

(at least with the latest svn of FB)

which means that the problem with my code really does have something to do with MusicLoad :(

*edit*

oops, I accidentally swapped some arguments, here's the corrected code, with this you can compile the music into the exe without having to convert it with Bin2Bas:

Code: [Select]
#include once "bass.bi"
#include once "incfile.bi"

incfile(cuteball, "cuteball.xm", true)

if (BASS_Init( -1, 44100, 0, 0, 0 )) = false then
?"Error: BASS_Init failed"
?BASS_ErrorGetCode()
BASS_Free()
end if


dim as HMUSIC music = BASS_MusicLoad(true, cuteball, 0, 0, BASS_MUSIC_FT2MOD, 44100)

if BASS_ChannelPlay(music, false) = false then
?"Error: BASS_ChannelPlay failed"
?BASS_ErrorGetCode
endif

sleep

BASS_Free
« Last Edit: August 26, 2007 by Merick »

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17394
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Storing Mod / XM Music to be read by Bass
« Reply #15 on: August 26, 2007 »
Now that is very useful indeed Merick. Thank you very much.

I will try it out myself :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Merick

  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Re: Storing Mod / XM Music to be read by Bass
« Reply #16 on: August 26, 2007 »
you should thank voodooattack, he's the one who came up with the macro  ;)