send an input audio stream to a streaming server?

Started by Terry, November 05, 2024, 05:51:24 AM

Previous topic - Next topic

Terry

Hi,

Is there any way to send an input audio device stream to a streaming server?

Terry
Thank you.

Administrator

Hello Terry,

yes, this is possible with our DJ Studio components: take a look into the WasapiMixAndClone sample project, installed by our setup program, which shows how to attach an input device to the internal stream mixer and to send the result to a streaming server.

Hope this helps.

Kind regards

Severino Delaurenti
MultiMedia Soft

Terry

Hi,

There are two ways to send an audio stream to a streaming server. The sample project is one of them.
But it still needs to be attached to a Player and then output.
Is there any way to capture only the input audio source but not play output?

There is one more thing that I am confused about the WasapiMixAndClone sample project.
Why a control can initial more than 4 players? The three extra Players in the sample program seem to have no effect.

// init the DJ Studio control by instancing an adequate number of players:
// 2 for playing sound files from disk and 5 for attaching input devices
short nPlayers = 2 + 5;
nPlayers = m_audioDjAPI.InitSoundSystem(nPlayers, m_nWasapiDevice, m_nWasapiDevice, m_nWasapiDevice, 0);

Terry
Thank you

Administrator

Hello

Quote from: Terry on November 07, 2024, 06:35:13 AMThere are two ways to send an audio stream to a streaming server. The sample project is one of them.
But it still needs to be attached to a Player and then output.
Is there any way to capture only the input audio source but not play output?

Yes, you can avoid any sound being sent to the render device by setting its output device to -1; inside the FormMain_Load function you will find the following lines of code

// obtain the stream mixer internal to the selected WASAPI device
m_nStreamMixerUniqueID = m_audioDjAPI.StreamMixerGetIdFromOutput (m_nWasapiDevice);

simply add the following code immediately after them:

m_audioDjAPI.StreamOutputDeviceSet(m_nStreamMixerUniqueID, -1);

QuoteThere is one more thing that I am confused about the WasapiMixAndClone sample project.
Why a control can initial more than 4 players? The three extra Players in the sample program seem to have no effect.

// init the DJ Studio control by instancing an adequate number of players:
// 2 for playing sound files from disk and 5 for attaching input devices
short nPlayers = 2 + 5;
nPlayers = m_audioDjAPI.InitSoundSystem(nPlayers, m_nWasapiDevice, m_nWasapiDevice, m_nWasapiDevice, 0);

Inside the project there are 2 players that are used for loading and playing sound files from disk (Player_1 and Player_2) while the other 5 players (Player_Input_3 up to Player_Input_7) are used to attach different input channels and mix them into the internal stream mixer of the render device.
If you shouldn't need to play sounds from files on disk and you should simply need to attach and cast one single input stream you may instance one single player only.

Hope this helps

Kind regards

Severino Delaurenti
MultiMedia Soft

Terry

#4
Hi,

I found that the streaming audio sent from CastingCreateFromStreamMixer becomes faster and choppy. You can listen to http://220.135.102.142:8010/q, which is sent through the sample program WasapiMixAndClone.exe. And http://220.135.102.142:8010/test is sent by another program and is relatively normal. You can compare the two. Both audio sources are from the same input device.

Terry
Thank you.

Administrator

Hello,

looking at the properties of the 2 streams, it seems that the first one has a bitrate of 128 Kbps while the second one has a bitrate of 96 Kbps: please, try to reduce the one sent by our sample to 96 Kbps, using the connection Settings form accessible through the "Settings" button, and see if the problem persists.

Kind regards

Severino Delaurenti
MultiMedia Soft

Terry

Hi,

I have already adjusted it to 96 K, but the situation remains the same.

Terry

Administrator

#7
Hello,

we have been able to replicate the issue so we made a slight modification to our 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 Sound Suite API for .NET\Audio DJ Studio API for .NET\Redist
* C:\Program Files\MultiMedia Soft\Audio Sound Suite API for .NET\Audio Sound Recorder API for .NET\Redist
* C:\Program Files\MultiMedia Soft\Audio Sound Suite API for .NET\Audio Sound Editor API 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 Sound Suite API for .NET\Audio DJ Studio API for .NET\Redist
* C:\Program Files\MultiMedia Soft\Audio Sound Suite API for .NET\Audio Sound Recorder API for .NET\Redist
* C:\Program Files\MultiMedia Soft\Audio Sound Suite API for .NET\Audio Sound Editor API for .NET\Redist
* If your machine has a x64 version of Windows
  - C:\Windows\System32

It would be very kind of you if you could report us if the updated version is enough to fix the reported issue.

