Jump to content

How to get the duration of a sound?


Gandi
 Share

Recommended Posts

..unfortunately, there is no direct commands LE provide out of box, for such info (at least not to my knowledge)..so, what i did in order to access such informations, as well as tons of other useful things , sound related, is rigged Bass audio library...hopefully some out of box commands will be included in LE3.x..or if there is some open source library similar to BASS, it will be nice to have it and maybe made some community project out of it for benefit of all..

 

EDIT:

actually it should be relatively easy to write some small lib to read such data from sound file header..

 

ALuint LoadALBuffer(string path)
{
   // Variables to store data which defines the buffer.
   ALenum format;
   ALsizei size; // THIS IS YOUR SOUND FILE DURATION 
   ALvoid* data;
   ALsizei freq;
   ALboolean loop;

   // Buffer id and error checking variable.
   ALuint buffer;
   ALenum result;

   // Generate a buffer. Check that it was created successfully.
   alGenBuffers(1, &buffer);

   if ((result = alGetError()) != AL_NO_ERROR)
       throw GetALErrorString(result);

   // Read in the wav data from file. Check that it loaded correctly.
   alutLoadWAVFile(szFilePath, &format, &data, &size, &freq, &loop);

   if ((result = alGetError()) != AL_NO_ERROR)
       throw GetALErrorString(result);

   // Send the wav data into the buffer. Check that it was received properly.
   alBufferData(buffer, format, data, size, freq);

   if ((result = alGetError()) != AL_NO_ERROR)
       throw GetALErrorString(result);

   // Get rid of the temporary data.
   alutUnloadWAV(format, data, size, freq);

   if ((result = alGetError()) != AL_NO_ERROR)
       throw GetALErrorString(result);

   // Return the buffer id.
   return buffer;
}

 

..ill play with this over weekend .. now im curious.. :unsure:

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...