Non realtime wav writer


(groovin) #1

I’m attempting to mixdown some audio files to a WAV file in faster than realtime but I’m getting the following error:

FMOD error! (46) A call to a standard soundcard driver failed, which could possibly mean a bug in the driver or resources were missing or exhausted.

Doing this in realtime works fine (but slow of course). I would not expect to have any hardware dependencies if using the software playback.

I have been trying this with Jerome Jouvie’s NativeFModEx Java wrapper.

My code is:

 private System createMixdownSystem( boolean realtime, String filename )
    {
        System mixdownSystem  = new System();

        ERRCHECK( FmodEx.System_Create(mixdownSystem) );
        
        // Write to file specified in the init call
        if (realtime)
            mixdownSystem.setOutput( FMOD_OUTPUTTYPE.FMOD_OUTPUTTYPE_WAVWRITER );
        else
            mixdownSystem.setOutput( FMOD_OUTPUTTYPE.FMOD_OUTPUTTYPE_WAVWRITER_NRT );
        
         if (filename != null)
         {
            // Wrap the filename string in an ObjectPointer
            ByteBuffer buffer = BufferUtils.newByteBuffer(filename.length() + 1 );
            
            BufferUtils.putString(buffer, filename);
            buffer.rewind();        // Must rewind to beginning of buffer
            
            Pointer filenamePtr = BufferUtils.createView(buffer);

            // Use FMOD_INIT_STREAM_FROM_UPDATE flag to lock stream reading with update() thread
            // to avoid skipping audio.
            //
            if (realtime)
                ERRCHECK( mixdownSystem.init(32, FMOD_INITFLAGS.FMOD_INIT_NORMAL, filenamePtr));
            else
                ERRCHECK( mixdownSystem.init(32, FMOD_INITFLAGS.FMOD_INIT_STREAM_FROM_UPDATE, filenamePtr));
         }
         else
         {
             ERRCHECK( mixdownSystem.init(32, FMOD_INITFLAGS.FMOD_INIT_NORMAL, null));
         }

        return mixdownSystem;
    }

Any help would be much appreciated!


(jouvieje) #2

FMOD Ex 4.02.03 don’t fix this error :

FMOD error! (46) A call to a standard soundcard driver failed, which could possibly mean a bug in the driver or resources were missing or exhausted.

Here is a little more precisions.
This works :

 mixdownSystem.setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT);
 mixdownSystem.init(32, FMOD_INIT_STREAM_FROM_UPDATE, null);

But this not :

 mixdownSystem.setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT);
 mixdownSystem.init(32, FMOD_INIT_STREAM_FROM_UPDATE, filename);	//Same error with FMOD_INIT_NORMAL

This seem to be a problem in FMOD_OUTPUTTYPE_WAVWRITER_NRT when passing a filename.
Note :
There is no problem with FMOD_OUTPUTTYPE_WAVWRITER when a filename is passed.

Can you check this Brett ?

Thanks


(groovin) #3

I compared fmod.h used in version 4.02.02 with the one used in the Java wrapper and they match. Interestingly, after setting the output, I call “mixdownSystem.getOutput()” which returns FMOD_OUTPUTTYPE_AUTODETECT. That explains the error message I originally received but the question is why is it not getting set correctly? It appears like the Java wrapper code is doing the right thing.

Thanks again :slight_smile:


(jouvieje) #4

ERRCHECK was not called in setOutput.
The error come from system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT) and not from init :

FMOD error! (53) A requested output, dsp unit type or codec was not available. 

This error is generated by the line setOutput from this C++ code (FMOD Ex 4.02.03 & WIN) :

    /*
        Create a System object and initialize.
    */
    result = FMOD::System_Create(&system);
    ERRCHECK(result);

    result = system->getVersion(&version);
    ERRCHECK(result);

    if (version < FMOD_VERSION)
    {
        printf("Error!  You are using an old version of FMOD %08x.  This program requires %08x\n", version, FMOD_VERSION);
        return 0;
    }
	
    result = system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT);	//error 53 here
    ERRCHECK(result);

    result = system->init(32, FMOD_INIT_STREAM_FROM_UPDATE, 0);
    ERRCHECK(result);

setOutputByPlugin works with the index of FMOD_OUTPUTTYPE_WAVWRITER_NRT.
But, if we want to select FMOD_OUTPUTTYPE_WAVWRITER_NRT with setOuput, it don’t works (error 53).

All the other outputs works with setOuput and this code, but NOT WAVWRITER_NRT.
FMOD Ex don’t seem to recognize the FMOD_OUTPUTTYPE_WAVWRITER_NRT enum field.

Tell me if something is bad in the code.

Rem: this is tested from C++, so no problem from Java side.


(groovin) #5

Calling setOutputByPlugin() solves the problem I was having. You guys are great.