Recent

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

sporer@sctn.de

  • New Member
  • *
  • Posts: 24
Re: UOS recording mono audio source
« Reply #15 on: April 10, 2016, 11:46:27 am »
Hello,

yes it works, thank you.
The recorded file is now 150kByte instead of 300kByte(stereo).

But something is still missing, the audio quality is not the same as compared to recording the mono-source in stereo mode.

I made a comparison like this:

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,2,4096);  sleep(500);
for mono recording and
Code: Pascal  [Select][+][-]
  1. i:=uos_addIntoFile(plidx,pchar('C:\snd.wav'),8000,2,2,65536);  sleep(500);
  2.  inidx:=uos_AddFromDevIn(plidx,-1,-1,8000,-1,2,4096);  sleep(500);  
for stereo.

I have sent the two sample files to your hotmail.
Maybe you can compare it yourself. The audio source is definitely mono.

Regards

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: UOS recording mono audio source
« Reply #16 on: April 10, 2016, 12:22:46 pm »
If the mono source is mixed down to stereo (to have both left and right on your speakers or headphones) the most likely cause is phase inverted. i.e: left and right channel inverted. But this should be easily tested if you pan both left and right channel dead center it really should give the mono sound instead of hard left and hard right. If that's the case there is still something wrong with UOS. It should not happen.
Specialize a type, not a var.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #17 on: April 10, 2016, 12:43:50 pm »
Quote
But something is still missing, the audio quality is not the same as compared to recording the mono-source in stereo mode.

Indeed  :-[

It comes from  the conversion Stereo to Mono.
PortAudio deals with devices.
Input devices may have multi channels input.
In most of the case, the input of sound-cards has  2 channels (stereo).

If you want to record the stereo input to mono, the common way is to -> (chan1 + chan2) / 2 and set the wav-header to 1 channel..
It is what uos does.

I will check why the quality is worst in mono.

Write you later.
 
Fre;D

[EDIT] ->
Quote
as compared to recording the mono-source in stereo mode.

Huh, do you use a pc-sound card for recording ?
If yes, I think that you record a stereo-source and want to save it in mono mode.
« Last Edit: April 10, 2016, 01:09:57 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 #18 on: April 10, 2016, 07:06:06 pm »
Huh, do you use a pc-sound card for recording ?
If yes, I think that you record a stereo-source and want to save it in mono mode.
-------------------------------------------------------------------------------------------------------
Yes this is definitly the case. It's a SoundMax Audio Device and the input is configured as Line-In which is stereo, I suppose.
Don't bother any longer, I will use stereo mode.

Thank you for your efforts

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #19 on: April 10, 2016, 11:05:14 pm »
Quote
Thank you for your efforts
It was with pleasure.  ;)

