Wave
Audio Package v1.53
|
Copyright ©
Kambiz R. Khojasteh. All rights reserved.
Get future package updates from http://www.delphiarea.com.
Delphi 3 | Delphi 4 | Delphi 5 | Delphi 6 | Delphi 7 |
The Wave Audio Package provides seven components for playing and recording of wave audio formats, two components for storing wave data as Delphi resources, one audio mixer component, and one high resolution multimedia timer. The package has also a set of useful functions for manipulating wave audio's.
The package's components are:
Although for using the components available in the Wave Audio package, you do not know to know about the details, however for some low level descriptions I've supposed you are familiar with Microsoft Multimedia terminology and API. To know more about details you can study "Microsoft Multimedia Programmer's Reference".
TPCMChannel
= (cMono, cStereo) |
TPCMSamplesPerSec
= (ss8000Hz, ss11025Hz, ss22050Hz, ss44100Hz, ss48000Hz); |
TPCMBitsPerSample
= (bs8Bit, bs16Bit); |
TWaveDeviceFormats
= set of TPCMFormat; |
TWaveOutDeviceSupport
= (dsVolume, dsStereoVolume, dsPitch, dsPlaybackRate, dsPosition,
dsAsynchronize, dsDirectSound);
|
TWaveOutDeviceSupports
= set of TWaveOutDeviceSupport; |
TWaveOutOption
= (woSetVolume, woSetPitch, woSetPlaybackRate);
|
TWaveOutOptions
= set of TWaveOutOption; |
TMS2StrFormat
= (msHMSh, msHMS, msMSh, msMS, msSh, msS, msAh, msA);
|
TMixerControlType
= (mcVolume, mcMute, mcSelect);
|
TMixerControlTypes
= set of TMixerControlType; |
TMixerLineTargetType
= (tgUndefined, tgWaveOut, tgWaveIn, tgMidiOut, tgMidiIn, tgAux);
|
TMixerLineComponentType
= (cmDstUndefined, cmDstDigital, cmDstLine, cmDstMonitor, cmDstSpeakers,
cmDstHeadphones, cmDstTelephone, cmDstWaveIn, cmDstVoiceIn, cmSrcUndefined,
cmSrcDigital, cmSrcLine, cmSrcMicrophone, cmSrcSynthesizer, cmCompactDisc,
cmSrcTelephone, cmSrcPCSpeaker, cmSrcWaveOut, cmSrcAuxiliary, cmSrcAnalog);
|
TMixerLineFlags
= set of (lfActive, lfDisconnected, lfSource);
|
TWaveAudioEvent
= procedure(Sender: TObject) of object; |
TWaveAudioGetFormatEvent
= procedure(Sender: TObject; var pWaveFormat: PWaveFormatEx; var FreeIt:
Boolean) of object; |
TWaveAudioGetDataEvent
= function(Sender: TObject; const Buffer: Pointer; BufferSize: DWORD;
var NumLoops: DWORD): DWORD of object; |
TWaveAudioGetDataPtrEvent
= function(Sender: TObject; var Buffer: Pointer; var NumLoops: DWORD;
var FreeIt: Boolean): DWORD of object; |
TWaveAudioDataReadyEvent
= procedure(Sender: TObject; const Buffer: Pointer; BufferSize: DWORD;
var FreeIt: Boolean) of object; This event is used for wave audio events that informs the caller about the recorded wave audio data. The wave data stored in buffer specified by the Buffer parameter, and the size of the actual data in the buffer is specified by the BufferSize parameter. If the FreeIt parameter set to True, the component will release the memory allocated for the buffer, otherwise your application must release it. |
TWaveAudioLevelEvent
= procedure(Sender: TObject; Level: Integer) of object; This event is used for wave audio events that informs the caller about the peak level of the audio buffer in percent. |
TWaveAudioFilterEvent
= procedure(Sender: TObject; const Buffer: Pointer; BufferSize: DWORD)
of object; This event is used for wave audio events that offers to the caller to filter wave data. The wave data stored in the buffer specified by the Buffer parameter, and the size of the actual data in the buffer is specified by the BufferSize parameter. The event handler only can change the data, not the size of the data. |
TMixerLineNotifyEvent
= procedure(Sender: TObject; MixerLine: TAudioMixerLine)
of object; This event notifies the application that the state of an audio line has changed. |
TMixerControlNotifyEvent
= procedure(Sender: TObject; MixerLine: TAudioMixerLine;
ControlType: TMixerControlType) of
object; This event notifies the application that the state of a control associated with an audio line has changed. |
EWaveAudioError
= class(Exception) This class is the base exception class for wave audio exceptions. |
EWaveAudioSysError
= class(EWaveAudioError) This exception is raised if the operating system returns an error code for a wave audio device. The exception dialog contains the system message associated with the error. |
EWaveAudioInvalidOperation
= class(EWaveAudioError) This exception is raised if the when a component receives a request for an invalid operation. For example, if an application attempts to open an already open wave audio device, or change its wave format an EWaveAudioInvalidOperation exception is raised. |
TWave
= class(TMemoryStream);
|
TCustomWaveStorage
= class(TComponent);
(Abstract)
|
TWaveStorage
= class(TCustomWaveStorage);
|
TWaveCollection
= class(TCustomWaveStorage);
|
TWaveItems
= class(TCollection);
|
TWaveItem
= class(TCollectionItem);
|
TWaveAudioIO
= class(TComponent);
(Abstract)
|
TWaveAudioOut
= class(TWaveAudioIO);
(Abstract)
|
TWaveAudioIn
= class(TWaveAudioIO);
(Abstract)
|
TAudioPlayer
= class(TWaveAudioOut);
|
TStockAudioPlayer
= class(TWaveAudioOut);
|
TLiveAudioPlayer
= class(TWaveAudioOut);
|
TAudioRecorder
= class(TWaveAudioIn);
|
TStockAudioRecorder
= class(TWaveAudioIn);
|
TLiveAudioRecorder
= class(TWaveAudioIn);
|
TAudioRedirector
= class(TComponent);
|
TAudioIn
= class(TWaveAudioIn);
|
TAudioOut
= class(TWaveAudioOut);
|
TAudioMixer
= class(TComponent);
|
TAudioMixerLine
= class(TObject);
|
TMultimediaTimer
= class(TComponent);
|
function
GetWaveAudioInfo(mmIO: HMMIO; out pWaveFormat: PWaveFormatEx; var
DataSize, DataOffset: DWORD): Boolean; |
function
CreateWaveAudio(mmIO: HMMIO; const pWaveFormat: PWaveFormatEx; out ckRIFF,
ckData: TMMCKInfo): Boolean; Initializes a wave RIFF format in an open mmIO handle. The previous content of the mmIO will be lost. |
CloseWaveAudio(mmIO:
HMMIO; var ckRIFF, ckData: TMMCKInfo); Updates the chunks and closes an mmIO handle; |
function
GetStreamWaveAudioInfo(Stream: TStream; out pWaveFormat: PWaveFormatEx;
out DataSize, DataOffset: DWORD): Boolean; |
function
CreateStreamWaveAudio(Stream: TStream; const pWaveFormat: PWaveFormatEx;
out ckRIFF, ckData: TMMCKInfo): HMMIO; |
function
OpenStreamWaveAudio(Stream: TStream): HMMIO ; |
function
CalcWaveBufferSize(const pWaveFormat: PWaveFormatEx; Duration: DWORD):
DWORD; Returns the number of bytes required to store wave data for the specified wave format and duration in milliseconds. |
function
GetWaveAudioFormat(const pWaveFormat: PWaveFormatEx): String; Returns the string representation of a wave audio format. |
function
GetWaveAudioLength(const pWaveFormat: PWaveFormatEx; DataSize: DWORD):
DWORD; Returns the wave's length in milliseconds. |
function
GetWaveAudioBitRate(const pWaveFormat: PWaveFormatEx): DWORD; Returns the wave's bit rate in kbps (kilo bits per socond). |
function
GetWaveAudioPeakLevel(const Data: Pointer; DataSize: DWORD; BitsPerSample:
WORD): Integer; Returns the volume peak level in percent of the specified wave data (PCM format only). If the function fails, it returns -1. |
procedure
InvertWaveAudio(const Data: Pointer; DataSize: DWORD; BitsPerSample:
WORD); Reverses the direction of the wave audio (PCM format only). |
procedure
SilenceWaveAudio(const Data: Pointer; DataSize: DWORD; BitsPerSample:
WORD); Fills the specified buffer with the silence data (PCM format only). |
procedure
ChangeWaveAudioVolume(const Data: Pointer; DataSize: DWORD; BitsPerSample:
WORD; Percent: Integer); Increases or decreases the wave data volume by the specified percentage (PCM format only). |
function
ConvertWaveFormat(const srcFormat: PWaveFormatEx; srcData: Pointer;
srcDataSize: DWORD; const dstFormat: PWaveFormatEx; out dstData: Pointer;
out dstDataSize: DWORD): Boolean; Converts the format of a waveform audio. If the function succeeds and returns True, it is the caller's responsiblity to release the memory allocated for the output wave data buffer via ReallocMem procedure. For more information, please read Multistep Format Conversion on MSDN. |
procedure
SetPCMAudioFormat(const pWaveFormat: PWaveFormatEx; Channels: TPCMChannel;
SamplesPerSec: TPCMSamplesPerSec; BitsPerSample:
TPCMBitsPerSample); Initializes a standard PCM wave format header. The size of memory referenced by the pWaveFormat parameter must not be less than the size of TWaveFormatEx record. |
procedure
SetPCMAudioFormatS(const pWaveFormat: PWaveFormatEx; PCMFormat: TPCMFormat); Initializes a standard PCM wave format header (shorcut form). The size of memory referenced by the pWaveFormat parameter must not be less than the size of TWaveFormatEx record. |
function
GetPCMAudioFormat(const pWaveFormat: PWaveFormatEx): TPCMFormat; Returns the standard PCM format specifier of a wave format. |
function
MS2Str(Milliseconds: DWORD; Fmt: TMS2StrFormat):
String; |
function
mmioStreamProc(lpmmIOInfo: PMMIOInfo; uMsg, lParam1, lParam2: DWORD):
LRESULT; stdcall; User defined mmIOProc to handle Delphi;s streams by Windows' mmIO API functions. To open a stream using mmIO API functions, use the following code as sample: FillChar(mmioInfo, SizeOf(mmioInfo), 0); mmioInfo.pIOProc := @mmioStreamProc; mmioInfo.adwInfo[0] := DWORD(your_stream_instance); mmIO := mmioOpen(nil, @mmioInfo, dwOpenFlags); The flags specified by the dwOpenFlags parameter of mmioOpen function can be only one of MMIO_READ, MMIO_WRITE, and MMIO_READWRITE flags. If you use another flags, they will be ignored by this user defined function. |
Special thanks to:
- Inprise <?> for his help on wave format conversion.
The Wave Audio Package is freeware. You may copy package's files AS LONG AS YOU COPY ALL OF THEM. If you want to change the source code in order to improve the components' features, performance, etc. please send me the new source code so that I can have a look at it. The changed source code should contain descriptions what you have changed, and of course your name. The only thing you MAY NOT CHANGE is the ORIGINAL COPYRIGHT INFORMATION.
The Wave Audio Package is provided "AS IS" without any warranty of any kind, either express or implied. The entire risk as to the quality and performance of the software is with you. The author is NOT liable for any DAMAGES resulting from the use and misuse of the package, especially he is NOT liable for DAMAGES that were caused BY ANY VERSION WHICH HAS NOT BEEN PROGRAMMED BY THE AUTHOR HIMSELF.
|
END OF DOCUMENT |