aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/base/UMusic.pas18
-rw-r--r--src/base/URecord.pas18
-rw-r--r--src/base/URingBuffer.pas24
3 files changed, 36 insertions, 24 deletions
diff --git a/src/base/UMusic.pas b/src/base/UMusic.pas
index 792d5e3f..10f789d7 100644
--- a/src/base/UMusic.pas
+++ b/src/base/UMusic.pas
@@ -35,6 +35,7 @@ interface
uses
UTime,
+ SysUtils,
Classes;
type
@@ -212,12 +213,12 @@ type
TSoundEffect = class
public
EngineData: Pointer; // can be used for engine-specific data
- procedure Callback(Buffer: PChar; BufSize: integer); virtual; abstract;
+ procedure Callback(Buffer: PByteArray; BufSize: integer); virtual; abstract;
end;
TVoiceRemoval = class(TSoundEffect)
public
- procedure Callback(Buffer: PChar; BufSize: integer); override;
+ procedure Callback(Buffer: PByteArray; BufSize: integer); override;
end;
type
@@ -262,7 +263,7 @@ type
function IsEOF(): boolean; virtual; abstract;
function IsError(): boolean; virtual; abstract;
public
- function ReadData(Buffer: PChar; BufferSize: integer): integer; virtual; abstract;
+ function ReadData(Buffer: PByteArray; BufferSize: integer): integer; virtual; abstract;
property EOF: boolean read IsEOF;
property Error: boolean read IsError;
@@ -292,7 +293,7 @@ type
function GetVolume(): single; virtual; abstract;
procedure SetVolume(Volume: single); virtual; abstract;
function Synchronize(BufferSize: integer; FormatInfo: TAudioFormatInfo): integer;
- procedure FillBufferWithFrame(Buffer: PChar; BufferSize: integer; Frame: PChar; FrameSize: integer);
+ procedure FillBufferWithFrame(Buffer: PByteArray; BufferSize: integer; Frame: PByteArray; FrameSize: integer);
public
(**
* Opens a SourceStream for playback.
@@ -335,7 +336,7 @@ type
function Open(ChannelMap: integer; FormatInfo: TAudioFormatInfo): boolean; virtual;
procedure Close(); override;
- procedure WriteData(Buffer: PChar; BufferSize: integer); virtual; abstract;
+ procedure WriteData(Buffer: PByteArray; BufferSize: integer); virtual; abstract;
function GetAudioFormatInfo(): TAudioFormatInfo; override;
function GetLength(): real; override;
@@ -468,7 +469,7 @@ type
* input-buffer bytes used.
* Returns the number of bytes written to the output-buffer or -1 if an error occured.
*)
- function Convert(InputBuffer: PChar; OutputBuffer: PChar; var InputSize: integer): integer; virtual; abstract;
+ function Convert(InputBuffer: PByteArray; OutputBuffer: PByteArray; var InputSize: integer): integer; virtual; abstract;
(**
* Destination/Source size ratio
@@ -561,7 +562,6 @@ procedure DumpMediaInterfaces();
implementation
uses
- sysutils,
math,
UIni,
UMain,
@@ -942,7 +942,7 @@ end;
{ TVoiceRemoval }
-procedure TVoiceRemoval.Callback(Buffer: PChar; BufSize: integer);
+procedure TVoiceRemoval.Callback(Buffer: PByteArray; BufSize: integer);
var
FrameIndex, FrameSize: integer;
Value: integer;
@@ -1180,7 +1180,7 @@ end;
(*
* Fills a buffer with copies of the given frame or with 0 if frame.
*)
-procedure TAudioPlaybackStream.FillBufferWithFrame(Buffer: PChar; BufferSize: integer; Frame: PChar; FrameSize: integer);
+procedure TAudioPlaybackStream.FillBufferWithFrame(Buffer: PByteArray; BufferSize: integer; Frame: PByteArray; FrameSize: integer);
var
i: integer;
FrameCopyCount: integer;
diff --git a/src/base/URecord.pas b/src/base/URecord.pas
index 132bafd5..00d82abb 100644
--- a/src/base/URecord.pas
+++ b/src/base/URecord.pas
@@ -36,8 +36,8 @@ interface
uses
Classes,
Math,
- SysUtils,
sdl,
+ SysUtils,
UCommon,
UMusic,
UIni;
@@ -54,8 +54,8 @@ type
function GetToneString: string; // converts a tone to its string represenatation;
- procedure BoostBuffer(Buffer: PChar; Size: Cardinal);
- procedure ProcessNewBuffer(Buffer: PChar; BufferSize: integer);
+ procedure BoostBuffer(Buffer: PByteArray; Size: Cardinal);
+ procedure ProcessNewBuffer(Buffer: PByteArray; BufferSize: integer);
// we call it to analyze sound by checking Autocorrelation
procedure AnalyzeByAutocorrelation;
@@ -135,7 +135,7 @@ type
procedure UpdateInputDeviceConfig;
// handle microphone input
- procedure HandleMicrophoneData(Buffer: PChar; Size: Cardinal;
+ procedure HandleMicrophoneData(Buffer: PByteArray; Size: Cardinal;
InputDevice: TAudioInputDevice);
end;
@@ -268,7 +268,7 @@ begin
UnlockAnalysisBuffer();
end;
-procedure TCaptureBuffer.ProcessNewBuffer(Buffer: PChar; BufferSize: integer);
+procedure TCaptureBuffer.ProcessNewBuffer(Buffer: PByteArray; BufferSize: integer);
var
BufferOffset: integer;
SampleCount: integer;
@@ -464,7 +464,7 @@ begin
Result := '-';
end;
-procedure TCaptureBuffer.BoostBuffer(Buffer: PChar; Size: Cardinal);
+procedure TCaptureBuffer.BoostBuffer(Buffer: PByteArray; Size: Cardinal);
var
i: integer;
Value: Longint;
@@ -608,10 +608,10 @@ end;
* Length - number of bytes in Buffer
* Input - Soundcard-Input used for capture
*}
-procedure TAudioInputProcessor.HandleMicrophoneData(Buffer: PChar; Size: Cardinal; InputDevice: TAudioInputDevice);
+procedure TAudioInputProcessor.HandleMicrophoneData(Buffer: PByteArray; Size: Cardinal; InputDevice: TAudioInputDevice);
var
- MultiChannelBuffer: PChar; // buffer handled as array of bytes (offset relative to channel)
- SingleChannelBuffer: PChar; // temporary buffer for new samples per channel
+ MultiChannelBuffer: PByteArray; // buffer handled as array of bytes (offset relative to channel)
+ SingleChannelBuffer: PByteArray; // temporary buffer for new samples per channel
SingleChannelBufferSize: integer;
ChannelIndex: integer;
CaptureChannel: TCaptureBuffer;
diff --git a/src/base/URingBuffer.pas b/src/base/URingBuffer.pas
index 515d0efb..684c13ee 100644
--- a/src/base/URingBuffer.pas
+++ b/src/base/URingBuffer.pas
@@ -39,7 +39,7 @@ uses
type
TRingBuffer = class
private
- RingBuffer: PChar;
+ RingBuffer: PByteArray;
BufferCount: integer;
BufferSize: integer;
WritePos: integer;
@@ -47,8 +47,10 @@ type
public
constructor Create(Size: integer);
destructor Destroy; override;
- function Read(Buffer: PChar; Count: integer): integer;
- function Write(Buffer: PChar; Count: integer): integer;
+ function Read(Buffer: PByteArray; Count: integer): integer;
+ function Write(Buffer: PByteArray; Count: integer): integer;
+ function Size(): integer;
+ function Available(): integer;
procedure Flush();
end;
@@ -71,7 +73,7 @@ begin
FreeMem(RingBuffer);
end;
-function TRingBuffer.Read(Buffer: PChar; Count: integer): integer;
+function TRingBuffer.Read(Buffer: PByteArray; Count: integer): integer;
var
PartCount: integer;
begin
@@ -106,7 +108,7 @@ begin
Result := Count;
end;
-function TRingBuffer.Write(Buffer: PChar; Count: integer): integer;
+function TRingBuffer.Write(Buffer: PByteArray; Count: integer): integer;
var
PartCount: integer;
begin
@@ -143,6 +145,16 @@ begin
Result := Count;
end;
+function TRingBuffer.Available(): integer;
+begin
+ Result := BufferCount;
+end;
+
+function TRingBuffer.Size(): integer;
+begin
+ Result := BufferSize;
+end;
+
procedure TRingBuffer.Flush();
begin
ReadPos := 0;
@@ -150,4 +162,4 @@ begin
BufferCount := 0;
end;
-end. \ No newline at end of file
+end.