Skip to content

SoundAnalysis watchOS xcode13.0 beta1

tj_devel709 edited this page Jul 22, 2021 · 3 revisions

#SoundAnalysis.framework https://github.com/xamarin/xamarin-macios/pull/12181

diff -ruN /Applications/Xcode_12.5.0.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNClassificationResult.h /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNClassificationResult.h
--- /Applications/Xcode_12.5.0.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNClassificationResult.h	2021-03-16 05:19:19.000000000 -0400
+++ /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNClassificationResult.h	2021-06-02 07:35:05.000000000 -0400
@@ -8,6 +8,7 @@
 #import <Foundation/Foundation.h>
 #import <CoreMedia/CoreMedia.h>
 #import <SoundAnalysis/SNDefines.h>
+#import <SoundAnalysis/SNTypes.h>
 #import <SoundAnalysis/SNResult.h>
 
 NS_ASSUME_NONNULL_BEGIN
@@ -21,12 +22,12 @@
 /*!
  @brief The identifier of a classification request. An example classification could be a string like 'laughter' or 'applause'. The string is defined in the model that was used for the classification. Usually these are technical labels that are not localized and not meant to be used directly to be presented to an end user in the UI.
  */
-@property (readonly) NSString *identifier;
+@property (readonly, copy) NSString *identifier;
 
 /*!
  @brief The level of confidence normalized to [0, 1], where 1 is most confident
  */
-@property (readonly) double confidence;
+@property (readonly, assign) double confidence;
 
 - (instancetype)init NS_UNAVAILABLE;
 + (instancetype)new NS_UNAVAILABLE;
@@ -40,9 +41,9 @@
 @interface SNClassificationResult : NSObject <SNResult>
 
 /*!
- @brief The top classification candidates, sorted with highest confidence first
+ @brief All classification candidates, sorted with highest confidence first.
  */
-@property (readonly) NSArray<SNClassification *> *classifications;
+@property (readonly, copy) NSArray<SNClassification *> *classifications;
 
 /*!
  @brief The time range in the client-provided audio stream to which this classification result corresponds
@@ -53,6 +54,14 @@
 - (instancetype)init NS_UNAVAILABLE;
 + (instancetype)new NS_UNAVAILABLE;
 
+/*!
+ @brief Retrieves the classification candidate with the specified identifier.
+ @param identifier An identifier on which to query for a particular classification candidate. The query will match to any classification candidate whose `identifier` property (see `identifier` property of `SNClassification`) contains a value equal to the provided argument.
+ @result The classification candidate which has the specified identifier, if it exists. If no such candidate exists, `nil` will be returned.
+ */
+- (nullable SNClassification *)classificationForIdentifier:(NSString *)identifier
+    API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0), watchos(8.0));
+
 @end
 
 NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_12.5.0.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNClassifySoundRequest.h /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNClassifySoundRequest.h
--- /Applications/Xcode_12.5.0.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNClassifySoundRequest.h	2021-03-16 05:19:19.000000000 -0400
+++ /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNClassifySoundRequest.h	2021-06-02 11:05:23.000000000 -0400
@@ -7,11 +7,16 @@
 
 #import <Foundation/Foundation.h>
 #import <CoreML/CoreML.h>
+#import <CoreMedia/CoreMedia.h>
+
 #import <SoundAnalysis/SNDefines.h>
+#import <SoundAnalysis/SNTypes.h>
 #import <SoundAnalysis/SNRequest.h>
 
 NS_ASSUME_NONNULL_BEGIN
 
+@class SNTimeDurationConstraint;
+
 /*!
  @brief Configure an analyzer to perform sound classification using the provided MLModel.
  @discussion When a new classification result is produced, the results observer will be called with an SNClassificationResult. Audio buffers provided to SNAudioStreamAnalyzer may vary in size, and the analyzer will reblock the audio data to the block size expected by the MLModel. By default, analysis will occur on the first audio channel in the audio stream, and the analyzer will apply sample rate conversion if the provided audio does not match the sample rate required by the MLModel.
@@ -23,7 +28,25 @@
  @brief The overlap factor of the windows of audio data provided to the classifier, if the model operates on fixed audio block sizes.
  @discussion When performing audio analysis on fixed audio block sizes, it is common for the analysis windows to overlap by some factor. Without overlapping the analysis windows (when the overlap factor is 0.0), a sound might be split across two analysis windows, which could negatively affect classification performance. Overlapping the analysis windows by 50% ensures each sound will fall near the center of at least one analysis window. The supported range is [0.0, 1.0), and the default value is 0.5. Increasing the overlap factor increases computational complexity, so values greater than 0.5 should be used with care.
  */
