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.

LASHClient.cpp 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. LASHClient.cpp - LASH support
  4. Copyright (C) 2006-2009 Lars Luthman
  5. Author: Lars Luthman
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of version 2 of the GNU General Public License
  8. as published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License (version 2 or later) for more details.
  13. You should have received a copy of the GNU General Public License (version 2)
  14. along with this program; if not, write to the Free Software Foundation,
  15. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #include <unistd.h>
  18. #include <iostream>
  19. #include <string>
  20. #include "LASHClient.h"
  21. LASHClient::LASHClient(int *argc, char ***argv)
  22. {
  23. client = lash_init(lash_extract_args(argc, argv), "ZynAddSubFX",
  24. LASH_Config_File, LASH_PROTOCOL(2, 0));
  25. }
  26. void LASHClient::setalsaid(int id)
  27. {
  28. if(lash_enabled(client))
  29. if(id != -1)
  30. lash_alsa_client_id(client, id);
  31. }
  32. void LASHClient::setjackname(const char *name)
  33. {
  34. if(lash_enabled(client))
  35. if(name != NULL) {
  36. lash_jack_client_name(client, name);
  37. lash_event_t *event = lash_event_new_with_type(LASH_Client_Name);
  38. lash_event_set_string(event, name);
  39. lash_send_event(client, event);
  40. }
  41. }
  42. LASHClient::Event LASHClient::checkevents(std::string &filename)
  43. {
  44. if(!lash_enabled(client))
  45. return NoEvent;
  46. Event received = NoEvent;
  47. lash_event_t *event;
  48. while((event = lash_get_event(client))) {
  49. // save
  50. if(lash_event_get_type(event) == LASH_Save_File) {
  51. std::cerr << "LASH event: LASH_Save_File" << std::endl;
  52. filename = std::string(lash_event_get_string(event))
  53. + "/master.xmz";
  54. received = Save;
  55. break;
  56. }
  57. // restore
  58. else
  59. if(lash_event_get_type(event) == LASH_Restore_File) {
  60. std::cerr << "LASH event: LASH_Restore_File" << std::endl;
  61. filename = std::string(lash_event_get_string(event))
  62. + "/master.xmz";
  63. received = Restore;
  64. break;
  65. }
  66. // quit
  67. else
  68. if(lash_event_get_type(event) == LASH_Quit) {
  69. std::cerr << "LASH event: LASH_Quit" << std::endl;
  70. received = Quit;
  71. break;
  72. }
  73. lash_event_destroy(event);
  74. }
  75. return received;
  76. }
  77. void LASHClient::confirmevent(Event event)
  78. {
  79. if(event == Save)
  80. lash_send_event(client, lash_event_new_with_type(LASH_Save_File));
  81. else
  82. if(event == Restore)
  83. lash_send_event(client, lash_event_new_with_type(LASH_Restore_File));
  84. }