Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sound export improvements #278

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions Exporters/ExportSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "Exporters.h"


#define XMA_EXPORT 1
bool GXmaExport = true;


static void SaveSound(const UObject *Obj, void *Data, int DataSize, const char *DefExt)
Expand All @@ -28,7 +28,7 @@ static void SaveSound(const UObject *Obj, void *Data, int DataSize, const char *
else if (!memcmp(Data, "FSB4", 4))
ext = "fsb"; // FMOD sound bank
else if (!memcmp(Data, "MSFC", 4))
ext = "mp3"; // PS3 MP3 codec
ext = "msf"; // PS3 MP3 codec

FArchive *Ar = CreateExportArchive(Obj, EFileArchiveOptions::Default, "%s.%s", Obj->Name, ext);
if (Ar)
Expand All @@ -39,8 +39,6 @@ static void SaveSound(const UObject *Obj, void *Data, int DataSize, const char *
}


#if XMA_EXPORT

static void WriteRiffHeader(FArchive &Ar, int FileLength)
{
assert(!Ar.IsLoading);
Expand Down Expand Up @@ -198,12 +196,10 @@ static bool SaveXMASound(const UObject *Obj, void *Data, int DataSize, const cha
return true;
}

#endif // XMA_EXPORT


void ExportSound(const USound *Snd)
{
SaveSound(Snd, (void*)&Snd->RawData[0], Snd->RawData.Num(), "unk");
SaveSound(Snd, (void*)&Snd->RawData[0], Snd->RawData.Num(), Snd->FileType);
}


Expand All @@ -228,10 +224,9 @@ void ExportSoundNodeWave(const USoundNodeWave *Snd)
{
bulk = &Snd->CompressedXbox360Data;
ext = "x360audio";
#if XMA_EXPORT
if (SaveXMASound(Snd, bulk->BulkData, bulk->ElementCount, "xma")) return;

if (GXmaExport && SaveXMASound(Snd, bulk->BulkData, bulk->ElementCount, "xma")) return;
// else - detect format by data tags, like for PC
#endif
}
else if (Snd->CompressedPS3Data.ElementCount)
{
Expand Down
1 change: 1 addition & 0 deletions Exporters/Exporters.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extern bool GUncook;
extern bool GUseGroups;
extern bool GDontOverwriteFiles;
extern bool GDummyExport;
extern bool GXmaExport;

// forwards
class UObject;
Expand Down
4 changes: 4 additions & 0 deletions UmodelTool/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ UIElement& UISettingsDialog::MakeExportOptions()
]
+ NewControl(UICheckbox, "Export compressed textures to dds format", &Opt.Export.ExportDdsTexture)
]
+ NewControl(UIGroup, "Sound Export")
[
NewControl(UICheckbox, "Export UE3 XMA as RIFF", &Opt.Export.ExportRiffXma)
]
+ NewControl(UICheckbox, "Don't overwrite already exported files", &Opt.Export.DontOverwriteFiles)
;
}
Expand Down
2 changes: 2 additions & 0 deletions UmodelTool/UmodelSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void CExportSettings::Reset()
SaveUncooked = false;
SaveGroups = false;
DontOverwriteFiles = false;
ExportRiffXma = true;
}

void CExportSettings::Apply()
Expand All @@ -149,6 +150,7 @@ void CExportSettings::Apply()
GUncook = SaveUncooked;
GUseGroups = SaveGroups;
GDontOverwriteFiles = DontOverwriteFiles;
GXmaExport = ExportRiffXma;
}

void CSavePackagesSettings::SetPath(const char* path)
Expand Down
2 changes: 2 additions & 0 deletions UmodelTool/UmodelSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ struct CExportSettings
bool SaveUncooked;
bool SaveGroups;
bool DontOverwriteFiles;
bool ExportRiffXma;

BEGIN_PROP_TABLE
PROP_STRING(ExportPath)
Expand All @@ -91,6 +92,7 @@ struct CExportSettings
PROP_BOOL(SaveUncooked)
PROP_BOOL(SaveGroups)
PROP_BOOL(DontOverwriteFiles)
PROP_BOOL(ExportRiffXma)
END_PROP_TABLE

CExportSettings()
Expand Down
2 changes: 1 addition & 1 deletion Unreal/FileSystem/GameFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ char GRootDirectory[MAX_PACKAGE_PATH];

static const char *PackageExtensions[] =
{
"u", "ut2", "utx", "uax", "usx", "ukx",
"u", "ut2", "utx", "uax", "umx", "usx", "ukx",
#if UNREAL3
"upk", "ut3", "xxx", "umap", "udk", "map",
#endif
Expand Down
3 changes: 3 additions & 0 deletions Unreal/GameDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const GameInfo GListOfGames[] = {
#if UNDYING
G("Undying", undying, GAME_Undying),
#endif
#if HP2
G("Harry Potter and the Chamber of Secrets", hp2, GAME_HP2),
#endif
#endif // UNREAL1

// Unreal Engine 2
Expand Down
1 change: 1 addition & 0 deletions Unreal/GameDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#define DEUS_EX 1
#define RUNE 1
#define UNDYING 1
#define HP2 1
#endif

// requires UNREAL25
Expand Down
1 change: 1 addition & 0 deletions Unreal/UnCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ enum EGame

GAME_UE1 = 0x0100000,
GAME_Undying,
GAME_HP2,

GAME_UE2 = 0x0200000,
GAME_UT2,
Expand Down
41 changes: 38 additions & 3 deletions Unreal/UnSound.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,56 @@ class USound : public UObject
{
DECLARE_CLASS(USound, UObject);
public:
FName FileType;
float f2C;
FName f5C;
TLazyArray<byte> RawData;

void Serialize(FArchive &Ar)
{
guard(USound::Serialize);

Super::Serialize(Ar);
Ar << f5C;
Ar << FileType;
#if UT2 || BATTLE_TERR || LOCO
if ((Ar.Game == GAME_UT2 || Ar.Game == GAME_BattleTerr || Ar.Game == GAME_Loco) && Ar.ArLicenseeVer >= 2)
Ar << f2C;
#endif
#if HP2
if (Ar.Game == GAME_HP2)
{
int CoreFlags;
float Duration;
int raw_NumSamples, raw_BitsPerSample, raw_NumChannels, raw_SampleRate;

Ar << CoreFlags;
Ar << Duration;

// These are used for raw EA-XA
Ar << raw_NumSamples << raw_BitsPerSample << raw_NumChannels << raw_SampleRate;

appPrintf("USound %s: raw_NumSamples=%d, raw_BitsPerSample=%d, raw_NumChannels=%d, raw_SampleRate=%d\n",
Name, raw_NumSamples, raw_BitsPerSample, raw_NumChannels, raw_SampleRate);

Ar << RawData;

if (CoreFlags & 128)
{
TLazyArray<byte> LipSyncData;
Ar << LipSyncData;
}
return;
}
#endif

Ar << RawData;

// some hack to support more games ...
if (Ar.Tell() < Ar.GetStopper())
{
appPrintf("USound %s: dropping %d bytes\n", Name, Ar.GetStopper() - Ar.Tell());
DROP_REMAINING_DATA(Ar);
}

unguard;
}
};
Expand Down Expand Up @@ -245,7 +279,8 @@ class USoundWave : public UObject // actual parent is USoundBase


#define REGISTER_SOUND_CLASSES \
REGISTER_CLASS(USound)
REGISTER_CLASS(USound) \
REGISTER_CLASS_ALIAS(USound, UMusic)

#define REGISTER_SOUND_CLASSES_UE3 \
REGISTER_CLASS(USoundNodeWave)
Expand Down