Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute MFCC from audio file for iOS apps #219

Closed
Bee-HN opened this issue Dec 10, 2018 · 2 comments
Closed

Compute MFCC from audio file for iOS apps #219

Bee-HN opened this issue Dec 10, 2018 · 2 comments

Comments

@Bee-HN
Copy link

Bee-HN commented Dec 10, 2018

Hello, I am new to iOS development and Aubio. Can someone show me how to compute the mfcc from audio input file? So far, I manage to load audio file following the example from aubio's documentation;
below is my code in Objective-C:

unsigned int hop_size = 512;
fvec_t *f_vector = new_fvec(hop_size);
aubio_source_t *new_source = new_aubio_source(audio_file_path, 0, hop_size);
// smpl_t samplerate = aubio_source_get_samplerate(new_source);
unsigned int read = 0;
unsigned int total_frames = 0;
int count = 0;
while (true)
{
aubio_source_do(new_source, f_vector, &read);
total_frames += read;
count += 1;
if (read < hop_size)
{
break;
}
}
NSLog (@"Read: %u frames at: %u Hz", total_frames, aubio_source_get_samplerate(new_source));
NSLog (@"Data Vector:");
fvec_print(f_vector);

Thank you

@piem
Copy link
Member

piem commented Dec 11, 2018

hi @Bee-HN

The file tests/src/spectral/test-mfcc.c was just updated to a more complete example, see 423a427 (the branch will be merged in master once the tests have passed).

Could you share the line where audio_file_path is declared? @socalledsound mentioned having troubles with this in #179.

thanks, piem

@piem piem closed this as completed in 423a427 Dec 11, 2018
@Bee-HN
Copy link
Author

Bee-HN commented Dec 13, 2018

Hi piem,
This is my code to get the file path of the audio file

NSString *file_path_string = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:@"name_of_audio_file.m4a"];

const char *audio_file_path = [file_path_string UTF8String];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants