This unit is a demo showing how to build new input and output components for NewAC.
| Components Demo | This unit is a demo showing how to build new input and output components for NewAC. |
| Constants | |
| InitialBufferSize | An Integer equal to $1000 (that’s 4096 bytes, if you don’t speak hex). |
| TDemoWaveIn | A demo input component capable of reading data from raw PCM wav files. |
| Functions | |
| OpenFile | Called by the base methods of TAuFileIn class to open the file. |
| CloseFile | Called by the base methods of TAuFileIn class to close the file. |
| Create | Reimplementing constructor and destructor is optional. |
| GetDataInternal | Used by NewAC to retrieve decoded data. |
| Variables | |
| Integer - the number of bytes to read, returns bytes read. | |
| Functions | |
| SeekInternal | Performs the file seeking. |
| TDemoWaveOut | A demo output component capable of storing data on disk or in a stream in the raw PCM wav format. |
| Functions | |
| Prepare | Performs all the steps required to initialize output. |
| DoOutput | Called in a loop to perform actual output. |
| Done | Called to do whatever is needed to close the output as well as freeing any associated resources. |
| Compare4 | Used internally by ReadRIFFHeader. |
| ReadRIFFHeader | A helper function that parses wav file header and gets audio data parameters. |
A demo input component capable of reading data from raw PCM wav files. Like most input components, it descends from the TAuFileIn class.
| Functions | |
| OpenFile | Called by the base methods of TAuFileIn class to open the file. |
| CloseFile | Called by the base methods of TAuFileIn class to close the file. |
| Create | Reimplementing constructor and destructor is optional. |
| GetDataInternal | Used by NewAC to retrieve decoded data. |
| Variables | |
| Integer - the number of bytes to read, returns bytes read. | |
| Functions | |
| SeekInternal | Performs the file seeking. |
Used by NewAC to retrieve decoded data. You should pass the number of bytes you want to read in the Bytes parameter. This method returns the pointer to the data buffre in the Buffer variable parameter and the number of bytes actually read in the buffer in the Bytes paramter. The buffer pointer must be provided by THIS method and not by the caller. The pointer returned by GetData should be valid until the next call to the method. When the method cannot return any more data it should return nil in the Buffer and 0 in the Bytes parameter. The GetDataInternal method can return less bytes than it is asked to and it should not be considered as an end of file indication.
| Buffer: Pointer | an unassigned pointer to use for the results, GetData initializes the pointer itself. |
function SeekInternal( var SampleNum : Int64 ) : Boolean; override
Performs the file seeking. The new position is set in samples, not in bytes, relatively to the beginning of the file. Seek should return True if the input is seekable and False otherwise. This method implementation is optional. If your input component doesn’t support seeking.
function TSomeInputComponent.Seek(SampleNum : Integer) : Boolean; begin Result := False; end;
In the SampleNum parameter we pass the new position in the input stream in frames (which are called samples ;-) relative to the beginning of the stream.
A demo output component capable of storing data on disk or in a stream in the raw PCM wav format. Like most output components, it descends from the TAuFileOut class.
| Functions | |
| Prepare | Performs all the steps required to initialize output. |
| DoOutput | Called in a loop to perform actual output. |
| Done | Called to do whatever is needed to close the output as well as freeing any associated resources. |
| Compare4 | Used internally by ReadRIFFHeader. |
| ReadRIFFHeader | A helper function that parses wav file header and gets audio data parameters. |
function DoOutput( Abort : Boolean ):Boolean; override
Called in a loop to perform actual output. If the Abort parameter is set to True the function must do whatever is needed to stop the output. The function may be called several times with the Abort value set to True. The return value indicartes wheter an output operation should continue. If the function has done its job (because of an end of input file condition, or because the Abort parameter is set to True, or because of some failure, it should return False as a result. Otherwise it returns True.
| Abort: Boolean | set to True in order to stop the output operation |
| Success | Boolean |
function Compare4( S1, S2 : PChar ) : Boolean
Used internally by ReadRIFFHeader.
Called by the base methods of TAuFileIn class to open the file.
procedure OpenFile; override
Called by the base methods of TAuFileIn class to close the file.
procedure CloseFile; override
Reimplementing constructor and destructor is optional.
constructor Create( AOwner: TComponent ); override
Performs the file seeking.
function SeekInternal( var SampleNum : Int64 ) : Boolean; override
Performs all the steps required to initialize output.
procedure Prepare; override
Called in a loop to perform actual output.
function DoOutput( Abort : Boolean ):Boolean; override
Called to do whatever is needed to close the output as well as freeing any associated resources.
procedure Done; override
Used internally by ReadRIFFHeader.
function Compare4( S1, S2 : PChar ) : Boolean
A helper function that parses wav file header and gets audio data parameters.
function ReadRIFFHeader( Stream : TStream; var AudioInfo : TAudioInfo ) : Boolean