c@174
|
1
|
c@174
|
2 @0xc4b1c6c44c999206;
|
c@174
|
3
|
c@174
|
4 using Cxx = import "/capnp/c++.capnp";
|
c@174
|
5 $Cxx.namespace("piper");
|
c@174
|
6
|
c@174
|
7 struct Basic {
|
cannam@195
|
8 # Basic metadata common to many Piper structures.
|
cannam@195
|
9
|
cannam@196
|
10 identifier @0 :Text; # A computer-readable string. Must match the regex /^[a-zA-Z0-9_-]+$/.
|
cannam@196
|
11 name @1 :Text; # A short human-readable name or label. Must be present.
|
cannam@196
|
12 description @2 :Text; # An optional human-readable descriptive text that may accompany the name.
|
c@174
|
13 }
|
c@174
|
14
|
c@174
|
15 struct ParameterDescriptor {
|
cannam@196
|
16 # Properties of an adjustable parameter. A parameter's value is just a single
|
cannam@195
|
17 # float, but the descriptor explains how to interpret and present that value.
|
cannam@196
|
18 # A Piper feature extractor has a static list of parameters. The properties of
|
cannam@196
|
19 # a given parameter never change, in contrast to output descriptors, which
|
cannam@196
|
20 # may have different properties depending on the configuration of the extractor.
|
cannam@195
|
21
|
cannam@196
|
22 basic @0 :Basic; # Basic metadata about the parameter.
|
cannam@196
|
23 unit @1 :Text; # Human-recognisable unit of the parameter (e.g. Hz). May be left empty.
|
cannam@196
|
24 minValue @2 :Float32 = 0.0; # Minimum value. Must be provided.
|
cannam@196
|
25 maxValue @3 :Float32 = 0.0; # Maximum value. Must be provided.
|
cannam@196
|
26 defaultValue @4 :Float32 = 0.0; # Default if the parameter is not set to anything else. Must be provided.
|
cannam@196
|
27 isQuantized @5 :Bool = false; # True if parameter values are quantized to a particular resolution.
|
cannam@196
|
28 quantizeStep @6 :Float32 = 0.0; # Quantization resolution, if isQuantized.
|
cannam@196
|
29 valueNames @7 :List(Text) = []; # Optional human-readable labels for the values, if isQuantized.
|
c@174
|
30 }
|
c@174
|
31
|
c@174
|
32 enum SampleType {
|
cannam@195
|
33 # How returned features are spaced on the input timeline.
|
cannam@195
|
34
|
cannam@196
|
35 oneSamplePerStep @0; # Each process input returns a feature aligned with that input's timestamp.
|
cannam@196
|
36 fixedSampleRate @1; # Features are equally spaced at a given sample rate.
|
cannam@196
|
37 variableSampleRate @2; # Features have their own individual timestamps.
|
c@174
|
38 }
|
c@174
|
39
|
c@174
|
40 struct ConfiguredOutputDescriptor {
|
cannam@196
|
41 # Properties of an output, that is, a single stream of features produced
|
cannam@196
|
42 # in response to process and finish requests. A feature extractor may
|
cannam@196
|
43 # have any number of outputs, and it always calculates and returns features
|
cannam@196
|
44 # from all of them when processing; this is useful in cases where more
|
cannam@196
|
45 # than one feature can be easily calculated using a single method.
|
cannam@196
|
46 # This structure contains the properties of an output that are not static,
|
cannam@196
|
47 # i.e. that may depend on the parameter values provided at configuration.
|
cannam@196
|
48
|
cannam@196
|
49 unit @0 :Text; # Human-recognisable unit of the bin values in output features. May be empty.
|
cannam@196
|
50 hasFixedBinCount @1 :Bool = false; # True if this output has an equal number of values in each returned feature.
|
cannam@196
|
51 binCount @2 :Int32 = 0; # Number of values per feature for this output, if hasFixedBinCount.
|
cannam@196
|
52 binNames @3 :List(Text) = []; # Optional human-readable labels for the value bins, if hasFixedBinCount.
|
cannam@196
|
53 hasKnownExtents @4 :Bool = false; # True if all feature values fall within the same fixed min/max range.
|
cannam@196
|
54 minValue @5 :Float32 = 0.0; # Minimum value in range for any value from this output, if hasKnownExtents.
|
cannam@196
|
55 maxValue @6 :Float32 = 0.0; # Maximum value in range for any value from this output, if hasKnownExtents.
|
cannam@196
|
56 isQuantized @7 :Bool = false; # True if feature values are quantized to a particular resolution.
|
cannam@196
|
57 quantizeStep @8 :Float32 = 0.0; # Quantization resolution, if isQuantized.
|
cannam@196
|
58 sampleType @9 :SampleType; # How returned features from this output are spaced on the input timeline.
|
cannam@196
|
59 sampleRate @10 :Float32 = 0.0; # Sample rate (features per second) if sampleType == fixedSampleRate.
|
cannam@196
|
60 hasDuration @11 :Bool = false; # True if features returned from this output will have a duration.
|
c@174
|
61 }
|
c@174
|
62
|
c@174
|
63 struct OutputDescriptor {
|
cannam@196
|
64 # All the properties of an output, both static (the basic metadata) and
|
cannam@196
|
65 # potentially dependent on configuration parameters (the configured descriptor).
|
cannam@196
|
66
|
cannam@196
|
67 basic @0 :Basic; # Basic metadata about the output.
|
cannam@196
|
68 configured @1 :ConfiguredOutputDescriptor; # Properties of the output that may depend on configuration parameters.
|
c@174
|
69 }
|
c@174
|
70
|
c@174
|
71 enum InputDomain {
|
cannam@196
|
72 # Whether a feature extractor requires time-domain audio input (i.e.
|
cannam@196
|
73 # "normal" or "unprocessed" audio samples) or frequency-domain input
|
cannam@196
|
74 # (i.e. resulting from windowed, usually overlapping, short-time
|
cannam@196
|
75 # Fourier transforms).
|
cannam@196
|
76
|
cannam@196
|
77 timeDomain @0; # The plugin requires time-domain audio samples as input.
|
cannam@196
|
78 frequencyDomain @1; # The plugin requires input to have been pre-processed using windowed STFTs.
|
c@174
|
79 }
|
c@174
|
80
|
c@174
|
81 struct ExtractorStaticData {
|
cannam@196
|
82 # Static properties of a feature extractor. That is, metadata about the
|
cannam@196
|
83 # extractor that are the same regardless of how you configure or run it.
|
cannam@196
|
84
|
cannam@196
|
85 key @0 :Text; # Composed string that identifies the extractor among all extractors (see docs).
|
cannam@196
|
86 basic @1 :Basic; # Basic metadata about the extractor.
|
cannam@196
|
87 maker @2 :Text; # Human-readable text naming the author or vendor of the extractor.
|
cannam@196
|
88 copyright @3 :Text; # ??? review
|
cannam@196
|
89 version @4 :Int32; # Version number of extractor; must increase if new algorithm changes outputs.
|
cannam@196
|
90 category @5 :List(Text); # ??? review
|
cannam@196
|
91 minChannelCount @6 :Int32; # Minimum number of input channels of audio this extractor can accept.
|
cannam@196
|
92 maxChannelCount @7 :Int32; # Maximum number of input channels of audio this extractor can accept.
|
cannam@196
|
93 parameters @8 :List(ParameterDescriptor); # List of configurable parameter properties for the feature extractor.
|
cannam@196
|
94 programs @9 :List(Text); # ??? review
|
cannam@196
|
95 inputDomain @10 :InputDomain; # Whether the extractor requires time-domain or frequency-domain input audio.
|
cannam@196
|
96 basicOutputInfo @11 :List(Basic); # Basic metadata about all of the outputs of the extractor.
|
c@174
|
97 }
|
c@174
|
98
|
c@174
|
99 struct RealTime {
|
cannam@196
|
100 # Time structure. When used as a timestamp, this is relative to "start
|
cannam@196
|
101 # of audio".
|
cannam@196
|
102
|
cannam@196
|
103 sec @0 :Int32 = 0; # Number of seconds.
|
cannam@196
|
104 nsec @1 :Int32 = 0; # Number of nanoseconds. Must have same sign as sec unless sec == 0.
|
c@174
|
105 }
|
c@174
|
106
|
c@174
|
107 struct ProcessInput {
|
cannam@196
|
108 # Audio and timing input data provided to a process request.
|
cannam@196
|
109
|
cannam@196
|
110 inputBuffers @0 :List(List(Float32)); # For each input channel, a single block of audio data (time or frequency domain).
|
cannam@196
|
111 timestamp @1 :RealTime; # Time of start of input block (time-domain) or "centre" of it (frequency-domain).
|
c@174
|
112 }
|
c@174
|
113
|
c@174
|
114 struct Feature {
|
cannam@196
|
115 # A single feature calculated and returned from a process or finish request.
|
cannam@196
|
116
|
cannam@196
|
117 hasTimestamp @0 :Bool = false; # True if feature has a timestamp. Must be true if on a variableSampleRate output.
|
cannam@196
|
118 timestamp @1 :RealTime; # Timestamp of feature, if hasTimestamp.
|
cannam@196
|
119 hasDuration @2 :Bool = false; # True if feature has a duration. Must be true if output's hasDuration is true.
|
cannam@196
|
120 duration @3 :RealTime; # Duration of feature, if hasDuration.
|
cannam@196
|
121 label @4 :Text; # Optional human-readable text attached to feature.
|
cannam@196
|
122 featureValues @5 :List(Float32) = []; # The feature values themselves (of size binCount, if output hasFixedBinCount).
|
c@174
|
123 }
|
c@174
|
124
|
c@174
|
125 struct FeatureSet {
|
c@174
|
126 struct FSPair {
|
c@174
|
127 output @0 :Text;
|
c@174
|
128 features @1 :List(Feature) = [];
|
c@174
|
129 }
|
c@174
|
130 featurePairs @0 :List(FSPair);
|
c@174
|
131 }
|
c@174
|
132
|
cannam@191
|
133 struct Framing {
|
cannam@191
|
134 stepSize @0 :Int32;
|
cannam@191
|
135 blockSize @1 :Int32;
|
cannam@191
|
136 }
|
cannam@191
|
137
|
c@174
|
138 struct Configuration {
|
c@174
|
139 struct PVPair {
|
c@174
|
140 parameter @0 :Text;
|
c@174
|
141 value @1 :Float32;
|
c@174
|
142 }
|
c@174
|
143 parameterValues @0 :List(PVPair);
|
c@174
|
144 currentProgram @1 :Text;
|
c@174
|
145 channelCount @2 :Int32;
|
cannam@191
|
146 framing @3 :Framing;
|
c@174
|
147 }
|
c@174
|
148
|
c@174
|
149 enum AdapterFlag {
|
c@174
|
150 adaptInputDomain @0;
|
c@174
|
151 adaptChannelCount @1;
|
c@174
|
152 adaptBufferSize @2;
|
c@174
|
153 }
|
c@174
|
154
|
c@174
|
155 const adaptAllSafe :List(AdapterFlag) =
|
c@174
|
156 [ adaptInputDomain, adaptChannelCount ];
|
c@174
|
157
|
c@174
|
158 const adaptAll :List(AdapterFlag) =
|
c@174
|
159 [ adaptInputDomain, adaptChannelCount, adaptBufferSize ];
|
c@174
|
160
|
c@174
|
161 struct ListRequest {
|
c@179
|
162 from @0 :List(Text);
|
c@174
|
163 }
|
c@174
|
164
|
c@174
|
165 struct ListResponse {
|
c@174
|
166 available @0 :List(ExtractorStaticData);
|
c@174
|
167 }
|
c@174
|
168
|
c@174
|
169 struct LoadRequest {
|
c@174
|
170 key @0 :Text;
|
c@174
|
171 inputSampleRate @1 :Float32;
|
c@174
|
172 adapterFlags @2 :List(AdapterFlag);
|
c@174
|
173 }
|
c@174
|
174
|
c@174
|
175 struct LoadResponse {
|
c@174
|
176 handle @0 :Int32;
|
c@174
|
177 staticData @1 :ExtractorStaticData;
|
c@174
|
178 defaultConfiguration @2 :Configuration;
|
c@174
|
179 }
|
c@174
|
180
|
c@174
|
181 struct ConfigurationRequest {
|
c@174
|
182 handle @0 :Int32;
|
c@174
|
183 configuration @1 :Configuration;
|
c@174
|
184 }
|
c@174
|
185
|
c@174
|
186 struct ConfigurationResponse {
|
c@174
|
187 handle @0 :Int32;
|
c@174
|
188 outputs @1 :List(OutputDescriptor);
|
cannam@191
|
189 framing @2 :Framing;
|
c@174
|
190 }
|
c@174
|
191
|
c@174
|
192 struct ProcessRequest {
|
c@174
|
193 handle @0 :Int32;
|
c@174
|
194 processInput @1 :ProcessInput;
|
c@174
|
195 }
|
c@174
|
196
|
c@174
|
197 struct ProcessResponse {
|
c@174
|
198 handle @0 :Int32;
|
c@174
|
199 features @1 :FeatureSet;
|
c@174
|
200 }
|
c@174
|
201
|
c@174
|
202 struct FinishRequest {
|
c@174
|
203 handle @0 :Int32;
|
c@174
|
204 }
|
c@174
|
205
|
c@174
|
206 struct FinishResponse {
|
c@174
|
207 handle @0 :Int32;
|
c@174
|
208 features @1 :FeatureSet;
|
c@174
|
209 }
|
c@174
|
210
|
c@174
|
211 struct Error {
|
c@174
|
212 code @0 :Int32;
|
c@174
|
213 message @1 :Text;
|
c@174
|
214 }
|
c@174
|
215
|
c@174
|
216 struct RpcRequest {
|
c@174
|
217 # Request bundle for use when using Cap'n Proto serialisation without
|
c@174
|
218 # Cap'n Proto RPC layer. For Cap'n Proto RPC, see piper.rpc.capnp.
|
c@175
|
219 id :union {
|
c@175
|
220 number @0 :Int32;
|
c@175
|
221 tag @1 :Text;
|
c@175
|
222 none @2 :Void;
|
c@175
|
223 }
|
c@174
|
224 request :union {
|
c@175
|
225 list @3 :ListRequest;
|
c@175
|
226 load @4 :LoadRequest;
|
c@175
|
227 configure @5 :ConfigurationRequest;
|
c@175
|
228 process @6 :ProcessRequest;
|
c@177
|
229 finish @7 :FinishRequest;
|
c@177
|
230 # finish gets any remaining calculated features and unloads
|
c@177
|
231 # the feature extractor. Note that you can call finish at any
|
c@177
|
232 # time -- even if you haven't configured or used the extractor,
|
c@177
|
233 # it will unload any resources used and abandon the handle.
|
c@174
|
234 }
|
c@174
|
235 }
|
c@174
|
236
|
c@174
|
237 struct RpcResponse {
|
c@174
|
238 # Response bundle for use when using Cap'n Proto serialisation without
|
c@174
|
239 # Cap'n Proto RPC layer. For Cap'n Proto RPC, see piper.rpc.capnp.
|
c@175
|
240 id :union {
|
c@175
|
241 number @0 :Int32;
|
c@175
|
242 tag @1 :Text;
|
c@175
|
243 none @2 :Void;
|
c@175
|
244 }
|
c@174
|
245 response :union {
|
c@175
|
246 error @3 :Error;
|
c@175
|
247 list @4 :ListResponse;
|
c@175
|
248 load @5 :LoadResponse;
|
c@175
|
249 configure @6 :ConfigurationResponse;
|
c@175
|
250 process @7 :ProcessResponse;
|
c@175
|
251 finish @8 :FinishResponse;
|
c@174
|
252 }
|
c@174
|
253 }
|
c@174
|
254
|