0
0

Hi.

I’m writing a audio plugin for a 3D animation package – basically it’ll allow you to scrub the timeline and it’ll playback the section of audio that you’ve scrubbed.
So far, it’s working fine. I initialize FMOD with a path to an audio file and use CreateSound when the plugin is added into the scene.

As the user scrubs the timeline, I pass the current playhead position, the speed that the user is scrubbing the timeline (or playback) and a length to play the audio back for to a function. The function plays the audio file, I then use setPosition, setDelay and setFrequency to set a position, length and speed of playback. This function is called every time the time changes, which is at most, once per frame.

I’ve added the source code below.

Anyway, I am running to a problem where I get a kind of popping sound every time it calls the function to play the sound. This creates a kind of stuttering to the audio, as it plays each section with a small gap inbetween (even though my maths for playback speed is spot on). If play a silent audio track using the same function, I get a silent track but a slight popping noise every time it calls the function to play audio. Which suggests it’s not each snippet of audio falling short, but instead something to do with calling the play function over and over again.

As you’ve probably guessed from reading this, my knowledge of audio and sound library’s isn’t great. So there’s a good chance I’m taking the wrong approach or have done something quite obviously wrong. Can anyone help point me in the right direction as to what the problem could be? Each section of audio should sync up perfectly based on the speed and position calculations I’m doing, but I can’t get rid of the popping.


Code: (I’ve removed some error checking).

[code:38rf9gca]
FMOD::System *system;
FMOD::Sound *sound;
FMOD::Channel *channel;

void initialize_audioLibrary(const char * filename)
{
FMOD::System_Create(&system);
system->init(32, FMOD_INIT_NORMAL, 0);
system->createSound(filename, FMOD_SOFTWARE, 0, &sound);
}

void playAudio_audioLibrary(int position, float speed, int length, int direction)
{
system->update();

system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);

unsigned int loNumber;
unsigned int hiNumber;
system->getDSPClock(&hiNumber, &loNumber);

FMOD_64BIT_ADD(hiNumber, loNumber, 0, 44100*length/1000); // 44100 is a standin. Need to get the system sample rate.
channel->setPosition(position, FMOD_TIMEUNIT_MS);

channel->setDelay(FMOD_DELAYTYPE_DSPCLOCK_END, hiNumber, loNumber);

float frequency;
channel->getFrequency(&frequency);

float newFrequency = frequency * speed;

if(direction == 1) {
    newFrequency = newFrequency * -1;
}

channel->setFrequency(newFrequency);

}

// Deintialize audio library...etc.
[/code:38rf9gca]

Any help would be really appreciated.

-Matt

  • You must to post comments
0
0

Actually, the more I look into this, I think that it’s more of a performance issue than anything else. I was assuming that the host application is playing realtime, but I don’t think it is.

  • You must to post comments
0
0

After spending some more time on this and continuing with the plugin. I’ve managed to reduce some of the problems, however, I am still seeing some crackling and popping on every frame. I assume this is because I play the audio track for a single frame on every frame. So it plays them in turn and should result in smooth playback. However, If the playback speed isn’t realtime (even if it is out by a fraction of a second), that will create gaps between each frame of audio.

However, I am seeing some crackling and a pause between frames, even if it is playing at a realtime rate.

Is this because of the way I am playing the audio file? Playing a single frame, then the next frame, then the next. Is it too many requests per second for FMOD to play smoothly?

The bizarre thing is, if I add a silent audio track and play that. It’ll create a popping sound on every frame. It’s bizarre.

Has anyone got any advice on how I could improve the code above or maybe how I could approach the problem differently to reduce the popping/crackling problem.

Thanks.
-Matt

  • You must to post comments
0
0

I just wanted to bump this in case anyone hadn’t seen it.

I’m still struggling to track down the stuttering and popping playback.

Thanks.
-Matt

  • You must to post comments
0
0

Can you reproduce the bug in a really isolated program, without all the rest of your code? If you can reproduce it in a tiny program or modifying one of the examples that come with fmod, try sending it to fmod support email. It seems they are super busy with the new Fmod Studio and some post can go unanswered, but they do answer bug reports asap.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.