Page 1 of 1
Is it possible to get sound memory address from LoadSound??
Posted: Mon Jul 03, 2017 8:36 pm
by dman10001
Hi, I'm trying to get the sound memory address from LoadSound function.
the function returns a number, is that the address or something else. I just need to know where in memory is the sound data.
Please help
Re: Is it possible to get sound memory address from LoadSou
Posted: Mon Jul 03, 2017 10:19 pm
by Zebuddi123
Hi dman10001
LoadSound() returns 0 if file failed to load or a positive Integer for success.
Make sure your in debug mode to see ShowMemViewer() to see the sound file start and end address etc.
Zebuddi.
Code: Select all
EnableExplicit
EnableDebugger ; personally I use the stand alone debugger
InitSound() ; Initialize Sound system
UseOGGSoundDecoder() ; Use ogg files
#filename$ = #PB_Compiler_Home +"Examples\3D\Data\Siren.ogg"
Define iFileLength.i, iSoundFileLoaded.i
If ReadFile(0, #filename$)
iFileLength.i = Lof(0)
iSoundFileLoaded = CatchSound(0, ?MemAddressSoundStart, Lof(0), #PB_Sound_Streaming)
If iSoundFileLoaded
PlaySound(0, #PB_Sound_Loop)
Delay(3000)
FreeSound(0) ; The sound is freed
ShowMemoryViewer(?MemAddressSoundStart , ?MemAddressSoundEnd-?MemAddressSoundStart) ; of use lof(0) for file size/bytes
MessageRequester("Sound File Info", "Start Address:" + Str(?MemAddressSoundStart) + #CRLF$ + " End Address:" + Str(?MemAddressSoundEnd) )
EndIf
CloseFile(0)
EndIf
End
DataSection
MemAddressSoundStart:
IncludeBinary #filename$
MemAddressSoundEnd:
EndDataSection
Re: Is it possible to get sound memory address from LoadSou
Posted: Mon Jul 03, 2017 10:33 pm
by infratec
Btw. where is the Tipp or the Trick?
It is more a coding question.
Re: Is it possible to get sound memory address from LoadSou
Posted: Tue Jul 04, 2017 12:44 am
by dman10001
Yes it is. thank you for your response, but I already knew that and it didn't answer my question.
I was referring to the LOADSOUND function and its numbers it returns.
Re: Is it possible to get sound memory address from LoadSou
Posted: Tue Jul 04, 2017 3:59 am
by Demivec
Will a Moderator please move the contents of this topic over to the duplicate thread and delete this one, or just move this one to the correct forum and delete the duplicate?
Duplicate thread:
How can I get the sound address from the LoadSound function
Re: Is it possible to get sound memory address from LoadSou
Posted: Tue Jul 04, 2017 8:25 am
by Rings
topic moved, duplicated topic deleted .
Re: Is it possible to get sound memory address from LoadSou
Posted: Tue Jul 04, 2017 11:11 am
by Mijikai
Code: Select all
Structure LOADSOUND_STRUCT
Unknown.b[$40]
*Buffer
EndStructure
Global *SoundBuffer.LOADSOUND_STRUCT
InitSound()
UseOGGSoundDecoder()
*SoundBuffer = LoadSound(#PB_Any,"Siren.ogg")
If *SoundBuffer
ShowMemoryViewer(*SoundBuffer\Buffer,1024)
EndIf
Re: Is it possible to get sound memory address from LoadSou
Posted: Tue Jul 04, 2017 6:52 pm
by dman10001
Hi, I didn't think it was there. I thank you for responding.
I tried the code but It did not work, it returned this message.
The specified memory location is not valid for reading.
I did put debug on, or is it something else I have to do??
Re: Is it possible to get sound memory address from LoadSou
Posted: Wed Jul 05, 2017 6:11 pm
by Mijikai
Seems to be some OS specific problem...
Runs fine for me on Win7 x64 but not on Win10 x64 (PB 5.60)
On Win10 it only works with this trick:
Code: Select all
Structure LOADSOUND_STRUCT
Unknown.b[$40]
*Buffer
EndStructure
Global *SoundBuffer.LOADSOUND_STRUCT
InitSound()
UseOGGSoundDecoder()
*SoundBuffer = LoadSound(#PB_Any,"Siren.ogg")
FreeSound(*SoundBuffer)
*SoundBuffer = LoadSound(#PB_Any,"Siren.ogg")
ShowMemoryViewer(*SoundBuffer\Buffer,1024)
Would be nice if there was a inbuild command...
Im not sure how usable this hackish approach is.
Mby someone has time to do some investegating.
Coding a custom loader might be the best solution.