procedure TForm1.Button2Click(Sender: TObject);
var
outformatst : string;
outformat :integer;
begin
if (checkbox1.Checked = True) or (checkbox2.Checked = True) then
begin
PlayerIndex1 := 0;
// PlayerIndex : from 0 to what your computer can do ! (depends of ram, cpu, ...)
// If PlayerIndex exists already, it will be overwritten...
uos_CreatePlayer(PlayerIndex1);
//// Create the player.
//// PlayerIndex : from 0 to what your computer can do !
//// If PlayerIndex exists already, it will be overwriten...
uos_AddIntoFileFromMem(PlayerIndex1, Pchar(edit3.Text));
//// add Output into wav file (save record) from TMemoryStream with default parameters
if bwav.checked then
begin
outformatst := '.wav';
outformat := 0;
end else
begin
outformatst := '.ogg';
outformat := 3;
end;
edit3.Text := 'rec_' + UTF8Decode(formatdatetime('YY_MM_DD_HH_mm_ss', now)) + outformatst ;
// saving in a file using a File-Stream:
uos_AddIntoFile(PlayerIndex1, PChar(edit3.Text), -1, -1, -1, 4096, outformat);
// function uos_AddIntoFile(PlayerIndex: cint32; Filename: PChar; SampleRate: cint32;
// Channels: cint32; SampleFormat: cint32 ; FramesCount: cint32 ; FileFormat: cint32): cint32;
// Add a Output into audio wav file with custom parameters from TFileStream
// PlayerIndex : Index of a existing Player
// FileName : filename of saved audio wav file
// SampleRate : delault : -1 (44100)
// Channels : delault : -1 (2:stereo) (1:mono, 2:stereo, ...)
// SampleFormat : default : -1 (2:Int16) (1:Int32, 2:Int16)
// FramesCount : default : -1 (= 65536)
// FileFormat : default : -1 (wav) (0:wav, 1:pcm, 2:custom, 3:ogg);
//// add Output into wav or ogg file (save record) from TFileStream
// saving in a Memory-Buffer:
SetLength(thebuffer, 0);
uos_AddIntoMemoryBuffer(PlayerIndex1, @thebuffer, -1, 0, -1, -1); // save to buffer
// uos_AddIntoMemoryBuffer(PlayerIndex1, @thebuffer);
// saving in a Memory-Stream:
// if thememorystream = nil then thememorystream := tmemorystream.create;
// uos_AddIntoMemoryStream(PlayerIndex1, (thememorystream),-1,-1,-1,-1);
// saving in a file using a Menory-Stream:
// uos_AddIntoFileFromMem(PlayerIndex1, Pchar(filenameEdit4.filename));
//// add Output into wav file (save record) with default parameters
{$if defined(cpuarm) or defined(cpuaarch64)} // need a lower latency
out1index := uos_AddIntoDevOut(PlayerIndex1, -1, 0.8, -1, -1, -1, -1) ;
{$else}
out1index := uos_AddIntoDevOut(PlayerIndex1);
{$endif}
uos_outputsetenable(PlayerIndex1, out1index, checkbox1.Checked);
// uos_AddIntoDevOut(PlayerIndex1, -1, -1, 8000, -1, -1,65536, -1); //// add a Output into device with custom parameters
//////////// PlayerIndex : Index of a existing Player
//////////// Device ( -1 is default Output device )
//////////// Latency ( -1 is latency suggested ) )
//////////// SampleRate : delault : -1 (44100)
//////////// Channels : delault : -1 (2:stereo) (0: no channels, 1:mono, 2:stereo, ...)
//////////// SampleFormat : -1 default : Int16 : (0: Float32, 1:Int32, 2:Int16)
//////////// FramesCount : -1 default : 65536
// ChunkCount : default : -1 (= 512)
In1Index := uos_AddFromDevIn(PlayerIndex1);
//// add input from mic with custom parameters
//////////// PlayerIndex : Index of a existing Player
//////////// Device ( -1 is default Input device )
//////////// Latency ( -1 is latency suggested ) )
//////////// SampleRate : delault : -1 (44100)
//////////// OutputIndex : OutputIndex of existing Output // -1 : all output, -2: no output, other integer : existing output)
//////////// SampleFormat : -1 default : Int16 : (0: Float32, 1:Int32, 2:Int16)
//////////// FramesCount : -1 default : 4096 ( > = safer, < = better latency )
uos_InputAddDSPVolume(PlayerIndex1, In1Index, 1, 1);
///// DSP Volume changer
//////////// PlayerIndex : Index of a existing Player
////////// In1Index : InputIndex of a existing input
////////// VolLeft : Left volume
////////// VolRight : Right volume
uos_InputSetDSPVolume(PlayerIndex1, In1Index, TrackBar1.position / 100,
TrackBar3.position / 100, True); /// Set volume
/////// procedure to execute when stream is terminated
// uos_EndProc(PlayerIndex1, @ClosePlayer1);
///// Assign the procedure of object to execute at end
//////////// PlayerIndex : Index of a existing Player
//////////// ClosePlayer1 : procedure of object to execute inside the loop
uos_Play(PlayerIndex1); /////// everything is ready to play...
Button2.Enabled := False;
Button3.Enabled := True;
Button4.Enabled := False;
//CheckBox1.Enabled := False;
CheckBox2.Enabled := False;
end;
end;