Simple Recorder format settings?

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

Simple Recorder format settings?

MrJohn
Good evening.... I am new to UOS and have been trying to make a sound recorder,  I want long duration records of a AM radio channel.  I would really like records to be 24 hours, or as long as I can make them and the channel to be recorded is quite low fidelity.

I am using SimpleRecorder  unit main_sr which is headed 'Demo how to use United Openlib of Sound'. There is this line around about line 290 in the file.  

   uos_AddIntoFile(PlayerIndex1, PChar(edit3.Text), -1, -1, -1, 4096, outformat);

By following the remarks in the file I have been able to change to mono  (which is what I want) but I cannot change sample rate or sample format.

I would like to have  11025 sample rate, mono channel, 16bit.  I think this format would allow me to record 24 hours into a 2Gb file.

Can you please tell me how to set these parameters and please confirm this part of the code is the place to do it?

Thank you
John Hill
New Zealand

     
Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

fredvs
Administrator
This post was updated on .
Hello John and welcome to uos forum.

> I would like to have  11025 sample rate, mono channel, 16bit.

To record into wav file:

uos_AddIntoFile(PlayerIndex1, PChar(edit3.Text), 11025, 1, -1, 4096, 0);
...
 In1Index := uos_AddFromDevIn(PlayerIndex1,-1,-1,11025 ,-1,-1,-1,-1);

   
I suppose you dont want to ear the result while recording, so simply comment lines with uos_AddIntoDevOut:

 {$if defined(cpuarm) or defined(cpuaarch64)}  // need a lower latency
 //   out1index := uos_AddIntoDevOut(PlayerIndex1, -1, 0.08, -1, -1, -1, -1) ;
       {$else}
  //  out1index := uos_AddIntoDevOut(PlayerIndex1);
       {$endif}    


If you want to record into ogg file ( + - 10 times less size than wav format ):
(Note that recording into ogg needs to set input as stereo and also that reducing the samplerate dont affect a lot the resulted size of the record.)

 uos_AddIntoFile(PlayerIndex1, PChar(edit3.Text), 11025, -1, -1, 4096, 3); // note that channels must be stereo (-1)
...  
In1Index := uos_AddFromDevIn(PlayerIndex1,-1,-1,11025,-1,-1,-1,-1);


The same as wav, if you dont want to ear the result while recording, comment lines with uos_AddIntoDevOut.

Hope it helps.

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

Re: Simple Recorder format settings?

MrJohn

Greetings Fred
Thank you for the very prompt response to my query and I must report the changes you suggested work very well.

I will use .WAV file.   Please tell me what changes I need to hear the recording in progress?

Thanks
John
Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

fredvs
Administrator
Hello.

> I will use .WAV file.   Please tell me what changes I need to hear the recording in progress?

If you take the code from previous post for input then un-comment lines with uos_AddIntoDevOut.

This should enable direct-wiring (listen while recording):

    {$if defined(cpuarm) or defined(cpuaarch64)}  // need a lower latency
    out1index := uos_AddIntoDevOut(PlayerIndex1, -1, 0.08, 11025, -1, -1, -1) ;
       {$else}
    out1index := uos_AddIntoDevOut(PlayerIndex1, -1, -1, 11025, -1, -1, -1, -1) ; // change this
      {$endif}  

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

Re: Simple Recorder format settings?

MrJohn
I tried that but the headphone audio is 'chopped up' at about 3 times per second.

John
Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

fredvs
Administrator
This post was updated on .
Hello.
*
What kind of audio card do you have?

What OS?

What widgetset (console, Lazarus-LCL, msegui or fpgui) ?

Can you ear recording with the original "SimpleRecorder" demo?

You may try with a lower latency, something like this:

out1index := uos_AddIntoDevOut(PlayerIndex1, -1, 0.3, 11025, -1, -1, -1, -1) ; // change this 
Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

MrJohn
Thanks,  I tried this:-

 out1index := uos_AddIntoDevOut(PlayerIndex1, -1, 0.8, 11025, -1, -1, -1, -1) ;  

latency increased to 0.8......and this works.  Thanks for your help.
John
Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

MrJohn
Hi..

My project is coming along quite well but I have a problem with sound quality..

The project is based on the UOS  Simple Recorder,  

Sound system is  Stereo Mix..  Realtek High Definition Audio

