Pointers and more Pointers

Just starting out? Need help? Post your questions and find answers here.
zapadepowday
User
User
Posts: 14
Joined: Tue Jan 05, 2010 5:43 pm

Pointers and more Pointers

Post 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)
AZJIO
Addict
Addict
Posts: 2180
Joined: Sun May 14, 2017 1:48 am

Re: Pointers and more Pointers

Post by AZJIO »

LoadSound does not return a pointer
zapadepowday
User
User
Posts: 14
Joined: Tue Jan 05, 2010 5:43 pm

Re: Pointers and more Pointers

Post by zapadepowday »

Thankyou.. That solves that.
AZJIO
Addict
Addict
Posts: 2180
Joined: Sun May 14, 2017 1:48 am

Re: Pointers and more Pointers

Post 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)
zapadepowday
User
User
Posts: 14
Joined: Tue Jan 05, 2010 5:43 pm

Re: Pointers and more Pointers

Post 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 ?
zapadepowday
User
User
Posts: 14
Joined: Tue Jan 05, 2010 5:43 pm

Re: Pointers and more Pointers

Post 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.
zapadepowday
User
User
Posts: 14
Joined: Tue Jan 05, 2010 5:43 pm

Re: Pointers and more Pointers

Post 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)
BarryG
Addict
Addict
Posts: 4167
Joined: Thu Apr 18, 2019 8:17 am

Re: Pointers and more Pointers

Post 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?
AZJIO
Addict
Addict
Posts: 2180
Joined: Sun May 14, 2017 1:48 am

Re: Pointers and more Pointers

Post 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)
Last edited by AZJIO on Sun Feb 20, 2022 7:02 am, edited 1 time in total.
zapadepowday
User
User
Posts: 14
Joined: Tue Jan 05, 2010 5:43 pm

Re: Pointers and more Pointers

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