Recent

Author Topic: UOS recording mono audio source  (Read 24790 times)

sporer@sctn.de

  • New Member
  • *
  • Posts: 24
UOS recording mono audio source
« on: April 08, 2016, 01:23:32 pm »
Hi everyone,
I need a bit of advice. It's about recording a mono audio source with telephone quality, i.e. the recorded file should be as small as possible.
Console application, Win XP-32, Lazarus v1.4.4, FPC 2.6.4

Here is the code sample:

Code: Pascal  [Select][+][-]
  1. i:=uos_loadlib(pchar('C:\sndlib\libPortaudio-32.dll'),
  2.                                               nil,
  3.                                               nil,
  4.                                               nil,
  5.                                               pchar('C:\sndlib\LibFaad2-32.dll'));
  6.  plidx:=0;
  7.  uos_CreatePlayer(plidx); sleep(500);
  8.  i:=uos_addIntoFile(plidx,pchar('C:\snd.wav'),8000,2,2,65536);  sleep(500);
  9.  inidx:=uos_AddFromDevIn(plidx,-1,-1,8000,2,-1,2,4096);  sleep(500);
  10.  uos_play(plidx);
  11.  sleep(10000);
  12.  uos_stop(plidx);
  13.  sleep(500);
  14.  uos_unloadlib;    

As can be seen, I reduced the sampling rate to 8000.
This gives good results with a file size of 305kbyte for a 10sec record.
But when I set the parameters to 'MONO' the recorded audio file becomes unintelligible and it's duration is only half of the recording periode.

So if anyone can direct me to the correct settings to record voice (mono) in telephone quality with minimum filesize, I would highly appreciate it.

But if it's not possible I can bear it to have the record in stereo, no problem as such.

Finally, UOS is a great peace of code, thanks to the authors.

Kind regards
Chris

Fred vS

  • Hero Member
  • *****
  • Posts: 3726
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #1 on: April 08, 2016, 01:45:07 pm »
Hello and thanks to use uos.
Code: Pascal  [Select][+][-]
  1. i:=uos_loadlib(pchar('C:\sndlib\libPortaudio-32.dll'),   nil,    nil,      nil,    pchar('C:\sndlib\LibFaad2-32.dll'));
  2.  plidx:=0;
  3.  uos_CreatePlayer(plidx);
  4. sleep(500);
  5.  i:=uos_addIntoFile(plidx,pchar('C:\snd.wav'),8000,2,2,65536);
  6.  sleep(500);
  7.  

Why do you need to load LibFaad2-32.dll library ?

Quote
But when I set the parameters to 'MONO'

Please, give us the code that you use.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

sporer@sctn.de

  • New Member
  • *
  • Posts: 24
Re: UOS recording mono audio source
« Reply #2 on: April 08, 2016, 02:03:10 pm »
Hello and thanks to use uos.
Code: Pascal  [Select][+][-]
  1. i:=uos_loadlib(pchar('C:\sndlib\libPortaudio-32.dll'),   nil,    nil,      nil,    pchar('C:\sndlib\LibFaad2-32.dll'));
  2.  plidx:=0;
  3.  uos_CreatePlayer(plidx);
  4. sleep(500);
  5.  i:=uos_addIntoFile(plidx,pchar('C:\snd.wav'),8000,2,2,65536);
  6.  sleep(500);
  7.  

Why do you need to load LibFaad2-32.dll library ?

Quote
But when I set the parameters to 'MONO'

Please, give us the code that you use.

Fre;D

Thank you for replying so fast.
Well, to tell you the truth, I don't know what the effects of the uos_loadlib parameters are.
I can load all of them, or parts of them, it still works to give me an audio output file.

Here is the code (for the function call) when I try MONO (I think it is what you mean when saying 'give us the code' ?)

Code: Pascal  [Select][+][-]
  1. i:=uos_addIntoFile(plidx,pchar('C:\snd.wav'),8000,1,2,65536);  sleep(500);
  2.  inidx:=uos_AddFromDevIn(plidx,-1,-1,8000,1,-1,2,4096);  sleep(500);

As you can see, I just changed the parameter after SAMPLING_RATE from 2 to 1 for having a MONO recording.

If you can just give me the parameter settings for recording MONO with minimum filesize, I will be happy.

Thanks in advance
Chris

Fred vS

  • Hero Member
  • *****
  • Posts: 3726
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #3 on: April 08, 2016, 02:36:15 pm »
Quote
Well, to tell you the truth, I don't know what the effects of the uos_loadlib parameters are.

uos (United Openlibs of Sound) uses open-source libraries.

Code: Pascal  [Select][+][-]
  1. function uos_loadlib(PortAudioFileName, SndFileFileName, Mpg123FileName, Mp4ffFileName, FaadFileName: PChar) : LongInt;

PortAudio -> for dealing with the sound-card.

SndFile -> for dealing with .wav, .flac, .ogg audio files.

Mpg123 -> for dealing with .mp2 and .mp3 audio files.

 Mp4ff + Faad -> for dealing with .m4a and .aac audio files.

You may load the libraries depending on what you need.

If you only want to record, PortAudio is enough.
And if you want to listen to the recorded file, you need to load SndFile too.

Quote
As you can see, I just changed the parameter after SAMPLING_RATE from 2 to 1 for having a MONO recording.
If you can just give me the parameter settings for recording MONO with minimum filesize, I will be happy.

Huh, I do not have my pc here, I will check it.

Write you later.

Fre;D
« Last Edit: April 08, 2016, 02:37:46 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

sporer@sctn.de

  • New Member
  • *
  • Posts: 24
