Make games that sell. |  |
| download
| order now
KSound
> Introduction
> Examples
> Showcase
> Documentation
| KWindow
| KGraphic
| KMiscTools
| KInput
| KText
| KTrueText
| KSpline
| KWeb
| KIniReader
| KResource
| K3D
| KSound
| KSound2
> History
> Download
> FAQ
> Credits
KSound2: #include "Ksound2.h" Requires KSound2.lib Windows users: add openal.lib and Alut.lib to your project. OpenAL32.dll and wrap_oal.dll in your executable folder. KSound2 uses openAL, full source code is provided when you purchase the full version of PTK. | Quick Reference isPlaying loadModule loadSample loadStream playStream setGlobalVolumes setPosition setVolume stop loadModule playModule setModulePosition setPitch
bool loadStream( const char* filename , bool loop=true , float volume=1.0f)
Loads a ogg stream in memory. Example : KSound2 *snd_music; snd_music = new KSound2 ; snd_music->loadStream( "music.ogg" , true, 0.5f ) ;
void playStream( void )
plays a ogg stream previously loaded in memory. Example : KSound2 *snd_music; snd_music = new KSound2 ; snd_music->loadStream( "music.ogg" , true, 0.5f ) ; snd_music->playStream( ) ;
void stop( void )
Stops, a sample, a stream or a module. Example : KSound2 *snd_music; snd_music = new KSound2 ; snd_music->loadStream( "music.ogg" , true, 0.5f ) ; snd_music->playStream( ) ; snd_music->stop( ) ;
bool loadModule( const char* filename , bool loop=false , float volume=1.0f ) ;
Loads a module ( .mod, .xm .s3m or .it ). Example : KSound2 *myMusic = NULL ; myMusic = new KSound2 ; myMusic->loadModule( KMiscTools::makeFilePath( "supermod.mod" ) , true, 0.4f ); myMusic->playModule( ) ; //play
void playModule( void ) ;
Plays a module.( .mod, .xm .s3m ). Example : KSound2 *myMusic = NULL ; myMusic = new KSound2 ; myMusic->loadModule( KMiscTools::makeFilePath( "supermod.mod" ) , true ); myMusic->playModule( ) ;
void setModulePosition( int position ) ; //jump in the patterns
Jumps into the patterns of a module. ( skip to another position in the music ) Example : myMusic->setModulePosition( 30 ) ;//jumps to pattern 30
bool loadSample( const char* filename , bool loop=true , float volume=1.0f , short maxChannels =1 )
Loads a ogg or wav sample in memory. Example : KSound2 *snd_bounce; snd_bounce = new KSound2 ; snd_bounce->loadSample( "bounce.ogg" , false, 0.5f , 5 ) ; //allows up to 5 channels for this sample
long playSample( void )
plays a sample, returns the ID of the played channel. Example : KSound2 *snd_bounce; snd_bounce = new KSound2 ; snd_bounce->loadSample( "bounce.ogg" , false, 0.5f , 5 ) ; long playedChannel = snd_bounce->playSample( ) ;
void setVolume( float volume )
sets the volume of a sound or a music. 0 = no sound 1 = maximum volume. Example : KSound2 *snd_bounce; ... snd_bounce->setVolume( 0.3f ) ;
void setPosition( float x, float y, float z )
sets the position of a sound in space.. 0 = no sound 1 = maximum volume. Example : KSound2 *snd_bounce; ... snd_bounce->setPosition( -1,0,0 ) ; //plays the sound completely on the left
void setPitch( float pitch )
Changes the pitch of a sound. Example : KSound2 *snd_bounce; ... snd_bounce->setPitch( 2 ) ; //plays the sound 2 times faster.
static void setGlobalVolumes( float music, float sfx ) ;
Changes the global volumes ( all sounds and sfx are affected by this factor ). -1 doesn't change the desired volume. Example : KSound2::setGlobalVolume( 0.2f,0.8f ) ; ... //keep the music as it was before, only change the sound effects KSound2::setGlobalVolume( -1 , 0.8f ) ;
Mod playback is based on the DUMB source code. OGG on the OGG Vorbis library
© 2003-2005, Phelios, inc. - All rights reserved. Trademarks mentioned are the property of their respective owners.