Kind Regards

Severino Delaurenti
MultiMedia Soft

Terry

Hi,

I have replaced AdjMmsEng64.dll and AdjMmsEng.dll(ver. 14.4.5.2), but the connection shows an 'ERR_ENCODER_NOT_AVAILABLE' error message. Reverting to the previous version (ver. 14.4.5.1) works fine. All sample programs related to casting show the same error.

Terry
Thank you.

Administrator

Hello,

as recommended inside the documentation tutorial "How to use the control as a source for streaming servers like SHOUTcast" https://www.multimediasoft.com/adjstudnetapi/help/adjstudnet_000076.htm
and inside the section "Files to be included with your application"
https://www.multimediasoft.com/adjstudnetapi/help/adjstudnet_000002.htm
in order to encode certain formats (like MP3) for ShoutCast and Icecast servers there is the need of an external encoder (Lame.exe, etc.).

It must be remarked that inside the previous versions we tried to use an internal encoder that seemed to work well but, unfortunately, it seems to give the problem you reported so we reverted back the behaviour to the usage of the external encoders as specified inside the documentation while we will investigate the problem further.

A copy of the needed encoders should be already available inside the "\Windows\System32" folder of the PC where you originally installed our setup package.

Hope this helps

Kind Regards

Severino Delaurenti
MultiMedia Soft

Administrator

Hello again,

after further investigation we have found the nature of the original issue and we have reverted the code in order to use again the internal encoders for casting purposes so there would be no more need to use an external encoder: we suggest to download again the multimedia engine, using previously provided URLs, and see if the new build fixes the problem on your side as well.

It would be very kind of you if you could report us if the updated version is enough to fix the reported issue.

Kind Regards

Severino Delaurenti
MultiMedia Soft

Terry

Hi,

After replacing the program, the issue no longer occurs. Thank you. However, I have discovered another problem that existed even before the update.

When using "CastingCreateFromStreamMixer" to generate encoded streams and connect to the same or different "Icecast Servers" with different MountPoint Names, only the last MountPoint remains on the "Icecast server", and all others disappear. I slightly modified the WasapiMixAndClone sample program as follows:

For i = 0 To 3
    Dim mp As String = frmShoutcast.TextMountName.Text.Trim & "." & i.ToString

    ' create and intialize casting
    m_nCastingUniqueID = m_audioDjAPI.CastingCreateFromStreamMixer(m_nStreamMixerUniqueID, frmShoutcast.TextServerAddress.Text, frmShoutcast.TextPwd.Text, mp, nFormat, frmShoutcast.TextStreamName.Text, frmShoutcast.TextUrl.Text, frmShoutcast.TextGenre.Text, "", frmShoutcast.TextDescription.Text, nEncodeMode, fEncodeValue, 44100, 2)

    ' check if casting was intialized correctly
    If m_nCastingUniqueID = 0 Then
       CheckConnection.Checked = False
       CheckConnection.Text = "Connect"
       MessageBox.Show("Cannot create casting due to the following error " & m_audioDjAPI.LastError.ToString())
       Return
    End If
    .
    .
    .same codes
    . 
    .
 Next

When connect to Icecast, each MountPoint can be seen on the Icecast2 Status management webpage. However, when trying to listen by entering the URL, a '404 - The file you requested could not be found' error appears, and then the MountPoint disappears from the Icecast2 Status management webpage.

This phenomenon only occurs with CastingCreateFromStreamMixer, but not with CastingCreateFromPlayer."

Any idea?

Terry

Administrator

Hello,

thanks for your feedback.

It's likely that you are not using the stream mixer and the casting in the correct way: when using WASAPI, a single stream mixer, in this case the internal stream mixer that serves as the output of the sound card, can only serve one casting (mount point) at a time: if you use the same stream mixer for more mount points, only the last one will effectively work. This behaviour is by design.

As you noticed, this doesn't happen when using a player so you could have more than one player, each linked to a different casting session.

Kind Regards

Severino Delaurenti
MultiMedia Soft


Administrator

Hello again,

a possible solution to your problem, allowing to operate as a source for multiple mount points from a single application, would be to avoid using the WASAPI protocol and to use the default DirectSound protocol, allowing to create multiple custom stream mixers and to cast each of them to a separate mount point.

For this purpose we have created a small sample which shows how to operate; you can download it from the link below:
https://www.multimediasoft.com/tmp/Sample.zip

Before using this sample it's recommended that you download and replace again the multimedia engine in order to avoid a small bug that was found while creating the sample.

Hope this helps.

Kind Regards

Severino Delaurenti
MultiMedia Soft