objc2_sound_analysis/generated/SNClassificationResult.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-media")]
7use objc2_core_media::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13 /// The likelihood of a sound belonging to identified class
14 ///
15 /// See also [Apple's documentation](https://developer.apple.com/documentation/soundanalysis/snclassification?language=objc)
16 #[unsafe(super(NSObject))]
17 #[derive(Debug, PartialEq, Eq, Hash)]
18 pub struct SNClassification;
19);
20
21extern_conformance!(
22 unsafe impl NSObjectProtocol for SNClassification {}
23);
24
25impl SNClassification {
26 extern_methods!(
27 /// 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.
28 #[unsafe(method(identifier))]
29 #[unsafe(method_family = none)]
30 pub unsafe fn identifier(&self) -> Retained<NSString>;
31
32 /// The level of confidence normalized to [0, 1], where 1 is most confident
33 #[unsafe(method(confidence))]
34 #[unsafe(method_family = none)]
35 pub unsafe fn confidence(&self) -> c_double;
36
37 #[unsafe(method(init))]
38 #[unsafe(method_family = init)]
39 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
40
41 #[unsafe(method(new))]
42 #[unsafe(method_family = new)]
43 pub unsafe fn new() -> Retained<Self>;
44 );
45}
46
47extern_class!(
48 /// A result containing the most likely classification candidates in the time range specified
49 ///
50 /// See also [Apple's documentation](https://developer.apple.com/documentation/soundanalysis/snclassificationresult?language=objc)
51 #[unsafe(super(NSObject))]
52 #[derive(Debug, PartialEq, Eq, Hash)]
53 pub struct SNClassificationResult;
54);
55
56extern_conformance!(
57 unsafe impl NSObjectProtocol for SNClassificationResult {}
58);
59
60#[cfg(feature = "SNResult")]
61extern_conformance!(
62 unsafe impl SNResult for SNClassificationResult {}
63);
64
65impl SNClassificationResult {
66 extern_methods!(
67 /// All classification candidates, sorted with highest confidence first.
68 #[unsafe(method(classifications))]
69 #[unsafe(method_family = none)]
70 pub unsafe fn classifications(&self) -> Retained<NSArray<SNClassification>>;
71
72 #[cfg(feature = "objc2-core-media")]
73 /// The time range in the client-provided audio stream to which this classification result corresponds
74 ///
75 /// Each CMTime contains of a value (audio frame count) and timescale (client sample rate). This enables the client to precisely identify the frame range in the original audio stream to which this result corresponds. Time ranges will often be in the past compared to the frame count of the most recent audio buffer provided to the analyzer, due to the inherent audio buffering operations required to deliver a full block of audio to an MLModel.
76 #[unsafe(method(timeRange))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn timeRange(&self) -> CMTimeRange;
79
80 #[unsafe(method(init))]
81 #[unsafe(method_family = init)]
82 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
83
84 #[unsafe(method(new))]
85 #[unsafe(method_family = new)]
86 pub unsafe fn new() -> Retained<Self>;
87
88 /// Retrieves the classification candidate with the specified identifier.
89 ///
90 /// - Parameter 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.
91 ///
92 /// - Returns: The classification candidate which has the specified identifier, if it exists. If no such candidate exists, `nil` will be returned.
93 #[unsafe(method(classificationForIdentifier:))]
94 #[unsafe(method_family = none)]
95 pub unsafe fn classificationForIdentifier(
96 &self,
97 identifier: &NSString,
98 ) -> Option<Retained<SNClassification>>;
99 );
100}