Can we create Audio Mixer with two inputs

Started by Ravindra, March 27, 2023, 08:21:47 AM

Previous topic - Next topic

Ravindra

Hello Severino,

Can we have a provision to create Audio Mixer with two inputs,

The First input is through built in microphone in laptop.(External Input)
The second input is an mp3 file.

Can we mix these inputs and control their volumes ?
Precisely I want to create a karaoke mixer.

Regards,

Ravindra.

Administrator

Hello,

yes, this is possible.
Just take a look into the WasapiMixAndClone sample project that does exactly what you request (and something more, like cloning the mixer's output and sending the mixed output to a shoutcast server).

Kind regards

Severino Delaurenti
MultiMedia Soft


Ravindra

Hello Severino,

That's Great....

I referred sample projects directory but i did not find WasapiMixAndClone sample project but
i found WasapiInputPlayer and WasapiSpeakersManager only. Are these projects helpful ?

I think it is because i am using older version of AudioDJ.

Can you send me a link to download WasapiMixAndClone sample project ?

Regards,

Ravindra.


Administrator

Hello,

the WasapiInputPlayer sample project shows how to attach a capture device to a player in order to render directly what is being received in input but it doesn't show how to mix this player to another player loaded with a regular mp3 song.
Attached you will find a sample project that does stuffs you need: in order to be run this project requires the presence of the Audio Sound Recorder for .NET component but, from the source code, you should be able to achieve what you need.
With version 7 of the component, the one you are currently registered for, the AttachInputDeviceToPlayer method is the way to go to render a capture device directly into a player.

Hope this helps.

Kind Regards

Severino Delaurenti
MultiMedia Soft

Ravindra

Hello,

Thanks for your Help...
As per your suggestion I tried following code.

Form Load:

 Dim nOutputs As Integer = 0
        '//
        Dim nReturn As enumErrorCodes = AudioDjStudio2.InitDriversType(enumDriverTypes.DRIVER_TYPE_WASAPI)
        If nReturn = enumErrorCodes.ERR_INVALID_PLATFORM Then
            MessageBox.Show("This sample can only work on Windows Vista or higher versions. The program will now close.")
            Close()
        End If
        '//
        AudioDjStudio2.InitSoundSystem(1, 0, 0, 0, 0, -1)
***************************************************************

Later I collected all the playback and input devices successfully and set them.

****************************************************************

Code written in Play Command:

Here i have loaded an mp3 file to AudioDj object as ,

            Dim streamFile As FileStream = New FileStream(cFileName, FileMode.Open)
            Dim binReader As BinaryReader = New BinaryReader(streamFile)

            m_byteBuffer = New Byte(streamFile.Length - 1) {}
            Dim read As Integer = binReader.Read(m_byteBuffer, 0, CInt(Fix(streamFile.Length)))

            ' send the memory buffer to the component
            If AudioDjStudio2.LoadSoundFromMemory(0, m_byteBuffer, CInt(Fix(streamFile.Length))) = AudioDjStudio.enumErrorCodes.NOERROR Then

            End If


'//Added captured device.
            Dim nResult As enumErrorCodes = AudioDjStudio2.WASAPI.AttachInputDeviceToPlayer(0, m_nCurrCaptureDevice, enumWasapiDeviceTypes.WASAPI_DEVICE_TYPE_CAPTURE)

            If nResult <> enumErrorCodes.NOERROR Then
                MessageBox.Show("Cannot start playback du to error " & nResult.ToString())
                Return
            End If

            lErrorCode = AudioDjStudio2.PlaySound(0)

*********************************************************************

Behavior of the Code:

1. Once I trigger play button there is no action and no sound is coming.(Showing No Error)
2. If I remove capture device from player (Just commented the code) then everything works fine.

Will you please guide me what is going wrong ???

Thanks and Regards,

Ravindra.


Administrator

Hello,

at a first glance it seems that you are using the same player for both the mp3 file and the input device: it would be like using a single deck for playing two different disks at the same time so it won't work.
Inside the InitSoundSystem method allocate 2 players instead of 1 (the first parameter of the method).

Due to the fact that you are using player 0 for the LoadSoundFromMemory method, be sure to use player 1 as first parameter of the call to the WASAPI.AttachInputDeviceToPlayer method.
At the same time, in order to play both sounds, you will need to invoke the PlaySound method for both player 0 and player 1.

Hope this helps.

Kind regards

Severino Delaurenti
MultiMedia Soft

Ravindra

Hello Severino,

The solution worked and I could hear the sound of my microphone now....Thanks a lot.

I am using Focusrite scarlet 2i2 interface as Audio Playback and Capture Device.
My inputs are,

Player_A = Playing a karaoke mp3 file
Player_B = Dyanamic microphone input given to first channel of interface.

I am getting output from Player_B (Microphone) very very low inspite of increasing the gain on my Interface. The volume control on microphone does not increase the volume level.
Also have a little latency issue.

 Private Sub trkMicrophone_Scroll(ByVal sender As Object, ByVal e As EventArgs) Handles trkMicrophoneVolume.Scroll
        AudioDjStudio2.WASAPI.DeviceVolumeSet(m_nCurrCaptureDevice, enumWasapiDeviceTypes.WASAPI_DEVICE_TYPE_CAPTURE, enumVolumeScales.SCALE_LINEAR, trkMicrophoneVolume.Value)
    End Sub

Can you further guide me to resolve this issue.

Thanks and Regards,

Ravindra.

Ravindra

Hello Severino,

After some workaround I could resolve the following issues now,

1. Low output is resolved after I applied Preamplifier.
1. Volume of a microphone is now getting controlled.
2. Latency is negligible.

The only issue which i am facing is that microphone sound is giving annoying echo effect.
inspite of keeping all enhancement disabled in my PC.

Do we have any provision to control this unwanted echo effect?

Thanks and Regards,

Ravindra.

Ravindra

Hello Severino,

With lot of workaround and referring to your sample projects i shifted to ASIO Driver.

Now i got rid of Latency and all other issues.

My current issues are,

1. I am not able to apply equalizer on ASIO Input (Microphone Input). It doesn't work.
   If i apply it to regular running sound mp3/mp4 it works.

2. I can not save ASIO Input / Output settings. DO you have any functions to retrieve last setting
   directly from ASIO Control Panel especially Input / output settings.  Because control panel keeps the
   last settings.

Thanks and Regards,

Ravindra.
 

Administrator

Hello,

1. the equalizer should not be applied to the input channel but to the player attached to the input channel through the ASIO.AttachInputChannelToPlayer method: may be that you are not using the correct value for the nPlayerIndex parameter when applying the equalizer?

2- Unfortunately the component doesn't have access to ASIO settings: it can only launch the ASIO control panel which contains the settings.

Kind regards

Severino Delaurenti
MultiMedia Soft


Ravindra

Hello Severino,

Thanks a lot for your guidance so far......

As per your suggestion i checked your doubt, but i have applied the equalizer to my second player correctly.

Actually i have given microphone input this channel. I am getting good sound and rest of the things like volume / Reverb are working fine.

In fact i modified the sample project AsioSpeakersManager in your VB.NET directory and applied the equalizer but no success.

Can you further investigate and suggest the right code to be written.

Thanks and Regards,

Ravindra.


Administrator

Hello,

could you be so kind to attach the modified AsioSpeakersManager project? In this way we could test your code directly.

Kind regards

Severino Delaurenti
MultiMedia Soft


Ravindra

Hello Severino,

I am attaching the Project for your reference.

Thanks And Regards,
You cannot view this attachment.
Ravindra.

Administrator

Hello,

the issue should be fixed inside the latest build 14.4 of the multimedia engine; you can get the latest build of the multimedia engine from the link below:
https://www.multimediasoft.com/bins/AdjMmsEng14.zip
and you can use it to replace existing instances on your PC under the following folders:
* C:\Program Files\MultiMedia Soft\Audio DJ Studio for .NET\Redist
* If your machine has a x86 version of Windows
    - C:\Windows\System32
* If your machine has a x64 version of Windows
    - C:\Windows\SysWOW64

The x64 version is available as well on the link below:
https://www.multimediasoft.com/bins/AdjMmsEng14_64.zip
and you can use it to replace existing instances on your PC under the following folders:
* C:\Program Files\MultiMedia Soft\Audio DJ Studio for .NET\Redist
* If your machine has a x64 version of Windows
    - C:\Windows\System32

Kind regards

Severino Delaurenti
MultiMedia Soft