Mercurial > hg > audiodb
comparison examples/iAudioDB/AppController.m @ 688:8bc10774e56b
Disabled query button if no query file selected.
author | mas01mj |
---|---|
date | Fri, 12 Mar 2010 11:54:02 +0000 |
parents | e2f4924130ef |
children | 015e361e5baa |
comparison
equal
deleted
inserted
replaced
687:e2f4924130ef | 688:8bc10774e56b |
---|---|
137 [plistFilename release]; | 137 [plistFilename release]; |
138 [trackMap release]; | 138 [trackMap release]; |
139 [dbState release]; | 139 [dbState release]; |
140 } | 140 } |
141 | 141 |
142 if(selectedKey) | |
143 { | |
144 NSLog(@"Released selected key: %@", selectedKey); | |
145 [selectedKey release]; | |
146 selectedKey = Nil; | |
147 NSLog(@"Is now %@", selectedKey); | |
148 } | |
149 | |
150 if(selectedKey) | |
151 { | |
152 NSLog(@"Still evals"); | |
153 } | |
154 | |
142 // Reset query flags | 155 // Reset query flags |
143 [queryPath setStringValue: @"No file selected"]; | 156 [queryPath setStringValue: @"No file selected"]; |
144 [queryLengthSeconds setDoubleValue:0]; | 157 [queryLengthSeconds setDoubleValue:0]; |
145 [queryLengthVectors setDoubleValue:0]; | 158 [queryLengthVectors setDoubleValue:0]; |
146 [multipleCheckBox setState:NSOnState]; | 159 [multipleCheckBox setState:NSOnState]; |
219 } | 232 } |
220 else | 233 else |
221 { | 234 { |
222 NSLog(@"No db"); | 235 NSLog(@"No db"); |
223 [performQueryButton setEnabled:NO]; | 236 [performQueryButton setEnabled:NO]; |
224 [playBothButton setEnabled:FALSE]; | 237 [playBothButton setEnabled:NO]; |
225 [playResultButton setEnabled:FALSE]; | 238 [playResultButton setEnabled:NO]; |
226 } | 239 } |
227 } | 240 } |
228 | 241 |
229 /** | 242 /** |
230 * Choose the file(s) to be imported. | 243 * Choose the file(s) to be imported. |
247 [NSApp runModalSession:session]; | 260 [NSApp runModalSession:session]; |
248 | 261 |
249 NSArray *filesToOpen = [panel filenames]; | 262 NSArray *filesToOpen = [panel filenames]; |
250 | 263 |
251 NSString* extractor = [dbState objectForKey:@"extractor"]; | 264 NSString* extractor = [dbState objectForKey:@"extractor"]; |
252 NSString* extractorPath = [NSString stringWithFormat:@"/Users/mikej/Development/audioDB/examples/iAudioDB/rdf/%@.n3", extractor]; | 265 NSString* extractorPath = [NSString stringWithFormat:@"/Applications/iAudioDB.app/rdf/%@.n3", extractor]; |
253 | 266 |
254 // TODO Shift this process into a separate function. | 267 // TODO Shift this process into a separate function. |
255 // Create the customized extractor config | 268 // Create the customized extractor config |
256 NSString* extractorContent = [NSString stringWithContentsOfFile:extractorPath]; | 269 NSString* extractorContent = [NSString stringWithContentsOfFile:extractorPath]; |
257 NSString* hopStr = [dbState objectForKey:@"hopsize"]; | 270 NSString* hopStr = [dbState objectForKey:@"hopsize"]; |
509 /** | 522 /** |
510 * Select an audio file, determine the key, and fire off a query. | 523 * Select an audio file, determine the key, and fire off a query. |
511 */ | 524 */ |
512 -(IBAction)chooseQuery:(id)sender | 525 -(IBAction)chooseQuery:(id)sender |
513 { | 526 { |
527 [queryButton setEnabled:(selectedKey ? YES : NO)]; | |
514 [NSApp beginSheet:querySheet modalForWindow:mainWindow modalDelegate:self didEndSelector:NULL contextInfo:nil]; | 528 [NSApp beginSheet:querySheet modalForWindow:mainWindow modalDelegate:self didEndSelector:NULL contextInfo:nil]; |
515 session = [NSApp beginModalSessionForWindow:querySheet]; | 529 session = [NSApp beginModalSessionForWindow:querySheet]; |
516 [NSApp runModalSession:session]; | 530 [NSApp runModalSession:session]; |
517 } | 531 } |
518 | 532 |
540 { | 554 { |
541 selectedKey = [opts objectAtIndex:0]; | 555 selectedKey = [opts objectAtIndex:0]; |
542 [queryKey setStringValue:selectedKey]; | 556 [queryKey setStringValue:selectedKey]; |
543 [queryPath setStringValue:selectedKey]; | 557 [queryPath setStringValue:selectedKey]; |
544 selectedFilename = [[panel filename] retain]; | 558 selectedFilename = [[panel filename] retain]; |
559 [queryButton setEnabled:YES]; | |
545 | 560 |
546 [self resetLengths:self]; | 561 [self resetLengths:self]; |
547 } | 562 } |
548 } | 563 } |
549 } | 564 } |
571 if (ed == queryLengthSeconds) | 586 if (ed == queryLengthSeconds) |
572 { | 587 { |
573 double secs = [queryLengthSeconds doubleValue]; | 588 double secs = [queryLengthSeconds doubleValue]; |
574 if(secs > 0) | 589 if(secs > 0) |
575 { | 590 { |
591 // (samples - windowSize) / hopSize | |
592 | |
576 [queryLengthVectors setDoubleValue:ceil(((secs*44100)-winSize)/hopSize)]; | 593 [queryLengthVectors setDoubleValue:ceil(((secs*44100)-winSize)/hopSize)]; |
577 } | 594 } |
578 } | 595 } |
579 if (ed == queryLengthVectors) | 596 if (ed == queryLengthVectors) |
580 { | 597 { |