Logiciels divers autour du protocole « Open Sound Control » aka OSC
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.

101 lines
2.6 KiB

  1. /*
  2. *
  3. * code semi-grabed from the original asedump.
  4. *
  5. */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <alsa/asoundlib.h>
  9. #include "alsaseq.h"
  10. extern int verbosity;
  11. /* ----------------------------------------------------------------- */
  12. snd_seq_t * create_sequencer(char *name)
  13. {
  14. snd_seq_t *p_seq;
  15. int err;
  16. #if DEBUG_LEVEL
  17. fprintf(stderr, "---> %s ( '%s' )\n", __func__, name);
  18. #endif
  19. /* open sequencer */
  20. err = snd_seq_open(&p_seq, "default", SND_SEQ_OPEN_DUPLEX, 0);
  21. // fprintf(stderr, " seq_open --> %d\n", err);
  22. if (err) {
  23. fprintf(stderr, "%s : open sequencer -% d", __func__, err);
  24. exit(1);
  25. }
  26. /* set our client's name */
  27. err = snd_seq_set_client_name(p_seq, name);
  28. if (err) {
  29. fprintf(stderr, "%s : set client name -% d", __func__, err);
  30. exit(1);
  31. }
  32. return p_seq;
  33. }
  34. /* ----------------------------------------------------------------- */
  35. /* ----------------------------------------------------------------- */
  36. int create_port(snd_seq_t *seq)
  37. {
  38. int err;
  39. #if DEBUG_LEVEL
  40. fprintf(stderr, "---> %s (%p)\n", __func__, seq);
  41. #endif
  42. err = snd_seq_create_simple_port(seq, "kontrol2osc",
  43. SND_SEQ_PORT_CAP_WRITE |
  44. SND_SEQ_PORT_CAP_SUBS_WRITE ,
  45. SND_SEQ_PORT_TYPE_MIDI_GENERIC |
  46. SND_SEQ_PORT_TYPE_APPLICATION );
  47. if (err) {
  48. fprintf(stderr, "%s:%s snd_seq_create_simple_port : err %d\n",
  49. __FILE__, __func__, err);
  50. }
  51. return err;
  52. }
  53. /* ----------------------------------------------------------------- */
  54. void list_ports(snd_seq_t *seq)
  55. {
  56. snd_seq_client_info_t *cinfo;
  57. snd_seq_port_info_t *pinfo;
  58. int client;
  59. snd_seq_client_info_alloca(&cinfo);
  60. snd_seq_port_info_alloca(&pinfo);
  61. puts(" Port Client name Port name");
  62. snd_seq_client_info_set_client(cinfo, -1);
  63. while (snd_seq_query_next_client(seq, cinfo) >= 0) {
  64. client = snd_seq_client_info_get_client(cinfo);
  65. snd_seq_port_info_set_client(pinfo, client);
  66. snd_seq_port_info_set_port(pinfo, -1);
  67. while (snd_seq_query_next_port(seq, pinfo) >= 0) {
  68. /* we need both READ and SUBS_READ */
  69. if ((snd_seq_port_info_get_capability(pinfo)
  70. & (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ))
  71. != (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ))
  72. continue;
  73. printf("%3d:%-3d %-32.32s %s\n",
  74. snd_seq_port_info_get_client(pinfo),
  75. snd_seq_port_info_get_port(pinfo),
  76. snd_seq_client_info_get_name(cinfo),
  77. snd_seq_port_info_get_name(pinfo));
  78. }
  79. }
  80. }
  81. /* ----------------------------------------------------------------- */
  82. /* ----------------------------------------------------------------- */
  83. /* ----------------------------------------------------------------- */