Music Playback

Monkey Forums/Monkey Programming/Music Playback

Raz(Posted 2015) [#1]
Hi all,

the built in system for playing music in Monkey does not lend it self very well to loading and playing files midway through game play.

I figure it's best if I use an external system, something like Fmod or Bass.dll maybe, I'm wondering if anyone has any experience with either?

Or... is there a way to improve the the GLFW target to stream audio files during play?

Ta!


Nobuyuki(Posted 2015) [#2]
There's been threads in the past that had working examples of hooking bass.dll through a simple wrapper. If you are willing to pay the fee to use it in your project, then great. If not, then let me know if you decide to dig into raw OpenAL calls. All you'd need to get something like libmodplug working is access to an open stream to output sound to, and even that small amount of added functionality could do wonders.

Aforementioned bass library (likely incomplete):
https://github.com/JochenHeizmann/monkeybass


Raz(Posted 2015) [#3]
Oh nice one, why I didn't search here for bass.dll already, I don't know.

I'll give that a go thank you very much!

Edit: Ahh it seems I did search here for bass.dll and from what I can tell the linked to library is for Android only at the mo?


Nobuyuki(Posted 2015) [#4]
yeah, and unfortunately, a 1:1 from java to c++ isn't possible without some glue code to handle Monkey strings. I'm sure it's not hard for someone who has dealt with C++ (and there's some stuff on that again if you search the forum for "cstring"), but I'm assuming anyone who'd be capable of stepping up to the plate either isn't interested in doing it or isn't interested in mentioning that they did. Furthermore, it looks like the list of functions in the monkey externs is incomplete, but it's probably good enough for what you want it to do...


Samah(Posted 2015) [#5]
@Nobuyuki: ...but I'm assuming anyone who'd be capable of stepping up to the plate either isn't interested in doing it or isn't interested in mentioning that they did.

I just so happen to be working on a BASS wrapper right now, actually. Most of the core library is working, I'm just trying to get BASS_FX working too.
So far it's just C++ targets (GLFW3/iOS), but it shouldn't be too hard to use the Java bindings for Android (or NDK).
Interesting timing with this thread...I started on this about a week ago.


Raz(Posted 2015) [#6]
Nobu : I wish I knew more about the under the hood stuff with Monkey, on the face of it, the concept of creating an interface for an external lib seems quite simple (as long as the API is relatively simple!) but I just get lost instantly.

Samah :D That's great news :) I look forward to hearing how you get on


Raz(Posted 2015) [#7]
Samah: Sorry to hijack my own thread but, I see you've got an Sqlite3 plugin that "currently only supports C++" does that include GLFW? Should this be working with Monkey-X 84e ?

I'm currently getting

build/Release/main.o:main.cpp:(.text+0x5b9b): undefined reference to `sqlite3_open_v2'
build/Release/main.o:main.cpp:(.text+0x5c68): undefined reference to `sqlite3_open_v2'
build/Release/main.o:main.cpp:(.text+0x5cc6): undefined reference to `sqlite3_open'
build/Release/main.o:main.cpp:(.text+0x5d84): undefined reference to `sqlite3_exec'
build/Release/main.o:main.cpp:(.text+0x5e72): undefined reference to `sqlite3_prepare_v2'
build/Release/main.o:main.cpp:(.text+0x5f9d): undefined reference to `sqlite3_prepare_v2'



Samah(Posted 2015) [#8]
@Raz: Sorry to hijack my own thread but...

SQLite continued here:
http://www.monkey-x.com/Community/posts.php?topic=9928&post=111891

@Raz: Samah :D That's great news :) I look forward to hearing how you get on

Currently working on MonkeyBass, MonkeySQLite, and preparing for the Monkey X Jam...
Also I raid for three hours twice a week (it used to be three nights until our guild leader decided that nine hours a week was burning people out).


Raz(Posted 2015) [#9]
@Samah so what you're saying is, you're not at all busy? ;)

I kid, obviously! Thanks :)


Nobuyuki(Posted 2015) [#10]
samah: I will give you a fresh coat of paint if you manage to have a working version of the BASS lib ready in time for the game jam. I would love to be able to use tracker modules instead of resorting to OGG rendering for obvious reasons!


Samah(Posted 2015) [#11]
@Nobuyuki: samah: I will give you a fresh coat of paint if you manage to have a working version of the BASS lib ready in time for the game jam

I'll try my hardest, but no promises! XD

Edit: I'm going to work on getting the core library fully wrapped first, then I'll see how I go with BASS_FX.


Nobuyuki(Posted 2015) [#12]
I'd be happy with basic playback and loop functionality, if function signatures change, it's no big loss


Samah(Posted 2015) [#13]
Nobuyuki I've given you access to my private GitHub repo. Tell me what you think, and when it's at a "releasable" stage I'll make it public.

Example:
Import monkeybass

' initialise bass
BASS.BASS_Init(-1, 44100)
' load a file
Local stream:HSTREAM = BASS.BASS_StreamCreateFile("data\test.ogg")
' play it
BASS.BASS_ChannelPlay(stream)
' get the position in seconds
Local position:Float = BASS.BASS_ChannelBytes2Seconds(stream, BASS.BASS_ChannelGetPosition(stream, BASS_POS_BYTE))

I'll probably make some nice fancy wrapper classes eventually, but for now it's direct calls.


Nobuyuki(Posted 2015) [#14]
Thanks muchly samah. I didn't get a notification email, so I'll have to look around to see if I can find where the repo is. Will probably be able to get back to you sometime during the weekend as I'm pretty busy right now! Can't wait to check it out.


Samah(Posted 2015) [#15]
@Nobuyuki: ...so I'll have to look around to see if I can find where the repo is.

Follow me on twitter and I'll DM you the info.


Samah(Posted 2015) [#16]
Alright, the core library is 90% wrapped, but it's only been implemented for C++ (and thus GLFW3) and only tested on Windows 64-bit.
Once I've done some more testing I'll make the repo public.

@Nobuyuki: ...in time for the game jam.

Requirement for the game jam is that it must run on HTML5. :(


Nobuyuki(Posted 2015) [#17]
Fack. What's up with that? It sounded implicit with the encouragement of full joypad support that using the desktop target was obviously allowed. Hacking the target is a requirement for joypad support on html5, isn't it?

Edit: I'm pretty sure that desktop targets are supported, but I'm asking in the thread just to make absolutely certain


Samah(Posted 2015) [#18]
@Nobuyuki: Edit: I'm pretty sure that desktop targets are supported...

Sorry, I meant that HTML5 is one of the targets listed, and if it's mandatory, no BASS. :(


Nobuyuki(Posted 2015) [#19]
Okay, so I've been bad, and haven't actually dug into the code much yet. Downloaded it, but didn't try running your sample code!! Didn't expect I'd spend so much time on the actual platforming engine part of the game, sheesh...

Anyway, I may or may not be able to use it in time for the project deadline and I was just wondering: Would you recommend against using this for a game's sound FX? I'm not sure I'd use BASS in that capacity unless it was going to be the primary sound engine in use, but just curious about it. Might be more setup than it's worth than to just roll with both OpenAL's mixer and BASS's.