Playing a sound with effects

To play a sound with special-effects, add the effects component between the sound source and the destination. Call Play on the first playable component in the series to play the sound:

      // Create a default player, speaker, and echo effect.
      TSineWave*  aSine = new TSineWave(440.,TMilliseconds(500));
      TAudioPlayer    *aPlayer = TAudioPlayer::CreateDefaultAudioPlayer(aSine,
    TAudioType::GetOffsetBinary8bit22KHz()); TSpeaker *aSpeaker =
    TSpeaker::CreateDefaultSpeaker(TAudioType::GetOffsetBinary8bit22KHz()); TEcho *anEcho = TEcho::CreateDefaultEcho(TMilliseconds(1000.), 0.5, 0.5,
    TAudioTYpe::GetOffsetBinary8bit22KHz()); // Create port surrogates and connect the components. TAudioOutputPortSurrogate* aPlayerOut = aPlayer->CreateLeftOutput(); TAudioInputPortSurrogate* anEchoIn = anEcho->CreateInput(); TAudioOutputPortSurrogate* anEchoOut = anEcho->CreateLeftOutput(); TAudioInputPortSurrogate* aSpeakerIn = aSpeaker->CreateInput(); aPlayerOut->ConnectTo(*anEchoIn); anEchoOut->ConnectTo(*aSpeakerIn); // Play the sound with the effect. aPlayer->Play(); aPlayer->WaitUntilComplete();

[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