amuse/lib/AudioGroup.cpp

51 lines
1.6 KiB
C++
Raw Normal View History

#include "amuse/AudioGroup.hpp"
#include "amuse/AudioGroupData.hpp"
namespace amuse
{
2018-07-18 07:39:26 +00:00
void AudioGroup::assign(const AudioGroupData& data)
{
m_proj = AudioGroupProject::CreateAudioGroupProject(data);
m_pool = AudioGroupPool::CreateAudioGroupPool(data);
m_sdir = AudioGroupSampleDirectory::CreateAudioGroupSampleDirectory(data);
m_samp = data.getSamp();
}
void AudioGroup::assign(SystemStringView groupPath)
{
/* Reverse order when loading intermediates */
2018-07-28 04:34:29 +00:00
m_groupPath = groupPath;
2018-07-18 07:39:26 +00:00
m_sdir = AudioGroupSampleDirectory::CreateAudioGroupSampleDirectory(groupPath);
m_pool = AudioGroupPool::CreateAudioGroupPool(groupPath);
m_proj = AudioGroupProject::CreateAudioGroupProject(groupPath);
m_samp = nullptr;
}
2018-07-29 03:37:06 +00:00
const SampleEntry* AudioGroup::getSample(SampleId sfxId) const
{
2016-05-14 22:38:37 +00:00
auto search = m_sdir.m_entries.find(sfxId);
if (search == m_sdir.m_entries.cend())
return nullptr;
2018-07-29 03:37:06 +00:00
return search->second.get();
}
2018-07-29 03:37:06 +00:00
std::pair<ObjToken<SampleEntryData>, const unsigned char*>
AudioGroup::getSampleData(SampleId sfxId, const SampleEntry* sample) const
2018-07-16 07:41:15 +00:00
{
2018-07-29 03:37:06 +00:00
if (sample->m_data->m_looseData)
2018-07-16 07:41:15 +00:00
{
2018-07-28 04:34:29 +00:00
setIdDatabases();
2018-07-16 07:41:15 +00:00
#if _WIN32
SystemString basePath = m_groupPath + _S('/') +
athena::utility::utf8ToWide(SampleId::CurNameDB->resolveNameFromId(sfxId));
#else
SystemString basePath = m_groupPath + _S('/') +
SampleId::CurNameDB->resolveNameFromId(sfxId).data();
#endif
2018-07-29 03:37:06 +00:00
const_cast<SampleEntry*>(sample)->loadLooseData(basePath);
return {sample->m_data, sample->m_data->m_looseData.get()};
2018-07-16 07:41:15 +00:00
}
2018-07-29 03:37:06 +00:00
return {{}, m_samp + sample->m_data->m_sampleOff};
2018-07-16 07:41:15 +00:00
}
}