comparison rdf/generator/template-generator.cpp @ 148:afd60ff5ceef

* Commit updates from David to deal with quantized outputs and known-range outputs
author cannam
date Mon, 23 Jun 2008 13:05:21 +0000
parents 27da08f3e951
children 58f4d399a85d
comparison
equal deleted inserted replaced
147:27da08f3e951 148:afd60ff5ceef
118 return res; 118 return res;
119 } 119 }
120 120
121 string describe_param(Plugin *plugin, Plugin::ParameterDescriptor p) 121 string describe_param(Plugin *plugin, Plugin::ParameterDescriptor p)
122 { 122 {
123
124 //FIXME: dc:format and vamp:unit are the same???
125 if(p.isQuantized){
126 string res=\
127 "plugbase:"+plugin->getIdentifier()+"_param_"+p.identifier+" a vamp:QuantizedParameterDescriptor ;\n\
128 vamp:identifier \""+p.identifier+"\" ;\n\
129 dc:title \""+p.name+"\" ;\n\
130 dc:format \""+p.unit+"\" ;\n\
131 vamp:min_value "+to_string(p.minValue)+" ;\n\
132 vamp:max_value "+to_string(p.maxValue)+" ;\n\
133 vamp:unit \""+p.unit+"\" ;\n\
134 vamo:quantize_step "+to_string(p.quantizeStep)+" ;\n\
135 vamp:default_value "+to_string(p.defaultValue)+" ;\n\
136 vamp:value_names (";
137
138 unsigned int i;
139 for (i=0; i+1 < p.valueNames.size(); i++)
140 res+=" \""+p.valueNames[i]+"\"";
141 if (i < p.valueNames.size())
142 res+=" \""+p.valueNames[i]+"\"";
143 res+=");\n";
144
145 res+=" .\n";
146
147 return res;
148
149 }else{
123 string res=\ 150 string res=\
124 "plugbase:"+plugin->getIdentifier()+"_param_"+p.identifier+" a vamp:ParameterDescriptor ;\n\ 151 "plugbase:"+plugin->getIdentifier()+"_param_"+p.identifier+" a vamp:ParameterDescriptor ;\n\
125 vamp:identifier \""+p.identifier+"\" ;\n\ 152 vamp:identifier \""+p.identifier+"\" ;\n\
126 dc:title \""+p.name+"\" ;\n\ 153 dc:title \""+p.name+"\" ;\n\
127 dc:format \""+p.unit+"\" ;\n\ 154 dc:format \""+p.unit+"\" ;\n\
128 vamp:min_value "+to_string(p.minValue)+" ;\n\ 155 vamp:min_value "+to_string(p.minValue)+" ;\n\
129 vamp:max_value "+to_string(p.maxValue)+" ;\n\ 156 vamp:max_value "+to_string(p.maxValue)+" ;\n\
130 vamp:default_value "+to_string(p.defaultValue)+" .\n\n"; 157 vamp:unit \""+p.unit+"\" ;\n\
131 return res; 158 vamp:default_value "+to_string(p.defaultValue)+" ;\n\
159 vamp:value_names (";
160
161 unsigned int i;
162 for (i=0; i+1 < p.valueNames.size(); i++)
163 res+=" \""+p.valueNames[i]+"\"";
164 if (i < p.valueNames.size())
165 res+=" \""+p.valueNames[i]+"\"";
166 res+=");\n";
167
168 res+=" .\n";
169
170 return res;
171
172 }
132 } 173 }
133 174
134 string describe_output(Plugin *plugin, Plugin::OutputDescriptor o) 175 string describe_output(Plugin *plugin, Plugin::OutputDescriptor o)
135 { 176 {
136 177
137 //we need to distinguish here between different output types: 178 //we need to distinguish here between different output types:
179
180 //Quantize or not
181 //KnownExtents or not
182 //Data output classification:
138 //DenseOutput 183 //DenseOutput
139 //SparseOutput 184 //SparseOutput
140 //TrackLevelOutput 185 //TrackLevelOutput
141 186
142 187
151 "plugbase:"+plugin->getIdentifier()+"_output_"+o.identifier+" a vamp:SparseOutput ;\n\ 196 "plugbase:"+plugin->getIdentifier()+"_output_"+o.identifier+" a vamp:SparseOutput ;\n\
152 vamp:identifier \""+o.identifier+"\" ;\n\ 197 vamp:identifier \""+o.identifier+"\" ;\n\
153 dc:title \""+o.name+"\" ;\n\ 198 dc:title \""+o.name+"\" ;\n\
154 dc:description \""+o.description+"\" ;\n\ 199 dc:description \""+o.description+"\" ;\n\
155 vamp:fixed_bin_count \""+(o.hasFixedBinCount == 1 ? "true" : "false")+"\" ;\n\ 200 vamp:fixed_bin_count \""+(o.hasFixedBinCount == 1 ? "true" : "false")+"\" ;\n\
156 vamp:is_quantized \""+(o.isQuantized == 1 ? "true" : "false")+"\" ;\n\
157 vamp:unit \""+(o.unit)+"\" ;\n"; 201 vamp:unit \""+(o.unit)+"\" ;\n";
158 202
159 203
204 //another type of output
205 if(o.isQuantized){
206
207 res+=" a vamp:QuantizedOutput ;\n";
208 res+=" vamp:quantize_step "+to_string(o.quantizeStep)+" ;\n";
209 }
210
211 //and yet another type
212 if(o.hasKnownExtents){
213
214 res+=" a vamp:KnownExtentsOutput ;\n";
215 res+=" vamp:min_value "+to_string(o.minValue)+" ;\n";
216 res+=" vamp:max_value "+to_string(o.maxValue)+" ;\n";
217 }
160 218
161 // FIXME ? Bin names may vary based on plugin setup, so including them here might be misleading... 219 // FIXME ? Bin names may vary based on plugin setup, so including them here might be misleading...
162 if (o.hasFixedBinCount) 220 if (o.hasFixedBinCount)
163 { 221 {
164 res+=" vamp:bin_count "+to_string(o.binCount)+" ;\n"; 222 res+=" vamp:bin_count "+to_string(o.binCount)+" ;\n";
169 res+=" \""+o.binNames[i]+"\""; 227 res+=" \""+o.binNames[i]+"\"";
170 if (i < o.binNames.size()) 228 if (i < o.binNames.size())
171 res+=" \""+o.binNames[i]+"\""; 229 res+=" \""+o.binNames[i]+"\"";
172 res+=");\n"; 230 res+=");\n";
173 } 231 }
174 232
175 if (o.isQuantized)
176 {
177 res+=" vamp:quantize_step "+to_string(o.quantizeStep)+" ;\n";
178 }
179
180 res+=" vamp:sample_type vamp:VariableSampleRate ;\n"; 233 res+=" vamp:sample_type vamp:VariableSampleRate ;\n";
181 if (o.sampleRate > 0.0f) 234 if (o.sampleRate > 0.0f)
182 res+=" vamp:sample_rate "+to_string(o.sampleRate)+" ;\n"; 235 res+=" vamp:sample_rate "+to_string(o.sampleRate)+" ;\n";
183 236
184 } 237 }
191 "plugbase:"+plugin->getIdentifier()+"_output_"+o.identifier+" a vamp:DenseOutput ;\n\ 244 "plugbase:"+plugin->getIdentifier()+"_output_"+o.identifier+" a vamp:DenseOutput ;\n\
192 vamp:identifier \""+o.identifier+"\" ;\n\ 245 vamp:identifier \""+o.identifier+"\" ;\n\
193 dc:title \""+o.name+"\" ;\n\ 246 dc:title \""+o.name+"\" ;\n\
194 dc:description \""+o.description+"\" ;\n\ 247 dc:description \""+o.description+"\" ;\n\
195 vamp:fixed_bin_count \""+(o.hasFixedBinCount == 1 ? "true" : "false")+"\" ;\n\ 248 vamp:fixed_bin_count \""+(o.hasFixedBinCount == 1 ? "true" : "false")+"\" ;\n\
196 vamp:is_quantized \""+(o.isQuantized == 1 ? "true" : "false")+"\" ;\n\
197 vamp:unit \""+(o.unit)+"\" ;\n"; 249 vamp:unit \""+(o.unit)+"\" ;\n";
198 250
199 251
252 //another type of output
253 if(o.isQuantized){
254
255 res+=" a vamp:QuantizedOutput ;\n";
256 res+=" vamp:quantize_step "+to_string(o.quantizeStep)+" ;\n";
257 }
258
259 //and yet another type
260 if(o.hasKnownExtents){
261
262 res+=" a vamp:KnownExtentsOutput ;\n";
263 res+=" vamp:min_value "+to_string(o.minValue)+" ;\n";
264 res+=" vamp:max_value "+to_string(o.maxValue)+" ;\n";
265 }
200 266
201 // FIXME ? Bin names may vary based on plugin setup, so including them here might be misleading... 267 // FIXME ? Bin names may vary based on plugin setup, so including them here might be misleading...
202 if (o.hasFixedBinCount) 268 if (o.hasFixedBinCount)
203 { 269 {
204 res+=" vamp:bin_count "+to_string(o.binCount)+" ;\n"; 270 res+=" vamp:bin_count "+to_string(o.binCount)+" ;\n";
209 res+=" \""+o.binNames[i]+"\""; 275 res+=" \""+o.binNames[i]+"\"";
210 if (i < o.binNames.size()) 276 if (i < o.binNames.size())
211 res+=" \""+o.binNames[i]+"\""; 277 res+=" \""+o.binNames[i]+"\"";
212 res+=");\n"; 278 res+=");\n";
213 } 279 }
214
215 if (o.isQuantized)
216 {
217 res+=" vamp:quantize_step "+to_string(o.quantizeStep)+" ;\n";
218 }
219
220 280
221 else if (o.sampleType == Plugin::OutputDescriptor::FixedSampleRate) 281 else if (o.sampleType == Plugin::OutputDescriptor::FixedSampleRate)
222 { 282 {
223 res+=" vamp:sample_type vamp:FixedSampleRate ;\n"; 283 res+=" vamp:sample_type vamp:FixedSampleRate ;\n";
224 res+=" vamp:sample_rate "+to_string(o.sampleRate)+" ;\n"; 284 res+=" vamp:sample_rate "+to_string(o.sampleRate)+" ;\n";