Jump to content
Tuts 4 You

Playing tracker file with BASS [C++, MinGW]


Bang1338

Recommended Posts

Posted

Hi, I'm trying to make my program to play tracker

This time, i'm using BASS

hResource = FindResource(NULL, MAKEINTRESOURCE(IDR_BASS), "BINARY");
        hResourceLoaded = LoadResource(NULL, hResource);
        lpBuffer = (LPBYTE)LockResource(hResourceLoaded);
        dwFileSize = SizeofResource(0, hResource);
        GetTempPath(MAX_PATH, szTempName);
        GetTempFileName(szTempName, "MOD", 0, szTempName);
        hFile = CreateFile(szTempName,GENERIC_READ | GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
        WriteFile(hFile, lpBuffer, dwFileSize, &dwBytesWritten, 0);
        CloseHandle(hFile);

        hLibrary = LoadLibrary(szTempName);
        BASS_MusicLoadAddr = (BassMusicLoad)GetProcAddress(hLibrary, "BASS_MusicLoad");
        BASS_InitAddr = (BassInit)GetProcAddress(hLibrary, "BASS_Init");
        BASS_FreeAddr = (BassFree)GetProcAddress(hLibrary, "BASS_Free");
        BASS_ChannelPlayAddr = (BassChannelPlay)GetProcAddress(hLibrary, "BASS_ChannelPlay");
        BASS_ChannelStopAddr = (BassChannelStop)GetProcAddress(hLibrary, "BASS_ChannelStop");
        BASS_SetVolumeAddr = (BassSetVolume)GetProcAddress(hLibrary, "BASS_SetVolume");
        BASS_ChannelIsActiveAddr = (BassChannelIsActive)GetProcAddress(hLibrary, "BASS_ChannelIsActive");
        BASS_ErrorGetCodeAddr = (BassErrorGetCode)GetProcAddress(hLibrary, "BASS_ErrorGetCode");
        BASS_InitAddr(-1, 44100, BASS_DEVICE_NOSPEAKER, hwndDlg, NULL);
        hResource2 = FindResource(NULL, MAKEINTRESOURCE(IDR_SONG), "BINARY");
        dwFileSize2 = SizeofResource(NULL, hResource2);
        hResourceLoaded2 = LoadResource(NULL, hResource2);
        hSong = LockResource(hResourceLoaded2);
        hMusic = BASS_MusicLoadAddr(TRUE, hSong, 0, dwFileSize2, BASS_MUSIC_LOOP | BASS_MUSIC_RAMPS | BASS_MUSIC_SURROUND2, 44100);
        BASS_ChannelPlayAddr(hMusic, FALSE);

however, this happened:

spacer.png

My guess is this line caused the error

        lpBuffer = (LPBYTE)LockResource(hResourceLoaded);
        dwFileSize = SizeofResource(0, hResource);
        GetTempPath(MAX_PATH, szTempName);
        GetTempFileName(szTempName, "MOD", 0, szTempName);
        hFile = CreateFile(szTempName,GENERIC_READ | GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
        WriteFile(hFile, lpBuffer, dwFileSize, &dwBytesWritten, 0);

Do you know where i'm wrong and how can i fix this issues?

Posted

Looks like the call to LoadLibrary failed. Most likely reasons: your code is 64bit but the DLL is 32bit (or vice versa), or your machine is missing some Microsoft Redistributable package that BASS requires.

Posted (edited)
6 hours ago, kao said:

Looks like the call to LoadLibrary failed. Most likely reasons: your code is 64bit but the DLL is 32bit (or vice versa), or your machine is missing some Microsoft Redistributable package that BASS requires.

I forgot to mention that when file exported to temp but it's not writen

I used basstest.c from asmcommunity (http://www.asmcommunity.net/forums/topic/?id=25338)

basstest.c

Extra: How to change 64bit to 32bit?

Edited by Bang1338
Posted
23 hours ago, kao said:

Looks like the call to LoadLibrary failed. Most likely reasons: your code is 64bit but the DLL is 32bit (or vice versa), or your machine is missing some Microsoft Redistributable package that BASS requires.

When I changed to compile 32bit, I got this:

error: ld returned 1 exit status

 

Added options (codeblocks): 

Project > Build Options > General > Target x86 (32 bit)

also tried:

Settings > Compiler > General > Target x86 (32 bit)

whythis.png

  • 4 months later...
Posted
On 12/15/2022 at 11:17 PM, kao said:

Looks like the call to LoadLibrary failed. Most likely reasons: your code is 64bit but the DLL is 32bit (or vice versa), or your machine is missing some Microsoft Redistributable package that BASS requires.

 

I tried in WindowsXP VM, but this still happening

image.png.71b8a3d4065ae5112d6e1d6e04539571.png
 

Posted (edited)

Turn out this line of code:

hResource = FindResourceA(NULL, MAKEINTRESOURCE(IDR_BASS), "BINARY");


Give the null, so...

Edited by Bang1338

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...