PC
Device name ASUS-3-in-1
Processor Intel(R) Core(TM) i5-2400S CPU @ 2.50GHz   2.50 GHz
Installed RAM 8.00 GB
Device ID 70DF6127-EFF0-486A-96DD-B27305A2B02D
Product ID 00330-80000-00000-AA749
System type 64-bit operating system, x64-based processor

Operating System
Edition Windows 10 Pro
Version 21H1
Installed on ‎22-‎Sep-‎20
OS build 19043.1052


Lazarus IDE.

I am recording single channel at 11025.


My problem is that the sound appears to have a high frequency distortion that almost sounds like static.  Adjusting the treble control on playback (Audacity) reduces but does not eliminate the problem.

I can hear the distortion on the phones when recording and on playback.

I am using sound from a small CD player for testing.


Please suggest whatever I can do to address this problem.

Brgds
John


Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

fredvs
Administrator
Hello.

It is extremely difficult to diagnose something without any code.
Could you give in attachment a example of the wav file with problems + the code used to produce that wav?

Did you try to save as ogg, do you get the same problems?

Thanks.

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

Re: Simple Recorder format settings?

fredvs
Administrator
Re-hello.

If high quality and low size of recorded file are important, why not use a higher sample-rate and save it as ogg ?

Recording into ogg 44100 HZ, Stereo will have < size than recording into wav, 11025 Hz, Mono.
Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

MrJohn
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

MrJohn
This post was updated on .
Today has been an exercise in frustration and I must admit I have been unable to make any progress whatsoever.

I have a new installation of lazarus-2.0.12-fpc-3.2.0-win64  and file  uoslib-master.zip.

I know I can install a UOS package from within the Lazarus IDE.  

As a first effort should I try the UOS package in the IDE or use the zip file?

Thank you for any advice.

John
Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

fredvs
Administrator
Hello.

There are 2 different projects: uos and uoslib.
For Pascal users, please use preferably uos, uoslib is the library version of uos (uos access directly the audio libraries).
uoslib is a native library that can be used for C, Java, Python, etc.
But there are less methods than the "pure" uos framework.

So, please go on this site:
https://github.com/fredvs/uos

And click on the green button [Code] and "Download zip".
I am not sure that OPM has the last release of uos.

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

Re: Simple Recorder format settings?

fredvs
Administrator
This post was updated on .
Follow of previous post...

When you have downloaded the zip file from https://github.com/fredvs/uos, unzip it somewhere.

Then, run Lazarus- "Open Project" and choose "simplerecorder.lpi" demo that is in /uos/examples/.
Compile and run the project.

[EDIT] Dont use the debugger to run the application, debugger dont work ok for audio-things because debugging will have a impact on latency, so on Lazarus, click on "Execute without debug".

Then test the recording, saving as wav or ogg.

And tell me if there are problems to listen the ogg file (here it works perfectly with Audacity too).

If all is working ok with the uos-demo "simplerecorder", then we can do steps further.

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

Re: Simple Recorder format settings?

fredvs
Administrator
Hello.

I just have try the simplerecorder demo on Windows 10.

Indeed there is problem with the saved record into ogg file.
The file is corrupted.

I am very sorry for this, I dont use Windows any more.
I am super buzy now but asap (if I find a Windows machine) I will jump into it to see what is wrong.

I apologize for the inconvenience.

Fre;D



Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

fredvs
Administrator
Re-hello.

It seems to be a problem in libsndfile ogg encoder for Windows.

I opened a issues on their Github site:

https://github.com/libsndfile/libsndfile/issues/761

I hope to have news soon.

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

Re: Simple Recorder format settings?

fredvs
Administrator
Hello.

In last commit of uos, fixed uos_AddIntoFile() in ogg format under Windows.
You will need to re-download the uos-project.

And maybe test the simplerecorder demo.

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

Re: Simple Recorder format settings?

MrJohn
 Thank you

I have easily made download and a test of simple recorder,  .wav appears good but only tested at default parameters.

Now I am busy but I will download and test ogg soon.

P.S.  I think you are working late?  It is sunny winter morning here in New Zealand.
Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

fredvs
Administrator
Hello.

Yes, I am a night bird ;)

And almost on the opposite side of NZ (Europe).
Here it is a hot summer moon night.

Fre;D

Reply | Threaded
Open this post in threaded view
|

Re: Simple Recorder format settings?

MrJohn
Hello...

The ogg test went poorly with a lot of noise .

I trust this link will work  https://1drv.ms/u/s!ArKD4sEFwF_83w_IXNw27jYKF6jb?e=jUvm9I

John
12