Recording audio data

There are two ways to record: use a TSound convenience player or create and connect player and microphone components explicitly using TAudioPlayer and TMicrophone. To record using TSound, see "Audio concepts" on page 305.

To record audio data with a player and microphone:

  1. Create an audio player.
    You can create a default audio player by calling the static function TAudioPlayer::CreateDefaultAudioPlayer. When you create a default player, you must pass it a pointer to a sequence and specify the sequence's type. The sequence is an instance of TAudioSequence and can be of any valid audio type.
  2. Create a microphone instance.
    You can create a default audio microphone by calling the static function TMicrophone::CreateDefaultMicrophone.
  3. Connect the microphone instance to the player.
    If you are recording in stereo, use one microphone for each channel (left and right).
    1. Create an output port surrogate for the microphone.
    2. Create an input port surrogate for the player.
    3. Connect the microphone to the player.
  4. Call AdviseWillRecord on the player.
  5. Call Start on the microphone.
  6. Call Record on the player.
  7. Call Stop on the player.
      TAudioPlayer*   aPlayer=
      TAudioPlayer::CreateDefaultAudioPlayer(aSequence,TAudioType::GetLinear16Bit44KHz()); TMicrophone* aMicrophone=
      TMicrophone::CreateDefaultMicrophone(TAudioType::GetLinear16Bit44KHz()); // Connect the microphone to the player. TAudioOutputPortSurrogate* aMicOut = aMicrophone->CreateOutput(); TAudioInputPortSurrogate* aPlayerIn = aPlayer->CreateLeftInput(); aMicOut->ConnectTo(*aPlayerIn); aPlayer->AdviseWillRecord(); aMicrophone->Start(); aPlayer->Record(); //Call stop to end recording. aPlayer->Stop();

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker