Mercurial > hg > audiodb
comparison examples/iAudioDB/AppController.m @ 705:1214e1da5b8d
* Initial installer project
* Tweaks to code to use bundle paths
author | mas01mj |
---|---|
date | Thu, 03 Jun 2010 15:59:24 +0000 |
parents | df35c9c976a0 |
children | 6d3ed50c9d2d |
comparison
equal
deleted
inserted
replaced
704:df35c9c976a0 | 705:1214e1da5b8d |
---|---|
223 { | 223 { |
224 NSLog(@"Got a db"); | 224 NSLog(@"Got a db"); |
225 adb_status_t *status = (adb_status_t *)malloc(sizeof(adb_status_t)); | 225 adb_status_t *status = (adb_status_t *)malloc(sizeof(adb_status_t)); |
226 int flags; | 226 int flags; |
227 flags = audiodb_status(db, status); | 227 flags = audiodb_status(db, status); |
228 [statusField setStringValue: [NSString stringWithFormat:@"%@ Dim: %d Files: %d Hop: %@ Ext: %@", | 228 [statusField setStringValue: [NSString stringWithFormat:@"%@ Dim: %d Files: %d Slice: %@ms Ext: %@", |
229 dbName, | 229 dbName, |
230 status->dim, | 230 status->dim, |
231 status->numFiles, | 231 status->numFiles, |
232 [dbState objectForKey:@"hopsize"], | 232 [dbState objectForKey:@"hopsize"], |
233 [dbState objectForKey:@"extractor"]]]; | 233 [dbState objectForKey:@"extractor"]]]; |
305 NSString* featuresFileName = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:tempFileNameCString length:strlen(tempFileNameCString)]; | 305 NSString* featuresFileName = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:tempFileNameCString length:strlen(tempFileNameCString)]; |
306 free(tempFileNameCString); | 306 free(tempFileNameCString); |
307 | 307 |
308 // Extract features with sonic-annotator | 308 // Extract features with sonic-annotator |
309 NSTask* task = [[NSTask alloc] init]; | 309 NSTask* task = [[NSTask alloc] init]; |
310 [task setLaunchPath:@"/usr/local/bin/sonic-annotator"]; | 310 |
311 NSString* extractPath = [ [ NSBundle mainBundle ] pathForAuxiliaryExecutable: @"sonic-annotator" ]; | |
312 [task setLaunchPath:extractPath]; | |
313 | |
311 NSArray* args; | 314 NSArray* args; |
312 args = [NSArray arrayWithObjects:@"-t", n3FileName, @"-w", @"rdf", @"-r", @"--rdf-network", @"--rdf-one-file", featuresFileName, @"--rdf-force", filename, nil]; | 315 args = [NSArray arrayWithObjects:@"-t", n3FileName, @"-w", @"rdf", @"-r", @"--rdf-network", @"--rdf-one-file", featuresFileName, @"--rdf-force", filename, nil]; |
313 [task setArguments:args]; | 316 [task setArguments:args]; |
314 [task launch]; | 317 [task launch]; |
315 [task waitUntilExit]; | 318 [task waitUntilExit]; |
316 [task release]; | 319 [task release]; |
317 | 320 |
318 // Populate the audioDB instance | 321 // Populate the audioDB instance |
319 NSTask* importTask = [[NSTask alloc] init]; | 322 NSTask* importTask = [[NSTask alloc] init]; |
320 [importTask setLaunchPath:@"/usr/local/bin/populate"]; | 323 NSString* importPath = [ [ NSBundle mainBundle ] pathForAuxiliaryExecutable: @"populate" ]; |
324 [importTask setLaunchPath:importPath]; | |
321 args = [NSArray arrayWithObjects:featuresFileName, dbFilename, nil]; | 325 args = [NSArray arrayWithObjects:featuresFileName, dbFilename, nil]; |
322 [importTask setArguments:args]; | 326 [importTask setArguments:args]; |
323 [importTask launch]; | 327 [importTask launch]; |
324 [importTask waitUntilExit]; | 328 [importTask waitUntilExit]; |
325 [importTask release]; | 329 [importTask release]; |
329 | 333 |
330 // Update the plist store. | 334 // Update the plist store. |
331 [trackMap setValue:val forKey:key]; | 335 [trackMap setValue:val forKey:key]; |
332 [dbState writeToFile:plistFilename atomically: YES]; | 336 [dbState writeToFile:plistFilename atomically: YES]; |
333 | 337 |
338 | |
334 } | 339 } |
335 | 340 |
336 /** | 341 /** |
337 * Choose the file(s) to be imported. | 342 * Choose the file(s) to be imported. |
338 */ | 343 */ |
353 [NSApp runModalSession:session]; | 358 [NSApp runModalSession:session]; |
354 | 359 |
355 NSArray *filesToOpen = [panel filenames]; | 360 NSArray *filesToOpen = [panel filenames]; |
356 | 361 |
357 NSString* extractor = [dbState objectForKey:@"extractor"]; | 362 NSString* extractor = [dbState objectForKey:@"extractor"]; |
358 NSString* extractorPath = [NSString stringWithFormat:@"/Applications/iAudioDB.app/rdf/%@.n3", extractor]; | 363 |
364 NSLog([NSString stringWithFormat:@"rdf/%@.n3", extractor]); | |
365 NSString* extractorPath = [ [ NSBundle mainBundle ] pathForResource:extractor ofType:@"n3" inDirectory:@"rdf"]; | |
366 NSLog(@"Extractor path: %@", extractorPath); | |
367 | |
368 // NSString* extractorPath = [NSString stringWithFormat:@"/Applications/iAudioDB.app/rdf/%@.n3", extractor]; | |
359 | 369 |
360 for(int i=0; i<[filesToOpen count]; i++) | 370 for(int i=0; i<[filesToOpen count]; i++) |
361 { | 371 { |
362 audiodb_close(db); | 372 audiodb_close(db); |
363 | 373 |