Change pitch while the voice is captured by the microphone

Started by AntonioMSR, October 20, 2017, 07:09:56 PM

Previous topic - Next topic

AntonioMSR

Hello people!  :)

I'm trying to implement in the sample code "Playback of a WASAPI capture device" for VB 6.0 of the Active DJ control \ Studio \ Samples \ VB6 \ WasapiInputPlayer to modify the pitch at the same time that the voice is captured by the microphone, :o but error "ERR_NOT_LOADED_FOR_MIXING -24 Unsupported" is is being shown. The DirectX and VST effects work fine, :-\ but pitch is not working in several attempts made with SetPitch and SetPitchFloat. Is it possible to make it work with Active DJ Studio in any way at the same time that I speak using the microphone? The version of Active DJ Studio is 8.0.0. Can you give me some tips please? Thank you very much!  ;)

Here is the code:

General Declarations

Public tomvoz As Integer


Private Sub Slider1_Change()  ''' CHANGE PITCH
    tomvoz = Slider1.Value
    TextSemitones.Text = tomvoz
    Slider1.Text = tomvoz

  Dim err As enumErrorCodes
  err = Amp3dj1.SetPitch(0, tomvoz)
  If err < 0 Then
    DisplayError err  '''''=> ERR_NOT_LOADED_FOR_MIXING  -24   Unsupported
    Exit Sub
  End If

Amp3dj1.PlaySound 0
End Sub

Private Sub Slider1_Scroll()
    Slider1_Change
End Sub

Private Sub ComboCaptureDevices_Click()
    ' stop the previous capture device
    If Amp3dj1.WASAPI.DeviceIsStarted(m_nCurrCaptureDevice, WASAPI_DEVICE_TYPE_CAPTURE) Then
        Amp3dj1.WASAPI.DeviceStop m_nCurrCaptureDevice, WASAPI_DEVICE_TYPE_CAPTURE, BOOL_TRUE
    End If
   
    ' start the device in shared mode
    Dim nResult As enumErrorCodes
    nResult = Amp3dj1.WASAPI.DeviceStartShared(m_nCurrCaptureDevice, WASAPI_DEVICE_TYPE_CAPTURE, WASAPI_CHANNEL_MODE_STEREO, 0, 0)
    If nResult <> ERR_NOERROR Then
        MsgBox "Device failed to start due to error " & nResult
        Exit Sub
    End If
   
    m_nCurrCaptureDevice = ComboCaptureDevices.ListIndex
   
    ' get the current volume level for the selected device
    Dim fVolume As Single
    Amp3dj1.WASAPI.DeviceVolumeGet 0, WASAPI_DEVICE_TYPE_CAPTURE, SCALE_LINEAR, fVolume
    SliderVolumeCapture.Value = 100 - fVolume
End Sub


Private Sub CommandStartCapture_Click()

    Dim nResult As enumErrorCodes
    nResult = Amp3dj1.WASAPI.AttachInputDeviceToPlayer(0, m_nCurrCaptureDevice, WASAPI_DEVICE_TYPE_CAPTURE)
    If nResult <> ERR_NOERROR Then
        MsgBox "Cannot start playback due to error " & nResult
        Exit Sub
    End If

Amp3dj1.PlaySound 0
End Sub

