⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unavcide.pas

📁 Voice Commnucation Components for Delphi
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    }
    procedure ensureFormat();
    {DP:METHOD
      Returns current volume value. calcVolume must be set to true.
    }
    function getVolume(channel: int = 0): int;
    //
    {DP:METHOD
      Flushes any data panding.
    }
    procedure flush();
    //
    {DP:METHOD
      Returns ACM manager for the device.
    }
    property acm: unaMsAcm read f_acm;
    {DP:METHOD
      Returns device driver.
    }
    property driver: unaMsAcmDriver read f_driver write setDriver;
    {DP:METHOD
      Returns wave device associated with the pipe.
    }
    property device: unaMsAcmStreamDevice read f_device;
    {DP:METHOD
      Returns PCM format of the wave device.
    }
    property pcmFormat: pWAVEFORMATEX read getFormat write setFormat;
    {DP:METHOD
    }
    property chunkSize: unsigned read getChunkSize;
    {DP:METHOD
    }
    property dstChunkSize: unsigned read getDstChunkSize;
    {DP:METHOD
    }
    property waveError: int read f_waveError;
    {DP:METHOD
    }
    property waveErrorAsString: string read getWaveErrorAsString;
    //
    {DP:METHOD
      When true tells the component to calculate the audio volume of a stream coming into or from the component.
      Use the getVolume() method to get the current volume level.
    }
    property calcVolume: bool read f_calcVolume write setCalcVolume default false;
  published
    {DP:METHOD
      Specifies how many chunks of data (every chunk can hold 1/10 second of audio) component can store in the input or output buffer, if data cannot be processed immediately.
      Set this property to 0 to disable the buffer overflow checking (be carefully, since this could lead to uncontrolled memory usage grow).
    }
    property overNum: unsigned read f_overNum write setOverNum default defOverNumValue;
    {DP:METHOD
      Specifies number of samples per second for wave device. Common values are 44100, 22050, 11025 and 8000.
    }
    property pcm_samplesPerSec: unsigned index 0 read getSamplingParam write setSamplingParam default c_defSamplingSamplesPerSec;
    {DP:METHOD
      Specifies number of bits per sample for wave device. Common values are 8 and 16.
    }
    property pcm_bitsPerSample: unsigned index 1 read getSamplingParam write setSamplingParam default c_defSamplingBitsPerSample;
    {DP:METHOD
      Specifies number of channels per sample for wave device. Common values are 1 (mono) and 2 (stereo).
    }
    property pcm_numChannels: unsigned index 2 read getSamplingParam write setSamplingParam default c_defSamplingNumChannels;
  end;


  //
  // -- TunavclWaveInDevice --
  //

  {DP:CLASS
    <P /><I>Purpose</I>: real time PCM audio stream recording from the sound card or other hardware device.
    <P /><I>Usage</I>: If components has no provider component with formatProvider=true, specify PCM stream parameters before activating: pcm_SamplesPerSec, pcm_BitsPerSample and pcm_NumChannels.
    Set deviceId property if required. minActiveTime and minVolumeLevel controls the silence detection behavior.
    <P /><I>Example</I>: refer to the vcTalkNow demo. It has waveIn_server and waveIn_client components.
    Both are used to record real-time PCM stream to be sent to remote side. waveIn_server has c_codec_serverOut component as a consumer.
    That means PCM stream produced by waveIn_server will be passed to c_codec_serverOut component automatically.
  }
  TunavclWaveInDevice = class(unavclInOutWavePipe)
  private
    f_minVolume: unsigned;
    f_minActiveTime: unsigned;
    //
    f_onThreshold: unaWaveInOnThresholdEvent;
    //
    function getWaveInDevice(): unaWaveInDevice;
    //
    function getMinActiveTime(): unsigned;
    function getMinVolLevel(): unsigned;
    procedure setMinActiveTime(value: unsigned);
    procedure setMinVolLevel(value: unsigned);
    procedure setOnThreshold(value: unaWaveInOnThresholdEvent);
  protected
    {DP:METHOD
      Creates waveIn (recording) device.
    }
    procedure createNewDevice(); override;
    {DP:METHOD
    }
    function applyDeviceFormat(const format: WAVEFORMATEX; isSrc: bool = true): bool; override;
  public
    //
    procedure AfterConstruction(); override;
    //
    {DP:METHOD
      Returns waveIn device.
    }
    property waveInDevice: unaWaveInDevice read getWaveInDevice;
  published
    //
    property deviceId;
    property mapped;
    property direct;
    property calcVolume;
    //
    {DP:METHOD
      Minimum volume level for recording.
    }
    property minVolumeLevel: unsigned read getMinVolLevel write setMinVolLevel default 0;
    {DP:METHOD
      Minimum active time for recording.
    }
    property minActiveTime: unsigned read getMinActiveTime write setMinActiveTime default 0;
    {DP:METHOD
      waveIn component is usually a format provider--so this property value was changed to be true by default.
    }
    property isFormatProvider default true;
    //
    property onThreshold: unaWaveInOnThresholdEvent read f_onThreshold write setOnThreshold;
    {DP:METHOD
      Specifies whether the component would produce any data.
      Setting this property to False does not release the waveIn device.
      Set active property to False to release the device as well.
    }
    property enableDataProcessing;
    {DP:METHOD
      Specifies how component should detect silence.
    }
    property silenceDetectionMode;
  end;


  //
  // -- TunavclWaveOutDevice --
  //

  {DP:CLASS
    <P /><I>Purpose</I>: real time PCM audio stream playback using the sound card or other hardware device.
    <P /><I>Usage</I>: If components has no provider component with formatProvider=true, specify PCM stream parameters before activating: pcm_SamplesPerSec, pcm_BitsPerSample and pcm_NumChannels.
    <P /><I>Example</I>: refer to the vcTalkNow demo. It has waveOut_server and waveOut_client components.
    Both are used to playback real-time PCM stream received from remote side.
    In this demo, waveOut_server is a consumer of c_codec_serverIn component.
    That means PCM stream, produced by c_codec_serverIn will be passed to waveOut_server automatically.
  }
  TunavclWaveOutDevice = class(unavclInOutWavePipe)
  private
    f_onFC: unavclPipeDataEvent;
    f_onFD: unavclPipeDataEvent;
    //
    function getWaveOutDevice(): unaWaveOutDevice;
    procedure myOnACF(sender: tObject; data: pointer; size: unsigned);
    procedure myOnACD(sender: tObject; data: pointer; size: unsigned);
  protected
    {DP:METHOD
      Creates wave Out (playback) device.
    }
    procedure createNewDevice(); override;
    {DP:METHOD
    }
    function applyDeviceFormat(const format: WAVEFORMATEX; isSrc: bool = true): bool; override;
    {DP:METHOD
      Since waveOut device is output device, and output format is PCM, we should specify input format as not PCM.
    }
    property inputIsPcm default false;
  public
    {DP:METHOD
    }
    procedure AfterConstruction(); override;
    //
    //function getVolume(channel: int = 0): int; override;
    //
    {DP:METHOD
      Returns waveOut device.
    }
    property waveOutDevice: unaWaveOutDevice read getWaveOutDevice;
  published
    property deviceId;
    property mapped;
    property direct;
    property calcVolume;
    {DP:METHOD
      Specifies whether the component would playback any data.
      Setting this property to False does not release the waveOut device.
      Set active property to False to release the device as well.
    }
    property enableDataProcessing;
    //
    {DP:METHOD
      Fired when another audio chunk was passed to driver for playback.
      If you are self-feeding the playback, it means you have to feed another chunk to achieve continuous playback.
      <BR /><STRONG>NOTE</STRONG>: VCL is NOT multi-threading safe, and you should avoid using VCL routines and classes in this event.
    }
    property onFeedChunk: unavclPipeDataEvent read f_onFC write f_onFC;
    {DP:METHOD
      Fired when chunk was just played out by device.
      This is a good place for any user feedback. Since the data passed
      to this event was played out about 1/25 second ago, you can achieve
      very short delay between actual data being played back, and feedback.
      For example, if you draw an oscilloscope of a wave, use this event
      to be in synch with actual playback.
      <BR /><STRONG>NOTE</STRONG>: VCL is NOT multi-threading safe, and you should avoid using VCL routines and classes in this event.
    }
    property onFeedDone: unavclPipeDataEvent read f_onFD write f_onFD;
  end;


  //
  // -- TunavclWaveCodecDevice --
  //

  {DP:CLASS
    <P /><I>Purpose</I>: audio stream conversion from one supported format to another. It can convert PCM stream to other format (compression) or other format to PCM (decompression).
    <P /><I>Usage</I>: If components has no provider component with formatProvider=true, specify PCM stream parameters before activating: pcm_SamplesPerSec, pcm_BitsPerSample and pcm_NumChannels.
    Set formatTag property to specify the audio format you wish to compress to or decompress from.
    Refer to WAVE_FORMAT_XXXX constants from unaMsAcmAPI.pas unit for possible values of this property, or you can use the output of amcEnum demo to receive the list of installed formats.
    Set inputIsPCM to true,  if you wish to convert PCM stream to another audio format (compression).
    Set inputIsPCM to false, if you wish to convert some audio format to PCM stream (decompression).
    <P /><I>Example</I>: refer to the vcTalkNow demo. It has c_codec_serverOut component, which is a consumer of waveIn_server component.
    That means PCM stream, produced by waveIn_server will be passed to c_codec_serverOut automatically.
    It also has ip_server as a consumer. That means compressed audio stream will be passed to ip_server automatically.
  }
  TunavclWaveCodecDevice = class(unavclInOutWavePipe)
  private
    function getCodec(): unaMsAcmCodec;
  protected
    procedure doSetDriverMode(value: unaAcmCodecDriverMode); override;
    procedure doSetDriverLibrary(const value: wideString); override;
    //
    {DP:METHOD
      Creates ACM codec device.
    }
    procedure createNewDevice(); override;
    {DP:METHOD
      Notifies ACM codec device about driver change.
    }
    procedure onDriverChanged(); override;
    {DP:METHOD
      Applies PCM format for ACM codec device.
    }
    function applyDeviceFormat(const format: WAVEFORMATEX; isSrc: bool = true): bool; override;
    {DP:METHOD
      Returns format exchange data of the codec.
    }
    function getFormatExchangeData(out data: pointer): unsigned; override;
  public
    {DP:METHOD
    }
    procedure AfterConstruction(); override;
    //
    //function getVolume(channel: int = 0): int; override;
    {DP:METHOD
      Sets non-PCM format for ACM codec device.
    }
    function setNonPCMFormat(const format: WAVEFORMATEX): bool;
    {DP:METHOD
      Returns ACM codec device.
    }
    property codec: unaMsAcmCodec read getCodec;
  published
    //
    property formatTag;
    //property realTime;	 // MARCH 07: removed from published, since it makes more confusion than sence
    property inputIsPcm;
    property calcVolume;
    //
    {DP:METHOD
      Codecs usually does not use the format tag provided by other PCM devices.
    }
    property formatTagImmunable default true;
    {DP:METHOD
      ACM driver mode. When set to unacdm_acm, codec uses ACM to access stream conversion routines.
      unacdm_installable tells codec to use installable driver, specified by driverLibrary.
      unacdm_internal is not currently used.
    }
    property driverMode;
    {DP:METHOD
      When driverMode is set to unacdm_installable this property specifies the name of driver library to use.
      Refer to MSDN documentation for more information about installable drivers.
    }
    property driverLibrary;
    {DP:METHOD
      codec component is usually a format provider--so default value for was changed to true.
    }
    property isFormatProvider default true;
    {DP:METHOD
      Specifies whether the component would perform any data conversion.
    }
    property enableDataProcessing;
    {DP:METHOD
      Specifies how component should detect silence.
    }
    property silenceDetectionMode;
  end;


  //
  // -- TunavclWaveInRiff --
  //

  {DP:CLASS
    <P /><I>Purpose</I>: reads audio stream from WAV file, producing PCM stream, or creates and writes new WAV file.
    <P /><I>Usage</I>: set fileName property to specify the file to use.
    Set isInput to true if you wish to read from WAV file.
    Set isInput to false if you wish to create and write into WAV file.
    Set active to true, or call the open() method to start reading or writing.
    Set active to false, or call the close() method to stop reading, or close the produced WAV file.
    Set realTime to true if you wish the stream read from WAV file will be available in real time manner.
    <P /><I>Example (reading)</I>: refer to the vcWavePlayer demo. Look for wavIn component, which is used to read the stream from WAV file.
    It has waveResampler as a consumer, that means read audio stream will be passed to waveResampler automatically.
    <P /><I>Example (writing)</I>: refer to the voiceRec demo. Look for waveRiff component, which is a consumer of waveIn component.
    That means PCM stream, produced by waveIn will be passed to waveRiff automatically. In this demo waveRiff component is used to create the WAV file.
  }
  TunavclWaveRiff = class(unavclInOutWavePipe)
  private
    f_isInput: bool;
    f_fileName: string;
    f_acod: bool;
    f_onStreamIsDone: unaOnRiffStreamIsDone;
    //
    function getRiff(): unaRiffStream;
    //
    procedure setFileName(const value: string);
    procedure setIsInput(value: bool);
    //
    procedure riffOnStreamIsDone(sender: tObject);
  protected
    procedure doSetLoop(value: bool); override;
    //
    {DP:METHOD
      Creates Riff wave device.
    }
    procedure createNewDevice(); override;
    {DP:METHOD
      This method is supported in WAV-writing mode only (isInput = false),
      and only PCM formats are supported.
    }
    function applyDeviceFormat(const format: WAVEFORMATEX; isSrc: bool = true): bool; override;
    {DP:METHOD

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -