Record mic input to memory buffer

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

Record mic input to memory buffer

Segator
First to all thanks for the great job in the ous lib,
It's possible to save the mic input into a memory buffer with out write a file to process latter for show graphics and freq levels for example?.
Reply | Threaded
Open this post in threaded view
|

Re: Record mic input to memory buffer

fredvs
Administrator
Hello.

> It's possible to save the mic input into a memory buffer with out write a file

Yes it is possible, you may use uos_AddIntoMemoryBuffer() and then do what you want with the memory-buffer.

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

Re: Record mic input to memory buffer

fredvs
Administrator
Re-hello.

There is also uos_File2Buffer() to create a buffer from a file.

You may take a look at consoleplaymemorybuffer.lpi demo, it shows how to use uos_AddFromMemoryBuffer().

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

Re: Record mic input to memory buffer

Segator
Hola fred gracias por la respuesta, la idea es grabar la entrada del microphono en un buffer o una memoria sin escribir un archivo para luego procesar los datos con la maxima rapides posible, como dije para reconocimiento de voz o un programa de texto a voz, podrias modificar el ejemplo de simplerecorder para grabar a un buffer y no a un archivo y luego poder reproducir desde esta memoria?

El lun., 10 sept. 2018 a las 10:42, fredvs [via uos] (<[hidden email]>) escribió:
Re-hello.

There is also uos_File2Buffer() to create a buffer from a file.

You may take a look  at consoleplaymemorybuffer.lpi demo, it shows how to use uos_AddFromMemoryBuffer().

Fre;D


If you reply to this email, your message will be added to the discussion below:
http://uos.2369694.n4.nabble.com/Record-mic-input-to-memory-buffer-tp473p475.html
To unsubscribe from Record mic input to memory buffer, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Record mic input to memory buffer

fredvs
Administrator
This post was updated on .
> odrias modificar el ejemplo de simplerecorder

var
  outmemory: TDArFloat;

  ...
   
   uos_CreatePlayer(PlayerIndex1);
 
   uos_AddIntoMemoryBuffer(PlayerIndex1, outmemory);

   uos_AddFromDevIn(PlayerIndex1);
 
   uos_Play(PlayerIndex1);  

...
 
  uos_Stop(PlayerIndex1); ---> para completar la grabación.


   ==> esto creará el buffer outmemory que puedes usar más adelante con uos_AddFromMemoryBuffer().

Fre;D


Reply | Threaded
Open this post in threaded view
|

Re: Record mic input to memory buffer

fredvs
Administrator
Re-hola.

No olvides usar uos_stop(PlayerIndex1) al final de la grabación en el ejemplo anterior.

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

Re: Record mic input to memory buffer

fredvs
Administrator
Re-re-hello.

In last commit 7038e41 was added uos_CustBufferInfos() needed for AddFromMemoryBuffer() if no bufferinfos was created.

So, to audio-play the buffer you did save with uos_AddIntoMemoryBuffer(PlayerIndex1, outmemory);

---->

var
infomemory : Tuos_BufferInfos;
...

// SampleFormat and Channels must be the one used in outmemory.
 
 uos_CustBufferInfos(infomemory, 44100, SampleFormat, Channels, Length(infomemory) div Channels);

 uos_CreatePlayer(PlayerIndex1);
   
 uos_AddFromMemoryBuffer(PlayerIndex1,outmemory,infomemory, -1, 1024);

 uos_AddIntoDevOut(PlayerIndex1);

 uos_Play(PlayerIndex1);

....
Reply | Threaded
Open this post in threaded view
|

Re: Record mic input to memory buffer

Segator
Thanks Fred i try with it and comment here my progress

El lun., 10 sept. 2018 a las 15:31, fredvs [via uos] (<[hidden email]>) escribió:
Re-re-hello.

In last commit 7038e41 was added uos_CustBufferInfos() needed for AddFromMemoryBuffer() if no bufferinfos was created.

