|
|
|
const char * getError() ;
|
Returns the last error that occured.
Example :
const char *errorMsg ;
errorMsg = yourSound->getError( ) ; |
| bool isPlaying( void ) |
Returns true if the sound/music is playing.
Example :
if ( mySound->isPlaying() == true ) { dance( ) ; } |
void setVolume( int volume ) ;
|
Sets the volume of the sound/music ( range 0-100 )
Example :
mySound->setVolume( 80 ) ;
myMusic->setVolume( 45 ) ; |
| static void setGlobalVolumes( int volumeMusic , int volumeSFX ) |
Sets the overall Music /Sound volumes.
It is useful for option panels for example.
Example :
mySound->setGlobalVolumes( 20,80 ) ; //play the music low and the sounds high |
bool loadModule( const char *moduleName ) ;
|
Loads a module ( .mod, .xm .s3m please refer to the sound engine you are using for supported formats ).
Example :
KSound *myMusic = NULL ;
myMusic = new KSound ;
myMusic->loadModule( KMiscTools::makeFilePath( "supermod.mod" ) );
myMusic->playModule( true ) ; //play and loop |
void playModule( bool loop ) ;
|
Plays a module.( .mod, .xm .s3m please refer to the sound engine you are using for supported formats ).
Set the loop parameter to true for looping.
Example :
KSound *myMusic = NULL ;
myMusic = new KSound ;
myMusic->loadModule( KMiscTools::makeFilePath( "supermod.mod" ) );
myMusic->playModule( true ) ; //play and loop |
bool isMusicPaused( void ) ;
|
returns true if the music is currently paused.
Example :
if ( myMusic->isMusicPaused() == true ) { doNotDance() } ;
|
void pauseModule( void ) ;
|
Pauses the current module.
Example :
myMusic->pauseModule( ) ;
|
void modToRaw( const char* filename , unsigned long bytesRequested ) ;
|
Writes the current mod format into raw data.
On Intel the output format is raw 16 bits / signed / stereo / little endian / 0 byte offset
On Motorola the output format is raw 16 bits / signed / stereo / big endian / 0 byte offset
Example :
snd->loadModule( "music.xm" ) ;
snd->setModulePosition( 12 ) ;
snd->modToRaw( "c:\\music.raw" , (1024*1024)*5 ); // write 5 megs of raw pcm ("wav") data
|
void continueModule( void ) ;
|
Resumes a previously paused module.
Example :
myMusic->pauseModule( ) ;
//pause
myMusic->continueModule( ) ;
|
void setModulePosition( int position ) ; //jump dans les 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 *sampleName , int volume=100 , bool loop=false , short maxChannels=1) ;
|
loads a sample. ( uncompressed wav or OGG )
OGG samples get completely depacked in a sound buffer,
use the STREAM functions if you plan to play a music or it can use a lot of memory!
use maxChannels to be able to play several channels of the same sound ( up to 10 )
Example :
KSound *explosionSound = NULL ;
explosionSound = new KSound ;
explosionSound->loadSample( KMiscTools::makeFilePath( "explode.wav" ) );
|
void playSample( void ) ;
|
plays a sample.
Example :
KSound *explosionSound = NULL ;
explosionSound = new KSound ;
explosionSound->loadSample( KMiscTools::makeFilePath( "explode.wav" ) );
explosionSound->playSample( ) ;
explosionSound->setVolume( 90 ) ; //forces the volume!
|
void stopSample( void ) ;
|
stops a sample.
Example :
explosionSound->stopSample( ) ;
|
void setPan( long p ) ;
|
sets the panoramic of a sound/song.
value range is -100 to 100 ( -100 = left, 100 =right )
the default is 0 ( center )
|
bool loadStream( const char *streamName ) ;
|
Loads a stream, ( ogg )
Note that the only format supported by the stream format is OGG.
The OGG music gets completely preloaded in memory then streamed a little bit a at time. ( no disk access )
Example :
KSound *musicStreamed ;
musicStreamed = new KSound ;
musicStreamed->loadStream( "supersong.ogg" ) ;
|
| bool loadStreamFromPtr( char *oggPtr , unsigned long datasize ) ; |
Loads a OGG stream given a memory location
Note that the only format supported by the stream format is OGG.
Example :
KSound *musicStreamed ;
musicStreamed = new KSound ;
musicStreamed->loadStreamFromPtr( myMemoryBuffer, myBufferLen ) ;
|
void playStream( bool loop ) ;
|
plays a previously loaded ogg.
Example :
KSound *musicStreamed ;
musicStreamed = new KSound ;
musicStreamed->loadStream( "supersong.ogg" ) ;
musicStreamed->playStream( true )
|
void stopStream( void ) ;
|
stops a stream that's playing.
Example :
musicStreamed->stopStream( )
|
|