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.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. */
  11. #include <unistd.h>
  12. #include <iostream>
  13. #include <string>
  14. #include "LASHClient.h"
  15. namespace zyncarla {
  16. LASHClient::LASHClient(int *argc, char ***argv)
  17. {
  18. client = lash_init(lash_extract_args(argc, argv), "ZynAddSubFX",
  19. LASH_Config_File, LASH_PROTOCOL(2, 0));
  20. }
  21. void LASHClient::setalsaid(int id)
  22. {
  23. if(lash_enabled(client))
  24. if(id != -1)
  25. lash_alsa_client_id(client, id);
  26. }
  27. void LASHClient::setjackname(const char *name)
  28. {
  29. if(lash_enabled(client))
  30. if(name != NULL) {
  31. lash_jack_client_name(client, name);
  32. lash_event_t *event = lash_event_new_with_type(LASH_Client_Name);
  33. lash_event_set_string(event, name);
  34. lash_send_event(client, event);
  35. }
  36. }
  37. LASHClient::Event LASHClient::checkevents(std::string &filename)
  38. {
  39. if(!lash_enabled(client))
  40. return NoEvent;
  41. Event received = NoEvent;
  42. lash_event_t *event;
  43. while((event = lash_get_event(client))) {
  44. // save
  45. if(lash_event_get_type(event) == LASH_Save_File) {
  46. std::cerr << "LASH event: LASH_Save_File" << std::endl;
  47. filename = std::string(lash_event_get_string(event))
  48. + "/master.xmz";
  49. received = Save;
  50. break;
  51. }
  52. // restore
  53. else
  54. if(lash_event_get_type(event) == LASH_Restore_File) {
  55. std::cerr << "LASH event: LASH_Restore_File" << std::endl;
  56. filename = std::string(lash_event_get_string(event))
  57. + "/master.xmz";
  58. received = Restore;
  59. break;
  60. }
  61. // quit
  62. else
  63. if(lash_event_get_type(event) == LASH_Quit) {
  64. std::cerr << "LASH event: LASH_Quit" << std::endl;
  65. received = Quit;
  66. break;
  67. }
  68. lash_event_destroy(event);
  69. }
  70. return received;
  71. }
  72. void LASHClient::confirmevent(Event event)
  73. {
  74. if(event == Save)
  75. lash_send_event(client, lash_event_new_with_type(LASH_Save_File));
  76. else
  77. if(event == Restore)
  78. lash_send_event(client, lash_event_new_with_type(LASH_Restore_File));
  79. }
  80. }