Main Menu


Sponsored Links

  


  
  
Web Cartoon Maker: a Fun Way to Learn C++ Contents Previous Next

Playing Sou nds

There is a special function Play in Web Cartoon Maker for playing WAV files. It accepts one string parameter and two optional ( double and int) parameters which you can omit if you want. The string parameter specifies a WAV file name. This could be an URL like " http://www.webcartoonmaker.com/lib/sounds/wcm/hello.wav" or path to a file on your hard drive like "c:\\myaudio.wav" (please remember about double back slashes). Instead of using fully qualifier URLs you can also use a short path to an audio file in Web Cartoon Maker's library. To browse the library you can go to the following URL:

http://www.webcartoonmaker.com/?art=help/lib_sounds

Please keep in mind that function Play does not change time in a cartoon scene and does not make your cartoon longer. If you want to wait until all the playing is done, you must use Sleep immediately after it. Here is an example:

void Scene1 ()

{

// play them at the same time

Play ( "people/applause.wav" );

Play ( "people/laugh.wav" );


Sleep ( 4 );


// play audio files one after another

Play ( "c:\\my_audio.wav" ); // file must exist on your hard drive

Sleep ( 4 ); // duration of your wav file

Play (

"http://www.webcartoonmaker.com/lib/sounds/effects/gunshot.wav" );

Sleep ( 2 );

}

If you compile the above example, you will notice that "applause.wav" and "laugh.wav" sounds were mixed together.

As I said before there are two more optional parameters for function Play available. First of them is an audio volume factor. Similarly to the character's Says method, when it is equal to 1 (default), the audio is playing with its original volume. If it is less than 1, then audio is playing quieter. If it is more than 1, then audio is playing louder.

Another parameter specifies how you want your sounds to be mixed together. You probably noticed from the above example that "applause.wav" and "laugh.wav" sounds were mixed together. This is the default behavior. But it is also possible to replace a first sound with a second one or make first sound quieter. You suppose to use one of the following constants:

  • MIXMODE_MIX – just mixes the sounds together. This is the default behavior

  • MIXMODE_REPLACE – replaces the existing sound

  • MIXMODE_REPLACEFADE – smoothly replaces the existing sound

  • MIXMODE_DAMP – makes the existing sound quieter and then mixes the sounds

  • MIXMODE_DAMPFADE – smoothly makes the existing sound quieter and then mixes the sounds

You can try the example below to understand the constants. But you can just omit them if default mixing forks fine for you:

void Scene1 ()

{

Play ( "people/applause.wav" );

Play ( "people/laugh.wav", 1, MIXMODE_MIX );

Sleep ( 4 );


Play ( "people/applause.wav" );

Play ( "people/laugh.wav", 1, MIXMODE_REPLACE );

Sleep ( 4 );


Play ( "people/applause.wav" );

Play ( "people/laugh.wav", 1, MIXMODE_REPLACEFADE );

Sleep ( 4 );


Play ( "people/applause.wav" );

Play ( "people/laugh.wav", 1, MIXMODE_DAMP );

Sleep ( 4 );


Play ( "people/applause.wav" );

Play ( "people/laugh.wav", 1, MIXMODE_DAMPFADE );

Sleep ( 4 );

}


Contents Previous Next
  
News

New Tales Animator Video by Alan Sturgess

Alan Sturgess shared an excellent video he made using Tales Animator! You can still download Tales Animator here. Unfortunately it is only available for Wi

...

Simple Online Character Designer

There is a prototype of simple online character designer available HERE. It is only a prototype, it does not contain many pieces yet but it can already generat

...

Book is updated

Now our book "Web Cartoon Maker: A Fun Way to Learn C++" is fully in synch with WCM 1.5! It is available for download and online reading HERE.

...

Web Cartoon Maker 1.5 is here!

Web Cartoon Maker 1.5 is finally here! You can download it HERE! Here is what was updated in version 1.5: Web Cartoon Maker Desktop Edition is now fully standal

...

read more news...


Poll