You can use a plugin to calculate the length of a wav sound then playing each sound without overlapping.
For the wav, what I'm using :
Code:
/*
(*) Wav file format.
(*) More informations : http://ccrma.stanford.edu/CCRMA/Courses/422/projects/WaveFormat/
[ Offset Field Size ]
0 ChunkId 4 |
4 ChunkSize 4 |-> The "RIFF" chunk descriptor.
8 Format 4 |
12 SubChuck1ID 4 |
16 SubChuck1Size 4 |
20 AudioFormat 2 |
22 NumChannels 2 |-> The "fmt" sub-chunk.
24 SampleRate 4 |
28 ByteRate 4 |
32 BlockAlign 2 |
34 BitPerSample 2 |
36 SubChunk2ID 4 |
40 SubChunk2Size 4 |-> The "data" sub-chunk
44 Data | |
SubChunk2Size
(*) Time = SubChunk2Size / ( BitPerSample * SampleRate ) / 8.
*/
Float:GetWavDuration( const WavFile[] )
{
new Frequence [ 4 ];
new Bitrate [ 2 ];
new DataLength[ 4 ];
new File;
// --| Open the file.
File = fopen( WavFile, "rb" );
// --| Get the frequence from offset 24. ( Read 4 bytes )
fseek( File, 24, SEEK_SET );
fread_blocks( File, Frequence, 4, BLOCK_INT );
// --| Get the bitrate from offset 34. ( read 2 bytes )
fseek( File, 34, SEEK_SET );
fread_blocks( File, i_Bitrate, 2, BLOCK_BYTE );
// --| Search 'data'. If the 'd' not on the offset 40, we search it.
if ( fgetc( File ) != 'd' ) while( fgetc( File ) != 'd' && !feof( File ) ) {}
// --| Get the data length from offset 44. ( after 'data', read 4 bytes )
fseek( File, 3, SEEK_CUR );
fread_blocks( File, DataLength, 4, BLOCK_INT );
// --| Close file.
fclose( File );
// --| Calculate the time. ( Data length / ( frequence * bitrate ) / 8 ).
return float( DataLength[ 0 ] ) / ( float( Frequence[ 0 ] * i_Bitrate[ 0 ] ) / 8.0 );
}