Mercurial > hg > audiodb
changeset 691:203181f7d804
Added checks for max length/vectors that disable the query button if invalid values are provided.
author | mas01mj |
---|---|
date | Fri, 12 Mar 2010 14:46:22 +0000 |
parents | f3268055df0a |
children | 02756c5ca15a |
files | examples/iAudioDB/AppController.m examples/iAudioDB/iAudioDB.xcodeproj/project.pbxproj |
diffstat | 2 files changed, 44 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/iAudioDB/AppController.m Fri Mar 12 14:28:18 2010 +0000 +++ b/examples/iAudioDB/AppController.m Fri Mar 12 14:46:22 2010 +0000 @@ -587,9 +587,27 @@ double hopSize = [[dbState objectForKey:@"hopsize"] doubleValue]; double winSize = [[dbState objectForKey:@"windowsize"] doubleValue]; + if(!queryTrack) + { + queryTrack = [[NSSound alloc] initWithContentsOfFile:selectedFilename byReference:YES]; + } + + double totalDuration = [queryTrack duration]; + double samples = totalDuration * 44100; + double totalVectors = ((samples-winSize)/hopSize); + if (ed == queryLengthSeconds) { double secs = [queryLengthSeconds doubleValue]; + if(secs > totalDuration) + { + [queryButton setEnabled:NO]; + } + else if(![queryButton isEnabled]) + { + [queryButton setEnabled:YES]; + } + if(secs > 0) { // (samples - windowSize) / hopSize @@ -600,6 +618,16 @@ if (ed == queryLengthVectors) { double vectors = [queryLengthVectors doubleValue]; + + if(vectors > totalVectors) + { + [queryButton setEnabled:NO]; + } + else if(![queryButton isEnabled]) + { + [queryButton setEnabled:YES]; + } + if(vectors > 0) { [queryLengthSeconds setDoubleValue:ceil(((hopSize*vectors)+winSize)/44100)];
--- a/examples/iAudioDB/iAudioDB.xcodeproj/project.pbxproj Fri Mar 12 14:28:18 2010 +0000 +++ b/examples/iAudioDB/iAudioDB.xcodeproj/project.pbxproj Fri Mar 12 14:46:22 2010 +0000 @@ -11,6 +11,10 @@ 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; + B798CFD3114A70DC00026712 /* Add.tiff in Resources */ = {isa = PBXBuildFile; fileRef = B798CFCF114A70DB00026712 /* Add.tiff */; }; + B798CFD4114A70DC00026712 /* Play.tiff in Resources */ = {isa = PBXBuildFile; fileRef = B798CFD0114A70DB00026712 /* Play.tiff */; }; + B798CFD5114A70DC00026712 /* Spotlight.tiff in Resources */ = {isa = PBXBuildFile; fileRef = B798CFD1114A70DB00026712 /* Spotlight.tiff */; }; + B798CFD6114A70DC00026712 /* Stop.tiff in Resources */ = {isa = PBXBuildFile; fileRef = B798CFD2114A70DB00026712 /* Stop.tiff */; }; B7CBF33211105F1700B8C1C8 /* AppController.m in Sources */ = {isa = PBXBuildFile; fileRef = B7CBF33111105F1700B8C1C8 /* AppController.m */; }; B7CBF3B711106F4C00B8C1C8 /* libaudioDB.0.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B7CBF3B611106F4C00B8C1C8 /* libaudioDB.0.0.dylib */; }; B7E0FD5B114164430003AB08 /* BWToolkitFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B7E0FD5A114164430003AB08 /* BWToolkitFramework.framework */; }; @@ -41,6 +45,10 @@ 32CA4F630368D1EE00C91783 /* iAudioDB_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iAudioDB_Prefix.pch; sourceTree = "<group>"; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 8D1107320486CEB800E47090 /* iAudioDB.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iAudioDB.app; sourceTree = BUILT_PRODUCTS_DIR; }; + B798CFCF114A70DB00026712 /* Add.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Add.tiff; path = ../../../../Downloads/devicons/Add.tiff; sourceTree = SOURCE_ROOT; }; + B798CFD0114A70DB00026712 /* Play.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Play.tiff; path = ../../../../Downloads/devicons/Play.tiff; sourceTree = SOURCE_ROOT; }; + B798CFD1114A70DB00026712 /* Spotlight.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Spotlight.tiff; path = ../../../../Downloads/devicons/Spotlight.tiff; sourceTree = SOURCE_ROOT; }; + B798CFD2114A70DB00026712 /* Stop.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Stop.tiff; path = ../../../../Downloads/devicons/Stop.tiff; sourceTree = SOURCE_ROOT; }; B7CBF33011105F1700B8C1C8 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; }; B7CBF33111105F1700B8C1C8 /* AppController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppController.m; sourceTree = "<group>"; }; B7CBF3B611106F4C00B8C1C8 /* libaudioDB.0.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libaudioDB.0.0.dylib; path = /usr/local/lib/libaudioDB.0.0.dylib; sourceTree = "<absolute>"; }; @@ -121,6 +129,10 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + B798CFCF114A70DB00026712 /* Add.tiff */, + B798CFD0114A70DB00026712 /* Play.tiff */, + B798CFD1114A70DB00026712 /* Spotlight.tiff */, + B798CFD2114A70DB00026712 /* Stop.tiff */, 8D1107310486CEB800E47090 /* Info.plist */, 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, 1DDD58140DA1D0A300B32029 /* MainMenu.xib */, @@ -184,6 +196,10 @@ files = ( 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, 1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */, + B798CFD3114A70DC00026712 /* Add.tiff in Resources */, + B798CFD4114A70DC00026712 /* Play.tiff in Resources */, + B798CFD5114A70DC00026712 /* Spotlight.tiff in Resources */, + B798CFD6114A70DC00026712 /* Stop.tiff in Resources */, ); runOnlyForDeploymentPostprocessing = 0; };