[Solved] Incbin and LoadSound

BlitzMax Forums/Brucey's Modules/[Solved] Incbin and LoadSound

RustyKristi(Posted 2016) [#1]
Hi, I'm trying to load some sounds using Incbin. The exe builds but it does not load up, I even tried using banks..

http://www.blitzmax.com/Community/post.php?topic=99118&post=1162049

Any ideas or examples?


Midimaster(Posted 2016) [#2]
It has nothing to do with brucey modules...

Incbin "TestSound.ogg" 
SoundPath="Incbin::""

Global Sound:TSound=LoadSound(SoundPath + "TestSound.ogg")
PlaySound Sound


together with Koriolis Zipstream you can also handle zipped folders:

Import koriolis.zipstream

Incbin "DATA.ZIP" 
SoundPath="ZIP::Incbin::DATA.ZIP//"

Global Sound:TSound=LoadSound(SoundPath + "TestSound.ogg")
PlaySound Sound



RustyKristi(Posted 2016) [#3]
Thanks Midimaster, actually I'm trying to use BMX-NG + SDLMixerAudio and I forgot to mention that earlier and so I placed it under Brucey's Modules

Apparently this works on normal load but not incbin:

' simple stream example.

SuperStrict

Framework brl.standardio
Import SDL.SDLMixerAudio

SetAudioDriver("SDLMixerAudio")

Incbin "TestSound.ogg" 

Global SoundPath:String = "Incbin::"

Global sound:TSound=LoadSound(SoundPath + "TestSound.ogg")

DebugStop
If sound Then
	Print "Sound loaded"
Else
Print " :( "
	End
End If

Local channel:TChannel = CueSound(sound)

' wait for it...
Delay(1000)

' just to prove the cueing works!
channel.SetPaused(False)

' keep ticking until the music has finished
Repeat
	Delay(500)
	Print "tick..."
Until Not channel.Playing()


Link to original example

https://github.com/bmx-ng/sdl.mod/blob/master/sdlmixeraudio.mod/examples/example_01.bmx

I'm getting the sad face not loaded result :/


Floyd(Posted 2016) [#4]
I can play Inbinned sounds with ordinary BlitzMax. Can you?

Another thing to try is to get rid of the Framework. Maybe it's causing a problem. If that helps then use Framework Assistant to be sure you get everything you need.


RustyKristi(Posted 2016) [#5]
thanks Floyd, actually I can't use vanilla Blitzmax with SDL, as it does not complete build. Ok let me check with the framework assistant although it's weird that the code above works without incbin.


Midimaster(Posted 2016) [#6]
did you check, that the file was really added?

there is a FileExists() that is also working with Incbin:

Function _FileExists%(Datei$)
		Local Stream:TStream=ReadFile(Datei)
		If stream=Null Then Return False
		CloseFile Stream
		Return True
End Function



Floyd(Posted 2016) [#7]
I don't know about NG, but on regular blitz the program won't build if the file can't be found. If I try the one line program

Incbin "FakeNonexistentFile"

file "C:/BlitzMax150/tmp/FakeNonexistentFile"
error: file not found.
Build Error: Failed to assemble C:/BlitzMax150/tmp/.bmx/untitled1.bmx.gui.release.win32.x86.s


RustyKristi(Posted 2016) [#8]
@MidiMaster

Yes, the exe got bigger when I try to use incbin..

I should probably try it incbin with other sound drivers and check it again, maybe it's just with SDL :/


FireballStarfish(Posted 2016) [#9]
If you want to access an IncBin-ed file through BlitzMax' stream functions, always make sure you have an import of BRL.RamStream somewhere in your program.
There's a TStreamFactory in there which needs to be registered in order for the "incbin::" prefix to work.


RustyKristi(Posted 2016) [#10]
Thanks FireballFlame! :) Somehow I missed that part but I did remember putting the import on previous test. Now it's loaded! ..but I still can't hear any sounds :/

Here's my updated code:

SuperStrict

Framework brl.standardio
Import BRL.RamStream
Import SDL.SDLMixerAudio


SetAudioDriver("SDLMixerAudio")

Incbin "TestSound.ogg" 

Global SoundPath:String = "Incbin::"

Global sound:TSound=LoadSound(SoundPath + "TestSound.ogg")

DebugStop
If sound Then
	Print "Sound loaded"
Else
Print " :( "
	End
End If

Local channel:TChannel = CueSound(sound)

' wait for it...
Delay(1000)

' just to prove the cueing works!
channel.SetPaused(False)

' keep ticking until the music has finished
Repeat
	Delay(500)
	Print "tick..."
Until Not channel.Playing()



Brucey(Posted 2016) [#11]
Hallo. I am intending dropping the SDLMixedAudio module - as there is generally better support for audio using other modules.
The main issue is getting all the right shared libraries setup correctly across platforms. I personally feel it's just a major pain.

You would be much better trying out the new bah.soloudaudio - from my experience so far, it *just works*.


RustyKristi(Posted 2016) [#12]
Thanks Brucey! :) I intend to test and use this on Android, does it work? I'm assuming you need to incbin the sound files.

Checking it now..

Edit: SoloAudio works great! :D Awesome Brucey!!


Brucey(Posted 2016) [#13]
Good to hear (*cough*)

I'm assuming you need to incbin the sound files

You shouldn't... but I haven't implemented stream loading support yet in bah.soloud.

There's an "SDL" stream type you can utilise via the "sdl::" proto - similar to how you would use "incbin::file.wav" and other protos. The SDL stream gives you access to the filesystem on your devices so that you don't need to incbin your files. File locations are platform specific though, in which case you need to read the relevant documentation about it.

See the "loading assets" section in http://hg.libsdl.org/SDL/file/5b61e12c0a30/docs/README-android.md for Android specific asset location information. rw_ops (mentioned there) is the abstraction layer that the SDL stream sits atop of.
Also see foot of sdl.mod/sdl.bmx for some useful filesystem access functions.


RustyKristi(Posted 2016) [#14]
Great thanks! I'll just check with sdl.bmx. I did manage to test it and get the files in without incbin when I place them in the assets folder.