-@property (readwrite) double overlapFactor;
+@property (readwrite, assign) double overlapFactor;
+
+/*!
+ @brief The duration of a single analysis window.
+ @discussion When performing classification over an audio stream, a classifier computes each classification result based on a single 'analysis window' of audio. Analysis windows are uniformly-sized time intervals, where the size of any given window is considered that window's 'duration'. Some classifiers can operate over analysis windows which conform to one of several different duration options. Larger window durations allow classification to execute less frequently over larger contexts of audio, potentially improving classification performance. Smaller window durations allow classification to execute more frequently over smaller contexts of audio, producing results with sharper time resolution. Depending on the use-case, a larger or smaller window may be preferrable. When configuring the window duration, it is important to respect the capabilities of the classifier. A classifier's supported window durations can be discovered using the `windowDurationConstraint` property. If an unsupported window duration is selected, the window duration will be automatically rounded down to the nearest supported value if possible, else rounded up.
+ */
+@property (readwrite, assign) CMTime windowDuration API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0), watchos(8.0));
+
+/*!
+ @brief The constraints governing permitted analysis window durations.
+ @discussion The analysis window duration is controlled using the `windowDuration` property. If an analysis window duration is selected which does not meet the necessary constraints, it will automatically be adjusted to meet these constraints (see `windowDuration` for more information regarding how this adjustment will be applied).
+ */
+@property (readonly, strong) SNTimeDurationConstraint *windowDurationConstraint NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0), watchos(8.0));
+
+/*!
+ @brief Lists all labels that can be produced by this request.
+ @return An array of strings containing all sound identifiers which can be produced by this request.
+ */
+@property (readonly, copy) NSArray<NSString *> *knownClassifications API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0), watchos(8.0));
 
 /*!
  @brief Initializes a sound classification request with the provided MLModel
@@ -32,9 +55,20 @@
  */
 - (nullable instancetype)initWithMLModel:(MLModel *)mlModel error:(NSError **)error;
 
+/*!
+ @brief Initializes a sound classification request with a known classifier.
+ @param classifierIdentifier An identifier identifying the particular classifier to use for labeling sounds.
+ @param error An output parameter which, in the case of an error, will be populated with details about that error. Upon success, the contents of this output parameter are undefined. Please use the return value of this method to determine whether or not an error occurred before using the value assigned to this output parameter.
+ @return Upon failure, `nil`; upon success, an `SNClassifySoundRequest` instance which can be added to an analyzer to classify sounds using a recognized classifier.
+ @discussion This initializer may be used to classify sounds using Apple-provided sound classifiers. Note that Apple may add new classifiers in the future, but it commits to ensuring the consistent performance of existing classifiers.
+ */
+- (nullable instancetype)initWithClassifierIdentifier:(SNClassifierIdentifier)classifierIdentifier
+												error:(NSError **)error API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0), watchos(8.0));
+
 - (instancetype)init NS_UNAVAILABLE;
 + (instancetype)new NS_UNAVAILABLE;
 
 @end
 
+
 NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_12.5.0.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNTimeDurationConstraint.h /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNTimeDurationConstraint.h
