本文整理汇总了C++中shared_ptr::AddMachine方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::AddMachine方法的具体用法?C++ shared_ptr::AddMachine怎么用?C++ shared_ptr::AddMachine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shared_ptr
的用法示例。
在下文中一共展示了shared_ptr::AddMachine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitMachines
void BassCastPimpl::InitMachines()
{
machineStack = new_shared<MachineStack>();
noiseSource = new_shared<NoiseSource>();
bassSource = new_shared<BassSource>();
avSource = new_shared<AvSource>();
resample = new_shared<Resample>();
mixChannels = new_shared<MixChannels>();
mapChannels = new_shared<MapChannels>();
linearFade = new_shared<LinearFade>();
gain = new_shared<Gain>();
noiseSource->SetChannels(setting::encoder_channels);
float ratio = setting::amiga_channel_ratio;
mixChannels->Set(1 - ratio, ratio, 1 - ratio, ratio);
mapChannels->SetOutChannels(setting::encoder_channels);
machineStack->AddMachine(noiseSource);
machineStack->AddMachine(resample);
machineStack->AddMachine(mixChannels);
machineStack->AddMachine(mapChannels);
machineStack->AddMachine(linearFade);
machineStack->AddMachine(gain);
converter.SetSource(machineStack);
}
示例2: ChangeSong
// this is called whenever the song is changed
void BassCastPimpl::ChangeSong()
{
// reset routing
resample->SetEnabled(false);
mixChannels->SetEnabled(false);
linearFade->SetEnabled(false);
SongInfo songInfo;
uint32_t samplerate = setting::encoder_samplerate;
double duration = 0;
for (bool loadSuccess = false; !loadSuccess;)
{
bool bassLoaded = false;
bool avLoaded = false;
GetNextSong(songInfo);
if (exists(songInfo.fileName))
{
// try loading by extension
if (BassSource::CheckExtension(songInfo.fileName))
bassLoaded = bassSource->Load(songInfo.fileName);
else if (AvSource::CheckExtension(songInfo.fileName))
avLoaded = avSource->Load(songInfo.fileName);
// if above failed
if (!bassLoaded && !avLoaded)
bassLoaded = bassSource->Load(songInfo.fileName);
if (!bassLoaded && !avLoaded)
avLoaded = avSource->Load(songInfo.fileName);
}
else
Error("file doesn't exist: %1%"), songInfo.fileName;
if (bassLoaded)
{
machineStack->AddMachine(bassSource, 0);
samplerate = bassSource->Samplerate();
duration = bassSource->Duration();
if (bassSource->IsAmigaModule() && setting::encoder_channels == 2)
mixChannels->SetEnabled(true);
if (songInfo.loopDuration > 0)
{
bassSource->SetLoopDuration(songInfo.loopDuration);
uint64_t const start = (songInfo.loopDuration - 5) * setting::encoder_samplerate;
uint64_t const end = songInfo.loopDuration * setting::encoder_samplerate;
linearFade->Set(start, end, 1, 0);
linearFade->SetEnabled(true);
}
loadSuccess = true;
}
if (avLoaded)
{
machineStack->AddMachine(avSource, 0);
samplerate = avSource->Samplerate();
loadSuccess = true;
}
if (!loadSuccess && songInfo.fileName == setting::error_tune)
{
Log(warning, "no error tune, playing some glorious noise"), songInfo.fileName;
noiseSource->SetDuration(120 * setting::encoder_samplerate);
machineStack->AddMachine(noiseSource, 0);
gain->SetAmp(DbToAmp(-24));
loadSuccess = true;
}
}
Log(info, "duration %1% seconds"), duration;
if (samplerate != setting::encoder_samplerate)
{
resample->Set(samplerate, setting::encoder_samplerate);
resample->SetEnabled(true);
}
// once clipping is working also apply positive gain
gain->SetAmp(DbToAmp(songInfo.gain));
machineStack->UpdateRouting();
string title = create_cast_title(songInfo.artist, songInfo.title);
BASS_Encode_CastSetTitle(encoder, title.c_str(), NULL);
}