0
0

I’m saving output with WAVWRITER but manipulation with channel do not affect the result.
In the second method I try reduce the volume slowly. And when I comment the line setting output to wavwriter to listen what’s going on, everything looks correct. But not with wavwriter.

What’s the matter?

[code:vi2sb9m4]#pragma mark File Saving
– (void)saveSoundWithInstrument:(int)instrument andNote:(int)note toFile:(NSString *)file
{
char cDest[200] = {0};
char cSrc[200] = {0};

FMOD::System * rSystem;
FMOD::Sound * rDls;
FMOD::Sound * rSound;

FMOD_RESULT rResult = FMOD_OK;

int noteNum = [self noteFromSymbol:note];
float freq = [self freqFromNote:noteNum];

NSString * src = [NSString stringWithFormat:@"%@/instr.dls", [[NSBundle mainBundle] resourcePath]];
[src getCString:cSrc maxLength:200 encoding:NSASCIIStringEncoding];
NSString * dest = file;
[dest getCString:cDest maxLength:200 encoding:NSASCIIStringEncoding];

rResult = FMOD::System_Create(&rSystem); 
ERRCHECK(rResult);

rSystem->setOutput(FMOD_OUTPUTTYPE_WAVWRITER);
ERRCHECK(rResult);

rResult = rSystem->init(32, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE, cDest);
ERRCHECK(rResult);

rResult = rSystem->createSound(cSrc, FMOD_SOFTWARE, NULL, &rDls);
ERRCHECK(rResult);

rResult = dls->getSubSound(instrument, &rSound);
ERRCHECK(rResult);

NSDictionary * args = [[NSDictionary alloc] initWithObjectsAndKeys:
                       [NSValue valueWithPointer:rSystem], @"system",
                       [NSValue valueWithPointer:rSound], @"sound",
                       [NSNumber numberWithFloat:freq], @"frequency",
                       nil];
[self performSelectorOnMainThread:@selector(doSaving:) withObject:args waitUntilDone:YES];

}

  • (void)doSaving:(NSDictionary *)args
    {
    float vol = 1.0;
    float freq = [[args objectForKey:@"frequency"] floatValue];
    FMOD::System * rSystem = (FMOD::System *)[[args objectForKey:@"system"] pointerValue];
    FMOD::Sound * rSound = (FMOD::Sound *)[[args objectForKey:@"sound"] pointerValue];
    FMOD::Channel * rChannel;

    FMOD_RESULT rResult = FMOD_OK;

    rResult = rSystem->playSound(FMOD_CHANNEL_FREE, rSound, false, &rChannel);
    ERRCHECK(rResult);

    rResult = rChannel->setFrequency(freq);
    ERRCHECK(rResult);

    rResult = rChannel->setVolume(vol);
    ERRCHECK(rResult);

    usleep(2000 * 500);

    while (true)
    {
    vol = vol – 0.2;
    rChannel->setVolume(vol);
    rSystem->update();
    ERRCHECK(rResult);
    usleep(25 * 2000);
    if (vol <= 0.0)
    break;
    }
    rChannel->stop();
    ERRCHECK(rResult);

    rResult = rSystem->release();
    ERRCHECK(rResult);

    [args release];
    }

pragma mark File Saving[/code:vi2sb9m4]

  • You must to post comments
0
0

The output from wavwriter should be exactly the same as what comes out of the speakers normally. Can you check the date modified of the output .wav you’re testing to make sure it’s the right one?

  • You must to post comments
0
0

Thanks fast reply.

I didn’t change anything but now everything works correct.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.