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, 2006 Christian Schoenebeck * |
* Copyright (C) 2005 - 2007 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
9 |
* 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 * |
24 |
#include "FxSend.h" |
#include "FxSend.h" |
25 |
|
|
26 |
#include "../drivers/audio/AudioOutputDevice.h" |
#include "../drivers/audio/AudioOutputDevice.h" |
27 |
|
#include "../common/RTMath.h" |
28 |
|
|
29 |
#include <map> |
#include <map> |
30 |
|
|
31 |
namespace LinuxSampler { |
namespace LinuxSampler { |
32 |
|
|
33 |
/* |
FxSend::FxSend(EngineChannel* pEngineChannel, uint8_t MidiCtrl, String Name) throw (Exception) { |
|
FIXME: we create fx send indeces globally for now, although we might |
|
|
want them to be an individual sequence per sampler channel, beside that |
|
|
we don't handle the cases yet where __indexer overflows back to 0 |
|
|
*/ |
|
|
static uint __indexer = 0; |
|
|
|
|
|
FxSend::FxSend(EngineChannel* pEngineChannel, uint8_t MidiCtrl, String Name) { |
|
34 |
this->pEngineChannel = pEngineChannel; |
this->pEngineChannel = pEngineChannel; |
35 |
AudioOutputDevice* pDevice = pEngineChannel->GetAudioOutputDevice(); |
AudioOutputDevice* pDevice = pEngineChannel->GetAudioOutputDevice(); |
36 |
const int iChanOffset = (pDevice) ? pDevice->ChannelCount() - pEngineChannel->Channels() : 0; |
const int iChanOffset = (pDevice) ? pDevice->ChannelCount() - pEngineChannel->Channels() : 0; |
40 |
} |
} |
41 |
MidiFxSendController = MidiCtrl; |
MidiFxSendController = MidiCtrl; |
42 |
sName = Name; |
sName = Name; |
43 |
iId = __indexer; |
|
44 |
__indexer++; |
// create an EngineChannel unique ID for this FxSend instance |
45 |
|
if (!pEngineChannel->GetFxSendCount()) iId = 0; |
46 |
|
else { |
47 |
|
// get the highest existing map ID |
48 |
|
uint highestIndex = 0; |
49 |
|
for (uint i = 0; i < pEngineChannel->GetFxSendCount(); i++) |
50 |
|
highestIndex = RTMath::Max(highestIndex, pEngineChannel->GetFxSend(i)->Id()); |
51 |
|
// check if we reached the index limit |
52 |
|
if (highestIndex + 1 < highestIndex) { |
53 |
|
// search for an unoccupied map ID starting from 0 |
54 |
|
for (uint i = 0; i < highestIndex; i++) { |
55 |
|
bool bOccupied = false; |
56 |
|
for (uint j = 0; j < pEngineChannel->GetFxSendCount(); j++) { |
57 |
|
if (pEngineChannel->GetFxSend(j)->Id() == i) { |
58 |
|
bOccupied = true; |
59 |
|
break; |
60 |
|
} |
61 |
|
} |
62 |
|
if (!bOccupied) { |
63 |
|
iId = i; |
64 |
|
goto __done; |
65 |
|
} |
66 |
|
} |
67 |
|
throw Exception("Internal error: could not find unoccupied FxSend ID."); |
68 |
|
} |
69 |
|
iId = highestIndex + 1; |
70 |
|
} |
71 |
|
__done: |
72 |
|
|
73 |
fLevel = 0.3f; // default FX send level |
fLevel = 0.3f; // default FX send level |
74 |
} |
} |
75 |
|
|