Mercurial > hg > vamp-plugin-sdk
comparison rdf/generator/template-generator.cpp @ 139:bb46b8bd213a
* Update template generator with changes from km-rdf repo -- apart from the
Prolog compatibility bits
author | cannam |
---|---|
date | Thu, 19 Jun 2008 09:43:24 +0000 |
parents | 147de5e64d28 |
children | 8e3a5f779d89 |
comparison
equal
deleted
inserted
replaced
138:147de5e64d28 | 139:bb46b8bd213a |
---|---|
53 string describe_namespaces(Plugin* plugin, string pluginBundleBaseURI) | 53 string describe_namespaces(Plugin* plugin, string pluginBundleBaseURI) |
54 { | 54 { |
55 string res=\ | 55 string res=\ |
56 "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n\ | 56 "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n\ |
57 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\ | 57 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\ |
58 @prefix vamp: <http://www.vamp-plugins.org/ontology/> .\n\ | 58 @prefix vamp: <http://www.purl.org/ontology/vamp/> .\n\ |
59 @prefix vampex: <http://www.vamp-plugins.org/examples/> .\n\ | 59 @prefix vampex: <http://www.purl.org/ontology/vamp/examples/> .\n\ |
60 @prefix plugbase: <"+pluginBundleBaseURI+"> .\n\ | 60 @prefix plugbase: <"+pluginBundleBaseURI+"> .\n\ |
61 @prefix owl: <http://www.w3.org/2002/07/owl#> .\n\ | 61 @prefix owl: <http://www.w3.org/2002/07/owl#> .\n\ |
62 @prefix dc: <http://purl.org/dc/elements/1.1/> .\n\ | 62 @prefix dc: <http://purl.org/dc/elements/1.1/> .\n\ |
63 @prefix af: <http://purl.org/ontology/af/> .\n\ | 63 @prefix af: <http://purl.org/ontology/af/> .\n\ |
64 @prefix foaf: <http://xmlns.com/foaf/0.1/> .\n\ | 64 @prefix foaf: <http://xmlns.com/foaf/0.1/> .\n\ |
83 string describe_plugin(Plugin* plugin) | 83 string describe_plugin(Plugin* plugin) |
84 { | 84 { |
85 string res=\ | 85 string res=\ |
86 "plugbase:"+plugin->getIdentifier()+" a vamp:Plugin ;\n\ | 86 "plugbase:"+plugin->getIdentifier()+" a vamp:Plugin ;\n\ |
87 dc:title \""+plugin->getName()+"\" ;\n\ | 87 dc:title \""+plugin->getName()+"\" ;\n\ |
88 vamp:name \""+plugin->getName()+"\" ;\n\ | |
88 dc:description \""+plugin->getDescription()+"\" ;\n\ | 89 dc:description \""+plugin->getDescription()+"\" ;\n\ |
89 foaf:maker [ foaf:name \""+plugin->getMaker()+"\"] ; # FIXME could give plugin author's URI here\n\ | 90 foaf:maker [ foaf:name \""+plugin->getMaker()+"\"] ; # FIXME could give plugin author's URI here\n\ |
90 cc:license <FIXME license for the plugin> ; \n\ | 91 cc:license <FIXME license for the plugin> ; \n\ |
91 vamp:identifier \""+plugin->getIdentifier()+"\" ;\n\ | 92 vamp:identifier \""+plugin->getIdentifier()+"\" ;\n\ |
92 vamp:vamp_API_version vamp:api_version_"+to_string(plugin->getVampApiVersion())+" ;\n\ | 93 vamp:vamp_API_version vamp:api_version_"+to_string(plugin->getVampApiVersion())+" ;\n\ |
115 string res=\ | 116 string res=\ |
116 "thisplug:param_"+p.identifier+" a vamp:ParameterDescriptor ;\n\ | 117 "thisplug:param_"+p.identifier+" a vamp:ParameterDescriptor ;\n\ |
117 vamp:identifier \""+p.identifier+"\" ;\n\ | 118 vamp:identifier \""+p.identifier+"\" ;\n\ |
118 dc:title \""+p.name+"\" ;\n\ | 119 dc:title \""+p.name+"\" ;\n\ |
119 dc:format \""+p.unit+"\" ;\n\ | 120 dc:format \""+p.unit+"\" ;\n\ |
120 vamp:minValue "+to_string(p.minValue)+" ;\n\ | 121 vamp:min_value "+to_string(p.minValue)+" ;\n\ |
121 vamp:maxValue "+to_string(p.maxValue)+" ;\n\ | 122 vamp:max_value "+to_string(p.maxValue)+" ;\n\ |
122 vamp:defaultValue "+to_string(p.defaultValue)+" .\n\n"; | 123 vamp:default_value "+to_string(p.defaultValue)+" .\n\n"; |
123 return res; | 124 return res; |
124 } | 125 } |
125 | 126 |
126 string describe_output(Plugin::OutputDescriptor o) | 127 string describe_output(Plugin::OutputDescriptor o) |
127 { | 128 { |
128 string res=\ | 129 |
129 "thisplug:output_"+o.identifier+" a vamp:OutputDescriptor ;\n\ | 130 //we need to distinguish here between different output types: |
130 vamp:identifier \""+o.identifier+"\" ;\n\ | 131 //DenseOutput |
131 dc:title \""+o.name+"\" ;\n\ | 132 //SparseOutput |
132 vamp:fixed_bin_count \""+(o.hasFixedBinCount == 1 ? "true" : "false")+"\" ;\n"; | 133 //TrackLevelOutput |
133 | 134 |
134 // FIXME ? Bin names may vary based on plugin setup, so including them here might be misleading... | 135 |
135 if (o.hasFixedBinCount) | 136 //SparseOutput: variable sample rate. Events are not evenly spaced so we need to record the time associated with the event as it its not ensured that we have an event after the next one (but there is not time to set the duration, it has to be calculated as the different between 2 different events). The timestamp must be read. |
137 | |
138 string res; | |
139 | |
140 if (o.sampleType == Plugin::OutputDescriptor::VariableSampleRate) | |
136 { | 141 { |
137 res+=" vamp:bin_count "+to_string(o.binCount)+" ;\n"; | 142 |
138 res+=" vamp:bin_names ("; | 143 res=\ |
144 "thisplug:output_"+o.identifier+" a vamp:SparseOutput ;\n\ | |
145 vamp:identifier \""+o.identifier+"\" ;\n\ | |
146 dc:title \""+o.name+"\" ;\n\ | |
147 dc:description \""+o.description+"\" ;\n\ | |
148 vamp:fixed_bin_count \""+(o.hasFixedBinCount == 1 ? "true" : "false")+"\" ;\n\ | |
149 vamp:is_quantized \""+(o.isQuantized == 1 ? "true" : "false")+"\" ;\n\ | |
150 vamp:unit \""+(o.unit)+"\" ;\n"; | |
151 | |
152 | |
153 | |
154 // FIXME ? Bin names may vary based on plugin setup, so including them here might be misleading... | |
155 if (o.hasFixedBinCount) | |
156 { | |
157 res+=" vamp:bin_count "+to_string(o.binCount)+" ;\n"; | |
158 res+=" vamp:bin_names ("; | |
139 | 159 |
140 unsigned int i; | 160 unsigned int i; |
141 for (i=0; i+1 < o.binNames.size(); i++) | 161 for (i=0; i+1 < o.binNames.size(); i++) |
142 res+=" \""+o.binNames[i]+"\""; | 162 res+=" \""+o.binNames[i]+"\""; |
143 if (i < o.binNames.size()) | 163 if (i < o.binNames.size()) |
144 res+=" \""+o.binNames[i]+"\""; | 164 res+=" \""+o.binNames[i]+"\""; |
145 res+=");\n"; | 165 res+=");\n"; |
146 } | 166 } |
147 | 167 |
148 if (o.sampleType == Plugin::OutputDescriptor::VariableSampleRate) | 168 if (o.isQuantized) |
149 { | 169 { |
150 res+=" vamp:sample_type vamp:VariableSampleRate ;\n"; | 170 res+=" vamp:quantize_step "+to_string(o.quantizeStep)+" ;\n"; |
171 } | |
172 | |
173 res+=" vamp:sample_type vamp:VariableSampleRate ;\n"; | |
151 if (o.sampleRate > 0.0f) | 174 if (o.sampleRate > 0.0f) |
152 res+=" vamp:sample_rate "+to_string(o.sampleRate)+" ;\n"; | 175 res+=" vamp:sample_rate "+to_string(o.sampleRate)+" ;\n"; |
153 } | 176 |
154 else if (o.sampleType == Plugin::OutputDescriptor::FixedSampleRate) | 177 } |
155 { | 178 |
156 res+=" vamp:sample_type vamp:FixedSampleRate ;\n"; | 179 //If we do not have SparseOutput, then we have DenseOutput. TrackLevelOutput can not be inferred from the plugin directly without actually |
157 res+=" vamp:sample_rate "+to_string(o.sampleRate)+" ;\n"; | 180 //running the plugin. |
158 } | 181 else{ |
159 else if (o.sampleType == Plugin::OutputDescriptor::OneSamplePerStep) | 182 |
160 res+=" vamp:sample_type vamp:OneSamplePerStep ;\n"; | 183 res=\ |
161 else | 184 "thisplug:output_"+o.identifier+" a vamp:DenseOutput ;\n\ |
162 { | 185 vamp:identifier \""+o.identifier+"\" ;\n\ |
163 cerr<<"Incomprehensible sampleType for output descriptor "+o.identifier<<" !"<<endl; | 186 dc:title \""+o.name+"\" ;\n\ |
164 exit(1); | 187 dc:description \""+o.description+"\" ;\n\ |
165 } | 188 vamp:fixed_bin_count \""+(o.hasFixedBinCount == 1 ? "true" : "false")+"\" ;\n\ |
166 | 189 vamp:is_quantised \""+(o.isQuantized == 1 ? "true" : "false")+"\" ;\n\ |
190 vamp:unit \""+(o.unit)+"\" ;\n"; | |
191 | |
192 | |
193 | |
194 // FIXME ? Bin names may vary based on plugin setup, so including them here might be misleading... | |
195 if (o.hasFixedBinCount) | |
196 { | |
197 res+=" vamp:bin_count "+to_string(o.binCount)+" ;\n"; | |
198 res+=" vamp:bin_names ("; | |
199 | |
200 unsigned int i; | |
201 for (i=0; i+1 < o.binNames.size(); i++) | |
202 res+=" \""+o.binNames[i]+"\""; | |
203 if (i < o.binNames.size()) | |
204 res+=" \""+o.binNames[i]+"\""; | |
205 res+=");\n"; | |
206 } | |
207 | |
208 if (o.isQuantized) | |
209 { | |
210 res+=" vamp:quantize_step "+to_string(o.quantizeStep)+" ;\n"; | |
211 } | |
212 | |
213 | |
214 else if (o.sampleType == Plugin::OutputDescriptor::FixedSampleRate) | |
215 { | |
216 res+=" vamp:sample_type vamp:FixedSampleRate ;\n"; | |
217 res+=" vamp:sample_rate "+to_string(o.sampleRate)+" ;\n"; | |
218 } | |
219 else if (o.sampleType == Plugin::OutputDescriptor::OneSamplePerStep) | |
220 res+=" vamp:sample_type vamp:OneSamplePerStep ;\n"; | |
221 else | |
222 { | |
223 cerr<<"Incomprehensible sampleType for output descriptor "+o.identifier<<" !"<<endl; | |
224 exit(1); | |
225 } | |
226 } | |
227 | |
228 //There is no way to know this in advance, but we can use the km a bit for this. | |
167 res+=" vamp:computes_feature_type <FIXME feature type URI> ;\n"; | 229 res+=" vamp:computes_feature_type <FIXME feature type URI> ;\n"; |
168 res+=" vamp:computes_event_type <FIXME event type URI> ;\n"; | 230 res+=" vamp:computes_event_type <FIXME event type URI> ;\n"; |
169 res+=" .\n"; | 231 res+=" .\n"; |
170 | 232 |
171 return res; | 233 return res; |
172 } | 234 } |
235 | |
173 string describe(Plugin* plugin, string pluginBundleBaseURI, string describerURI) | 236 string describe(Plugin* plugin, string pluginBundleBaseURI, string describerURI) |
174 { | 237 { |
175 string res = describe_namespaces(plugin, pluginBundleBaseURI); | 238 string res = describe_namespaces(plugin, pluginBundleBaseURI); |
176 | 239 |
177 res += describe_doc(plugin, describerURI); | 240 res += describe_doc(plugin, describerURI); |