Page 1 of 1

PlaySound() to support real-time sound modification.

Posted: Wed Apr 24, 2013 9:13 am
by RichardL
PB would be able to support a degree of real time sound processing if the user could modify the sound buffer being played by PlaySound().

I can imagine the DirectX stuff going on within PlaySound() and propose that something along the following lines would be reasonable simple to add and powerful enough for a competent programmer to put to good effect.

Code: Select all

; CatchSound() works as before, defining the file header and buffer. 'Length' is mandatory for what follows.

CatchSound(#Sound,*Header,Length)
.
.
.
; PlaySound() has extra flag and the address of a callback routine.
;   SoundCallback() is called when SoundPosition reaches 0% and 50% (Using 'SetNotificationPositions'?)
;   so user can update sound in the original buffer. 

PlaySound(#Sound,#PB_Sound_UserUpdate | #PB_Sound_Loop ,Volume,@SoundCallback())
.
.
.
Procedure SoundCallback(Sound,*Buf,Bytes)
  
  ; Sound     Should match #Sound (To allow for multiple sounds)
  ; *Buf      Real address' *Header / *Header+(Length/2)
  ; Bytes     should correspond to Length/2
  
  ; User writes appropriate section of buffer ahead of it being played
  ; and sets Result = #True
  
  ; If Result is returned #True caller copies appropriate half of user's 
  ; buffer into DS Buffer
  
  ProcedureReturn Result
EndProcedure

Re: PlaySound() to support real-time sound modification.

Posted: Wed Apr 24, 2013 4:46 pm
by Joris
RichardL wrote:PB would be able to support a degree of real time sound processing if the user could modify the sound buffer being played by PlaySound().
I'm interested and will follow this.

Re: PlaySound() to support real-time sound modification.

Posted: Sun Nov 17, 2013 10:33 pm
by Kurzer
That's exactly what I need in this second.
See here: http://www.purebasic.fr/english/viewtop ... 13&t=57411

+1 Please, Fred.

Re: PlaySound() to support real-time sound modification.

Posted: Sun Nov 17, 2013 10:54 pm
by davido
+1