Is it possible to get sound memory address from LoadSound??

Just starting out? Need help? Post your questions and find answers here.
dman10001
User
User
Posts: 55
Joined: Mon Feb 25, 2013 3:04 pm

Is it possible to get sound memory address from LoadSound??

Post 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
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: Is it possible to get sound memory address from LoadSou

Post 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 
malleo, caput, bang. Ego, comprehendunt in tempore
infratec
Always Here
Always Here
Posts: 7582
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Is it possible to get sound memory address from LoadSou

Post by infratec »

Btw. where is the Tipp or the Trick?

It is more a coding question.
dman10001
User
User
Posts: 55
Joined: Mon Feb 25, 2013 3:04 pm

Re: Is it possible to get sound memory address from LoadSou

Post 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.
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Is it possible to get sound memory address from LoadSou

Post 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
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: Is it possible to get sound memory address from LoadSou

Post by Rings »

topic moved, duplicated topic deleted .
SPAMINATOR NR.1
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: Is it possible to get sound memory address from LoadSou

Post 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
dman10001
User
User
Posts: 55
Joined: Mon Feb 25, 2013 3:04 pm

Re: Is it possible to get sound memory address from LoadSou

Post 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??
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: Is it possible to get sound memory address from LoadSou

Post 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.
Post Reply