|
-
Aug 14th, 2018, 06:08 AM
#5
Thread Starter
Member
Re: Mixing sounds with DirectX and recording them
 Originally Posted by The trick
Code:
But I see that for each file we have to apply a manual correction factor to avoid saturation of the amplitude or volume of the final sound.
You can use a floating-point format and a normalization after addition.
Code:
It also loses the modifications made in each individual sound like volume, pan, frequency, effects, etc. In other words, I could only work with each original sound, load without play them and to make the mixing and later recording.
You can't access to the data without playing the sound. AFAIK DS mixes the buffers in the kernel mixer and passes it to the driver.
Thanks Trick, I have done as you advise, play each sound channel in its own circular buffer. I access it and recover the array to mix it and/or record it. But it (red marked) does not preserve the individual modifications of volume, panorama, sampling frequency or assigned effects. Only I can listen them. The recorded is the same copy of the original file.
Would you know how to access the data of the sound that is playing with effects? Thank you.

Code:
Private Sub DirectXEvent8_DXCallback(ByVal eventid As Long)
Dim WaveBuffer() As Byte
If Not (oSecondaryBuffer Is Nothing) Then
If eventid = StartEvent Or eventid = MidEvent Then
ReDim WaveBuffer(HalfBuffLen - 1) ' array 176400 bytes (1000mseg).
RaiseEvent NeedWavData(WaveBuffer) 'read data array from file sound
End If
If Not (oSecondaryBuffer Is Nothing) Then
Select Case eventid
Case StartEvent
oSecondaryBuffer.WriteBuffer HalfBuffLen, HalfBuffLen, WaveBuffer(0), DSBLOCK_DEFAULT
If fRecording Then 'flag clicked recording button
oSecondaryBuffer.ReadBuffer 0, HalfBuffLen, WaveBuffer(0), DSBLOCK_DEFAULT 'read the other half buffer playing
Call SoundRec(WaveBuffer()) 'save buffer array to file
End If
Case MidEvent
oSecondaryBuffer.WriteBuffer 0, HalfBuffLen, WaveBuffer(0), DSBLOCK_DEFAULT
If fRecording Then 'flag clicked recording button
oSecondaryBuffer.ReadBuffer HalfBuffLen, HalfBuffLen, WaveBuffer(0), DSBLOCK_DEFAULT 'read the other half buffer playing
Call SoundRec(WaveBuffer())
End If
Case EndEvent
' not used
End Select
End If
End If
End Sub
Last edited by enribuz; Aug 14th, 2018 at 06:20 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|