Author Topic: Record the line/microphone with vst, monitor the sound before or during  (Read 658 times)

hub73

  • Posts: 68
Hello.
My Scarlett solo external card (with microphone XLR input) is connected to my PC with USB)
i know how to record the sound from the Microphone and write an ogg file, and apply some Vst on it : (Purebasic)

Code: [Select]
Procedure.l Son_EnregistrementCallback_enreg(Channel.l, *buffer, length.f, user.f)
  Protected Result.l
  Result = BASS_Encode_IsActive(Channel); //  <> 0 continue recording if encoder is live
  BASS_Encode_Write(Channel.l,*buffer,length.f)
  ProcedureReturn Result
 EndProcedure

BASS_RecordInit(InputDevice)
Channel_enreg = BASS_RecordStart (48000, 2, #BASS_RECORD_PAUSE | #BASS_SAMPLE_FLOAT, @Son_EnregistrementCallback_enreg(), #Null);)
FDSP  = BASS_VST_ChannelSetDSP(Channel_enreg, VstPath, #BASS_Unicode, 0);
HENCODE_encoder_enreg = BASS_Encode_Ogg_StartFile(Channel_enreg, @options, #BASS_UNICODE | #BASS_ENCODE_AUTOFREE, @NomFichier); // setup the encoder
BASS_ChannelPlay(Channel_enreg, 0)

But how to monitor the microphone sound (with vst) and listen it to my headphones (connected to the Scarlett). This before  or during record.

(Note : i can hear only the microphone sound on my headphones with the scarlett monitor switch button, but without the vst effect).

Many thanks for pseudo code sample !

Ian @ un4seen

  • Administrator
  • Posts: 24589
You could create a "push" stream and have your RECORDPROC callback feed the recorded data to it. That could look something like this:

Code: [Select]
outstream = BASS_StreamCreate(48000, 2, BASS_SAMPLE_FLOAT, STREAMPROC_PUSH, 0); // create a push stream with same format as recording
BASS_ChannelPlay(outstream, 0); // start it

...

BOOL CALLBACK RecordProc(HRECORD handle, const void *buffer, DWORD length, void *user)
{
BASS_StreamPutData(outstream, buffer, length); // pass data to output stream
return TRUE; // continue recording
}

Please see the BASS_StreamCreate and BASS_StreamPutData documentation for details.

hub73

  • Posts: 68
Thanks Ian.
I've updated my code to this, (but not work no sound on my headphones)
Perhaps something at the wrong place ! :

Code: [Select]
Procedure.l Son_EnregistrementCallback_enreg(Channel.l, *buffer, length.f, user.f)
 
  Protected Result.l
 
  Result = BASS_Encode_IsActive(Channel); //  <> 0 continue recording if encoder is live
 
  BASS_Encode_Write(Channel.l,*buffer,length.f)
 
  BASS_StreamPutData(gParametres\Channel_play.l, *buffer, length.f); // pass data to output stream
 
  ProcedureReturn Result
 
EndProcedure

Procedure Son_commencer_enregistrer()
 
  Protected NomFichier.s
  Protected Retour
 
  Protected i
 
  Protected NumFic
 
  NomFichier = gParametres\CheminFichier$
 
  If NomFichier <> ""
   
    Arreter_sonore()
   
    SetGadgetText (Button_gerer_enregistrement, "Arrêter l'enregistrement de ma voix")
   
    ; ---
   
    Retour = BASS_RecordInit(gParametres\Dispositif_sonore_entree)
   
     If Retour = 0
       Ajouter_au_log ("Bass: choix dispositif enregistrement : " + BASS_ErrorGetCode())
       BASS_RecordFree()
       ProcedureReturn #False
     EndIf
     
     Retour = BASS_RecordSetDevice(gParametres\Dispositif_sonore_entree)
     If Retour = 0
       Ajouter_au_log ("Bass: choix dispositif enregistrement : " + BASS_ErrorGetCode())
       ProcedureReturn #False
     EndIf
     
     gParametres\Channel_play = BASS_StreamCreate(48000, 2, #BASS_SAMPLE_FLOAT, #STREAMPROC_PUSH, 0); // create a push stream with same format as recording
     BASS_ChannelPlay(gParametres\Channel_play, 0)
     
     MessageRequester ("info", Str(gParametres\Channel_play))
     
     gParametres\Channel_enreg = BASS_RecordStart (48000, 2, #BASS_RECORD_PAUSE | #BASS_SAMPLE_FLOAT, @Son_EnregistrementCallback_enreg(), #Null);)
     
     If gParametres\Channel_enreg = 0
       Ajouter_au_log ("Bass : enregistrement erreur : " + BASS_ErrorGetCode())
       ProcedureReturn #False
     Else
       Ajouter_au_log ("Bass : enregistrement démarré.")
     EndIf 
     
    If gParametres\bActiverVst = #True
      Son_ouvrir_vst_01()
      Son_ouvrir_vst_02()
      Son_ouvrir_vst_03()
    EndIf
   
    Protected Options.s
    Options = StringToANSI("--bitrate 192")
   
    gParametres\HENCODE_encoder_enreg = BASS_Encode_Ogg_StartFile(gParametres\Channel_enreg, @options, #BASS_UNICODE | #BASS_ENCODE_AUTOFREE, @NomFichier); // setup the encoder
   
    If gParametres\HENCODE_encoder_enreg = 0
      Ajouter_au_log ("Bass : erreur de l'encodeur ogg : " + BASS_ErrorGetCode())
      ProcedureReturn #False
    Else
      Ajouter_au_log ("Encodeur OGG Bass fonctionne. ("+ Str(gParametres\HENCODE_encoder_enreg) + ")")
    EndIf
       
    BASS_ChannelPlay(gParametres\Channel_enreg, 0)
    ;BASS_ChannelPlay(gParametres\Channel_play, 0)
   
    Afficher_message ("Enregistrement du fichier en cours, parlez dans votre micro !")
    gParametres\NbEssais = gParametres\NbEssais + 1
    gParametres\Enregistre = #True
    gParametres\TempsEnregistrement = ElapsedMilliseconds()
     
   Else
     
     MessageRequester ("Erreur","Veuillez indiquer le nom et l'emplacement du fichier auparavant !")
     
   EndIf
   
EndProcedure

hub73

  • Posts: 68
Code: [Select]
Procedure.l Son_EnregistrementCallback_enreg(Channel.l, *buffer, length.f, user.f)
 
  Protected Result.l
  Protected toto
  Protected titi
 
  Result = BASS_Encode_IsActive(Channel); //  <> 0 continue recording if encoder is live
 
  titi = BASS_ChannelGetData(Channel.l, *buffer, length.f) ; A ENLEVER
  Debug "titi=" + Str(titi)
 
  BASS_Encode_Write(Channel.l,*buffer,length.f)
 
  toto = BASS_StreamPutData(gParametres\Channel_play.l, *buffer, length.f); // pass data to output stream
  Debug "toto=" + Str(Toto)
 
 
  ProcedureReturn Result
 
EndProcedure

debug value variable 'toto' return always '0'
debug value variable 'titi' return sometimes a value by eample 7680.

Ian @ un4seen

  • Administrator
  • Posts: 24589
Make sure you have also called BASS_Init somewhere beforehand. If it still doesn't work then please check all return values for any failures. If any call is failing, you can then use BASS_ErrorGetCode to find out why.

hub73

  • Posts: 68
BASS_Init is called before. The program does not crash but nothing happens. I checked all return values for any failures and and I have no particular error.  Otherwise everything else works I can record my voice with the vst effects applied in an ogg file. It's a shame not to have a back sound before to properly adjust and hear the effects. Many thanks for your help Ian.
« Last Edit: 12 Jul '22 - 19:58 by hub73 »

hub73

  • Posts: 68
maybe there is another way? Mixer ?

Ian @ un4seen

  • Administrator
  • Posts: 24589
The encoder will be fed the data from its source automatically by default (unless BASS_ENCODE_PAUSE is set), so you shouldn't call BASS_Encode_Write to feed the data again in the RECORDPROC callback. Try just doing this in the RECORDPROC:

Code: [Select]
BOOL CALLBACK RecordProc(HRECORD handle, const void *buffer, DWORD length, void *user)
{
BASS_StreamPutData(outstream, buffer, length); // pass data to output stream
return BASS_Encode_IsActive(handle); // continue recording if encoder is alive
}

If you still hear nothing then please check what BASS_ChannelIsActive(outstream) reports. Also confirm what device you initialized in your BASS_Init call (check it isn't the "No Sound" device).

hub73

  • Posts: 68
BASS_ChannelIsActive(outstream) report '1'

Quote
BASS_Init call (check it isn't the "No Sound" device).
i use BASS_SetDevice to choose the output. Next Windows 10 takes over (with the 'speaker' icon in the taskbar) and actually really chooses the final audio output. I have an internal card and the external Focusrite in usb.

Is it possible with BASS to listen directly the sound of the microphone on the audio output? (with or without vst).
Microphone -> Bass -> vst -> audio output

when i record it works
Microphone -> Bass -> vst -> record to a file.

maybe another solution :
sound microphone -> Bass with an mixer channel -> output to headphones?

sorry to bother you with this. For my software would be great to achieve this !




Ian @ un4seen

  • Administrator
  • Posts: 24589
i use BASS_SetDevice to choose the output.

What device parameter are you using in the BASS_SetDevice call, and what is the return value? Note you will need to initialize the device with BASS_Init before it can be used in a BASS_SetDevice call.

Also, what value do you get from BASS_ChannelGetDevice(outstream)?

Is it possible with BASS to listen directly the sound of the microphone on the audio output? (with or without vst).
Microphone -> Bass -> vst -> audio output

when i record it works
Microphone -> Bass -> vst -> record to a file.

The "push" stream should achieve that but note that you will still need a recording channel to feed it. You can simply leave out the BASS_Encode_Ogg_StartFile call when you don't want to record to file. You should also leave out the BASS_Encode_IsActive call from your RECORDPROC function in that case.

hub73

  • Posts: 68
Quote
The "push" stream should achieve that but note that you will still need a recording channel to feed it. You can simply leave out the BASS_Encode_Ogg_StartFile call when you don't want to record to file. You should also leave out the BASS_Encode_IsActive call from your RECORDPROC function in that case.

Code: [Select]
Procedure.l Son_EnregistrementCallback_enreg_deux(Channel.l, *buffer, length.f, user.f)
 
  Protected Result.l
 
  BASS_StreamPutData(gParametres\Channel_enreg, *buffer, length); // pass data to output stream
 
  Result.l = 1
 
  ProcedureReturn Result.l
 
EndProcedure

Procedure Son_commencer_enregistrer()
 
  Protected Retour
 
  Protected i
 
  Protected NumFic
   
    Arreter_sonore()
   
    Bass_Init(-1, 41400, 0, 0, #Null)
   
    SetGadgetText (Button_gerer_enregistrement, "Arrêter l'enregistrement de ma voix")
   
    Debug "Dispositif sortie " + Str(gParametres\Dispositif_sonore_sortie)
   
    ;BASS_SetDEvice (gParametres\Dispositif_sonore_sortie)
    BASS_SetDEvice (2)
   
    Retour = BASS_RecordInit(gParametres\Dispositif_sonore_entree)
    Debug "Dispositif enregistrement " + Str(gParametres\Dispositif_sonore_entree)
    If Retour = 0
       Debug ("Bass: choix dispositif enregistrement : " + BASS_ErrorGetCode())
       BASS_RecordFree()
       MessageRequester ("Erreur", "Erreur")
       ProcedureReturn #False
     EndIf
     
     gParametres\Channel_enreg = BASS_RecordStart (41400, 2, #BASS_SAMPLE_FLOAT, @Son_EnregistrementCallback_enreg_deux(), #Null);)
     
     If gParametres\Channel_enreg = 0
       Debug "Bass : enregistrement erreur : " + BASS_ErrorGetCode()
       ProcedureReturn #False
     EndIf 
       
    BASS_ChannelPlay(gParametres\Channel_enreg, 0)
   
EndProcedure

I've no sound on the headphones, but my db meter indicate some sound ! (see picture) What is this mystery !
« Last Edit: 14 Jul '22 - 17:41 by hub73 »

Chris

  • Posts: 2082
Hi,  how much Bass_Init do you  have ?

for every Device Bass must Init the Devices.

i will see only "Bass_Init(-1, 41400, 0, 0, #Null)"     (-1 Default/First Device) so that`s Device 1

But you are Calling Bass_SetDevice(2)  ,  I don`t see   "Bass_Init(2, 41400, 0, 0, #Null)"

When  BASS_SetDevice is called, BASS will check the current thread's device setting, and if no device is selected (or the selected device is not initialized), BASS will automatically select the lowest device that is initialized.

You can Check it on this way

If (not Bass_SetDevice(2)) then
begin
  // Now Check it via Bass_ErrorGetCode ...... if  BASS_ERROR_INIT    or  BASS_ERROR_DEVICE the Error is.
end;
« Last Edit: 15 Jul '22 - 08:15 by Chris »

hub73

  • Posts: 68
I've two sound cards.

1- Internal PC Souncard on motherboard
2- External USB Sound Card (Focus Rite) XLR input with the microphone.

I just want  Select a Card, and next the input and output.

So. Record from the XLR microphone INPUT on the FocusRite, and play the sound (monitor and final when the files is saved) on the OUTPUT FocusRite HeadPhone.

Perhaps i'm wrong with SetDevice. ? Setdevice is not also used to choose the input or output of the sound card? So I'm a bit lost!


Guest

  • Guest
Hi,  how much Bass_Init do you  have ?

for every Device Bass must Init the Devices.

i will see only "Bass_Init(-1, 41400, 0, 0, #Null)"     (-1 Default/First Device) so that`s Device 1

But you are Calling Bass_SetDevice(2)  ,  I don`t see   "Bass_Init(2, 41400, 0, 0, #Null)"

When  BASS_SetDevice is called, BASS will check the current thread's device setting, and if no device is selected (or the selected device is not initialized), BASS will automatically select the lowest device that is initialized.

You can Check it on this way

If (not Bass_SetDevice(2) then
begin
   Now Check it via Bass_ErrorGetCode ...... if  BASS_ERROR_INIT    or  BASS_ERROR_DEVICE the Error is.
end;

TE used Purebasic not Delphi!
so begin and end is wrong..

Code: [Select]
If (not Bass_SetDevice(2) then
   Now Check it via Bass_ErrorGetCode ...... if  BASS_ERROR_INIT    or  BASS_ERROR_DEVICE the Error is.

Chris

  • Posts: 2082
@hub73

You must call for every Device Bass_Init.
so in your case
Code: [Select]
Bass_Init(1, 41400, 0, 0, #Null) // first Device
Bass_Init(2, 41400, 0, 0, #Null) // Second Device

after that Calls you can switch via Bass_SetDevice.........

Ian @ un4seen

  • Administrator
  • Posts: 24589
Note device 1 is the "Default" device (unless disabled via BASS_CONFIG_DEV_DEFAULT), so your real devices/soundcards will probably be at device 2 and 3. You can use BASS_GetDeviceInfo to enumerate devices.

hub73

  • Posts: 68
Thanks to you two. I will take a good look at this in detail. All I'm missing is the return sound from the microphone to the headphones. By dint of attempts I will succeed!

hub73

  • Posts: 68
- Now i use a mixer. Mixer is 'Icecasted'... ok
- The mixer receive sound from played ogg files... ok
- All the final mixer output is also recorder to a file... ok

- So now how to add the microphone sound to the mixer ? (yes i lost it again !  :( ) Check Son_micro()
You're welcome if you have complete code to do this : microphone -> mixer !

Note i use an external soundcard Focusrite Solo with the XLR MIcrophone plugged.

Code: [Select]
Procedure Son_MicroCallBack(Channel.l, *buffer, length.f, user.f)
 
  Protected Result.l
 
  BASS_StreamPutData(Channel.l, *buffer, length.f)
  BASS_Encode_Write(Channel.l,*buffer,length.f)
  BASS_ChannelGetData(Channel.l, *buffer, length.f)
 
  Result = BASS_Encode_IsActive(Channel); //  <> 0 continue recording if encoder is live

  ProcedureReturn Result
 
EndProcedure

Procedure Son_micro()
 
  BASS_RecordInit(0)  ;initializing input device
  gParametres\Channel_micro = BASS_StreamCreate(44100, 2, #BASS_SAMPLE_FLOAT|#BASS_STREAM_DECODE, #Null,#Null)
  gParametres\EntreeMicro = BASS_RecordStart (48000, 2, #BASS_RECORD_PAUSE | #BASS_SAMPLE_FLOAT, @Son_MicroCallBack(), #Null);)
  BASS_ChannelPlay (gParametres\Channel_micro, 1)
  BASS_Mixer_StreamAddChannel(gParametres\Mixer, gParametres\Channel_micro, #BASS_STREAM_AUTOFREE) 
 
EndProcedure

Procedure Son_caster()
 
  Protected NomServeur.s
  Protected MotDePasse.s
  Protected Nom.s
  Protected Url.s
  Protected Genre.s 
  Protected Description.s
  Protected Header.s
  Protected Commande.s
 
  Protected Retour
 
  Protected t
  Retour = BASS_SetDevice (gParametres\Dispositif_sonore_sortie)
  If Retour <> 1
    MessageRequester ("Erreur", "Dispositif de sortie non initialisé !")
  EndIf
 
  BASS_SetConfig (#BASS_CONFIG_NET_TIMEOUT, #ICECAST_TEMPS_NET_CONFIG_SECONDES * 5000)
 
  Son_Initialiser_mixer()
  Son_changer_volume_mixer (100)
 
  NomServeur = StringToANSI(gParametres\IceCastServeur) ; address:port/mount" (Icecast).
  MotDePasse = StringToANSI(gParametres\IceCastUtilisateur)
  Nom = StringToANSI(gParametres\IceCastNom)
  Url = StringToANSI(gParametres\IceCastUrl)
  Genre = StringToANSI(gParametres\IceCastGenre)
  Description = StringToANSI (gParametres\IceCastDescription)
  Header = StringToANSI(gParametres\IceCastEntete)
 
  Description = StringToANSI ("Webradio à Castelnaudary France")
 
  Retour = BASS_RecordInit(gParametres\Dispositif_sonore_entree)
  If Retour = 0
    Ajouter_au_log ("Choix dispositif enregistrement : " + BASS_ErrorGetCode(), #LOG_ERREUR)
    BASS_RecordFree()
    ProcedureReturn #False
  EndIf
 
  Retour = BASS_RecordSetDevice(gParametres\Dispositif_sonore_entree)
  If Retour = 0
    Ajouter_au_log ("Choix dispositif enregistrement : " + BASS_ErrorGetCode(), #LOG_ERREUR)
    ProcedureReturn #False
  EndIf
 
  Son_ouvrir_vst(1)
  Son_ouvrir_vst(2)
  Son_ouvrir_vst(3)
  Son_ouvrir_vst(4)
  Son_ouvrir_vst(5)
  Son_ouvrir_vst(6)
 
  Protected Options.s
  Options = StringToANSI("--bitrate 192")
 
  gParametres\HENCODE_encoder = BASS_Encode_Ogg_Start(gParametres\Mixer, @options, #BASS_UNICODE | #BASS_ENCODE_AUTOFREE, #Null, #Null); // setup the encoder
 
  If gParametres\HENCODE_encoder = 0
    Ajouter_au_log ("Bass : erreur de l'encodeur ogg : " + BASS_ErrorGetCode(), #LOG_ERREUR)
    ProcedureReturn #False
  Else
    Ajouter_au_log ("Encodeur OGG Bass fonctionne. ("+ Str(gParametres\HENCODE_encoder) + ")", #LOG_NORMAL)
  EndIf
 
  Protected Content.s
 
  Content = StringToANSI (#BASS_ENCODE_TYPE_OGG)
 
  Site_envoyer_commande ("CASTSTOP")
  Site_envoyer_commande ("PAUSE")
  Direct_manuel_envoyer_infos_site()
 
  Ajouter_au_log ("Connexion au serveur IceCast en cours...", #LOG_NORMAL)
 
  Patienter_ouvrir_fenetre ("Veuillez patienter. Connexion au serveur IceCast en cours...")
 
  Retour = BASS_Encode_CastInit(gParametres\HENCODE_encoder, @NomServeur, @MotDePasse, @content, @Nom, @Url , @Genre, @Description, @Header, 0, 0) ; débute le cast
 
  Patienter_fermer_fenetre()
 
  If Retour = 1
   
    Ajouter_au_log ("Connecté au serveur IceCast. (" + Str(Retour) + ")", #LOG_NORMAL)
   
    SetGadgetColor (Text_icecast_infos, #PB_Gadget_BackColor, $00FF00)
    SetGadgetText (Text_icecast_infos, "CAST OK")
    SetGadgetText (Button_direct_commencer_terminer, "Terminer le direct")
   
    Son_enregistrer()
   
    gParametres\bTenterReconnecterIceCast = #False
   
  Else 
   
    Select BASS_ErrorGetCode()
       
      Case #BASS_ERROR_BUSY
       
         SetGadgetColor (Text_icecast_infos, #PB_Gadget_BackColor, $0000FF)
         SetGadgetText (Text_icecast_infos, "CAST OCCUPE !")
       
         Ajouter_au_log ("Le serveur IceCast est déja occupé !", #LOG_ERREUR)
         
         Site_envoyer_commande ("REPRISE")
         Site_envoyer_commande ("CASTGO")
         
         Son_liberer_mixer()
       
      Default
       
         Ajouter_au_log ("IceCast : Connection serveur Erreur n° : " + BASS_ErrorGetCode(), #LOG_ERREUR)
         Ajouter_au_log ("IceCast : Tentative de reconnexion dans " + Str(#ICECAST_TEMPS_RECONNEXION_SECONDES) + " secondes", #LOG_WARNING)
       
         SetGadgetColor (Text_icecast_infos, #PB_Gadget_BackColor, $0000FF)
         SetGadgetText (Text_icecast_infos, "CAST ERREUR !")
         
         BASS_RecordFree()
         BASS_Encode_Stop (gParametres\HENCODE_encoder)
         
         Son_fermer_vst(1)
         Son_fermer_vst(2)
         Son_fermer_vst(3)
         Son_fermer_vst(4)
         Son_fermer_vst(5)
         Son_fermer_vst(6)
         
         Son_liberer_mixer()
         
         gParametres\TempsReconnexionIceCast = ElapsedMilliseconds()
         gParametres\bTenterReconnecterIceCast = #True
       
    EndSelect
   
  EndIf
 
  BASS_ChannelPlay(gParametres\mixer, 1)
 
  Son_micro()
 
  BASS_Encode_SetNotify(gParametres\HENCODE_encoder, @Son_EncoderNotify(), 0)
 
EndProcedure

Procedure.l Son_EnregistrementCallback_enreg(Channel.l, *buffer, length.f, user.f)
 
  Protected Result.l
 
  Result = BASS_Encode_IsActive(Channel); //  <> 0 continue recording if encoder is live
 
  BASS_Encode_Write(Channel.l,*buffer,length.f)
 
  ProcedureReturn Result
 
EndProcedure

Procedure Son_enregistrer()
 
  Protected NomFichier.s
  Protected Retour
 
  Protected StandardFile$
  Protected Pattern$
  Protected Pattern
  Protected i
 
  NomFichier = gParametres\CheminFichierEnregAudio
 
  If NomFichier <> ""
   
     Retour = BASS_RecordSetDevice(gParametres\Dispositif_sonore_entree)
     If Retour = 0
       Ajouter_au_log ("Choix dispositif enregistrement : " + BASS_ErrorGetCode(), #LOG_ERREUR)
       ProcedureReturn #False
     EndIf
     
    Protected Options.s
    Options = StringToANSI("--bitrate 192")
   
    gParametres\HENCODE_encoder_enreg = BASS_Encode_Ogg_StartFile(gParametres\Mixer, @options, #BASS_UNICODE | #BASS_ENCODE_AUTOFREE, @NomFichier); // setup the encoder
   
    If gParametres\HENCODE_encoder_enreg = 0
      Ajouter_au_log ("Erreur de l'encodeur d'enregistrement fichier ogg : " + BASS_ErrorGetCode(), #LOG_ERREUR)
      ProcedureReturn #False
    Else
      Ajouter_au_log ("Encodeur OGG Bass d'enregistrement fichier fonctionne. ("+ Str(gParametres\HENCODE_encoder_enreg) + ")", #LOG_NORMAL)
    EndIf
       
    BASS_ChannelPlay(gParametres\Channel_enreg, 0)
   
    SetGadgetColor (Text_enregistrement, #PB_Gadget_BackColor, $00FF00)
    SetGadgetText (Text_enregistrement, "ENREG. OK") 
 
   Else
     
     MessageRequester ("Erreur","Nom de fichier non valide pour enregistrement !")
     
    SetGadgetColor (Text_enregistrement, #PB_Gadget_BackColor, $0000FF)
    SetGadgetText (Text_enregistrement, "ENREG. ERR") 
     
   EndIf
   
EndProcedure

Procedure Son_arreter_cast()
 
  Son_fermer_vst(1)
  Son_fermer_vst(2)
  Son_fermer_vst(3)
  Son_fermer_vst(4)
  Son_fermer_vst(5)
  Son_fermer_vst(6)
 
  BASS_RecordFree()
 
  SetGadgetText (Button_direct_commencer_terminer, "Lancer le direct")
 
  Ajouter_au_log ("Cast terminé, serveur libéré.", #LOG_NORMAL)
  Afficher_message ("Cast terminé, serveur libéré.")
 
  SetGadgetColor (Text_icecast_infos, #PB_Gadget_BackColor, $FFFFFF)
  SetGadgetText (Text_icecast_infos, "...") 
 
  SetGadgetColor (Text_enregistrement, #PB_Gadget_BackColor, $FFFFFF)
  SetGadgetText (Text_enregistrement, "...") 
 
  Site_envoyer_commande ("REPRISE")
  Site_envoyer_commande ("CASTGO")
 
  Cartouches_arreter_sons_tous()
 
  Son_liberer_mixer()
 
EndProcedure
Ton of thanks if you can help me about that !
« Last Edit: 22 Jul '22 - 23:14 by hub73 »

hub73

  • Posts: 68
Maybe it's not possible to do this:
- Device 0 (input) Scarlett Solo XLR microphone.
- Device 2 (usb output) Scarlett Solo.

Device 0 (microphone) -> mixer (--- NOT OK my problem here! ---)
Device 2 (sounds played) -> mixer (ok)

Mixer -> IceCast (ok)
Mixer -> Save Ogg file to computer (ok)

hub73

  • Posts: 68
do I need an encoder (ogg) on ​​the microphone channel?

hub73

  • Posts: 68
Code: [Select]
Procedure Son_MicroCallBack(Channel.l, *buffer, length.f, user.f)
 
  Protected Result.l
  Protected toto
 
  Result = BASS_Encode_IsActive(Channel); //  <> 0 continue recording if encoder is live
 
  BASS_StreamPutData(gParametres\Mixer, *buffer, length.f)
  BASS_Encode_Write(gParametres\Mixer,*buffer,length.f)
  BASS_ChannelGetData(gParametres\Mixer, *buffer, length.f)
 
  Result = 1
 
  ProcedureReturn Result
 
EndProcedure

Procedure Son_micro()
 
  Protected Retour
 
  Bass_setDevice (gParametres\Dispositif_sonore_entree)
 
  Retour =  BASS_RecordGetDevice()
 
  If Retour = -1
    Ajouter_au_log ("Son micro : erreur dispositif sélectionné : " + BASS_ErrorGetCode(), #LOG_ERREUR)
  Else
    Ajouter_au_log ("Son micro : dispositif : " + Str (Bass_getDevice()), #LOG_NORMAL)
  EndIf
 
  ; (commented) gParametres\Channel_micro = BASS_StreamCreate(44100, 2, #BASS_SAMPLE_FLOAT|#BASS_STREAM_DECODE, #Null,#Null)
  gParametres\EntreeMicro = BASS_RecordStart (48000, 2, #BASS_RECORD_PAUSE | #BASS_SAMPLE_FLOAT, @Son_MicroCallBack(), #Null);)
   
  If gParametres\EntreeMicro = 0
    Ajouter_au_log ("Son micro : erreur recordstart : " + BASS_ErrorGetCode(), #LOG_ERREUR)
  Else
    Ajouter_au_log ("Son micro : recordstart ok", #LOG_NORMAL)
  EndIf
 
  BASS_Mixer_StreamAddChannel(gParametres\Mixer, gParametres\EntreeMicro, #Null) 
 
  BASS_ChannelPlay (gParametres\EntreeMicro, 1)
 
  Bass_setDevice (gParametres\Dispositif_sonore_sortie)
 
EndProcedure

Is there a way to send gParametres\EntreeMicro = BASS_RecordStart ( ...) to mixer ?

hub73

  • Posts: 68
it works fine with the following code. The bass library is really fantastic!  So vst, sound monitor, and  record to file !
Code: [Select]
Procedure Son_micro()
 
 BASS_RecordInit(gParametres\Dispositif_sonore_entree) 
 gParametres\EntreeMicro = BASS_RecordStart(44100, 1, #BASS_STREAM_DECODE, #Null, 0)
 BASS_Mixer_StreamAddChannel(gParametres\Mixer, gParametres\EntreeMicro, #BASS_MIXER_NORAMPIN | #BASS_STREAM_AUTOFREE)
 
EndProcedure
« Last Edit: 24 Jul '22 - 20:25 by hub73 »