Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to play a gapless looped WAV file without stuttering?

I have a requirement for perfect gapless looped audio in a BlackBerry 10 app. My loops are stored as WAV files. The method I'm using for playing them is:

  1. Create a buffer for the WAV file using alutCreateBufferFromFile which returns a bufferID
  2. Create a sound source using alGenSources
  3. Attach the buffer to the source using alSourcei(source, AL_BUFFER, bufferID)
  4. Set the source looping property to true using alSourcei(source, AL_LOOPING, AL_TRUE)
  5. Play the source using alSourcePlay(source)

The audio plays fine most of the time, but during UI transitions (such as when the backlight goes off, or when the app is minimised) the audio stutters.

Any ideas how I can ensure the audio is smooth the whole time?

like image 1000
donturner Avatar asked Jun 28 '13 14:06

donturner


People also ask

How do I loop a WAV file?

Go to tools and then New Loop. Go in Loop start and type in where your loop starts. Once your done typing your loop points. go to file and save as and then save your music where ever you want.

Can a WAV file have multiple tracks?

WAV Poly files are multi-channel BWF files that contain extra metadata identifying the channels. With WAV mono (monophonic) as the file type, the audio recorder will generate separate data files for each individual track recorded.

How can I play multiple WAV files at once?

You can use DirectShow transform filter it is a Microsoft Windows Application Programming Interface (API) that enables Windows applications to interact with and control Windows "Media" input devices, Or you can use WaveMix DLL it is a utility that allows multiple WAV files to be played simultaneously.


1 Answers

How do you run a thread/process playing WAV file? Have you had a chance to play around priorities and policies with that thread?

I think these low-level system calls allowing to change process (thread, actually) priority and policy might help:

  • pthread_setschedprio
  • pthread_setschedparam

Also, have a look at respective doc pages:

  • BB10 Priorities
  • BB10 Scheduling policies
  • QNX Neutrino MicroKernel

I'd start with setting policy to FIFO and raise priority of the process playing audio file. Hope it helps.

like image 112
Sunseeker Avatar answered Nov 15 '22 09:11

Sunseeker