0
0

hi ,
I am using offlineDecoding sample to decode my midi file. but when i ran the code the while loop keeps going on forever . I forcefully stopped the code and when i saw it in the temporary files then it has already created a 4.76 GB file.
So that looks obvious that the code is not getting the end of file (EOF) for midi.
Any update on how it can be done.

Thanks in advance

Regards

Tauheed yar khan

  • You must to post comments
0
0

If you used the same MIDI file in the playstream example, do you hear the music?

  • George
  • You must to post comments
0
0

When I stopped the application I saw a 4.76 GB mid file . When I tried to play the application threw an error.

Regards

Tauheed

  • You must to post comments
0
0

Hello,

I did a little test and looked at the console when the application was running (Command-Shift-R). I got the following error:

FMOD error! (69) A resource that the plugin requires cannot be found. (ie the DLS file for MIDI playback).

This is possibly because I didn’t specify a DLS file using FMOD_CREATESOUNDEXINFO in the createSound call. I guess you may need to get a DLS file first and add it to a new FMOD_CREATESOUNDEXINFO structure, which would be passed to createSound.

  • George
  • You must to post comments
0
0

Hi ,
I am using windows DLS file in my code and it is working for midi playback.

Regards

Tauheed

  • You must to post comments
0
0

Hello,

I think I see the same problem you’re seeing. The playsound example works great, but offlinedecoding example spits out huge files really quickly.

This is the code I was using for offlinedecoding:

[code:2gmemg27]
FMOD_CREATESOUNDEXINFO exinfo;

char dlsname[4096] = {0};
[[NSString stringWithFormat:@"%@/gm16.dls", [[NSBundle mainBundle] resourcePath]] getCString:dlsname maxLength:4096 encoding:NSASCIIStringEncoding];

memset( &exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO) );
exinfo.cbsize           = sizeof( FMOD_CREATESOUNDEXINFO );
exinfo.dlsname  = dlsname;

[[NSString stringWithFormat:@"%@/Blackbird.mid", [[NSBundle mainBundle] resourcePath]] getCString:buffer maxLength:200 encoding:NSASCIIStringEncoding];
result = system->createSound(buffer, FMOD_SOFTWARE| FMOD_OPENONLY | FMOD_ACCURATETIME, &exinfo, &sound);
ERRCHECK(result);

[/code:2gmemg27]

In a reply to one of your other posts on this subject, Mathew mentioned writing a DSP that would spit out the combination of two audio sounds (one being the recorded vocals and the other being the output of the MIDI) to a single file, but I’m afraid I can’t help you there. Probably by looking at the custom DSP code you could just take that and output the values to a file instead of changing the values.

  • George
  • You must to post comments
0
0

Sorry for late reply … I am using exactly the same code as given by you but i am stil getting problem in decoding midi file using following code from offlicedecoder sample code.

[code:247dkksk]- (IBAction)decodeSound:(id)sender
{
const unsigned int CHUNKSIZE = 4096;
FMOD_RESULT result = FMOD_OK;
char buffer[200] = {0};
unsigned int length = 0;
FILE *outFile = NULL;
void *data = NULL;
unsigned int bytesRead = 0;
unsigned int read = 0;

result = sound->getLength(&length, FMOD_TIMEUNIT_PCMBYTES);
ERRCHECK(result);

[[NSString stringWithFormat:@"%@/output.raw", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]] getCString:buffer maxLength:200 encoding:NSASCIIStringEncoding];
outFile = fopen(buffer, "wb");
if (!outFile)
{
    fprintf(stderr, "Error! Could not open output.raw output file.\n");
    return;
}

data = malloc(CHUNKSIZE);
if (!data)
{
    fprintf(stderr, "Error! Failed to allocate %d bytes.\n", CHUNKSIZE);
    return;
}


bytesRead = 0;
do
{
  result = sound->readData((char *)data, CHUNKSIZE, &read);

    fwrite((char *)data, read, 1, outFile);

    bytesRead   += read;

    status.text  = [NSString stringWithFormat:@"Written %d bytes of %d to output.raw", bytesRead, length];
}
 while (result == FMOD_OK && read == CHUNKSIZE);

readDataSize= i * CHUNKSIZE;
/*
    Loop terminates when either 
    1. the read function returns an error.  (ie FMOD_ERR_FILE_EOF etc).
    2. the amount requested was different to the amount returned. (somehow got an EOF without the file error, maybe a non stream file format like mod/s3m/xm/it/midi).

    If 'bytesread' is bigger than 'length' then it just means that FMOD miscalculated the size, 
    but this will not usually happen if FMOD_ACCURATETIME is used.  (this will give the correct length for VBR formats)
*/

if (outFile)
{
    fclose(outFile);
    outFile = NULL;
}

}

[/code:247dkksk]

In this code the data keeps running do while loop for infini time creating GB’s of data when i stop the code while the original midi file size is near 4KB.

Is there any other way to store midi file from the stream Or if this a known bug when we can expect that it will get resolved.

Regards

Tauheed

  • You must to post comments
0
0

You can just stop the loop when bytesRead is more than length. As a warning though, MIDI files can be quite large when dumped out to file. Also be aware that some of the tracked formats can have loops so some sanity checking on the size return by getLength might be prudent too.

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.