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.

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