Re: UOS recording mono audio source
« Reply #4 on: April 08, 2016, 02:42:51 pm »
All right, thank you. Understood.
I only want to record.
So I will only load PortAudio and see what happens.

Cheers
Chris

sporer@sctn.de

  • New Member
  • *
  • Posts: 24
Re: UOS recording mono audio source
« Reply #5 on: April 08, 2016, 03:29:26 pm »
Hello Fred,

I tried with a modified uos_loadlib call and parameters for MONO recording.
The recorded file is shrinking to 77kbyte for a 10sec record, but when I replay it (with VLC mediaplayer) it seems to be played with double speed (i.e. the 10sec record gives a 5sec playback).
Here is the modified source code:

Code: Pascal  [Select][+][-]
  1. i:=uos_loadlib(pchar('C:\sndlib\libPortaudio-32.dll'), nil, nil, nil, nil);
  2.  plidx:=0;
  3.  uos_CreatePlayer(plidx); sleep(500);
  4.  i:=uos_addIntoFile(plidx,pchar('C:\snd.wav'),8000,1,2,65536);  sleep(500);
  5.  inidx:=uos_AddFromDevIn(plidx,-1,-1,8000,1,-1,2,4096);  sleep(500);
  6.  uos_play(plidx);
  7.  sleep(10000);
  8.  uos_stop(plidx);
  9.  sleep(500);
  10.  uos_unloadlib;

Fred vS

  • Hero Member
  • *****
  • Posts: 3726
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #6 on: April 09, 2016, 04:45:31 am »
Hello.

When you play the record with uos (after loading SndFile lib), with same sample-rate than when recording, does it play at the right speed ?

In fact, it is not the right speed but the right sample-rate.

If the speed is double with VLC but ok with uos, it means that VLC does not use the same sample-rate that used by the record.

You should ask it why to VLC forum, maybe VLC use 16000 as sample rate instead of 8000...

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3726
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #7 on: April 09, 2016, 05:24:53 am »
Quote
When you play the record with uos (after loading SndFile lib), with same sample-rate than when recording, does it play at the right speed ?

You may use uos Simple Player example to test it,  it uses the right sample-rate.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

sporer@sctn.de

  • New Member
  • *
  • Posts: 24
Re: UOS recording mono audio source
« Reply #8 on: April 09, 2016, 11:36:12 am »
Quote
When you play the record with uos (after loading SndFile lib), with same sample-rate than when recording, does it play at the right speed ?

You may use uos Simple Player example to test it,  it uses the right sample-rate.

Fre;D

Yes I tried consoleplay. But the result is still the same.

Code: Pascal  [Select][+][-]
  1. uos_AddFromFile(PlayerIndex1,(pchar(SoundFilename)),-1,2,65536);
  2. uos_AddIntoDevOut(PlayerIndex1,-1,-1,8000,1,2,65536);



Fred vS

  • Hero Member
  • *****
  • Posts: 3726
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #9 on: April 09, 2016, 03:36:35 pm »
OK, I will (try to) find some free time this week-end and see what is wrong.

Write you later.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

sporer@sctn.de

  • New Member
  • *
  • Posts: 24
Re: UOS recording mono audio source
« Reply #10 on: April 09, 2016, 03:44:41 pm »
OK, I will (try to) find some free time this week-end and see what is wrong.

Write you later.

Fre;D

Ok, thanks.
But as I said earlier, don't worry, if it's not possible I will manage with stereo recording.

Thaddy

  • Hero Member
  • *****
  • Posts: 18529
  • Here stood a man who saw the Elbe and jumped it.
Re: UOS recording mono audio source
« Reply #11 on: April 09, 2016, 03:47:25 pm »
If you manage with stereo recordings... It just means uOS is unusable for any proper recording tasks, like a recording studio. The libraries that underly uOS definitely support mono playback and record.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

sporer@sctn.de

  • New Member
  • *
  • Posts: 24
Re: UOS recording mono audio source
« Reply #12 on: April 09, 2016, 04:12:36 pm »
If you manage with stereo recordings... It just means uOS is unusable for any proper recording tasks, like a recording studio. The libraries that underly uOS definitely support mono playback and record.

Sorry,
it's not fair what you are saying. I am only an occasional programmer and SW is only a part of the job.
I personally find UOS extremely useful, as it allows people like me for example, to quickly set up a piece of SW that records telephone conversations between a dispatcher and outstations  (the recording is only part of the job) without any specialized knowledge.
And if mono recording is not possible I will just supply a harddisk with double capacity. The difference in terms of cost is almost zero.

And apart from that, as you might have noticed in this post, the author of UOS is extremly helpful in trying to resolve this problem.

Fred vS

  • Hero Member
  • *****
  • Posts: 3726
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #13 on: April 09, 2016, 04:31:06 pm »
Quote
And if mono recording is not possible

Yes, it must be possible.
But I agree that I did not check mono-recording.

Tomorrow I will have some free-time to check-fix it.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3726
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #14 on: April 10, 2016, 02:16:36 am »
Hello.

Could you try please with last commit https://github.com/fredvs/uos and this :

 
Code: Pascal  [Select][+][-]
  1.    i:=uos_loadlib(pchar('C:\sndlib\libPortaudio-32.dll'), nil, nil, nil, nil);
  2.      plidx:=0;
  3.      uos_CreatePlayer(plidx);
  4.      i:=uos_addIntoFile(plidx,pchar('C:\snd.wav'),8000,1,2,65536);
  5.      inidx:=uos_AddFromDevIn(plidx,-1,-1,8000,-1,2,4096); // No more channel parameter
  6.      uos_play(plidx);
  7.      sleep(10000);
  8.      uos_stop(plidx);
  9.      sleep(500);
  10.      uos_unloadlib;
  11.  

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018