So, to audio-play the buffer you did save with uos_AddIntoMemoryBuffer(PlayerIndex1, outmemory);

---->

var
infomemory : Tuos_BufferInfos;
...

// SampleFormat and Channels must be the one used in outmemory.
 
 uos_CustBufferInfos(infomemory, 44100, SampleFormat, Channels, Length(infomemory) div Channels);

 uos_CreatePlayer(PlayerIndex1);
   
 uos_AddFromMemoryBuffer(PlayerIndex1,outmemory,infomemory, -1, 1024);

 uos_AddIntoDevOut(PlayerIndex1);

 uos_Play(PlayerIndex1);

....


If you reply to this email, your message will be added to the discussion below:
http://uos.2369694.n4.nabble.com/Record-mic-input-to-memory-buffer-tp473p479.html
To unsubscribe from Record mic input to memory buffer, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Record mic input to memory buffer

fredvs
Administrator
Re-re-Hello.

There was a bug in AddIntoMemoryBuffer() fixed in last uos commit b296550.
Sorry for this.

I have tested SimpleRecorder demo using AddIntoMemoryBuffer().

Here how to do.

Add this global variables:

var
  thebuffer : array of cfloat;
  thebufferinfos : TuosF_BufferInfos;

And at recording:

Change this:

 uos_AddIntoFile(PlayerIndex1, Pchar(filenameEdit4.filename));
 
With this:

 SetLength(thebuffer, 0);
 uos_AddIntoMemoryBuffer(PlayerIndex1, @thebuffer);

And at playing:

Change this:

 In1Index := uos_AddFromFile(PlayerIndex1, Pchar(filenameedit4.FileName));
 
with this:
 
 uos_CustBufferInfos(thebufferinfos, 44100, 2, 2 ,Length(thebuffer) div 2);
 In1Index := uos_AddFromMemoryBuffer(PlayerIndex1,thebuffer,thebufferinfos, -1, 1024*4);

Here it works.

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

Re: Record mic input to memory buffer

Segator

Hi fred, sorry for delay to response but I am make several tests with you suggestions and It work, the code save the mic in the buffer but when i play it the noise is to much, i dont not  why, here is a example projet, please test and tell me what is wrong


src.zip (366K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Record mic input to memory buffer

fredvs
Administrator
Hello Segator.

Segator wrote
please test and tell me what is wrong
Hum, indeed there was a problem with uos.
;(

Could you try with last uos-commit 1a714fd..be2c0a3 ?
It must be fixed now.

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

Re: Record mic input to memory buffer

Segator

Thanks Fred its work fine now.

off topic: I make some search to find a libportaudio for android and casually see that you find for that, so me question is in what point is the the libportaudio and ous android support?

El sep 12, 2018 2:28 AM, "fredvs [via uos]" <[hidden email]> escribió:
Hello Segator.

Segator wrote
please test and tell me what is wrong
Hum, indeed there was a problem with uos.
;(

Could you try with last uos-commit 1a714fd..be2c0a3 ?
It must be fixed now.

Fre;D


If you reply to this email, your message will be added to the discussion below:
http://uos.2369694.n4.nabble.com/Record-mic-input-to-memory-buffer-tp473p487.html
To unsubscribe from Record mic input to memory buffer, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Record mic input to memory buffer

fredvs
Administrator
Segator wrote
Thanks Fred its work fine now.
Nice !

In last commit was added uos_AddIntoMemoryBuffer() with extended parameters.

If you have problems of sound-quality/latency, you may try to use uos_AddIntoMemoryBuffer() with extended parameters.

And mainly adapt the "FramesCount" parameter.

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

Re: Record mic input to memory buffer

fredvs
Administrator
In reply to this post by Segator
Segator wrote
off topic: I make some search to find a libportaudio for android and casually see that you find for that, so me question is in what point is the the libportaudio and ous android support?
https://github.com/Gundersanne/portaudio_opensles

I did some test but without luck.

If you have more success, please share it.

Fre;D