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