Results 1 to 8 of 8

Thread: [RESOLVED] Mixing sounds with DirectX and recording them

Threaded View

  1. #5

    Thread Starter
    Member enribuz's Avatar
    Join Date
    Nov 2015
    Location
    Spain
    Posts
    36

    Question Re: Mixing sounds with DirectX and recording them

    Quote Originally Posted by The trick View Post
    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.

    Name:  Snap 2018-08-14, 12_56_30.png
Views: 615
Size:  34.0 KB

    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
  •  



Click Here to Expand Forum to Full Width