Changeset 6138b266a4a6d8c7ca668cbd2de4aa4f2ee4da59

Show
Ignore:
Timestamp:
06/06/09 15:59:48 (3 years ago)
Author:
Nedko Arnaudov <nedko@…>
Children:
32f245638cfcf98a8ed5832fdf305da107dc6d7e
Parents:
82d3db57c220e736e7320faeb86381299e1b08e9
git-committer:
Nedko Arnaudov <nedko@arnaudov.name> / 2009-06-06T15:59:48Z+0300
Message:

Stereo plugin

Files:
6 modified

Legend:

Unmodified
Added
Removed
  • filter.ttl

    r364ee15 r6138b26  
    2020    foaf:mbox <mailto:nedko@arnaudov.name>; 
    2121  ]; 
    22   doap:name "4-band parametric filter"; 
     22  doap:name "4-band parametric filter (Mono)"; 
    2323  doap:license <http://usefulinc.com/doap/licenses/gpl>; 
    2424 
     
    273273    ue:unit ue:db; 
    274274  ]. 
     275 
     276<http://nedko.aranaudov.org/soft/filter/1/stereo> 
     277  a lv2:Plugin; 
     278  a lv2:FilterPlugin; 
     279  doap:maintainer [ 
     280    foaf:name "Nedko Arnaudov"; 
     281    foaf:homepage <http://nedko.arnaudov.name/>; 
     282    foaf:mbox <mailto:nedko@arnaudov.name>; 
     283  ]; 
     284  doap:name "4-band parametric filter (Stereo)"; 
     285  doap:license <http://usefulinc.com/doap/licenses/gpl>; 
     286 
     287  uiext:ui <http://nedko.aranaudov.org/soft/filter/1/gui>; 
     288 
     289  lv2:port [ 
     290    a lv2:InputPort, lv2:AudioPort; 
     291    lv2:datatype lv2:float; 
     292    lv2:index 0; 
     293    lv2:symbol "in_left"; 
     294    lv2:name "left audio input"; 
     295  ], 
     296 
     297  [ 
     298    a lv2:InputPort, lv2:AudioPort; 
     299    lv2:datatype lv2:float; 
     300    lv2:index 1; 
     301    lv2:symbol "in_right"; 
     302    lv2:name "Right audio input"; 
     303  ], 
     304 
     305  [ 
     306    a lv2:OutputPort, lv2:AudioPort; 
     307    lv2:datatype lv2:float; 
     308    lv2:index 2; 
     309    lv2:symbol "out_left"; 
     310    lv2:name "Left audio output"; 
     311  ], 
     312 
     313  [ 
     314    a lv2:OutputPort, lv2:AudioPort; 
     315    lv2:datatype lv2:float; 
     316    lv2:index 3; 
     317    lv2:symbol "out_right"; 
     318    lv2:name "Right audio output"; 
     319  ], 
     320 
     321  [ 
     322    a lv2:InputPort; 
     323    a lv2:ControlPort; 
     324    lv2:index 4; 
     325    lv2:symbol "active"; 
     326    lv2:name "Active"; 
     327    lv2:default 0.0; 
     328    lv2:minimum 0.0; 
     329    lv2:maximum 1.0; 
     330    lv2:portProperty lv2:toggled; 
     331  ], 
     332 
     333  [ 
     334    a lv2:InputPort; 
     335    a lv2:ControlPort; 
     336    lv2:index 5; 
     337    lv2:symbol "gain"; 
     338    lv2:name "Gain"; 
     339    lv2:default 0.0; 
     340    lv2:minimum -20.0; 
     341    lv2:maximum 20.0; 
     342    lv2:portProperty epp:hasStrictBounds; 
     343    ue:unit ue:db; 
     344  ], 
     345 
     346  [ 
     347    a lv2:InputPort; 
     348    a lv2:ControlPort; 
     349    lv2:index 6; 
     350    lv2:symbol "active1"; 
     351    lv2:name "Active1"; 
     352    lv2:default 0.0; 
     353    lv2:minimum 0.0; 
     354    lv2:maximum 1.0; 
     355    lv2:portProperty lv2:toggled; 
     356  ], 
     357 
     358  [ 
     359    a lv2:InputPort; 
     360    a lv2:ControlPort; 
     361    lv2:index 7; 
     362    lv2:symbol "freq1"; 
     363    lv2:name "Frequency 1"; 
     364    lv2:default 200.0; 
     365    lv2:minimum 20.0; 
     366    lv2:maximum 2000.0; 
     367    lv2:portProperty epp:hasStrictBounds; 
     368    lv2:portProperty epp:logarithmic; 
     369    ue:unit ue:hz; 
     370  ], 
     371 
     372  [ 
     373    a lv2:InputPort; 
     374    a lv2:ControlPort; 
     375    lv2:index 8; 
     376    lv2:symbol "bandwidth1"; 
     377    lv2:name "Bandwidth 1"; 
     378    lv2:default 1.0; 
     379    lv2:minimum 0.125; 
     380    lv2:maximum 8.0; 
     381    lv2:portProperty epp:hasStrictBounds; 
     382    lv2:portProperty epp:logarithmic; 
     383  ], 
     384 
     385  [ 
     386    a lv2:InputPort; 
     387    a lv2:ControlPort; 
     388    lv2:index 9; 
     389    lv2:symbol "gain1"; 
     390    lv2:name "Gain 1"; 
     391    lv2:default 0.0; 
     392    lv2:minimum -20.0; 
     393    lv2:maximum 20.0; 
     394    lv2:portProperty epp:hasStrictBounds; 
     395    ue:unit ue:db; 
     396  ], 
     397 
     398  [ 
     399    a lv2:InputPort; 
     400    a lv2:ControlPort; 
     401    lv2:index 10; 
     402    lv2:symbol "active2"; 
     403    lv2:name "Active 2"; 
     404    lv2:default 0.0; 
     405    lv2:minimum 0.0; 
     406    lv2:maximum 1.0; 
     407    lv2:portProperty lv2:toggled; 
     408  ], 
     409 
     410  [ 
     411    a lv2:InputPort; 
     412    a lv2:ControlPort; 
     413    lv2:index 11; 
     414    lv2:symbol "frequency2"; 
     415    lv2:name "Frequency 2"; 
     416    lv2:default 400; 
     417    lv2:minimum 40; 
     418    lv2:maximum 4000; 
     419    lv2:portProperty epp:hasStrictBounds; 
     420    lv2:portProperty epp:logarithmic; 
     421    ue:unit ue:hz; 
     422  ], 
     423 
     424  [ 
     425    a lv2:InputPort; 
     426    a lv2:ControlPort; 
     427    lv2:index 12; 
     428    lv2:symbol "bandwidth2"; 
     429    lv2:name "Bandwidth 2"; 
     430    lv2:default 1.0; 
     431    lv2:minimum 0.125; 
     432    lv2:maximum 8.0; 
     433    lv2:portProperty epp:hasStrictBounds; 
     434    lv2:portProperty epp:logarithmic; 
     435  ], 
     436 
     437  [ 
     438    a lv2:InputPort; 
     439    a lv2:ControlPort; 
     440    lv2:index 13; 
     441    lv2:symbol "gain2"; 
     442    lv2:name "Gain 2"; 
     443    lv2:default 0.0; 
     444    lv2:minimum -20.0; 
     445    lv2:maximum 20.0; 
     446    lv2:portProperty epp:hasStrictBounds; 
     447    ue:unit ue:db; 
     448  ], 
     449 
     450  [ 
     451    a lv2:InputPort; 
     452    a lv2:ControlPort; 
     453    lv2:index 14; 
     454    lv2:symbol "active3"; 
     455    lv2:name "Active 3"; 
     456    lv2:default 0.0; 
     457    lv2:minimum 0.0; 
     458    lv2:maximum 1.0; 
     459    lv2:portProperty lv2:toggled; 
     460  ], 
     461 
     462  [ 
     463    a lv2:InputPort; 
     464    a lv2:ControlPort; 
     465    lv2:index 15; 
     466    lv2:symbol "frequency3"; 
     467    lv2:name "Frequency 3"; 
     468    lv2:default 1000; 
     469    lv2:minimum 100; 
     470    lv2:maximum 10000; 
     471    lv2:portProperty epp:hasStrictBounds; 
     472    lv2:portProperty epp:logarithmic; 
     473    ue:unit ue:hz; 
     474  ], 
     475 
     476  [ 
     477    a lv2:InputPort; 
     478    a lv2:ControlPort; 
     479    lv2:index 16; 
     480    lv2:symbol "bandwidth3"; 
     481    lv2:name "Bandwidth 3"; 
     482    lv2:default 1.0; 
     483    lv2:minimum 0.125; 
     484    lv2:maximum 8.0; 
     485    lv2:portProperty epp:hasStrictBounds; 
     486    lv2:portProperty epp:logarithmic; 
     487  ], 
     488 
     489  [ 
     490    a lv2:InputPort; 
     491    a lv2:ControlPort; 
     492    lv2:index 17; 
     493    lv2:symbol "gain3"; 
     494    lv2:name "Gain 3"; 
     495    lv2:default 0.0; 
     496    lv2:minimum -20.0; 
     497    lv2:maximum 20.0; 
     498    lv2:portProperty epp:hasStrictBounds; 
     499    ue:unit ue:db; 
     500  ], 
     501 
     502  [ 
     503    a lv2:InputPort; 
     504    a lv2:ControlPort; 
     505    lv2:index 18; 
     506    lv2:symbol "active4"; 
     507    lv2:name "Active 4"; 
     508    lv2:default 0.0; 
     509    lv2:minimum 0.0; 
     510    lv2:maximum 1.0; 
     511    lv2:portProperty lv2:toggled; 
     512  ], 
     513 
     514  [ 
     515    a lv2:InputPort; 
     516    a lv2:ControlPort; 
     517    lv2:index 19; 
     518    lv2:symbol "frequency4"; 
     519    lv2:name "Frequency 4"; 
     520    lv2:default 2000; 
     521    lv2:minimum 200; 
     522    lv2:maximum 20000; 
     523    lv2:portProperty epp:hasStrictBounds; 
     524    lv2:portProperty epp:logarithmic; 
     525    ue:unit ue:hz; 
     526  ], 
     527 
     528  [ 
     529    a lv2:InputPort; 
     530    a lv2:ControlPort; 
     531    lv2:index 20; 
     532    lv2:symbol "bandwidth4"; 
     533    lv2:name "Bandwidth 4"; 
     534    lv2:default 1.0; 
     535    lv2:minimum 0.125; 
     536    lv2:maximum 8.0; 
     537    lv2:portProperty epp:hasStrictBounds; 
     538    lv2:portProperty epp:logarithmic; 
     539  ], 
     540 
     541  [ 
     542    a lv2:InputPort; 
     543    a lv2:ControlPort; 
     544    lv2:index 21; 
     545    lv2:symbol "gain4"; 
     546    lv2:name "Gain 4"; 
     547    lv2:default 0.0; 
     548    lv2:minimum -20.0; 
     549    lv2:maximum 20.0; 
     550    lv2:portProperty epp:hasStrictBounds; 
     551    ue:unit ue:db; 
     552  ]. 
  • lv2filter.c

    r3969583 r6138b26  
    3434#define BANDS_COUNT 4 
    3535 
    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) 
    3947 
    4048struct lv2filter 
    4149{ 
     50  bool stereo; 
    4251  filter_handle filter; 
     52  filter_handle filter_right; 
    4353  char * bundle_path; 
    4454  const float * audio_in; 
     55  const float * audio_in_right; 
    4556  float * audio_out; 
     57  float * audio_out_right; 
    4658  const LV2_Feature * const * host_features; 
    4759}; 
     
    5870 
    5971  LOG_DEBUG("lv2filter_create_plugin_instance() called."); 
     72  LOG_DEBUG("uri = \"%s\"", descriptor->URI); 
    6073  LOG_DEBUG("sample_rate = %f", sample_rate); 
    6174  LOG_DEBUG("bundle_path = \"%s\"", bundle_path); 
     
    7487    goto fail; 
    7588  } 
    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 
    77104  lv2filter_ptr->host_features = host_features; 
    78105 
     
    88115  } 
    89116 
     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 
    90125  return (LV2_Handle)lv2filter_ptr; 
     126 
     127fail_destroy_filter: 
     128  filter_destroy(lv2filter_ptr->filter); 
    91129 
    92130fail_free_bundle_path: 
     
    112150  LOG_DEBUG("lv2filter_run"); 
    113151  filter_run( 
    114     lv2filter_ptr->filter,  
     152    lv2filter_ptr->filter, 
    115153    lv2filter_ptr->audio_in, 
    116154    lv2filter_ptr->audio_out, 
    117155    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  } 
    118165} 
    119166 
     
    123170{ 
    124171  filter_destroy(lv2filter_ptr->filter); 
     172 
     173  if (lv2filter_ptr->stereo) 
     174  { 
     175    filter_destroy(lv2filter_ptr->filter_right); 
     176  } 
     177 
    125178  free(lv2filter_ptr->bundle_path); 
    126179  free(lv2filter_ptr); 
     
    135188  LOG_DEBUG("lv2filter_connect_port %u %p", (unsigned int)port, data_location); 
    136189 
    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    } 
    150232  } 
    151233  else 
    152234  { 
    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; 
    157248    } 
    158249    else 
    159250    { 
    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      } 
    163262    } 
    164263  } 
  • lv2filter.h

    r3969583 r6138b26  
    2121#ifndef LV2FILTER_H__6EC1E456_7DD7_4536_B8D3_F23BE4583A23__INCLUDED 
    2222#define LV2FILTER_H__6EC1E456_7DD7_4536_B8D3_F23BE4583A23__INCLUDED 
     23 
     24#define LV2FILTER_MONO_URI   "http://nedko.aranaudov.org/soft/filter/1/mono" 
     25#define LV2FILTER_STEREO_URI "http://nedko.aranaudov.org/soft/filter/1/stereo" 
    2326 
    2427LV2_Handle 
  • lv2plugin.c

    r364ee15 r6138b26  
    2929{ 
    3030  { 
    31     .URI = "http://nedko.aranaudov.org/soft/filter/1/mono", 
     31    .URI = LV2FILTER_MONO_URI, 
     32    .instantiate = lv2filter_instantiate, 
     33    .connect_port = lv2filter_connect_port, 
     34    .run = lv2filter_run, 
     35    .cleanup = lv2filter_cleanup, 
     36    .extension_data = lv2filter_extension_data 
     37  }, 
     38  { 
     39    .URI = LV2FILTER_STEREO_URI, 
    3240    .instantiate = lv2filter_instantiate, 
    3341    .connect_port = lv2filter_connect_port, 
  • manifest.ttl

    r364ee15 r6138b26  
    77  lv2:binary <filter.so>; 
    88  rdfs:seeAlso <filter.ttl>. 
     9 
     10<http://nedko.aranaudov.org/soft/filter/1/stereo> 
     11  a lv2:Plugin; 
     12  a lv2:FilterPlugin; 
     13  lv2:binary <filter.so>; 
     14  rdfs:seeAlso <filter.ttl>. 
  • ui

    r82d3db5 r6138b26  
    700700        dssi_ui.__init__(self, argv) 
    701701 
     702        if self.plugin_uri == "http://nedko.aranaudov.org/soft/filter/1/mono": 
     703            self.port_base = 2 
     704        elif self.plugin_uri == "http://nedko.aranaudov.org/soft/filter/1/stereo": 
     705            self.port_base = 4 
     706        else: 
     707            return 
     708 
    702709        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) 
    703710        #self.window.set_size_request(600, 400) 
     
    744751        freq_max = [2000.0, 4000.0, 10000.0, 20000.0] 
    745752 
    746         self.port_base = 2 
    747         port_index = self.port_base 
     753        port_index = 2 
    748754 
    749755        for i in [0, 1, 2, 3]: