Changeset 6138b266a4a6d8c7ca668cbd2de4aa4f2ee4da59 for lv2filter.c
- Timestamp:
- 06/06/09 15:59:48 (3 years ago)
- Children:
- 32f245638cfcf98a8ed5832fdf305da107dc6d7e
- Parents:
- 82d3db57c220e736e7320faeb86381299e1b08e9
- git-committer:
- Nedko Arnaudov <nedko@arnaudov.name> / 2009-06-06T15:59:48Z+0300
- Files:
-
- 1 modified
-
lv2filter.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lv2filter.c
r3969583 r6138b26 34 34 #define BANDS_COUNT 4 35 35 36 #define LV2_PORT_AUDIO_IN 0 37 #define LV2_PORT_AUDIO_OUT 1 38 #define LV2_PORTS_COUNT (2 + GLOBAL_PARAMETERS_COUNT + BANDS_COUNT * BAND_PARAMETERS_COUNT) 36 #define LV2_PORT_MONO_AUDIO_IN 0 37 #define LV2_PORT_MONO_AUDIO_OUT 1 38 #define LV2_MONO_AUDIO_PORT_COUNT 2 39 #define LV2_PORTS_COUNT_MONO (LV2_MONO_AUDIO_PORT_COUNT + GLOBAL_PARAMETERS_COUNT + BANDS_COUNT * BAND_PARAMETERS_COUNT) 40 41 #define LV2_PORT_LEFT_AUDIO_IN 0 42 #define LV2_PORT_RIGHT_AUDIO_IN 1 43 #define LV2_PORT_LEFT_AUDIO_OUT 2 44 #define LV2_PORT_RIGHT_AUDIO_OUT 3 45 #define LV2_STEREO_AUDIO_PORT_COUNT 4 46 #define LV2_PORTS_COUNT_STEREO (LV2_STEREO_AUDIO_PORT_COUNT + GLOBAL_PARAMETERS_COUNT + BANDS_COUNT * BAND_PARAMETERS_COUNT) 39 47 40 48 struct lv2filter 41 49 { 50 bool stereo; 42 51 filter_handle filter; 52 filter_handle filter_right; 43 53 char * bundle_path; 44 54 const float * audio_in; 55 const float * audio_in_right; 45 56 float * audio_out; 57 float * audio_out_right; 46 58 const LV2_Feature * const * host_features; 47 59 }; … … 58 70 59 71 LOG_DEBUG("lv2filter_create_plugin_instance() called."); 72 LOG_DEBUG("uri = \"%s\"", descriptor->URI); 60 73 LOG_DEBUG("sample_rate = %f", sample_rate); 61 74 LOG_DEBUG("bundle_path = \"%s\"", bundle_path); … … 74 87 goto fail; 75 88 } 76 89 90 if (strcmp(descriptor->URI, LV2FILTER_STEREO_URI) == 0) 91 { 92 lv2filter_ptr->stereo = true; 93 } 94 else if (strcmp(descriptor->URI, LV2FILTER_MONO_URI) == 0) 95 { 96 lv2filter_ptr->stereo = false; 97 } 98 else 99 { 100 assert(false); 101 goto fail_free_instance; 102 } 103 77 104 lv2filter_ptr->host_features = host_features; 78 105 … … 88 115 } 89 116 117 if (lv2filter_ptr->stereo) 118 { 119 if (!filter_create(sample_rate, BANDS_COUNT, &lv2filter_ptr->filter_right)) 120 { 121 goto fail_destroy_filter; 122 } 123 } 124 90 125 return (LV2_Handle)lv2filter_ptr; 126 127 fail_destroy_filter: 128 filter_destroy(lv2filter_ptr->filter); 91 129 92 130 fail_free_bundle_path: … … 112 150 LOG_DEBUG("lv2filter_run"); 113 151 filter_run( 114 lv2filter_ptr->filter, 152 lv2filter_ptr->filter, 115 153 lv2filter_ptr->audio_in, 116 154 lv2filter_ptr->audio_out, 117 155 samples_count); 156 157 if (lv2filter_ptr->stereo) 158 { 159 filter_run( 160 lv2filter_ptr->filter_right, 161 lv2filter_ptr->audio_in_right, 162 lv2filter_ptr->audio_out_right, 163 samples_count); 164 } 118 165 } 119 166 … … 123 170 { 124 171 filter_destroy(lv2filter_ptr->filter); 172 173 if (lv2filter_ptr->stereo) 174 { 175 filter_destroy(lv2filter_ptr->filter_right); 176 } 177 125 178 free(lv2filter_ptr->bundle_path); 126 179 free(lv2filter_ptr); … … 135 188 LOG_DEBUG("lv2filter_connect_port %u %p", (unsigned int)port, data_location); 136 189 137 if (port >= LV2_PORTS_COUNT) 138 { 139 assert(0); 140 return; 141 } 142 143 if (port == LV2_PORT_AUDIO_IN) 144 { 145 lv2filter_ptr->audio_in = data_location; 146 } 147 else if (port == LV2_PORT_AUDIO_OUT) 148 { 149 lv2filter_ptr->audio_out = data_location; 190 if (lv2filter_ptr->stereo) 191 { 192 if (port >= LV2_PORTS_COUNT_STEREO) 193 { 194 assert(0); 195 return; 196 } 197 198 if (port == LV2_PORT_LEFT_AUDIO_IN) 199 { 200 lv2filter_ptr->audio_in = data_location; 201 } 202 else if (port == LV2_PORT_LEFT_AUDIO_OUT) 203 { 204 lv2filter_ptr->audio_out = data_location; 205 } 206 else if (port == LV2_PORT_RIGHT_AUDIO_IN) 207 { 208 lv2filter_ptr->audio_in_right = data_location; 209 } 210 else if (port == LV2_PORT_RIGHT_AUDIO_OUT) 211 { 212 lv2filter_ptr->audio_out_right = data_location; 213 } 214 else 215 { 216 assert(port >= LV2_STEREO_AUDIO_PORT_COUNT); 217 port -= LV2_STEREO_AUDIO_PORT_COUNT; 218 if (port < GLOBAL_PARAMETERS_COUNT) 219 { 220 filter_connect_global_parameter(lv2filter_ptr->filter, port, data_location); 221 filter_connect_global_parameter(lv2filter_ptr->filter_right, port, data_location); 222 } 223 else 224 { 225 assert(port >= GLOBAL_PARAMETERS_COUNT); 226 port -= GLOBAL_PARAMETERS_COUNT; 227 228 filter_connect_band_parameter(lv2filter_ptr->filter, port / BANDS_COUNT, port % BANDS_COUNT, data_location); 229 filter_connect_band_parameter(lv2filter_ptr->filter_right, port / BANDS_COUNT, port % BANDS_COUNT, data_location); 230 } 231 } 150 232 } 151 233 else 152 234 { 153 port -= 2; 154 if (port < GLOBAL_PARAMETERS_COUNT) 155 { 156 filter_connect_global_parameter(lv2filter_ptr->filter, port, data_location); 235 if (port >= LV2_PORTS_COUNT_MONO) 236 { 237 assert(0); 238 return; 239 } 240 241 if (port == LV2_PORT_MONO_AUDIO_IN) 242 { 243 lv2filter_ptr->audio_in = data_location; 244 } 245 else if (port == LV2_PORT_MONO_AUDIO_OUT) 246 { 247 lv2filter_ptr->audio_out = data_location; 157 248 } 158 249 else 159 250 { 160 port -= GLOBAL_PARAMETERS_COUNT; 161 162 filter_connect_band_parameter(lv2filter_ptr->filter, port / BANDS_COUNT, port % BANDS_COUNT, data_location); 251 port -= LV2_MONO_AUDIO_PORT_COUNT; 252 if (port < GLOBAL_PARAMETERS_COUNT) 253 { 254 filter_connect_global_parameter(lv2filter_ptr->filter, port, data_location); 255 } 256 else 257 { 258 port -= GLOBAL_PARAMETERS_COUNT; 259 260 filter_connect_band_parameter(lv2filter_ptr->filter, port / BANDS_COUNT, port % BANDS_COUNT, data_location); 261 } 163 262 } 164 263 }
