MultiMedia Soft forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

SMF - Just Installed!

Author Topic: Record two session from same StreamMixerCreate  (Read 130 times)

thsorensen

  • Newbie
  • *
  • Posts: 3
    • View Profile
Record two session from same StreamMixerCreate
« on: January 24, 2019, 10:34:24 PM »

I'm trying to record two sessions from an internet stream.

I'm able to start recording to both files, but when I'm stopping recording#1, the other recording is stopping as well.


I start the stream with btnLoad.
Then clicking btnRestart1, followed by btnRestart2.
This will start recording to c:\data\zz.mp3 and c:\data\zz2.mp3.

After a couple of seconds, I press btnRestart1 again, this causes the studioSoundRecorder2 to ALSO stop recording.

Maybe this is clearer with this code:

Code: [Select]

    Dim smc1 As Short = 0
    Dim smc2 As Short = 0

  Private Sub btnLoad_Click(sender As Object, e As EventArgs) Handles btnLoad.Click
            audioDjStudio1.InitSoundSystem(1, 0, 0, 0, 0, -1)

            audioDjStudio1.LoadInternetStream(0, "URL")

            smc1 = audioDjStudio1.StreamMixerCreate(0, 48000, 2) 'always get 3000 here
            audioDjStudio1.StreamMixerPlayerAdd(smc1, 0)

            ' smc2 = audioDjStudio1.StreamMixerCreate(0, 48000, 2) 'always get 3001 here, but do not get any sound from this ID.
            ' audioDjStudio1.StreamMixerPlayerAdd(smc2, 0)

            audioSoundRecorder1.EncodeFormatForRecording = AudioSoundRecorder.enumEncodingFormats.ENCODING_FORMAT_MP3
            audioSoundRecorder1.EncodeMp3Mode = enumMp3EncodeModes.MP3_ENCODE_CBR
            audioSoundRecorder1.EncodeMp3CBR = 48000

            audioSoundRecorder2.EncodeFormatForRecording = AudioSoundRecorder.enumEncodingFormats.ENCODING_FORMAT_MP3
            audioSoundRecorder2.EncodeMp3Mode = enumMp3EncodeModes.MP3_ENCODE_CBR
            audioSoundRecorder2.EncodeMp3CBR = 48000
        End Sub

        Private Sub btnRestart1_Click(sender As Object, e As EventArgs) Handles btnRestart1.Click
            audioSoundRecorder1.Stop()
            audioSoundRecorder1.StartFromDjStudioMixer(smc1, "c:\data\zz.mp3")
        End Sub

        Private Sub btnRestart2_Click(sender As Object, e As EventArgs) Handles btnRestart2.Click
            audioSoundRecorder2.Stop()
            audioSoundRecorder2.StartFromDjStudioMixer(smc1, "c:\data\zz2.mp3") 'tried using smc2 here, but I'm not getting any sound.
        End Sub

Anyone have a clue what might be wrong?


---
Thomas
Logged

Administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 209
    • View Profile
    • MultiMedia Soft
Re: Record two session from same StreamMixerCreate
« Reply #1 on: January 27, 2019, 11:56:01 AM »

Hello Thomas,

due to the internal architecture, there are the following limitations that apply to your code:
- a single instance of the DJ studio component cannot create multiple stream mixers: only one is allowed.
- you can record from a specific stream mixer using one single instance of the recorder only
- a player can be attached to a single stream mixer only

We have verified that these points are not well documented so we will have to update the documentation accordingly.

Anyway, in order to achieve what you are trying to do, you should use a second instance of Audio DJ Studio and a code similar to the one below:

Code: [Select]
Dim smc1 As Short
Dim smc2 As Short
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AudioDjStudio1.InitSoundSystem(1, 0, 0, 0, 0, -1)
AudioDjStudio2.InitSoundSystem(1, 0, 0, 0, 0, -1)
AudioSoundRecorder1.InitRecorder(0, -1)
AudioSoundRecorder2.InitRecorder(0, -1)

smc1 = AudioDjStudio1.StreamMixerCreate(0, 48000, 2) 'always get 3000 here
AudioDjStudio1.StreamMixerPlayerAdd(smc1, 0)

smc2 = AudioDjStudio2.StreamMixerCreate(0, 48000, 2)
AudioDjStudio2.StreamMixerPlayerAdd(smc2, 0)

AudioDjStudio1.LoadInternetStream(0, strURL)
AudioDjStudio2.LoadInternetStream(0, strURL)

AudioSoundRecorder1.EncodeFormatForRecording = AudioSoundRecorder.enumEncodingFormats.ENCODING_FORMAT_MP3
AudioSoundRecorder1.EncodeMp3Mode = enumMp3EncodeModes.MP3_ENCODE_CBR
AudioSoundRecorder1.EncodeMp3CBR = 48000

AudioSoundRecorder2.EncodeFormatForRecording = AudioSoundRecorder.enumEncodingFormats.ENCODING_FORMAT_MP3
AudioSoundRecorder2.EncodeMp3Mode = enumMp3EncodeModes.MP3_ENCODE_CBR
AudioSoundRecorder2.EncodeMp3CBR = 48000

ButtonStart1.Enabled = False
ButtonStart2.Enabled = False
End Sub

Private Sub AudioDjStudio1_StreamLoaded(ByVal sender As System.Object, ByVal e As AudioDjStudio.StreamLoadedEventArgs) Handles AudioDjStudio1.StreamLoaded
AudioDjStudio1.PlaySound(0)
ButtonStart1.Enabled = True
End Sub

Private Sub AudioDjStudio2_StreamLoaded(ByVal sender As System.Object, ByVal e As AudioDjStudio.StreamLoadedEventArgs) Handles AudioDjStudio2.StreamLoaded
AudioDjStudio2.PlaySound(0)
ButtonStart2.Enabled = True
End Sub

Private Sub ButtonStart1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonStart1.Click
AudioSoundRecorder1.Stop()
AudioSoundRecorder1.StartFromDjStudioMixer(smc1, "c:\zz.mp3")
End Sub

Private Sub ButtonStart2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonStart2.Click
AudioSoundRecorder2.Stop()
AudioSoundRecorder2.StartFromDjStudioMixer(smc2, "c:\zz2.mp3")
End Sub

Hope this helps

Kind regards

Severino Delaurenti
MultiMedia Soft
« Last Edit: January 27, 2019, 12:21:52 PM by Administrator »
Logged