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-2010 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 * |
23 |
***************************************************************************/ |
***************************************************************************/ |
24 |
|
|
25 |
#ifndef __LS_MIDIKEYBOARDMANAGER_H__ |
#ifndef __LS_MIDIKEYBOARDMANAGER_H__ |
26 |
#define __LS_MIDIKEYBOARDMANAGER_H__ |
#define __LS_MIDIKEYBOARDMANAGER_H__ |
27 |
|
|
28 |
#include "Event.h" |
#include "Event.h" |
29 |
#include "Stream.h" |
#include "Stream.h" |
175 |
|
|
176 |
MidiKey* pMIDIKeyInfo; ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key |
MidiKey* pMIDIKeyInfo; ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key |
177 |
Pool<uint>* pActiveKeys; ///< Holds all keys in it's allocation list with active voices. |
Pool<uint>* pActiveKeys; ///< Holds all keys in it's allocation list with active voices. |
|
std::map<uint,uint*> ActiveKeyGroups; ///< Contains active keys (in case they belong to a key group) ordered by key group ID. |
|
178 |
bool SoloMode; ///< in Solo Mode we only play one voice (group) at a time |
bool SoloMode; ///< in Solo Mode we only play one voice (group) at a time |
179 |
int SoloKey; ///< Currently 'active' solo key, that is the key to which the currently sounding voice belongs to (only if SoloMode is enabled) |
int SoloKey; ///< Currently 'active' solo key, that is the key to which the currently sounding voice belongs to (only if SoloMode is enabled) |
180 |
bool SustainPedal; ///< true if sustain pedal is down |
bool SustainPedal; ///< true if sustain pedal is down |
205 |
if (pMIDIKeyInfo) delete[] pMIDIKeyInfo; |
if (pMIDIKeyInfo) delete[] pMIDIKeyInfo; |
206 |
} |
} |
207 |
|
|
208 |
void Reset(){ |
void Reset() { |
209 |
SoloKey = -1; // no solo key active yet |
SoloKey = -1; // no solo key active yet |
210 |
|
|
|
// reset all key groups |
|
|
std::map<uint,uint*>::iterator iter = ActiveKeyGroups.begin(); |
|
|
for (; iter != ActiveKeyGroups.end(); iter++) iter->second = NULL; |
|
|
|
|
211 |
// reset key info |
// reset key info |
212 |
for (uint i = 0; i < 128; i++) pMIDIKeyInfo[i].Reset(); |
for (uint i = 0; i < 128; i++) pMIDIKeyInfo[i].Reset(); |
213 |
|
|
269 |
if (itVoice) { |
if (itVoice) { |
270 |
MidiKey* pKey = &pMIDIKeyInfo[itVoice->MIDIKey]; |
MidiKey* pKey = &pMIDIKeyInfo[itVoice->MIDIKey]; |
271 |
|
|
|
uint keygroup = itVoice->KeyGroup; |
|
|
|
|
272 |
// if the sample and dimension region belong to an |
// if the sample and dimension region belong to an |
273 |
// instrument that is unloaded, tell the disk thread to |
// instrument that is unloaded, tell the disk thread to |
274 |
// release them |
// release them |
280 |
|
|
281 |
// free the voice object |
// free the voice object |
282 |
pKey->pActiveVoices->free(itVoice); |
pKey->pActiveVoices->free(itVoice); |
|
|
|
|
// if member of a key group and no other non-release-trigger |
|
|
// voices left, remove from key group |
|
|
if (keygroup) { |
|
|
RTListVoiceIterator it = pKey->pActiveVoices->first(); |
|
|
RTListVoiceIterator end = pKey->pActiveVoices->end(); |
|
|
for (; it != end ; ++it) { |
|
|
if (it->Type != V::type_release_trigger) break; |
|
|
} |
|
|
if (it == end) { |
|
|
uint** ppKeyGroup = &ActiveKeyGroups[keygroup]; |
|
|
if (*ppKeyGroup == &*pKey->itSelf) *ppKeyGroup = NULL; // remove key from key group |
|
|
} |
|
|
} |
|
283 |
} |
} |
284 |
else std::cerr << "Couldn't release voice! (!itVoice)\n" << std::flush; |
else std::cerr << "Couldn't release voice! (!itVoice)\n" << std::flush; |
285 |
} |
} |
611 |
}; |
}; |
612 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |
613 |
|
|
614 |
#endif /* __LS_MIDIKEYBOARDMANAGER_H__ */ |
#endif /* __LS_MIDIKEYBOARDMANAGER_H__ */ |
|
|
|