Quote
Don't bother any longer, I will use stereo mode.
OK, but I still did not find why function cvStereoToMono() change the quality of sound. ...   :-[

[EDIT] In last version of uos, you may record and save in 32 bit format.
With 32 bit format, the quality of sound is the same for saving in mono or stereo.
So the problem is only with saving in 16 bit mono.
There is something strange (like loosing resolution) when saving wav file into 16 bit mono.
I do not understand why.

Cheers.

Fre;D
« Last Edit: April 15, 2016, 01:56:29 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

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: UOS recording mono audio source
« Reply #20 on: April 11, 2016, 06:37:58 am »
hello,
sporer@sctn.de , if you don't use the recorded files in realtime, maybe to save space, you can use a batch converter to compress audio files using for example audacity or sox and for audio compressed format  : aac, mp3,ogg, adpcm .
for example  -> mp3 voice  8k  16 bits stéréo    10 seconds ---> size 20kb     at  rate 16kb/s

Friendly, J.P

Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

sporer@sctn.de

  • New Member
  • *
  • Posts: 24
Re: UOS recording mono audio source
« Reply #21 on: April 11, 2016, 10:23:45 am »
hello,
sporer@sctn.de , if you don't use the recorded files in realtime, maybe to save space, you can use a batch converter to compress audio files using for example audacity or sox and for audio compressed format  : aac, mp3,ogg, adpcm .
for example  -> mp3 voice  8k  16 bits stéréo    10 seconds ---> size 20kb     at  rate 16kb/s

Friendly, J.P

This is definitly an interesting option. Thank you for that.
I will try it, once the main recording task is completed.

Regards C

sporer@sctn.de

  • New Member
  • *
  • Posts: 24
Re: UOS recording mono audio source
« Reply #22 on: April 16, 2016, 04:10:55 pm »
hello,
sporer@sctn.de , if you don't use the recorded files in realtime, maybe to save space, you can use a batch converter to compress audio files using for example audacity or sox and for audio compressed format  : aac, mp3,ogg, adpcm .
for example  -> mp3 voice  8k  16 bits stéréo    10 seconds ---> size 20kb     at  rate 16kb/s

Friendly, J.P

hello,
sox was definitely the best solution.
I have now UOS in the main executable to record the audio (in stereo) and a batch process on the localhost that triggers SOX to compress the recorded WAV file, once the recording is completed. The reduction in file size is considerable.
Thank you again for this valuable hint!

Kindly CS

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #23 on: April 17, 2016, 03:42:58 pm »
Quote
and a batch process on the localhost that triggers SOX to compress the recorded WAV file,

There is a mp3, ogg and acc incoder in the uos todo-list.
It is already working but I have to check everything before to commit 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

M.A.R.C.

  • Jr. Member
  • **
  • Posts: 68
Re: UOS recording mono audio source
« Reply #24 on: April 18, 2016, 05:47:28 pm »
Hi All, I have the same problem: I'm trying to record from USB Microphone audio devices (mono source).

I test two sources at the same time, mono and stereo. I'm using the library from the trunk.

The output from the stereo source is ok.
The output from the mono source is more faster (twice) and half length (in time), but the basic frequencies (tune) are ok (as when a speed filter is applied).

Also using the simplerecorder demo.

@Fred I have some changes for uos.pas, there are, for example, some problems if you edit the define.inc and exclude bs2b and noiseremoval. I added some compiler directives ($IF DEF). For example:

Code: Pascal  [Select][+][-]
  1. destructor Tuos_DSP.Destroy;
  2. begin
  3.   if assigned(fftdata) then
  4.   begin
  5.     {$IF DEFINED(noiseremoval)}  
  6.     if assigned(fftdata.FNoise) then FreeAndNil(fftdata.FNoise);
  7.     {$endif}
  8.     FreeandNil(fftdata);
  9.   end;
  10. end;
  11.  

Also:
Code: Pascal  [Select][+][-]
  1. - for x2 := 0 to StreamIn[x].Data.WantFrames do
  2. + for x2 := 0 to StreamIn[x].Data.WantFrames-1 do
  3.  
Thanks for your great work.

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #25 on: April 21, 2016, 02:58:35 pm »
Hello and sorry for late answer.

Quote
The output from the mono source is more faster (twice) and half length (in time), but the basic frequencies (tune) are ok (as when a speed filter is applied).

Did you record in 16 or 32 bit ?
Could you give the code you use for recording/playing ?
There is ,indeed, problem with recording in mono 16 bit. (till now,I do not understand why)
But recording in mono 32 bit should work.

[EDIT] Are you really sure that your input device is mono (1 channel) ?
If you run "DeviceInfo" uos-example, how many max-channels for the input device do you get ?

Quote
@Fred I have some changes for uos.pas,
Many thanks, I will check it and apply change.

Fre;D
« Last Edit: April 21, 2016, 03:40:09 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

M.A.R.C.

  • Jr. Member
  • **
  • Posts: 68
Re: UOS recording mono audio source
« Reply #26 on: April 23, 2016, 03:28:24 am »
Hi Fred,

Microphone (USB Audio Device)
Type: In
ChanIn: 1
ChanOut: 0
Samplerate: 44100
LatencyHigh: 0.1800
LatencyLow: 0.0900
HostAPI: MME

Using the default Windows Driver: USB Audio Device

The device is similar to this http://www.dx.com/p/usb-3d-sound-adapter-color-assorted-5831

Recording in 16 or 32 bits, only portaudio and sndfile enabled.
The same error with the github simplerecorder updated demo

Code: Pascal  [Select][+][-]
  1.  
  2. In1Index := TmpPlayer.AddFromDevIn(-1,-1,44100,-1,
  3.             1, //(0: Float32, 1:Int32, 2:Int16)
  4.            -1);
  5.  

If I active audio monitor:
Code: Pascal  [Select][+][-]
  1.   Out1Index := TmpPlayer.AddIntoDevOut(-1,-1,
  2.                TmpPlayer.StreamIn[In1Index].Data.SampleRate,
  3.                TmpPlayer.StreamIn[In1Index].Data.Channels,
  4.                TmpPlayer.StreamIn[In1Index].Data.SampleFormat,-1);
  5.  

I can hear the problem in real time.

If I use BASS library the generated wav is ok.

Regards.
« Last Edit: April 23, 2016, 03:30:51 am by mrisco »

Fred vS

  • Hero Member
  • *****
  • Posts: 3158
    • StrumPract is the musicians best friend
Re: UOS recording mono audio source
« Reply #27 on: April 24, 2016, 02:19:25 pm »
Quote
Microphone (USB Audio Device)
Type: In
ChanIn: 1
ChanOut: 0

OK, I will check that ASAP.

Thanks to note it.

[EDIT] Could you, please,  post in attachment samples of the mono-recording. (one recorded in mono and one in stereo).
This because I do not have mono-device to test. (but I may detect the problem with the sample)

Fre;D
« Last Edit: April 24, 2016, 02:29:22 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

M.A.R.C.

  • Jr. Member
  • **
  • Posts: 68
Re: UOS recording mono audio source
« Reply #28 on: April 25, 2016, 04:46:14 am »
Hi Fred, here are the attachment samples:
Track0 - Microphone USB Audio Device
Track1 - Microphone High Definition Audio Device

Both taken at the same time, same duration. Microphone High Definition Audio Device originally is a two channels device (Mainboard integrated audio).

Regards,

MRisco.

M.A.R.C.

  • Jr. Member
  • **
  • Posts: 68
Re: UOS recording mono audio source
« Reply #29 on: April 25, 2016, 05:21:01 am »
I just load the samples into Audacity, and when I zoom in I can see each "N" samples as an interruption in the buffer. Maybe only a half of the buffer is stored in the audio stream.

FramesCount was setup in 2048.
Discontinuity about 0.023s
1024/44100 = 0.0233
Then N ~ 1024

I hope these numbers means something.

Regards-




 

TinyPortal © 2005-2018