Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.3KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2009 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #include "Gain_Module.H"
  19. #include <FL/Fl_Single_Window.H>
  20. #include <math.h>
  21. #include <dsp.h>
  22. Gain_Module::Gain_Module ( )
  23. : Module ( 50, 24, name() )
  24. {
  25. add_port( Port( this, Port::INPUT, Port::AUDIO ) );
  26. add_port( Port( this, Port::OUTPUT, Port::AUDIO ) );
  27. Port p( this, Port::INPUT, Port::CONTROL, "Gain (dB)" );
  28. p.hints.type = Port::Hints::LOGARITHMIC;
  29. p.hints.ranged = true;
  30. p.hints.minimum = -70.0f;
  31. // p.hints.maximum = HUGE;
  32. p.hints.maximum = 6.0f;
  33. p.hints.default_value = 0.0f;
  34. p.connect_to( new float );
  35. p.control_value( p.hints.default_value );
  36. add_port( p );
  37. // color( FL_BLACK );
  38. end();
  39. log_create();
  40. }
  41. Gain_Module::~Gain_Module ( )
  42. {
  43. delete (float*)control_input[0].buffer();
  44. log_destroy();
  45. }
  46. bool
  47. Gain_Module::configure_inputs ( int n )
  48. {
  49. audio_input.clear();
  50. audio_output.clear();
  51. // control_input.clear();
  52. for ( int i = 0; i < n; ++i )
  53. {
  54. add_port( Port( this, Port::INPUT, Port::AUDIO ) );
  55. add_port( Port( this, Port::OUTPUT, Port::AUDIO ) );
  56. // add_port( Port( this, Port::INPUT, Port::CONTROL ) );
  57. /* Port p( Port::OUTPUT, Port::CONTROL, "dB level" ); */
  58. /* p.hints.type = Port::Hints::LOGARITHMIC; */
  59. /* add_port( p ); */
  60. }
  61. return true;
  62. }
  63. void
  64. Gain_Module::process ( void )
  65. {
  66. if ( control_input[0].connected() )
  67. {
  68. float g = DB_CO( control_input[0].control_value() );
  69. for ( int i = audio_input.size(); i--; )
  70. {
  71. if ( audio_input[i].connected() && audio_output[i].connected() )
  72. {
  73. buffer_apply_gain( (sample_t*)audio_input[i].buffer(), nframes(), g );
  74. /* buffer_copy_and_apply_gain( (sample_t*)audio_output[0].buffer(), */
  75. /* (sample_t*)audio_input[0].buffer(), */
  76. /* nframes(), */
  77. /* g ); */
  78. }
  79. }
  80. }
  81. }