1. Bass Library?
- Posted by ron77 Aug 16, 2023
- 801 views
hi everyone i've been looking into how can I use and play sound and music with my programs... i like to make simple text games with sample royalty-free music or sounds and in freeBASIC there are some nice libraries to use (external ones) for both 32bit and 64bit both windows and linux - now I've looked into the github of euphoria and yes there are libraries for sound and music playing such as SDL2_mixer however there are recommended to 32 bit not for 64 bit and I'm on 64 bit Linux OS... anyway I've been thinking about translating with the help of someone the header of Bass Library from C to Euphoria to use with the actual library...
for those who are not familiar Bass is a good sound/music library that is very easy to use with other languages - it is written entirely in C and can play mp3 wav m4a ogg files and many other formats it has versions for win32 Linux 64 bit macOS freeDOS and many other OS's it's also very portable... I've personally used bass library both in C and in freeBasic programs/games I think it would be a good addition to the euphoria github project...
what do you think?
here is the link to the library: Bass Libray Site
2. Re: Bass Library?
- Posted by Icy_Viking Aug 16, 2023
- 789 views
hi everyone i've been looking into how can I use and play sound and music with my programs... i like to make simple text games with sample royalty-free music or sounds and in freeBASIC there are some nice libraries to use (external ones) for both 32bit and 64bit both windows and linux - now I've looked into the github of euphoria and yes there are libraries for sound and music playing such as SDL2_mixer however there are recommended to 32 bit not for 64 bit and I'm on 64 bit Linux OS... anyway I've been thinking about translating with the help of someone the header of Bass Library from C to Euphoria to use with the actual library...
for those who are not familiar Bass is a good sound/music library that is very easy to use with other languages - it is written entirely in C and can play mp3 wav m4a ogg files and many other formats it has versions for win32 Linux 64 bit macOS freeDOS and many other OS's it's also very portable... I've personally used bass library both in C and in freeBasic programs/games I think it would be a good addition to the euphoria github project...
what do you think?
here is the link to the library: Bass Libray Site
If you want to make an updated wrapper for the Bass library go for it. I thought about making a wrapper myself, but I already made a wrapper for SoLoud.
https://github.com/gAndy50/EuSoLoud
You can use it with 64-bit Euphoria, you just need to use the 64-bit DLL along with 64-bit euphoria. I need to update it for use with Greg's FFI library, but it still works well. I guess I should say .so or shared library file in your case since you're under Linux. My OS is Windows, but I do have WSL installed. So I can test for both Windows and Linux. I'm a 64-bit OS myself, but I use the 32-bit version of DLLs or shared libraries for compatibility reasons.
3. Re: Bass Library?
- Posted by ron77 Aug 16, 2023
- 773 views
hello thanks well i did made an attempt to convert the C/Cpp bass library header into a euphoria header (.e file) and then test it but i cheated to make a shortcut i used chatGPT to slowly convert the header from C/Cpp to euphoria each time a slice of the code (some 250 - 300 lines chunk each time)the result is a buggy header since GPT doesn't know well euphoria nor is accurate to-be-honest... but here is the code of the header I'm using "pastey" and also bringing the bassTest file i made converted from freebasic to euphoria...
include bass.e -- Call this once at the beginning of the program if BASS_GetVersion() < MAKELONG(2, 2) then puts(1, "BASS version 2.2 or above required!") abort(1) end if if BASS_Init(-1, 44100, 0, 0, 0) = 0 then puts(1, "Could not initialize BASS") abort(1) end if global HMUSIC g_BackgroundMusic procedure stopMusic(music) if music = 0 then music = g_BackgroundMusic end if if music then BASS_ChannelStop(music) end procedure procedure freeMusic(music) if music = 0 then music = g_BackgroundMusic : g_BackgroundMusic = 0 end if if music then BASS_MusicFree(music) end procedure function playMusic(soundfile) if g_BackgroundMusic then stopMusic(g_BackgroundMusic) freeMusic(g_BackgroundMusic) g_BackgroundMusic = 0 end if object music = BASS_StreamCreateFile(0, soundfile, 0, 0, 0) if music then g_BackgroundMusic = music BASS_ChannelPlay(music, 0) end if return music end function playMusic("test1.mp3") puts(1,"playing the test music file - mp3") wait_key() stopMusic() freeMusic() puts(1,"\n\ntest completed")
the error I'm getting is :
/home/ronen/Documents/euphoria/bass_eu_header/bass.e:48 <0076>:: expected to see an assignment after 'define', such as =, +=, -=, *=, /= or &= type HMUSIC = atom, -- MOD music handle ^ Press Enter
here is bass.e header code from pastey:
4. Re: Bass Library?
- Posted by ron77 Aug 16, 2023
- 790 views
If you want to make an updated wrapper for the Bass library go for it. I thought about making a wrapper myself, but I already made a wrapper for SoLoud.
https://github.com/gAndy50/EuSoLoud
You can use it with 64-bit Euphoria, you just need to use the 64-bit DLL along with 64-bit euphoria. I need to update it for use with Greg's FFI library, but it still works well. I guess I should say .so or shared library file in your case since you're under Linux. My OS is Windows, but I do have WSL installed. So I can test for both Windows and Linux. I'm a 64-bit OS myself, but I use the 32-bit version of DLLs or shared libraries for compatibility reasons.
hi Ice_viking :) I tried SoLoud Library wrapper I downloaded the 64 bit dll with SDL.dll from SoLoud Library site and tried the "flags.e" file I got an error :(
/home/ronen/Documents/euphoria/EuSoLoud-main/EuSoLoud.ew:40 in function Soloud_create() c_proc/c_func: bad routine number (-1) ... called from /home/ronen/Documents/euphoria/EuSoLoud-main/Ex.exw:8 --> See ex.err ------------------ (program exited with code: 1) Press return to continue
any clue what I'm doing wrong? i tried to look for the .so libs for linux but all I found was dll files 86x and 64x I'm using the 64x dll...
5. Re: Bass Library?
- Posted by Icy_Viking Aug 16, 2023
- 766 views
If you want to make an updated wrapper for the Bass library go for it. I thought about making a wrapper myself, but I already made a wrapper for SoLoud.
https://github.com/gAndy50/EuSoLoud
You can use it with 64-bit Euphoria, you just need to use the 64-bit DLL along with 64-bit euphoria. I need to update it for use with Greg's FFI library, but it still works well. I guess I should say .so or shared library file in your case since you're under Linux. My OS is Windows, but I do have WSL installed. So I can test for both Windows and Linux. I'm a 64-bit OS myself, but I use the 32-bit version of DLLs or shared libraries for compatibility reasons.
hi Ice_viking :) I tried SoLoud Library wrapper I downloaded the 64 bit dll with SDL.dll from SoLoud Library site and tried the "flags.e" file I got an error :(
/home/ronen/Documents/euphoria/EuSoLoud-main/EuSoLoud.ew:40 in function Soloud_create() c_proc/c_func: bad routine number (-1) ... called from /home/ronen/Documents/euphoria/EuSoLoud-main/Ex.exw:8 --> See ex.err ------------------ (program exited with code: 1) Press return to continue
any clue what I'm doing wrong? i tried to look for the .so libs for linux but all I found was dll files 86x and 64x I'm using the 64x dll...
Well here is the Soloud github. https://github.com/jarikomppa/soloud
You may have to build it from source for the .so files. The reason you're getting the bad routine id error is because you're probably using the 32-bit DLL on a 64-bit Euphoria. You'll need to use the 64-bit DLL/.so for it to work properly. You'll want the "Soloud_x64.DLL" instead of the "Soloud_x86.DLL" I should probably add in the 64-bit DLL. So users can pick between the 32 or 64-bit DLL.
include std/machine.e include std/dll.e include std/os.e atom sol ifdef WIN32 then --change WIN32 to WINDOWS sol = open_dll("soloud_x86.dll") -- change to soloud_x64.dll for 64-bits elsifdef LINUX or FREEBSD then sol = open_dll("soloud_x86.so") --change to soloud_x64.so for 64-bits end ifdef
Or since you're on Linux, you could probably just do this
include std/dll.e public atom sol = 0 ifdef LINUX or FREEBSD then sol = open_dll("soloud_x64.so") end ifdef
6. Re: Bass Library?
- Posted by ron77 Aug 16, 2023
- 740 views
hi Icy_viking...
well the thig is i don't know how to compile a library with GCC on linux or on windows (I got GCC and codeblocks) however I have wine 32 bit on my linux and I managed to use the soloud library after I installed euphoria 32 bit on it so I am able to run the interpreter but not compile under wine 32 bit with euc but eui runs well...
I'm not really that good at compiling libraries on GCC... :( at least soloud code worked on wine 32 bit :) still I don't see how I can play sound/music with euphoria on my 64 bit linux...
7. Re: Bass Library?
- Posted by petelomax Aug 16, 2023
- 720 views
A couple of years ago I wrote a little wrapper for bass, however
- it is pretty basic
- it only works on Windows
- it was written for Phix
You can download it from http://phix.x10.mx/pmwiki/pmwiki.php?n=Main.Bass and view examples of use at
https://rosettacode.org/wiki/Audio_overlap_loop#Phix and
https://rosettacode.org/wiki/Audio_alarm#Phix
I'd be perfectly happy to collaborate with you on extending that to work on Linux (and Eu), as long as
you are doing the bulk of the testing and can provide all the "install on linux" details, specifically
being what you have to download (from un4seen) and which directories you need to put things in.
I really won't care if that (PCAN) download ends up 15MB but equally would have no objection to splitting
it into four or five platform specific pieces.
Just this week I also happened to stumble on a YouTube video of someone using ChatGPT to write code,
they pasted any errors back in, which makes ChatGPT try a bit harder... Ultimately they concluded that
while quite impressive the output was pretty much useless and completely impossible to maintain.
Obviously no real harm getting it to do some gruntwork, but it cannot possibly "understand things for you",
that is in the same way it cannot "sleep" or "exercise" or "eat a healthy diet" for you, though it can
(perhaps) give you some useful tips on all four.
8. Re: Bass Library?
- Posted by ron77 Aug 17, 2023
- 704 views
A couple of years ago I wrote a little wrapper for bass, however
- it is pretty basic
- it only works on Windows
- it was written for Phix
You can download it from http://phix.x10.mx/pmwiki/pmwiki.php?n=Main.Bass and view examples of use at
https://rosettacode.org/wiki/Audio_overlap_loop#Phix and
https://rosettacode.org/wiki/Audio_alarm#Phix
I'd be perfectly happy to collaborate with you on extending that to work on Linux (and Eu), as long as
you are doing the bulk of the testing and can provide all the "install on linux" details, specifically
being what you have to download (from un4seen) and which directories you need to put things in.
I really won't care if that (PCAN) download ends up 15MB but equally would have no objection to splitting
it into four or five platform specific pieces.
Just this week I also happened to stumble on a YouTube video of someone using ChatGPT to write code,
they pasted any errors back in, which makes ChatGPT try a bit harder... Ultimately they concluded that
while quite impressive the output was pretty much useless and completely impossible to maintain.
Obviously no real harm getting it to do some gruntwork, but it cannot possibly "understand things for you",
that is in the same way it cannot "sleep" or "exercise" or "eat a healthy diet" for you, though it can
(perhaps) give you some useful tips on all four.
hello I answered to you by email (sent you a mail to your profile address)
9. Re: Bass Library?
- Posted by petelomax Aug 17, 2023
- 686 views
hello I answered to you by email (sent you a mail to your profile address)
Probably better if we communicate here: we've got nothing to hide, someone else might take an interest
and maybe even chip in at some point with a fix for something stumping both of us two, or while I sleep.
It's actually been quite a while since I wrote any Eu-compatible code, so I might need the odd correction.
bass.e:21 <0069>:: expected ',' or ')'
Ah yes, Eu uses iif() whereas Phix can use that or iff(). Will correct that.
I tried to run AudioOverlapLoop.exw
Good choice, the AudioAlarm example I linked would be nightmarish to get working on Eu, since my pGUI.e
is strictly Phix-only, and it would be much easier to start that from scratch, or translate a C sample.
sudo cp libbass.so /usr/local/lib (to copy bass library into linux lib)
sudo chmod a+rx /usr/local/lib/libbass.so (to load the lib)
sudo ldconfig (to autoconfig)
That'll do nicely, thanks. I've updated the PCAN page
(Obviously you just need bass.e and don't need and can ignore the binaries)
Ah, I forgot the updated sample:
constant dl = `Download rosetta\bass\ from http://phix.x10.mx/pmwiki/pmwiki.php?n=Main.Bass` --/**/constant ftok = get_file_type("bass")=FILETYPE_DIRECTORY --/* include std/filesys.e -- file_type() include std/console.e -- wait_key() constant ftok = file_type("bass")=2 --*/ if not ftok then crash(dl) end if include bass\bass.e BASS_Init(-1, 44100) for i=1 to 5 do atom filePlayerHandle = BASS_StreamCreateFile(false, `bass\Scream01.mp3`) BASS_ChannelPlay(filePlayerHandle) sleep(0.2) end for ?"done" integer k = wait_key()
If that doesn't work, can you try replacing two lines near the top of bass.e with these:
libnames = {sprintf(`bass\%d\bass.dll`,{machine_bits()}),"libbass.so"}, libname = libnames[lwdx],