--- /Applications/Xcode_12.5.0.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNTimeDurationConstraint.h	1969-12-31 19:00:00.000000000 -0500
+++ /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNTimeDurationConstraint.h	2021-06-02 07:33:22.000000000 -0400
@@ -0,0 +1,77 @@
+//
+//  SNTimeDurationConstraint.h
+//  SoundAnalysis
+//
+//  Copyright © 2020 Apple. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <CoreMedia/CoreMedia.h>
+#import <SoundAnalysis/SNDefines.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/*!
+ @brief Enumerates possible types for `SNTimeDurationConstraint`.
+ */
+typedef NS_ENUM(NSInteger, SNTimeDurationConstraintType) {
+	/*!
+	 @brief An 'enumerated' constraint type.
+	 @discussion In order for a duration to satisfy a constraint of this type, it must be a member of a particular set of discrete permissible values.
+	 */
+	SNTimeDurationConstraintTypeEnumerated = 1,
+
+	/*!
+	 @brief A 'range' constraint type.
+	 @discussion In order for a duration to satisfy a constraint of this type, it must be a member of a particular continuous range of permissible values.
+	 */
+	SNTimeDurationConstraintTypeRange = 2,
+} NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0), watchos(8.0));
+
+/*!
+ @brief Constrains CMTime durations to a subset of legal values.
+ @discussion `SNTimeDurationConstraint` is a union type, which, based on the value of its `type` property, may assume one of several forms. Instance properties may be used to extract information from an object, but certain properties are only valid to exercise under certain circumstances. Before accessing a particular property, refer to its documentation to understand what `type` value is required in order for that property to be valid.
+ */
+SN_EXPORT NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0), watchos(8.0))
+@interface SNTimeDurationConstraint : NSObject
+
+/*!
+ @brief The time constraint type.
+ @discussion The value of this property dictates whether or not other properties associated with this class can be validly accessed. Please refer to the documentation of other individual properties to understand their relationship to this one. This property is always valid to access.
+ */
+@property (readonly, assign) SNTimeDurationConstraintType type;
+
+/*!
+ @brief If the constraint type is enumerated, then the set of discrete allowable time durations.
+ @return If the constraint type is enumerated, an array of CMTime structures (boxed in NSValue instances) representing the set of allowable time durations. The durations will always be provided sorted in order of ascending time. If the constraint type is not enumerated, an empty array will be returned.
+ @discussion The `type` property should be queried before this property is accessed. This property will only yield meaningful values if the constraint type is considered to be 'enumerated'. The constraint type is considered to be 'enumerated' if the `type` property is equal to `SNTimeDurationConstraintTypeEnumerated`.
+ */
+@property (readonly, strong) NSArray<NSValue *> *enumeratedDurations;
+
+/*!
+ @brief If the constraint type is range, then the range of allowable window durations.
+ @return If the constraint type is range, a CMTimeRange representing the range of allowable window durations. If the constraint type is not range, `kCMTimeRangeInvalid`.
+ @discussion The `type` property should be queried before this property is accessed. This property will only yield meaningful values if the constraint type is considered to be 'range'. The constraint type is considered to be 'range' if the `type` property is equal to `SNTimeDurationConstraintTypeRange`.
+ */
+@property (readonly, assign) CMTimeRange durationRange;
+
+/*!
+ @brief Initializes an enumerated-type constraint.
+ @param enumeratedDurations A discrete set of duration values (represented as CMTime values boxed in NSValue instances) permitted by this constraint.
+ @return An instance whose `type` is `SNTimeDurationConstraintTypeEnumerated`, and which constrains duration values to the provided set of discrete values.
+ */
+- (instancetype)initWithEnumeratedDurations:(NSArray<NSValue *> *)enumeratedDurations;
+
+/*!
+ @brief Initializes a range-type constraint.
+ @param durationRange A continuous range of duration values (represented as CMTime values) permitted by this constraint.
+ @return An instance whose `type` is `SNTimeDurationConstraintTypeRange`, and which constrains durations values to the provided range.
+ */
+- (instancetype)initWithDurationRange:(CMTimeRange)durationRange;
+
+- (instancetype)init NS_UNAVAILABLE;
++ (instancetype)new NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_12.5.0.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNTypes.h /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNTypes.h
--- /Applications/Xcode_12.5.0.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNTypes.h	1969-12-31 19:00:00.000000000 -0500
+++ /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SNTypes.h	2021-06-02 07:35:04.000000000 -0400
@@ -0,0 +1,21 @@
+//
+//  SNTypes.h
+//  SoundAnalysis
+//
+//  Copyright © 2020 Apple. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <SoundAnalysis/SNDefines.h>
+
+/*!
+ @brief Identifiers denoting particular recognized sound classifiers.
+ */
+typedef NSString *SNClassifierIdentifier NS_TYPED_ENUM API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0), watchos(8.0));
+
+/*!
+ @brief Denotes the first edition of the Apple-provided sound classifier.
+ */
+SN_EXPORT SNClassifierIdentifier const SNClassifierIdentifierVersion1 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0), watchos(8.0));
+
+
diff -ruN /Applications/Xcode_12.5.0.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SoundAnalysis.h /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SoundAnalysis.h
--- /Applications/Xcode_12.5.0.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SoundAnalysis.h	2021-03-16 05:15:12.000000000 -0400
+++ /Applications/Xcode_13.0.0-beta.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/SoundAnalysis.framework/Headers/SoundAnalysis.h	2021-06-01 20:45:07.000000000 -0400
@@ -12,10 +12,12 @@
 #import <Foundation/Foundation.h>
 
 #import <SoundAnalysis/SNDefines.h>
+#import <SoundAnalysis/SNTypes.h>
 #import <SoundAnalysis/SNError.h>
 #import <SoundAnalysis/SNRequest.h>
 #import <SoundAnalysis/SNResult.h>
 #import <SoundAnalysis/SNAnalyzer.h>
 
+#import <SoundAnalysis/SNTimeDurationConstraint.h>
 #import <SoundAnalysis/SNClassifySoundRequest.h>
 #import <SoundAnalysis/SNClassificationResult.h>
Clone this wiki locally