Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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?

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.

  • Author
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

  • Author
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...
  • Author
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
 

  • Author

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.