annotate capnp/piper.capnp @ 195:2dfac1f5a419

Start adding docs to Cap'n Proto schema
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 09 Feb 2017 16:06:08 +0000
parents 4fed2f3f2cd0
children 9a36c8850b1b
rev   line source
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
c@174 10 identifier @0 :Text;
cannam@195 11 # A computer-readable string. Must match the regex /^[a-zA-Z0-9_-]+$/.
cannam@195 12
c@174 13 name @1 :Text;
cannam@195 14 # A short human-readable name or label. Must be present.
cannam@195 15
c@174 16 description @2 :Text;
cannam@195 17 # An optional human-readable descriptive text that may accompany the name.
c@174 18 }
c@174 19
c@174 20 struct ParameterDescriptor {
cannam@195 21 # Properties of an adjustable parameter. Each parameter value is just a single
cannam@195 22 # float, but the descriptor explains how to interpret and present that value.
cannam@195 23
c@174 24 basic @0 :Basic;
cannam@195 25 # Basic metadata about the parameter.
cannam@195 26
c@174 27 unit @1 :Text;
cannam@195 28 # Human-recognisable unit of the parameter (e.g. Hz). May be left empty.
cannam@195 29
c@174 30 minValue @2 :Float32 = 0.0;
cannam@195 31 # Minimum value. Must be provided.
cannam@195 32
c@174 33 maxValue @3 :Float32 = 0.0;
cannam@195 34 # Maximum value. Must be provided.
cannam@195 35
c@174 36 defaultValue @4 :Float32 = 0.0;
cannam@195 37 # Default if the parameter is not set to anything else. Must be provided.
cannam@195 38
c@174 39 isQuantized @5 :Bool = false;
cannam@195 40 # True if parameter values are quantized to a particular resolution.
cannam@195 41
c@174 42 quantizeStep @6 :Float32 = 0.0;
cannam@195 43 # Quantization resolution, if isQuantized.
cannam@195 44
c@174 45 valueNames @7 :List(Text) = [];
cannam@195 46 # Optional human-readable labels for the values, if isQuantized.
c@174 47 }
c@174 48
c@174 49 enum SampleType {
cannam@195 50 # How returned features are spaced on the input timeline.
cannam@195 51
c@174 52 oneSamplePerStep @0;
cannam@195 53 # Each process input returns a feature aligned with that input's timestamp.
cannam@195 54
c@174 55 fixedSampleRate @1;
cannam@195 56 # Features are equally spaced at a given sample rate.
cannam@195 57
c@174 58 variableSampleRate @2;
cannam@195 59 # Features have their own individual timestamps.
c@174 60 }
c@174 61
c@174 62 struct ConfiguredOutputDescriptor {
c@174 63 unit @0 :Text;
c@174 64 hasFixedBinCount @1 :Bool = false;
c@174 65 binCount @2 :Int32 = 0;
c@174 66 binNames @3 :List(Text) = [];
c@174 67 hasKnownExtents @4 :Bool = false;
c@174 68 minValue @5 :Float32 = 0.0;
c@174 69 maxValue @6 :Float32 = 0.0;
c@174 70 isQuantized @7 :Bool = false;
c@174 71 quantizeStep @8 :Float32 = 0.0;
c@174 72 sampleType @9 :SampleType;
c@174 73 sampleRate @10 :Float32 = 0.0;
c@174 74 hasDuration @11 :Bool = false;
c@174 75 }
c@174 76
c@174 77 struct OutputDescriptor {
c@174 78 basic @0 :Basic;
c@174 79 configured @1 :ConfiguredOutputDescriptor;
c@174 80 }
c@174 81
c@174 82 enum InputDomain {
c@174 83 timeDomain @0;
c@174 84 frequencyDomain @1;
c@174 85 }
c@174 86
c@174 87 struct ExtractorStaticData {
c@174 88 key @0 :Text;
c@174 89 basic @1 :Basic;
c@174 90 maker @2 :Text;
c@174 91 copyright @3 :Text;
c@174 92 version @4 :Int32;
c@174 93 category @5 :List(Text);
c@174 94 minChannelCount @6 :Int32;
c@174 95 maxChannelCount @7 :Int32;
c@174 96 parameters @8 :List(ParameterDescriptor);
c@174 97 programs @9 :List(Text);
c@174 98 inputDomain @10 :InputDomain;
c@174 99 basicOutputInfo @11 :List(Basic);
c@174 100 }
c@174 101
c@174 102 struct RealTime {
c@174 103 sec @0 :Int32 = 0;
c@174 104 nsec @1 :Int32 = 0;
c@174 105 }
c@174 106
c@174 107 struct ProcessInput {
c@174 108 inputBuffers @0 :List(List(Float32));
c@174 109 timestamp @1 :RealTime;
c@174 110 }
c@174 111
c@174 112 struct Feature {
c@174 113 hasTimestamp @0 :Bool = false;
c@174 114 timestamp @1 :RealTime;
c@174 115 hasDuration @2 :Bool = false;
c@174 116 duration @3 :RealTime;
c@174 117 label @4 :Text;
c@174 118 featureValues @5 :List(Float32) = [];
c@174 119 }
c@174 120
c@174 121 struct FeatureSet {
c@174 122 struct FSPair {
c@174 123 output @0 :Text;
c@174 124 features @1 :List(Feature) = [];
c@174 125 }
c@174 126 featurePairs @0 :List(FSPair);
c@174 127 }
c@174 128
cannam@191 129 struct Framing {
cannam@191 130 stepSize @0 :Int32;
cannam@191 131 blockSize @1 :Int32;
cannam@191 132 }
cannam@191 133
c@174 134 struct Configuration {
c@174 135 struct PVPair {
c@174 136 parameter @0 :Text;
c@174 137 value @1 :Float32;
c@174 138 }
c@174 139 parameterValues @0 :List(PVPair);
c@174 140 currentProgram @1 :Text;
c@174 141 channelCount @2 :Int32;
cannam@191 142 framing @3 :Framing;
c@174 143 }
c@174 144
c@174 145 enum AdapterFlag {
c@174 146 adaptInputDomain @0;
c@174 147 adaptChannelCount @1;
c@174 148 adaptBufferSize @2;
c@174 149 }
c@174 150
c@174 151 const adaptAllSafe :List(AdapterFlag) =
c@174 152 [ adaptInputDomain, adaptChannelCount ];
c@174 153
c@174 154 const adaptAll :List(AdapterFlag) =
c@174 155 [ adaptInputDomain, adaptChannelCount, adaptBufferSize ];
c@174 156
c@174 157 struct ListRequest {
c@179 158 from @0 :List(Text);
c@174 159 }
c@174 160
c@174 161 struct ListResponse {
c@174 162 available @0 :List(ExtractorStaticData);
c@174 163 }
c@174 164
c@174 165 struct LoadRequest {
c@174 166 key @0 :Text;
c@174 167 inputSampleRate @1 :Float32;
c@174 168 adapterFlags @2 :List(AdapterFlag);
c@174 169 }
c@174 170
c@174 171 struct LoadResponse {
c@174 172 handle @0 :Int32;
c@174 173 staticData @1 :ExtractorStaticData;
c@174 174 defaultConfiguration @2 :Configuration;
c@174 175 }
c@174 176
c@174 177 struct ConfigurationRequest {
c@174 178 handle @0 :Int32;
c@174 179 configuration @1 :Configuration;
c@174 180 }
c@174 181
c@174 182 struct ConfigurationResponse {
c@174 183 handle @0 :Int32;
c@174 184 outputs @1 :List(OutputDescriptor);
cannam@191 185 framing @2 :Framing;
c@174 186 }
c@174 187
c@174 188 struct ProcessRequest {
c@174 189 handle @0 :Int32;
c@174 190 processInput @1 :ProcessInput;
c@174 191 }
c@174 192
c@174 193 struct ProcessResponse {
c@174 194 handle @0 :Int32;
c@174 195 features @1 :FeatureSet;
c@174 196 }
c@174 197
c@174 198 struct FinishRequest {
c@174 199 handle @0 :Int32;
c@174 200 }
c@174 201
c@174 202 struct FinishResponse {
c@174 203 handle @0 :Int32;
c@174 204 features @1 :FeatureSet;
c@174 205 }
c@174 206
c@174 207 struct Error {
c@174 208 code @0 :Int32;
c@174 209 message @1 :Text;
c@174 210 }
c@174 211
c@174 212 struct RpcRequest {
c@174 213 # Request bundle for use when using Cap'n Proto serialisation without
c@174 214 # Cap'n Proto RPC layer. For Cap'n Proto RPC, see piper.rpc.capnp.
c@175 215 id :union {
c@175 216 number @0 :Int32;
c@175 217 tag @1 :Text;
c@175 218 none @2 :Void;
c@175 219 }
c@174 220 request :union {
c@175 221 list @3 :ListRequest;
c@175 222 load @4 :LoadRequest;
c@175 223 configure @5 :ConfigurationRequest;
c@175 224 process @6 :ProcessRequest;
c@177 225 finish @7 :FinishRequest;
c@177 226 # finish gets any remaining calculated features and unloads
c@177 227 # the feature extractor. Note that you can call finish at any
c@177 228 # time -- even if you haven't configured or used the extractor,
c@177 229 # it will unload any resources used and abandon the handle.
c@174 230 }
c@174 231 }
c@174 232
c@174 233 struct RpcResponse {
c@174 234 # Response bundle for use when using Cap'n Proto serialisation without
c@174 235 # Cap'n Proto RPC layer. For Cap'n Proto RPC, see piper.rpc.capnp.
c@175 236 id :union {
c@175 237 number @0 :Int32;
c@175 238 tag @1 :Text;
c@175 239 none @2 :Void;
c@175 240 }
c@174 241 response :union {
c@175 242 error @3 :Error;
c@175 243 list @4 :ListResponse;
c@175 244 load @5 :LoadResponse;
c@175 245 configure @6 :ConfigurationResponse;
c@175 246 process @7 :ProcessResponse;
c@175 247 finish @8 :FinishResponse;
c@174 248 }
c@174 249 }
c@174 250