0
0

Hi,

I want to put output of multiple played sound to an output file.

So i look after : FMOD_OUTPUTTYPE_WAVWRITER_NRT.

// …system created…
result = system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT);
ERRCHECK(result);

// … file creation, and buffer contain the path to the file…
result = system->init(32, FMOD_INIT_STREAM_FROM_UPDATE, buffer);
ERRCHECK(result);

But I don’t understand what i’ve to do then : do I have to do like in the recordtodisk example ?
So i need to create a sound, write his header to a wav file and his output…

Regards ?

  • You must to post comments
0
0

Once you call init, and specify that path to the output file that is all. Anything you play will be sent to the file instead of the speakers.

You don’t have to do anything extra, the creation of the wave file is automatic, you don’t need to write a header.

  • You must to post comments
0
0

Ok, i saw that the file is 655k (so data is written into).

My problem is that VLC can’t play the file : audio lenght is zero seconds (instead of 6secs).

Can i use DSPs without problem in this mode ?

  • You must to post comments
0
0

Make sure that you call System::release() before exiting your application. It is during release that we write the length information into the wav file.

In this mode everything works as usual, the only difference is the final output is sent to a file instead of the speakers. So you can use DSPs or any other usual FMOD features.

  • You must to post comments
0
0

The issue is that i call release. The command "ffmpeg -i generated.wav" reports correctly the duration of the wav.

Maybe my while stop test isn’t correct ?
My code :
[code:38n3cxue]

  • (void)recordPitchedSound:(PisteAudio*)piste {
    FMOD_RESULT result = FMOD_OK;
    char buffer[200] = {0};
    unsigned int ms = 0;
    unsigned int lenms = 0;
    unsigned int played = 0;
    int channelsplaying = 0;

    FMOD::Sound *currentsound = NULL;

    FMOD::System *recordSystem = [FMODSystem createRecordAudioToOutFileSystem:[piste pathToPitchedWav]];

    [[piste pathToWav] getCString:buffer maxLength:200 encoding:NSASCIIStringEncoding];
    result = recordSystem->createSound(buffer, FMOD_SOFTWARE, NULL, &sound);
    ERRCHECK(result);

    result = sound->setMode(FMOD_LOOP_OFF);
    ERRCHECK(result);

    if( [piste hasPitch] ){
    hasPitch = true;
    dureePiste = [piste.secondes doubleValue];
    numberOfPoints = [piste pitchPointsNumber];
    mSecondsBetweenTwoPoints = [piste pitchGap];
    points = (float*) malloc( [[piste pitchData] length]);
    memcpy(points, [[piste pitchData] bytes], [[piste pitchData] length]);
    currentPitchValue = -1;
    result = recordSystem->createDSPByType(FMOD_DSP_TYPE_PITCHSHIFT, &dspPitch);
    ERRCHECK(result);

    [self setPitchForTime:0];
    

    } else
    hasPitch = false;

    result = recordSystem->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
    ERRCHECK(result);

    result = channel->setVolume( [piste.volume floatValue] );
    ERRCHECK(result);

    if( hasPitch ) {
    result = channel->addDSP(dspPitch, NULL);
    ERRCHECK(result);
    }

    do {
    result = channel->getCurrentSound(&currentsound);
    if (currentsound != NULL)
    {
    result = currentsound->getLength(&lenms, FMOD_TIMEUNIT_MS);
    if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
    {
    ERRCHECK(result);
    }

        result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS); // milliseconds
        if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
        {
            ERRCHECK(result);
        }
        played = ms;
    
        if( played < lenms && hasPitch )
            [self setPitchForTime:playedms];
    
    
        if (recordSystem != NULL) {
            result = recordSystem->getChannelsPlaying(&channelsplaying);
            ERRCHECK(result);
    
            result = recordSystem->update();
            ERRCHECK(result);
        }
    }
    

    } while( currentsound );

    [self stop]; // remove dsp & release played sound

    recordSystem->release(); // appel close
    recordSystem = NULL;
    }
    [/code:38n3cxue]

  • You must to post comments
0
0

Hmm, I just did a quick test, it would appear something is broken with the non-realtime wave writer, the normal wave writer works.

I am out of time today but I will look into this for you first thing tomorrow.

  • You must to post comments
0
0

Thanks for the bug report, I have found the problem.

We just did a build last night (pending upload) so this fix will be in the release after that.

  • You must to post comments
0
0

Where can I download this release ? Is it the Development Version: 4.27.09 ?

Regards

  • You must to post comments
0
0

It will be 4.27.11, as I said we have a version pending upload that is already built so the bug fix has not made it into that release. The fix will be in the next release.

  • You must to post comments
0
0

Ok, thanks a lot.

  • You must to post comments
Showing 9 results
Your Answer

Please first to submit.