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.

93 lines
2.7KB

  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 <math.h>
  19. #include <dsp.h>
  20. #include "Gain_Module.H"
  21. Gain_Module::Gain_Module ( )
  22. : Module ( 50, 24, name() )
  23. {
  24. add_port( Port( this, Port::INPUT, Port::AUDIO ) );
  25. add_port( Port( this, Port::OUTPUT, Port::AUDIO ) );
  26. Port p( this, Port::INPUT, Port::CONTROL, "Gain (dB)" );
  27. p.hints.type = Port::Hints::LOGARITHMIC;
  28. p.hints.ranged = true;
  29. p.hints.minimum = -70.0f;
  30. p.hints.maximum = 6.0f;
  31. p.hints.default_value = 0.0f;
  32. p.connect_to( new float );
  33. p.control_value( p.hints.default_value );
  34. add_port( p );
  35. end();
  36. log_create();
  37. }
  38. Gain_Module::~Gain_Module ( )
  39. {
  40. delete (float*)control_input[0].buffer();
  41. log_destroy();
  42. }
  43. bool
  44. Gain_Module::configure_inputs ( int n )
  45. {
  46. audio_input.clear();
  47. audio_output.clear();
  48. // control_input.clear();
  49. for ( int i = 0; i < n; ++i )
  50. {
  51. add_port( Port( this, Port::INPUT, Port::AUDIO ) );
  52. add_port( Port( this, Port::OUTPUT, Port::AUDIO ) );
  53. }
  54. return true;
  55. }
  56. /**********/
  57. /* Engine */
  58. /**********/
  59. void
  60. Gain_Module::process ( nframes_t nframes )
  61. {
  62. float g = DB_CO( control_input[0].control_value() );
  63. for ( int i = audio_input.size(); i--; )
  64. {
  65. if ( audio_input[i].connected() && audio_output[i].connected() )
  66. {
  67. buffer_apply_gain( (sample_t*)audio_input[i].buffer(), nframes, g );
  68. }
  69. }
  70. }