Page 1 of 1

Pointers and more Pointers

Posted: Sat Feb 12, 2022 9:25 pm
by zapadepowday
Hi, PB Pointers are new to me, what am I missing here.
I wish to load the wav file and copy it from its loading buffer to a different memory location.
InitSound()

*NewBuffer =AllocateMemory(50000000)

*SoundBuffer = LoadSound (1,"D:\Smart music\New Mix Runoffs\Everyone we Told Remix With Vox (2).wav")

CopyMemory(*Soundbuffer,*NewBuffer,30000000)

Debug(*newBuffer)

Re: Pointers and more Pointers

Posted: Sat Feb 12, 2022 10:24 pm
by AZJIO
LoadSound does not return a pointer

Re: Pointers and more Pointers

Posted: Sat Feb 12, 2022 10:51 pm
by zapadepowday
Thankyou.. That solves that.

Re: Pointers and more Pointers

Posted: Sat Feb 12, 2022 10:57 pm
by AZJIO
Maybe I'm wrong, check by copying smaller data. Maybe your file is less than 30 MB.

Code: Select all

EnableExplicit
Define *NewBuffer, *SoundBuffer, fs,q, path$
InitSound() 
; UseOGGSoundDecoder()
*NewBuffer =AllocateMemory(50000000)
; *SoundBuffer =AllocateMemory(50000000)
path$ = "D:\Smart music\New Mix Runoffs\Everyone we Told Remix With Vox (2).wav"
*SoundBuffer = LoadSound(1,path$)
fs = FileSize(path$)
CopyMemory(*Soundbuffer,*NewBuffer, 2331) ; fs ?
; ShowMemoryViewer(*NewBuffer , 10)
ShowMemoryViewer(*SoundBuffer , 10)
Debug *newBuffer
Debug fs
FreeMemory(*NewBuffer)
; FreeMemory(*SoundBuffer)
FreeSound(1)

Re: Pointers and more Pointers

Posted: Sat Feb 12, 2022 11:19 pm
by zapadepowday
Well almost, Anybody know a way to do this? If I instead use a pointer to access the returned value and hopefully give me the address
of the loaded Wav. The value is incorrect. Does anybody know how to find a Loaded Soundfile ?

Re: Pointers and more Pointers

Posted: Sat Feb 12, 2022 11:27 pm
by zapadepowday
Thanks AZJIO, But the address is not where the wav file is. I am Missing something here, But I don't know what it is
I feel Like Dylans Mr Jones.

Re: Pointers and more Pointers

Posted: Sat Feb 12, 2022 11:56 pm
by zapadepowday
I Have also tried including wav files as Binary (includeBinary) in a Data Section, but getting above 70mgb I immediately get a POLINK Linker Error. Cannot find out why so tried to resort to LoadSound, But then I have no idea where the Wav is.
Maybe I'll load it and run a search through memory until I find the Start of the Header (RIFF)

Re: Pointers and more Pointers

Posted: Sun Feb 13, 2022 2:16 am
by BarryG
AZJIO wrote: Sat Feb 12, 2022 10:24 pmLoadSound does not return a pointer
Does CatchSound() return a pointer to the sound?
zapadepowday wrote: Sat Feb 12, 2022 11:56 pm70mgb
Is that meant to be MB or GB?

Re: Pointers and more Pointers

Posted: Sun Feb 13, 2022 5:55 am
by AZJIO

Code: Select all

EnableExplicit
InitSound()

#Sound = 0
#File = 0

Define isSnd, *mem, length,q, path$, bytes

isSnd = 0

path$ = "D:\Smart music\New Mix Runoffs\Everyone we Told Remix With Vox (2).wav"
If path$
	If ReadFile(#File, path$)
		length = Lof(#File)
		*mem = AllocateMemory(length)
		If *mem
			bytes = ReadData(#File, *mem, length)
			If bytes
; 				Debug bytes
				ShowMemoryViewer(*mem , 48)
				isSnd = CatchSound(#Sound, *mem, bytes)
			EndIf
		EndIf
		CloseFile(0)
		
	EndIf
EndIf

; Debug isSnd
If isSnd
	PlaySound(#Sound)
	Delay(SoundLength(#Sound, #PB_Sound_Millisecond))
	FreeSound(#Sound)
EndIf
FreeMemory(*mem)
Added FreeMemory(*mem)

Re: Pointers and more Pointers

Posted: Sun Feb 13, 2022 11:15 am
by zapadepowday
Fantastic AZJIO, That works perfectly, Your a Genius.
Genuine thanks for your help you have saved my brain
I of course meant 70MB, it was late, my eyes had gone to bed...Oh imagine a 70GB Wav file. HaHa.