PlaySound() to support real-time sound modification.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

PlaySound() to support real-time sound modification.

Post 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
Joris
Addict
Addict
Posts: 890
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

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

Post 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.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 670
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

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

Post 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.
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2024: 56y
"Happiness is a pet." | "Never run a changing system!"
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

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

Post by davido »

+1
DE AA EB
Post Reply