Fixed: Sound CSheetID implementation (part 2) (not tested)
This commit is contained in:
parent
b755bafdae
commit
fe90c89d9a
9 changed files with 17 additions and 27 deletions
|
@ -100,7 +100,7 @@ USource *OnAddSource( const char *name, float x, float y, float z )
|
||||||
/*
|
/*
|
||||||
* Create a source with sound 'name', and set some of its initial properties, if successful
|
* Create a source with sound 'name', and set some of its initial properties, if successful
|
||||||
*/
|
*/
|
||||||
USource *source = AudioMixer->createSource(CSheetId(name));
|
USource *source = AudioMixer->createSource(CSheetId(name, "sound"));
|
||||||
if ( source != NULL )
|
if ( source != NULL )
|
||||||
{
|
{
|
||||||
source->setPos( CVector(x,y,z) );
|
source->setPos( CVector(x,y,z) );
|
||||||
|
@ -161,8 +161,8 @@ int main()
|
||||||
printf( "One is 20 meters ahead, on the right\n" );
|
printf( "One is 20 meters ahead, on the right\n" );
|
||||||
printf( "The other is 5 meters ahead, on the left\n" );
|
printf( "The other is 5 meters ahead, on the left\n" );
|
||||||
getchar();
|
getchar();
|
||||||
USource *src1 = OnAddSource( "beep.sound", 1.0f, 20.0f, 0.0f ); // Beep on the right, 20 meters ahead
|
USource *src1 = OnAddSource( "beep", 1.0f, 20.0f, 0.0f ); // Beep on the right, 20 meters ahead
|
||||||
USource *src2 = OnAddSource( "tuut.sound", -2.0f, 5.0f, 0.0f ); // Tuut on the left, 5 meters ahead
|
USource *src2 = OnAddSource( "tuut", -2.0f, 5.0f, 0.0f ); // Tuut on the left, 5 meters ahead
|
||||||
|
|
||||||
// Second step: we will move the listener ahead
|
// Second step: we will move the listener ahead
|
||||||
printf( "Press ENTER again to start moving the listener\n" );
|
printf( "Press ENTER again to start moving the listener\n" );
|
||||||
|
|
|
@ -1132,7 +1132,7 @@ void CAudioMixerUser::CControledSources::serial(NLMISC::IStream &s)
|
||||||
for (uint i=0; i<size; ++i)
|
for (uint i=0; i<size; ++i)
|
||||||
{
|
{
|
||||||
s.serial(soundName);
|
s.serial(soundName);
|
||||||
SoundNames.push_back(CSheetId(soundName.find(".sound") == std::string::npos ? (soundName + ".sound") : soundName));
|
SoundNames.push_back(CSheetId(soundName, "sound"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -237,7 +237,7 @@ void CComplexSound::serial(NLMISC::IStream &s)
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
s.serial(name);
|
s.serial(name);
|
||||||
_Sounds.push_back(/*CStringMapper::map(name)*/NLMISC::CSheetId(name));
|
_Sounds.push_back(NLMISC::CSheetId(name, "sound"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -246,7 +246,7 @@ void CComplexSound::serial(NLMISC::IStream &s)
|
||||||
s.serial(nb);
|
s.serial(nb);
|
||||||
for (uint i=0; i<nb; ++i)
|
for (uint i=0; i<nb; ++i)
|
||||||
{
|
{
|
||||||
std::string name = /*CStringMapper::unmap(_Sounds[i])*/_Sounds[i].toString();
|
std::string name = _Sounds[i].toString();
|
||||||
s.serial(name);
|
s.serial(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,8 +301,8 @@ void CComplexSound::importForm(const std::string& filename, NLGEORGES::UFormElm&
|
||||||
string soundname;
|
string soundname;
|
||||||
if (psoundsArray->getArrayValue(soundname, i))
|
if (psoundsArray->getArrayValue(soundname, i))
|
||||||
{
|
{
|
||||||
soundname = CFile::getFilenameWithoutExtension(soundname);
|
nlassert(soundname.find(".sound") != std::string::npos);
|
||||||
_Sounds.push_back(NLMISC::CSheetId(soundname)/*CStringMapper::map(soundname)*/);
|
_Sounds.push_back(NLMISC::CSheetId(soundname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,17 +134,7 @@ void CSound::serial(NLMISC::IStream &s)
|
||||||
s.serial(_Direction);
|
s.serial(_Direction);
|
||||||
s.serial(_Looping);
|
s.serial(_Looping);
|
||||||
s.serial(_MaxDist);
|
s.serial(_MaxDist);
|
||||||
if (s.isReading())
|
_Name.serialString(s, "sound");
|
||||||
{
|
|
||||||
std::string name;
|
|
||||||
s.serial(name);
|
|
||||||
_Name = NLMISC::CSheetId(name);//CStringMapper::map(name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string name = _Name.toString();//CStringMapper::unmap(_Name);
|
|
||||||
s.serial(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
nlassert(CGroupControllerRoot::getInstance()); // not sure
|
nlassert(CGroupControllerRoot::getInstance()); // not sure
|
||||||
#if NLSOUND_SHEET_VERSION_BUILT < 2
|
#if NLSOUND_SHEET_VERSION_BUILT < 2
|
||||||
|
@ -171,6 +161,7 @@ void CSound::serial(NLMISC::IStream &s)
|
||||||
void CSound::importForm(const std::string& filename, NLGEORGES::UFormElm& root)
|
void CSound::importForm(const std::string& filename, NLGEORGES::UFormElm& root)
|
||||||
{
|
{
|
||||||
// Name
|
// Name
|
||||||
|
nlassert(filename.find(".sound") != std::string::npos);
|
||||||
_Name = NLMISC::CSheetId(filename);
|
_Name = NLMISC::CSheetId(filename);
|
||||||
|
|
||||||
// InternalConeAngle
|
// InternalConeAngle
|
||||||
|
|
|
@ -41,7 +41,7 @@ void CSoundAnimMarker::play(UAudioMixer* mixer, NL3D::CCluster *cluster, CSoundC
|
||||||
|
|
||||||
for (; first != last; ++first)
|
for (; first != last; ++first)
|
||||||
{
|
{
|
||||||
USource* source = mixer->createSource(NLMISC::CSheetId(*first), true, NULL, NULL, cluster, &context);
|
USource* source = mixer->createSource((*first), true, NULL, NULL, cluster, &context);
|
||||||
if (source != NULL)
|
if (source != NULL)
|
||||||
{
|
{
|
||||||
source->setRelativeGain(context.RelativeGain);
|
source->setRelativeGain(context.RelativeGain);
|
||||||
|
|
|
@ -190,7 +190,7 @@ void CSoundAnimation::load()
|
||||||
throw NLMISC::Exception("Invalid sound animation marker");
|
throw NLMISC::Exception("Invalid sound animation marker");
|
||||||
}
|
}
|
||||||
|
|
||||||
marker->addSound(NLMISC::CSheetId(string(name))/*CStringMapper::map(string(name))*/);
|
marker->addSound(NLMISC::CSheetId(string(name), "sound"));
|
||||||
|
|
||||||
xmlFree ((void*)name);
|
xmlFree ((void*)name);
|
||||||
|
|
||||||
|
|
|
@ -73,13 +73,13 @@ void CStreamFileSound::serial(NLMISC::IStream &s)
|
||||||
|
|
||||||
void CStreamFileSound::setMusicFilePath(const std::string &filePath, bool async, bool loop)
|
void CStreamFileSound::setMusicFilePath(const std::string &filePath, bool async, bool loop)
|
||||||
{
|
{
|
||||||
#if !FINAL_VERSION
|
/*#if !FINAL_VERSION
|
||||||
//_Name = NLMISC::CStringMapper::map(std::string("<MusicChannel:") + NLMISC::CFile::getFilenameWithoutExtension(filePath) + ">");
|
//_Name = NLMISC::CStringMapper::map(std::string("<MusicChannel:") + NLMISC::CFile::getFilenameWithoutExtension(filePath) + ">");
|
||||||
_Name = NLMISC::CSheetId(std::string("<MusicChannel:") + NLMISC::CFile::getFilenameWithoutExtension(filePath) + ">");
|
_Name = NLMISC::CSheetId(std::string("<MusicChannel:") + NLMISC::CFile::getFilenameWithoutExtension(filePath) + ">");
|
||||||
#else
|
#else
|
||||||
//_Name = NLMISC::CStringMapper::map("<MusicChannel>");
|
//_Name = NLMISC::CStringMapper::map("<MusicChannel>");
|
||||||
_Name = NLMISC::CSheetId("<MusicChannel>");
|
#endif*/
|
||||||
#endif
|
_Name = NLMISC::CSheetId("music_channel.sound");
|
||||||
_ConeInnerAngle = NLMISC::Pi * 2;
|
_ConeInnerAngle = NLMISC::Pi * 2;
|
||||||
_ConeOuterAngle = NLMISC::Pi * 2;
|
_ConeOuterAngle = NLMISC::Pi * 2;
|
||||||
_Looping = loop;
|
_Looping = loop;
|
||||||
|
|
|
@ -419,7 +419,7 @@ CClientConfig::CClientConfig()
|
||||||
|
|
||||||
// only force patching under Windows by default
|
// only force patching under Windows by default
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
PatchWanted = false;//true;
|
PatchWanted = true;
|
||||||
#else
|
#else
|
||||||
PatchWanted = false;
|
PatchWanted = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2006,8 +2006,7 @@ public:
|
||||||
virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
|
virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
|
||||||
{
|
{
|
||||||
string sName = getParam(Params, "name");
|
string sName = getParam(Params, "name");
|
||||||
//TStringId id = CStringMapper::map(sName);
|
CSheetId id = CSheetId(sName, "sound");
|
||||||
CSheetId id = CSheetId(sName);
|
|
||||||
if (SoundMngr != NULL)
|
if (SoundMngr != NULL)
|
||||||
SoundMngr->spawnSource(id,CVector(0,0,0));
|
SoundMngr->spawnSource(id,CVector(0,0,0));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue