1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2008 - 2009 Andreas Persson * |
* Copyright (C) 2008 - 2011 Andreas Persson * |
4 |
* * |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
87 |
|
|
88 |
int EventThread::Main() { |
int EventThread::Main() { |
89 |
for (;;) { |
for (;;) { |
90 |
|
TestCancel(); |
91 |
sleep(1); |
sleep(1); |
92 |
pSampler->fireStatistics(); |
pSampler->fireStatistics(); |
93 |
} |
} |
174 |
} |
} |
175 |
|
|
176 |
/* |
/* |
177 |
|
These methods can be overloaded by different plugin types to map |
178 |
|
file names to/from file names to be used in the state text, making |
179 |
|
it possible for state to be self-contained and/or movable. |
180 |
|
*/ |
181 |
|
|
182 |
|
String Plugin::PathToState(const String& string) { |
183 |
|
return string; |
184 |
|
} |
185 |
|
|
186 |
|
String Plugin::PathFromState(const String& string) { |
187 |
|
return string; |
188 |
|
} |
189 |
|
|
190 |
|
/* |
191 |
The sampler state is stored in a text base format, designed to |
The sampler state is stored in a text base format, designed to |
192 |
be easy to parse with the istream >> operator. Values are |
be easy to parse with the istream >> operator. Values are |
193 |
separated by spaces or newlines. All string values that may |
separated by spaces or newlines. All string values that may |
233 |
int(iter->first.midi_bank_lsb)) << ' ' << |
int(iter->first.midi_bank_lsb)) << ' ' << |
234 |
int(iter->first.midi_prog) << ' ' << |
int(iter->first.midi_prog) << ' ' << |
235 |
iter->second.EngineName << ' ' << |
iter->second.EngineName << ' ' << |
236 |
iter->second.InstrumentFile << '\n' << |
PathToState(iter->second.InstrumentFile) << '\n' << |
237 |
MIDIMAPPING << ' ' << |
MIDIMAPPING << ' ' << |
238 |
iter->second.InstrumentIndex << ' ' << |
iter->second.InstrumentIndex << ' ' << |
239 |
iter->second.Volume << ' ' << |
iter->second.Volume << ' ' << |
255 |
String filename = engine_channel->InstrumentFileName(); |
String filename = engine_channel->InstrumentFileName(); |
256 |
s << channel->GetMidiInputChannel() << ' ' << |
s << channel->GetMidiInputChannel() << ' ' << |
257 |
engine_channel->Volume() << ' ' << |
engine_channel->Volume() << ' ' << |
258 |
filename << '\n' << |
PathToState(filename) << '\n' << |
259 |
engine_channel->InstrumentIndex() << ' ' << |
engine_channel->InstrumentIndex() << ' ' << |
260 |
engine_channel->GetSolo() << ' ' << |
engine_channel->GetSolo() << ' ' << |
261 |
(engine_channel->GetMute() == 1) << ' ' << |
(engine_channel->GetMute() == 1) << ' ' << |
263 |
engine_channel->OutputChannel(1) << ' ' << |
engine_channel->OutputChannel(1) << ' ' << |
264 |
(engine_channel->UsesNoMidiInstrumentMap() ? -2 : |
(engine_channel->UsesNoMidiInstrumentMap() ? -2 : |
265 |
(engine_channel->UsesDefaultMidiInstrumentMap() ? -1 : |
(engine_channel->UsesDefaultMidiInstrumentMap() ? -1 : |
266 |
engine_channel->GetMidiInstrumentMap())) << '\n'; |
engine_channel->GetMidiInstrumentMap())) << ' ' << |
267 |
|
engine_channel->EngineName() << '\n'; |
268 |
|
|
269 |
for (int i = 0 ; i < engine_channel->GetFxSendCount() ; i++) { |
for (int i = 0 ; i < engine_channel->GetFxSendCount() ; i++) { |
270 |
FxSend* fxsend = engine_channel->GetFxSend(i); |
FxSend* fxsend = engine_channel->GetFxSend(i); |
318 |
bool mute; |
bool mute; |
319 |
s >> index >> solo >> mute; |
s >> index >> solo >> mute; |
320 |
|
|
321 |
|
int left = -1; |
322 |
|
int right; |
323 |
|
int oldMapId; |
324 |
|
String engineType = "gig"; |
325 |
|
if (s.get() == ' ') { |
326 |
|
s >> left >> right >> oldMapId; |
327 |
|
if (s.get() == ' ') { |
328 |
|
s >> engineType; |
329 |
|
// skip rest of line |
330 |
|
s.ignore(std::numeric_limits<int>::max(), '\n'); |
331 |
|
} |
332 |
|
} |
333 |
SamplerChannel* channel = global->pSampler->AddSamplerChannel(); |
SamplerChannel* channel = global->pSampler->AddSamplerChannel(); |
334 |
channel->SetEngineType("gig"); |
channel->SetEngineType(engineType); |
335 |
channel->SetAudioOutputDevice(pAudioDevice); |
channel->SetAudioOutputDevice(pAudioDevice); |
336 |
channel->SetMidiInputDevice(pMidiDevice); |
channel->SetMidiInputDevice(pMidiDevice); |
337 |
channel->SetMidiInputChannel(midi_chan_t(midiChannel)); |
channel->SetMidiInputChannel(midi_chan_t(midiChannel)); |
338 |
|
|
339 |
engine_channel = channel->GetEngineChannel(); |
engine_channel = channel->GetEngineChannel(); |
340 |
engine_channel->Volume(volume); |
engine_channel->Volume(volume); |
341 |
if (s.get() == ' ') { |
|
342 |
int left; |
if (left != -1) { |
|
int right; |
|
|
int oldMapId; |
|
|
s >> left >> right >> oldMapId; |
|
343 |
engine_channel->SetOutputChannel(0, left); |
engine_channel->SetOutputChannel(0, left); |
344 |
engine_channel->SetOutputChannel(1, right); |
engine_channel->SetOutputChannel(1, right); |
345 |
|
|
348 |
} else if (oldMapId >= 0) { |
} else if (oldMapId >= 0) { |
349 |
engine_channel->SetMidiInstrumentMap(oldToNewId[oldMapId]); |
engine_channel->SetMidiInstrumentMap(oldToNewId[oldMapId]); |
350 |
} |
} |
|
// skip rest of line |
|
|
s.ignore(std::numeric_limits<int>::max(), '\n'); |
|
351 |
} |
} |
352 |
if (!filename.empty() && index != -1) { |
if (!filename.empty() && index != -1) { |
353 |
InstrumentManager::instrument_id_t id; |
InstrumentManager::instrument_id_t id; |
354 |
id.FileName = filename; |
id.FileName = PathFromState(filename); |
355 |
id.Index = index; |
id.Index = index; |
356 |
InstrumentManager::LoadInstrumentInBackground(id, engine_channel); |
InstrumentManager::LoadInstrumentInBackground(id, engine_channel); |
357 |
} |
} |