dssi_data.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* dssi_data.h - DSSI data
  2. Copyright (C) 2005, 2006 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. #include <stdlib.h>
  32. #include <dlfcn.h>
  33. #include <sys/time.h>
  34. #include <jni.h>
  35. #include <dssi.h>
  36. #include <jack/jack.h>
  37. #include <alsa/asoundlib.h>
  38. #include <alsa/seq.h>
  39. #include <stdio.h>
  40. #include "../classpath/jcl.h"
  41. /* Specify the size of the circular buffer. It only needs to be big
  42. enough to hold the events that happen between jack callbacks (~
  43. 1/40th of a second). */
  44. #define EVENT_BUFFER_SIZE 1024
  45. /* Every DSSI Synthesizer has one of these associated with it. The
  46. Java class sees it as a "long" handle. */
  47. typedef struct
  48. {
  49. /* This is a handle to the dlopen'ed .so file containing the DSSI
  50. synthesizer. */
  51. void *dlhandle;
  52. /* The function to call to get the DSS_Descriptor. */
  53. DSSI_Descriptor_Function fn;
  54. /* The descriptor for this synthesizer. See the dssi.h system
  55. header. */
  56. const DSSI_Descriptor *desc;
  57. /* We currently open a jack client connection for every
  58. synthesizer. */
  59. jack_client_t *jack_client;
  60. /* We currently only handle stereo jack connections. Output from
  61. mono synthesizers is sent to both left and right ports. */
  62. jack_port_t *jack_left_output_port;
  63. jack_port_t *jack_right_output_port;
  64. /* We use a circular buffer to hold MIDI events before processing
  65. them in the jack audio processing callback function. */
  66. snd_seq_event_t midiEventBuffer[EVENT_BUFFER_SIZE];
  67. int midiEventReadIndex;
  68. int midiEventWriteIndex;
  69. /* This is a handle the synthesizers underlying LADSPA structure.
  70. See the ladspa.h system header for details. */
  71. LADSPA_Handle plugin_handle;
  72. /* These are buffers we pass to the DSSI Synthesizer for
  73. filling. */
  74. float *left_buffer;
  75. float *right_buffer;
  76. /* The number of input controls for this synth. */
  77. unsigned control_count;
  78. /* An array of control values, control_count in length. */
  79. LADSPA_Data *control_values;
  80. /* A mapping of MIDI controllers to control values. There are a
  81. maximum of 128 MIDI controllers. */
  82. unsigned control_value_map[128];
  83. /* A mapping of MIDI controllers to LADSPA ports. There are a
  84. maximum of 128 MIDI controllers. */
  85. unsigned control_port_map[128];
  86. /* The sample rate. */
  87. jack_nframes_t sample_rate;
  88. } dssi_data;