Audio plugin host https://kx.studio/carla
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.

133 lines
5.8KB

  1. /* nekobee DSSI software synthesizer plugin
  2. *
  3. * Copyright (C) 2004 Sean Bolton and others.
  4. *
  5. * Portions of this file may have come from Peter Hanappe's
  6. * Fluidsynth, copyright (C) 2003 Peter Hanappe and others.
  7. * Portions of this file may have come from alsa-lib, copyright
  8. * and licensed under the LGPL v2.1.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be
  16. * useful, but WITHOUT ANY WARRANTY; without even the implied
  17. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  18. * PURPOSE. See the GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public
  21. * License along with this program; if not, write to the Free
  22. * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307, USA.
  24. */
  25. #ifndef _XSYNTH_SYNTH_H
  26. #define _XSYNTH_SYNTH_H
  27. #include <pthread.h>
  28. #include "nekobee.h"
  29. #include "nekobee_types.h"
  30. #define XSYNTH_MONO_MODE_OFF 0
  31. #define XSYNTH_MONO_MODE_ON 1
  32. #define XSYNTH_MONO_MODE_ONCE 2
  33. #define XSYNTH_MONO_MODE_BOTH 3
  34. #define XSYNTH_GLIDE_MODE_LEGATO 0
  35. #define XSYNTH_GLIDE_MODE_INITIAL 1
  36. #define XSYNTH_GLIDE_MODE_ALWAYS 2
  37. #define XSYNTH_GLIDE_MODE_LEFTOVER 3
  38. #define XSYNTH_GLIDE_MODE_OFF 4
  39. /*
  40. * nekobee_synth_t
  41. */
  42. struct _nekobee_synth_t {
  43. /* output */
  44. unsigned long sample_rate;
  45. float deltat; /* 1 / sample_rate */
  46. unsigned long nugget_remains;
  47. /* voice tracking and data */
  48. unsigned int note_id; /* incremented for every new note, used for voice-stealing prioritization */
  49. int polyphony; /* requested polyphony, must be <= XSYNTH_MAX_POLYPHONY */
  50. int voices; /* current polyphony, either requested polyphony above or 1 while in monophonic mode */
  51. int monophonic; /* true if operating in monophonic mode */
  52. int glide; /* current glide mode */
  53. float last_noteon_pitch; /* glide start pitch for non-legato modes */
  54. signed char held_keys[8]; /* for monophonic key tracking, an array of note-ons, most recently received first */
  55. float vcf_accent; /* used to emulate the circuit that sweeps the vcf at full resonance */
  56. float vca_accent; /* used to smooth the accent pulse, removing the click */
  57. //nekobee_voice_t *voice[XSYNTH_MAX_POLYPHONY];
  58. nekobee_voice_t *voice;
  59. pthread_mutex_t voicelist_mutex;
  60. int voicelist_mutex_grab_failed;
  61. /* current non-paramter-mapped controller values */
  62. unsigned char key_pressure[128];
  63. unsigned char cc[128]; /* controller values */
  64. unsigned char channel_pressure;
  65. unsigned char pitch_wheel_sensitivity; /* in semitones */
  66. int pitch_wheel; /* range is -8192 - 8191 */
  67. /* translated controller values */
  68. float mod_wheel; /* filter cutoff multiplier, off = 1.0, full on = 0.0 */
  69. float pitch_bend; /* frequency multiplier, product of wheel setting and sensitivity, center = 1.0 */
  70. float cc_volume; /* volume multiplier, 0.0 to 1.0 */
  71. /* patch parameters */
  72. float tuning;
  73. float waveform;
  74. float cutoff;
  75. float resonance;
  76. float envmod;
  77. float decay;
  78. float accent;
  79. float volume;
  80. };
  81. void nekobee_synth_all_voices_off(nekobee_synth_t *synth);
  82. void nekobee_synth_note_off(nekobee_synth_t *synth, unsigned char key,
  83. unsigned char rvelocity);
  84. void nekobee_synth_all_notes_off(nekobee_synth_t *synth);
  85. void nekobee_synth_note_on(nekobee_synth_t *synth, unsigned char key,
  86. unsigned char velocity);
  87. void nekobee_synth_control_change(nekobee_synth_t *synth, unsigned int param,
  88. signed int value);
  89. void nekobee_synth_init_controls(nekobee_synth_t *synth);
  90. void nekobee_synth_render_voices(nekobee_synth_t *synth, float *out,
  91. unsigned long sample_count,
  92. int do_control_update);
  93. /* these come right out of alsa/asoundef.h */
  94. #define MIDI_CTL_MSB_MODWHEEL 0x01 /**< Modulation */
  95. #define MIDI_CTL_MSB_PORTAMENTO_TIME 0x05 /**< Portamento time */
  96. #define MIDI_CTL_MSB_MAIN_VOLUME 0x07 /**< Main volume */
  97. #define MIDI_CTL_MSB_BALANCE 0x08 /**< Balance */
  98. #define MIDI_CTL_LSB_MODWHEEL 0x21 /**< Modulation */
  99. #define MIDI_CTL_LSB_PORTAMENTO_TIME 0x25 /**< Portamento time */
  100. #define MIDI_CTL_LSB_MAIN_VOLUME 0x27 /**< Main volume */
  101. #define MIDI_CTL_LSB_BALANCE 0x28 /**< Balance */
  102. #define MIDI_CTL_SUSTAIN 0x40 /**< Sustain pedal */
  103. // nekobee defines
  104. #define MIDI_CTL_TUNING 0x4b // impossible
  105. #define MIDI_CTL_WAVEFORM 0x46 // select waveform
  106. #define MIDI_CTL_CUTOFF 0x4a // VCF Cutoff
  107. #define MIDI_CTL_RESONANCE 0x47 // VCF Resonance
  108. #define MIDI_CTL_ENVMOD 0x01 // cheat and use modwheel
  109. #define MIDI_CTL_DECAY 0x48 // Decay time (well release really)
  110. #define MIDI_CTL_ACCENT 0x4c // impossible
  111. #define MIDI_CTL_ALL_SOUNDS_OFF 0x78 /**< All sounds off */
  112. #define MIDI_CTL_RESET_CONTROLLERS 0x79 /**< Reset Controllers */
  113. #define MIDI_CTL_ALL_NOTES_OFF 0x7b /**< All notes off */
  114. #define XSYNTH_SYNTH_SUSTAINED(_s) ((_s)->cc[MIDI_CTL_SUSTAIN] >= 64)
  115. #endif /* _XSYNTH_SYNTH_H */