Comments (10)
Hello.
What do you want to do ?
Wav-file needs a special wav header at begin of file, with some infos like resolution, sample-rate, duration,...
Fre;D
from uos.
I want to save input in wave file for a long time. In example SimpleRecorder input stream writes to memory and after stop saves to file. So, recording of one hour uses lots of memory. I want to write buffer to wave file directly.
Wave header is not problem :)
from uos.
Hello.
When recording, the buffer is saved in a temporally file.
Recording hours uses a big temporally file but not lot of RAM.
from uos.
Hi, please check my code:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
uos_flat, LazUTF8;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
ComboBox1: TComboBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
s1,s2 : string;
PlayerIndex1: cardinal;
In1Index : integer;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var x:integer;
begin
{$IFDEF Windows}
{$if defined(cpu64)}
s1 := application.Location + 'lib\Windows\64bit\LibPortaudio-64.dll';
s2 := application.Location + 'lib\Windows\64bit\LibSndFile-64.dll';
{$else}
s1 := application.Location + 'lib\Windows\32bit\LibPortaudio-32.dll';
s2 := application.Location + 'lib\Windows\32bit\LibSndFile-32.dll';
{$endif}
{$ENDIF}
x:=0;
uos_LoadLib(Pchar(s1), pchar(s2), nil, nil, nil);
uos_GetInfoDevice();
while x < UOSDeviceCount do
begin
if (uosDeviceInfos[x].ChannelsIn > 0) and (uosDeviceInfos[x].HostAPIName = 'MME') then
ComboBox1.Items.Add(IntToStr(uosDeviceInfos[x].DeviceNum)+ '-'+ SysToUTF8(uosDeviceInfos[x].DeviceName));
inc(X);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
PlayerIndex1 := 0;
uos_CreatePlayer(PlayerIndex1);
uos_addIntoFile(PlayerIndex1, Pchar('d:\temp\test.wav') ,44100,2,2,-1 );
In1Index := uos_AddFromDevIn(PlayerIndex1, 2, -1, -1, -1,-1, 4096);
uos_Play(PlayerIndex1);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
uos_Stop(PlayerIndex1);
end;
end.
This is RAM usage after 12 min of recording :
This is RAM usage after stop button click :
from uos.
Indeed, lot of ram are used.
Does the ram used increase with time or is it stable to 1,2 gigas ?
What if you use cmem (memory manager) instead ?
`unit Unit1;
{$mode objfpc}{$H+}
interface
uses
cmem, // C memory manager
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
uos_flat, LazUTF8;`
from uos.
Used ram increases with time when recording in on.
from uos.
cmem must be the first unit of the main code (program).
Tested SimpleRecorder on Windows 10 with cmem and no problem here.
Used ram increases with time when recording in on.
It is normal that recording uses lot of ram.
For latency it will try to use the most ram possible to access less time the disk.
The question was, is all the ram is used, does it still does recording ?
Fre;D
from uos.
Hi, after one hour of recording (with cmem and without) programm crashes.
Error string is :
StreamOut[x].Data.Buffer[0], StreamIn[x2].Data.outframes * StreamIn[x2].Data.Channels * rat);
from uos.
Hello.
Could you try with last commit da316a2..5f11b62 ?
Thanks.
from uos.
Hello.
Thanks to Phoenix fixed bug in uos_AddIntoFile() --> for recording using TFileStream.
--> max length = Available free-space-disk.
Added also uos_AddIntoFileFromMem() --> --> for recording using TMemoryStream.
--> max length = Available RAM (but it could have a better latency).
All this in last commit: de823d5..af9530b.
Fre;D
from uos.
Related Issues (20)
- uos does synthesizer !
- Failed to use within Delphi as description mentioned Delphi HOT 2
- Russian Device Names HOT 7
- Device Enumeration HOT 10
- uos has his forum ;-) HOT 2
- problem on threaded uos_File2Buffer HOT 5
- Check Range error HOT 2
- uos_EndProc not working on linux 64-bit xfce using uos v2.0.1 ? HOT 1
- Highpass filter not working HOT 4
- mpg123 - wrong declaration of records HOT 5
- mpg123 - missing function mpg123_meta_free HOT 14
- Missing Identifiers HOT 1
- Problem with multi audio cards and PortAudio+PulseAudio HOT 1
- Zip File Corrupted HOT 1
- No external libraries HOT 9
- Debug output HOT 38
- Distorted (ogg file) audio output HOT 2
- DELPHI? HOT 1
- Compilation fails in DEBUG mode HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uos.