Setting output volume while recording

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting output volume while recording

msavigo1
Hello,

thanks a lot for this great tools.

I'm trying to record an Internet stream in background.
If I try to reduce the output volume it comes to an error:
In Datei 'UOS/uos.pas' in Zeile 3965:
StreamOut[OutputIndex].DSP[DSPVolIndex].Enabled := Enable;


Hera is an example:

procedure TForm1.btStartClick(Sender: TObject);
var
  URL: string;
  AppDir: string;
  Filename: string;
  Mpg123Path: string;
  PortAudioPath: string;
begin
  URL := 'http://stream-uk1.radioparadise.com/mp3-128';
  Filename := AppDir + PathDelim + 'Recording.wav';

  {$IFDEF Windows}
    {$if defined(cpu64)}
      PortAudioPath := application.Location + 'lib\Windows\64bit\LibPortaudio-64.dll';
      Mpg123Path := application.Location + 'lib\Windows\64bit\LibMpg123-64.dll';
    {$else}
      PortAudioPath := application.Location + 'lib\Windows\32bit\LibPortaudio-32.dll';
      Mpg123Path := application.Location + 'lib\Windows\32bit\LibMpg123-32.dll';
    {$endif}
  {$ENDIF}

  {$if defined(cpu64) and defined(linux) }
    PortAudioPath := application.Location + 'lib/Linux/64bit/LibPortaudio-64.so';
    Mpg123Path := application.Location + 'lib/Linux/64bit/LibMpg123-64.so';
  {$ENDIF}
  {$if defined(cpu86) and defined(linux)}
    PortAudioPath := application.Location + 'lib/Linux/32bit/LibPortaudio-32.so';
    Mpg123Path := application.Location + 'lib/Linux/32bit/LibMpg123-32.so';
  {$ENDIF}


  uos_LoadLib(PChar(PortAudioPath), nil, PChar(Mpg123Path), nil, nil, nil);

  PlayerIndex := 0;
  uos_CreatePlayer(PlayerIndex);
  InputIndex := uos_AddFromURL(PlayerIndex, PChar(URL), -1, -1, -1, -1, True);
  OutputIndex := uos_AddIntoDevOut(PlayerIndex);

  uos_OutputAddDSPVolume(PlayerIndex, OutputIndex, 1, 1);
  uos_OutputSetDSPVolume(PlayerIndex, OutputIndex, 1, 1, True); // **** The error appears here *****

  uos_AddIntoFile(PlayerIndex, PChar(Filename));

  uos_Play(PlayerIndex);
end;

Any ideas what to do?

Reply | Threaded
Open this post in threaded view
|

Re: Setting output volume while recording

fredvs
Administrator
Hello.

Did you try/check SimpleRecorder.lpi demo ?

Otherwise there is code that you want in  StrumPract project:
https://github.com/fredvs/strumpract

(binary :https://github.com/fredvs/strumpract/releases)


> uos_OutputAddDSPVolume(PlayerIndex, OutputIndex, 1, 1);
> uos_OutputSetDSPVolume(PlayerIndex, OutputIndex, 1, 1, True); // **** The error appears here *****

If you want to control the volume of a input (here url-stream) please use uos_Inputxxxx

In your example, change with this:

 uos_InputSetLevelEnable(PlayerIndex, InputIndex, 2); // Important otherwise no result

 uos_InputAddDSPVolume(PlayerIndex, InputIndex, 1, 1);
 
 uos_InputSetDSPVolume(PlayerIndex, InputIndex, 1,1, True);

Fre;D





Reply | Threaded
Open this post in threaded view
|

Re: Setting output volume while recording

msavigo1
If I'm using uos_Inputxxxx to reduce the output volume, then I'm reducing the record level as well.

uos_InputSetDSPVolume(PlayerIndex, InputIndex, 0, 0, True);

Would produce an empty file. I have tried that in the beginning.
Reply | Threaded
Open this post in threaded view
|

Re: Setting output volume while recording

fredvs
Administrator
> uos_OutputSetDSPVolume(PlayerIndex, OutputIndex, 1, 1, True); // **** The error appears here *****

Ooops, indeed, there was a bug, I apologize.  ;-(

Could you please try with last uos commits? : e0cb494..9355be6.
https://github.com/fredvs/uos/

> Would produce an empty file. I have tried that in the beginning.

Could you explain more what you want to archive ?

Fre;D




Reply | Threaded
Open this post in threaded view
|

Re: Setting output volume while recording

fredvs
Administrator
In reply to this post by msavigo1
> If I'm using uos_Inputxxxx to reduce the output volume, then I'm reducing the record level as well.

Sorry, I do not understand.

Do you mean that if you have 2 input (the URL stream + the mic), if you reduce the volume of the input-URL, it reduce the volume of the input-mic as well ?

If so, it should not, only the volume of the URL should change, not the volume of mic .

To reduce the volume of Input-URL + input-MIC, you should use, like you proposed uos_Outputxxx:

But maybe I miss something.

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: Setting output volume while recording

msavigo1
I have only a URL stream as input.

With your latest commit I'm able to reduce or mute the output of the URL stream while recording it.

Thanks a lot ;-))