3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005-2009 Christian Schoenebeck * |
* Copyright (C) 2005-2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009 Grigor Iliev * |
* Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev * |
8 |
* * |
* * |
9 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
10 |
* 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 * |
36 |
// fully loaded, try to give back instrument again (see bug #113) |
// fully loaded, try to give back instrument again (see bug #113) |
37 |
InstrumentChangeCmd< ::gig::DimensionRegion, ::gig::Instrument>& cmd = ChangeInstrument(NULL); |
InstrumentChangeCmd< ::gig::DimensionRegion, ::gig::Instrument>& cmd = ChangeInstrument(NULL); |
38 |
if (cmd.pInstrument) { |
if (cmd.pInstrument) { |
39 |
InstrumentResourceManager* instrs = dynamic_cast<InstrumentResourceManager*>(pEngine->GetInstrumentManager()); |
Engine::instruments.HandBack(cmd.pInstrument, this); |
|
instrs->HandBack(cmd.pInstrument, this); |
|
40 |
} |
} |
41 |
/////// |
/////// |
42 |
} |
} |
58 |
* @param Program - MIDI program change number |
* @param Program - MIDI program change number |
59 |
*/ |
*/ |
60 |
void EngineChannel::SendProgramChange(uint8_t Program) { |
void EngineChannel::SendProgramChange(uint8_t Program) { |
61 |
|
SetMidiProgram(Program); |
62 |
Engine* engine = dynamic_cast<Engine*>(pEngine); |
Engine* engine = dynamic_cast<Engine*>(pEngine); |
63 |
if(engine == NULL) return; |
if(engine == NULL) return; |
64 |
|
|
65 |
if(engine->GetDiskThread()) { |
if(engine->GetDiskThread()) { |
66 |
engine->GetDiskThread()->OrderProgramChange(Program, this); |
uint32_t merged = (GetMidiBankMsb() << 16) | (GetMidiBankLsb() << 8) | Program; |
67 |
|
engine->GetDiskThread()->OrderProgramChange(merged, this); |
68 |
} else { |
} else { |
69 |
// TODO: |
// TODO: |
70 |
} |
} |
92 |
cmd.pRegionsInUse->clear(); |
cmd.pRegionsInUse->clear(); |
93 |
|
|
94 |
// delete all key groups |
// delete all key groups |
95 |
ActiveKeyGroups.clear(); |
DeleteGroupEventLists(); |
96 |
|
|
97 |
// request gig instrument from instrument manager |
// request gig instrument from instrument manager |
98 |
::gig::Instrument* newInstrument; |
::gig::Instrument* newInstrument; |
105 |
if (!newInstrument) { |
if (!newInstrument) { |
106 |
throw InstrumentManagerException("resource was not created"); |
throw InstrumentManagerException("resource was not created"); |
107 |
} |
} |
108 |
|
|
109 |
|
::gig::Script* script = newInstrument->GetScriptOfSlot(0); |
110 |
|
if (script) { |
111 |
|
String sourceCode = script->GetScriptAsText(); |
112 |
|
loadInstrumentScript(sourceCode); |
113 |
|
} |
114 |
} |
} |
115 |
catch (RIFF::Exception e) { |
catch (RIFF::Exception e) { |
116 |
InstrumentStat = -2; |
InstrumentStat = -2; |
138 |
// counter for each region |
// counter for each region |
139 |
int region = 0; |
int region = 0; |
140 |
for (::gig::Region* pRegion = newInstrument->GetFirstRegion(); pRegion; pRegion = newInstrument->GetNextRegion()) { |
for (::gig::Region* pRegion = newInstrument->GetFirstRegion(); pRegion; pRegion = newInstrument->GetNextRegion()) { |
141 |
if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL; |
AddGroup(pRegion->KeyGroup); |
142 |
|
|
143 |
RoundRobinIndexes[region] = 0; |
RoundRobinIndexes[region] = 0; |
144 |
for (int iKey = pRegion->KeyRange.low; iKey <= pRegion->KeyRange.high; iKey++) { |
for (int iKey = pRegion->KeyRange.low; iKey <= pRegion->KeyRange.high; iKey++) { |
163 |
(pInstrument->DimensionKeyRange.high - pInstrument->DimensionKeyRange.low + 1); |
(pInstrument->DimensionKeyRange.high - pInstrument->DimensionKeyRange.low + 1); |
164 |
} |
} |
165 |
} |
} |
166 |
|
|
167 |
|
String EngineChannel::InstrumentFileName() { |
168 |
|
return EngineChannelBase<Voice, ::gig::DimensionRegion, ::gig::Instrument>::InstrumentFileName(); |
169 |
|
} |
170 |
|
|
171 |
|
String EngineChannel::InstrumentFileName(int index) { |
172 |
|
if (index == 0) return InstrumentFileName(); |
173 |
|
if (!pInstrument || !pInstrument->GetParent()) return ""; |
174 |
|
DLS::File* pMainFile = dynamic_cast<DLS::File*>(pInstrument->GetParent()); |
175 |
|
if (!pMainFile) return ""; |
176 |
|
RIFF::File* pExtensionFile = pMainFile->GetExtensionFile(index); |
177 |
|
return (pExtensionFile) ? pExtensionFile->GetFileName() : ""; |
178 |
|
} |
179 |
|
|
180 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |