| free(frame); | free(frame); | ||||
| } | } | ||||
| int LoadFrame(SpectFrame *frame, FILE *stream, int file_format_type) | |||||
| static espeak_ng_STATUS LoadFrame(SpectFrame *frame, FILE *stream, int file_format_type) | |||||
| { | { | ||||
| short ix; | short ix; | ||||
| short x; | short x; | ||||
| spect_data = malloc(sizeof(USHORT) * frame->nx); | spect_data = malloc(sizeof(USHORT) * frame->nx); | ||||
| if (spect_data == NULL) { | |||||
| fprintf(stderr, "Failed to allocate memory\n"); | |||||
| return 1; | |||||
| } | |||||
| if (spect_data == NULL) | |||||
| return ENOMEM; | |||||
| frame->max_y = 0; | frame->max_y = 0; | ||||
| for (ix = 0; ix < frame->nx; ix++) { | for (ix = 0; ix < frame->nx; ix++) { | ||||
| } | } | ||||
| frame->spect = spect_data; | frame->spect = spect_data; | ||||
| return 0; | |||||
| return ENS_OK; | |||||
| } | } | ||||
| double GetFrameRms(SpectFrame *frame, int seq_amplitude) | double GetFrameRms(SpectFrame *frame, int seq_amplitude) | ||||
| if (!frame) | if (!frame) | ||||
| return ENOMEM; | return ENOMEM; | ||||
| if (LoadFrame(frame, stream, spect->file_format) != 0) { | |||||
| espeak_ng_STATUS status = LoadFrame(frame, stream, spect->file_format); | |||||
| if (status != ENS_OK) { | |||||
| free(frame); | free(frame); | ||||
| break; | |||||
| return status; | |||||
| } | } | ||||
| spect->frames[spect->numframes++] = frame; | spect->frames[spect->numframes++] = frame; |