2 |
* * |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2009 Grigor Iliev * |
* Copyright (C) 2009 - 2011 Grigor Iliev * |
6 |
* * |
* * |
7 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
8 |
* 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 * |
45 |
}; |
}; |
46 |
|
|
47 |
PluginAU::PluginAU(ComponentInstance inComponentInstance) |
PluginAU::PluginAU(ComponentInstance inComponentInstance) |
48 |
: MusicDeviceBase(inComponentInstance, 0, 1), Plugin(false) { |
: MusicDeviceBase(inComponentInstance, 0, 16), Plugin(false) { |
|
|
|
49 |
#if AU_DEBUG_DISPATCHER |
#if AU_DEBUG_DISPATCHER |
50 |
mDebugDispatcher = new AUDebugDispatcher(this); |
mDebugDispatcher = new AUDebugDispatcher(this); |
51 |
#endif |
#endif |
169 |
} |
} |
170 |
|
|
171 |
UInt32 PluginAU::SupportedNumChannels(const AUChannelInfo** outInfo) { |
UInt32 PluginAU::SupportedNumChannels(const AUChannelInfo** outInfo) { |
172 |
static AUChannelInfo plugChannelInfo = { 0, -1 }; |
static AUChannelInfo plugChannelInfo = { 0, 2 }; |
173 |
if (outInfo != NULL) *outInfo = &plugChannelInfo; |
if (outInfo != NULL) *outInfo = &plugChannelInfo; |
174 |
return 1; |
return 1; |
175 |
} |
} |
176 |
|
|
177 |
ComponentResult PluginAU::Initialize() { |
ComponentResult PluginAU::Initialize() { |
178 |
|
// format validation: current LS engines only support stereo |
179 |
|
// buses |
180 |
|
int busCount = Outputs().GetNumberOfElements(); |
181 |
|
for (int i = 0 ; i < busCount ; i++) { |
182 |
|
if (GetOutput(i)->GetStreamFormat().mChannelsPerFrame != 2) { |
183 |
|
return kAudioUnitErr_FormatNotSupported; |
184 |
|
} |
185 |
|
} |
186 |
|
|
187 |
MusicDeviceBase::Initialize(); |
MusicDeviceBase::Initialize(); |
188 |
|
|
189 |
// The timeconsuming tasks delayed until the pluging is to be used |
// The timeconsuming tasks delayed until the plugin is to be used |
190 |
PreInit(); |
PreInit(); |
191 |
|
|
192 |
if(pAudioDevice) { |
if(pAudioDevice) { |
201 |
} |
} |
202 |
|
|
203 |
int srate = (int)GetStreamFormat(kAudioUnitScope_Output, 0).mSampleRate; |
int srate = (int)GetStreamFormat(kAudioUnitScope_Output, 0).mSampleRate; |
204 |
int chnNum = GetStreamFormat(kAudioUnitScope_Output, 0).NumberChannels(); |
int chnNum = 0; |
205 |
|
for (int i = 0 ; i < busCount ; i++) { |
206 |
|
chnNum += GetOutput(i)->GetStreamFormat().mChannelsPerFrame; |
207 |
|
} |
208 |
|
|
209 |
Init(srate, GetMaxFramesPerSlice(), chnNum); |
Init(srate, GetMaxFramesPerSlice(), chnNum); |
210 |
|
|
305 |
const AudioTimeStamp& inTimeStamp, |
const AudioTimeStamp& inTimeStamp, |
306 |
UInt32 inNumberFrames |
UInt32 inNumberFrames |
307 |
) { |
) { |
308 |
float* buf; |
int i = 0; |
309 |
int chnCount = GetOutput(0)->GetBufferList().mNumberBuffers; |
int busCount = Outputs().GetNumberOfElements(); |
310 |
for(int i = 0; i < chnCount; i++) { |
for (int bus = 0 ; bus < busCount ; bus++) { |
311 |
buf = (float*)GetOutput(0)->GetBufferList().mBuffers[i].mData; |
AudioBufferList& list = GetOutput(bus)->PrepareBuffer(inNumberFrames); |
312 |
pAudioDevice->Channel(i)->SetBuffer(buf); |
int chnCount = list.mNumberBuffers; |
313 |
|
for (int chn = 0; chn < chnCount; chn++) { |
314 |
|
float* buf = static_cast<float*>(list.mBuffers[chn].mData); |
315 |
|
pAudioDevice->Channel(i)->SetBuffer(buf); |
316 |
|
i++; |
317 |
|
} |
318 |
} |
} |
319 |
|
|
320 |
pAudioDevice->Render(inNumberFrames); |
pAudioDevice->Render(inNumberFrames); |