Output_mp3 plugin

We try to use two samples from FMOD engine, SimpleEvent and Output_mp3, to output a mp3 file for a given event.

We first build the output_mp3L64.dll using output_mp3 project. and then use following code.

The problem is output_state->readfrommixer(output_state, destptr, l); always returns FMOD_ERR_INTERNAL. Please help us to indicate why, thank you!

/*==============================================================================
Simple Event Example
Copyright (c), Firelight Technologies Pty, Ltd 2012-2019.

This example demonstrates the various ways of playing an event.

Explosion Event

This event is played as a one-shot and released immediately after it has been
created.

Looping Ambience Event

A single instance is started or stopped based on user input.

Cancel Event

This instance is started and if already playing, restarted.

==============================================================================*/
#include “fmod_studio.hpp”
#include “fmod.hpp”
#include “common.h”

int FMOD_Main()
{
void* extraDriverData = NULL;
Common_Init(&extraDriverData);

FMOD::Studio::System* system = NULL;
ERRCHECK(FMOD::Studio::System::create(&system));

// The example Studio project is authored for 5.1 sound, so set up the system output mode to match
FMOD::System* coreSystem = NULL;
ERRCHECK(system->getCoreSystem(&coreSystem));

unsigned int pluginHandle = 0;
ERRCHECK(coreSystem->loadPlugin("output_mp3L64.dll", &pluginHandle));
ERRCHECK(coreSystem->setOutputByPlugin(pluginHandle));

ERRCHECK(coreSystem->setSoftwareFormat(0, FMOD_SPEAKERMODE_5POINT1, 0));


ERRCHECK(system->initialize(1024, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, extraDriverData));

FMOD::Studio::Bank* masterBank = NULL;
ERRCHECK(system->loadBankFile(Common_MediaPath("Master.bank"), FMOD_STUDIO_LOAD_BANK_NORMAL, &masterBank));

FMOD::Studio::Bank* stringsBank = NULL;
ERRCHECK(system->loadBankFile(Common_MediaPath("Master.strings.bank"), FMOD_STUDIO_LOAD_BANK_NORMAL, &stringsBank));

FMOD::Studio::Bank* sfxBank = NULL;
ERRCHECK(system->loadBankFile(Common_MediaPath("Sound2D.bank"), FMOD_STUDIO_LOAD_BANK_NORMAL, &sfxBank));

// Get the Single Explosion event
FMOD::Studio::EventDescription* eventDescription = NULL;
ERRCHECK(system->getEvent("event:/Sound2D/ui_boss_1", &eventDescription));

// Get instance
FMOD::Studio::EventInstance* eventInstance = NULL;
ERRCHECK(eventDescription->createInstance(&eventInstance));

ERRCHECK(eventInstance->start());

// Wait for the event to finish playing
FMOD_STUDIO_PLAYBACK_STATE state;
do {
    ERRCHECK(eventInstance->getPlaybackState(&state));
    ERRCHECK(system->update());

    Common_Sleep(50);
} while (state != FMOD_STUDIO_PLAYBACK_STOPPED);

// Release the event instance after playback
ERRCHECK(eventInstance->release());

ERRCHECK(sfxBank->unload());
ERRCHECK(stringsBank->unload());
ERRCHECK(masterBank->unload());

ERRCHECK(system->release());

Common_Close();


return 0;

}

Hi,

Thank you for sharing the information and code.

May I confirm which version of FMOD Engine you are using?

The issue is likely caused by the mixer being configured for 5.1 output.

The output_mp3 example only supports mono or stereo input, so requesting a 5.1 mix might vcause readfrommixer to return FMOD_ERR_INTERNAL.

Could you please try forcing the software format to stereo before calling initialize, for example:

ERRCHECK(coreSystem->setSoftwareFormat(48000, FMOD_SPEAKERMODE_STEREO, 0));

Let me know if the issue persists.

Thank you very much!

We changed from FMOD_SPEAKERMODE_5POINT1 to FMOD_SPEAKERMODE_STEREO, but the issue persists.

We are using FMOD Studio API Windows version 2.00.06.

We also tried FMOD Studio API Windows version 2.03.10, the problem is the same.

Thanks again!

Thanks for trying that!

I was able to reproduce the behavior you described on my side as well.
I’ve passed the details on to our dev team so they can take a closer look.

Thank you for bringing this to our attention