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.

102 lines
3.2KB

  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" );
  28. p.hints.type = Port::Hints::LOGARITHMIC;
  29. p.hints.ranged = true;
  30. p.hints.minimum = 0.0f;
  31. // p.hints.maximum = HUGE;
  32. p.hints.maximum = 10.0f;
  33. p.hints.default_value = 1.0f;
  34. p.connect_to( new float );
  35. p.control_value( 1.0f );
  36. add_port( p );
  37. // color( FL_BLACK );
  38. end();
  39. log_create();
  40. }
  41. Gain_Module::~Gain_Module ( )
  42. {
  43. log_destroy();
  44. }
  45. bool
  46. Gain_Module::configure_inputs ( int n )
  47. {
  48. audio_input.clear();
  49. audio_output.clear();
  50. // control_input.clear();
  51. for ( int i = 0; i < n; ++i )
  52. {
  53. add_port( Port( this, Port::INPUT, Port::AUDIO ) );
  54. add_port( Port( this, Port::OUTPUT, Port::AUDIO ) );
  55. // add_port( Port( this, Port::INPUT, Port::CONTROL ) );
  56. /* Port p( Port::OUTPUT, Port::CONTROL, "dB level" ); */
  57. /* p.hints.type = Port::Hints::LOGARITHMIC; */
  58. /* add_port( p ); */
  59. }
  60. return true;
  61. }
  62. void
  63. Gain_Module::process ( void )
  64. {
  65. if ( control_input[0].connected() )
  66. {
  67. float g = control_input[0].control_value();
  68. for ( int i = audio_input.size(); i--; )
  69. {
  70. if ( audio_input[i].connected() && audio_output[i].connected() )
  71. {
  72. buffer_apply_gain( (sample_t*)audio_input[i].buffer(), nframes(), g );
  73. /* buffer_copy_and_apply_gain( (sample_t*)audio_output[0].buffer(), */
  74. /* (sample_t*)audio_input[0].buffer(), */
  75. /* nframes(), */
  76. /* g ); */
  77. }
  78. }
  79. }
  80. }