Private Sub Form_Load()

    ' initialize usage of WASAPI audio drivers
    Dim nReturn As enumErrorCodes
    nReturn = Amp3dj1.InitDriversType(DRIVER_TYPE_WASAPI)
    If nReturn = ERR_INVALID_PLATFORM Then
        MsgBox "This sample can only work on Windows Vista or higher versions. The program will now close."
        End
    End If

    ' verify presence of audio render devices
    Dim nOutputs As Integer
    Amp3dj1.WASAPI.DeviceGetCount WASAPI_DEVICE_TYPE_RENDER, nOutputs
    If nOutputs = 0 Then
        MsgBox "No render device detected and/or connected: the program will now close. Jack-sensing could disable an existing sound card if no speaker is physically connected so, if you are sure that a sound card is installed, try to plug a couple of speakers into the sound card before launching again this program."
        End
    End If
   
    ' verify presence of audio capture devices
    Dim nInputs As Integer
    Amp3dj1.WASAPI.DeviceGetCount WASAPI_DEVICE_TYPE_CAPTURE, nInputs
    If nInputs = 0 Then
        MsgBox "No capture device detected and/or connected: the program will now close. Jack-sensing could disable an existing sound card if no speaker is physically connected so, if you are sure that a sound card is installed, try to plug a microphone into the sound card before launching again this program."
        End
    End If
   
    ' init the DJ control with system default output device
    Amp3dj1.InitDJSystem 1, Me.hwnd, 0, 0, 0, 0

    ' reduce latency using the minimal buffer length (we add 50 ms for safety): in case of stuttering sound,
    ' there could be an issue with the sound card's driver not reporting the correct
    ' minimal allowed buffer length; in order to use this feature, remember to set
    ' the CheckOutputDevicesLatency property to "True" at design-time
    Amp3dj1.BufferLength = Amp3dj1.GetOutputDeviceMinBufferLength(0) + 50

    ' list and start in shared mode the available render devices
    Dim i As Integer
    Dim strDevice As String
    For i = 0 To nOutputs - 1
        strDevice = Amp3dj1.WASAPI.DeviceGetDesc(i, WASAPI_DEVICE_TYPE_RENDER)
        ComboRenderDevices.AddItem strDevice
        Dim nResult As enumErrorCodes
        nResult = Amp3dj1.WASAPI.DeviceStartShared(i, WASAPI_DEVICE_TYPE_RENDER, WASAPI_CHANNEL_MODE_STEREO, 50, 10)
        If nResult <> ERR_NOERROR Then
            Dim strMsg As String
            If nResult = ERR_WASAPI_DEVICE_BUSY Then
                strMsg = "Device " & strDevice & " failed to start because already started in exclusive mode by another process - Do you want to continue?"
            Else
                strMsg = "Device " & strDevice & " failed to start due to error " & nResult & " - Do you want to continue?"
            End If
           
            Dim Response
            Response = MsgBox(strMsg, vbYesNo)
            If Response = vbNo Then
                End
            End If
        End If
    Next i

    ' list the available capture devices
    For i = 0 To nInputs - 1
        strDevice = Amp3dj1.WASAPI.DeviceGetDesc(i, WASAPI_DEVICE_TYPE_CAPTURE)
        ComboCaptureDevices.AddItem strDevice
    Next i
   
    ' select the current system default devices
    ComboRenderDevices.ListIndex = 0
    ComboCaptureDevices.ListIndex = 0
    m_nCurrRenderDevice = ComboRenderDevices.ListIndex
    m_nCurrCaptureDevice = ComboCaptureDevices.ListIndex
   
    ' get the current volume level for the selected playback device
    Dim fVolume As Single
    Amp3dj1.WASAPI.DeviceVolumeGet m_nCurrRenderDevice, WASAPI_DEVICE_TYPE_RENDER, SCALE_LINEAR, fVolume
    SliderVolumePlayer.Value = 100 - fVolume
   
    ' enable generating VU-Meter events passing 0 to the embedded VU meter
    Amp3dj1.VUMeter.Create 0, 0
   
    ' create a fancy VU-Meter
    m_hWndVuMeterLeft = CreateVuMeter(FrameDevices, PictureVuMeterLeft)
    m_hWndVuMeterRight = CreateVuMeter(FrameDevices, PictureVuMeterRight)

    Amp3dj1.EnableMixingFeatures = True

    TextSemitones.Text = 0#

End Sub

Administrator

Hello,

at the moment the feature you need is not supported: indeed the pitch algorithm used by our component needs to rely upon a sound file and cannot be used with a continuous stream as in the case of the microphone's input.
We will see if we could implement this feature in a future version.

Kind regards

Severino Delaurenti
MultiMedia Soft

AntonioMSR

Hello, Severino Delaurenti

Anyway thank you very much for your attention!  :)